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.Arrays;
35 import java.util.Calendar;
36 import java.util.Collections;
37 import java.util.Date;
38 import java.util.HashSet;
39 import java.util.List;
40 import java.util.Map;
41 import java.util.Set;
42
43 public class EnrolledCourseTermResolver extends EnrolledCoursesTermResolver {
44
45 @Override
46 public String getOutput() {
47 return this.getClass().getSimpleName();
48 }
49
50 @Override
51 public Set<String> getParameterNames() {
52 Set<String> temp = new HashSet<String>(1);
53 temp.add(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
54 temp.add(KSKRMSExecutionConstants.TERM_ID_TERM_PROPERTY);
55
56 return Collections.unmodifiableSet(temp);
57 }
58
59 @Override
60 public int getCost() {
61
62 return 0;
63 }
64
65 @Override
66 public List<CourseRegistrationInfo> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
67
68 List<CourseRegistrationInfo> enrolledCourseRecords = super.resolve(resolvedPrereqs, parameters);
69 String personId = parameters.get(KSKRMSExecutionConstants.PERSON_ID_TERM_PROPERTY);
70
71 for (CourseRegistrationInfo courseRegistrationInfo : enrolledCourseRecords) {
72 if (courseRegistrationInfo.getStudentId().equals(personId)) {
73 return Arrays.asList(courseRegistrationInfo);
74 }
75 }
76
77 return null;
78 }
79 }