| 1 | |
package org.kuali.student.enrollment.class2.academicrecord.service.impl; |
| 2 | |
|
| 3 | |
import java.util.ArrayList; |
| 4 | |
import java.util.List; |
| 5 | |
|
| 6 | |
import org.kuali.student.enrollment.academicrecord.dto.GPAInfo; |
| 7 | |
import org.kuali.student.enrollment.academicrecord.dto.StudentCourseRecordInfo; |
| 8 | |
import org.kuali.student.enrollment.academicrecord.service.AcademicRecordService; |
| 9 | |
import org.kuali.student.enrollment.class2.academicrecord.service.assembler.StudentCourseRecordAssembler; |
| 10 | |
import org.kuali.student.enrollment.courseregistration.dto.CourseRegistrationInfo; |
| 11 | |
import org.kuali.student.enrollment.courseregistration.service.CourseRegistrationService; |
| 12 | |
import org.kuali.student.enrollment.grading.service.GradingService; |
| 13 | |
import org.kuali.student.r2.common.assembler.AssemblyException; |
| 14 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
| 15 | |
import org.kuali.student.r2.common.exceptions.DisabledIdentifierException; |
| 16 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
| 17 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
| 18 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
| 19 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
| 20 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
| 21 | |
import org.kuali.student.r2.core.atp.service.AtpService; |
| 22 | |
import org.kuali.student.r2.lum.lrc.service.LRCService; |
| 23 | |
import org.springframework.transaction.annotation.Transactional; |
| 24 | |
|
| 25 | |
@Transactional(readOnly=true,noRollbackFor={DoesNotExistException.class},rollbackFor={Throwable.class}) |
| 26 | 0 | public class AcademicRecordServiceImpl implements AcademicRecordService{ |
| 27 | |
private CourseRegistrationService courseRegService; |
| 28 | |
|
| 29 | |
public GradingService getGradingService() { |
| 30 | 0 | return gradingService; |
| 31 | |
} |
| 32 | |
|
| 33 | |
public void setGradingService(GradingService gradingService) { |
| 34 | 0 | this.gradingService = gradingService; |
| 35 | 0 | } |
| 36 | |
|
| 37 | |
public LRCService getLrcService() { |
| 38 | 0 | return lrcService; |
| 39 | |
} |
| 40 | |
|
| 41 | |
public void setLrcService(LRCService lrcService) { |
| 42 | 0 | this.lrcService = lrcService; |
| 43 | 0 | } |
| 44 | |
|
| 45 | |
private GradingService gradingService; |
| 46 | |
private LRCService lrcService; |
| 47 | |
|
| 48 | |
public AtpService getAtpService() { |
| 49 | 0 | return atpService; |
| 50 | |
} |
| 51 | |
|
| 52 | |
public void setAtpService(AtpService atpService) { |
| 53 | 0 | this.atpService = atpService; |
| 54 | 0 | } |
| 55 | |
|
| 56 | |
private AtpService atpService; |
| 57 | |
private StudentCourseRecordAssembler courseRecordAssembler; |
| 58 | |
|
| 59 | |
public CourseRegistrationService getCourseRegService() { |
| 60 | 0 | return courseRegService; |
| 61 | |
} |
| 62 | |
|
| 63 | |
public void setCourseRegService(CourseRegistrationService courseRegService) { |
| 64 | 0 | this.courseRegService = courseRegService; |
| 65 | 0 | } |
| 66 | |
|
| 67 | |
|
| 68 | |
public StudentCourseRecordAssembler getCourseRecordAssembler() { |
| 69 | 0 | return courseRecordAssembler; |
| 70 | |
} |
| 71 | |
|
| 72 | |
public void setCourseRecordAssembler( |
| 73 | |
StudentCourseRecordAssembler courseRecordAssembler) { |
| 74 | 0 | courseRecordAssembler.setAtpService(atpService); |
| 75 | 0 | courseRecordAssembler.setGradingService(gradingService); |
| 76 | 0 | courseRecordAssembler.setLrcService(lrcService); |
| 77 | 0 | this.courseRecordAssembler = courseRecordAssembler; |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
@Override |
| 81 | |
public List<StudentCourseRecordInfo> getAttemptedCourseRecordsForTerm( |
| 82 | |
String personId, String termId, ContextInfo context) |
| 83 | |
throws DoesNotExistException, InvalidParameterException, |
| 84 | |
MissingParameterException, OperationFailedException { |
| 85 | 0 | List<StudentCourseRecordInfo> courseRecords = new ArrayList<StudentCourseRecordInfo>(); |
| 86 | |
try { |
| 87 | 0 | List<CourseRegistrationInfo> regs = courseRegService.getCourseRegistrationsForStudentByTerm(personId, termId, context); |
| 88 | 0 | if(regs != null && !regs.isEmpty()){ |
| 89 | 0 | for (CourseRegistrationInfo reg : regs ){ |
| 90 | 0 | StudentCourseRecordInfo courseRecord = courseRecordAssembler.assemble(reg, context); |
| 91 | 0 | if (courseRecord != null) courseRecords.add(courseRecord); |
| 92 | 0 | } |
| 93 | |
} |
| 94 | 0 | } catch (PermissionDeniedException e) { |
| 95 | 0 | throw new OperationFailedException(); |
| 96 | 0 | } catch (DisabledIdentifierException e) { |
| 97 | 0 | throw new OperationFailedException(); |
| 98 | 0 | } catch (AssemblyException e) { |
| 99 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 100 | 0 | } |
| 101 | |
|
| 102 | 0 | return courseRecords; |
| 103 | |
} |
| 104 | |
|
| 105 | |
@Override |
| 106 | |
public List<StudentCourseRecordInfo> getCompletedCourseRecords( |
| 107 | |
String personId, ContextInfo context) throws DoesNotExistException, |
| 108 | |
InvalidParameterException, MissingParameterException, |
| 109 | |
OperationFailedException { |
| 110 | 0 | List<StudentCourseRecordInfo> courseRecords = new ArrayList<StudentCourseRecordInfo>(); |
| 111 | |
try { |
| 112 | 0 | List<CourseRegistrationInfo> regs = courseRegService.getCourseRegistrationsForStudent(personId, context); |
| 113 | 0 | getCompletedCourseRecords(courseRecords, regs, context); |
| 114 | 0 | } catch (PermissionDeniedException e) { |
| 115 | 0 | throw new OperationFailedException(); |
| 116 | 0 | } catch (DisabledIdentifierException e) { |
| 117 | 0 | throw new OperationFailedException(); |
| 118 | 0 | } |
| 119 | |
|
| 120 | 0 | return courseRecords; |
| 121 | |
} |
| 122 | |
|
| 123 | |
@Override |
| 124 | |
public List<StudentCourseRecordInfo> getCompletedCourseRecordsForTerm( |
| 125 | |
String personId, String termId, ContextInfo context) |
| 126 | |
throws DoesNotExistException, InvalidParameterException, |
| 127 | |
MissingParameterException, OperationFailedException { |
| 128 | 0 | List<StudentCourseRecordInfo> courseRecords = new ArrayList<StudentCourseRecordInfo>(); |
| 129 | |
try { |
| 130 | 0 | List<CourseRegistrationInfo> regs = courseRegService.getCourseRegistrationsForStudentByTerm(personId, termId, context); |
| 131 | 0 | getCompletedCourseRecords(courseRecords, regs, context); |
| 132 | 0 | } catch (PermissionDeniedException e) { |
| 133 | 0 | throw new OperationFailedException(); |
| 134 | 0 | } catch (DisabledIdentifierException e) { |
| 135 | 0 | throw new OperationFailedException(); |
| 136 | 0 | } |
| 137 | |
|
| 138 | 0 | return courseRecords; |
| 139 | |
} |
| 140 | |
|
| 141 | |
private void getCompletedCourseRecords(List<StudentCourseRecordInfo> courseRecords, List<CourseRegistrationInfo> regs, ContextInfo context) |
| 142 | |
throws OperationFailedException { |
| 143 | 0 | if(regs != null && !regs.isEmpty()){ |
| 144 | 0 | for (CourseRegistrationInfo reg : regs ){ |
| 145 | 0 | StudentCourseRecordInfo courseRecord = null; |
| 146 | |
try { |
| 147 | 0 | courseRecord = courseRecordAssembler.assemble(reg, context); |
| 148 | 0 | } catch (AssemblyException e) { |
| 149 | 0 | throw new OperationFailedException("AssemblyException : " + e.getMessage()); |
| 150 | 0 | } |
| 151 | |
|
| 152 | 0 | if (courseRecord != null) { |
| 153 | 0 | if(courseRecord.getAssignedGradeValue()!= null || courseRecord.getAdministrativeGradeValue() != null) |
| 154 | 0 | courseRecords.add(courseRecord); |
| 155 | |
} |
| 156 | 0 | } |
| 157 | |
} |
| 158 | 0 | } |
| 159 | |
|
| 160 | |
@Override |
| 161 | |
public GPAInfo getGPAForTerm(String personId, String termId, |
| 162 | |
String calculationTypeKey, ContextInfo context) |
| 163 | |
throws DoesNotExistException, InvalidParameterException, |
| 164 | |
MissingParameterException, OperationFailedException { |
| 165 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 166 | |
} |
| 167 | |
|
| 168 | |
@Override |
| 169 | |
public GPAInfo getGPAForAcademicCalendar(String personId, |
| 170 | |
String academicCalendarKey, String calculationTypeKey, |
| 171 | |
ContextInfo context) throws DoesNotExistException, |
| 172 | |
InvalidParameterException, MissingParameterException, |
| 173 | |
OperationFailedException { |
| 174 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 175 | |
} |
| 176 | |
|
| 177 | |
@Override |
| 178 | |
public GPAInfo getCumulativeGPA(String personId, String calculationTypeKey, |
| 179 | |
ContextInfo context) throws DoesNotExistException, |
| 180 | |
InvalidParameterException, MissingParameterException, |
| 181 | |
OperationFailedException { |
| 182 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 183 | |
} |
| 184 | |
|
| 185 | |
@Override |
| 186 | |
public String getEarnedCreditsForTerm(String personId, String termId, |
| 187 | |
String calculationTypeKey, ContextInfo context) |
| 188 | |
throws DoesNotExistException, InvalidParameterException, |
| 189 | |
MissingParameterException, OperationFailedException { |
| 190 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 191 | |
} |
| 192 | |
|
| 193 | |
@Override |
| 194 | |
public String getEarnedCreditsForAcademicCalendar(String personId, |
| 195 | |
String academicCalendarKey, String calculationTypeKey, |
| 196 | |
ContextInfo context) throws DoesNotExistException, |
| 197 | |
InvalidParameterException, MissingParameterException, |
| 198 | |
OperationFailedException { |
| 199 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 200 | |
} |
| 201 | |
|
| 202 | |
@Override |
| 203 | |
public String getEarnedCredits(String personId, String calculationTypeKey, |
| 204 | |
ContextInfo context) throws DoesNotExistException, |
| 205 | |
InvalidParameterException, MissingParameterException, |
| 206 | |
OperationFailedException { |
| 207 | 0 | throw new UnsupportedOperationException("Method not yet implemented!"); |
| 208 | |
} |
| 209 | |
|
| 210 | |
} |