1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.kuali.student.enrollment.class2.courseoffering.service.facade;
18
19 import org.apache.commons.lang.StringUtils;
20 import org.kuali.student.enrollment.courseoffering.dto.ActivityOfferingInfo;
21 import org.kuali.student.enrollment.courseoffering.service.CourseOfferingService;
22 import org.kuali.student.enrollment.courseofferingset.service.CourseOfferingSetService;
23 import org.kuali.student.r2.common.dto.ContextInfo;
24 import org.kuali.student.r2.common.dto.StatusInfo;
25 import org.kuali.student.r2.common.exceptions.OperationFailedException;
26 import org.kuali.student.r2.common.util.constants.CourseOfferingSetServiceConstants;
27 import org.kuali.student.r2.common.util.constants.LuiServiceConstants;
28 import org.kuali.student.r2.core.class1.type.service.TypeService;
29
30 import javax.annotation.Resource;
31
32
33
34
35
36
37 public class CSRServiceFacadeImpl implements CSRServiceFacade {
38 @Resource(name="coService")
39 private CourseOfferingService coService;
40
41 @Resource(name="typeService")
42 private TypeService typeService;
43
44 @Resource(name="socService")
45 private CourseOfferingSetService socService;
46
47 public void setCoService(CourseOfferingService coService) {
48 this.coService = coService;
49 }
50
51 public void setTypeService(TypeService typeService) {
52 this.typeService = typeService;
53 }
54
55 public void setSocService(CourseOfferingSetService socService) {
56 this.socService = socService;
57 }
58
59 @Override
60 public void cancelActivityOffering(String aoId, ContextInfo context) throws Exception {
61 StatusInfo statusInfo = coService.changeActivityOfferingState(aoId, LuiServiceConstants.LUI_AO_STATE_CANCELED_KEY, context);
62 if (!statusInfo.getIsSuccess()){
63 throw new OperationFailedException("Error updating Activity offering state to " + LuiServiceConstants.LUI_AO_STATE_CANCELED_KEY + " " + statusInfo);
64 }
65 }
66
67 @Override
68 public void suspendActivityOffering(String aoId, ContextInfo context) throws Exception {
69 StatusInfo statusInfo = coService.changeActivityOfferingState(aoId, LuiServiceConstants.LUI_AO_STATE_SUSPENDED_KEY, context);
70 if (!statusInfo.getIsSuccess()){
71 throw new OperationFailedException("Error updating Activity offering state to " + LuiServiceConstants.LUI_AO_STATE_SUSPENDED_KEY + " " + statusInfo);
72 }
73 }
74
75 @Override
76 public void reinstateActivityOffering(ActivityOfferingInfo aoInfo, String socState, ContextInfo context) throws Exception {
77
78 if (aoInfo.getScheduleIds() != null && !aoInfo.getScheduleIds().isEmpty()) {
79 if (StringUtils.equals(socState, CourseOfferingSetServiceConstants.PUBLISHED_SOC_STATE_KEY)) {
80 StatusInfo statusInfo = coService.changeActivityOfferingState(aoInfo.getId(), LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY, context);
81 if (!statusInfo.getIsSuccess()){
82 throw new OperationFailedException("Error updating Activity offering state to " + LuiServiceConstants.LUI_AO_STATE_OFFERED_KEY + " " + statusInfo);
83 }
84 } else if (StringUtils.equals(socState, CourseOfferingSetServiceConstants.FINALEDITS_SOC_STATE_KEY) ||
85 StringUtils.equals(socState, CourseOfferingSetServiceConstants.LOCKED_SOC_STATE_KEY)) {
86 StatusInfo statusInfo = coService.changeActivityOfferingState(aoInfo.getId(), LuiServiceConstants.LUI_AO_STATE_APPROVED_KEY, context);
87 if (!statusInfo.getIsSuccess()){
88 throw new OperationFailedException("Error updating Activity offering state to " + LuiServiceConstants.LUI_AO_STATE_APPROVED_KEY + " " + statusInfo);
89 }
90 } else {
91 throw new RuntimeException("Error reinstating Activity offering in SOC " + socState);
92 }
93 } else {
94 StatusInfo statusInfo = coService.changeActivityOfferingState(aoInfo.getId(), LuiServiceConstants.LUI_AO_STATE_DRAFT_KEY, context);
95 if (!statusInfo.getIsSuccess()){
96 throw new OperationFailedException("Error updating Activity offering state to " + LuiServiceConstants.LUI_AO_STATE_DRAFT_KEY + " " + statusInfo);
97 }
98 }
99 }
100 }