Clover Coverage Report - Kuali Student 1.2-M6-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Sep 12 2011 05:03:53 EDT
../../../../../../img/srcFileCovDistChart8.png 29% of files have more coverage
214   378   85   16.46
56   333   0.4   13
13     6.54  
1    
 
  LumServiceMethodInvoker       Line # 42 214 0% 85 76 73.1% 0.73144877
 
  (32)
 
1    package org.kuali.student.lum.service.assembler;
2   
3    import java.util.List;
4   
5    import org.apache.log4j.Logger;
6    import org.kuali.student.common.assembly.BaseDTOAssemblyNode;
7    import org.kuali.student.common.assembly.BusinessServiceMethodInvoker;
8    import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation;
9    import org.kuali.student.common.assembly.data.AssemblyException;
10    import org.kuali.student.common.exceptions.AlreadyExistsException;
11    import org.kuali.student.common.exceptions.CircularReferenceException;
12    import org.kuali.student.common.exceptions.CircularRelationshipException;
13    import org.kuali.student.common.exceptions.DataValidationErrorException;
14    import org.kuali.student.common.exceptions.DependentObjectsExistException;
15    import org.kuali.student.common.exceptions.DoesNotExistException;
16    import org.kuali.student.common.exceptions.InvalidParameterException;
17    import org.kuali.student.common.exceptions.MissingParameterException;
18    import org.kuali.student.common.exceptions.OperationFailedException;
19    import org.kuali.student.common.exceptions.PermissionDeniedException;
20    import org.kuali.student.common.exceptions.UnsupportedActionException;
21    import org.kuali.student.common.exceptions.VersionMismatchException;
22    import org.kuali.student.core.atp.service.AtpService;
23    import org.kuali.student.core.organization.service.OrganizationService;
24    import org.kuali.student.core.statement.dto.RefStatementRelationInfo;
25    import org.kuali.student.core.statement.dto.ReqComponentInfo;
26    import org.kuali.student.core.statement.dto.StatementInfo;
27    import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
28    import org.kuali.student.core.statement.service.StatementService;
29    import org.kuali.student.lum.course.service.assembler.LoCategoryRelationInfo;
30    import org.kuali.student.lum.lo.dto.LoInfo;
31    import org.kuali.student.lum.lo.dto.LoLoRelationInfo;
32    import org.kuali.student.lum.lo.service.LearningObjectiveService;
33    import org.kuali.student.lum.lrc.dto.ResultComponentInfo;
34    import org.kuali.student.lum.lrc.service.LrcService;
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.dto.CluLoRelationInfo;
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.service.LuService;
41   
 
