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