Clover Coverage Report - Kuali Student 1.2-M3-SNAPSHOT (Aggregated)
Coverage timestamp: Mon Jun 6 2011 05:02:46 EDT
../../../../../../../img/srcFileCovDistChart1.png 52% of files have more coverage
43   130   16   8.6
12   79   0.37   5
5     3.2  
1    
 
  CourseJointAssembler       Line # 35 43 0% 16 58 3.3% 0.033333335
 
No Tests
 
1    /*
2    * Copyright 2008 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.course.service.assembler;
17   
18    import org.kuali.student.common.assembly.BOAssembler;
19    import org.kuali.student.common.assembly.BaseDTOAssemblyNode;
20    import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation;
21    import org.kuali.student.common.assembly.data.AssemblyException;
22    import org.kuali.student.common.dto.DtoConstants;
23    import org.kuali.student.common.util.UUIDHelper;
24    import org.kuali.student.lum.course.dto.CourseJointInfo;
25    import org.kuali.student.lum.lu.dto.CluCluRelationInfo;
26    import org.kuali.student.lum.lu.dto.CluInfo;
27    import org.kuali.student.lum.lu.service.LuService;
28   
29    /**
30    * Assembles/Disassembles CourseJointInfo DTO from/to CluCluRelationInfo
31    *
32    * @author Kuali Student Team
33    *
34    */
 
35    public class CourseJointAssembler implements BOAssembler<CourseJointInfo, CluCluRelationInfo> {
36   
37    LuService luService;
38   
39    /**
40    * @return the luService
41    */
 
42  0 toggle public LuService getLuService() {
43  0 return luService;
44    }
45   
46    /**
47    * @param luService the luService to set
48    */
 
49  1 toggle public void setLuService(LuService luService) {
50  1 this.luService = luService;
51    }
52   
 
53  0 toggle @Override
54    public CourseJointInfo assemble(CluCluRelationInfo cluRel, CourseJointInfo jointInfo, boolean shallowBuild) throws AssemblyException {
55  0 if(null == cluRel) {
56  0 return null;
57    }
58   
59  0 CourseJointInfo joint = (jointInfo != null) ? jointInfo : new CourseJointInfo();
60   
61  0 CluInfo clu;
62  0 try {
63  0 clu = luService.getClu(cluRel.getRelatedCluId());
64   
65  0 joint.setCourseId(clu.getId());
66  0 joint.setType(clu.getType());//FIXME is this ever used?
67  0 joint.setSubjectArea(clu.getOfficialIdentifier().getDivision());
68  0 joint.setCourseTitle(clu.getOfficialIdentifier().getLongName());
69  0 joint.setCourseNumberSuffix(clu.getOfficialIdentifier().getSuffixCode());
70  0 joint.setRelationId(cluRel.getId());
71   
72    } catch (Exception e) {
73  0 throw new AssemblyException("Error getting related clus", e);
74    }
75   
76  0 return joint;
77    }
78   
 
79  0 toggle public CourseJointInfo assemble(CluCluRelationInfo cluRel, String cluId, CourseJointInfo jointInfo, boolean shallowBuild) throws AssemblyException {
80  0 if(null == cluRel) {
81  0 return null;
82    }
83   
84  0 CourseJointInfo joint = (jointInfo != null) ? jointInfo : new CourseJointInfo();
85   
86  0 CluInfo clu;
87  0 try {
88  0 clu = luService.getClu(cluId);
89   
90  0 if (clu.getState().equals(DtoConstants.STATE_ACTIVE) || clu.getState().equals(DtoConstants.STATE_SUPERSEDED) ||
91    clu.getState().equals(DtoConstants.STATE_APPROVED) || clu.getState().equals(DtoConstants.STATE_SUSPENDED)) {
92  0 joint.setCourseId(clu.getId());
93  0 joint.setType(clu.getType());//FIXME is this ever used?
94  0 joint.setSubjectArea(clu.getOfficialIdentifier().getDivision());
95  0 joint.setCourseTitle(clu.getOfficialIdentifier().getLongName());
96  0 joint.setCourseNumberSuffix(clu.getOfficialIdentifier().getSuffixCode());
97  0 joint.setRelationId(cluRel.getId());
98    } else
99  0 return null;
100   
101    } catch (Exception e) {
102  0 throw new AssemblyException("Error getting related clus", e);
103    }
104   
105  0 return joint;
106    }
107   
 
108  0 toggle @Override
109    public BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> disassemble(
110    CourseJointInfo joint, NodeOperation operation) throws AssemblyException {
111   
112  0 if(null == joint){
113    //FIXME Unsure now if this is an exception or just return null or empty assemblyNode
114  0 throw new AssemblyException("Activity can not be null");
115    }
116   
117  0 BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> result = new BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo>(this);
118  0 result.setBusinessDTORef(joint);
119  0 result.setOperation(operation);
120   
121  0 CluCluRelationInfo cluRel = new CluCluRelationInfo();
122  0 cluRel.setId(UUIDHelper.genStringUUID(joint.getRelationId()));
123  0 cluRel.setRelatedCluId(joint.getCourseId());
124  0 cluRel.setType(CourseAssemblerConstants.JOINT_RELATION_TYPE);
125  0 result.setNodeData(cluRel);
126    // The caller is required to set the CluId on the cluCluRelation
127   
128  0 return result;
129    }
130    }