Skip to content

Commit

Permalink
feat(Peer Group): Add support for Peer Group activities (#111)
Browse files Browse the repository at this point in the history
* Create domain objects and dao's for PeerGroup #38 (#39)
Requires creating new tables in the database (see wise_db_init.sql).
Domain objects include PeerGroupActivity and PeerGroup.
Add unit tests.
* feat(Peer Interaction): Add service method to get PeerGroupActivity (#41)
- Add PeerGroupActivityService and getByComponent() method to return
PeerGroupActivity for a specific component.
- Add supporting classes (ProjectContent, ProjectNode, ProjectComponent)
to parse the project JSON.
- PeerGroupActivityNotFoundException is thrown if a PeerGroupActivity
for the component cannot be found in the database and curriculum
content.
* feat(Peer Group): Add service method to get/create PeerGroup #42 (#43)
- Assumes PeerGrouping logic looks at the same nodeId/componentId
- Extracted common hibernate/service test methods to parent.
* feat(Peer Group): Add endpoint for getting Peer Group (#45)
* feat(Peer Group): Add endpoint to get PeerGroup
- Ensure there are at least 2 submissions before pairing
* feat(Peer Group): Add endpoint to get PeerGroup
- Threshold not met now throws an exception instead of returning null.
- Throws PeerGroupCreationException when there are other workgroups
to wait for.
- Fix issue calculating completion percentage by using float instead
of int.
* feat(Peer Group): Add endpoint to get PeerGroup
- Add id equality test to WorkgroupImpl and PersistentGroup
- Changed getNumWorkgroupsInPeerGroup() to get PeerGroup for activity
component instead of logic component
- Return exception key in ResponseBody
* feat(Peer Group): Add endpoint to get StudentWork for PeerGroup (#48)
- Also change URL to get PeerGroup to
  /{runId}/{workgroupId}/{nodeId}/{componentId}
* feat(Peer Group): Add teacher endpoint to get work for peer group (#50)
* refactor(Peer Group): Move PeerGroupWork api to new class
* feat(Peer Group): Add teacher endpoint to get work for PeerGroup
- Extract common test methods to AbstractPeerGroupAPIControllerTest
* feat(Peer Group): Make PeerGroup with remaining students (#53)
- When maxMembershipCount + 1 students have not been pair yet, and
everybody else have completed the logic activity, we put them all
into the same peer group.
- Also updated code to ensure that we only look for workgroups
in the same period when pairing students into PeerGroups.
* feat(Peer Group): Add teacher endpoint to get PeerGroup info for activity (#58)
* feat(Peer Group): Add teacher endpoint to get PeerGroups for activity
Requires database change: add periodId bigint field to peer_groups table
Closes #57
* feat(PeerGroup): Add teacher endpoint to get PeerGroup info
- url: /api/teacher/peer-group-info returns a Map of PeerGroups and
workgroups that don't belong in PeerGroups for the specified
PeerGroupActivity
* Remove PeerGroupActivity from PeerGroup serialization #57
* Exclude HibernateStudentAttendaceDao unit test
This test has been known to be finicky, so we decided to exclude from
running until we can find time to look into the root cause.
* feat(Get Classmate Work): Create endpoint for Peer Chat other work (#63)
The other work is the work from a previous component that is shown at the top of the Peer Chat component.
Closes #62
* feat(Peer-Chat): Add endpoint to get latest student work for other
component
* test(Peer-Chat): Fix PeerChatDataControllerTest
* feat(Peer-Group): Add teacher endpoint to create peer group
* feat(Group): Add GroupRepository
* feat(PeerGroup): Add teacher endpoint for creating PeerGroup
- Needed to edit APIControllerTest to use the PersistentGroup class type
  now that we are using DomainConverter to directly pass in objects
  instead of Long
* feat(PeerGroup): Add teacher endpoint for creating PeerGroup
- Ensure that requested period is in requested run.
- Modified test's period name to distinguish from other periods
* feat(Peer-Group): Add teacher endpoint to add member to peer group
* feat(Group): Add GroupRepository
* feat(PeerGroup): Add teacher endpoint for creating PeerGroup
- Needed to edit APIControllerTest to use the PersistentGroup class type
  now that we are using DomainConverter to directly pass in objects
  instead of Long
* feat(Peer-Chat): Add endpoint to add member to PeerGroup
- Added PeerGroupRepository to convert PeerGroupId PathVariables to
  PeerGroup objects and updated tests to use impl classes.
* feat(Peer-Chat): Add endpoint to add member to PeerGroup
- Don't allow addMember if requested workgroup does not belong in the
  run.
* fix(Test): Fix a test that was not compiling
* feat(Peer Group): Add ability to get manually assigned peer group (#77)
* feat(Peer Group): Add ability to get manually assigned peer group
If a Peer Activity uses auto assignment and a Peer Group is requested
and the Peer Group does not exist, it will automatically be created.
If a Peer Activity uses manual assignment and a Peer Group is requested
and the Peer Group does not exist, it will not be automatically created.
* refactor(PeerGroup): Change PeerGroupServiceHelperTest to extend WISEServiceTest
- Renamed PeerGroupServiceHelperTest to PeerGroupServiceTest
* feat(PeerGroup): Add teacher endpoint to remove member from PeerGroup
* Merge branch: 'get-peer-group-by-tag' into issue-37-peer-interaction
* feat(PeerGroup): Add endpoint to get by Tag
* feat(PeerGroup): Create PeerGroupActivity from tag in project
When a peerGroupActivityTag is added in the project in the authoring tool
or if a new run is created from the project that contains the tag,
PeerGroupActivities are created for each tag.
* refactor(PeerGroup): Use PeerGroupActivityTag to get PeerGroup (#96)
* refactor(PeerGroup): Use PeerGroupActivityTag to get PeerGroup
- Switch to using the new PeerGroupActivityTag to lookup the
PeerGroupActrivity instead of nodeId/componentId.
- Add tag column to db init sql
- Clean up code
* Remove unused exceptions
* feat(PeerChat): Group students randomly (#94)
* feat(PeerChat): Group students randomly
* Improve addMembersRandomly efficiency
Removed randomly chosen members from future consideration.
* Optimize addMembersRandomly method
* refactor(PeerGroup): Pass in domain objects to controllers (#99)
* feat(PeerChat): Allow teacher participation
- Add endpoint at /api/teacher/run/{runId}/work for teachers to POST work
- Add PeerGroupId to StudentWork (requires db update, see below)
* refactor(PeerGroupActivity): Remove nodeId and componentId fields
- Remove nodeId, componentId fields from PeerGroupActivity
- Set PeerGroupActivity.logic field's default value to [{"name":"manual"}]
- Remove PeerGroupActivityDao.getByComponent()
* feat(Peer Group Activity): Move settings to project level (#108)
* refactor(PeerGroupActivityDao): Remove getByComponent()
Layers above should now be using getByTag() to look up the
PeerGroupActivity.
* refactor(PeerGroupActivityImpl): Remove nodeId, componentId fields
Also set logic field's default value to [{"name":"manual"}]
* Remove nodeId/componentId fields from db init sql
* refactor(PeerGroupActivity): Change logic field from JSON array to string (#107)
Instead of expressing the logic entirely in the logic field, use the
logic field to only store a string from the following: "manual",
"random", "custom".
* feat(Peer Group Activity): Move settings to project-level
- Introduce new "peerGroupActivity" project level field, an array to store
PeerGroupActivities in the unit
* refactor(Peer Group API): Remove getPeerGroup by component (#110)
- This API endpoint has been replaced by getting PeerGroup by Tag
* feat(Peer Group Settings): Add endpoint to create and edit (#113)
* feat(ACL): Add support for parsing permission string
* feat(Peer Group Settings): Add endpoint to create/edit
* feat(Peer Group Settings): Remove scan for tags on project save
* chore(Peer Grouping): Rename Peer Group Activity to Peer Grouping (#115)
* fix(PeerGrouping): Random pairing (#120)
- Also remove completion requirement before pairing
- Fix tests
* fix(Peer Grouping): Create run with Peer Groupings with correct fields (#121)
* fix(Peer Grouping): Return bad request when creating duplicate tag
* fix(PeerGroup): Don't pair with empty workgroups
* fix(Peer Group): Don't count empty workgroups when check if can create
  • Loading branch information
hirokiterashima authored May 13, 2022
1 parent db20551 commit a800bea
Show file tree
Hide file tree
Showing 94 changed files with 5,051 additions and 345 deletions.
11 changes: 11 additions & 0 deletions src/main/java/org/wise/portal/dao/group/GroupRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.wise.portal.dao.group;

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.wise.portal.domain.group.impl.PersistentGroup;

/**
* @author Hiroki Terashima
*/
@Repository
public interface GroupRepository extends PagingAndSortingRepository<PersistentGroup, Long> {}
45 changes: 45 additions & 0 deletions src/main/java/org/wise/portal/dao/peergroup/PeerGroupDao.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2008-2021 Regents of the University of California (Regents).
* Created by WISE, Graduate School of Education, University of California, Berkeley.
*
* This software is distributed under the GNU General Public License, v3,
* or (at your option) any later version.
*
* Permission is hereby granted, without written agreement and without license
* or royalty fees, to use, copy, modify, and distribute this software and its
* documentation for any purpose, provided that the above copyright notice and
* the following two paragraphs appear in all copies of this software.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
* HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.wise.portal.dao.peergroup;

import java.util.List;
import org.wise.portal.dao.SimpleDao;
import org.wise.portal.domain.group.Group;
import org.wise.portal.domain.peergroup.PeerGroup;
import org.wise.portal.domain.peergrouping.PeerGrouping;
import org.wise.portal.domain.workgroup.Workgroup;

/**
* @author Hiroki Terashima
*/
public interface PeerGroupDao<T extends PeerGroup> extends SimpleDao<T> {

PeerGroup getByWorkgroupAndPeerGrouping(Workgroup workgroup, PeerGrouping peerGrouping);

List<PeerGroup> getListByPeerGrouping(PeerGrouping peerGrouping);

List<PeerGroup> getListByWorkgroup(Workgroup workgroup);

List<Workgroup> getWorkgroupsInPeerGroup(PeerGrouping peerGrouping, Group period);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.wise.portal.dao.peergroup;

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.wise.portal.domain.peergroup.impl.PeerGroupImpl;

/**
* @author Hiroki Terashima
*/
@Repository
public interface PeerGroupRepository extends PagingAndSortingRepository<PeerGroupImpl, Long> {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/**
* Copyright (c) 2008-2021 Regents of the University of California (Regents).
* Created by WISE, Graduate School of Education, University of California, Berkeley.
*
* This software is distributed under the GNU General Public License, v3,
* or (at your option) any later version.
*
* Permission is hereby granted, without written agreement and without license
* or royalty fees, to use, copy, modify, and distribute this software and its
* documentation for any purpose, provided that the above copyright notice and
* the following two paragraphs appear in all copies of this software.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
* HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.wise.portal.dao.peergroup.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import org.wise.portal.dao.impl.AbstractHibernateDao;
import org.wise.portal.dao.peergroup.PeerGroupDao;
import org.wise.portal.domain.group.Group;
import org.wise.portal.domain.peergroup.PeerGroup;
import org.wise.portal.domain.peergroup.impl.PeerGroupImpl;
import org.wise.portal.domain.peergrouping.PeerGrouping;
import org.wise.portal.domain.peergrouping.impl.PeerGroupingImpl;
import org.wise.portal.domain.run.Run;
import org.wise.portal.domain.workgroup.Workgroup;
import org.wise.portal.domain.workgroup.impl.WorkgroupImpl;

/**
* @author Hiroki Terashima
*/
@Repository
public class HibernatePeerGroupDao extends AbstractHibernateDao<PeerGroup>
implements PeerGroupDao<PeerGroup> {

@PersistenceContext
private EntityManager entityManager;

@Override
protected String getFindAllQuery() {
return "from PeerGroupImpl";
}

@Override
protected Class<? extends PeerGroup> getDataObjectClass() {
return PeerGroupImpl.class;
}

@Override
public PeerGroup getByWorkgroupAndPeerGrouping(Workgroup workgroup, PeerGrouping peerGrouping) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<PeerGroupImpl> cq = cb.createQuery(PeerGroupImpl.class);
Root<PeerGroupImpl> peerGroupImplRoot = cq.from(PeerGroupImpl.class);
Root<WorkgroupImpl> workgroupImplRoot = cq.from(WorkgroupImpl.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(workgroupImplRoot.get("id"), workgroup.getId()));
predicates.add(cb.equal(peerGroupImplRoot.get("peerGrouping"),
peerGrouping.getId()));
predicates.add(cb.isMember(workgroupImplRoot.get("id"),
peerGroupImplRoot.<Set<Workgroup>>get("members")));
cq.select(peerGroupImplRoot).where(predicates.toArray(new Predicate[predicates.size()]));
TypedQuery<PeerGroupImpl> query = entityManager.createQuery(cq);
return (PeerGroup) query.getResultStream().findFirst().orElse(null);
}


@Override
public List<PeerGroup> getListByPeerGrouping(PeerGrouping peerGrouping) {
return getListByTag(peerGrouping.getRun(), peerGrouping.getTag());
}

private List<PeerGroup> getListByTag(Run run, String tag) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<PeerGroupImpl> cq = cb.createQuery(PeerGroupImpl.class);
Root<PeerGroupImpl> peerGroupImplRoot = cq.from(PeerGroupImpl.class);
Root<PeerGroupingImpl> peerGroupingImplRoot = cq.from(PeerGroupingImpl.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(peerGroupingImplRoot.get("run"), run.getId()));
predicates.add(cb.equal(peerGroupingImplRoot.get("tag"), tag));
predicates.add(cb.equal(peerGroupImplRoot.get("peerGrouping"),
peerGroupingImplRoot.get("id")));
cq.select(peerGroupImplRoot).where(predicates.toArray(new Predicate[predicates.size()]));
TypedQuery<PeerGroupImpl> query = entityManager.createQuery(cq);
List<PeerGroupImpl> resultList = query.getResultList();
return (List<PeerGroup>) (Object) resultList;
}

@Override
@SuppressWarnings("unchecked")
public List<PeerGroup> getListByWorkgroup(Workgroup workgroup) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<PeerGroupImpl> cq = cb.createQuery(PeerGroupImpl.class);
Root<PeerGroupImpl> peerGroupImplRoot = cq.from(PeerGroupImpl.class);
Root<WorkgroupImpl> workgroupImplRoot = cq.from(WorkgroupImpl.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(workgroupImplRoot.get("id"), workgroup.getId()));
predicates.add(cb.isMember(workgroupImplRoot.get("id"),
peerGroupImplRoot.<Set<Workgroup>>get("members")));
cq.select(peerGroupImplRoot).where(predicates.toArray(new Predicate[predicates.size()]));
TypedQuery<PeerGroupImpl> query = entityManager.createQuery(cq);
List<PeerGroupImpl> resultList = query.getResultList();
return (List<PeerGroup>) (Object) resultList;
}

@Override
@SuppressWarnings("unchecked")
public List<Workgroup> getWorkgroupsInPeerGroup(PeerGrouping peerGrouping, Group period) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<WorkgroupImpl> cq = cb.createQuery(WorkgroupImpl.class);
Root<PeerGroupImpl> peerGroupImplRoot = cq.from(PeerGroupImpl.class);
Root<WorkgroupImpl> workgroupImplRoot = cq.from(WorkgroupImpl.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(peerGroupImplRoot.get("peerGrouping"),
peerGrouping.getId()));
predicates.add(cb.equal(workgroupImplRoot.get("period"), period.getId()));
predicates.add(cb.isMember(workgroupImplRoot.get("id"),
peerGroupImplRoot.<Set<Workgroup>>get("members")));
cq.select(workgroupImplRoot).where(predicates.toArray(new Predicate[predicates.size()]));
TypedQuery<WorkgroupImpl> query = entityManager.createQuery(cq);
List<WorkgroupImpl> resultList = query.getResultList();
return (List<Workgroup>) (Object) resultList;
}

private CriteriaBuilder getCriteriaBuilder() {
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
return session.getCriteriaBuilder();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2008-2021 Regents of the University of California (Regents).
* Created by WISE, Graduate School of Education, University of California, Berkeley.
*
* This software is distributed under the GNU General Public License, v3,
* or (at your option) any later version.
*
* Permission is hereby granted, without written agreement and without license
* or royalty fees, to use, copy, modify, and distribute this software and its
* documentation for any purpose, provided that the above copyright notice and
* the following two paragraphs appear in all copies of this software.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
* HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.wise.portal.dao.peergrouping;

import org.wise.portal.dao.SimpleDao;
import org.wise.portal.domain.peergrouping.PeerGrouping;
import org.wise.portal.domain.run.Run;

/**
* @author Hiroki Terashima
*/
public interface PeerGroupingDao<T extends PeerGrouping> extends SimpleDao<T> {

PeerGrouping getByTag(Run run, String tag);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* Copyright (c) 2008-2021 Regents of the University of California (Regents).
* Created by WISE, Graduate School of Education, University of California, Berkeley.
*
* This software is distributed under the GNU General Public License, v3,
* or (at your option) any later version.
*
* Permission is hereby granted, without written agreement and without license
* or royalty fees, to use, copy, modify, and distribute this software and its
* documentation for any purpose, provided that the above copyright notice and
* the following two paragraphs appear in all copies of this software.
*
* REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
* HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
* IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
* REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.wise.portal.dao.peergrouping.impl;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;

import org.hibernate.Session;
import org.springframework.stereotype.Repository;
import org.wise.portal.dao.impl.AbstractHibernateDao;
import org.wise.portal.dao.peergrouping.PeerGroupingDao;
import org.wise.portal.domain.peergrouping.PeerGrouping;
import org.wise.portal.domain.peergrouping.impl.PeerGroupingImpl;
import org.wise.portal.domain.run.Run;

/**
* @author Hiroki Terashima
*/
@Repository
public class HibernatePeerGroupingDao extends AbstractHibernateDao<PeerGrouping>
implements PeerGroupingDao<PeerGrouping> {

@PersistenceContext
private EntityManager entityManager;

@Override
protected String getFindAllQuery() {
return "from PeerGroupingImpl";
}

@Override
protected Class<? extends PeerGrouping> getDataObjectClass() {
return PeerGroupingImpl.class;
}

@Override
public PeerGrouping getByTag(Run run, String tag) {
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<PeerGroupingImpl> cq = cb.createQuery(PeerGroupingImpl.class);
Root<PeerGroupingImpl> peerGroupingImplRoot = cq.from(PeerGroupingImpl.class);
List<Predicate> predicates = new ArrayList<>();
predicates.add(cb.equal(peerGroupingImplRoot.get("run"), run.getId()));
predicates.add(cb.equal(peerGroupingImplRoot.get("tag"), tag));
cq.select(peerGroupingImplRoot).where(predicates.toArray(new Predicate[predicates.size()]));
TypedQuery<PeerGroupingImpl> query = entityManager.createQuery(cq);
return (PeerGroupingImpl) query.getResultStream().findFirst().orElse(null);
}

private CriteriaBuilder getCriteriaBuilder() {
Session session = this.getHibernateTemplate().getSessionFactory().getCurrentSession();
return session.getCriteriaBuilder();
}
}
18 changes: 15 additions & 3 deletions src/main/java/org/wise/portal/dao/work/StudentWorkDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@
*/
package org.wise.portal.dao.work;

import java.util.List;
import java.util.Set;

import org.json.JSONObject;
import org.wise.portal.dao.SimpleDao;
import org.wise.portal.domain.group.Group;
import org.wise.portal.domain.peergroup.PeerGroup;
import org.wise.portal.domain.run.Run;
import org.wise.portal.domain.workgroup.Workgroup;
import org.wise.vle.domain.work.StudentWork;

import java.util.List;

/**
* Domain Access Object for StudentWork
*
*
* @author Hiroki Terashima
*/
public interface StudentWorkDao<T extends StudentWork> extends SimpleDao<T> {
Expand All @@ -43,7 +45,17 @@ List<StudentWork> getStudentWorkListByParams(Integer id, Run run, Group period,
Workgroup workgroup, Boolean isAutoSave, Boolean isSubmit, String nodeId, String componentId,
String componentType, List<JSONObject> components);

List<StudentWork> getWorkForComponentByWorkgroup(Workgroup workgroup, String nodeId,
String componentId);

List<StudentWork> getWorkForComponentByPeriod(Run run, Group period, String nodeId,
String componentId);

List<StudentWork> getStudentWork(Run run, String nodeId, String componentId);

List<StudentWork> getStudentWork(Run run, Group period, String nodeId, String componentId);

List<StudentWork> getStudentWork(PeerGroup peerGroup, String nodeId, String componentId);

List<StudentWork> getStudentWork(Set<Workgroup> workgroups, String nodeId, String componentId);
}
Loading

0 comments on commit a800bea

Please sign in to comment.