1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.student.r2.core.class1.process.krms.proposition; |
18 | |
|
19 | |
import org.kuali.rice.krms.api.engine.ExecutionEnvironment; |
20 | |
import org.kuali.rice.krms.api.engine.ResultEvent; |
21 | |
import org.kuali.rice.krms.api.engine.Term; |
22 | |
import org.kuali.rice.krms.framework.engine.PropositionResult; |
23 | |
import org.kuali.rice.krms.framework.engine.result.BasicResult; |
24 | |
import org.kuali.student.common.util.krms.RulesExecutionConstants; |
25 | |
import org.kuali.student.common.util.krms.proposition.AbstractLeafProposition; |
26 | |
import org.kuali.student.r2.core.hold.dto.HoldInfo; |
27 | |
|
28 | |
import java.util.ArrayList; |
29 | |
import java.util.Collections; |
30 | |
import java.util.List; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
public class RegistrationHoldProposition extends AbstractLeafProposition { |
39 | |
|
40 | |
private final String issueId; |
41 | |
|
42 | 0 | public RegistrationHoldProposition(String issueId) { |
43 | 0 | this.issueId = issueId; |
44 | 0 | } |
45 | |
|
46 | |
@Override |
47 | |
public PropositionResult evaluate(ExecutionEnvironment environment) { |
48 | |
|
49 | 0 | Term studentRegistrationHoldsTerm = new Term(RulesExecutionConstants.STUDENT_REGISTRATION_HOLDS_TERM_NAME, Collections.singletonMap(RulesExecutionConstants.ISSUE_KEY_TERM_PROPERTY, issueId)); |
50 | 0 | List<HoldInfo> studentRegistrationHolds = environment.resolveTerm(studentRegistrationHoldsTerm, this); |
51 | |
|
52 | 0 | PropositionResult result = null; |
53 | |
|
54 | 0 | if (studentRegistrationHolds.isEmpty()) { |
55 | 0 | result = new PropositionResult(true); |
56 | |
} else { |
57 | 0 | List<HoldInfo> blockingHolds = new ArrayList<HoldInfo>(); |
58 | |
|
59 | |
|
60 | 0 | for (HoldInfo hold : studentRegistrationHolds) { |
61 | 0 | blockingHolds.add(hold); |
62 | |
} |
63 | |
|
64 | |
|
65 | 0 | result = new PropositionResult(blockingHolds.isEmpty()); |
66 | |
} |
67 | |
|
68 | 0 | environment.getEngineResults().addResult(new BasicResult(ResultEvent.PROPOSITION_EVALUATED, this, environment, result.getResult())); |
69 | |
|
70 | 0 | return result; |
71 | |
} |
72 | |
} |