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.CourseOfferingInfo;
21 import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo;
22 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
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.core.class1.state.service.RelatedObjectHelper;
31
32 import javax.xml.namespace.QName;
33 import java.util.HashMap;
34 import java.util.Map;
35
36
37
38
39
40
41 public class RelatedObjectHelperFOtoCOImpl implements RelatedObjectHelper {
42
43 private CourseOfferingService courseOfferingService;
44
45 public RelatedObjectHelperFOtoCOImpl() {
46 }
47
48 @Override
49 public Map<String, String> getRelatedObjectsIdAndState(String formatOfferingId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
50
51 Map<String,String> idsAndState = new HashMap<String, String>();
52 CourseOfferingInfo courseOfferingInfo = getCourseOfferingInfoByFormatOfferingId(formatOfferingId, contextInfo);
53 idsAndState.put(courseOfferingInfo.getId(),courseOfferingInfo.getStateKey());
54 return idsAndState;
55 }
56
57 private CourseOfferingInfo getCourseOfferingInfoByFormatOfferingId(String formatOfferingId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
58
59 CourseOfferingInfo courseOfferingInfo = null;
60
61 FormatOfferingInfo formatOfferingInfo = getCourseOfferingService().getFormatOffering(formatOfferingId, contextInfo);
62 courseOfferingInfo = getCourseOfferingService().getCourseOffering(formatOfferingInfo.getCourseOfferingId(), contextInfo);
63
64 return courseOfferingInfo;
65 }
66
67 protected CourseOfferingService getCourseOfferingService(){
68 if (courseOfferingService == null){
69 courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
70 }
71 return courseOfferingService;
72 }
73 }