Coverage Report - org.kuali.student.enrollment.class2.academicrecord.service.assembler.StudentCourseRecordAssembler
 
Classes in this File Line Coverage Branch Coverage Complexity
StudentCourseRecordAssembler
0%
0/82
0%
0/14
4.25
 
 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.courseregistration.dto.CourseRegistrationInfo;
 5  
 import org.kuali.student.enrollment.grading.dto.GradeRosterEntryInfo;
 6  
 import org.kuali.student.enrollment.grading.service.GradingService;
 7  
 
 8  
 import org.kuali.student.enrollment.lui.service.LuiService;
 9  
 import org.kuali.student.enrollment.lui.dto.LuiInfo;
 10  
 import org.kuali.student.enrollment.lui.dto.LuiIdentifierInfo;
 11  
 
 12  
 import org.kuali.student.r2.common.assembler.AssemblyException;
 13  
 import org.kuali.student.r2.common.assembler.DTOAssembler;
 14  
 import org.kuali.student.r2.common.dto.ContextInfo;
 15  
 import org.kuali.student.r2.common.exceptions.*;
 16  
 
 17  
 import org.kuali.student.r2.core.atp.dto.AtpInfo;
 18  
 import org.kuali.student.r2.core.atp.service.AtpService;
 19  
 
 20  
 import org.kuali.student.r2.lum.lrc.dto.ResultValueInfo;
 21  
 import org.kuali.student.r2.lum.lrc.service.LRCService;
 22  
 
 23  0
 public class StudentCourseRecordAssembler 
 24  
     implements DTOAssembler<StudentCourseRecordInfo, CourseRegistrationInfo> {
 25  
 
 26  
         private AtpService atpService;
 27  
         private GradingService gradingService;
 28  
         private LRCService lrcService;
 29  
         private LuiService luiService;
 30  
         
 31  
         public AtpService getAtpService() {
 32  0
                 return atpService;
 33  
         }
 34  
 
 35  
         public void setAtpService(AtpService atpService) {
 36  0
                 this.atpService = atpService;
 37  0
         }
 38  
 
 39  
         public GradingService getGradingService() {
 40  0
                 return gradingService;
 41  
         }
 42  
 
 43  
         public void setGradingService(GradingService gradingService) {
 44  0
                 this.gradingService = gradingService;
 45  0
         }
 46  
 
 47  
         public LRCService getLrcService() {
 48  0
                 return lrcService;
 49  
         }
 50  
 
 51  
         public void setLrcService(LRCService lrcService) {
 52  0
                 this.lrcService = lrcService;
 53  0
         }
 54  
 
 55  
         public LuiService getLuiService() {
 56  0
                 return luiService;
 57  
         }
 58  
 
 59  
         public void setLuiService(LuiService luiService) {
 60  0
                 this.luiService = luiService;
 61  0
         }
 62  
 
 63  
         @Override
 64  
         public StudentCourseRecordInfo assemble(CourseRegistrationInfo courseReg, ContextInfo context) throws AssemblyException {
 65  0
             StudentCourseRecordInfo courseRecord = new StudentCourseRecordInfo();
 66  
             
 67  0
             courseRecord.setCourseRegistrationId(courseReg.getId());
 68  0
             courseRecord.setPersonId(courseReg.getStudentId());
 69  
 
 70  
             try {
 71  
             
 72  0
                 LuiInfo lui = this.luiService.getLui(courseReg.getCourseOfferingId(), context);
 73  0
                 LuiIdentifierInfo identifier = lui.getOfficialIdentifier();
 74  0
                 courseRecord.setCourseTitle(identifier != null ? identifier.getLongName() : null);
 75  0
                 courseRecord.setCourseCode(identifier != null ? identifier.getCode() : null);
 76  
                 
 77  
                 //TODO:The code or number of the primary activity. how to determine which activity is primary?
 78  
                 /*            RegGroupRegistrationInfo regGroup = courseReg.getRegGroupRegistration();
 79  
                               if (regGroup.getActivityRegistrations()!= null && !regGroup.getActivityRegistrations().isEmpty()) {
 80  
                               courseRecord.setActivityCode(regGroup.getActivityRegistrations().get(0).getActivityOffering().getActivityCode());
 81  
                               }
 82  
                 */
 83  
 
 84  0
                 if (lui.getAtpId() != null) {
 85  0
                     AtpInfo atp = getAtpService().getAtp(lui.getAtpId(), context);
 86  0
                     courseRecord.setTermName(atp.getName());
 87  0
                     courseRecord.setCourseBeginDate(atp.getStartDate());
 88  0
                     courseRecord.setCourseEndDate(atp.getEndDate());
 89  
                 }
 90  
 
 91  0
                 GradeRosterEntryInfo finalRosterEntry = null;
 92  0
                 finalRosterEntry = gradingService.getFinalGradeForStudentInCourseOffering(courseReg.getStudentId(), lui.getId(), context);
 93  0
                 courseRecord.setAssignedGradeValue(getValue(finalRosterEntry.getAssignedGradeKey(), context));
 94  0
                 courseRecord.setAssignedGradeScaleKey(getScaleKey(finalRosterEntry.getAssignedGradeKey(), context));
 95  0
                 courseRecord.setAdministrativeGradeValue(getValue(finalRosterEntry.getAdministrativeGradeKey(), context));
 96  0
                 courseRecord.setAdministrativeGradeScaleKey(getScaleKey(finalRosterEntry.getAdministrativeGradeKey(), context));
 97  0
                 courseRecord.setCalculatedGradeValue(getValue(finalRosterEntry.getCalculatedGradeKey(), context));
 98  0
                 courseRecord.setCalculatedGradeScaleKey(getScaleKey(finalRosterEntry.getCalculatedGradeKey(), context));
 99  
                 
 100  0
             } catch (DisabledIdentifierException e) {
 101  0
                 throw new AssemblyException("DisabledIdentifierException: " + e.getMessage());
 102  0
             } catch (DoesNotExistException e) {
 103  0
                 throw new AssemblyException("DoesNotExistException: " + e.getMessage());
 104  0
             } catch (InvalidParameterException e) {
 105  0
                 throw new AssemblyException("InvalidParameterException: " + e.getMessage());
 106  0
             } catch (MissingParameterException e) {
 107  0
                 throw new AssemblyException("MissingParameterException: " + e.getMessage());
 108  0
             } catch (OperationFailedException e) {
 109  0
                 throw new AssemblyException("OperationFailedException: " + e.getMessage());
 110  0
             } catch (PermissionDeniedException e) {
 111  0
                 throw new AssemblyException("PermissionDeniedException: "  + e.getMessage());
 112  0
             }        
 113  
             
 114  0
             return courseRecord;
 115  
         }
 116  
 
 117  
         @Override
 118  
         public CourseRegistrationInfo disassemble(
 119  
                         StudentCourseRecordInfo businessDTO, ContextInfo context) {
 120  0
                 return null;
 121  
         }
 122  
         
 123  
         private String getValue(String key, ContextInfo context) throws AssemblyException {
 124  0
                 String value = null;
 125  0
                 if(key != null){
 126  
                         try {
 127  0
                                 if(lrcService != null){
 128  0
                                         ResultValueInfo resultValue = lrcService.getResultValue(key, context);
 129  0
                                         value = resultValue.getValue();
 130  
                                 }
 131  0
                         } catch (DoesNotExistException e) {
 132  0
                                 throw new AssemblyException("DoesNotExistException: " + e.getMessage());
 133  0
                         } catch (InvalidParameterException e) {
 134  0
                                 throw new AssemblyException("InvalidParameterException: "  + e.getMessage());
 135  0
                         } catch (MissingParameterException e) {
 136  0
                                 throw new AssemblyException("MissingParameterException: "  + e.getMessage());
 137  0
                         } catch (OperationFailedException e) {
 138  0
                                 throw new AssemblyException("OperationFailedException: "  + e.getMessage());
 139  0
                         } catch (PermissionDeniedException e) {
 140  0
                                 throw new AssemblyException("PermissionDeniedException: "  + e.getMessage());
 141  0
                         }
 142  
                 }
 143  
                 
 144  0
                 return value;
 145  
         }
 146  
         
 147  
         private String getScaleKey(String key, ContextInfo context) throws AssemblyException {
 148  0
                 String scaleKey = null;
 149  0
                 if(key != null){
 150  
                         try {
 151  0
                                 if(lrcService != null){
 152  0
                                         ResultValueInfo resultValue = lrcService.getResultValue(key, context);
 153  0
                                         scaleKey = resultValue.getResultScaleKey();
 154  
                                 }
 155  0
                         } catch (DoesNotExistException e) {
 156  0
                                 throw new AssemblyException("DoesNotExistException: " + e.getMessage());
 157  0
                         } catch (InvalidParameterException e) {
 158  0
                                 throw new AssemblyException("InvalidParameterException: " + e.getMessage());
 159  0
                         } catch (MissingParameterException e) {
 160  0
                                 throw new AssemblyException("MissingParameterException: "  + e.getMessage());
 161  0
                         } catch (OperationFailedException e) {
 162  0
                                 throw new AssemblyException("OperationFailedException: "  + e.getMessage());
 163  0
                         } catch (PermissionDeniedException e) {
 164  0
                                 throw new AssemblyException("PermissionDeniedException: "  + e.getMessage());
 165  0
                         }
 166  
                 }
 167  
                 
 168  0
                 return scaleKey;
 169  
         }
 170  
 }