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.enrollment.examoffering.dto.ExamOfferingInfo;
7 import org.kuali.student.enrollment.examoffering.service.ExamOfferingService;
8 import org.kuali.student.r2.common.dto.ContextInfo;
9 import org.kuali.student.r2.common.dto.StatusInfo;
10 import org.kuali.student.r2.common.exceptions.DoesNotExistException;
11 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
12 import org.kuali.student.r2.common.exceptions.MissingParameterException;
13 import org.kuali.student.r2.common.exceptions.OperationFailedException;
14 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
15 import org.kuali.student.r2.common.util.constants.CourseOfferingServiceConstants;
16 import org.kuali.student.r2.common.util.constants.ExamOfferingServiceConstants;
17 import org.kuali.student.r2.core.class1.state.service.StateHelper;
18
19 import javax.xml.namespace.QName;
20
21
22
23
24
25 public class EOStateHelperImpl implements StateHelper {
26 ExamOfferingService examOfferingService;
27 public EOStateHelperImpl() {
28 }
29
30 protected ExamOfferingService getExamOfferingService(){
31 if (examOfferingService == null){
32 examOfferingService = (ExamOfferingService) GlobalResourceLoader.getService(new QName(ExamOfferingServiceConstants.NAMESPACE, ExamOfferingServiceConstants.SERVICE_NAME_LOCAL_PART));
33 }
34 return examOfferingService;
35 }
36
37 @Override
38 public StatusInfo updateState(String id, String nextStateKey, ContextInfo contextInfo) {
39 StatusInfo si = null;
40 try {
41 si = getExamOfferingService().changeExamOfferingState(id, nextStateKey, contextInfo);
42 si.setSuccess(true);
43 } catch (Exception e) {
44 si.setSuccess(false);
45 }
46 return si;
47 }
48
49 @Override
50 public String getStateKey(String entityId, ContextInfo context) throws InvalidParameterException, MissingParameterException, DoesNotExistException, OperationFailedException, PermissionDeniedException {
51 ExamOfferingInfo eo = getExamOfferingService().getExamOffering(entityId, context);
52 return eo.getStateKey();
53 }
54 }