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
27
28 public class ValidationAction implements Action {
29
30
31 private final ValidationActionType type;
32 private final String message;
33
34
35
36
37
38
39 public ValidationAction(ValidationActionType type, String message) {
40 if (type == null) throw new IllegalArgumentException("type must not be null");
41
42 this.type = type;
43 this.message = message;
44 }
45
46 @Override
47 public void execute(ExecutionEnvironment environment) {
48
49
50
51 Object value = environment.getEngineResults().getAttribute(ValidationActionTypeService.VALIDATIONS_ACTION_ATTRIBUTE);
52 StringBuilder selectedAttributesStringBuilder = new StringBuilder();
53
54 if (value != null) {
55
56 selectedAttributesStringBuilder.append(value.toString());
57
58 selectedAttributesStringBuilder.append(",");
59 }
60
61
62 selectedAttributesStringBuilder.append(type.getCode());
63 selectedAttributesStringBuilder.append(":");
64 selectedAttributesStringBuilder.append(message);
65
66
67 environment.getEngineResults().setAttribute(ValidationActionTypeService.VALIDATIONS_ACTION_ATTRIBUTE,
68 selectedAttributesStringBuilder.toString()
69 );
70 }
71
72 @Override
73 public void executeSimulation(ExecutionEnvironment environment) {
74
75 execute(environment);
76 }
77 }