1 |
|
package org.kuali.student.lum.program.server; |
2 |
|
|
3 |
|
import java.util.List; |
4 |
|
|
5 |
|
import org.kuali.student.common.dto.DtoConstants; |
6 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
7 |
|
import org.kuali.student.common.exceptions.InvalidParameterException; |
8 |
|
import org.kuali.student.common.versionmanagement.dto.VersionDisplayInfo; |
9 |
|
import org.kuali.student.core.statement.dto.StatementTreeViewInfo; |
10 |
|
import org.kuali.student.lum.common.server.StatementUtil; |
11 |
|
import org.kuali.student.lum.course.dto.LoDisplayInfo; |
12 |
|
import org.kuali.student.lum.program.dto.MajorDisciplineInfo; |
13 |
|
import org.kuali.student.lum.program.dto.ProgramRequirementInfo; |
14 |
|
import org.kuali.student.lum.program.dto.ProgramVariationInfo; |
15 |
|
import org.kuali.student.lum.program.service.ProgramService; |
16 |
|
import org.kuali.student.lum.program.service.ProgramServiceConstants; |
17 |
|
import org.springframework.transaction.annotation.Transactional; |
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
@author |
28 |
|
|
29 |
|
@Transactional(noRollbackFor = {DoesNotExistException.class}, rollbackFor = {Throwable.class}) |
|
|
| 0% |
Uncovered Elements: 55 (55) |
Complexity: 13 |
Complexity Density: 0.35 |
|
30 |
|
public class ProgramStateChangeServiceImpl { |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
private ProgramService programService; |
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
@param |
43 |
|
@param |
44 |
|
@return |
45 |
|
@throws |
46 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
0
|
public void changeState( String majorDisciplineId, String newState) throws Exception {... |
48 |
|
|
49 |
|
|
50 |
0
|
changeState(null, null, majorDisciplineId, newState); |
51 |
|
} |
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
|
@param |
57 |
|
@param |
58 |
|
@param |
59 |
|
@param |
60 |
|
@param |
61 |
|
@return |
62 |
|
@throws |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 4 |
Complexity Density: 0.36 |
|
64 |
0
|
public void changeState(String endEntryTerm, String endEnrollTerm, String majorDisciplineId, String newState) throws Exception {... |
65 |
|
|
66 |
|
|
67 |
0
|
if (newState == null) |
68 |
0
|
throw new InvalidParameterException("new state cannot be null"); |
69 |
|
|
70 |
|
|
71 |
0
|
MajorDisciplineInfo selectedVersion = programService.getMajorDiscipline(majorDisciplineId); |
72 |
|
|
73 |
|
|
74 |
|
|
75 |
0
|
if (newState.equals(DtoConstants.STATE_ACTIVE)) { |
76 |
|
|
77 |
|
|
78 |
0
|
MajorDisciplineInfo previousVersion = findPreviousVersion(selectedVersion); |
79 |
|
|
80 |
0
|
if (previousVersion != null) { |
81 |
|
|
82 |
|
|
83 |
0
|
setEndTerms(previousVersion, endEntryTerm, endEnrollTerm); |
84 |
|
|
85 |
|
|
86 |
0
|
updateMajorDisciplineInfoState(previousVersion, DtoConstants.STATE_SUPERSEDED); |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
|
91 |
0
|
updateMajorDisciplineInfoState(selectedVersion, newState); |
92 |
|
|
93 |
|
|
94 |
0
|
makeCurrent(selectedVersion); |
95 |
|
} else { |
96 |
|
|
97 |
|
|
98 |
0
|
updateMajorDisciplineInfoState(selectedVersion, newState); |
99 |
|
} |
100 |
|
|
101 |
|
|
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
@param |
110 |
|
@param |
111 |
|
@param |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
113 |
0
|
private void setEndTerms(MajorDisciplineInfo majorDisciplineInfo, String endEntryTerm, String endEnrollTerm) {... |
114 |
0
|
majorDisciplineInfo.setEndProgramEntryTerm(endEntryTerm); |
115 |
0
|
majorDisciplineInfo.setEndTerm(endEnrollTerm); |
116 |
|
} |
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
@param |
124 |
|
@param |
125 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
126 |
0
|
private void updateMajorDisciplineInfoState(MajorDisciplineInfo majorDisciplineInfo, String newState) throws Exception {... |
127 |
|
|
128 |
0
|
updateRequirementsState(majorDisciplineInfo, newState); |
129 |
|
|
130 |
|
|
131 |
0
|
majorDisciplineInfo.setState(newState); |
132 |
0
|
programService.updateMajorDiscipline(majorDisciplineInfo); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
@param |
139 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
140 |
0
|
private void makeCurrent(MajorDisciplineInfo majorDisciplineInfo) throws Exception {... |
141 |
|
|
142 |
|
|
143 |
|
|
144 |
0
|
VersionDisplayInfo currentVersion = programService.getCurrentVersion(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersionInfo().getVersionIndId()); |
145 |
|
|
146 |
|
|
147 |
0
|
if (!currentVersion.getSequenceNumber().equals(majorDisciplineInfo.getVersionInfo().getSequenceNumber())) { |
148 |
0
|
programService.setCurrentMajorDisciplineVersion(majorDisciplineInfo.getId(), null); |
149 |
|
} |
150 |
|
} |
151 |
|
|
152 |
|
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
|
|
160 |
|
|
161 |
|
@param |
162 |
|
@return |
163 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
164 |
0
|
private MajorDisciplineInfo findPreviousVersion(MajorDisciplineInfo majorDisciplineInfo) throws Exception {... |
165 |
|
|
166 |
0
|
List<VersionDisplayInfo> versions = programService.getVersions(ProgramServiceConstants.PROGRAM_NAMESPACE_MAJOR_DISCIPLINE_URI, majorDisciplineInfo.getVersionInfo().getVersionIndId()); |
167 |
|
|
168 |
|
|
169 |
0
|
Long sequenceNumber = majorDisciplineInfo.getVersionInfo().getSequenceNumber(); |
170 |
|
|
171 |
|
|
172 |
0
|
sequenceNumber -= 1; |
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
0
|
MajorDisciplineInfo previousVersion = null; |
182 |
0
|
for (VersionDisplayInfo versionInfo : versions) { |
183 |
0
|
if (versionInfo.getSequenceNumber().equals(sequenceNumber)) { |
184 |
0
|
previousVersion = programService.getMajorDiscipline(versionInfo.getId()); |
185 |
0
|
break; |
186 |
|
} |
187 |
|
} |
188 |
0
|
return previousVersion; |
189 |
|
} |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
@param |
197 |
|
@param |
198 |
|
@throws |
199 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
200 |
0
|
public void updateRequirementsState(MajorDisciplineInfo majorDisciplineInfo, String newState) throws Exception {... |
201 |
|
|
202 |
|
|
203 |
0
|
List<String> programRequirementIds = majorDisciplineInfo.getProgramRequirements(); |
204 |
0
|
for (String programRequirementId : programRequirementIds) { |
205 |
|
|
206 |
|
|
207 |
0
|
ProgramRequirementInfo programRequirementInfo = programService.getProgramRequirement(programRequirementId, null, null); |
208 |
|
|
209 |
|
|
210 |
0
|
StatementTreeViewInfo statementTree = programRequirementInfo.getStatement(); |
211 |
|
|
212 |
|
|
213 |
0
|
StatementUtil.updateStatementTreeViewInfoState(newState, statementTree); |
214 |
|
|
215 |
|
|
216 |
0
|
programRequirementInfo.setState(newState); |
217 |
|
|
218 |
|
|
219 |
0
|
programService.updateProgramRequirement(programRequirementInfo); |
220 |
|
|
221 |
|
} |
222 |
|
} |
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
@param |
228 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
229 |
0
|
public void setProgramService(ProgramService programService) {... |
230 |
0
|
this.programService = programService; |
231 |
|
} |
232 |
|
|
233 |
|
} |