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.StudentCourseRecordInfo;
22 import org.kuali.student.enrollment.courseregistration.dto.CourseRegistrationInfo;
23 import org.kuali.student.enrollment.courseregistration.service.CourseRegistrationService;
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 EnrolledCourseCodeTermResolver implements TermResolver<List<CourseRegistrationInfo>> {
43
44 private CourseRegistrationService courseRegistrationService;
45
46
47 public CourseRegistrationService getAcademicRecordService() {
48 return courseRegistrationService;
49 }
50
51 public void setCourseRegistrationService(CourseRegistrationService courseRegistrationService) {
52 this.courseRegistrationService = courseRegistrationService;
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 "EnrolledCourseCodeTermResolver.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 return Collections.unmodifiableSet(temp);
70 }
71
72 @Override
73 public int getCost() {
74
75 return 5;
76 }
77
78 @Override
79 public List<CourseRegistrationInfo> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
80 ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME);
81 String personId = parameters.get(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
82 String termId = parameters.get(KSKRMSExecutionConstants.TERM_ID_TERM_PROPERTY);
83
84 List<CourseRegistrationInfo> result = null;
85 try {
86 result = courseRegistrationService.getCourseRegistrationsByStudentAndTerm(personId, termId, context);
87 } catch (Exception e) {
88 KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
89 }
90 return result;
91 }
92 }