1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class1.state.impl;
18
19 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
20 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
21 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
22 import org.kuali.student.enrollment.examoffering.dto.ExamOfferingInfo;
23 import org.kuali.student.enrollment.examoffering.dto.ExamOfferingRelationInfo;
24 import org.kuali.student.enrollment.examoffering.service.ExamOfferingService;
25 import org.kuali.student.r2.common.dto.ContextInfo;
26 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
27 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
28 import org.kuali.student.r2.common.exceptions.MissingParameterException;
29 import org.kuali.student.r2.common.exceptions.OperationFailedException;
30 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
31 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
32 import org.kuali.student.r2.common.util.constants.ExamOfferingServiceConstants;
33 import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
34
35 import javax.xml.namespace.QName;
36 import java.util.ArrayList;
37 import java.util.HashMap;
38 import java.util.List;
39 import java.util.Map;
40
41
42
43
44
45
46
47 public class RelatedObjectHelperEOtoAOImpl implements RelatedObjectHelper {
48 private ExamOfferingService examOfferingService;
49 private CourseOfferingService courseOfferingService;
50
51 public RelatedObjectHelperEOtoAOImpl() {
52 }
53
54 @Override
55 public Map<String, String> getRelatedObjectsIdAndState(String examOfferingId, ContextInfo contextInfo)
56 throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
57
58 Map<String, String> idsAndStatesMap = new HashMap<String, String>();
59 List<ExamOfferingRelationInfo> eoRelations = this.getExamOfferingService().getExamOfferingRelationsByExamOffering(examOfferingId, contextInfo);
60 if(eoRelations==null || eoRelations.isEmpty()){
61 return idsAndStatesMap;
62 }
63
64 List<String> activityOfferingIds = new ArrayList<String>();
65
66 for(ExamOfferingRelationInfo eoRelation : eoRelations){
67 activityOfferingIds.addAll(eoRelation.getActivityOfferingIds());
68 }
69
70 if (activityOfferingIds!=null && !activityOfferingIds.isEmpty()) {
71 List<ActivityOfferingInfo> aoInfoList = getCourseOfferingService().getActivityOfferingsByIds(activityOfferingIds,contextInfo);
72 for(ActivityOfferingInfo activityOfferingInfo : aoInfoList) {
73 idsAndStatesMap.put(activityOfferingInfo.getId(),activityOfferingInfo.getStateKey());
74 }
75 }
76
77 return idsAndStatesMap;
78 }
79
80 protected ExamOfferingService getExamOfferingService(){
81 if (examOfferingService == null){
82 examOfferingService = (ExamOfferingService) GlobalResourceLoader.getService(new QName(ExamOfferingServiceConstants.NAMESPACE, ExamOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
83 }
84 return examOfferingService;
85 }
86
87 protected CourseOfferingService getCourseOfferingService(){
88 if (courseOfferingService == null){
89 courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
90 }
91 return courseOfferingService;
92 }
93 }