| 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.List; |
| 19 |
|
|
| 20 |
|
import org.apache.log4j.Logger; |
| 21 |
|
import org.kuali.student.common.assembly.BOAssembler; |
| 22 |
|
import org.kuali.student.common.assembly.BaseDTOAssemblyNode; |
| 23 |
|
import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation; |
| 24 |
|
import org.kuali.student.common.assembly.data.AssemblyException; |
| 25 |
|
import org.kuali.student.common.dto.AmountInfo; |
| 26 |
|
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 27 |
|
import org.kuali.student.lum.lu.dto.CluInfo; |
| 28 |
|
import org.kuali.student.lum.lu.service.LuService; |
| 29 |
|
import org.kuali.student.lum.program.dto.ProgramVariationInfo; |
| 30 |
|
import org.kuali.student.lum.service.assembler.CluAssemblerUtils; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
@author |
| 34 |
|
|
| 35 |
|
|
|
|
|
| 0% |
Uncovered Elements: 94 (94) |
Complexity: 22 |
Complexity Density: 0.34 |
|
| 36 |
|
public class ProgramVariationAssembler implements BOAssembler<ProgramVariationInfo, CluInfo> { |
| 37 |
|
final static Logger LOG = Logger.getLogger(ProgramVariationAssembler.class); |
| 38 |
|
|
| 39 |
|
private LuService luService; |
| 40 |
|
private CluAssemblerUtils cluAssemblerUtils; |
| 41 |
|
private ProgramAssemblerUtils programAssemblerUtils; |
| 42 |
|
|
|
|
|
| 0% |
Uncovered Elements: 25 (25) |
Complexity: 4 |
Complexity Density: 0.21 |
|
| 43 |
0
|
@Override... |
| 44 |
|
public ProgramVariationInfo assemble(CluInfo clu, ProgramVariationInfo programVariation, boolean shallowBuild) throws AssemblyException { |
| 45 |
|
|
| 46 |
0
|
ProgramVariationInfo pvInfo = (null != programVariation) ? programVariation : new ProgramVariationInfo(); |
| 47 |
|
|
| 48 |
|
|
| 49 |
0
|
programAssemblerUtils.assembleBasics(clu, pvInfo); |
| 50 |
0
|
programAssemblerUtils.assembleIdentifiers(clu, pvInfo); |
| 51 |
0
|
programAssemblerUtils.assembleBasicAdminOrgs(clu, pvInfo); |
| 52 |
0
|
programAssemblerUtils.assembleFullOrgs(clu, pvInfo); |
| 53 |
0
|
programAssemblerUtils.assembleAtps(clu, pvInfo); |
| 54 |
0
|
programAssemblerUtils.assembleLuCodes(clu, pvInfo); |
| 55 |
0
|
programAssemblerUtils.assemblePublications(clu, pvInfo); |
| 56 |
|
|
| 57 |
0
|
if (!shallowBuild) { |
| 58 |
0
|
programAssemblerUtils.assembleRequirements(clu, pvInfo); |
| 59 |
0
|
pvInfo.setResultOptions(programAssemblerUtils.assembleResultOptions(clu.getId())); |
| 60 |
0
|
pvInfo.setLearningObjectives(cluAssemblerUtils.assembleLos(clu.getId(), shallowBuild)); |
| 61 |
|
} |
| 62 |
|
|
| 63 |
0
|
pvInfo.setIntensity((null != clu.getIntensity()) ? clu.getIntensity().getUnitType() : null); |
| 64 |
0
|
pvInfo.setStdDuration(clu.getStdDuration()); |
| 65 |
0
|
pvInfo.setCampusLocations(clu.getCampusLocations()); |
| 66 |
0
|
pvInfo.setEffectiveDate(clu.getEffectiveDate()); |
| 67 |
0
|
pvInfo.setDescr(clu.getDescr()); |
| 68 |
0
|
pvInfo.setVersionInfo(clu.getVersionInfo()); |
| 69 |
|
|
| 70 |
0
|
return pvInfo; |
| 71 |
|
} |
| 72 |
|
|
|
|
|
| 0% |
Uncovered Elements: 47 (47) |
Complexity: 9 |
Complexity Density: 0.26 |
|
| 73 |
0
|
@Override... |
| 74 |
|
public BaseDTOAssemblyNode<ProgramVariationInfo, CluInfo> disassemble(ProgramVariationInfo variation, NodeOperation operation) throws AssemblyException { |
| 75 |
0
|
BaseDTOAssemblyNode<ProgramVariationInfo, CluInfo> result = new BaseDTOAssemblyNode<ProgramVariationInfo, CluInfo>(this); |
| 76 |
|
|
| 77 |
0
|
if (variation == null) { |
| 78 |
|
|
| 79 |
|
|
| 80 |
0
|
LOG.error("Variation to disassemble is null!"); |
| 81 |
0
|
throw new AssemblyException("Variation can not be null"); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
0
|
CluInfo clu; |
| 85 |
0
|
try { |
| 86 |
0
|
clu = (NodeOperation.UPDATE == operation) ? luService.getClu(variation.getId()) : new CluInfo(); |
| 87 |
|
} catch (Exception e) { |
| 88 |
0
|
throw new AssemblyException("Error getting existing learning unit during variation update", e); |
| 89 |
|
} |
| 90 |
|
|
| 91 |
0
|
boolean stateChanged = NodeOperation.UPDATE == operation && variation.getState() != null && !variation.getState().equals(clu.getState()); |
| 92 |
|
|
| 93 |
0
|
programAssemblerUtils.disassembleBasics(clu, variation); |
| 94 |
0
|
if (variation.getId() == null) |
| 95 |
0
|
variation.setId(clu.getId()); |
| 96 |
0
|
programAssemblerUtils.disassembleIdentifiers(clu, variation, operation); |
| 97 |
0
|
programAssemblerUtils.disassembleAdminOrgs(clu, variation, operation); |
| 98 |
0
|
programAssemblerUtils.disassembleAtps(clu, variation, operation); |
| 99 |
0
|
programAssemblerUtils.disassembleLuCodes(clu, variation, operation); |
| 100 |
0
|
programAssemblerUtils.disassemblePublications(clu, variation, operation, result); |
| 101 |
|
|
| 102 |
0
|
if(variation.getProgramRequirements() != null && !variation.getProgramRequirements().isEmpty()) { |
| 103 |
0
|
programAssemblerUtils.disassembleRequirements(clu, variation, operation, result, stateChanged); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
0
|
if (variation.getResultOptions() != null) { |
| 107 |
0
|
disassembleResultOptions(variation, operation, result); |
| 108 |
|
} |
| 109 |
|
|
| 110 |
0
|
if (variation.getLearningObjectives() != null) { |
| 111 |
0
|
disassembleLearningObjectives(variation, operation, result); |
| 112 |
|
} |
| 113 |
|
|
| 114 |
0
|
AmountInfo intensity = new AmountInfo(); |
| 115 |
0
|
intensity.setUnitType(variation.getIntensity()); |
| 116 |
0
|
clu.setIntensity(intensity); |
| 117 |
0
|
clu.setStdDuration(variation.getStdDuration()); |
| 118 |
0
|
clu.setCampusLocations(variation.getCampusLocations()); |
| 119 |
0
|
clu.setEffectiveDate(variation.getEffectiveDate()); |
| 120 |
0
|
clu.setDescr(variation.getDescr()); |
| 121 |
0
|
clu.setVersionInfo(variation.getVersionInfo()); |
| 122 |
|
|
| 123 |
|
|
| 124 |
0
|
result.setNodeData(clu); |
| 125 |
0
|
result.setOperation(operation); |
| 126 |
0
|
result.setBusinessDTORef(variation); |
| 127 |
0
|
return result; |
| 128 |
|
|
| 129 |
|
} |
| 130 |
|
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 4 |
Complexity Density: 0.8 |
|
| 131 |
0
|
private void disassembleLearningObjectives(ProgramVariationInfo variation, NodeOperation operation, BaseDTOAssemblyNode<ProgramVariationInfo, CluInfo> result) throws AssemblyException {... |
| 132 |
0
|
try { |
| 133 |
0
|
List<BaseDTOAssemblyNode<?, ?>> loResults = cluAssemblerUtils.disassembleLos(variation.getId(), variation.getState(), variation.getLearningObjectives(), operation); |
| 134 |
0
|
if (loResults != null) { |
| 135 |
0
|
result.getChildNodes().addAll(loResults); |
| 136 |
|
} |
| 137 |
|
} catch (DoesNotExistException e) { |
| 138 |
|
} catch (Exception e) { |
| 139 |
0
|
throw new AssemblyException("Error while disassembling los", e); |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
| 143 |
0
|
private void disassembleResultOptions(ProgramVariationInfo variation, NodeOperation operation, BaseDTOAssemblyNode<ProgramVariationInfo, CluInfo> result) throws AssemblyException {... |
| 144 |
0
|
BaseDTOAssemblyNode<?, ?> resultOptions = cluAssemblerUtils.disassembleCluResults( |
| 145 |
|
variation.getId(), variation.getState(), variation.getResultOptions(), operation, ProgramAssemblerConstants.DEGREE_RESULTS, "Result options", "Result option"); |
| 146 |
0
|
if (resultOptions != null) { |
| 147 |
0
|
result.getChildNodes().add(resultOptions); |
| 148 |
|
} |
| 149 |
|
} |
| 150 |
|
|
| 151 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 152 |
0
|
public void setLuService(LuService luService) {... |
| 153 |
0
|
this.luService = luService; |
| 154 |
|
} |
| 155 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 156 |
0
|
public void setCluAssemblerUtils(CluAssemblerUtils cluAssemblerUtils) {... |
| 157 |
0
|
this.cluAssemblerUtils = cluAssemblerUtils; |
| 158 |
|
} |
| 159 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 160 |
0
|
public void setProgramAssemblerUtils(ProgramAssemblerUtils programAssemblerUtils) {... |
| 161 |
0
|
this.programAssemblerUtils = programAssemblerUtils; |
| 162 |
|
} |
| 163 |
|
} |