1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.util.UUIDHelper;
23 import org.kuali.student.lum.course.dto.CourseJointInfo;
24 import org.kuali.student.lum.lu.dto.CluCluRelationInfo;
25 import org.kuali.student.lum.lu.dto.CluInfo;
26 import org.kuali.student.lum.lu.service.LuService;
27
28
29
30
31
32
33
34 public class CourseJointAssembler implements BOAssembler<CourseJointInfo, CluCluRelationInfo> {
35
36 LuService luService;
37
38
39
40
41 public LuService getLuService() {
42 return luService;
43 }
44
45
46
47
48 public void setLuService(LuService luService) {
49 this.luService = luService;
50 }
51
52 @Override
53 public CourseJointInfo assemble(CluCluRelationInfo cluRel, CourseJointInfo jointInfo, boolean shallowBuild) throws AssemblyException {
54 if(null == cluRel) {
55 return null;
56 }
57
58 CourseJointInfo joint = (jointInfo != null) ? jointInfo : new CourseJointInfo();
59
60 CluInfo clu;
61 try {
62 clu = luService.getClu(cluRel.getRelatedCluId());
63
64 joint.setCourseId(clu.getId());
65 joint.setType(clu.getType());
66 joint.setSubjectArea(clu.getOfficialIdentifier().getDivision());
67 joint.setCourseTitle(clu.getOfficialIdentifier().getLongName());
68 joint.setCourseNumberSuffix(clu.getOfficialIdentifier().getSuffixCode());
69 joint.setRelationId(cluRel.getId());
70
71 } catch (Exception e) {
72 throw new AssemblyException("Error getting related clus", e);
73 }
74
75 return joint;
76 }
77
78 public CourseJointInfo assemble(CluCluRelationInfo cluRel, String cluId, CourseJointInfo jointInfo, boolean shallowBuild) throws AssemblyException {
79 if(null == cluRel) {
80 return null;
81 }
82
83 CourseJointInfo joint = (jointInfo != null) ? jointInfo : new CourseJointInfo();
84
85 CluInfo clu;
86 try {
87 clu = luService.getClu(cluId);
88
89 joint.setCourseId(clu.getId());
90 joint.setType(clu.getType());
91 joint.setSubjectArea(clu.getOfficialIdentifier().getDivision());
92 joint.setCourseTitle(clu.getOfficialIdentifier().getLongName());
93 joint.setCourseNumberSuffix(clu.getOfficialIdentifier().getSuffixCode());
94 joint.setRelationId(cluRel.getId());
95
96 } catch (Exception e) {
97 throw new AssemblyException("Error getting related clus", e);
98 }
99
100 return joint;
101 }
102
103 @Override
104 public BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> disassemble(
105 CourseJointInfo joint, NodeOperation operation) throws AssemblyException {
106
107 if(null == joint){
108
109 throw new AssemblyException("Activity can not be null");
110 }
111
112 BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> result = new BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo>(this);
113 result.setBusinessDTORef(joint);
114 result.setOperation(operation);
115
116 CluCluRelationInfo cluRel = new CluCluRelationInfo();
117 cluRel.setId(UUIDHelper.genStringUUID(joint.getRelationId()));
118 cluRel.setRelatedCluId(joint.getCourseId());
119 cluRel.setType(CourseAssemblerConstants.JOINT_RELATION_TYPE);
120 result.setNodeData(cluRel);
121
122
123 return result;
124 }
125 }