View Javadoc

1   package org.kuali.student.enrollment.class1.state.impl;
2   
3   import org.kuali.rice.core.api.resourceloader.GlobalResourceLoader;
4   import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
5   import org.kuali.student.enrollment.courseoffering.dto.FormatOfferingInfo;
6   import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
7   import org.kuali.student.r2.common.dto.ContextInfo;
8   import org.kuali.student.r2.common.exceptions.DoesNotExistException;
9   import org.kuali.student.r2.common.exceptions.InvalidParameterException;
10  import org.kuali.student.r2.common.exceptions.MissingParameterException;
11  import org.kuali.student.r2.common.exceptions.OperationFailedException;
12  import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
13  import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
14  import org.kuali.student.r2.core.class1.state.service.RelatedObjectHelper;
15  
16  import javax.xml.namespace.QName;
17  import java.util.HashMap;
18  import java.util.Map;
19  
20  /**
21   * @Version 2.0
22   * @Author Sri komandur@uw.edu
23   */
24  
25  public class RelatedObjectHelperAOtoFOImpl implements RelatedObjectHelper {
26  
27      private CourseOfferingService courseOfferingService;
28  
29      public RelatedObjectHelperAOtoFOImpl() {
30      }
31  
32      @Override
33      public Map<String, String> getRelatedObjectsIdAndState(String activityOfferingId, ContextInfo contextInfo)
34              throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
35          //TODO - FIXME - these are expensive calls to get ids and states (should be done with one DB call using search)
36          Map<String, String> idsAndStatesMap = new HashMap<String, String>();
37  
38          FormatOfferingInfo formatOfferingInfo = getFormatOfferingInfoByActivityOfferingId(activityOfferingId, contextInfo);
39          idsAndStatesMap.put(formatOfferingInfo.getId(), formatOfferingInfo.getStateKey());
40  
41          return idsAndStatesMap;
42      }
43  
44      private FormatOfferingInfo getFormatOfferingInfoByActivityOfferingId(String activityOfferingId, ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException {
45  
46          FormatOfferingInfo formatOfferingInfo = null;
47  
48          ActivityOfferingInfo activityOfferingInfo = getCourseOfferingService().getActivityOffering(activityOfferingId, contextInfo);
49          formatOfferingInfo = getCourseOfferingService().getFormatOffering(activityOfferingInfo.getFormatOfferingId(), contextInfo);
50  
51          return formatOfferingInfo;
52      }
53  
54      protected CourseOfferingService getCourseOfferingService(){
55          if (courseOfferingService == null){
56              courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
57          }
58          return  courseOfferingService;
59      }
60  }