| 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.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 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | 1 | public class CourseJointAssembler implements BOAssembler<CourseJointInfo, CluCluRelationInfo> { |
| 36 | |
|
| 37 | |
LuService luService; |
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
public LuService getLuService() { |
| 43 | 0 | return luService; |
| 44 | |
} |
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
public void setLuService(LuService luService) { |
| 50 | 1 | this.luService = luService; |
| 51 | 1 | } |
| 52 | |
|
| 53 | |
@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 | |
CluInfo clu; |
| 62 | |
try { |
| 63 | 0 | clu = luService.getClu(cluRel.getRelatedCluId()); |
| 64 | |
|
| 65 | 0 | joint.setCourseId(clu.getId()); |
| 66 | 0 | joint.setType(clu.getType()); |
| 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 | 0 | } catch (Exception e) { |
| 73 | 0 | throw new AssemblyException("Error getting related clus", e); |
| 74 | 0 | } |
| 75 | |
|
| 76 | 0 | return joint; |
| 77 | |
} |
| 78 | |
|
| 79 | |
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 | |
CluInfo clu; |
| 87 | |
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()); |
| 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 | 0 | } catch (Exception e) { |
| 102 | 0 | throw new AssemblyException("Error getting related clus", e); |
| 103 | 0 | } |
| 104 | |
|
| 105 | 0 | return joint; |
| 106 | |
} |
| 107 | |
|
| 108 | |
@Override |
| 109 | |
public BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> disassemble( |
| 110 | |
CourseJointInfo joint, NodeOperation operation) throws AssemblyException { |
| 111 | |
|
| 112 | 0 | if(null == joint){ |
| 113 | |
|
| 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 | |
|
| 127 | |
|
| 128 | 0 | return result; |
| 129 | |
} |
| 130 | |
} |