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.kew.rule.GenericWorkflowAttribute;
24 import org.kuali.rice.kew.rule.WorkflowAttributeValidationError;
25 import org.kuali.rice.kns.web.ui.Field;
26 import org.kuali.rice.kns.web.ui.Row;
27
28 public class DestinationRuleAttribute extends GenericWorkflowAttribute {
29
30 private static final String DEST_LABEL = "Destination";
31 private static final String DEST_FIELD_KEY = "destination";
32
33 private final List<Row> rows = new ArrayList<Row>();
34
35 private String destination;
36
37 public DestinationRuleAttribute() {
38 super("destination");
39 }
40
41 public DestinationRuleAttribute(String destination) {
42 super("destination");
43 this.destination = destination;
44 }
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 public List<Row> getRuleRows() {
79 return getRows();
80 }
81
82 public List<Row> getRoutingDataRows() {
83 return getRows();
84 }
85
86 private List<Row> getRows() {
87 log.info("Returning rows: " + rows);
88 List<Field> fields = new ArrayList<Field>();
89 fields.add(new Field(DEST_LABEL, "", Field.TEXT, false, DEST_FIELD_KEY, "", false, false, null, null));
90 List<Row> rows = new ArrayList<Row>();
91 rows.add(new Row(fields));
92 return rows;
93 }
94
95
96 public void setDestination(String destination) {
97 this.destination = destination;
98 }
99
100 public Map<String, String> getProperties() {
101 Map<String, String> props = new HashMap<String, String>();
102 props.put("destination", destination);
103 return props;
104 }
105
106 public List validateRoutingData(Map paramMap) {
107 return validateInputMap(paramMap);
108 }
109
110 public List validateRuleData(Map paramMap) {
111 return validateInputMap(paramMap);
112 }
113
114 private List validateInputMap(Map paramMap) {
115 List errors = new ArrayList();
116 this.destination = (String) paramMap.get(DEST_FIELD_KEY);
117 if (this.destination == null && required) {
118 errors.add(new WorkflowAttributeValidationError(DEST_FIELD_KEY, "Destination is required."));
119 }
120 return errors;
121 }
122 }