1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.student.r2.core.class1.process.krms.termresolver; |
17 | |
|
18 | |
import java.util.Collections; |
19 | |
import java.util.HashSet; |
20 | |
import java.util.List; |
21 | |
import java.util.Map; |
22 | |
import java.util.Set; |
23 | |
|
24 | |
import org.kuali.rice.krms.api.engine.TermResolutionException; |
25 | |
import org.kuali.rice.krms.api.engine.TermResolver; |
26 | |
import org.kuali.student.common.util.krms.RulesExecutionConstants; |
27 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
28 | |
import org.kuali.student.r2.common.exceptions.InvalidParameterException; |
29 | |
import org.kuali.student.r2.common.exceptions.MissingParameterException; |
30 | |
import org.kuali.student.r2.common.exceptions.OperationFailedException; |
31 | |
import org.kuali.student.r2.common.exceptions.PermissionDeniedException; |
32 | |
import org.kuali.student.r2.core.hold.dto.HoldInfo; |
33 | |
import org.kuali.student.r2.core.hold.service.HoldService; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | 0 | public class RegistrationHoldsTermResolver implements TermResolver<List<HoldInfo>> { |
43 | |
|
44 | |
private HoldService holdService; |
45 | |
|
46 | 0 | private final static Set<String> prerequisites = new HashSet<String>(2); |
47 | |
|
48 | |
static { |
49 | 0 | prerequisites.add(RulesExecutionConstants.STUDENT_ID_TERM_NAME); |
50 | 0 | prerequisites.add(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME); |
51 | 0 | } |
52 | |
|
53 | |
public void setHoldService(HoldService holdService) { |
54 | 0 | this.holdService = holdService; |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
public Set<String> getPrerequisites() { |
59 | 0 | return prerequisites; |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
public String getOutput() { |
64 | 0 | return RulesExecutionConstants.STUDENT_REGISTRATION_HOLDS_TERM_NAME; |
65 | |
} |
66 | |
|
67 | |
@Override |
68 | |
public Set<String> getParameterNames() { |
69 | 0 | return Collections.singleton(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY); |
70 | |
} |
71 | |
|
72 | |
@Override |
73 | |
public int getCost() { |
74 | |
|
75 | 0 | return 0; |
76 | |
} |
77 | |
|
78 | |
@Override |
79 | |
public List<HoldInfo> resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException { |
80 | 0 | String studentId = (String) resolvedPrereqs.get(RulesExecutionConstants.STUDENT_ID_TERM_NAME); |
81 | 0 | ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME); |
82 | 0 | String issueId = parameters.get(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY); |
83 | |
|
84 | |
List<HoldInfo> studentHolds; |
85 | |
|
86 | |
|
87 | |
try { |
88 | 0 | studentHolds = holdService.getActiveHoldsByIssueAndPerson(issueId, studentId, context); |
89 | 0 | } catch (InvalidParameterException e) { |
90 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
91 | 0 | } catch (MissingParameterException e) { |
92 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
93 | 0 | } catch (OperationFailedException e) { |
94 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
95 | 0 | } catch (PermissionDeniedException e) { |
96 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
97 | 0 | } |
98 | |
|
99 | 0 | return studentHolds; |
100 | |
} |
101 | |
} |