1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.krms.termresolver;
17
18 import org.kuali.rice.krms.api.engine.TermResolutionException;
19 import org.kuali.rice.krms.api.engine.TermResolver;
20 import org.kuali.student.common.util.krms.RulesExecutionConstants;
21 import org.kuali.student.enrollment.academicrecord.dto.GPAInfo;
22 import org.kuali.student.enrollment.academicrecord.dto.StudentCourseRecordInfo;
23 import org.kuali.student.enrollment.academicrecord.service.AcademicRecordService;
24 import org.kuali.student.krms.util.KSKRMSExecutionConstants;
25 import org.kuali.student.krms.util.KSKRMSExecutionUtil;
26 import org.kuali.student.r2.common.dto.ContextInfo;
27 import org.kuali.student.r2.common.exceptions.InvalidParameterException;
28 import org.kuali.student.r2.common.exceptions.MissingParameterException;
29 import org.kuali.student.r2.common.exceptions.OperationFailedException;
30 import org.kuali.student.r2.common.exceptions.PermissionDeniedException;
31 import org.kuali.student.r2.core.atp.dto.MilestoneInfo;
32 import org.kuali.student.r2.core.atp.service.AtpService;
33
34 import java.util.Calendar;
35 import java.util.Collections;
36 import java.util.Date;
37 import java.util.HashSet;
38 import java.util.List;
39 import java.util.Map;
40 import java.util.Set;
41
42 public class GPATermResolver implements TermResolver<GPAInfo> {
43
44 private AcademicRecordService academicRecordService;
45
46
47 public AcademicRecordService getAcademicRecordService() {
48 return academicRecordService;
49 }
50
51 public void setAcademicRecordService(AcademicRecordService academicRecordService) {
52 this.academicRecordService = academicRecordService;
53 }
54
55 @Override
56 public Set<String> getPrerequisites() {
57 return Collections.singleton(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
58 }
59
60 @Override
61 public String getOutput() {
62 return "GPATermResolver.getOutput()";
63 }
64
65 @Override
66 public Set<String> getParameterNames() {
67 Set<String> temp = new HashSet<String>(1);
68 temp.add(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
69 temp.add(KSKRMSExecutionConstants.CALC_TYPE_KEY_TERM_PROPERTY);
70 return Collections.unmodifiableSet(temp);
71 }
72
73 @Override
74 public int getCost() {
75
76 return 5;
77 }
78
79 @Override
80 public GPAInfo resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
81 ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
82 String personId = parameters.get(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
83 String calculationTypeKey = parameters.get(KSKRMSExecutionConstants.CALC_TYPE_KEY_TERM_PROPERTY);
84
85 GPAInfo result = null;
86 try {
87 result = academicRecordService.getCumulativeGPA(personId, calculationTypeKey, context);
88 } catch (Exception e) {
89 KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
90 }
91 return result;
92 }
93 }