Clover Coverage Report - Kuali Student 1.3.0-SNAPSHOT (Aggregated)
Coverage timestamp: Thu Apr 28 2011 05:03:32 EDT
../../../../../../../img/srcFileCovDistChart0.png 2% of files have more coverage
65   163   22   9.29
22   113   0.34   7
7     3.14  
1    
 
  ProgramVariationAssembler       Line # 36 65 0% 22 94 0% 0.0
 
No Tests
 
1    /*
2    * Copyright 2007 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 1.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl1.php
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
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 KS
34    *
35    */
 
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   
 
43  0 toggle @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    // Copy all the data from the clu to the programvariation
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   
 
73  0 toggle @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    // FIXME Unsure now if this is an exception or just return null or
79    // empty assemblyNode
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    // Add the Clu to the result
124  0 result.setNodeData(clu);
125  0 result.setOperation(operation);
126  0 result.setBusinessDTORef(variation);
127  0 return result;
128   
129    }
130   
 
131  0 toggle 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   
 
143  0 toggle 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    // Spring setter
 
152  0 toggle public void setLuService(LuService luService) {
153  0 this.luService = luService;
154    }
155   
 
156  0 toggle public void setCluAssemblerUtils(CluAssemblerUtils cluAssemblerUtils) {
157  0 this.cluAssemblerUtils = cluAssemblerUtils;
158    }
159   
 
160  0 toggle public void setProgramAssemblerUtils(ProgramAssemblerUtils programAssemblerUtils) {
161  0 this.programAssemblerUtils = programAssemblerUtils;
162    }
163    }