| 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.List; |
| 20 |
|
import java.util.Map; |
| 21 |
|
|
| 22 |
|
import org.apache.log4j.Logger; |
| 23 |
|
import org.kuali.student.common.assembly.BOAssembler; |
| 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.AmountInfo; |
| 28 |
|
import org.kuali.student.common.dto.DtoConstants; |
| 29 |
|
import org.kuali.student.common.exceptions.DataValidationErrorException; |
| 30 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 31 |
|
import org.kuali.student.common.exceptions.InvalidParameterException; |
| 32 |
|
import org.kuali.student.common.exceptions.MissingParameterException; |
| 33 |
|
import org.kuali.student.common.exceptions.OperationFailedException; |
| 34 |
|
import org.kuali.student.lum.course.service.assembler.CourseAssembler; |
| 35 |
|
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
| 36 |
|
import org.kuali.student.lum.lu.dto.CluInfo; |
| 37 |
|
import org.kuali.student.lum.lu.service.LuService; |
| 38 |
|
import org.kuali.student.lum.program.dto.CoreProgramInfo; |
| 39 |
|
import org.kuali.student.lum.program.dto.MajorDisciplineInfo; |
| 40 |
|
import org.kuali.student.lum.program.dto.ProgramVariationInfo; |
| 41 |
|
import org.kuali.student.lum.service.assembler.CluAssemblerUtils; |
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
@author |
| 46 |
|
|
| 47 |
|
|
|
|
|
| 87.2% |
Uncovered Elements: 28 (219) |
Complexity: 59 |
Complexity Density: 0.39 |
|
| 48 |
|
public class MajorDisciplineAssembler implements BOAssembler<MajorDisciplineInfo, CluInfo> { |
| 49 |
|
final static Logger LOG = Logger.getLogger(CourseAssembler.class); |
| 50 |
|
|
| 51 |
|
private LuService luService; |
| 52 |
|
|
| 53 |
|
private ProgramVariationAssembler programVariationAssembler; |
| 54 |
|
private CoreProgramAssembler coreProgramAssembler; |
| 55 |
|
private CluAssemblerUtils cluAssemblerUtils; |
| 56 |
|
private ProgramAssemblerUtils programAssemblerUtils; |
| 57 |
|
|
|
|
|
| 96.8% |
Uncovered Elements: 1 (31) |
Complexity: 4 |
Complexity Density: 0.16 |
|
| 58 |
27
|
@Override... |
| 59 |
|
public MajorDisciplineInfo assemble(CluInfo clu, MajorDisciplineInfo majorDiscipline, boolean shallowBuild) throws AssemblyException { |
| 60 |
27
|
MajorDisciplineInfo mdInfo = (null != majorDiscipline) ? majorDiscipline : new MajorDisciplineInfo(); |
| 61 |
|
|
| 62 |
|
|
| 63 |
27
|
programAssemblerUtils.assembleBasics(clu, mdInfo); |
| 64 |
27
|
programAssemblerUtils.assembleIdentifiers(clu, mdInfo); |
| 65 |
27
|
programAssemblerUtils.assembleBasicAdminOrgs(clu, mdInfo); |
| 66 |
27
|
programAssemblerUtils.assembleFullOrgs(clu, mdInfo); |
| 67 |
27
|
programAssemblerUtils.assembleAtps(clu, mdInfo); |
| 68 |
27
|
programAssemblerUtils.assembleLuCodes(clu, mdInfo); |
| 69 |
|
|
| 70 |
27
|
mdInfo.setIntensity((null != clu.getIntensity()) ? clu.getIntensity().getUnitType() : null); |
| 71 |
27
|
mdInfo.setStdDuration(clu.getStdDuration()); |
| 72 |
27
|
mdInfo.setPublishedInstructors(clu.getInstructors()); |
| 73 |
27
|
mdInfo.setCampusLocations(clu.getCampusLocations()); |
| 74 |
27
|
mdInfo.setAccreditingAgencies(clu.getAccreditations()); |
| 75 |
27
|
mdInfo.setEffectiveDate(clu.getEffectiveDate()); |
| 76 |
27
|
mdInfo.setDescr(clu.getDescr()); |
| 77 |
27
|
mdInfo.setVersionInfo(clu.getVersionInfo()); |
| 78 |
27
|
mdInfo.setNextReviewPeriod(clu.getNextReviewPeriod()); |
| 79 |
|
|
| 80 |
27
|
if (!shallowBuild) { |
| 81 |
14
|
programAssemblerUtils.assembleRequirements(clu, mdInfo); |
| 82 |
14
|
mdInfo.setCredentialProgramId(programAssemblerUtils.getCredentialProgramID(clu.getId())); |
| 83 |
14
|
mdInfo.setResultOptions(programAssemblerUtils.assembleResultOptions(clu.getId())); |
| 84 |
14
|
mdInfo.setLearningObjectives(cluAssemblerUtils.assembleLos(clu.getId(), shallowBuild)); |
| 85 |
14
|
mdInfo.setVariations(assembleVariations(clu.getId(), shallowBuild)); |
| 86 |
14
|
mdInfo.setOrgCoreProgram(assembleCoreProgram(clu.getId(), shallowBuild)); |
| 87 |
14
|
programAssemblerUtils.assemblePublications(clu, mdInfo); |
| 88 |
|
} |
| 89 |
|
|
| 90 |
27
|
return mdInfo; |
| 91 |
|
} |
| 92 |
|
|
|
|
|
| 76.9% |
Uncovered Elements: 3 (13) |
Complexity: 4 |
Complexity Density: 0.44 |
|
| 93 |
14
|
private CoreProgramInfo assembleCoreProgram(String cluId, boolean shallowBuild) throws AssemblyException {... |
| 94 |
14
|
CoreProgramInfo coreProgramInfo = null; |
| 95 |
14
|
try { |
| 96 |
14
|
List<CluInfo> corePrograms = luService.getRelatedClusByCluId(cluId, ProgramAssemblerConstants.HAS_CORE_PROGRAM); |
| 97 |
|
|
| 98 |
14
|
if (corePrograms.size() == 1) { |
| 99 |
12
|
coreProgramInfo = coreProgramAssembler.assemble(corePrograms.get(0), null, shallowBuild); |
| 100 |
2
|
} else if (corePrograms.size() > 1) { |
| 101 |
0
|
throw new AssemblyException(new DataValidationErrorException("MajorDiscipline has more than one associated Core Program")); |
| 102 |
|
} |
| 103 |
|
} catch (Exception e) { |
| 104 |
0
|
throw new AssemblyException(e); |
| 105 |
|
} |
| 106 |
14
|
return coreProgramInfo; |
| 107 |
|
} |
| 108 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 109 |
14
|
private List<ProgramVariationInfo> assembleVariations(String cluId, boolean shallowBuild) throws AssemblyException {... |
| 110 |
14
|
List<ProgramVariationInfo> variations = new ArrayList<ProgramVariationInfo>(); |
| 111 |
|
|
| 112 |
14
|
try { |
| 113 |
14
|
Map<String, CluCluRelationInfo> currentRelations = null; |
| 114 |
14
|
currentRelations = programAssemblerUtils.getCluCluActiveRelations(cluId, ProgramAssemblerConstants.HAS_PROGRAM_VARIATION); |
| 115 |
|
|
| 116 |
14
|
if(currentRelations != null && !currentRelations.isEmpty()){ |
| 117 |
14
|
for (String variationId : currentRelations.keySet()) { |
| 118 |
30
|
CluInfo variationClu = luService.getClu(variationId); |
| 119 |
30
|
variations.add(programVariationAssembler.assemble(variationClu, null, shallowBuild)); |
| 120 |
|
} |
| 121 |
|
} |
| 122 |
|
} catch (Exception e) { |
| 123 |
0
|
throw new AssemblyException(e); |
| 124 |
|
} |
| 125 |
14
|
return variations; |
| 126 |
|
} |
| 127 |
|
|
|
|
|
| 86.2% |
Uncovered Elements: 9 (65) |
Complexity: 14 |
Complexity Density: 0.3 |
|
| 128 |
11
|
@Override... |
| 129 |
|
public BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> disassemble(MajorDisciplineInfo major, NodeOperation operation) throws AssemblyException { |
| 130 |
11
|
if (major == null) { |
| 131 |
0
|
LOG.error("Major for disassemble is null!"); |
| 132 |
0
|
throw new AssemblyException("Major cannot be null"); |
| 133 |
|
} |
| 134 |
|
|
| 135 |
|
|
| 136 |
|
|
| 137 |
11
|
BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result = new BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo>( |
| 138 |
|
this); |
| 139 |
|
|
| 140 |
11
|
CluInfo clu; |
| 141 |
11
|
try { |
| 142 |
11
|
clu = (NodeOperation.UPDATE == operation) ? luService.getClu(major.getId()) : new CluInfo(); |
| 143 |
|
} catch (Exception e) { |
| 144 |
0
|
throw new AssemblyException("Error getting existing learning unit during major update", e); |
| 145 |
|
} |
| 146 |
|
|
| 147 |
11
|
boolean stateChanged = NodeOperation.UPDATE == operation && major.getState() != null && !major.getState().equals(clu.getState()); |
| 148 |
|
|
| 149 |
11
|
programAssemblerUtils.disassembleBasics(clu, major); |
| 150 |
11
|
if (major.getId() == null) |
| 151 |
3
|
major.setId(clu.getId()); |
| 152 |
11
|
programAssemblerUtils.disassembleLuCodes(clu, major, operation); |
| 153 |
11
|
programAssemblerUtils.disassembleAdminOrgs(clu, major, operation); |
| 154 |
11
|
programAssemblerUtils.disassembleAtps(clu, major, operation); |
| 155 |
11
|
programAssemblerUtils.disassembleIdentifiers(clu, major, operation); |
| 156 |
11
|
programAssemblerUtils.disassemblePublications(clu, major, operation, result); |
| 157 |
|
|
| 158 |
11
|
if(major.getProgramRequirements() != null && !major.getProgramRequirements().isEmpty()) { |
| 159 |
4
|
programAssemblerUtils.disassembleRequirements(clu, major, operation, result, stateChanged); |
| 160 |
|
} |
| 161 |
|
|
| 162 |
11
|
if (major.getVariations() != null && !major.getVariations().isEmpty()) { |
| 163 |
11
|
try { |
| 164 |
11
|
disassembleVariations(major, operation, result); |
| 165 |
|
} catch (Exception e) { |
| 166 |
0
|
throw new AssemblyException("Error diassembling Variations during major update", e); |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
11
|
if (major.getOrgCoreProgram() != null ) { |
| 170 |
9
|
disassembleCoreProgram(major, operation, result); |
| 171 |
|
} |
| 172 |
11
|
if (major.getCredentialProgramId() != null) { |
| 173 |
11
|
disassembleCredentialProgram(major, operation, result); |
| 174 |
|
} |
| 175 |
11
|
if (major.getResultOptions() != null) { |
| 176 |
11
|
disassembleResultOptions(major, operation, result); |
| 177 |
|
} |
| 178 |
11
|
if (major.getLearningObjectives() != null) { |
| 179 |
11
|
disassembleLearningObjectives(major, operation, result); |
| 180 |
|
} |
| 181 |
|
|
| 182 |
11
|
AmountInfo intensity = new AmountInfo(); |
| 183 |
11
|
intensity.setUnitType(major.getIntensity()); |
| 184 |
11
|
clu.setIntensity(intensity); |
| 185 |
11
|
clu.setStdDuration(major.getStdDuration()); |
| 186 |
11
|
clu.setInstructors(major.getPublishedInstructors()); |
| 187 |
|
|
| 188 |
11
|
clu.setNextReviewPeriod(major.getNextReviewPeriod()); |
| 189 |
11
|
clu.setEffectiveDate(major.getEffectiveDate()); |
| 190 |
|
|
| 191 |
11
|
clu.setCampusLocations(major.getCampusLocations()); |
| 192 |
11
|
clu.setDescr(major.getDescr()); |
| 193 |
|
|
| 194 |
11
|
clu.setAccreditations(major.getAccreditingAgencies()); |
| 195 |
11
|
clu.setNextReviewPeriod(major.getNextReviewPeriod()); |
| 196 |
11
|
clu.setState(major.getState()); |
| 197 |
|
|
| 198 |
|
|
| 199 |
11
|
result.setNodeData(clu); |
| 200 |
11
|
result.setOperation(operation); |
| 201 |
11
|
result.setBusinessDTORef(major); |
| 202 |
|
|
| 203 |
11
|
return result; |
| 204 |
|
} |
| 205 |
|
|
|
|
|
| 71.4% |
Uncovered Elements: 2 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 206 |
11
|
private void disassembleLearningObjectives(MajorDisciplineInfo major, NodeOperation operation, BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result) throws AssemblyException {... |
| 207 |
11
|
try { |
| 208 |
11
|
List<BaseDTOAssemblyNode<?, ?>> loResults = cluAssemblerUtils.disassembleLos(major.getId(), major.getState(), major.getLearningObjectives(), operation); |
| 209 |
11
|
if (loResults != null) { |
| 210 |
11
|
result.getChildNodes().addAll(loResults); |
| 211 |
|
} |
| 212 |
|
} catch (DoesNotExistException e) { |
| 213 |
|
} catch (Exception e) { |
| 214 |
0
|
throw new AssemblyException("Error while disassembling los", e); |
| 215 |
|
} |
| 216 |
|
} |
| 217 |
|
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 218 |
11
|
private void disassembleResultOptions(MajorDisciplineInfo major, NodeOperation operation, BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result) throws AssemblyException {... |
| 219 |
|
|
| 220 |
|
|
| 221 |
11
|
BaseDTOAssemblyNode<?, ?> degreeResults = cluAssemblerUtils.disassembleCluResults( |
| 222 |
|
major.getId(), major.getState(), major.getResultOptions(), operation, ProgramAssemblerConstants.DEGREE_RESULTS, "Result options", "Result option"); |
| 223 |
11
|
if (degreeResults != null) { |
| 224 |
11
|
result.getChildNodes().add(degreeResults); |
| 225 |
|
} |
| 226 |
|
} |
| 227 |
|
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 228 |
11
|
private void disassembleCredentialProgram(MajorDisciplineInfo major, NodeOperation operation, BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result) throws AssemblyException {... |
| 229 |
|
|
| 230 |
11
|
List<BaseDTOAssemblyNode<?,?>> credentialResults; |
| 231 |
11
|
try { |
| 232 |
11
|
credentialResults = programAssemblerUtils.disassembleCredentialProgram(major, operation, ProgramAssemblerConstants.HAS_MAJOR_PROGRAM); |
| 233 |
11
|
if (credentialResults != null) { |
| 234 |
11
|
result.getChildNodes().addAll(credentialResults); |
| 235 |
|
} |
| 236 |
|
} catch (Exception e) { |
| 237 |
0
|
throw new AssemblyException("Error while disassembling Credential program", e); |
| 238 |
|
} |
| 239 |
|
} |
| 240 |
|
|
|
|
|
| 88.6% |
Uncovered Elements: 4 (35) |
Complexity: 12 |
Complexity Density: 0.52 |
|
| 241 |
11
|
private void disassembleVariations(MajorDisciplineInfo major, NodeOperation operation, BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result) throws AssemblyException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException {... |
| 242 |
11
|
Map<String, CluCluRelationInfo> currentRelations = null; |
| 243 |
11
|
List<BaseDTOAssemblyNode<?, ?>> nodes = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
| 244 |
|
|
| 245 |
11
|
if (!NodeOperation.CREATE.equals(operation)){ |
| 246 |
8
|
currentRelations = programAssemblerUtils.getCluCluActiveRelations(major.getId(), ProgramAssemblerConstants.HAS_PROGRAM_VARIATION); |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
|
| 250 |
11
|
for (ProgramVariationInfo variation : major.getVariations()) { |
| 251 |
23
|
BaseDTOAssemblyNode<?,?> variationNode; |
| 252 |
23
|
variation.setState(major.getState()); |
| 253 |
23
|
try { |
| 254 |
23
|
if (NodeOperation.UPDATE.equals(operation) && variation.getId() != null |
| 255 |
|
&& (currentRelations != null && currentRelations.containsKey(variation.getId()))) { |
| 256 |
|
|
| 257 |
|
|
| 258 |
16
|
variationNode = programVariationAssembler.disassemble(variation, operation); |
| 259 |
16
|
if (variationNode != null) nodes.add(variationNode); |
| 260 |
16
|
currentRelations.remove(variation.getId()); |
| 261 |
7
|
} else if (!NodeOperation.DELETE.equals(operation)) { |
| 262 |
|
|
| 263 |
7
|
variationNode = programVariationAssembler.disassemble(variation, NodeOperation.CREATE); |
| 264 |
7
|
if (variationNode != null) nodes.add(variationNode); |
| 265 |
7
|
programAssemblerUtils.addCreateRelationNode(major.getId(), variation.getId(), ProgramAssemblerConstants.HAS_PROGRAM_VARIATION, nodes); |
| 266 |
|
} |
| 267 |
|
} catch (Exception e) { |
| 268 |
0
|
throw new AssemblyException("Error while disassembling Variation", e); |
| 269 |
|
} |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
|
| 273 |
11
|
if(currentRelations != null && currentRelations.size() > 0){ |
| 274 |
1
|
programAssemblerUtils.addSuspendedRelationNodes(currentRelations, nodes); |
| 275 |
1
|
addInactivateVariationNodes(currentRelations, nodes); |
| 276 |
|
} |
| 277 |
|
|
| 278 |
11
|
result.getChildNodes().addAll(nodes); |
| 279 |
|
} |
| 280 |
|
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
| 281 |
1
|
private void addInactivateVariationNodes(Map<String, CluCluRelationInfo> currentRelations, List<BaseDTOAssemblyNode<?, ?>> nodes) throws AssemblyException{... |
| 282 |
1
|
for (String variationId : currentRelations.keySet()) { |
| 283 |
1
|
CluInfo variationClu; |
| 284 |
1
|
try { |
| 285 |
1
|
variationClu = luService.getClu(variationId); |
| 286 |
1
|
ProgramVariationInfo delVariation = programVariationAssembler.assemble(variationClu, null, true); |
| 287 |
1
|
delVariation.setState(DtoConstants.STATE_SUSPENDED); |
| 288 |
1
|
BaseDTOAssemblyNode<?,?> variationNode = programVariationAssembler.disassemble(delVariation , NodeOperation.UPDATE); |
| 289 |
1
|
if (variationNode != null) nodes.add(variationNode); |
| 290 |
|
} catch (Exception e) { |
| 291 |
0
|
throw new AssemblyException("Error while disassembling variation, deactivateVariations", e); |
| 292 |
|
} |
| 293 |
|
} |
| 294 |
|
} |
| 295 |
|
|
|
|
|
| 77.8% |
Uncovered Elements: 2 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 296 |
9
|
private void disassembleCoreProgram(MajorDisciplineInfo major, NodeOperation operation, BaseDTOAssemblyNode<MajorDisciplineInfo, CluInfo> result) throws AssemblyException {... |
| 297 |
|
|
| 298 |
9
|
BaseDTOAssemblyNode<?,?> coreResults; |
| 299 |
9
|
try { |
| 300 |
9
|
major.getOrgCoreProgram().setState(major.getState()); |
| 301 |
9
|
coreResults = coreProgramAssembler.disassemble(major.getOrgCoreProgram(), operation); |
| 302 |
9
|
if (coreResults != null) { |
| 303 |
9
|
result.getChildNodes().add(coreResults); |
| 304 |
|
} |
| 305 |
|
} catch (Exception e) { |
| 306 |
0
|
throw new AssemblyException("Error while disassembling Core program", e); |
| 307 |
|
} |
| 308 |
|
} |
| 309 |
|
|
| 310 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 311 |
1
|
public void setLuService(LuService luService) {... |
| 312 |
1
|
this.luService = luService; |
| 313 |
|
} |
| 314 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 315 |
1
|
public void setProgramVariationAssembler(ProgramVariationAssembler programVariationAssembler) {... |
| 316 |
1
|
this.programVariationAssembler = programVariationAssembler; |
| 317 |
|
} |
| 318 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 319 |
12
|
public ProgramVariationAssembler getProgramVariationAssembler() {... |
| 320 |
12
|
return programVariationAssembler; |
| 321 |
|
} |
| 322 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 323 |
1
|
public void setCoreProgramAssembler(CoreProgramAssembler coreProgramAssembler) {... |
| 324 |
1
|
this.coreProgramAssembler = coreProgramAssembler; |
| 325 |
|
} |
| 326 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 327 |
1
|
public void setCluAssemblerUtils(CluAssemblerUtils cluAssemblerUtils) {... |
| 328 |
1
|
this.cluAssemblerUtils = cluAssemblerUtils; |
| 329 |
|
} |
| 330 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 331 |
1
|
public void setProgramAssemblerUtils(ProgramAssemblerUtils programAssemblerUtils) {... |
| 332 |
1
|
this.programAssemblerUtils = programAssemblerUtils; |
| 333 |
|
} |
| 334 |
|
} |