42    public class LumServiceMethodInvoker implements BusinessServiceMethodInvoker {
43    final Logger LOG = Logger.getLogger(LumServiceMethodInvoker.class);
44    private LuService luService;
45    private StatementService statementService;
46    private LearningObjectiveService loService;
47    private OrganizationService orgService;
48    private AtpService atpService;
49    private LrcService lrcService;
50   
 
51  3352 toggle @SuppressWarnings("unchecked")
52    public final void invokeServiceCalls(BaseDTOAssemblyNode results)
53    throws AlreadyExistsException, DataValidationErrorException,
54    DoesNotExistException, InvalidParameterException,
55    MissingParameterException, OperationFailedException,
56    PermissionDeniedException, VersionMismatchException,
57    DependentObjectsExistException, CircularRelationshipException,
58    AssemblyException, UnsupportedActionException, UnsupportedOperationException, CircularReferenceException {
59   
60    // For Delete operation process the tree from bottom up
61  3352 if(NodeOperation.DELETE == results.getOperation()) {
62  130 for(BaseDTOAssemblyNode childNode: (List<BaseDTOAssemblyNode>) results.getChildNodes()){
63  112 invokeServiceCalls(childNode);
64    }
65    }
66   
67  3352 invokeServiceCallOnResult(results);
68   
69    // For create/update process the child nodes from top to bottom
70  3351 if(NodeOperation.DELETE != results.getOperation()) {
71  3221 for(BaseDTOAssemblyNode childNode: (List<BaseDTOAssemblyNode>) results.getChildNodes()){
72  3187 invokeServiceCalls(childNode);
73    }
74    }
75    }
76   
77    /**
78    * @param results
79    * @throws AlreadyExistsException
80    * @throws DataValidationErrorException
81    * @throws DoesNotExistException
82    * @throws InvalidParameterException
83    * @throws MissingParameterException
84    * @throws OperationFailedException
85    * @throws PermissionDeniedException
86    * @throws AssemblyException
87    * @throws VersionMismatchException
88    * @throws DependentObjectsExistException
89    * @throws CircularRelationshipException
90    * @throws UnsupportedActionException
91    * @throws UnsupportedOperationException
92    * @throws CircularReferenceException
93    */
 
94  3352 toggle protected void invokeServiceCallOnResult(BaseDTOAssemblyNode results)
95    throws AlreadyExistsException, DataValidationErrorException,
96    DoesNotExistException, InvalidParameterException,
97    MissingParameterException, OperationFailedException,
98    PermissionDeniedException, AssemblyException,
99    VersionMismatchException, DependentObjectsExistException,
100    CircularRelationshipException, UnsupportedActionException,
101    UnsupportedOperationException, CircularReferenceException {
102  3352 Object nodeData = results.getNodeData();
103  3352 if (nodeData == null) {
104  9 return;
105    }
106   
107  3343 if (LOG.isDebugEnabled()) {
108  0 LOG.debug(results.getOperation() + ": " + nodeData);
109    }
110   
111  3343 if(nodeData instanceof CluInfo){
112  230 CluInfo clu = (CluInfo) nodeData;
113  230 switch(results.getOperation()){
114  169 case CREATE:
115  169 CluInfo newClu = luService.createClu(clu.getType(), clu);
116  169 if(results.getAssembler() != null) {
117  169 results.getAssembler().assemble(newClu, results.getBusinessDTORef(), true);
118    }
119  169 break;
120  48 case UPDATE:
121  48 CluInfo updatedClu = luService.updateClu(clu.getId(), clu);
122  47 if(results.getAssembler() != null) {
123  47 results.getAssembler().assemble(updatedClu, results.getBusinessDTORef(), true);
124    }
125  47 break;
126  13 case DELETE:
127  13 luService.deleteClu(clu.getId());
128  13 break;
129    }
130  3113 }else if(nodeData instanceof CluCluRelationInfo){
131  197 CluCluRelationInfo relation = (CluCluRelationInfo) nodeData;
132  197 switch(results.getOperation()){
133  177 case CREATE:
134  177 CluCluRelationInfo newCluRel = luService.createCluCluRelation(relation.getCluId(), relation.getRelatedCluId(), relation.getType(), relation);
135    // Update the businessDTO if one exists for the cluclurelation (for e.g. CourseJointInfo)
136  177 if(null != results.getBusinessDTORef()) {
137  0 results.getAssembler().assemble(newCluRel, results.getBusinessDTORef(), true);
138    }
139  177 break;
140  1 case UPDATE:
141  1 CluCluRelationInfo updatedCluRel = luService.updateCluCluRelation(relation.getId(), relation);
142    // Update the businessDTO if one exists for the cluclurelation (for e.g. CourseJointInfo)
143  1 if(null != results.getBusinessDTORef()) {
144  0 results.getAssembler().assemble(updatedCluRel, results.getBusinessDTORef(), true);
145    }
146  1 break;
147  19 case DELETE:
148  19 luService.deleteCluCluRelation(relation.getId());
149  19 break;
150    }
151  2916 }else if(nodeData instanceof CluResultInfo){
152  109 CluResultInfo cluResult = (CluResultInfo) nodeData;
153  109 switch(results.getOperation()){
154  86 case CREATE:
155  86 luService.createCluResult(cluResult.getCluId(), cluResult.getType(), cluResult);
156  86 break;
157  19 case UPDATE:
158  19 luService.updateCluResult(cluResult.getId(), cluResult);
159  19 break;
160  4 case DELETE:
161  4 luService.deleteCluResult(cluResult.getId());
162  4 break;
163    }
164  2807 }else if(nodeData instanceof LoCategoryRelationInfo){
165  1331 LoCategoryRelationInfo loCategoryRelation = (LoCategoryRelationInfo) nodeData;
166  1331 switch(results.getOperation()){
167  1289 case CREATE:
168  1289 loService.addLoCategoryToLo(loCategoryRelation.getCategoryId(), loCategoryRelation.getLoId());
169  1289 break;
170  0 case UPDATE:
171  0 throw new UnsupportedOperationException("Can't call update on lo category relations, just add and remove");
172  42 case DELETE:
173  42 loService.removeLoCategoryFromLo(loCategoryRelation.getCategoryId(), loCategoryRelation.getLoId());
174  42 break;
175    }
176  1476 }else if(nodeData instanceof LoInfo){
177  695 LoInfo lo = (LoInfo) nodeData;
178  695 switch(results.getOperation()){
179  651 case CREATE:
180  651 LoInfo createdLo = loService.createLo(lo.getLoRepositoryKey(), lo.getType(), lo);
181  651 if(null != results.getBusinessDTORef()) {
182  651 results.getAssembler().assemble(createdLo, results.getBusinessDTORef(), true);
183    }
184  651 break;
185  21 case UPDATE:
186  21 LoInfo updatedLo = loService.updateLo(lo.getId(), lo);
187  21 if(null != results.getBusinessDTORef()) {
188  21 results.getAssembler().assemble(updatedLo, results.getBusinessDTORef(), true);
189    }
190  21 break;
191  23 case DELETE:
192  23 loService.deleteLo(lo.getId());
193  23 break;
194    }
195  781 }else if(nodeData instanceof LoLoRelationInfo){
196  570 LoLoRelationInfo loRelation = (LoLoRelationInfo) nodeData;
197  570 switch(results.getOperation()){
198  552 case CREATE:
199  552 loService.createLoLoRelation(loRelation.getLoId(), loRelation.getRelatedLoId(), loRelation.getType(), loRelation);
200  552 break;
201  0 case UPDATE:
202  0 loService.updateLoLoRelation(loRelation.getId(), loRelation);
203  0 break;
204  18 case DELETE:
205  18 loService.deleteLoLoRelation(loRelation.getId());
206  18 break;
207    }
208  211 }else if(nodeData instanceof CluLoRelationInfo){
209  104 CluLoRelationInfo cluLoRelation = (CluLoRelationInfo) nodeData;
210  104 switch(results.getOperation()){
211  99 case CREATE:
212  99 luService.createCluLoRelation(cluLoRelation.getCluId(), cluLoRelation.getLoId(), cluLoRelation.getType(), cluLoRelation);
213  99 break;
214  0 case UPDATE:
215  0 luService.updateCluLoRelation(cluLoRelation.getLoId(), cluLoRelation);
216  0 break;
217  5 case DELETE:
218  5 luService.deleteCluLoRelation(cluLoRelation.getId());
219  5 break;
220    }
221  107 }else if(nodeData instanceof ResultComponentInfo){
222  4 ResultComponentInfo resultComponent = (ResultComponentInfo) nodeData;
223  4 switch(results.getOperation()){
224  4 case CREATE:
225  4 ResultComponentInfo createdResultComponent = lrcService.createResultComponent(resultComponent.getType(), resultComponent);
226    //Copy the created back to the reference Should there be an assembler for this?
227  4 if(results.getBusinessDTORef()!=null&& results.getBusinessDTORef() instanceof ResultComponentInfo){
228  4 ResultComponentInfo resultComponentToUpdate = (ResultComponentInfo) results.getBusinessDTORef();
229  4 resultComponentToUpdate.setId(createdResultComponent.getId());
230  4 resultComponentToUpdate.setType(createdResultComponent.getType());
231  4 resultComponentToUpdate.setDesc(createdResultComponent.getDesc());
232  4 resultComponentToUpdate.setEffectiveDate(createdResultComponent.getEffectiveDate());
233  4 resultComponentToUpdate.setExpirationDate(createdResultComponent.getExpirationDate());
234  4 resultComponentToUpdate.setMetaInfo(createdResultComponent.getMetaInfo());
235  4 resultComponentToUpdate.setName(createdResultComponent.getName());
236  4 resultComponentToUpdate.setResultValues(createdResultComponent.getResultValues());
237  4 resultComponentToUpdate.setState(createdResultComponent.getState());
238    }
239  4 break;
240  0 case UPDATE:
241  0 lrcService.updateResultComponent(resultComponent.getId(), resultComponent);
242  0 break;
243  0 case DELETE:
244  0 lrcService.deleteResultComponent(resultComponent.getId());
245  0 break;
246    }
247  103 } else if(nodeData instanceof RefStatementRelationInfo){
248  9 RefStatementRelationInfo relation = (RefStatementRelationInfo) nodeData;
249  9 switch(results.getOperation()){
250  6 case CREATE:
251  6 RefStatementRelationInfo created = statementService.createRefStatementRelation(relation);
252  6 relation.setMetaInfo(created.getMetaInfo());
253  6 break;
254  1 case UPDATE:
255  1 RefStatementRelationInfo updated = statementService.updateRefStatementRelation(relation.getId(), relation);
256  1 relation.setMetaInfo(updated.getMetaInfo());
257  1 break;
258  2 case DELETE:
259  2 statementService.deleteRefStatementRelation(relation.getId());
260  2 break;
261    }
262  94 } else if(nodeData instanceof StatementInfo){
263  0 StatementInfo statement = (StatementInfo) nodeData;
264  0 switch(results.getOperation()){
265  0 case CREATE:
266  0 StatementInfo created = statementService.createStatement(statement.getType(), statement);
267  0 if(results.getAssembler() != null && results.getBusinessDTORef() != null) {
268  0 results.getAssembler().assemble(created, results.getBusinessDTORef(), true);
269    }
270  0 break;
271  0 case UPDATE:
272  0 StatementInfo updated = statementService.updateStatement(statement.getId(), statement);
273  0 if(results.getAssembler() != null && results.getBusinessDTORef() != null) {
274  0 results.getAssembler().assemble(updated, results.getBusinessDTORef(), true);
275    }
276  0 break;
277  0 case DELETE:
278  0 statementService.deleteStatement(statement.getId());
279  0 break;
280    }
281  94 } else if(nodeData instanceof ReqComponentInfo){
282  0 ReqComponentInfo reqComp = (ReqComponentInfo) nodeData;
283  0 switch(results.getOperation()){
284  0 case CREATE:
285  0 ReqComponentInfo created = statementService.createReqComponent(reqComp.getType(), reqComp);
286  0 reqComp.setMetaInfo(created.getMetaInfo());
287  0 break;
288  0 case UPDATE:
289  0 ReqComponentInfo updated = statementService.updateReqComponent(reqComp.getId(), reqComp);
290  0 reqComp.setMetaInfo(updated.getMetaInfo());
291  0 break;
292  0 case DELETE:
293  0 statementService.deleteReqComponent(reqComp.getId());
294  0 break;
295    }
296  94 }else if(nodeData instanceof StatementTreeViewInfo){
297  9 StatementTreeViewInfo treeView = (StatementTreeViewInfo) nodeData;
298  9 switch(results.getOperation()){
299  6 case CREATE:
300  6 StatementTreeViewInfo created = statementService.createStatementTreeView(treeView);
301  6 if(results.getAssembler() != null && results.getBusinessDTORef() != null) {
302  6 results.getAssembler().assemble(created, results.getBusinessDTORef(), true);
303    }
304  6 break;
305  1 case UPDATE:
306  1 StatementTreeViewInfo updated = statementService.updateStatementTreeView(treeView.getId(), treeView);
307  1 if(results.getAssembler() != null && results.getBusinessDTORef() != null) {
308  1 results.getAssembler().assemble(updated, results.getBusinessDTORef(), true);
309    }
310  1 break;
311  2 case DELETE:
312  2 statementService.deleteStatementTreeView(treeView.getId());
313  2 break;
314    }
315  85 }else if(nodeData instanceof CluPublicationInfo){
316  85 CluPublicationInfo cluPublication = (CluPublicationInfo) nodeData;
317  85 switch(results.getOperation()){
318  55 case CREATE:
319  55 luService.createCluPublication(cluPublication.getCluId(), cluPublication.getType(), cluPublication);
320  55 break;
321  30 case UPDATE:
322  30 luService.updateCluPublication(cluPublication.getId(), cluPublication);
323  30 break;
324  0 case DELETE:
325  0 luService.deleteCluPublication(cluPublication.getId());
326  0 break;
327    }
328    }else{
329  0 throw new UnsupportedActionException("This service invoker does not know how to handle nodeData for "+nodeData.getClass().getName());
330    }
331   
332    }
333   
 
334  0 toggle public LuService getLuService() {
335  0 return luService;
336    }
337   
 
338  2 toggle public void setLuService(LuService luService) {
339  2 this.luService = luService;
340    }
341   
 
342  0 toggle public StatementService getStatementService() {
343  0 return statementService;
344    }
345   
 
346  2 toggle public void setStatementService(StatementService statementService) {
347  2 this.statementService = statementService;
348    }
349   
 
350  0 toggle public LearningObjectiveService getLoService() {
351  0 return loService;
352    }
353   
 
354  2 toggle public void setLoService(LearningObjectiveService loService) {
355  2 this.loService = loService;
356    }
357   
 
358  0 toggle public OrganizationService getOrgService() {
359  0 return orgService;
360    }
361   
 
362  1 toggle public void setOrgService(OrganizationService orgService) {
363  1 this.orgService = orgService;
364    }
365   
 
366  0 toggle public AtpService getAtpService() {
367  0 return atpService;
368    }
369   
 
370  1 toggle public void setAtpService(AtpService atpService) {
371  1 this.atpService = atpService;
372    }
373   
 
374  1 toggle public void setLrcService(LrcService lrcService) {
375  1 this.lrcService = lrcService;
376    }
377   
378    }