1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.enrollment.class2.courseoffering.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.r2.common.krms.util.KSKRMSExecutionUtil;
21 import org.kuali.student.r2.core.constants.KSKRMSServiceConstants;
22
23 import java.util.Collections;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28
29
30
31
32
33
34
35
36
37
38 public class CompletedCoursesTermResolver implements TermResolver<Boolean> {
39
40 private TermResolver<List<String>> cluIdsInCluSetTermResolver;
41 private TermResolver<Boolean> completedCourseTermResolver;
42
43 @Override
44 public Set<String> getPrerequisites() {
45 Set<String> prereqs = new HashSet<String>(2);
46 prereqs.add(KSKRMSServiceConstants.TERM_PREREQUISITE_PERSON_ID);
47 prereqs.add(KSKRMSServiceConstants.TERM_PREREQUISITE_CONTEXTINFO);
48 return Collections.unmodifiableSet(prereqs);
49 }
50
51 @Override
52 public String getOutput() {
53 return KSKRMSServiceConstants.TERM_RESOLVER_COMPLETEDCOURSES;
54 }
55
56 @Override
57 public Set<String> getParameterNames() {
58 return Collections.singleton(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_CLUSET_KEY);
59 }
60
61 @Override
62 public int getCost() {
63 return 5;
64 }
65
66 @Override
67 public Boolean resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException {
68 try {
69
70 List<String> versionIndIds = this.getCluIdsInCluSetTermResolver().resolve(resolvedPrereqs, parameters);
71 for(String versionIndId : versionIndIds){
72 parameters.put(KSKRMSServiceConstants.TERM_PARAMETER_TYPE_CLU_KEY, versionIndId);
73 if(!this.getCompletedCourseTermResolver().resolve(resolvedPrereqs, parameters)){
74 return false;
75 }
76 }
77 } catch (Exception e) {
78 KSKRMSExecutionUtil.convertExceptionsToTermResolutionException(parameters, e, this);
79 }
80
81 return true;
82 }
83
84 public TermResolver<List<String>> getCluIdsInCluSetTermResolver() {
85 return cluIdsInCluSetTermResolver;
86 }
87
88 public void setCluIdsInCluSetTermResolver(TermResolver<List<String>> cluIdsInCluSetTermResolver) {
89 this.cluIdsInCluSetTermResolver = cluIdsInCluSetTermResolver;
90 }
91
92 public TermResolver<Boolean> getCompletedCourseTermResolver() {
93 return completedCourseTermResolver;
94 }
95
96 public void setCompletedCourseTermResolver(TermResolver<Boolean> completedCourseTermResolver) {
97 this.completedCourseTermResolver = completedCourseTermResolver;
98 }
99 }