| 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 java.util.ArrayList; |
| 19 | |
import java.util.Collections; |
| 20 | |
import java.util.Date; |
| 21 | |
import java.util.HashMap; |
| 22 | |
import java.util.HashSet; |
| 23 | |
import java.util.Iterator; |
| 24 | |
import java.util.List; |
| 25 | |
import java.util.Map; |
| 26 | |
import java.util.Map.Entry; |
| 27 | |
import java.util.Set; |
| 28 | |
|
| 29 | |
import org.apache.log4j.Logger; |
| 30 | |
import org.kuali.student.common.assembly.BOAssembler; |
| 31 | |
import org.kuali.student.common.assembly.BaseDTOAssemblyNode; |
| 32 | |
import org.kuali.student.common.assembly.BaseDTOAssemblyNode.NodeOperation; |
| 33 | |
import org.kuali.student.common.assembly.data.AssemblyException; |
| 34 | |
import org.kuali.student.common.dto.DtoConstants; |
| 35 | |
import org.kuali.student.common.dto.RichTextInfo; |
| 36 | |
import org.kuali.student.common.exceptions.DoesNotExistException; |
| 37 | |
import org.kuali.student.common.exceptions.InvalidParameterException; |
| 38 | |
import org.kuali.student.common.exceptions.MissingParameterException; |
| 39 | |
import org.kuali.student.common.exceptions.OperationFailedException; |
| 40 | |
import org.kuali.student.common.util.UUIDHelper; |
| 41 | |
import org.kuali.student.core.atp.dto.AtpInfo; |
| 42 | |
import org.kuali.student.core.atp.service.AtpService; |
| 43 | |
import org.kuali.student.lum.course.dto.CourseCrossListingInfo; |
| 44 | |
import org.kuali.student.lum.course.dto.CourseExpenditureInfo; |
| 45 | |
import org.kuali.student.lum.course.dto.CourseFeeInfo; |
| 46 | |
import org.kuali.student.lum.course.dto.CourseInfo; |
| 47 | |
import org.kuali.student.lum.course.dto.CourseJointInfo; |
| 48 | |
import org.kuali.student.lum.course.dto.CourseRevenueInfo; |
| 49 | |
import org.kuali.student.lum.course.dto.CourseVariationInfo; |
| 50 | |
import org.kuali.student.lum.course.dto.FormatInfo; |
| 51 | |
import org.kuali.student.lum.course.dto.LoDisplayInfo; |
| 52 | |
import org.kuali.student.lum.lo.dto.LoInfo; |
| 53 | |
import org.kuali.student.lum.lo.service.LearningObjectiveService; |
| 54 | |
import org.kuali.student.lum.lrc.dto.ResultComponentInfo; |
| 55 | |
import org.kuali.student.lum.lrc.service.LrcService; |
| 56 | |
import org.kuali.student.lum.lu.dto.AdminOrgInfo; |
| 57 | |
import org.kuali.student.lum.lu.dto.CluAccountingInfo; |
| 58 | |
import org.kuali.student.lum.lu.dto.CluCluRelationInfo; |
| 59 | |
import org.kuali.student.lum.lu.dto.CluFeeInfo; |
| 60 | |
import org.kuali.student.lum.lu.dto.CluFeeRecordInfo; |
| 61 | |
import org.kuali.student.lum.lu.dto.CluIdentifierInfo; |
| 62 | |
import org.kuali.student.lum.lu.dto.CluInfo; |
| 63 | |
import org.kuali.student.lum.lu.dto.CluLoRelationInfo; |
| 64 | |
import org.kuali.student.lum.lu.dto.CluResultInfo; |
| 65 | |
import org.kuali.student.lum.lu.dto.LuCodeInfo; |
| 66 | |
import org.kuali.student.lum.lu.dto.ResultOptionInfo; |
| 67 | |
import org.kuali.student.lum.lu.service.LuService; |
| 68 | |
import org.kuali.student.lum.service.assembler.CluAssemblerUtils; |
| 69 | |
import org.springframework.util.StringUtils; |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | 24 | public class CourseAssembler implements BOAssembler<CourseInfo, CluInfo> { |
| 78 | |
|
| 79 | 1 | final static Logger LOG = Logger.getLogger(CourseAssembler.class); |
| 80 | |
private LuService luService; |
| 81 | |
private FormatAssembler formatAssembler; |
| 82 | |
private CourseJointAssembler courseJointAssembler; |
| 83 | |
private LoAssembler loAssembler; |
| 84 | |
private LearningObjectiveService loService; |
| 85 | |
private CluAssemblerUtils cluAssemblerUtils; |
| 86 | |
private LrcService lrcService; |
| 87 | |
private AtpService atpService; |
| 88 | 1 | private float defaultCreditIncrement = 1.0f; |
| 89 | |
|
| 90 | |
@Override |
| 91 | |
public CourseInfo assemble(CluInfo clu, CourseInfo courseInfo, |
| 92 | |
boolean shallowBuild) throws AssemblyException { |
| 93 | |
|
| 94 | 45 | CourseInfo course = (null != courseInfo) ? courseInfo |
| 95 | |
: new CourseInfo(); |
| 96 | |
|
| 97 | |
|
| 98 | |
|
| 99 | 45 | course.setAttributes(clu.getAttributes()); |
| 100 | 45 | course.setCampusLocations(clu.getCampusLocations()); |
| 101 | 45 | course.setCode(clu.getOfficialIdentifier().getCode()); |
| 102 | 45 | course.setCourseNumberSuffix(clu.getOfficialIdentifier() |
| 103 | |
.getSuffixCode()); |
| 104 | 45 | course.setLevel(clu.getOfficialIdentifier().getLevel()); |
| 105 | 45 | course.setOutOfClassHours(clu.getIntensity()); |
| 106 | 45 | course.setInstructors(clu.getInstructors()); |
| 107 | 45 | course.setStartTerm(clu.getExpectedFirstAtp()); |
| 108 | 45 | course.setEndTerm(clu.getLastAtp()); |
| 109 | 45 | course.setCourseTitle(clu.getOfficialIdentifier().getLongName()); |
| 110 | |
|
| 111 | |
|
| 112 | 45 | List<CourseCrossListingInfo> crossListings = assembleCrossListings(clu.getAlternateIdentifiers()); |
| 113 | 45 | course.setCrossListings(crossListings); |
| 114 | |
|
| 115 | |
|
| 116 | 45 | List<CourseVariationInfo> variations = assembleVariations(clu.getAlternateIdentifiers()); |
| 117 | 45 | course.setVariations(variations); |
| 118 | |
|
| 119 | |
|
| 120 | 45 | if(course.getUnitsDeployment()==null){ |
| 121 | 0 | course.setUnitsDeployment(new ArrayList<String>()); |
| 122 | |
} |
| 123 | 45 | if(course.getUnitsContentOwner()==null){ |
| 124 | 0 | course.setUnitsContentOwner(new ArrayList<String>()); |
| 125 | |
} |
| 126 | 45 | List<String> courseAdminOrgs = new ArrayList<String>(); |
| 127 | 45 | List<String> courseSubjectOrgs = new ArrayList<String>(); |
| 128 | 45 | for(AdminOrgInfo adminOrg: clu.getAdminOrgs()){ |
| 129 | 178 | if(adminOrg.getType().equals(CourseAssemblerConstants.ADMIN_ORG)){ |
| 130 | 90 | courseAdminOrgs.add(adminOrg.getOrgId()); |
| 131 | |
} |
| 132 | 178 | if(adminOrg.getType().equals(CourseAssemblerConstants.SUBJECT_ORG)){ |
| 133 | 88 | courseSubjectOrgs.add(adminOrg.getOrgId()); |
| 134 | |
} |
| 135 | |
} |
| 136 | 45 | course.setUnitsDeployment(courseAdminOrgs); |
| 137 | 45 | course.setUnitsContentOwner(courseSubjectOrgs); |
| 138 | 45 | course.setDescr(clu.getDescr()); |
| 139 | 45 | course.setDuration(clu.getStdDuration()); |
| 140 | 45 | course.setEffectiveDate(clu.getEffectiveDate()); |
| 141 | 45 | course.setExpirationDate(clu.getExpirationDate()); |
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | 45 | List<CourseFeeInfo> fees = new ArrayList<CourseFeeInfo>(); |
| 146 | 45 | List<CourseRevenueInfo> revenues = new ArrayList<CourseRevenueInfo>(); |
| 147 | 45 | if(clu.getFeeInfo() != null){ |
| 148 | 45 | course.setFeeJustification(clu.getFeeInfo().getDescr()); |
| 149 | |
|
| 150 | |
|
| 151 | 45 | for(CluFeeRecordInfo cluFeeRecord: clu.getFeeInfo().getCluFeeRecords()){ |
| 152 | 178 | String feeType = cluFeeRecord.getFeeType(); |
| 153 | 178 | if(CourseAssemblerConstants.COURSE_FINANCIALS_REVENUE_TYPE.equals(feeType)){ |
| 154 | 90 | CourseRevenueInfo courseRevenue = new CourseRevenueInfo(); |
| 155 | 90 | courseRevenue.setFeeType(feeType); |
| 156 | 90 | courseRevenue.setAffiliatedOrgs(cluFeeRecord.getAffiliatedOrgs()); |
| 157 | 90 | courseRevenue.setAttributes(cluFeeRecord.getAttributes()); |
| 158 | 90 | courseRevenue.setId(cluFeeRecord.getId()); |
| 159 | 90 | courseRevenue.setMetaInfo(cluFeeRecord.getMetaInfo()); |
| 160 | 90 | revenues.add(courseRevenue); |
| 161 | 90 | }else{ |
| 162 | 88 | CourseFeeInfo courseFee = new CourseFeeInfo(); |
| 163 | 88 | courseFee.setFeeType(feeType); |
| 164 | 88 | courseFee.setRateType(cluFeeRecord.getRateType()); |
| 165 | 88 | courseFee.setDescr(cluFeeRecord.getDescr()); |
| 166 | 88 | courseFee.setMetaInfo(cluFeeRecord.getMetaInfo()); |
| 167 | 88 | courseFee.setId(cluFeeRecord.getId()); |
| 168 | 88 | courseFee.setFeeAmounts(cluFeeRecord.getFeeAmounts()); |
| 169 | 88 | courseFee.setAttributes(cluFeeRecord.getAttributes()); |
| 170 | 88 | fees.add(courseFee); |
| 171 | |
} |
| 172 | 178 | } |
| 173 | |
} |
| 174 | 45 | course.setFees(fees); |
| 175 | 45 | course.setRevenues(revenues); |
| 176 | |
|
| 177 | 45 | if(course.getExpenditure() == null || clu.getAccountingInfo() == null){ |
| 178 | 14 | course.setExpenditure(new CourseExpenditureInfo()); |
| 179 | |
} |
| 180 | 45 | if(clu.getAccountingInfo() != null){ |
| 181 | 45 | course.getExpenditure().setAffiliatedOrgs(clu.getAccountingInfo().getAffiliatedOrgs()); |
| 182 | |
} |
| 183 | |
|
| 184 | 45 | course.setId(clu.getId()); |
| 185 | 45 | course.setType(clu.getType()); |
| 186 | 45 | course.setTermsOffered(clu.getOfferedAtpTypes()); |
| 187 | 45 | course.setPrimaryInstructor(clu.getPrimaryInstructor()); |
| 188 | 45 | course.setInstructors(clu.getInstructors()); |
| 189 | 45 | course.setState(clu.getState()); |
| 190 | 45 | course.setSubjectArea(clu.getOfficialIdentifier().getDivision()); |
| 191 | 45 | course.setTranscriptTitle(clu.getOfficialIdentifier().getShortName()); |
| 192 | 45 | course.setMetaInfo(clu.getMetaInfo()); |
| 193 | 45 | course.setVersionInfo(clu.getVersionInfo()); |
| 194 | |
|
| 195 | |
|
| 196 | |
|
| 197 | 45 | course.setSpecialTopicsCourse(false); |
| 198 | 45 | for(LuCodeInfo luCode : clu.getLuCodes()){ |
| 199 | 3 | if(CourseAssemblerConstants.COURSE_CODE_SPECIAL_TOPICS.equals(luCode.getType())){ |
| 200 | 3 | course.setSpecialTopicsCourse(Boolean.parseBoolean(luCode.getValue())); |
| 201 | 3 | break; |
| 202 | |
} |
| 203 | |
} |
| 204 | |
|
| 205 | 45 | course.setPilotCourse(false); |
| 206 | 45 | for(LuCodeInfo luCode : clu.getLuCodes()){ |
| 207 | 6 | if(CourseAssemblerConstants.COURSE_CODE_PILOT_COURSE.equals(luCode.getType())){ |
| 208 | 3 | course.setPilotCourse(Boolean.parseBoolean(luCode.getValue())); |
| 209 | 3 | break; |
| 210 | |
} |
| 211 | |
} |
| 212 | |
|
| 213 | |
|
| 214 | 45 | if (!shallowBuild) { |
| 215 | |
try { |
| 216 | |
|
| 217 | |
|
| 218 | 14 | List<CluCluRelationInfo> cluClus = luService.getCluCluRelationsByClu(clu.getId()); |
| 219 | |
|
| 220 | 14 | for (CluCluRelationInfo cluRel : cluClus) { |
| 221 | 29 | if (cluRel.getType().equals(CourseAssemblerConstants.JOINT_RELATION_TYPE)) { |
| 222 | 0 | CourseJointInfo jointInfo = null; |
| 223 | 0 | if(cluRel.getCluId().equals(clu.getId())) |
| 224 | 0 | jointInfo = courseJointAssembler.assemble(cluRel, cluRel.getRelatedCluId(), null, false); |
| 225 | |
else |
| 226 | 0 | jointInfo = courseJointAssembler.assemble(cluRel, cluRel.getCluId(), null, false); |
| 227 | 0 | course.getJoints().add(jointInfo); |
| 228 | 29 | } |
| 229 | |
} |
| 230 | 0 | } catch (DoesNotExistException e) { |
| 231 | 0 | } catch (Exception e) { |
| 232 | 0 | throw new AssemblyException("Error getting course joints", e); |
| 233 | 14 | } |
| 234 | |
|
| 235 | |
try { |
| 236 | |
|
| 237 | |
|
| 238 | 14 | List<CluInfo> formats = luService.getRelatedClusByCluId(course |
| 239 | |
.getId(), |
| 240 | |
CourseAssemblerConstants.COURSE_FORMAT_RELATION_TYPE); |
| 241 | |
|
| 242 | 14 | for (CluInfo format : formats) { |
| 243 | 29 | FormatInfo formatInfo = formatAssembler.assemble(format, |
| 244 | |
null, false); |
| 245 | 29 | course.getFormats().add(formatInfo); |
| 246 | 29 | } |
| 247 | |
|
| 248 | 0 | } catch (DoesNotExistException e) { |
| 249 | 0 | } catch (Exception e) { |
| 250 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 251 | 14 | } |
| 252 | |
|
| 253 | |
try{ |
| 254 | |
|
| 255 | 14 | List<CluResultInfo> cluResults = luService.getCluResultByClu(course.getId()); |
| 256 | |
|
| 257 | 14 | List<ResultComponentInfo> creditOptions = assembleCreditOptions(cluResults); |
| 258 | 14 | course.setCreditOptions(creditOptions); |
| 259 | |
|
| 260 | 14 | List<String> gradingOptions = assembleGradingOptions(cluResults); |
| 261 | |
|
| 262 | 14 | course.setGradingOptions(gradingOptions); |
| 263 | 0 | } catch (DoesNotExistException e){ |
| 264 | 0 | } catch (Exception e) { |
| 265 | 0 | throw new AssemblyException("Error getting course results", e); |
| 266 | 14 | } |
| 267 | |
|
| 268 | |
|
| 269 | 14 | course.getCourseSpecificLOs().addAll(cluAssemblerUtils.assembleLos(course.getId(), shallowBuild)); |
| 270 | |
|
| 271 | |
} |
| 272 | |
|
| 273 | |
|
| 274 | 45 | course.getGradingOptions().remove(CourseAssemblerConstants.COURSE_RESULT_COMP_GRADE_AUDIT); |
| 275 | |
|
| 276 | 45 | return course; |
| 277 | |
} |
| 278 | |
|
| 279 | |
@Override |
| 280 | |
public BaseDTOAssemblyNode<CourseInfo, CluInfo> disassemble( |
| 281 | |
CourseInfo course, NodeOperation operation) |
| 282 | |
throws AssemblyException { |
| 283 | |
|
| 284 | 25 | if (course == null) { |
| 285 | |
|
| 286 | |
|
| 287 | 0 | LOG.error("Course to disassemble is null!"); |
| 288 | 0 | throw new AssemblyException("Course can not be null"); |
| 289 | |
} |
| 290 | |
|
| 291 | 25 | BaseDTOAssemblyNode<CourseInfo, CluInfo> result = new BaseDTOAssemblyNode<CourseInfo, CluInfo>( |
| 292 | |
this); |
| 293 | |
|
| 294 | |
CluInfo clu; |
| 295 | |
try { |
| 296 | 25 | clu = (NodeOperation.UPDATE == operation) ? luService.getClu(course.getId()) : new CluInfo(); |
| 297 | 0 | } catch (Exception e) { |
| 298 | 0 | throw new AssemblyException("Error getting existing learning unit during course update", e); |
| 299 | 25 | } |
| 300 | |
|
| 301 | |
|
| 302 | |
|
| 303 | 25 | clu.setId(UUIDHelper.genStringUUID(course.getId())); |
| 304 | 25 | if (null == course.getId()) { |
| 305 | 14 | course.setId(clu.getId()); |
| 306 | |
} |
| 307 | 25 | clu.setType(CourseAssemblerConstants.COURSE_TYPE); |
| 308 | 25 | clu.setState(course.getState()); |
| 309 | |
|
| 310 | 25 | CluIdentifierInfo identifier = new CluIdentifierInfo(); |
| 311 | 25 | identifier.setType(CourseAssemblerConstants.COURSE_OFFICIAL_IDENT_TYPE); |
| 312 | 25 | identifier.setState(course.getState()); |
| 313 | 25 | identifier.setLongName(course.getCourseTitle()); |
| 314 | 25 | identifier.setShortName(course.getTranscriptTitle()); |
| 315 | 25 | identifier.setSuffixCode(course.getCourseNumberSuffix()); |
| 316 | 25 | identifier.setDivision(course.getSubjectArea()); |
| 317 | 25 | identifier.setCode(course.getCode()); |
| 318 | |
|
| 319 | |
|
| 320 | 25 | if(StringUtils.hasText(course.getLevel())) { |
| 321 | 25 | identifier.setLevel(course.getLevel()); |
| 322 | 0 | } else if(course.getCourseNumberSuffix()!=null&&course.getCourseNumberSuffix().length()>=3){ |
| 323 | 0 | identifier.setLevel(course.getCourseNumberSuffix().substring(0, 1)+"00"); |
| 324 | |
} |
| 325 | |
|
| 326 | 25 | clu.setOfficialIdentifier(identifier); |
| 327 | |
|
| 328 | 25 | clu.setAdminOrgs(new ArrayList<AdminOrgInfo>()); |
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
|
| 334 | 25 | for(Iterator<CluIdentifierInfo> iter = clu.getAlternateIdentifiers().iterator();iter.hasNext();){ |
| 335 | 20 | CluIdentifierInfo cluIdentifier = iter.next(); |
| 336 | 20 | if(CourseAssemblerConstants.COURSE_VARIATION_IDENT_TYPE.equals(cluIdentifier.getType()) || |
| 337 | |
CourseAssemblerConstants.COURSE_CROSSLISTING_IDENT_TYPE.equals(cluIdentifier.getType()) ){ |
| 338 | 20 | iter.remove(); |
| 339 | |
} |
| 340 | 20 | } |
| 341 | |
|
| 342 | 25 | for(CourseVariationInfo variation:course.getVariations()){ |
| 343 | 50 | CluIdentifierInfo cluIdentifier = new CluIdentifierInfo(); |
| 344 | 50 | cluIdentifier.setId(variation.getId()); |
| 345 | 50 | cluIdentifier.setType(CourseAssemblerConstants.COURSE_VARIATION_IDENT_TYPE); |
| 346 | 50 | cluIdentifier.setCode(identifier.getCode()); |
| 347 | 50 | cluIdentifier.setSuffixCode(course.getCourseNumberSuffix()); |
| 348 | 50 | cluIdentifier.setDivision(course.getSubjectArea()); |
| 349 | 50 | cluIdentifier.setVariation(variation.getVariationCode()); |
| 350 | 50 | cluIdentifier.setLongName(variation.getVariationTitle()); |
| 351 | 50 | cluIdentifier.setState(course.getState()); |
| 352 | 50 | clu.getAlternateIdentifiers().add(cluIdentifier); |
| 353 | 50 | } |
| 354 | |
|
| 355 | 25 | for(CourseCrossListingInfo crossListing:course.getCrossListings()){ |
| 356 | 2 | CluIdentifierInfo cluIdentifier = new CluIdentifierInfo(); |
| 357 | 2 | cluIdentifier.setId(crossListing.getId()); |
| 358 | 2 | cluIdentifier.setType(CourseAssemblerConstants.COURSE_CROSSLISTING_IDENT_TYPE); |
| 359 | 2 | cluIdentifier.setSuffixCode(crossListing.getCourseNumberSuffix()); |
| 360 | 2 | cluIdentifier.setDivision(crossListing.getSubjectArea()); |
| 361 | 2 | cluIdentifier.setState(course.getState()); |
| 362 | 2 | cluIdentifier.setOrgId(crossListing.getDepartment()); |
| 363 | 2 | cluIdentifier.setAttributes(crossListing.getAttributes()); |
| 364 | 2 | cluIdentifier.setCode(crossListing.getCode()); |
| 365 | 2 | clu.getAlternateIdentifiers().add(cluIdentifier); |
| 366 | 2 | } |
| 367 | |
|
| 368 | 25 | List<AdminOrgInfo> adminOrgInfos = new ArrayList<AdminOrgInfo>(); |
| 369 | 25 | for(String org:course.getUnitsDeployment()){ |
| 370 | 50 | AdminOrgInfo adminOrg = new AdminOrgInfo(); |
| 371 | 50 | adminOrg.setType(CourseAssemblerConstants.ADMIN_ORG); |
| 372 | 50 | adminOrg.setOrgId(org); |
| 373 | 50 | adminOrgInfos.add(adminOrg); |
| 374 | 50 | } |
| 375 | 25 | clu.getAdminOrgs().addAll(adminOrgInfos); |
| 376 | |
|
| 377 | 25 | List<AdminOrgInfo> subjectOrgs = new ArrayList<AdminOrgInfo>(); |
| 378 | 25 | for (String subOrg : course.getUnitsContentOwner()) { |
| 379 | 48 | AdminOrgInfo subjectOrg = new AdminOrgInfo(); |
| 380 | 48 | subjectOrg.setType(CourseAssemblerConstants.SUBJECT_ORG); |
| 381 | 48 | subjectOrg.setOrgId(subOrg); |
| 382 | 48 | subjectOrgs.add(subjectOrg); |
| 383 | 48 | } |
| 384 | 25 | clu.getAdminOrgs().addAll(subjectOrgs); |
| 385 | |
|
| 386 | |
|
| 387 | 25 | clu.setAttributes(course.getAttributes()); |
| 388 | 25 | clu.setCampusLocations(course.getCampusLocations()); |
| 389 | 25 | clu.setDescr(course.getDescr()); |
| 390 | 25 | clu.setStdDuration(course.getDuration()); |
| 391 | |
|
| 392 | |
|
| 393 | 25 | if(course.getStartTerm() != null){ |
| 394 | |
try { |
| 395 | 17 | AtpInfo startAtp = atpService.getAtp(course.getStartTerm()); |
| 396 | 17 | course.setEffectiveDate(startAtp.getStartDate()); |
| 397 | 0 | } catch (Exception e) { |
| 398 | 0 | throw new AssemblyException("Error getting start term Atp.",e); |
| 399 | 17 | } |
| 400 | |
} |
| 401 | 25 | if(course.getEndTerm() != null){ |
| 402 | |
try { |
| 403 | 17 | AtpInfo endAtp = atpService.getAtp(course.getEndTerm()); |
| 404 | 17 | course.setExpirationDate(endAtp.getEndDate()); |
| 405 | 0 | } catch (Exception e) { |
| 406 | 0 | throw new AssemblyException("Error getting end term Atp.",e); |
| 407 | 17 | } |
| 408 | |
} |
| 409 | |
|
| 410 | 25 | clu.setEffectiveDate(course.getEffectiveDate()); |
| 411 | 25 | clu.setExpirationDate(course.getExpirationDate()); |
| 412 | |
|
| 413 | 25 | clu.setOfferedAtpTypes(course.getTermsOffered()); |
| 414 | 25 | clu.setPrimaryInstructor(course.getPrimaryInstructor()); |
| 415 | |
|
| 416 | 25 | clu.setIntensity(course.getOutOfClassHours()); |
| 417 | 25 | clu.setInstructors(course.getInstructors()); |
| 418 | |
|
| 419 | 25 | clu.setExpectedFirstAtp(course.getStartTerm()); |
| 420 | 25 | clu.setLastAtp(course.getEndTerm()); |
| 421 | |
|
| 422 | 25 | clu.setMetaInfo(course.getMetaInfo()); |
| 423 | 25 | clu.setVersionInfo(course.getVersionInfo()); |
| 424 | |
|
| 425 | |
|
| 426 | 25 | result.setNodeData(clu); |
| 427 | 25 | result.setOperation(operation); |
| 428 | 25 | result.setBusinessDTORef(course); |
| 429 | |
|
| 430 | |
|
| 431 | |
List<BaseDTOAssemblyNode<?, ?>> formatResults; |
| 432 | |
try { |
| 433 | 25 | formatResults = disassembleFormats(clu |
| 434 | |
.getId(), course, operation); |
| 435 | 25 | result.getChildNodes().addAll(formatResults); |
| 436 | |
|
| 437 | 0 | } catch (DoesNotExistException e) { |
| 438 | 0 | } catch (Exception e) { |
| 439 | 0 | throw new AssemblyException("Error while disassembling format", e); |
| 440 | 25 | } |
| 441 | |
|
| 442 | |
|
| 443 | |
|
| 444 | 25 | List<BaseDTOAssemblyNode<?, ?>> courseJointResults = disassembleJoints( |
| 445 | |
clu.getId(), course, operation); |
| 446 | 25 | result.getChildNodes().addAll(courseJointResults); |
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | 25 | if(course.getAttributes().containsKey(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_AUDIT)&&"true".equals(course.getAttributes().get(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_AUDIT))){ |
| 451 | 0 | if(!course.getGradingOptions().contains(CourseAssemblerConstants.COURSE_RESULT_COMP_GRADE_AUDIT)){ |
| 452 | 0 | course.getGradingOptions().add(CourseAssemblerConstants.COURSE_RESULT_COMP_GRADE_AUDIT); |
| 453 | |
} |
| 454 | |
} |
| 455 | |
|
| 456 | |
List<CluResultInfo> cluResultList; |
| 457 | |
try { |
| 458 | 25 | cluResultList = luService.getCluResultByClu(clu.getId()); |
| 459 | 0 | } catch (DoesNotExistException e) { |
| 460 | 0 | cluResultList = Collections.emptyList(); |
| 461 | 0 | } catch (Exception e) { |
| 462 | 0 | throw new AssemblyException("Error getting cluResults", e); |
| 463 | 25 | } |
| 464 | |
|
| 465 | 25 | List<BaseDTOAssemblyNode<?, ?>> creditOutcomes = disassembleCreditOutcomes(course, clu, cluResultList, operation); |
| 466 | 25 | result.getChildNodes().addAll(creditOutcomes); |
| 467 | |
|
| 468 | 25 | BaseDTOAssemblyNode<?, ?> gradingOptions = disassembleGradingOptions( |
| 469 | |
clu.getId(), course.getState(), course.getGradingOptions(), cluResultList, operation); |
| 470 | 25 | result.getChildNodes().add(gradingOptions); |
| 471 | |
|
| 472 | |
|
| 473 | |
try { |
| 474 | |
List<BaseDTOAssemblyNode<?, ?>> loResults; |
| 475 | 25 | loResults = disassembleLos(clu.getId(), course, operation); |
| 476 | 25 | result.getChildNodes().addAll(loResults); |
| 477 | 0 | } catch (Exception e) { |
| 478 | 0 | throw new AssemblyException("Error while disassembling los", e); |
| 479 | 25 | } |
| 480 | |
|
| 481 | |
|
| 482 | 25 | boolean alreadyHadSpecialTopicsCode = false; |
| 483 | 25 | for(Iterator<LuCodeInfo> luCodeIterator = clu.getLuCodes().iterator();luCodeIterator.hasNext();){ |
| 484 | 1 | LuCodeInfo luCode = luCodeIterator.next(); |
| 485 | 1 | if(CourseAssemblerConstants.COURSE_CODE_SPECIAL_TOPICS.equals(luCode.getType())){ |
| 486 | 1 | alreadyHadSpecialTopicsCode = true; |
| 487 | 1 | if(!course.isSpecialTopicsCourse()){ |
| 488 | 1 | luCodeIterator.remove(); |
| 489 | |
} |
| 490 | |
break; |
| 491 | |
} |
| 492 | 0 | } |
| 493 | 25 | if(!alreadyHadSpecialTopicsCode && course.isSpecialTopicsCourse()){ |
| 494 | 2 | LuCodeInfo luCode = new LuCodeInfo(); |
| 495 | 2 | luCode.setType(CourseAssemblerConstants.COURSE_CODE_SPECIAL_TOPICS); |
| 496 | 2 | luCode.setValue("true"); |
| 497 | 2 | clu.getLuCodes().add(luCode); |
| 498 | |
} |
| 499 | |
|
| 500 | |
|
| 501 | 25 | boolean alreadyHadPilotCourseCode = false; |
| 502 | 25 | for(Iterator<LuCodeInfo> luCodeIterator = clu.getLuCodes().iterator();luCodeIterator.hasNext();){ |
| 503 | 3 | LuCodeInfo luCode = luCodeIterator.next(); |
| 504 | 3 | if(CourseAssemblerConstants.COURSE_CODE_PILOT_COURSE.equals(luCode.getType())){ |
| 505 | 1 | alreadyHadPilotCourseCode = true; |
| 506 | 1 | if(!course.isPilotCourse()){ |
| 507 | 1 | luCodeIterator.remove(); |
| 508 | |
} |
| 509 | |
break; |
| 510 | |
} |
| 511 | 2 | } |
| 512 | 25 | if(!alreadyHadPilotCourseCode && course.isPilotCourse()){ |
| 513 | 2 | LuCodeInfo luCode = new LuCodeInfo(); |
| 514 | 2 | luCode.setType(CourseAssemblerConstants.COURSE_CODE_PILOT_COURSE); |
| 515 | 2 | luCode.setValue("true"); |
| 516 | 2 | clu.getLuCodes().add(luCode); |
| 517 | |
} |
| 518 | |
|
| 519 | |
|
| 520 | 25 | if(clu.getFeeInfo() == null){ |
| 521 | 15 | clu.setFeeInfo(new CluFeeInfo()); |
| 522 | |
} |
| 523 | 25 | clu.getFeeInfo().setDescr(course.getFeeJustification()); |
| 524 | 25 | clu.getFeeInfo().getCluFeeRecords().clear(); |
| 525 | 25 | for(CourseRevenueInfo courseRevenue:course.getRevenues()){ |
| 526 | 50 | CluFeeRecordInfo cluFeeRecord = new CluFeeRecordInfo(); |
| 527 | 50 | cluFeeRecord.setFeeType(CourseAssemblerConstants.COURSE_FINANCIALS_REVENUE_TYPE); |
| 528 | 50 | cluFeeRecord.setRateType(CourseAssemblerConstants.COURSE_FINANCIALS_REVENUE_TYPE); |
| 529 | 50 | cluFeeRecord.setAttributes(courseRevenue.getAttributes()); |
| 530 | 50 | cluFeeRecord.setAffiliatedOrgs(courseRevenue.getAffiliatedOrgs()); |
| 531 | 50 | cluFeeRecord.setId(courseRevenue.getId()); |
| 532 | 50 | cluFeeRecord.setMetaInfo(courseRevenue.getMetaInfo()); |
| 533 | 50 | clu.getFeeInfo().getCluFeeRecords().add(cluFeeRecord); |
| 534 | 50 | } |
| 535 | 25 | for(CourseFeeInfo courseFee : course.getFees()){ |
| 536 | 48 | CluFeeRecordInfo cluFeeRecord = new CluFeeRecordInfo(); |
| 537 | 48 | cluFeeRecord.setFeeType(courseFee.getFeeType()); |
| 538 | 48 | cluFeeRecord.setRateType(courseFee.getRateType()); |
| 539 | 48 | cluFeeRecord.setDescr(courseFee.getDescr()); |
| 540 | 48 | cluFeeRecord.setMetaInfo(courseFee.getMetaInfo()); |
| 541 | 48 | cluFeeRecord.setId(courseFee.getId()); |
| 542 | 48 | cluFeeRecord.setFeeAmounts(courseFee.getFeeAmounts()); |
| 543 | 48 | cluFeeRecord.setAttributes(courseFee.getAttributes()); |
| 544 | 48 | clu.getFeeInfo().getCluFeeRecords().add(cluFeeRecord); |
| 545 | 48 | } |
| 546 | 25 | if(clu.getAccountingInfo() == null || course.getExpenditure()== null){ |
| 547 | 15 | clu.setAccountingInfo( new CluAccountingInfo()); |
| 548 | |
} |
| 549 | 25 | if(course.getExpenditure() != null){ |
| 550 | 25 | clu.getAccountingInfo().setAffiliatedOrgs(course.getExpenditure().getAffiliatedOrgs()); |
| 551 | 25 | clu.getAccountingInfo().setAttributes(course.getExpenditure().getAttributes()); |
| 552 | |
} |
| 553 | |
|
| 554 | 25 | return result; |
| 555 | |
} |
| 556 | |
|
| 557 | |
private List<BaseDTOAssemblyNode<?, ?>> disassembleCreditOutcomes(CourseInfo course, CluInfo clu, List<CluResultInfo> currentCluResults, NodeOperation operation) throws AssemblyException, NumberFormatException { |
| 558 | |
|
| 559 | 25 | List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
| 560 | |
|
| 561 | 25 | String courseResultType = CourseAssemblerConstants.COURSE_RESULT_TYPE_CREDITS; |
| 562 | |
|
| 563 | |
|
| 564 | 25 | if(NodeOperation.DELETE!=operation){ |
| 565 | |
|
| 566 | 24 | Set<String> rsltComps = new HashSet<String>(); |
| 567 | |
|
| 568 | |
try{ |
| 569 | |
try { |
| 570 | 24 | rsltComps.addAll(lrcService.getResultComponentIdsByResultComponentType(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_FIXED)); |
| 571 | 24 | } catch (DoesNotExistException e) {} |
| 572 | |
try { |
| 573 | 24 | rsltComps.addAll(lrcService.getResultComponentIdsByResultComponentType(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_MULTIPLE)); |
| 574 | 24 | } catch (DoesNotExistException e) {} |
| 575 | |
try { |
| 576 | 24 | rsltComps.addAll(lrcService.getResultComponentIdsByResultComponentType(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_VARIABLE)); |
| 577 | 24 | } catch (DoesNotExistException e) {} |
| 578 | |
|
| 579 | |
|
| 580 | 24 | for(ResultComponentInfo creditOption:course.getCreditOptions()){ |
| 581 | 49 | String id = null; |
| 582 | 49 | String type = null; |
| 583 | 49 | List<String> resultValues = null; |
| 584 | 49 | Map<String,String> attributes = null; |
| 585 | |
|
| 586 | 49 | if(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_FIXED.equals(creditOption.getType())){ |
| 587 | 44 | float fixedCreditValue = Float.parseFloat(creditOption.getAttributes().get(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_FIXED_CREDIT_VALUE)); |
| 588 | 44 | id = CourseAssemblerConstants.COURSE_RESULT_COMP_CREDIT_PREFIX + fixedCreditValue; |
| 589 | 44 | type = CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_FIXED; |
| 590 | 44 | resultValues = new ArrayList<String>(); |
| 591 | 44 | resultValues.add(String.valueOf(fixedCreditValue)); |
| 592 | 44 | attributes = new HashMap<String,String>(); |
| 593 | 44 | attributes.put(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_FIXED_CREDIT_VALUE, String.valueOf(fixedCreditValue)); |
| 594 | 44 | }else if(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_MULTIPLE.equals(creditOption.getType())){ |
| 595 | 3 | Collections.sort(creditOption.getResultValues()); |
| 596 | 3 | StringBuilder sb = new StringBuilder(CourseAssemblerConstants.COURSE_RESULT_COMP_CREDIT_PREFIX); |
| 597 | 3 | for(Iterator<String> iter = creditOption.getResultValues().iterator();iter.hasNext();){ |
| 598 | 7 | sb.append(iter.next()); |
| 599 | 7 | if(iter.hasNext()){ |
| 600 | 4 | sb.append(","); |
| 601 | |
} |
| 602 | |
} |
| 603 | 3 | id = sb.toString(); |
| 604 | 3 | type = CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_MULTIPLE; |
| 605 | 3 | resultValues = creditOption.getResultValues(); |
| 606 | 3 | }else if(CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_VARIABLE.equals(creditOption.getType())){ |
| 607 | |
|
| 608 | |
|
| 609 | |
|
| 610 | |
|
| 611 | |
|
| 612 | 2 | String minCreditValue = creditOption.getAttributes().get(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_MIN_CREDIT_VALUE); |
| 613 | 2 | String maxCreditValue = creditOption.getAttributes().get(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_MAX_CREDIT_VALUE); |
| 614 | 2 | String creditValueIncr = creditOption.getAttributes().get(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_CREDIT_VALUE_INCR); |
| 615 | 2 | float minCredits = Float.parseFloat(minCreditValue); |
| 616 | 2 | float maxCredits = Float.parseFloat(maxCreditValue); |
| 617 | |
|
| 618 | 2 | float increment = (null != creditValueIncr && creditValueIncr.length() > 0 ) ? Float.parseFloat(creditValueIncr) : defaultCreditIncrement ; |
| 619 | |
|
| 620 | 2 | id = CourseAssemblerConstants.COURSE_RESULT_COMP_CREDIT_PREFIX + minCreditValue + "-" + maxCreditValue; |
| 621 | 2 | type = CourseAssemblerConstants.COURSE_RESULT_COMP_TYPE_CREDIT_VARIABLE; |
| 622 | 2 | resultValues = new ArrayList<String>(); |
| 623 | 16 | for(float i = minCredits; i <= maxCredits; i+=increment){ |
| 624 | 14 | resultValues.add(String.valueOf(i)); |
| 625 | |
} |
| 626 | 2 | attributes = new HashMap<String,String>(); |
| 627 | 2 | attributes.put(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_MIN_CREDIT_VALUE, minCreditValue); |
| 628 | 2 | attributes.put(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_MAX_CREDIT_VALUE, maxCreditValue); |
| 629 | 2 | attributes.put(CourseAssemblerConstants.COURSE_RESULT_COMP_ATTR_CREDIT_VALUE_INCR, creditValueIncr); |
| 630 | |
} |
| 631 | |
|
| 632 | |
|
| 633 | 49 | creditOption.setId(id); |
| 634 | |
|
| 635 | |
|
| 636 | 49 | if(id != null && !rsltComps.contains(id)){ |
| 637 | |
|
| 638 | |
|
| 639 | 4 | ResultComponentInfo resultComponent = new ResultComponentInfo(); |
| 640 | 4 | resultComponent.setId(id); |
| 641 | 4 | resultComponent.setType(type); |
| 642 | 4 | resultComponent.setState (course.getState()); |
| 643 | 4 | resultComponent.setResultValues(resultValues); |
| 644 | 4 | resultComponent.setAttributes(attributes); |
| 645 | 4 | BaseDTOAssemblyNode<ResultComponentInfo, ResultComponentInfo> node = new BaseDTOAssemblyNode<ResultComponentInfo, ResultComponentInfo>(null); |
| 646 | 4 | node.setOperation(NodeOperation.CREATE); |
| 647 | 4 | node.setNodeData(resultComponent); |
| 648 | 4 | node.setBusinessDTORef(creditOption); |
| 649 | 4 | results.add(node); |
| 650 | |
|
| 651 | 4 | rsltComps.add(id); |
| 652 | |
} |
| 653 | 49 | } |
| 654 | 0 | }catch (NumberFormatException e){ |
| 655 | 0 | throw new AssemblyException("Invalid Arguments for credit outcome values",e); |
| 656 | 0 | }catch (Exception e){ |
| 657 | 0 | throw new AssemblyException("Error Assembling", e); |
| 658 | 24 | } |
| 659 | |
} |
| 660 | |
|
| 661 | |
|
| 662 | |
|
| 663 | |
|
| 664 | 25 | Map<String, List<CluResultInfo>> currentResults = new HashMap<String, List<CluResultInfo>>(); |
| 665 | |
|
| 666 | |
|
| 667 | 25 | if (!NodeOperation.CREATE.equals(operation)) { |
| 668 | 11 | for (CluResultInfo currentResult : currentCluResults) { |
| 669 | 9 | if (courseResultType.equals(currentResult.getType())) { |
| 670 | |
|
| 671 | 6 | if(currentResult.getResultOptions().size()==1){ |
| 672 | |
|
| 673 | 6 | String resultComponentId = currentResult.getResultOptions().get(0).getResultComponentId(); |
| 674 | 6 | if(!currentResults.containsKey(resultComponentId)){ |
| 675 | 4 | currentResults.put(resultComponentId, new ArrayList<CluResultInfo>()); |
| 676 | |
} |
| 677 | 6 | currentResults.get(resultComponentId).add(currentResult); |
| 678 | 6 | }else{ |
| 679 | 0 | LOG.warn("Credit Results should have exactly one result option each"); |
| 680 | |
} |
| 681 | |
} |
| 682 | |
} |
| 683 | |
} |
| 684 | |
|
| 685 | |
|
| 686 | 25 | for(ResultComponentInfo creditOption : course.getCreditOptions()){ |
| 687 | 51 | if (NodeOperation.CREATE == operation |
| 688 | |
|| (NodeOperation.UPDATE == operation && !currentResults.containsKey(creditOption.getId()) )) { |
| 689 | |
|
| 690 | 46 | ResultOptionInfo resultOption = new ResultOptionInfo(); |
| 691 | 46 | resultOption.setState(course.getState()); |
| 692 | 46 | resultOption.setResultComponentId(creditOption.getId()); |
| 693 | |
|
| 694 | 46 | CluResultInfo cluResult = new CluResultInfo(); |
| 695 | 46 | cluResult.setCluId(clu.getId()); |
| 696 | 46 | cluResult.setState(course.getState()); |
| 697 | 46 | cluResult.setType(courseResultType); |
| 698 | |
|
| 699 | 46 | cluResult.getResultOptions().add(resultOption); |
| 700 | |
|
| 701 | 46 | BaseDTOAssemblyNode<ResultComponentInfo, CluResultInfo> cluResultNode = new BaseDTOAssemblyNode<ResultComponentInfo, CluResultInfo>(null); |
| 702 | 46 | cluResultNode.setNodeData(cluResult); |
| 703 | 46 | cluResultNode.setOperation(NodeOperation.CREATE); |
| 704 | |
|
| 705 | 46 | results.add(cluResultNode); |
| 706 | 46 | } else if (NodeOperation.UPDATE == operation |
| 707 | |
&& currentResults.containsKey(creditOption.getId())) { |
| 708 | |
|
| 709 | 3 | List<CluResultInfo> cluResults = currentResults.get(creditOption.getId()); |
| 710 | 3 | cluResults.remove(cluResults.size()-1); |
| 711 | 3 | if(cluResults.isEmpty()){ |
| 712 | 2 | currentResults.remove(creditOption.getId()); |
| 713 | |
} |
| 714 | 51 | } |
| 715 | |
} |
| 716 | |
|
| 717 | |
|
| 718 | 25 | for(Entry<String,List<CluResultInfo>> entry:currentResults.entrySet()){ |
| 719 | 2 | for(CluResultInfo cluResult:entry.getValue()){ |
| 720 | 3 | BaseDTOAssemblyNode<ResultComponentInfo, CluResultInfo> cluResultNode = new BaseDTOAssemblyNode<ResultComponentInfo, CluResultInfo>(null); |
| 721 | 3 | cluResultNode.setNodeData(cluResult); |
| 722 | 3 | cluResultNode.setOperation(NodeOperation.DELETE); |
| 723 | 3 | results.add(cluResultNode); |
| 724 | 3 | } |
| 725 | |
} |
| 726 | |
|
| 727 | 25 | return results; |
| 728 | |
} |
| 729 | |
|
| 730 | |
private List<String> assembleGradingOptions(List<CluResultInfo> cluResults){ |
| 731 | |
|
| 732 | 14 | String courseResultType = CourseAssemblerConstants.COURSE_RESULT_TYPE_GRADE; |
| 733 | |
|
| 734 | 14 | List<String> results = new ArrayList<String>(); |
| 735 | |
|
| 736 | 14 | for(CluResultInfo cluResult:cluResults){ |
| 737 | 42 | if(courseResultType.equals(cluResult.getType())){ |
| 738 | |
|
| 739 | 14 | for(ResultOptionInfo resultOption: cluResult.getResultOptions()){ |
| 740 | 28 | results.add(resultOption.getResultComponentId()); |
| 741 | |
} |
| 742 | 14 | break; |
| 743 | |
} |
| 744 | |
} |
| 745 | 14 | return results; |
| 746 | |
} |
| 747 | |
|
| 748 | |
private List<ResultComponentInfo> assembleCreditOptions( |
| 749 | |
List<CluResultInfo> cluResults) throws AssemblyException { |
| 750 | 14 | String courseResultType = CourseAssemblerConstants.COURSE_RESULT_TYPE_CREDITS; |
| 751 | 14 | List<ResultComponentInfo> results = new ArrayList<ResultComponentInfo>(); |
| 752 | |
|
| 753 | 14 | for(CluResultInfo cluResult:cluResults){ |
| 754 | 43 | if(courseResultType.equals(cluResult.getType())){ |
| 755 | |
|
| 756 | 29 | for(ResultOptionInfo resultOption: cluResult.getResultOptions()){ |
| 757 | |
try { |
| 758 | 29 | ResultComponentInfo resultComponent = lrcService.getResultComponent(resultOption.getResultComponentId()); |
| 759 | 29 | results.add(resultComponent); |
| 760 | 0 | } catch (DoesNotExistException e) { |
| 761 | 0 | LOG.warn("Course Credit option:"+resultOption.getId()+" refers to non-existant ResultComponentInfo "+resultOption.getResultComponentId()); |
| 762 | 0 | } catch (Exception e) { |
| 763 | 0 | throw new AssemblyException("Error getting result components",e); |
| 764 | 29 | } |
| 765 | |
} |
| 766 | |
} |
| 767 | |
} |
| 768 | 14 | return results; |
| 769 | |
} |
| 770 | |
|
| 771 | |
|
| 772 | |
private List<BaseDTOAssemblyNode<?, ?>> disassembleLos(String cluId, |
| 773 | |
CourseInfo course, NodeOperation operation) throws AssemblyException { |
| 774 | |
|
| 775 | 25 | List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
| 776 | |
|
| 777 | |
|
| 778 | |
|
| 779 | 25 | Map<String, CluLoRelationInfo> currentCluLoRelations = new HashMap<String, CluLoRelationInfo>(); |
| 780 | |
try { |
| 781 | 25 | List<CluLoRelationInfo> cluLoRelations = luService.getCluLoRelationsByClu(cluId); |
| 782 | 25 | for(CluLoRelationInfo cluLoRelation:cluLoRelations){ |
| 783 | 6 | if(CourseAssemblerConstants.COURSE_LO_COURSE_SPECIFIC_RELATION.equals(cluLoRelation.getType())){ |
| 784 | 6 | currentCluLoRelations.put(cluLoRelation.getLoId(), cluLoRelation); |
| 785 | |
} |
| 786 | |
} |
| 787 | 0 | } catch (DoesNotExistException e) { |
| 788 | 0 | } catch (Exception e) { |
| 789 | 0 | throw new AssemblyException("Error finding related Los"); |
| 790 | 25 | } |
| 791 | |
|
| 792 | |
|
| 793 | 25 | for(LoDisplayInfo loDisplay : course.getCourseSpecificLOs()){ |
| 794 | |
|
| 795 | |
|
| 796 | 50 | if (NodeOperation.CREATE == operation |
| 797 | |
|| (NodeOperation.UPDATE == operation && !currentCluLoRelations.containsKey(loDisplay.getLoInfo().getId()))) { |
| 798 | |
|
| 799 | |
|
| 800 | |
|
| 801 | 45 | loDisplay.getLoInfo().setId(null); |
| 802 | 45 | loDisplay.getLoInfo().setState(course.getState()); |
| 803 | 45 | BaseDTOAssemblyNode<LoDisplayInfo, LoInfo> loNode = loAssembler |
| 804 | |
.disassemble(loDisplay, NodeOperation.CREATE); |
| 805 | 45 | results.add(loNode); |
| 806 | |
|
| 807 | |
|
| 808 | 45 | CluLoRelationInfo relation = new CluLoRelationInfo(); |
| 809 | 45 | relation.setCluId(cluId); |
| 810 | 45 | relation.setLoId(loNode.getNodeData().getId()); |
| 811 | 45 | relation |
| 812 | |
.setType(CourseAssemblerConstants.COURSE_LO_COURSE_SPECIFIC_RELATION); |
| 813 | 45 | relation.setState(course.getState()); |
| 814 | |
|
| 815 | 45 | BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo> relationNode = new BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo>( |
| 816 | |
null); |
| 817 | 45 | relationNode.setNodeData(relation); |
| 818 | 45 | relationNode.setOperation(NodeOperation.CREATE); |
| 819 | |
|
| 820 | 45 | results.add(relationNode); |
| 821 | 45 | } else if (NodeOperation.UPDATE == operation |
| 822 | |
&& currentCluLoRelations.containsKey(loDisplay.getLoInfo().getId())) { |
| 823 | 3 | loDisplay.getLoInfo().setState(course.getState()); |
| 824 | |
|
| 825 | 3 | BaseDTOAssemblyNode<LoDisplayInfo, LoInfo> loNode = loAssembler |
| 826 | |
.disassemble(loDisplay, NodeOperation.UPDATE); |
| 827 | 3 | results.add(loNode); |
| 828 | |
|
| 829 | |
|
| 830 | |
|
| 831 | 3 | currentCluLoRelations.remove(loDisplay.getLoInfo().getId()); |
| 832 | 3 | } else if (NodeOperation.DELETE == operation |
| 833 | |
&& currentCluLoRelations.containsKey(loDisplay.getLoInfo().getId())) { |
| 834 | |
|
| 835 | |
|
| 836 | 2 | CluLoRelationInfo relationToDelete = currentCluLoRelations.get(loDisplay.getLoInfo().getId()); |
| 837 | 2 | BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo>( |
| 838 | |
null); |
| 839 | 2 | relationToDeleteNode.setNodeData(relationToDelete); |
| 840 | 2 | relationToDeleteNode.setOperation(NodeOperation.DELETE); |
| 841 | 2 | results.add(relationToDeleteNode); |
| 842 | |
|
| 843 | 2 | BaseDTOAssemblyNode<LoDisplayInfo, LoInfo> loNode = loAssembler |
| 844 | |
.disassemble(loDisplay, NodeOperation.DELETE); |
| 845 | 2 | results.add(loNode); |
| 846 | |
|
| 847 | |
|
| 848 | |
|
| 849 | 2 | currentCluLoRelations.remove(loDisplay.getLoInfo().getId()); |
| 850 | 50 | } |
| 851 | |
} |
| 852 | |
|
| 853 | |
|
| 854 | |
|
| 855 | 25 | for (Entry<String, CluLoRelationInfo> entry : currentCluLoRelations.entrySet()) { |
| 856 | |
|
| 857 | |
|
| 858 | 1 | CluLoRelationInfo relationToDelete = entry.getValue(); |
| 859 | 1 | BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<LoDisplayInfo, CluLoRelationInfo>( |
| 860 | |
null); |
| 861 | 1 | relationToDeleteNode.setNodeData(relationToDelete); |
| 862 | 1 | relationToDeleteNode.setOperation(NodeOperation.DELETE); |
| 863 | 1 | results.add(relationToDeleteNode); |
| 864 | |
|
| 865 | |
try{ |
| 866 | 1 | LoInfo loToDelete = loService.getLo(entry.getKey()); |
| 867 | |
|
| 868 | 1 | LoDisplayInfo loDisplayToDelete = loAssembler.assemble(loToDelete, null, false); |
| 869 | 1 | BaseDTOAssemblyNode<LoDisplayInfo, LoInfo> loNode = loAssembler |
| 870 | |
.disassemble(loDisplayToDelete, NodeOperation.DELETE); |
| 871 | 1 | results.add(loNode); |
| 872 | 0 | } catch (DoesNotExistException e){ |
| 873 | 0 | LOG.warn("Trying to delete non exsistant LO:"+entry.getKey()); |
| 874 | 0 | } catch (Exception e) { |
| 875 | 0 | throw new AssemblyException("Error disassembling LOs",e); |
| 876 | 1 | } |
| 877 | 1 | } |
| 878 | |
|
| 879 | 25 | return results; |
| 880 | |
} |
| 881 | |
|
| 882 | |
private BaseDTOAssemblyNode<?, ?> disassembleGradingOptions(String cluId, |
| 883 | |
String courseState, List<String> options, List<CluResultInfo> currentCluResults, NodeOperation operation) throws AssemblyException { |
| 884 | 25 | BaseDTOAssemblyNode<List<String>, CluResultInfo> cluResultNode = new BaseDTOAssemblyNode<List<String>, CluResultInfo>(null); |
| 885 | |
|
| 886 | 25 | String courseResultType=CourseAssemblerConstants.COURSE_RESULT_TYPE_GRADE; |
| 887 | 25 | String resultsDescription="Grading options"; |
| 888 | 25 | String resultDescription="Grading option"; |
| 889 | |
|
| 890 | |
|
| 891 | 25 | Map<String, ResultOptionInfo> currentResults = new HashMap<String, ResultOptionInfo>(); |
| 892 | |
|
| 893 | 25 | CluResultInfo cluResult = null; |
| 894 | |
|
| 895 | |
|
| 896 | 25 | if (!NodeOperation.CREATE.equals(operation)) { |
| 897 | 11 | for (CluResultInfo currentResult : currentCluResults) { |
| 898 | 8 | if (courseResultType.equals(currentResult.getType())) { |
| 899 | 3 | cluResult = currentResult; |
| 900 | 3 | if(NodeOperation.DELETE.equals(operation)){ |
| 901 | |
|
| 902 | 1 | cluResultNode.setOperation(NodeOperation.DELETE); |
| 903 | |
}else{ |
| 904 | |
|
| 905 | 2 | cluResultNode.setOperation(NodeOperation.UPDATE); |
| 906 | 2 | for(ResultOptionInfo resultOption:currentResult.getResultOptions()){ |
| 907 | 4 | currentResults.put(resultOption.getResultComponentId(), resultOption); |
| 908 | |
} |
| 909 | |
} |
| 910 | 2 | break; |
| 911 | |
} |
| 912 | |
} |
| 913 | |
} |
| 914 | |
|
| 915 | |
|
| 916 | 25 | if(!NodeOperation.DELETE.equals(operation)){ |
| 917 | 24 | if(cluResult == null){ |
| 918 | |
|
| 919 | 22 | cluResult = new CluResultInfo(); |
| 920 | 22 | cluResult.setCluId(cluId); |
| 921 | 22 | cluResult.setState(courseState); |
| 922 | 22 | cluResult.setType(courseResultType); |
| 923 | 22 | RichTextInfo desc = new RichTextInfo(); |
| 924 | 22 | desc.setPlain(resultsDescription); |
| 925 | 22 | cluResult.setDesc(desc); |
| 926 | 22 | cluResult.setEffectiveDate(new Date()); |
| 927 | 22 | cluResultNode.setOperation(NodeOperation.CREATE); |
| 928 | |
} |
| 929 | |
|
| 930 | 24 | cluResult.setResultOptions(new ArrayList<ResultOptionInfo>()); |
| 931 | |
|
| 932 | |
|
| 933 | 24 | for (String optionType : options) { |
| 934 | 48 | if(currentResults.containsKey(optionType)){ |
| 935 | |
|
| 936 | 3 | ResultOptionInfo resultOptionInfo = currentResults.get(optionType); |
| 937 | 3 | cluResult.getResultOptions().add(resultOptionInfo); |
| 938 | 3 | }else{ |
| 939 | |
|
| 940 | 45 | ResultOptionInfo resultOptionInfo = new ResultOptionInfo(); |
| 941 | 45 | RichTextInfo desc = new RichTextInfo(); |
| 942 | 45 | desc.setPlain(resultDescription); |
| 943 | 45 | resultOptionInfo.setDesc(desc); |
| 944 | 45 | resultOptionInfo.setResultComponentId(optionType); |
| 945 | 45 | resultOptionInfo.setState(courseState); |
| 946 | |
|
| 947 | 45 | cluResult.getResultOptions().add(resultOptionInfo); |
| 948 | 48 | } |
| 949 | |
} |
| 950 | |
} |
| 951 | |
|
| 952 | 25 | cluResultNode.setNodeData(cluResult); |
| 953 | 25 | return cluResultNode; |
| 954 | |
} |
| 955 | |
|
| 956 | |
|
| 957 | |
|
| 958 | |
private List<BaseDTOAssemblyNode<?, ?>> disassembleFormats(String nodeId, |
| 959 | |
CourseInfo course, NodeOperation operation) |
| 960 | |
throws AssemblyException, DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException { |
| 961 | |
|
| 962 | 25 | List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
| 963 | |
|
| 964 | |
|
| 965 | |
|
| 966 | 25 | Map<String, String> currentformatIds = new HashMap<String, String>(); |
| 967 | |
|
| 968 | 25 | if (!NodeOperation.CREATE.equals(operation)) { |
| 969 | |
try { |
| 970 | 11 | List<CluCluRelationInfo> formatRelationships = luService |
| 971 | |
.getCluCluRelationsByClu(course.getId()); |
| 972 | |
|
| 973 | |
|
| 974 | |
|
| 975 | 11 | for (CluCluRelationInfo formatRelation : formatRelationships) { |
| 976 | 7 | if (CourseAssemblerConstants.COURSE_FORMAT_RELATION_TYPE |
| 977 | |
.equals(formatRelation.getType())) { |
| 978 | 7 | currentformatIds.put(formatRelation.getRelatedCluId(), |
| 979 | |
formatRelation.getId()); |
| 980 | |
} |
| 981 | |
} |
| 982 | 0 | } catch (DoesNotExistException e) { |
| 983 | 0 | } catch (InvalidParameterException e) { |
| 984 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 985 | 0 | } catch (MissingParameterException e) { |
| 986 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 987 | 0 | } catch (OperationFailedException e) { |
| 988 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 989 | 11 | } |
| 990 | |
} |
| 991 | |
|
| 992 | |
|
| 993 | 25 | for (FormatInfo format : course.getFormats()) { |
| 994 | |
|
| 995 | |
|
| 996 | 51 | if (NodeOperation.CREATE == operation |
| 997 | |
|| (NodeOperation.UPDATE == operation && !currentformatIds.containsKey(format.getId()) )) { |
| 998 | |
|
| 999 | |
|
| 1000 | 45 | format.setState(course.getState()); |
| 1001 | 45 | BaseDTOAssemblyNode<FormatInfo, CluInfo> formatNode = formatAssembler |
| 1002 | |
.disassemble(format, NodeOperation.CREATE); |
| 1003 | 45 | results.add(formatNode); |
| 1004 | |
|
| 1005 | |
|
| 1006 | |
|
| 1007 | 45 | CluCluRelationInfo relation = new CluCluRelationInfo(); |
| 1008 | 45 | relation.setCluId(nodeId); |
| 1009 | 45 | relation.setRelatedCluId(formatNode.getNodeData().getId()); |
| 1010 | |
|
| 1011 | |
|
| 1012 | |
|
| 1013 | |
|
| 1014 | 45 | relation |
| 1015 | |
.setType(CourseAssemblerConstants.COURSE_FORMAT_RELATION_TYPE); |
| 1016 | 45 | relation.setState(course.getState()); |
| 1017 | |
|
| 1018 | 45 | BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo> relationNode = new BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo>( |
| 1019 | |
null); |
| 1020 | 45 | relationNode.setNodeData(relation); |
| 1021 | 45 | relationNode.setOperation(NodeOperation.CREATE); |
| 1022 | |
|
| 1023 | 45 | results.add(relationNode); |
| 1024 | 45 | } else if (NodeOperation.UPDATE == operation |
| 1025 | |
&& currentformatIds.containsKey(format.getId())) { |
| 1026 | |
|
| 1027 | |
|
| 1028 | 4 | format.setState(course.getState()); |
| 1029 | 4 | BaseDTOAssemblyNode<FormatInfo, CluInfo> formatNode = formatAssembler |
| 1030 | |
.disassemble(format, NodeOperation.UPDATE); |
| 1031 | 4 | results.add(formatNode); |
| 1032 | |
|
| 1033 | |
|
| 1034 | |
|
| 1035 | 4 | currentformatIds.remove(format.getId()); |
| 1036 | 4 | } else if (NodeOperation.DELETE == operation |
| 1037 | |
&& currentformatIds.containsKey(format.getId())) { |
| 1038 | |
|
| 1039 | 2 | CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
| 1040 | 2 | relationToDelete.setId( currentformatIds.get(format.getId()) ); |
| 1041 | 2 | BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo>( |
| 1042 | |
null); |
| 1043 | 2 | relationToDeleteNode.setNodeData(relationToDelete); |
| 1044 | 2 | relationToDeleteNode.setOperation(NodeOperation.DELETE); |
| 1045 | 2 | results.add(relationToDeleteNode); |
| 1046 | |
|
| 1047 | 2 | BaseDTOAssemblyNode<FormatInfo, CluInfo> formatNode = formatAssembler |
| 1048 | |
.disassemble(format, NodeOperation.DELETE); |
| 1049 | 2 | results.add(formatNode); |
| 1050 | |
|
| 1051 | |
|
| 1052 | |
|
| 1053 | 2 | currentformatIds.remove(format.getId()); |
| 1054 | 51 | } |
| 1055 | |
} |
| 1056 | |
|
| 1057 | |
|
| 1058 | |
|
| 1059 | 25 | for (Entry<String, String> entry : currentformatIds.entrySet()) { |
| 1060 | |
|
| 1061 | |
|
| 1062 | 1 | CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
| 1063 | 1 | relationToDelete.setId( entry.getValue() ); |
| 1064 | 1 | BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<CourseInfo, CluCluRelationInfo>( |
| 1065 | |
null); |
| 1066 | 1 | relationToDeleteNode.setNodeData(relationToDelete); |
| 1067 | 1 | relationToDeleteNode.setOperation(NodeOperation.DELETE); |
| 1068 | 1 | results.add(relationToDeleteNode); |
| 1069 | |
|
| 1070 | 1 | CluInfo formatCluToDelete = luService.getClu(entry.getKey()); |
| 1071 | 1 | FormatInfo formatToDelete = formatAssembler.assemble(formatCluToDelete, null, false); |
| 1072 | 1 | BaseDTOAssemblyNode<FormatInfo, CluInfo> formatNode = formatAssembler |
| 1073 | |
.disassemble(formatToDelete, NodeOperation.DELETE); |
| 1074 | 1 | results.add(formatNode); |
| 1075 | 1 | } |
| 1076 | |
|
| 1077 | 25 | return results; |
| 1078 | |
} |
| 1079 | |
|
| 1080 | |
private List<CourseVariationInfo> assembleVariations(List<CluIdentifierInfo> cluIdents) { |
| 1081 | 45 | List<CourseVariationInfo> variations = new ArrayList<CourseVariationInfo>(); |
| 1082 | 45 | if (cluIdents != null) { |
| 1083 | 45 | for (CluIdentifierInfo cluIdent : cluIdents) { |
| 1084 | 94 | if (cluIdent.getType() != null && |
| 1085 | |
cluIdent.getType().equals(CourseAssemblerConstants.COURSE_VARIATION_IDENT_TYPE)) { |
| 1086 | 90 | CourseVariationInfo variation = new CourseVariationInfo(); |
| 1087 | 90 | variation.setId(cluIdent.getId()); |
| 1088 | 90 | variation.setType(cluIdent.getType()); |
| 1089 | 90 | variation.setCourseNumberSuffix(cluIdent.getSuffixCode()); |
| 1090 | 90 | variation.setSubjectArea(cluIdent.getDivision()); |
| 1091 | 90 | variation.setVariationCode(cluIdent.getVariation()); |
| 1092 | 90 | variation.setVariationTitle(cluIdent.getLongName()); |
| 1093 | 90 | variations.add(variation); |
| 1094 | 94 | } |
| 1095 | |
} |
| 1096 | |
} |
| 1097 | 45 | return variations; |
| 1098 | |
} |
| 1099 | |
|
| 1100 | |
private List<CourseCrossListingInfo> assembleCrossListings(List<CluIdentifierInfo> cluIdents) { |
| 1101 | 45 | List<CourseCrossListingInfo> crossListings = new ArrayList<CourseCrossListingInfo>(); |
| 1102 | 45 | if (cluIdents != null) { |
| 1103 | 45 | for (CluIdentifierInfo cluIdent : cluIdents) { |
| 1104 | 94 | if (cluIdent.getType() != null && |
| 1105 | |
cluIdent.getType().equals(CourseAssemblerConstants.COURSE_CROSSLISTING_IDENT_TYPE)) { |
| 1106 | 4 | CourseCrossListingInfo crosslisting = new CourseCrossListingInfo(); |
| 1107 | 4 | crosslisting.setId(cluIdent.getId()); |
| 1108 | 4 | crosslisting.setCode(cluIdent.getCode()); |
| 1109 | 4 | crosslisting.setAttributes(cluIdent.getAttributes()); |
| 1110 | 4 | crosslisting.setType(cluIdent.getType()); |
| 1111 | 4 | crosslisting.setCourseNumberSuffix(cluIdent.getSuffixCode()); |
| 1112 | 4 | crosslisting.setSubjectArea(cluIdent.getDivision()); |
| 1113 | 4 | crosslisting.setDepartment(cluIdent.getOrgId()); |
| 1114 | 4 | crossListings.add(crosslisting); |
| 1115 | 94 | } |
| 1116 | |
} |
| 1117 | |
} |
| 1118 | 45 | return crossListings; |
| 1119 | |
} |
| 1120 | |
|
| 1121 | |
|
| 1122 | |
|
| 1123 | |
private List<BaseDTOAssemblyNode<?, ?>> disassembleJoints(String nodeId, |
| 1124 | |
CourseInfo course, NodeOperation operation) |
| 1125 | |
throws AssemblyException { |
| 1126 | |
|
| 1127 | 25 | List<BaseDTOAssemblyNode<?, ?>> results = new ArrayList<BaseDTOAssemblyNode<?, ?>>(); |
| 1128 | |
|
| 1129 | |
|
| 1130 | |
|
| 1131 | 25 | Map<String, CluCluRelationInfo> currentJointIds = new HashMap<String, CluCluRelationInfo>(); |
| 1132 | |
|
| 1133 | 25 | if (!NodeOperation.CREATE.equals(operation)) { |
| 1134 | |
try { |
| 1135 | 11 | List<CluCluRelationInfo> jointRelationships = luService.getCluCluRelationsByClu(course.getId()); |
| 1136 | 11 | for (CluCluRelationInfo jointRelation : jointRelationships) { |
| 1137 | 7 | if (CourseAssemblerConstants.JOINT_RELATION_TYPE.equals(jointRelation.getType())) { |
| 1138 | 0 | if(jointRelation.getCluId().equals(course.getId())) { |
| 1139 | 0 | CluInfo clu = luService.getClu(jointRelation.getRelatedCluId()); |
| 1140 | 0 | if (clu.getState().equals(DtoConstants.STATE_ACTIVE) || clu.getState().equals(DtoConstants.STATE_SUPERSEDED) || |
| 1141 | |
clu.getState().equals(DtoConstants.STATE_APPROVED) || clu.getState().equals(DtoConstants.STATE_SUSPENDED)) |
| 1142 | 0 | currentJointIds.put(jointRelation.getId(),jointRelation); |
| 1143 | 0 | } else { |
| 1144 | 0 | CluInfo clu = luService.getClu(jointRelation.getCluId()); |
| 1145 | 0 | if (clu.getState().equals(DtoConstants.STATE_ACTIVE) || clu.getState().equals(DtoConstants.STATE_SUPERSEDED) || |
| 1146 | |
clu.getState().equals(DtoConstants.STATE_APPROVED) || clu.getState().equals(DtoConstants.STATE_SUSPENDED)) |
| 1147 | 0 | currentJointIds.put(jointRelation.getId(),jointRelation); |
| 1148 | 7 | } |
| 1149 | |
} |
| 1150 | |
} |
| 1151 | 0 | } catch (DoesNotExistException e) { |
| 1152 | 0 | } catch (InvalidParameterException e) { |
| 1153 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 1154 | 0 | } catch (MissingParameterException e) { |
| 1155 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 1156 | 0 | } catch (OperationFailedException e) { |
| 1157 | 0 | throw new AssemblyException("Error getting related formats", e); |
| 1158 | 11 | } |
| 1159 | |
} |
| 1160 | |
|
| 1161 | |
|
| 1162 | 25 | for (CourseJointInfo joint : course.getJoints()) { |
| 1163 | |
|
| 1164 | 0 | if (NodeOperation.UPDATE.equals(operation) && joint.getRelationId() != null |
| 1165 | |
&& currentJointIds.containsKey(joint.getRelationId())) { |
| 1166 | |
|
| 1167 | |
|
| 1168 | 0 | CluCluRelationInfo relation = currentJointIds.remove(joint.getRelationId()); |
| 1169 | 0 | relation.setRelatedCluId(joint.getCourseId()); |
| 1170 | 0 | relation.setState(course.getState()); |
| 1171 | 0 | BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> jointNode = new BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo>(courseJointAssembler); |
| 1172 | 0 | jointNode.setBusinessDTORef(joint); |
| 1173 | 0 | jointNode.setNodeData(relation); |
| 1174 | 0 | jointNode.setOperation(NodeOperation.UPDATE); |
| 1175 | 0 | results.add(jointNode); |
| 1176 | 0 | } else if (!NodeOperation.DELETE.equals(operation)) { |
| 1177 | |
|
| 1178 | 0 | BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> jointNode = courseJointAssembler |
| 1179 | |
.disassemble(joint, NodeOperation.CREATE); |
| 1180 | 0 | jointNode.getNodeData().setCluId(nodeId); |
| 1181 | 0 | jointNode.getNodeData().setState(course.getState()); |
| 1182 | 0 | results.add(jointNode); |
| 1183 | 0 | } |
| 1184 | |
} |
| 1185 | |
|
| 1186 | |
|
| 1187 | |
|
| 1188 | 25 | for (String id : currentJointIds.keySet()) { |
| 1189 | |
|
| 1190 | |
|
| 1191 | 0 | CluCluRelationInfo relationToDelete = new CluCluRelationInfo(); |
| 1192 | 0 | relationToDelete.setId(id); |
| 1193 | 0 | BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo> relationToDeleteNode = new BaseDTOAssemblyNode<CourseJointInfo, CluCluRelationInfo>( |
| 1194 | |
courseJointAssembler); |
| 1195 | 0 | relationToDeleteNode.setNodeData(relationToDelete); |
| 1196 | 0 | relationToDeleteNode.setOperation(NodeOperation.DELETE); |
| 1197 | 0 | results.add(relationToDeleteNode); |
| 1198 | 0 | } |
| 1199 | |
|
| 1200 | 25 | return results; |
| 1201 | |
} |
| 1202 | |
|
| 1203 | |
public void setLuService(LuService luService) { |
| 1204 | 1 | this.luService = luService; |
| 1205 | 1 | } |
| 1206 | |
|
| 1207 | |
public void setFormatAssembler(FormatAssembler formatAssembler) { |
| 1208 | 1 | this.formatAssembler = formatAssembler; |
| 1209 | 1 | } |
| 1210 | |
|
| 1211 | |
public void setCourseJointAssembler( |
| 1212 | |
CourseJointAssembler courseJointAssembler) { |
| 1213 | 1 | this.courseJointAssembler = courseJointAssembler; |
| 1214 | 1 | } |
| 1215 | |
|
| 1216 | |
public void setLoAssembler(LoAssembler loAssembler) { |
| 1217 | 1 | this.loAssembler = loAssembler; |
| 1218 | 1 | } |
| 1219 | |
|
| 1220 | |
public void setLoService(LearningObjectiveService loService) { |
| 1221 | 1 | this.loService = loService; |
| 1222 | 1 | } |
| 1223 | |
|
| 1224 | |
public void setCluAssemblerUtils(CluAssemblerUtils cluAssemblerUtils) { |
| 1225 | 1 | this.cluAssemblerUtils = cluAssemblerUtils; |
| 1226 | 1 | } |
| 1227 | |
|
| 1228 | |
public void setLrcService(LrcService lrcService) { |
| 1229 | 1 | this.lrcService = lrcService; |
| 1230 | 1 | } |
| 1231 | |
|
| 1232 | |
public void setAtpService(AtpService atpService) { |
| 1233 | 1 | this.atpService = atpService; |
| 1234 | 1 | } |
| 1235 | |
|
| 1236 | |
public void setDefaultCreditIncrement(float defaultCreditIncrement) { |
| 1237 | 0 | this.defaultCreditIncrement = defaultCreditIncrement; |
| 1238 | 0 | } |
| 1239 | |
} |