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.service.CourseOfferingSetService;
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.common.util.constants.CourseOfferingSetServiceConstants;
30 import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
31
32 import javax.xml.namespace.QName;
33 import java.util.HashMap;
34 import java.util.List;
35 import java.util.Map;
36
37 public class RelatedObjectHelperSOCtoAOImpl implements RelatedObjectHelper {
38
39 private CourseOfferingSetService courseOfferingSetService;
40 private CourseOfferingService courseOfferingService;
41
42 @Override
43 public Map<String, String> getRelatedObjectsIdAndState(String socId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
44
45 Map<String,String> idsAndState = new HashMap<String, String>();
46 List<String> coIds = getCourseOfferingSetService().getCourseOfferingIdsBySoc(socId, contextInfo);
47 for (String coId : coIds) {
48 List<ActivityOfferingInfo> activityOfferings = getCourseOfferingService().getActivityOfferingsByCourseOffering(coId, contextInfo);
49 for (ActivityOfferingInfo ao : activityOfferings) {
50 idsAndState.put(ao.getId(),ao.getStateKey());
51 }
52 }
53 return idsAndState;
54 }
55
56 protected CourseOfferingSetService getCourseOfferingSetService(){
57 if (courseOfferingSetService == null){
58 courseOfferingSetService = (CourseOfferingSetService) GlobalResourceLoader.getService(new QName(CourseOfferingSetServiceConstants.NAMESPACE, CourseOfferingSetServiceConstants.SERVICE_NAME_LOCAL_PART));
59 }
60 return courseOfferingSetService;
61 }
62
63 protected CourseOfferingService getCourseOfferingService(){
64 if (courseOfferingService == null){
65 courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
66 }
67 return courseOfferingService;
68 }
69
70 }