| 1 | |
package org.kuali.student.enrollment.class2.academicrecord.service.assembler; |
| 2 | |
|
| 3 | |
import org.kuali.student.enrollment.academicrecord.dto.StudentCourseRecordInfo; |
| 4 | |
import org.kuali.student.enrollment.courseoffering.dto.CourseOfferingInfo; |
| 5 | |
import org.kuali.student.enrollment.courseregistration.dto.CourseRegistrationInfo; |
| 6 | |
import org.kuali.student.enrollment.courseregistration.dto.RegGroupRegistrationInfo; |
| 7 | |
import org.kuali.student.enrollment.grading.dto.GradeRosterEntryInfo; |
| 8 | |
import org.kuali.student.enrollment.grading.service.GradingService; |
| 9 | |
import org.kuali.student.r2.common.assembler.AssemblyException; |
| 10 | |
import org.kuali.student.r2.common.assembler.DTOAssembler; |
| 11 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 12 | |
import org.kuali.student.r2.common.exceptions.*; |
| 13 | |
import org.kuali.student.r2.core.atp.dto.AtpInfo; |
| 14 | |
import org.kuali.student.r2.core.atp.service.AtpService; |
| 15 | |
import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo; |
| 16 | |
import org.kuali.student.r2.lum.lrc.service.LRCService; |
| 17 | |
|
| 18 | 0 | public class StudentCourseRecordAssembler implements DTOAssembler<StudentCourseRecordInfo, CourseRegistrationInfo> { |
| 19 | |
private AtpService atpService; |
| 20 | |
private GradingService gradingService; |
| 21 | |
private LRCService lrcService; |
| 22 | |
|
| 23 | |
public AtpService getAtpService() { |
| 24 | 0 | return atpService; |
| 25 | |
} |
| 26 | |
|
| 27 | |
public void setAtpService(AtpService atpService) { |
| 28 | 0 | this.atpService = atpService; |
| 29 | 0 | } |
| 30 | |
|
| 31 | |
public GradingService getGradingService() { |
| 32 | 0 | return gradingService; |
| 33 | |
} |
| 34 | |
|
| 35 | |
public void setGradingService(GradingService gradingService) { |
| 36 | 0 | this.gradingService = gradingService; |
| 37 | 0 | } |
| 38 | |
|
| 39 | |
public LRCService getLrcService() { |
| 40 | 0 | return lrcService; |
| 41 | |
} |
| 42 | |
|
| 43 | |
public void setLrcService(LRCService lrcService) { |
| 44 | 0 | this.lrcService = lrcService; |
| 45 | 0 | } |
| 46 | |
|
| 47 | |
@Override |
| 48 | |
public StudentCourseRecordInfo assemble(CourseRegistrationInfo courseReg, ContextInfo context) throws AssemblyException { |
| 49 | 0 | StudentCourseRecordInfo courseRecord = new StudentCourseRecordInfo(); |
| 50 | |
|
| 51 | 0 | courseRecord.setCourseRegistrationId(courseReg.getId()); |
| 52 | 0 | courseRecord.setPersonId(courseReg.getStudentId()); |
| 53 | |
|
| 54 | 0 | CourseOfferingInfo co = courseReg.getCourseOffering(); |
| 55 | 0 | courseRecord.setCourseTitle(co.getCourseOfferingTitle()); |
| 56 | 0 | courseRecord.setCourseCode(co.getCourseOfferingCode()); |
| 57 | |
|
| 58 | |
|
| 59 | 0 | RegGroupRegistrationInfo regGroup = courseReg.getRegGroupRegistration(); |
| 60 | 0 | if(regGroup.getActivityRegistrations()!= null && !regGroup.getActivityRegistrations().isEmpty()) |
| 61 | 0 | courseRecord.setActivityCode(regGroup.getActivityRegistrations().get(0).getActivityOffering().getActivityCode()); |
| 62 | |
|
| 63 | |
try{ |
| 64 | 0 | if(co.getTermId() != null){ |
| 65 | 0 | AtpInfo atp = getAtpService().getAtp(co.getTermId(), context); |
| 66 | 0 | courseRecord.setTermName(atp.getName()); |
| 67 | 0 | courseRecord.setCourseBeginDate(atp.getStartDate()); |
| 68 | 0 | courseRecord.setCourseEndDate(atp.getEndDate()); |
| 69 | |
|
| 70 | |
} |
| 71 | |
|
| 72 | 0 | GradeRosterEntryInfo finalRosterEntry = null; |
| 73 | 0 | finalRosterEntry = gradingService.getFinalGradeForStudentInCourseOffering(courseReg.getStudentId(), co.getId(), context); |
| 74 | 0 | courseRecord.setAssignedGradeValue(getValue(finalRosterEntry.getAssignedGradeKey(), context)); |
| 75 | 0 | courseRecord.setAssignedGradeScaleKey(getScaleKey(finalRosterEntry.getAssignedGradeKey(), context)); |
| 76 | 0 | courseRecord.setAdministrativeGradeValue(getValue(finalRosterEntry.getAdministrativeGradeKey(), context)); |
| 77 | 0 | courseRecord.setAdministrativeGradeScaleKey(getScaleKey(finalRosterEntry.getAdministrativeGradeKey(), context)); |
| 78 | 0 | courseRecord.setCalculatedGradeValue(getValue(finalRosterEntry.getCalculatedGradeKey(), context)); |
| 79 | 0 | courseRecord.setCalculatedGradeScaleKey(getScaleKey(finalRosterEntry.getCalculatedGradeKey(), context)); |
| 80 | |
|
| 81 | 0 | } catch (DisabledIdentifierException e) { |
| 82 | 0 | throw new AssemblyException("DisabledIdentifierException: " + e.getMessage()); |
| 83 | 0 | } catch (DoesNotExistException e) { |
| 84 | 0 | throw new AssemblyException("DoesNotExistException: " + e.getMessage()); |
| 85 | 0 | } catch (InvalidParameterException e) { |
| 86 | 0 | throw new AssemblyException("InvalidParameterException: " + e.getMessage()); |
| 87 | 0 | } catch (MissingParameterException e) { |
| 88 | 0 | throw new AssemblyException("MissingParameterException: " + e.getMessage()); |
| 89 | 0 | } catch (OperationFailedException e) { |
| 90 | 0 | throw new AssemblyException("OperationFailedException: " + e.getMessage()); |
| 91 | 0 | } catch (PermissionDeniedException e) { |
| 92 | 0 | throw new AssemblyException("PermissionDeniedException: " + e.getMessage()); |
| 93 | 0 | } |
| 94 | |
|
| 95 | 0 | return courseRecord; |
| 96 | |
} |
| 97 | |
|
| 98 | |
@Override |
| 99 | |
public CourseRegistrationInfo disassemble( |
| 100 | |
StudentCourseRecordInfo businessDTO, ContextInfo context) { |
| 101 | 0 | return null; |
| 102 | |
} |
| 103 | |
|
| 104 | |
private String getValue(String key, ContextInfo context) throws AssemblyException { |
| 105 | 0 | String value = null; |
| 106 | 0 | if(key != null){ |
| 107 | |
try { |
| 108 | 0 | if(lrcService != null){ |
| 109 | 0 | ResultValueInfo resultValue = lrcService.getResultValue(key, context); |
| 110 | 0 | value = resultValue.getValue(); |
| 111 | |
} |
| 112 | 0 | } catch (DoesNotExistException e) { |
| 113 | 0 | throw new AssemblyException("DoesNotExistException: " + e.getMessage()); |
| 114 | 0 | } catch (InvalidParameterException e) { |
| 115 | 0 | throw new AssemblyException("InvalidParameterException: " + e.getMessage()); |
| 116 | 0 | } catch (MissingParameterException e) { |
| 117 | 0 | throw new AssemblyException("MissingParameterException: " + e.getMessage()); |
| 118 | 0 | } catch (OperationFailedException e) { |
| 119 | 0 | throw new AssemblyException("OperationFailedException: " + e.getMessage()); |
| 120 | 0 | } catch (PermissionDeniedException e) { |
| 121 | 0 | throw new AssemblyException("PermissionDeniedException: " + e.getMessage()); |
| 122 | 0 | } |
| 123 | |
} |
| 124 | |
|
| 125 | 0 | return value; |
| 126 | |
} |
| 127 | |
|
| 128 | |
private String getScaleKey(String key, ContextInfo context) throws AssemblyException { |
| 129 | 0 | String scaleKey = null; |
| 130 | 0 | if(key != null){ |
| 131 | |
try { |
| 132 | 0 | if(lrcService != null){ |
| 133 | 0 | ResultValueInfo resultValue = lrcService.getResultValue(key, context); |
| 134 | 0 | scaleKey = resultValue.getResultScaleKey(); |
| 135 | |
} |
| 136 | 0 | } catch (DoesNotExistException e) { |
| 137 | 0 | throw new AssemblyException("DoesNotExistException: " + e.getMessage()); |
| 138 | 0 | } catch (InvalidParameterException e) { |
| 139 | 0 | throw new AssemblyException("InvalidParameterException: " + e.getMessage()); |
| 140 | 0 | } catch (MissingParameterException e) { |
| 141 | 0 | throw new AssemblyException("MissingParameterException: " + e.getMessage()); |
| 142 | 0 | } catch (OperationFailedException e) { |
| 143 | 0 | throw new AssemblyException("OperationFailedException: " + e.getMessage()); |
| 144 | 0 | } catch (PermissionDeniedException e) { |
| 145 | 0 | throw new AssemblyException("PermissionDeniedException: " + e.getMessage()); |
| 146 | 0 | } |
| 147 | |
} |
| 148 | |
|
| 149 | 0 | return scaleKey; |
| 150 | |
} |
| 151 | |
} |