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