1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.kuali.student.lum.program.service.assembler; |
17 |
|
|
18 |
|
import java.util.ArrayList; |
19 |
|
import java.util.HashMap; |
20 |
|
import java.util.Iterator; |
21 |
|
import java.util.List; |
22 |
|
import java.util.Map; |
23 |
|
|
24 |
|
import org.kuali.student.common.util.UUIDHelper; |
25 |
|
import org.kuali.student.core.assembly.BaseDTOAssemblyNode; |
26 |
|
import org.kuali.student.core.assembly.BaseDTOAssemblyNode.NodeOperation; |
27 |
|
import org.kuali.student.core.assembly.data.AssemblyException; |
28 |
|
import org.kuali.student.core.dto.RichTextInfo; |
29 |
|
import org.kuali.student.core.exceptions.DoesNotExistException; |
30 |
|
import org.kuali.student.core.exceptions.InvalidParameterException; |
31 |
|
import org.kuali.student.core.exceptions.MissingParameterException; |
32 |
|
import org.kuali.student.core.exceptions.OperationFailedException; |
33 |
|
import org.kuali.student.lum.lu.dto.AdminOrgInfo; |
34 |
|
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
35 |
|
import org.kuali.student.lum.lu.dto.CluIdentifierInfo; |
36 |
|
import org.kuali.student.lum.lu.dto.CluInfo; |
37 |
|
import org.kuali.student.lum.lu.dto.CluPublicationInfo; |
38 |
|
import org.kuali.student.lum.lu.dto.CluResultInfo; |
39 |
|
import org.kuali.student.lum.lu.dto.FieldInfo; |
40 |
|
import org.kuali.student.lum.lu.dto.LuCodeInfo; |
41 |
|
import org.kuali.student.lum.lu.service.LuService; |
42 |
|
import org.kuali.student.lum.program.dto.CredentialProgramInfo; |
43 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramAtpAssembly; |
44 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramBasicOrgAssembly; |
45 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramCodeAssembly; |
46 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramCommonAssembly; |
47 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramCredentialAssembly; |
48 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramFullOrgAssembly; |
49 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramIdentifierAssembly; |
50 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramPublicationAssembly; |
51 |
|
import org.kuali.student.lum.program.dto.assembly.ProgramRequirementAssembly; |
52 |
|
import org.kuali.student.lum.service.assembler.CluAssemblerUtils; |
53 |
|
|
|
|
| 80.7% |
Uncovered Elements: 124 (643) |
Complexity: 184 |
Complexity Density: 0.42 |
|
54 |
|
public class ProgramAssemblerUtils { |
55 |
|
|
56 |
|
private LuService luService; |
57 |
|
private CluAssemblerUtils cluAssemblerUtils; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
@param |
63 |
|
@param |
64 |
|
@return |
65 |
|
@throws |
66 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
67 |
135
|
public ProgramCommonAssembly assembleBasics(CluInfo clu, ProgramCommonAssembly program) throws AssemblyException {... |
68 |
|
|
69 |
135
|
if (program instanceof CredentialProgramInfo) { |
70 |
6
|
((CredentialProgramInfo)program).setCredentialProgramType(clu.getType()); |
71 |
|
} |
72 |
|
else { |
73 |
129
|
program.setType(clu.getType()); |
74 |
|
} |
75 |
135
|
program.setState(clu.getState()); |
76 |
135
|
program.setMetaInfo(clu.getMetaInfo()); |
77 |
135
|
program.setAttributes(clu.getAttributes()); |
78 |
135
|
program.setId(clu.getId()); |
79 |
|
|
80 |
135
|
return program; |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
@param |
87 |
|
@param |
88 |
|
@param |
89 |
|
@return |
90 |
|
@throws |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 2 |
Complexity Density: 0.25 |
|
92 |
61
|
public CluInfo disassembleBasics(CluInfo clu, ProgramCommonAssembly program) throws AssemblyException {... |
93 |
|
|
94 |
61
|
if (program instanceof CredentialProgramInfo) { |
95 |
2
|
clu.setType (((CredentialProgramInfo)program).getCredentialProgramType()); |
96 |
|
} |
97 |
|
else { |
98 |
59
|
clu.setType(program.getType()); |
99 |
|
} |
100 |
61
|
clu.setId(UUIDHelper.genStringUUID(program.getId())); |
101 |
61
|
clu.setState(program.getState()); |
102 |
61
|
clu.setMetaInfo(program.getMetaInfo()); |
103 |
61
|
clu.setAttributes(program.getAttributes()); |
104 |
61
|
return clu; |
105 |
|
|
106 |
|
} |
107 |
|
|
108 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 4 |
Complexity Density: 0.67 |
|
109 |
78
|
public ProgramRequirementAssembly assembleRequirements(CluInfo clu, ProgramRequirementAssembly program) throws AssemblyException {... |
110 |
|
|
111 |
78
|
try { |
112 |
78
|
List<String> requirements = luService.getRelatedCluIdsByCluId(clu.getId(), ProgramAssemblerConstants.HAS_PROGRAM_REQUIREMENT); |
113 |
78
|
if (requirements != null && requirements.size() > 0) { |
114 |
7
|
program.setProgramRequirements(requirements); |
115 |
|
} |
116 |
|
} |
117 |
|
catch (Exception e) |
118 |
|
{ |
119 |
0
|
throw new AssemblyException("Error assembling program requirements", e); |
120 |
|
} |
121 |
|
|
122 |
78
|
return program; |
123 |
|
} |
124 |
|
|
125 |
|
|
|
|
| 87.5% |
Uncovered Elements: 4 (32) |
Complexity: 10 |
Complexity Density: 0.45 |
|
126 |
14
|
public CluInfo disassembleRequirements(CluInfo clu, ProgramRequirementAssembly program, NodeOperation operation, BaseDTOAssemblyNode<?, ?> result, boolean stateChanged) throws AssemblyException {... |
127 |
14
|
try { |
128 |
14
|
List<String> requirements = program.getProgramRequirements (); |
129 |
|
|
130 |
14
|
if (requirements != null && !requirements.isEmpty()) { |
131 |
14
|
if (stateChanged){ |
132 |
0
|
addUpdateRequirementStateNodes(requirements, clu.getState(), result); |
133 |
|
} |
134 |
|
|
135 |
14
|
Map<String, String> currentRelations = null; |
136 |
|
|
137 |
14
|
if (!NodeOperation.CREATE.equals(operation)) { |
138 |
2
|
currentRelations = getCluCluRelations(clu.getId(), ProgramAssemblerConstants.HAS_PROGRAM_REQUIREMENT); |
139 |
|
} |
140 |
|
|
141 |
14
|
for (String requirementId : requirements){ |
142 |
27
|
List<BaseDTOAssemblyNode<?, ?>> reqResults = addAllRelationNodes(clu.getId(), requirementId, ProgramAssemblerConstants.HAS_PROGRAM_REQUIREMENT, operation, currentRelations); |
143 |
27
|
if (reqResults != null && reqResults.size()> 0) { |
144 |
26
|
result.getChildNodes().addAll(reqResults); |
145 |
|
} |
146 |
|
} |
147 |
|
|
148 |
14
|
if(currentRelations != null && currentRelations.size() > 0){ |
149 |
1
|
for (Map.Entry<String, String> entry : currentRelations.entrySet()) { |
150 |
|
|
151 |
|
|
152 |
2
|
CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
153 |
2
|
relationToDelete.setId( entry.getValue() ); |
154 |
2
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
155 |
|
null); |
156 |
2
|
relationToDeleteNode.setNodeData(relationToDelete); |
157 |
2
|
relationToDeleteNode.setOperation(NodeOperation.DELETE); |
158 |
2
|
result.getChildNodes().add(relationToDeleteNode); |
159 |
|
} |
160 |
|
} |
161 |
|
} |
162 |
|
} catch (Exception e) { |
163 |
0
|
throw new AssemblyException("Error while disassembling program requirements", e); |
164 |
|
} |
165 |
|
|
166 |
14
|
return clu; |
167 |
|
|
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
@param |
174 |
|
@param |
175 |
|
@throws |
176 |
|
@throws |
177 |
|
@throws |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.25 |
|
179 |
0
|
private void addUpdateRequirementStateNodes(List<String> requirements, String state, BaseDTOAssemblyNode<?, ?> result) throws InvalidParameterException, MissingParameterException, OperationFailedException {... |
180 |
0
|
for (String requirementId:requirements){ |
181 |
0
|
try { |
182 |
0
|
CluInfo requirementClu = luService.getClu(requirementId); |
183 |
0
|
requirementClu.setState(state); |
184 |
0
|
BaseDTOAssemblyNode<Object, CluInfo> reqCluNode = new BaseDTOAssemblyNode<Object, CluInfo>(null); |
185 |
0
|
reqCluNode.setNodeData(requirementClu); |
186 |
0
|
reqCluNode.setOperation(NodeOperation.UPDATE); |
187 |
0
|
result.getChildNodes().add(reqCluNode); |
188 |
|
} catch (DoesNotExistException e){ |
189 |
|
|
190 |
|
} |
191 |
|
} |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
@param |
198 |
|
@param |
199 |
|
@return |
200 |
|
@throws |
201 |
|
|
|
|
| 82.8% |
Uncovered Elements: 5 (29) |
Complexity: 8 |
Complexity Density: 0.53 |
|
202 |
135
|
public ProgramIdentifierAssembly assembleIdentifiers(CluInfo clu, ProgramIdentifierAssembly program) throws AssemblyException {... |
203 |
|
|
204 |
135
|
if (clu.getOfficialIdentifier() != null) { |
205 |
135
|
if (clu.getOfficialIdentifier().getShortName() != null) { |
206 |
135
|
program.setShortTitle(clu.getOfficialIdentifier().getShortName()); |
207 |
|
} |
208 |
135
|
if (clu.getOfficialIdentifier().getLongName() != null) { |
209 |
135
|
program.setLongTitle(clu.getOfficialIdentifier().getLongName()); |
210 |
|
} |
211 |
135
|
if (clu.getOfficialIdentifier().getCode() != null) { |
212 |
135
|
program.setCode(clu.getOfficialIdentifier().getCode()); |
213 |
|
} |
214 |
|
} |
215 |
135
|
if (clu.getAlternateIdentifiers() != null) { |
216 |
135
|
for (CluIdentifierInfo cluIdInfo : clu.getAlternateIdentifiers()) { |
217 |
224
|
String idInfoType = cluIdInfo.getType(); |
218 |
224
|
if (ProgramAssemblerConstants.TRANSCRIPT.equals(idInfoType)) { |
219 |
130
|
program.setTranscriptTitle(cluIdInfo.getShortName()); |
220 |
94
|
} else if (ProgramAssemblerConstants.DIPLOMA.equals(idInfoType)) { |
221 |
72
|
program.setDiplomaTitle(cluIdInfo.getShortName()); |
222 |
|
} |
223 |
|
} |
224 |
|
} |
225 |
135
|
return program; |
226 |
|
} |
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
@param |
233 |
|
@param |
234 |
|
@param |
235 |
|
@return |
236 |
|
@throws |
237 |
|
|
|
|
| 98.2% |
Uncovered Elements: 1 (56) |
Complexity: 12 |
Complexity Density: 0.33 |
|
238 |
52
|
public CluInfo disassembleIdentifiers(CluInfo clu, ProgramIdentifierAssembly program, NodeOperation operation) throws AssemblyException {... |
239 |
|
|
240 |
52
|
CluIdentifierInfo official = null != clu.getOfficialIdentifier() ? clu.getOfficialIdentifier() : new CluIdentifierInfo(); |
241 |
|
|
242 |
52
|
official.setCode(program.getCode()); |
243 |
52
|
official.setLongName(program.getLongTitle()); |
244 |
52
|
official.setShortName(program.getShortTitle()); |
245 |
52
|
String existingState = program.getState(); |
246 |
52
|
official.setState((null != existingState && existingState.length() > 0) ? existingState : ProgramAssemblerConstants.ACTIVE); |
247 |
|
|
248 |
52
|
official.setType(ProgramAssemblerConstants.OFFICIAL); |
249 |
|
|
250 |
52
|
if (program instanceof CredentialProgramInfo) { |
251 |
2
|
CredentialProgramInfo cred = (CredentialProgramInfo)program; |
252 |
2
|
official.setLevel(cred.getProgramLevel()); |
253 |
|
} |
254 |
|
|
255 |
52
|
clu.setOfficialIdentifier(official); |
256 |
|
|
257 |
|
|
258 |
52
|
CluIdentifierInfo diplomaInfo = null; |
259 |
52
|
CluIdentifierInfo transcriptInfo = null; |
260 |
111
|
for(Iterator<CluIdentifierInfo> iter = clu.getAlternateIdentifiers().iterator();iter.hasNext();){ |
261 |
59
|
CluIdentifierInfo cluIdentifier = iter.next(); |
262 |
59
|
if (ProgramAssemblerConstants.DIPLOMA.equals(cluIdentifier.getType())) { |
263 |
19
|
diplomaInfo = cluIdentifier; |
264 |
40
|
} else if (ProgramAssemblerConstants.TRANSCRIPT.equals(cluIdentifier.getType())) { |
265 |
34
|
transcriptInfo = cluIdentifier; |
266 |
|
} |
267 |
|
} |
268 |
|
|
269 |
52
|
if (program.getDiplomaTitle() != null) { |
270 |
29
|
if (diplomaInfo == null) { |
271 |
10
|
diplomaInfo = new CluIdentifierInfo(); |
272 |
10
|
diplomaInfo.setState(ProgramAssemblerConstants.ACTIVE); |
273 |
10
|
clu.getAlternateIdentifiers().add(diplomaInfo); |
274 |
|
} |
275 |
29
|
diplomaInfo.setCode(official.getCode()); |
276 |
29
|
diplomaInfo.setShortName(program.getDiplomaTitle()); |
277 |
29
|
diplomaInfo.setType(ProgramAssemblerConstants.DIPLOMA); |
278 |
|
} |
279 |
|
|
280 |
52
|
if (program.getTranscriptTitle() != null) { |
281 |
51
|
if (transcriptInfo == null) { |
282 |
17
|
transcriptInfo = new CluIdentifierInfo(); |
283 |
17
|
transcriptInfo.setState(ProgramAssemblerConstants.ACTIVE); |
284 |
17
|
clu.getAlternateIdentifiers().add(transcriptInfo); |
285 |
|
} |
286 |
51
|
transcriptInfo.setCode(official.getCode()); |
287 |
51
|
transcriptInfo.setShortName(program.getTranscriptTitle()); |
288 |
51
|
transcriptInfo.setType(ProgramAssemblerConstants.TRANSCRIPT); |
289 |
|
} |
290 |
52
|
return clu; |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
@param |
297 |
|
@param |
298 |
|
@return |
299 |
|
@throws |
300 |
|
|
|
|
| 92% |
Uncovered Elements: 2 (25) |
Complexity: 7 |
Complexity Density: 0.54 |
|
301 |
135
|
public ProgramCodeAssembly assembleLuCodes(CluInfo clu, ProgramCodeAssembly program) throws AssemblyException {... |
302 |
|
|
303 |
135
|
if (clu.getLuCodes() != null) { |
304 |
135
|
for (LuCodeInfo codeInfo : clu.getLuCodes()) { |
305 |
506
|
if (ProgramAssemblerConstants.CIP_2000.equals(codeInfo.getType())) { |
306 |
94
|
program.setCip2000Code(codeInfo.getValue()); |
307 |
412
|
} else if (ProgramAssemblerConstants.CIP_2010.equals(codeInfo.getType())) { |
308 |
94
|
program.setCip2010Code(codeInfo.getValue()); |
309 |
318
|
} else if (ProgramAssemblerConstants.HEGIS.equals(codeInfo.getType())) { |
310 |
94
|
program.setHegisCode(codeInfo.getValue()); |
311 |
224
|
} else if (ProgramAssemblerConstants.UNIVERSITY_CLASSIFICATION.equals(codeInfo.getType())) { |
312 |
130
|
program.setUniversityClassification(codeInfo.getValue()); |
313 |
94
|
} else if (ProgramAssemblerConstants.SELECTIVE_ENROLLMENT.equals(codeInfo.getType())) { |
314 |
94
|
program.setSelectiveEnrollmentCode(codeInfo.getValue()); |
315 |
|
} |
316 |
|
} |
317 |
|
} |
318 |
|
|
319 |
135
|
return program; |
320 |
|
} |
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
@param |
327 |
|
@param |
328 |
|
@param |
329 |
|
@throws |
330 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
331 |
52
|
public CluInfo disassembleLuCodes(CluInfo clu, ProgramCodeAssembly program, NodeOperation operation) throws AssemblyException {... |
332 |
|
|
333 |
52
|
clu.setLuCodes(new ArrayList<LuCodeInfo>()); |
334 |
|
|
335 |
52
|
addLuCodeFromProgram(ProgramAssemblerConstants.CIP_2000, program.getCip2000Code(), clu.getLuCodes()); |
336 |
52
|
addLuCodeFromProgram(ProgramAssemblerConstants.CIP_2010, program.getCip2010Code(), clu.getLuCodes()); |
337 |
52
|
addLuCodeFromProgram(ProgramAssemblerConstants.HEGIS, program.getHegisCode(), clu.getLuCodes()); |
338 |
52
|
addLuCodeFromProgram(ProgramAssemblerConstants.UNIVERSITY_CLASSIFICATION, program.getUniversityClassification(), clu.getLuCodes()); |
339 |
52
|
addLuCodeFromProgram(ProgramAssemblerConstants.SELECTIVE_ENROLLMENT, program.getSelectiveEnrollmentCode(), clu.getLuCodes()); |
340 |
|
|
341 |
52
|
return clu; |
342 |
|
|
343 |
|
} |
344 |
|
|
345 |
|
|
346 |
|
|
347 |
|
|
348 |
|
@param |
349 |
|
@param |
350 |
|
@return |
351 |
|
@throws |
352 |
|
|
|
|
| 95.5% |
Uncovered Elements: 1 (22) |
Complexity: 6 |
Complexity Density: 0.5 |
|
353 |
135
|
public ProgramBasicOrgAssembly assembleBasicAdminOrgs(CluInfo clu, ProgramBasicOrgAssembly program) throws AssemblyException {... |
354 |
|
|
355 |
135
|
if (clu.getAdminOrgs() != null) { |
356 |
135
|
clearProgramAdminOrgs(program); |
357 |
135
|
for (AdminOrgInfo cluOrg : clu.getAdminOrgs()) { |
358 |
1465
|
if (cluOrg.getType().equals(ProgramAssemblerConstants.CURRICULUM_OVERSIGHT_DIVISION)) { |
359 |
169
|
program.getDivisionsContentOwner().add(cluOrg.getOrgId()); |
360 |
|
} |
361 |
1296
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.STUDENT_OVERSIGHT_DIVISION)) { |
362 |
169
|
program.getDivisionsStudentOversight().add(cluOrg.getOrgId()) ; |
363 |
|
} |
364 |
1127
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.CURRICULUM_OVERSIGHT_UNIT)) { |
365 |
169
|
program.getUnitsContentOwner().add(cluOrg.getOrgId()) ; |
366 |
|
} |
367 |
958
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.STUDENT_OVERSIGHT_UNIT)) { |
368 |
220
|
program.getUnitsStudentOversight().add(cluOrg.getOrgId()) ; |
369 |
|
} |
370 |
|
} |
371 |
|
} |
372 |
135
|
return program; |
373 |
|
} |
374 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (27) |
Complexity: 7 |
Complexity Density: 0.47 |
|
375 |
94
|
public ProgramFullOrgAssembly assembleFullOrgs(CluInfo clu, ProgramFullOrgAssembly program) throws AssemblyException {... |
376 |
|
|
377 |
94
|
clearFullAdminOrgs(program); |
378 |
94
|
for (AdminOrgInfo cluOrg : clu.getAdminOrgs()) { |
379 |
1259
|
if (cluOrg.getType().equals(ProgramAssemblerConstants.DEPLOYMENT_DIVISION)) { |
380 |
119
|
program.getDivisionsDeployment().add(cluOrg.getOrgId()) ; |
381 |
|
} |
382 |
1140
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.FINANCIAL_RESOURCES_DIVISION)) { |
383 |
119
|
program.getDivisionsFinancialResources().add(cluOrg.getOrgId()) ; |
384 |
|
} |
385 |
1021
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.FINANCIAL_CONTROL_DIVISION)) { |
386 |
119
|
program.getDivisionsFinancialControl().add(cluOrg.getOrgId()) ; |
387 |
|
} |
388 |
902
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.DEPLOYMENT_UNIT)) { |
389 |
119
|
program.getUnitsDeployment().add(cluOrg.getOrgId()) ; |
390 |
|
} |
391 |
783
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.FINANCIAL_RESOURCES_UNIT)) { |
392 |
119
|
program.getUnitsFinancialResources().add(cluOrg.getOrgId()) ; |
393 |
|
} |
394 |
664
|
else if (cluOrg.getType().equals(ProgramAssemblerConstants.FINANCIAL_CONTROL_UNIT)) { |
395 |
137
|
program.getUnitsFinancialControl().add(cluOrg.getOrgId()) ; |
396 |
|
} |
397 |
|
} |
398 |
94
|
return program; |
399 |
|
} |
400 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
401 |
135
|
private void clearProgramAdminOrgs(ProgramBasicOrgAssembly program) {... |
402 |
135
|
program.setDivisionsContentOwner(new ArrayList<String>()); |
403 |
135
|
program.setDivisionsStudentOversight(new ArrayList<String>()); |
404 |
135
|
program.setUnitsContentOwner(new ArrayList<String>()); |
405 |
135
|
program.setUnitsStudentOversight(new ArrayList<String>()); |
406 |
|
} |
407 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
408 |
94
|
private void clearFullAdminOrgs(ProgramFullOrgAssembly program) {... |
409 |
94
|
program.setDivisionsDeployment(new ArrayList<String>()); |
410 |
94
|
program.setDivisionsFinancialResources(new ArrayList<String>()); |
411 |
94
|
program.setDivisionsFinancialControl(new ArrayList<String>()); |
412 |
94
|
program.setUnitsDeployment(new ArrayList<String>()); |
413 |
94
|
program.setUnitsFinancialResources(new ArrayList<String>()); |
414 |
94
|
program.setUnitsFinancialControl(new ArrayList<String>()); |
415 |
|
} |
416 |
|
|
417 |
|
|
418 |
|
|
419 |
|
|
420 |
|
@param |
421 |
|
@param |
422 |
|
@param |
423 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 3 |
Complexity Density: 0.17 |
|
424 |
52
|
public CluInfo disassembleAdminOrgs(CluInfo clu, ProgramBasicOrgAssembly program, NodeOperation operation){... |
425 |
|
|
426 |
|
|
427 |
52
|
clu.setAdminOrgs(new ArrayList<AdminOrgInfo>()); |
428 |
|
|
429 |
52
|
newBuildAdminOrgs(clu, program.getDivisionsContentOwner(), ProgramAssemblerConstants.CURRICULUM_OVERSIGHT_DIVISION); |
430 |
52
|
newBuildAdminOrgs(clu, program.getDivisionsStudentOversight(), ProgramAssemblerConstants.STUDENT_OVERSIGHT_DIVISION ); |
431 |
52
|
newBuildAdminOrgs(clu, program.getUnitsContentOwner(), ProgramAssemblerConstants.CURRICULUM_OVERSIGHT_UNIT); |
432 |
52
|
newBuildAdminOrgs(clu, program.getUnitsStudentOversight(), ProgramAssemblerConstants.STUDENT_OVERSIGHT_UNIT ); |
433 |
52
|
if (program instanceof CredentialProgramInfo) { |
434 |
2
|
List<String> institutionOrgs = new ArrayList<String>(); |
435 |
2
|
institutionOrgs.add(((CredentialProgramInfo)program).getInstitution().getOrgId()); |
436 |
2
|
newBuildAdminOrgs(clu, institutionOrgs , ProgramAssemblerConstants.INSTITUTION) ; |
437 |
|
} |
438 |
52
|
if (program instanceof ProgramFullOrgAssembly) { |
439 |
35
|
ProgramFullOrgAssembly fullOrg = (ProgramFullOrgAssembly) program; |
440 |
35
|
newBuildAdminOrgs(clu, fullOrg.getDivisionsDeployment(), ProgramAssemblerConstants.DEPLOYMENT_DIVISION); |
441 |
35
|
newBuildAdminOrgs(clu, fullOrg.getDivisionsFinancialResources(), ProgramAssemblerConstants.FINANCIAL_RESOURCES_DIVISION); |
442 |
35
|
newBuildAdminOrgs(clu, fullOrg.getDivisionsFinancialControl(), ProgramAssemblerConstants.FINANCIAL_CONTROL_DIVISION); |
443 |
35
|
newBuildAdminOrgs(clu, fullOrg.getUnitsDeployment(), ProgramAssemblerConstants.DEPLOYMENT_UNIT); |
444 |
35
|
newBuildAdminOrgs(clu, fullOrg.getUnitsFinancialResources(), ProgramAssemblerConstants.FINANCIAL_RESOURCES_UNIT); |
445 |
35
|
newBuildAdminOrgs(clu, fullOrg.getUnitsFinancialControl(), ProgramAssemblerConstants.FINANCIAL_CONTROL_UNIT); |
446 |
|
|
447 |
|
} |
448 |
52
|
return clu; |
449 |
|
|
450 |
|
} |
451 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
452 |
420
|
private CluInfo newBuildAdminOrgs(CluInfo clu, List<String> orgIds, String type) {... |
453 |
|
|
454 |
420
|
if (null != orgIds) { |
455 |
420
|
for (String orgId : orgIds) { |
456 |
622
|
AdminOrgInfo subjectOrg = new AdminOrgInfo(); |
457 |
622
|
subjectOrg.setType(type); |
458 |
622
|
subjectOrg.setOrgId(orgId); |
459 |
622
|
clu.getAdminOrgs().add(subjectOrg); |
460 |
|
} |
461 |
|
} |
462 |
420
|
return clu; |
463 |
|
} |
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
468 |
|
@param |
469 |
|
@param |
470 |
|
@return |
471 |
|
@throws |
472 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.33 |
|
473 |
60
|
public List<String> assembleResultOptions(String cluId) throws AssemblyException {... |
474 |
60
|
List<String> resultOptions = null; |
475 |
60
|
try{ |
476 |
60
|
List<CluResultInfo> cluResults = luService.getCluResultByClu(cluId); |
477 |
|
|
478 |
60
|
List<String> resultTypes = new ArrayList<String>(); |
479 |
60
|
resultTypes.add(ProgramAssemblerConstants.DEGREE_RESULTS); |
480 |
60
|
resultTypes.add(ProgramAssemblerConstants.CERTIFICATE_RESULTS); |
481 |
|
|
482 |
60
|
resultOptions = cluAssemblerUtils.assembleCluResults(resultTypes, cluResults); |
483 |
|
|
484 |
|
} catch (DoesNotExistException e){ |
485 |
|
} catch (Exception e) { |
486 |
0
|
throw new AssemblyException("Error getting major results", e); |
487 |
|
} |
488 |
60
|
return resultOptions; |
489 |
|
} |
490 |
|
|
491 |
|
|
492 |
|
|
493 |
|
|
494 |
|
@param |
495 |
|
@param |
496 |
|
@return |
497 |
|
@throws |
498 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
499 |
135
|
public ProgramAtpAssembly assembleAtps(CluInfo clu, ProgramAtpAssembly program) throws AssemblyException {... |
500 |
|
|
501 |
135
|
if (clu.getExpectedFirstAtp() != null) { |
502 |
130
|
program.setStartTerm(clu.getExpectedFirstAtp()); |
503 |
|
} |
504 |
135
|
if (clu.getLastAtp() != null) { |
505 |
130
|
program.setEndTerm(clu.getLastAtp()); |
506 |
|
} |
507 |
135
|
if (clu.getLastAdmitAtp() != null) { |
508 |
130
|
program.setEndProgramEntryTerm(clu.getLastAdmitAtp()); |
509 |
|
} |
510 |
135
|
return program; |
511 |
|
} |
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
@param |
518 |
|
@param |
519 |
|
@return |
520 |
|
@throws |
521 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
522 |
52
|
public CluInfo disassembleAtps(CluInfo clu, ProgramAtpAssembly program, NodeOperation operation) throws AssemblyException {... |
523 |
|
|
524 |
52
|
clu.setExpectedFirstAtp(program.getStartTerm()); |
525 |
52
|
clu.setLastAtp(program.getEndTerm()); |
526 |
52
|
clu.setLastAdmitAtp(program.getEndProgramEntryTerm()); |
527 |
|
|
528 |
52
|
return clu; |
529 |
|
|
530 |
|
} |
531 |
|
|
532 |
|
|
533 |
|
|
534 |
|
|
535 |
|
@param |
536 |
|
@param |
537 |
|
@return |
538 |
|
@throws |
539 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 9 |
Complexity Density: 0.69 |
|
540 |
116
|
public ProgramPublicationAssembly assemblePublications(CluInfo clu, ProgramPublicationAssembly program) throws AssemblyException {... |
541 |
|
|
542 |
|
|
543 |
116
|
if (clu.getReferenceURL() != null) { |
544 |
116
|
program.setReferenceURL(clu.getReferenceURL()); |
545 |
|
} |
546 |
|
|
547 |
116
|
try { |
548 |
116
|
List<CluPublicationInfo> cluPublications = luService.getCluPublicationsByCluId(clu.getId()); |
549 |
|
|
550 |
116
|
List<String> targets = new ArrayList<String>(); |
551 |
|
|
552 |
116
|
for (CluPublicationInfo cluPublication : cluPublications) { |
553 |
104
|
if (cluPublication.getType().equals(ProgramAssemblerConstants.CATALOG)) { |
554 |
83
|
assembleCatalogDescr(program, cluPublication); |
555 |
|
} |
556 |
|
else { |
557 |
21
|
targets.add(cluPublication.getType()); |
558 |
|
} |
559 |
|
} |
560 |
|
|
561 |
116
|
if (targets != null && !targets.isEmpty()) { |
562 |
12
|
program.setCatalogPublicationTargets(targets); |
563 |
|
} |
564 |
|
} catch (DoesNotExistException e) { |
565 |
|
} catch (InvalidParameterException e) { |
566 |
|
} catch (MissingParameterException e) { |
567 |
|
} catch (OperationFailedException e) { |
568 |
0
|
throw new AssemblyException("Error getting publication targets", e); |
569 |
|
} |
570 |
116
|
return program; |
571 |
|
} |
572 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
573 |
83
|
private void assembleCatalogDescr(ProgramPublicationAssembly program, CluPublicationInfo cluPublication) {... |
574 |
|
|
575 |
83
|
for (FieldInfo fieldInfo : cluPublication.getVariants()) { |
576 |
73
|
if (fieldInfo.getId().equals(ProgramAssemblerConstants.CATALOG_DESCR)) { |
577 |
73
|
RichTextInfo desc = new RichTextInfo(); |
578 |
73
|
desc.setPlain(fieldInfo.getValue()); |
579 |
73
|
desc.setFormatted(fieldInfo.getValue()); |
580 |
73
|
program.setCatalogDescr(desc); |
581 |
73
|
break; |
582 |
|
} |
583 |
|
} |
584 |
|
} |
585 |
|
|
|
|
| 85.1% |
Uncovered Elements: 7 (47) |
Complexity: 12 |
Complexity Density: 0.36 |
|
586 |
50
|
private List<BaseDTOAssemblyNode<?, ?>> disassembleCatalogDescr(ProgramPublicationAssembly program, NodeOperation operation) throws AssemblyException {... |
587 |
|
|
588 |
50
|
List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
589 |
|
|
590 |
50
|
CluPublicationInfo currentPubInfo = null; |
591 |
|
|
592 |
50
|
try { |
593 |
|
|
594 |
|
|
595 |
50
|
if (!NodeOperation.CREATE.equals(operation)) { |
596 |
34
|
List<CluPublicationInfo> pubs = luService.getCluPublicationsByCluId(program.getId()); |
597 |
34
|
for (CluPublicationInfo pubInfo : pubs) { |
598 |
30
|
if (pubInfo.getType().equals(ProgramAssemblerConstants.CATALOG)) { |
599 |
19
|
currentPubInfo = pubInfo; |
600 |
|
} |
601 |
|
} |
602 |
|
} |
603 |
|
|
604 |
50
|
if (program.getCatalogDescr() != null) { |
605 |
|
|
606 |
43
|
if (NodeOperation.CREATE == operation |
607 |
|
|| (NodeOperation.UPDATE == operation && currentPubInfo == null )) { |
608 |
|
|
609 |
24
|
CluPublicationInfo pubInfo = buildCluPublicationInfo(program.getId(), ProgramAssemblerConstants.CATALOG); |
610 |
|
|
611 |
24
|
FieldInfo variant = new FieldInfo(); |
612 |
24
|
variant.setId(ProgramAssemblerConstants.CATALOG_DESCR); |
613 |
24
|
variant.setValue(program.getCatalogDescr() .getPlain()); |
614 |
24
|
pubInfo.getVariants().add(variant); |
615 |
|
|
616 |
24
|
BaseDTOAssemblyNode<Object, CluPublicationInfo> pubNode = new BaseDTOAssemblyNode<Object, CluPublicationInfo>( |
617 |
|
null); |
618 |
24
|
pubNode.setNodeData(pubInfo); |
619 |
24
|
pubNode.setOperation(NodeOperation.CREATE); |
620 |
|
|
621 |
24
|
results.add(pubNode); |
622 |
19
|
} else if (NodeOperation.UPDATE == operation |
623 |
|
&& currentPubInfo != null) { |
624 |
|
|
625 |
19
|
CluPublicationInfo pubInfo = currentPubInfo; |
626 |
|
|
627 |
19
|
for (FieldInfo fieldInfo : pubInfo.getVariants()) { |
628 |
19
|
if (fieldInfo.getId().equals(ProgramAssemblerConstants.CATALOG_DESCR)) { |
629 |
19
|
fieldInfo.setValue(program.getCatalogDescr() .getPlain()); |
630 |
19
|
break; |
631 |
|
} |
632 |
|
} |
633 |
|
|
634 |
19
|
BaseDTOAssemblyNode<Object, CluPublicationInfo> pubNode = new BaseDTOAssemblyNode<Object, CluPublicationInfo>( |
635 |
|
null); |
636 |
19
|
pubNode.setNodeData(pubInfo); |
637 |
19
|
pubNode.setOperation(NodeOperation.UPDATE); |
638 |
|
|
639 |
19
|
results.add(pubNode); |
640 |
|
|
641 |
|
} |
642 |
0
|
else if (NodeOperation.DELETE == operation ) { |
643 |
|
|
644 |
0
|
deletePublicationInfo(results, currentPubInfo); |
645 |
|
} |
646 |
|
} |
647 |
|
} catch (Exception e) { |
648 |
0
|
throw new AssemblyException(e); |
649 |
|
} |
650 |
50
|
return results; |
651 |
|
} |
652 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
|
653 |
0
|
private void deletePublicationInfo(List<BaseDTOAssemblyNode<?, ?>> results, CluPublicationInfo currentPubInfo) {... |
654 |
0
|
CluPublicationInfo descrToDelete = new CluPublicationInfo(); |
655 |
0
|
descrToDelete.setId(currentPubInfo.getId()); |
656 |
0
|
BaseDTOAssemblyNode<Object, CluPublicationInfo> pubToDeleteNode = new BaseDTOAssemblyNode<Object, CluPublicationInfo>( |
657 |
|
null); |
658 |
0
|
pubToDeleteNode.setNodeData(descrToDelete); |
659 |
0
|
pubToDeleteNode.setOperation(NodeOperation.DELETE); |
660 |
0
|
results.add(pubToDeleteNode); |
661 |
|
} |
662 |
|
|
663 |
|
|
664 |
|
|
665 |
|
|
666 |
|
@param |
667 |
|
@param |
668 |
|
@param |
669 |
|
@return |
670 |
|
@throws |
671 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 5 |
Complexity Density: 0.62 |
|
672 |
50
|
public CluInfo disassemblePublications(CluInfo clu, ProgramPublicationAssembly program, NodeOperation operation, BaseDTOAssemblyNode<?, ?> result) throws AssemblyException {... |
673 |
|
|
674 |
50
|
clu.setReferenceURL(program.getReferenceURL()); |
675 |
|
|
676 |
50
|
List<BaseDTOAssemblyNode<?, ?>> targetResults = disassemblePublicationTargets(program, operation); |
677 |
50
|
if (targetResults != null && targetResults.size()> 0) { |
678 |
16
|
result.getChildNodes().addAll(targetResults); |
679 |
|
} |
680 |
|
|
681 |
50
|
List<BaseDTOAssemblyNode<?, ?>> descrResults = disassembleCatalogDescr(program, operation) ; |
682 |
50
|
if (descrResults != null && descrResults.size()> 0) { |
683 |
43
|
result.getChildNodes().addAll(descrResults); |
684 |
|
} |
685 |
|
|
686 |
50
|
return clu; |
687 |
|
|
688 |
|
} |
689 |
|
|
690 |
|
|
691 |
|
|
692 |
|
|
693 |
|
@param |
694 |
|
@param |
695 |
|
@param |
696 |
|
@return |
697 |
|
@throws |
698 |
|
|
|
|
| 67.9% |
Uncovered Elements: 17 (53) |
Complexity: 18 |
Complexity Density: 0.44 |
|
699 |
11
|
public List<BaseDTOAssemblyNode<?,?>> disassembleCredentialProgram(ProgramCredentialAssembly program, NodeOperation operation, String relationType) throws AssemblyException {... |
700 |
|
|
701 |
11
|
List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
702 |
|
|
703 |
11
|
try { |
704 |
11
|
CluInfo credentialClu = luService.getClu(program.getCredentialProgramId()); |
705 |
|
} catch (DoesNotExistException e) { |
706 |
|
} catch (Exception e) { |
707 |
0
|
throw new AssemblyException("Credential Clu does not exist for " + program.getCredentialProgramId()); |
708 |
|
} |
709 |
|
|
710 |
11
|
Map<String, String> currentRelations = new HashMap<String, String>(); |
711 |
|
|
712 |
11
|
if (!NodeOperation.CREATE.equals(operation)) { |
713 |
8
|
try { |
714 |
8
|
List<CluCluRelationInfo> cluRelations = luService.getCluCluRelationsByClu(program.getId()); |
715 |
8
|
for (CluCluRelationInfo cluRelation : cluRelations) { |
716 |
32
|
if (relationType.equals(cluRelation.getType()) ) { |
717 |
6
|
currentRelations.put(cluRelation.getRelatedCluId(), cluRelation.getId()); |
718 |
|
} |
719 |
|
} |
720 |
|
} catch (DoesNotExistException e) { |
721 |
|
} catch (InvalidParameterException e) { |
722 |
|
} catch (MissingParameterException e) { |
723 |
|
} catch (OperationFailedException e) { |
724 |
0
|
throw new AssemblyException("Error getting related clus", e); |
725 |
|
} |
726 |
|
} |
727 |
|
|
728 |
|
|
729 |
|
|
730 |
11
|
if (NodeOperation.CREATE == operation |
731 |
|
|| (NodeOperation.UPDATE == operation && !currentRelations.containsKey(program.getCredentialProgramId()) )) { |
732 |
|
|
733 |
11
|
CluCluRelationInfo relation = new CluCluRelationInfo(); |
734 |
11
|
relation.setCluId(program.getCredentialProgramId()); |
735 |
11
|
relation.setRelatedCluId(program.getId()); |
736 |
11
|
relation.setType(relationType); |
737 |
11
|
relation.setState(ProgramAssemblerConstants.ACTIVE); |
738 |
|
|
739 |
11
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
740 |
|
null); |
741 |
11
|
relationNode.setNodeData(relation); |
742 |
11
|
relationNode.setOperation(NodeOperation.CREATE); |
743 |
|
|
744 |
11
|
results.add(relationNode); |
745 |
0
|
} else if (NodeOperation.UPDATE == operation |
746 |
|
&& currentRelations.containsKey(program.getCredentialProgramId())) { |
747 |
|
|
748 |
|
|
749 |
|
|
750 |
|
|
751 |
0
|
currentRelations.remove(program.getCredentialProgramId()); |
752 |
0
|
} else if (NodeOperation.DELETE == operation |
753 |
|
&& currentRelations.containsKey(program.getId())) { |
754 |
|
|
755 |
0
|
CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
756 |
0
|
relationToDelete.setId( currentRelations.get(program.getId()) ); |
757 |
0
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
758 |
|
null); |
759 |
0
|
relationToDeleteNode.setNodeData(relationToDelete); |
760 |
0
|
relationToDeleteNode.setOperation(NodeOperation.DELETE); |
761 |
0
|
results.add(relationToDeleteNode); |
762 |
|
|
763 |
|
|
764 |
|
|
765 |
0
|
currentRelations.remove(program.getId()); |
766 |
|
} |
767 |
|
|
768 |
11
|
if(currentRelations != null && currentRelations.size() > 0){ |
769 |
6
|
for (Map.Entry<String, String> entry : currentRelations.entrySet()) { |
770 |
|
|
771 |
|
|
772 |
6
|
CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
773 |
6
|
relationToDelete.setId( entry.getValue() ); |
774 |
6
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
775 |
|
null); |
776 |
6
|
relationToDeleteNode.setNodeData(relationToDelete); |
777 |
6
|
relationToDeleteNode.setOperation(NodeOperation.DELETE); |
778 |
6
|
results.add(relationToDeleteNode); |
779 |
|
} |
780 |
|
} |
781 |
11
|
return results; |
782 |
|
} |
783 |
|
|
|
|
| 0% |
Uncovered Elements: 30 (30) |
Complexity: 11 |
Complexity Density: 0.55 |
|
784 |
0
|
public List<BaseDTOAssemblyNode<?, ?>> addRelationNodes(String cluId, String relatedCluId, String relationType, NodeOperation operation)throws AssemblyException{... |
785 |
0
|
Map<String, String> currentRelations = null; |
786 |
0
|
List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
787 |
|
|
788 |
0
|
if (!NodeOperation.CREATE.equals(operation)) { |
789 |
0
|
currentRelations = getCluCluRelations(cluId, relationType); |
790 |
|
} |
791 |
|
|
792 |
|
|
793 |
0
|
if (NodeOperation.CREATE == operation |
794 |
|
|| (NodeOperation.UPDATE == operation && !currentRelations.containsKey(relatedCluId) )) { |
795 |
|
|
796 |
0
|
addCreateRelationNode(cluId, relatedCluId, relationType, results); |
797 |
0
|
} else if (NodeOperation.UPDATE == operation |
798 |
|
&& currentRelations.containsKey(relatedCluId)) { |
799 |
|
|
800 |
|
|
801 |
|
|
802 |
|
|
803 |
0
|
currentRelations.remove(relatedCluId); |
804 |
0
|
} else if (NodeOperation.DELETE == operation |
805 |
|
&& currentRelations.containsKey(relatedCluId)) { |
806 |
|
|
807 |
0
|
addDeleteRelationNodes(currentRelations, results); |
808 |
|
|
809 |
|
|
810 |
|
|
811 |
0
|
currentRelations.remove(relatedCluId); |
812 |
|
} |
813 |
|
|
814 |
0
|
if(currentRelations != null && currentRelations.size() > 0){ |
815 |
0
|
for (Map.Entry<String, String> entry : currentRelations.entrySet()) { |
816 |
|
|
817 |
|
|
818 |
0
|
CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
819 |
0
|
relationToDelete.setId( entry.getValue() ); |
820 |
0
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
821 |
|
null); |
822 |
0
|
relationToDeleteNode.setNodeData(relationToDelete); |
823 |
0
|
relationToDeleteNode.setOperation(NodeOperation.DELETE); |
824 |
0
|
results.add(relationToDeleteNode); |
825 |
|
} |
826 |
|
} |
827 |
0
|
return results; |
828 |
|
} |
|
|
| 60% |
Uncovered Elements: 6 (15) |
Complexity: 8 |
Complexity Density: 0.89 |
|
829 |
29
|
public List<BaseDTOAssemblyNode<?, ?>> addAllRelationNodes(String cluId, String relatedCluId, String relationType, NodeOperation operation, Map<String, String> currentRelations)throws AssemblyException{... |
830 |
29
|
List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
831 |
|
|
832 |
29
|
if (NodeOperation.CREATE == operation |
833 |
|
|| (NodeOperation.UPDATE == operation && !currentRelations.containsKey(relatedCluId) )) { |
834 |
|
|
835 |
27
|
addCreateRelationNode(cluId, relatedCluId, relationType, results); |
836 |
2
|
} else if (NodeOperation.UPDATE == operation |
837 |
|
&& currentRelations.containsKey(relatedCluId)) { |
838 |
|
|
839 |
|
|
840 |
|
|
841 |
|
|
842 |
2
|
currentRelations.remove(relatedCluId); |
843 |
0
|
} else if (NodeOperation.DELETE == operation |
844 |
|
&& currentRelations.containsKey(relatedCluId)) { |
845 |
|
|
846 |
0
|
addDeleteRelationNodes(currentRelations, results); |
847 |
|
|
848 |
|
|
849 |
|
|
850 |
0
|
currentRelations.remove(relatedCluId); |
851 |
|
} |
852 |
|
|
853 |
29
|
return results; |
854 |
|
} |
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 6 |
Complexity Density: 0.75 |
|
855 |
3
|
public Map<String, String> getCluCluRelations(String cluId, String relationType) throws AssemblyException{... |
856 |
3
|
Map<String, String> currentRelations = new HashMap<String, String>(); |
857 |
|
|
858 |
3
|
try { |
859 |
3
|
List<CluCluRelationInfo> cluRelations = luService.getCluCluRelationsByClu(cluId); |
860 |
|
|
861 |
3
|
for (CluCluRelationInfo cluRelation : cluRelations) { |
862 |
13
|
if (relationType.equals(cluRelation.getType())) { |
863 |
4
|
currentRelations.put(cluRelation.getRelatedCluId(), cluRelation.getId()); |
864 |
|
} |
865 |
|
} |
866 |
|
} catch (DoesNotExistException e) { |
867 |
|
} catch (InvalidParameterException e) { |
868 |
|
} catch (MissingParameterException e) { |
869 |
|
} catch (OperationFailedException e) { |
870 |
0
|
throw new AssemblyException("Error getting related clus", e); |
871 |
|
} |
872 |
|
|
873 |
3
|
return currentRelations; |
874 |
|
} |
875 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 8 |
Complexity Density: 1 |
|
876 |
22
|
public Map<String, CluCluRelationInfo> getCluCluActiveRelations(String cluId, String relationType) throws AssemblyException{... |
877 |
22
|
Map<String, CluCluRelationInfo> currentRelations = new HashMap<String, CluCluRelationInfo>(); |
878 |
|
|
879 |
22
|
try { |
880 |
22
|
List<CluCluRelationInfo> cluRelations = luService.getCluCluRelationsByClu(cluId); |
881 |
|
|
882 |
22
|
for (CluCluRelationInfo cluRelation : cluRelations) { |
883 |
97
|
if (relationType.equals(cluRelation.getType()) && (!cluRelation.getState().isEmpty() && cluRelation.getState().equalsIgnoreCase(ProgramAssemblerConstants.ACTIVE))) { |
884 |
47
|
currentRelations.put(cluRelation.getRelatedCluId(), cluRelation); |
885 |
|
} |
886 |
|
} |
887 |
|
} catch (DoesNotExistException e) { |
888 |
|
} catch (InvalidParameterException e) { |
889 |
|
} catch (MissingParameterException e) { |
890 |
|
} catch (OperationFailedException e) { |
891 |
0
|
throw new AssemblyException("Error getting related clus", e); |
892 |
|
} |
893 |
|
|
894 |
22
|
return currentRelations; |
895 |
|
} |
896 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
|
897 |
34
|
public void addCreateRelationNode(String cluId, String relatedCluId, String relationType, List<BaseDTOAssemblyNode<?, ?>> results){... |
898 |
34
|
CluCluRelationInfo relation = new CluCluRelationInfo(); |
899 |
34
|
relation.setCluId(cluId); |
900 |
34
|
relation.setRelatedCluId(relatedCluId); |
901 |
34
|
relation.setType(relationType); |
902 |
34
|
relation.setState(ProgramAssemblerConstants.ACTIVE); |
903 |
|
|
904 |
34
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
905 |
|
null); |
906 |
34
|
relationNode.setNodeData(relation); |
907 |
34
|
relationNode.setOperation(NodeOperation.CREATE); |
908 |
|
|
909 |
34
|
results.add(relationNode); |
910 |
|
|
911 |
|
} |
912 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
913 |
0
|
public void addDeleteRelationNodes(Map<String, String> currentRelations, List<BaseDTOAssemblyNode<?, ?>> results){... |
914 |
0
|
for (Map.Entry<String, String> entry : currentRelations.entrySet()) { |
915 |
|
|
916 |
|
|
917 |
0
|
CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
918 |
0
|
relationToDelete.setId( entry.getValue() ); |
919 |
0
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
920 |
|
null); |
921 |
0
|
relationToDeleteNode.setNodeData(relationToDelete); |
922 |
0
|
relationToDeleteNode.setOperation(NodeOperation.DELETE); |
923 |
0
|
results.add(relationToDeleteNode); |
924 |
|
} |
925 |
|
} |
926 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
|
927 |
1
|
public void addInactiveRelationNodes(Map<String, CluCluRelationInfo> currentRelations, List<BaseDTOAssemblyNode<?, ?>> results){... |
928 |
1
|
for (Map.Entry<String, CluCluRelationInfo> entry : currentRelations.entrySet()) { |
929 |
1
|
CluCluRelationInfo inactiveRelation = new CluCluRelationInfo(); |
930 |
1
|
inactiveRelation = entry.getValue(); |
931 |
1
|
inactiveRelation.setState(ProgramAssemblerConstants.INACTIVE); |
932 |
1
|
BaseDTOAssemblyNode<Object, CluCluRelationInfo> inactiveRelationNode = new BaseDTOAssemblyNode<Object, CluCluRelationInfo>( |
933 |
|
null); |
934 |
1
|
inactiveRelationNode.setNodeData(inactiveRelation); |
935 |
1
|
inactiveRelationNode.setOperation(NodeOperation.UPDATE); |
936 |
1
|
results.add(inactiveRelationNode); |
937 |
|
} |
938 |
|
} |
939 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
940 |
260
|
private void addLuCodeFromProgram(String type, String value, List<LuCodeInfo> list) throws AssemblyException {... |
941 |
|
|
942 |
260
|
if (value != null && !value.isEmpty()) { |
943 |
191
|
LuCodeInfo code = new LuCodeInfo(); |
944 |
191
|
code.setType(type); |
945 |
191
|
code.setValue(value); |
946 |
191
|
code.setAttributes(new HashMap<String, String>()); |
947 |
191
|
list.add(code); |
948 |
|
} |
949 |
|
} |
950 |
|
|
951 |
|
|
952 |
|
|
953 |
|
|
954 |
|
@param |
955 |
|
@param |
956 |
|
@param |
957 |
|
@return |
958 |
|
@throws |
959 |
|
|
|
|
| 69% |
Uncovered Elements: 13 (42) |
Complexity: 14 |
Complexity Density: 0.47 |
|
960 |
50
|
private List<BaseDTOAssemblyNode<?, ?>> disassemblePublicationTargets(ProgramPublicationAssembly program, NodeOperation operation) throws AssemblyException {... |
961 |
|
|
962 |
50
|
List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
963 |
|
|
964 |
50
|
Map<String, CluPublicationInfo> currentPubs = new HashMap<String, CluPublicationInfo>(); |
965 |
50
|
if (!NodeOperation.CREATE.equals(operation)) { |
966 |
|
|
967 |
|
|
968 |
34
|
try { |
969 |
34
|
List<CluPublicationInfo> cluPubs = luService.getCluPublicationsByCluId(program.getId()); |
970 |
34
|
for(CluPublicationInfo cluPub : cluPubs){ |
971 |
30
|
if (!cluPub.getType().equals(ProgramAssemblerConstants.CATALOG)) { |
972 |
11
|
currentPubs.put(cluPub.getType(), cluPub); |
973 |
|
} |
974 |
|
} |
975 |
|
} catch (DoesNotExistException e) { |
976 |
|
} catch (Exception e) { |
977 |
0
|
throw new AssemblyException("Error finding publications"); |
978 |
|
} |
979 |
|
} |
980 |
|
|
981 |
50
|
if (program.getCatalogPublicationTargets() != null && !program.getCatalogPublicationTargets().isEmpty()) { |
982 |
21
|
for (String publicationType : program.getCatalogPublicationTargets()) { |
983 |
|
|
984 |
42
|
if (NodeOperation.CREATE == operation |
985 |
|
|| (NodeOperation.UPDATE == operation && !currentPubs.containsKey(publicationType) )) { |
986 |
|
|
987 |
31
|
CluPublicationInfo pubInfo = buildCluPublicationInfo(program.getId(), publicationType); |
988 |
|
|
989 |
31
|
BaseDTOAssemblyNode<Object, CluPublicationInfo> pubNode = new BaseDTOAssemblyNode<Object, CluPublicationInfo>( |
990 |
|
null); |
991 |
31
|
pubNode.setNodeData(pubInfo); |
992 |
31
|
pubNode.setOperation(NodeOperation.CREATE); |
993 |
|
|
994 |
31
|
results.add(pubNode); |
995 |
11
|
} else if (NodeOperation.UPDATE == operation |
996 |
|
&& currentPubs.containsKey(publicationType)) { |
997 |
|
|
998 |
|
|
999 |
11
|
currentPubs.remove(publicationType); |
1000 |
0
|
} else if (NodeOperation.DELETE == operation |
1001 |
|
&& currentPubs.containsKey(publicationType)) { |
1002 |
|
|
1003 |
0
|
CluPublicationInfo pubToDelete = new CluPublicationInfo(); |
1004 |
0
|
pubToDelete.setId(publicationType); |
1005 |
0
|
BaseDTOAssemblyNode<Object, CluPublicationInfo> pubToDeleteNode = new BaseDTOAssemblyNode<Object, CluPublicationInfo>( |
1006 |
|
null); |
1007 |
0
|
pubToDeleteNode.setNodeData(pubToDelete); |
1008 |
0
|
pubToDeleteNode.setOperation(NodeOperation.DELETE); |
1009 |
0
|
results.add(pubToDeleteNode); |
1010 |
|
|
1011 |
0
|
currentPubs.remove(publicationType); |
1012 |
|
} |
1013 |
|
} |
1014 |
|
} |
1015 |
|
|
1016 |
|
|
1017 |
50
|
for (Map.Entry<String, CluPublicationInfo> entry : currentPubs.entrySet()) { |
1018 |
|
|
1019 |
|
|
1020 |
0
|
deletePublicationInfo(results, entry.getValue()); |
1021 |
|
} |
1022 |
|
|
1023 |
50
|
return results; |
1024 |
|
} |
1025 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
1026 |
55
|
private CluPublicationInfo buildCluPublicationInfo(String programId, String publicationType) throws AssemblyException {... |
1027 |
|
|
1028 |
55
|
CluPublicationInfo pubInfo = new CluPublicationInfo(); |
1029 |
55
|
pubInfo.setType(publicationType); |
1030 |
55
|
pubInfo.setCluId(programId); |
1031 |
55
|
pubInfo.setState(ProgramAssemblerConstants.ACTIVE); |
1032 |
|
|
1033 |
55
|
return pubInfo; |
1034 |
|
} |
1035 |
|
|
1036 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1037 |
1
|
public void setLuService(LuService luService) {... |
1038 |
1
|
this.luService = luService; |
1039 |
|
} |
1040 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
1041 |
1
|
public void setCluAssemblerUtils(CluAssemblerUtils cluAssemblerUtils) {... |
1042 |
1
|
this.cluAssemblerUtils = cluAssemblerUtils; |
1043 |
|
} |
1044 |
|
|
|
|
| 61.5% |
Uncovered Elements: 5 (13) |
Complexity: 5 |
Complexity Density: 0.56 |
|
1045 |
14
|
public String getCredentialProgramID(String cluId) throws AssemblyException {... |
1046 |
|
|
1047 |
14
|
List<String> credentialProgramIDs = null; |
1048 |
14
|
try { |
1049 |
14
|
credentialProgramIDs = luService.getCluIdsByRelation(cluId, ProgramAssemblerConstants.HAS_MAJOR_PROGRAM); |
1050 |
|
} catch (Exception e) { |
1051 |
0
|
throw new AssemblyException(e); |
1052 |
|
} |
1053 |
|
|
1054 |
|
|
1055 |
14
|
if (null == credentialProgramIDs || credentialProgramIDs.isEmpty()) { |
1056 |
0
|
throw new AssemblyException("Program with ID == " + cluId + " has no Credential Program associated with it."); |
1057 |
14
|
} else if (credentialProgramIDs.size() > 1) { |
1058 |
0
|
throw new AssemblyException("Program with ID == " + cluId + " has more than one Credential Program associated with it."); |
1059 |
|
} |
1060 |
14
|
return credentialProgramIDs.get(0); |
1061 |
|
} |
1062 |
|
} |