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.Map; |
20 | |
import java.util.Set; |
21 | |
|
22 | |
import org.kuali.rice.krms.api.engine.TermResolutionException; |
23 | |
import org.kuali.rice.krms.api.engine.TermResolver; |
24 | |
import org.kuali.student.common.util.krms.RulesExecutionConstants; |
25 | |
import org.kuali.student.r2.common.dto.ContextInfo; |
26 | |
import org.kuali.student.r2.common.exceptions.DoesNotExistException; |
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 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public class MilestoneResolver implements TermResolver<MilestoneInfo> { |
42 | |
private AtpService atpService; |
43 | |
|
44 | |
@Override |
45 | |
public Set<String> getPrerequisites() { |
46 | 0 | return Collections.singleton(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME); |
47 | |
} |
48 | |
|
49 | |
@Override |
50 | |
public String getOutput() { |
51 | 0 | return RulesExecutionConstants.MILESTONE_TERM_NAME; |
52 | |
} |
53 | |
|
54 | |
@Override |
55 | |
public Set<String> getParameterNames() { |
56 | 0 | return Collections.singleton(RulesExecutionConstants.MILESTONE_ID_TERM_PROPERTY); |
57 | |
} |
58 | |
|
59 | |
@Override |
60 | |
public int getCost() { |
61 | |
|
62 | 0 | return 0; |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public MilestoneInfo resolve(Map<String, Object> resolvedPrereqs, Map<String, String> parameters) throws TermResolutionException { |
67 | |
|
68 | 0 | String milestoneId = parameters.get(RulesExecutionConstants.MILESTONE_ID_TERM_PROPERTY); |
69 | 0 | ContextInfo context = (ContextInfo) resolvedPrereqs.get(RulesExecutionConstants.CONTEXT_INFO_TERM_NAME); |
70 | |
|
71 | 0 | MilestoneInfo result = null; |
72 | |
try { |
73 | 0 | result = atpService.getMilestone(milestoneId, context); |
74 | 0 | } catch (DoesNotExistException e) { |
75 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
76 | 0 | } catch (InvalidParameterException e) { |
77 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
78 | 0 | } catch (MissingParameterException e) { |
79 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
80 | 0 | } catch (OperationFailedException e) { |
81 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
82 | 0 | } catch (PermissionDeniedException e) { |
83 | 0 | throw new TermResolutionException(e.getMessage(), this, parameters); |
84 | 0 | } |
85 | |
|
86 | 0 | return result; |
87 | |
} |
88 | |
} |