1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.enrollment.class1.state.impl;
17
18 import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
19 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
20 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
21 import org.kuali.student.enrollment.courseofferingset.dto.SocInfo;
22 import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService;
23 import org.kuali.student.r2.common.dto.ContextInfo;
24 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
25 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
26 import org.kuali.student.r2.common.exceptions.MissingParameterException;
27 import org.kuali.student.r2.common.exceptions.OperationFailedException;
28 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
29 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
30 import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
31 import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
32
33 import javax.xml.namespace.QName;
34 import java.util.HashMap;
35 import java.util.List;
36 import java.util.Map;
37
38 public class RelatedObjectHelperAOtoSOCImpl implements RelatedObjectHelper {
39
40 private CourseOfferingSetService courseOfferingSetService;
41 private CourseOfferingService courseOfferingService;
42
43 @Override
44 public Map<String, String> getRelatedObjectsIdAndState(String aoId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
45
46 Map<String,String> idsAndState = new HashMap<String, String>();
47 ActivityOfferingInfo aoInfo = getCourseOfferingService().getActivityOffering(aoId,contextInfo);
48 List<String> socIds = getCourseOfferingSetService().getSocIdsByTerm(aoInfo.getTermId(),contextInfo);
49
50 for(String socId : socIds){
51 SocInfo socInfo = getCourseOfferingSetService().getSoc(socId, contextInfo);
52 idsAndState.put(socInfo.getId(), socInfo.getStateKey());
53 }
54 return idsAndState;
55 }
56
57 protected CourseOfferingSetService getCourseOfferingSetService(){
58 if (courseOfferingSetService == null){
59 courseOfferingSetService = (CourseOfferingSetService) GlobalResourceLoader.getService(new QName(CourseOfferingSetServiceConstants.NAMESPACE, CourseOfferingSetServiceConstants.SERVICE_NAME_LOCAL_PART));
60 }
61 return courseOfferingSetService;
62 }
63
64 protected CourseOfferingService getCourseOfferingService(){
65 if (courseOfferingService == null){
66 courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
67 }
68 return courseOfferingService;
69 }
70
71 }