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.RegistrationGroupInfo;
21 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
22 import org.kuali.student.r2.common.dto.ContextInfo;
23 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
24 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
25 import org.kuali.student.r2.common.exceptions.MissingParameterException;
26 import org.kuali.student.r2.common.exceptions.OperationFailedException;
27 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
28 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
29 import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
30
31 import javax.xml.namespace.QName;
32 import java.util.ArrayList;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36
37
38
39
40
41
42 public class RelatedObjectHelperAOtoRGImpl implements RelatedObjectHelper {
43
44 private CourseOfferingService courseOfferingService;
45
46 @Override
47 public Map<String, String> getRelatedObjectsIdAndState(String activityOfferingId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
48
49 Map<String,String> idsAndStates = new HashMap<String,String>();
50
51 List<RegistrationGroupInfo> registrationGroupInfos = getRegistrationGroupInfosByActivityOfferingId(activityOfferingId, contextInfo);
52
53 if (registrationGroupInfos != null && !registrationGroupInfos.isEmpty()) {
54 for(RegistrationGroupInfo regInfo : registrationGroupInfos) {
55 idsAndStates.put(regInfo.getId(),regInfo.getStateKey());
56 }
57 }
58
59 return idsAndStates;
60 }
61
62 private List<RegistrationGroupInfo> getRegistrationGroupInfosByActivityOfferingId(String activityOfferingId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
63
64 List<RegistrationGroupInfo> registrationGroupInfos = null;
65
66 registrationGroupInfos = getCourseOfferingService().getRegistrationGroupsByActivityOffering(activityOfferingId, contextInfo);
67
68 return registrationGroupInfos;
69 }
70
71 protected CourseOfferingService getCourseOfferingService(){
72 if (courseOfferingService == null){
73 courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
74 }
75 return courseOfferingService;
76 }
77
78
79 }