1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krms.impl.validation; |
17 | |
|
18 | |
import org.kuali.rice.krms.api.engine.ExecutionEnvironment; |
19 | |
import org.kuali.rice.krms.framework.engine.Action; |
20 | |
import org.kuali.rice.krms.framework.type.ValidationActionType; |
21 | |
import org.kuali.rice.krms.framework.type.ValidationActionTypeService; |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
public class ValidationAction implements Action { |
27 | |
|
28 | |
|
29 | |
private final ValidationActionType type; |
30 | |
private final String message; |
31 | |
|
32 | 0 | public ValidationAction(ValidationActionType type, String message) { |
33 | 0 | if (type == null) throw new IllegalArgumentException("type must not be null"); |
34 | |
|
35 | 0 | this.type = type; |
36 | 0 | this.message = message; |
37 | 0 | } |
38 | |
|
39 | |
@Override |
40 | |
public void execute(ExecutionEnvironment environment) { |
41 | |
|
42 | |
|
43 | |
|
44 | 0 | Object value = environment.getEngineResults().getAttribute(ValidationActionTypeService.VALIDATIONS_ACTION_ATTRIBUTE); |
45 | 0 | StringBuilder selectedAttributesStringBuilder = new StringBuilder(); |
46 | |
|
47 | 0 | if (value != null) { |
48 | |
|
49 | 0 | selectedAttributesStringBuilder.append(value.toString()); |
50 | |
|
51 | 0 | selectedAttributesStringBuilder.append(","); |
52 | |
} |
53 | |
|
54 | |
|
55 | 0 | selectedAttributesStringBuilder.append(type.getCode()); |
56 | 0 | selectedAttributesStringBuilder.append(":"); |
57 | 0 | selectedAttributesStringBuilder.append(message); |
58 | |
|
59 | |
|
60 | 0 | environment.getEngineResults().setAttribute(ValidationActionTypeService.VALIDATIONS_ACTION_ATTRIBUTE, |
61 | |
selectedAttributesStringBuilder.toString() |
62 | |
); |
63 | 0 | } |
64 | |
|
65 | |
@Override |
66 | |
public void executeSimulation(ExecutionEnvironment environment) { |
67 | |
|
68 | 0 | execute(environment); |
69 | 0 | } |
70 | |
} |