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.service.CourseOfferingService;
6   import org.kuali.student.r2.common.dto.ContextInfo;
7   import org.kuali.student.r2.common.dto.StatusInfo;
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.StateHelper;
15  
16  import javax.xml.namespace.QName;
17  
18  /**
19   * @Version 2.0
20   * @Author Sri komandur@uw.edu
21   */
22  public class AOStateHelperImpl implements StateHelper {
23      CourseOfferingService courseOfferingService;
24      public AOStateHelperImpl() {
25      }
26  
27      protected CourseOfferingService getCourseOfferingService(){
28          if (courseOfferingService == null){
29              courseOfferingService = (CourseOfferingService) GlobalResourceLoader.getService(new QName(CourseOfferingServiceConstants.NAMESPACE, CourseOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
30          }
31          return  courseOfferingService;
32      }
33  
34      @Override
35      public StatusInfo updateState(String id, String nextStateKey, ContextInfo contextInfo) {
36          StatusInfo si = null;
37          try {
38              si = getCourseOfferingService().changeActivityOfferingState(id, nextStateKey, contextInfo);
39              si.setSuccess(true);
40          } catch (Exception e) {
41              si.setSuccess(false);
42          }
43          return si;
44      }
45  
46      @Override
47      public String getStateKey(String entityId, ContextInfo context) throws InvalidParameterException, MissingParameterException, DoesNotExistException, OperationFailedException, PermissionDeniedException {
48          ActivityOfferingInfo ao = getCourseOfferingService().getActivityOffering(entityId, context);
49          return ao.getStateKey();
50      }
51  }