From 4afa72cffe3ec7fb38f356d4f80a51f8d3457ae8 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Fri, 10 Feb 2023 14:56:14 -0500 Subject: [PATCH 1/2] feat(Peer Group): Add endpoints to retrieve peer group annotations #209 --- .../dao/annotation/wise5/AnnotationDao.java | 25 +++--- .../wise5/impl/HibernateAnnotationDao.java | 8 ++ .../AbstractPeerGroupAPIController.java | 29 +++++++ .../PeerGroupAnnotationsAPIController.java | 79 +++++++++++++++++++ .../peergroup/PeerGroupWorkAPIController.java | 31 +------- .../service/peergroup/PeerGroupService.java | 4 + .../peergroup/impl/PeerGroupServiceImpl.java | 10 +++ 7 files changed, 149 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/wise/portal/presentation/web/controllers/peergroup/AbstractPeerGroupAPIController.java create mode 100644 src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java diff --git a/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java b/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java index d295218ed..b47388042 100644 --- a/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java +++ b/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java @@ -2,6 +2,7 @@ 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.annotation.wise5.Annotation; @@ -16,17 +17,21 @@ */ public interface AnnotationDao extends SimpleDao { - /** - * @return List of Annotations that match the specified parameters - */ - List getAnnotationsByParams(Integer id, Run run, Group period, - Workgroup fromWorkgroup, Workgroup toWorkgroup, String nodeId, String componentId, - StudentWork studentWork, String localNotebookItemId, NotebookItem notebookItem, String type); + /** + * @return List of Annotations that match the specified parameters + */ + List getAnnotationsByParams(Integer id, Run run, Group period, + Workgroup fromWorkgroup, Workgroup toWorkgroup, String nodeId, String componentId, + StudentWork studentWork, String localNotebookItemId, NotebookItem notebookItem, + String type); - List getAnnotations(Run run, String nodeId, String componentId); + List getAnnotations(Run run, String nodeId, String componentId); - List getAnnotations(Run run, Group period, String nodeId, String componentId); + List getAnnotations(Run run, Group period, String nodeId, String componentId); - List getAnnotationsToWorkgroups(Set workgroups, String nodeId, - String componentId); + List getAnnotationsToWorkgroups(Set workgroups, String nodeId, + String componentId); + + List getAnnotations(PeerGroup peerGroup, String nodeId, String componentId, + List teacherWorkgroups); } diff --git a/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java b/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java index f4f37aca2..e369b2114 100644 --- a/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java +++ b/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java @@ -18,6 +18,7 @@ import org.wise.portal.dao.impl.AbstractHibernateDao; import org.wise.portal.domain.group.Group; import org.wise.portal.domain.group.impl.PersistentGroup; +import org.wise.portal.domain.peergroup.PeerGroup; import org.wise.portal.domain.run.Run; import org.wise.portal.domain.run.impl.RunImpl; import org.wise.portal.domain.workgroup.Workgroup; @@ -130,4 +131,11 @@ public List getAnnotationsToWorkgroups(Set workgroups, St TypedQuery query = entityManager.createQuery(cq); return (List) query.getResultList(); } + + public List getAnnotations(PeerGroup peerGroup, String nodeId, String componentId, + List teacherWorkgroups) { + Set workgroups = peerGroup.getMembers(); + workgroups.addAll(teacherWorkgroups); + return getAnnotationsToWorkgroups(workgroups, nodeId, componentId); + } } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/AbstractPeerGroupAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/AbstractPeerGroupAPIController.java new file mode 100644 index 000000000..22a468bef --- /dev/null +++ b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/AbstractPeerGroupAPIController.java @@ -0,0 +1,29 @@ +package org.wise.portal.presentation.web.controllers.peergroup; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.Authentication; +import org.wise.portal.domain.peergroup.PeerGroup; +import org.wise.portal.domain.user.User; +import org.wise.portal.service.peergroup.PeerGroupService; +import org.wise.portal.service.peergrouping.PeerGroupingService; +import org.wise.portal.service.run.RunService; +import org.wise.portal.service.user.UserService; + +abstract class AbstractPeerGroupAPIController { + @Autowired + protected PeerGroupingService peerGroupingService; + + @Autowired + protected PeerGroupService peerGroupService; + + @Autowired + protected RunService runService; + + @Autowired + protected UserService userService; + + protected boolean isUserInPeerGroup(PeerGroup peerGroup, Authentication auth) { + User user = userService.retrieveUserByUsername(auth.getName()); + return peerGroup.isMember(user); + } +} diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java new file mode 100644 index 000000000..df527fad2 --- /dev/null +++ b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java @@ -0,0 +1,79 @@ +package org.wise.portal.presentation.web.controllers.peergroup; + +import java.util.ArrayList; +import java.util.List; + +import org.json.JSONException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.access.annotation.Secured; +import org.springframework.security.core.Authentication; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +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.run.Run; +import org.wise.portal.domain.run.impl.RunImpl; +import org.wise.portal.domain.user.User; +import org.wise.portal.domain.workgroup.Workgroup; +import org.wise.portal.domain.workgroup.impl.WorkgroupImpl; +import org.wise.portal.service.peergroup.PeerGroupCreationException; +import org.wise.portal.service.peergrouping.PeerGroupingNotFoundException; +import org.wise.portal.service.workgroup.WorkgroupService; +import org.wise.vle.domain.annotation.wise5.Annotation; + +@RestController +@Secured("ROLE_USER") +@RequestMapping("/api/peer-group") +public class PeerGroupAnnotationsAPIController extends AbstractPeerGroupAPIController { + @Autowired + private WorkgroupService workgroupService; + + @GetMapping("/{peerGroupId}/{nodeId}/{componentId}/annotations") + List getPeerGroupAnnotations(@PathVariable("peerGroupId") PeerGroupImpl peerGroup, + @PathVariable String nodeId, @PathVariable String componentId, Authentication auth) { + if (isUserInPeerGroup(peerGroup, auth)) { + List teacherWorkgroups = getTeacherWorkgroups( + peerGroup.getPeerGrouping().getRun()); + return peerGroupService.getStudentAnnotations(peerGroup, nodeId, componentId, + teacherWorkgroups); + } else { + throw new AccessDeniedException("Not permitted"); + } + } + + @Secured("ROLE_TEACHER") + @GetMapping("/{runId}/{workgroupId}/{nodeId}/{componentId}/annotations") + List getPeerGroupAnnotations(@PathVariable("runId") RunImpl run, + @PathVariable("workgroupId") WorkgroupImpl workgroup, @PathVariable String nodeId, + @PathVariable String componentId, Authentication auth) + throws JSONException, PeerGroupingNotFoundException, PeerGroupCreationException { + User user = userService.retrieveUserByUsername(auth.getName()); + if (runService.isAllowedToViewStudentWork(run, user)) { + PeerGrouping peerGrouping = peerGroupingService.getByComponent(run, nodeId, componentId); + PeerGroup peerGroup = peerGroupService.getPeerGroup(workgroup, peerGrouping); + List teacherWorkgroups = getTeacherWorkgroups(run); + return peerGroupService.getStudentAnnotations(peerGroup, nodeId, componentId, + teacherWorkgroups); + } else { + throw new AccessDeniedException("Not permitted"); + } + } + + List getTeacherWorkgroups(Run run) { + List teacherWorkgroups = new ArrayList(); + User runOwner = run.getOwner(); + List workgroupsForRunOwner = workgroupService.getWorkgroupListByRunAndUser(run, + runOwner); + teacherWorkgroups.addAll(workgroupsForRunOwner); + for (User sharedOwner : run.getSharedowners()) { + List sharedTeacherWorkgroups = workgroupService.getWorkgroupListByRunAndUser(run, + sharedOwner); + teacherWorkgroups.addAll(sharedTeacherWorkgroups); + } + return teacherWorkgroups; + } +} diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupWorkAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupWorkAPIController.java index 89a808565..af49ed89c 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupWorkAPIController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupWorkAPIController.java @@ -3,7 +3,6 @@ import java.util.List; import org.json.JSONException; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.AccessDeniedException; import org.springframework.security.access.annotation.Secured; import org.springframework.security.core.Authentication; @@ -18,29 +17,13 @@ import org.wise.portal.domain.user.User; import org.wise.portal.domain.workgroup.impl.WorkgroupImpl; import org.wise.portal.service.peergroup.PeerGroupCreationException; -import org.wise.portal.service.peergroup.PeerGroupService; import org.wise.portal.service.peergrouping.PeerGroupingNotFoundException; -import org.wise.portal.service.peergrouping.PeerGroupingService; -import org.wise.portal.service.run.RunService; -import org.wise.portal.service.user.UserService; import org.wise.vle.domain.work.StudentWork; @RestController @Secured("ROLE_USER") @RequestMapping("/api/peer-group") -public class PeerGroupWorkAPIController { - - @Autowired - private PeerGroupingService peerGroupingService; - - @Autowired - private PeerGroupService peerGroupService; - - @Autowired - private RunService runService; - - @Autowired - private UserService userService; +public class PeerGroupWorkAPIController extends AbstractPeerGroupAPIController { @GetMapping("/{peerGroupId}/{nodeId}/{componentId}/student-work") List getPeerGroupWork(@PathVariable("peerGroupId") PeerGroupImpl peerGroup, @@ -52,21 +35,15 @@ List getPeerGroupWork(@PathVariable("peerGroupId") PeerGroupImpl pe } } - private boolean isUserInPeerGroup(PeerGroup peerGroup, Authentication auth) { - User user = userService.retrieveUserByUsername(auth.getName()); - return peerGroup.isMember(user); - } - @Secured("ROLE_TEACHER") @GetMapping("/{runId}/{workgroupId}/{nodeId}/{componentId}/student-work") List getPeerGroupWork(@PathVariable("runId") RunImpl run, - @PathVariable("workgroupId") WorkgroupImpl workgroup, - @PathVariable String nodeId, @PathVariable String componentId, Authentication auth) + @PathVariable("workgroupId") WorkgroupImpl workgroup, @PathVariable String nodeId, + @PathVariable String componentId, Authentication auth) throws JSONException, PeerGroupingNotFoundException, PeerGroupCreationException { User user = userService.retrieveUserByUsername(auth.getName()); if (runService.isAllowedToViewStudentWork(run, user)) { - PeerGrouping peerGrouping = peerGroupingService.getByComponent(run, nodeId, - componentId); + PeerGrouping peerGrouping = peerGroupingService.getByComponent(run, nodeId, componentId); PeerGroup peerGroup = peerGroupService.getPeerGroup(workgroup, peerGrouping); return peerGroupService.getStudentWork(peerGroup, nodeId, componentId); } else { diff --git a/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java b/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java index 86edcb275..573276ccb 100644 --- a/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java +++ b/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java @@ -29,6 +29,7 @@ import org.wise.portal.domain.peergroup.PeerGroup; import org.wise.portal.domain.peergrouping.PeerGrouping; import org.wise.portal.domain.workgroup.Workgroup; +import org.wise.vle.domain.annotation.wise5.Annotation; import org.wise.vle.domain.work.StudentWork; public interface PeerGroupService { @@ -67,4 +68,7 @@ PeerGroup getPeerGroup(Workgroup workgroup, PeerGrouping peerGrouping) * @return List of StudentWork by members in the PeerGroup for the component */ public List getStudentWork(PeerGroup peerGroup, String nodeId, String componentId); + + public List getStudentAnnotations(PeerGroup peerGroup, String nodeId, + String componentId, List teacherWorkgroups); } diff --git a/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java b/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java index 3297f0130..10a22c10f 100644 --- a/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java +++ b/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.wise.portal.dao.ObjectNotFoundException; +import org.wise.portal.dao.annotation.wise5.AnnotationDao; import org.wise.portal.dao.peergroup.PeerGroupDao; import org.wise.portal.dao.work.StudentWorkDao; import org.wise.portal.domain.peergroup.PeerGroup; @@ -42,11 +43,15 @@ import org.wise.portal.service.peergrouping.logic.impl.DifferentIdeasLogicServiceImpl; import org.wise.portal.service.peergrouping.logic.impl.DifferentKIScoresLogicServiceImpl; import org.wise.portal.service.peergrouping.logic.impl.RandomLogicServiceImpl; +import org.wise.vle.domain.annotation.wise5.Annotation; import org.wise.vle.domain.work.StudentWork; @Service public class PeerGroupServiceImpl implements PeerGroupService { + @Autowired + private AnnotationDao annotationDao; + @Autowired private DifferentIdeasLogicServiceImpl differentIdeasLogicService; @@ -113,4 +118,9 @@ public List getPeerGroups(PeerGrouping peerGrouping) { public List getStudentWork(PeerGroup peerGroup, String nodeId, String componentId) { return studentWorkDao.getStudentWork(peerGroup, nodeId, componentId); } + + public List getStudentAnnotations(PeerGroup peerGroup, String nodeId, + String componentId, List teacherWorkgroups) { + return annotationDao.getAnnotations(peerGroup, nodeId, componentId, teacherWorkgroups); + } } From 3b2f571087880d5aa346c70391b2de41516b9c56 Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Tue, 14 Feb 2023 12:24:57 -0500 Subject: [PATCH 2/2] refactor(Peer Group): Call getAnnotationsToWorkgroups() directly #209 --- .../dao/annotation/wise5/AnnotationDao.java | 25 +++---- .../wise5/impl/HibernateAnnotationDao.java | 8 --- .../PeerGroupAnnotationsAPIController.java | 18 +++-- .../service/peergroup/PeerGroupService.java | 66 +++++++++---------- .../peergroup/impl/PeerGroupServiceImpl.java | 10 --- .../service/vle/wise5/AnnotationService.java | 3 + .../vle/wise5/impl/AnnotationServiceImpl.java | 5 ++ 7 files changed, 60 insertions(+), 75 deletions(-) diff --git a/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java b/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java index b47388042..d295218ed 100644 --- a/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java +++ b/src/main/java/org/wise/portal/dao/annotation/wise5/AnnotationDao.java @@ -2,7 +2,6 @@ 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.annotation.wise5.Annotation; @@ -17,21 +16,17 @@ */ public interface AnnotationDao extends SimpleDao { - /** - * @return List of Annotations that match the specified parameters - */ - List getAnnotationsByParams(Integer id, Run run, Group period, - Workgroup fromWorkgroup, Workgroup toWorkgroup, String nodeId, String componentId, - StudentWork studentWork, String localNotebookItemId, NotebookItem notebookItem, - String type); + /** + * @return List of Annotations that match the specified parameters + */ + List getAnnotationsByParams(Integer id, Run run, Group period, + Workgroup fromWorkgroup, Workgroup toWorkgroup, String nodeId, String componentId, + StudentWork studentWork, String localNotebookItemId, NotebookItem notebookItem, String type); - List getAnnotations(Run run, String nodeId, String componentId); + List getAnnotations(Run run, String nodeId, String componentId); - List getAnnotations(Run run, Group period, String nodeId, String componentId); + List getAnnotations(Run run, Group period, String nodeId, String componentId); - List getAnnotationsToWorkgroups(Set workgroups, String nodeId, - String componentId); - - List getAnnotations(PeerGroup peerGroup, String nodeId, String componentId, - List teacherWorkgroups); + List getAnnotationsToWorkgroups(Set workgroups, String nodeId, + String componentId); } diff --git a/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java b/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java index e369b2114..f4f37aca2 100644 --- a/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java +++ b/src/main/java/org/wise/portal/dao/annotation/wise5/impl/HibernateAnnotationDao.java @@ -18,7 +18,6 @@ import org.wise.portal.dao.impl.AbstractHibernateDao; import org.wise.portal.domain.group.Group; import org.wise.portal.domain.group.impl.PersistentGroup; -import org.wise.portal.domain.peergroup.PeerGroup; import org.wise.portal.domain.run.Run; import org.wise.portal.domain.run.impl.RunImpl; import org.wise.portal.domain.workgroup.Workgroup; @@ -131,11 +130,4 @@ public List getAnnotationsToWorkgroups(Set workgroups, St TypedQuery query = entityManager.createQuery(cq); return (List) query.getResultList(); } - - public List getAnnotations(PeerGroup peerGroup, String nodeId, String componentId, - List teacherWorkgroups) { - Set workgroups = peerGroup.getMembers(); - workgroups.addAll(teacherWorkgroups); - return getAnnotationsToWorkgroups(workgroups, nodeId, componentId); - } } diff --git a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java index df527fad2..7adfa353a 100644 --- a/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java +++ b/src/main/java/org/wise/portal/presentation/web/controllers/peergroup/PeerGroupAnnotationsAPIController.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Set; import org.json.JSONException; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +23,7 @@ import org.wise.portal.domain.workgroup.impl.WorkgroupImpl; import org.wise.portal.service.peergroup.PeerGroupCreationException; import org.wise.portal.service.peergrouping.PeerGroupingNotFoundException; +import org.wise.portal.service.vle.wise5.AnnotationService; import org.wise.portal.service.workgroup.WorkgroupService; import org.wise.vle.domain.annotation.wise5.Annotation; @@ -29,6 +31,9 @@ @Secured("ROLE_USER") @RequestMapping("/api/peer-group") public class PeerGroupAnnotationsAPIController extends AbstractPeerGroupAPIController { + @Autowired + private AnnotationService annotationService; + @Autowired private WorkgroupService workgroupService; @@ -36,10 +41,9 @@ public class PeerGroupAnnotationsAPIController extends AbstractPeerGroupAPIContr List getPeerGroupAnnotations(@PathVariable("peerGroupId") PeerGroupImpl peerGroup, @PathVariable String nodeId, @PathVariable String componentId, Authentication auth) { if (isUserInPeerGroup(peerGroup, auth)) { - List teacherWorkgroups = getTeacherWorkgroups( - peerGroup.getPeerGrouping().getRun()); - return peerGroupService.getStudentAnnotations(peerGroup, nodeId, componentId, - teacherWorkgroups); + Set workgroups = peerGroup.getMembers(); + workgroups.addAll(getTeacherWorkgroups(peerGroup.getPeerGrouping().getRun())); + return annotationService.getAnnotationsToWorkgroups(workgroups, nodeId, componentId); } else { throw new AccessDeniedException("Not permitted"); } @@ -55,9 +59,9 @@ List getPeerGroupAnnotations(@PathVariable("runId") RunImpl run, if (runService.isAllowedToViewStudentWork(run, user)) { PeerGrouping peerGrouping = peerGroupingService.getByComponent(run, nodeId, componentId); PeerGroup peerGroup = peerGroupService.getPeerGroup(workgroup, peerGrouping); - List teacherWorkgroups = getTeacherWorkgroups(run); - return peerGroupService.getStudentAnnotations(peerGroup, nodeId, componentId, - teacherWorkgroups); + Set workgroups = peerGroup.getMembers(); + workgroups.addAll(getTeacherWorkgroups(run)); + return annotationService.getAnnotationsToWorkgroups(workgroups, nodeId, componentId); } else { throw new AccessDeniedException("Not permitted"); } diff --git a/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java b/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java index 573276ccb..50e6013a6 100644 --- a/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java +++ b/src/main/java/org/wise/portal/service/peergroup/PeerGroupService.java @@ -29,46 +29,42 @@ import org.wise.portal.domain.peergroup.PeerGroup; import org.wise.portal.domain.peergrouping.PeerGrouping; import org.wise.portal.domain.workgroup.Workgroup; -import org.wise.vle.domain.annotation.wise5.Annotation; import org.wise.vle.domain.work.StudentWork; public interface PeerGroupService { - /** - * Gets the PeerGroup with the specified id - * @param id Long PeerGroup's id - * @return matched PeerGroup - * @throws ObjectNotFoundException when PeerGroup with the given id is not found - */ - public PeerGroup getById(Long id) throws ObjectNotFoundException; + /** + * Gets the PeerGroup with the specified id + * @param id Long PeerGroup's id + * @return matched PeerGroup + * @throws ObjectNotFoundException when PeerGroup with the given id is not found + */ + public PeerGroup getById(Long id) throws ObjectNotFoundException; - /** - * Gets a PeerGroup for the specified workgroup and PeerGrouping if a PeerGroup - * does not exist, create one. - * - * @param workgroup Workgroup to get/create the PeerGroup for - * @param peerGrouping PeerGrouping to get/create the PeerGroup for - * @return PeerGroup for the specified workgroup and PeerGrouping - * @throws PeerGroupCreationException the PeerGroup cannot be created for other reasons - * like an error occurred while grouping members - */ - PeerGroup getPeerGroup(Workgroup workgroup, PeerGrouping peerGrouping) - throws PeerGroupCreationException; + /** + * Gets a PeerGroup for the specified workgroup and PeerGrouping if a PeerGroup + * does not exist, create one. + * + * @param workgroup Workgroup to get/create the PeerGroup for + * @param peerGrouping PeerGrouping to get/create the PeerGroup for + * @return PeerGroup for the specified workgroup and PeerGrouping + * @throws PeerGroupCreationException the PeerGroup cannot be created for other reasons + * like an error occurred while grouping members + */ + PeerGroup getPeerGroup(Workgroup workgroup, PeerGrouping peerGrouping) + throws PeerGroupCreationException; - /** - * Gets all the PeerGroups for the specified PeerGrouping - * @param peerGrouping PeerGrouping the PeerGroups works on - * @return PeerGroups that work on the specified PeerGrouping - */ - List getPeerGroups(PeerGrouping peerGrouping); + /** + * Gets all the PeerGroups for the specified PeerGrouping + * @param peerGrouping PeerGrouping the PeerGroups works on + * @return PeerGroups that work on the specified PeerGrouping + */ + List getPeerGroups(PeerGrouping peerGrouping); - /** - * Gets StudentWork for the component from all the members in the PeerGroup - * @param peerGroup group of workgroups in the PeerGroup - * @return List of StudentWork by members in the PeerGroup for the component - */ - public List getStudentWork(PeerGroup peerGroup, String nodeId, String componentId); - - public List getStudentAnnotations(PeerGroup peerGroup, String nodeId, - String componentId, List teacherWorkgroups); + /** + * Gets StudentWork for the component from all the members in the PeerGroup + * @param peerGroup group of workgroups in the PeerGroup + * @return List of StudentWork by members in the PeerGroup for the component + */ + public List getStudentWork(PeerGroup peerGroup, String nodeId, String componentId); } diff --git a/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java b/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java index 10a22c10f..3297f0130 100644 --- a/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java +++ b/src/main/java/org/wise/portal/service/peergroup/impl/PeerGroupServiceImpl.java @@ -29,7 +29,6 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.wise.portal.dao.ObjectNotFoundException; -import org.wise.portal.dao.annotation.wise5.AnnotationDao; import org.wise.portal.dao.peergroup.PeerGroupDao; import org.wise.portal.dao.work.StudentWorkDao; import org.wise.portal.domain.peergroup.PeerGroup; @@ -43,15 +42,11 @@ import org.wise.portal.service.peergrouping.logic.impl.DifferentIdeasLogicServiceImpl; import org.wise.portal.service.peergrouping.logic.impl.DifferentKIScoresLogicServiceImpl; import org.wise.portal.service.peergrouping.logic.impl.RandomLogicServiceImpl; -import org.wise.vle.domain.annotation.wise5.Annotation; import org.wise.vle.domain.work.StudentWork; @Service public class PeerGroupServiceImpl implements PeerGroupService { - @Autowired - private AnnotationDao annotationDao; - @Autowired private DifferentIdeasLogicServiceImpl differentIdeasLogicService; @@ -118,9 +113,4 @@ public List getPeerGroups(PeerGrouping peerGrouping) { public List getStudentWork(PeerGroup peerGroup, String nodeId, String componentId) { return studentWorkDao.getStudentWork(peerGroup, nodeId, componentId); } - - public List getStudentAnnotations(PeerGroup peerGroup, String nodeId, - String componentId, List teacherWorkgroups) { - return annotationDao.getAnnotations(peerGroup, nodeId, componentId, teacherWorkgroups); - } } diff --git a/src/main/java/org/wise/portal/service/vle/wise5/AnnotationService.java b/src/main/java/org/wise/portal/service/vle/wise5/AnnotationService.java index 72b274b69..e710758ed 100644 --- a/src/main/java/org/wise/portal/service/vle/wise5/AnnotationService.java +++ b/src/main/java/org/wise/portal/service/vle/wise5/AnnotationService.java @@ -13,4 +13,7 @@ public interface AnnotationService { */ List getLatest(Set workgroups, String nodeId, String componentId, String type); + + List getAnnotationsToWorkgroups(Set workgroups, String nodeId, + String componentId); } diff --git a/src/main/java/org/wise/portal/service/vle/wise5/impl/AnnotationServiceImpl.java b/src/main/java/org/wise/portal/service/vle/wise5/impl/AnnotationServiceImpl.java index 2de47d9bf..b24cc7095 100644 --- a/src/main/java/org/wise/portal/service/vle/wise5/impl/AnnotationServiceImpl.java +++ b/src/main/java/org/wise/portal/service/vle/wise5/impl/AnnotationServiceImpl.java @@ -31,4 +31,9 @@ public List getLatest(Set workgroups, String nodeId, Stri } return new ArrayList(workgroupToAnnotation.values()); } + + public List getAnnotationsToWorkgroups(Set workgroups, String nodeId, + String componentId) { + return annotationDao.getAnnotationsToWorkgroups(workgroups, nodeId, componentId); + } }