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