1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package edu.sampleu.travel.workflow;
17
18 import java.util.ArrayList;
19 import java.util.HashMap;
20 import java.util.List;
21 import java.util.Map;
22
23 import org.kuali.rice.core.api.uif.AttributeError;
24 import org.kuali.rice.core.api.uif.RemotableAttributeError;
25 import org.kuali.rice.kew.rule.GenericWorkflowAttribute;
26 import org.kuali.rice.kns.web.ui.Field;
27 import org.kuali.rice.kns.web.ui.Row;
28
29 public class DestinationRuleAttribute extends GenericWorkflowAttribute {
30
31 private static final String DEST_LABEL = "Destination";
32 private static final String DEST_FIELD_KEY = "destination";
33
34 private final List<Row> rows = new ArrayList<Row>();
35
36 private String destination;
37
38 public DestinationRuleAttribute() {
39 super("destination");
40 }
41
42 public DestinationRuleAttribute(String destination) {
43 super("destination");
44 this.destination = destination;
45 }
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79 public List<Row> getRuleRows() {
80 return getRows();
81 }
82
83 public List<Row> getRoutingDataRows() {
84 return getRows();
85 }
86
87 private List<Row> getRows() {
88 log.info("Returning rows: " + rows);
89 List<Field> fields = new ArrayList<Field>();
90 fields.add(new Field(DEST_LABEL, "", Field.TEXT, false, DEST_FIELD_KEY, "", false, false, null, null));
91 List<Row> rows = new ArrayList<Row>();
92 rows.add(new Row(fields));
93 return rows;
94 }
95
96
97 public void setDestination(String destination) {
98 this.destination = destination;
99 }
100
101 public Map<String, String> getProperties() {
102 Map<String, String> props = new HashMap<String, String>();
103 props.put("destination", destination);
104 return props;
105 }
106
107 public List<? extends AttributeError> validateRoutingData(Map paramMap) {
108 return validateInputMap(paramMap);
109 }
110
111 public List<? extends AttributeError> validateRuleData(Map paramMap) {
112 return validateInputMap(paramMap);
113 }
114
115 private List<? extends AttributeError> validateInputMap(Map paramMap) {
116 List errors = new ArrayList();
117 this.destination = (String) paramMap.get(DEST_FIELD_KEY);
118 if (this.destination == null && required) {
119 errors.add(RemotableAttributeError.Builder.create(DEST_FIELD_KEY, "Destination is required.").build());
120 }
121 return errors;
122 }
123 }