1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.api.action;
17
18 import java.io.Serializable;
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.List;
22
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAnyElement;
26 import javax.xml.bind.annotation.XmlElement;
27 import javax.xml.bind.annotation.XmlRootElement;
28 import javax.xml.bind.annotation.XmlType;
29
30 import org.kuali.rice.core.api.CoreConstants;
31 import org.kuali.rice.core.api.mo.ModelBuilder;
32 import org.kuali.rice.kew.api.KewApiConstants;
33 import org.kuali.rice.kew.api.actionlist.DisplayParameters;
34 import org.w3c.dom.Element;
35
36
37
38
39
40
41
42 @XmlRootElement(name = ActionSet.Constants.ROOT_ELEMENT_NAME)
43 @XmlAccessorType(XmlAccessType.NONE)
44 @XmlType(name = ActionSet.Constants.TYPE_NAME, propOrder = {
45 ActionSet.Elements.ACTION_SET_LIST,
46 CoreConstants.CommonElements.FUTURE_ELEMENTS
47 })
48 public final class ActionSet implements Serializable, ActionSetContract {
49
50 private static final long serialVersionUID = 7857749268529671300L;
51
52 @XmlElement(name = Elements.ACTION_SET_LIST, required = false)
53 private List<String> actionSetList;
54
55 @SuppressWarnings("unused")
56 @XmlAnyElement
57 private final Collection<Element> _futureElements = null;
58
59
60
61
62
63 private ActionSet() {
64 this.actionSetList = null;
65 }
66
67
68
69
70
71
72
73 private ActionSet(Builder builder) {
74 this.actionSetList = builder.getActionSet();
75 }
76
77 @Override
78 public boolean hasAction(String actionCode) {
79 return actionSetList != null && actionSetList.contains(actionCode);
80 }
81
82 @Override
83 public boolean addAction(String actionCode) {
84 if (!actionSetList.contains(actionCode)) {
85 actionSetList.add(actionCode);
86 return true;
87 }
88 return false;
89 }
90
91 @Override
92 public boolean removeAction(String actionCode) {
93 return actionSetList.remove(actionCode);
94 }
95
96
97 @Override
98 public boolean hasApprove() {
99 return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
100 }
101
102 @Override
103 public boolean hasComplete() {
104 return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
105 }
106
107 @Override
108 public boolean hasAcknowledge() {
109 return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
110 }
111
112 @Override
113 public boolean hasFyi() {
114 return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
115 }
116
117 @Override
118 public boolean hasDisapprove() {
119 return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
120 }
121
122 @Override
123 public boolean hasCancel() {
124 return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
125 }
126
127 @Override
128 public boolean hasRouted() {
129 return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
130 }
131
132 @Override
133 public boolean addApprove() {
134 return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
135 }
136
137 @Override
138 public boolean addComplete() {
139 return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
140 }
141
142 @Override
143 public boolean addAcknowledge() {
144 return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
145 }
146
147 @Override
148 public boolean addFyi() {
149 return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
150 }
151
152 @Override
153 public boolean addDisapprove() {
154 return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
155 }
156
157 @Override
158 public boolean addCancel() {
159 return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
160 }
161
162 @Override
163 public boolean addRouted() {
164 return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
165 }
166
167
168
169
170 public final static class Builder implements Serializable, ModelBuilder, ActionSetContract {
171
172 private List<String> actionSet;
173
174
175
176
177 private Builder(List<String> actionSet) {
178 setActionSetList(actionSet);
179 }
180
181 public static Builder create() {
182 return new Builder(new ArrayList<String>());
183 }
184
185
186
187
188
189
190
191 public static Builder create(ActionSetContract contract) {
192 if (contract == null) {
193 throw new IllegalArgumentException("contract was null");
194 }
195 Builder builder = create();
196 return builder;
197 }
198
199 public ActionSet build() {
200 return new ActionSet(this);
201 }
202 public List<String> getActionSet() {
203 return this.actionSet;
204 }
205 public void setActionSetList(List<String> actionSet) {
206 this.actionSet = actionSet;
207 }
208
209 @Override
210 public boolean hasAction(String actionCode) {
211 return actionSet.contains(actionCode);
212 }
213
214 @Override
215 public boolean addAction(String actionCode) {
216 if (!actionSet.contains(actionCode)) {
217 actionSet.add(actionCode);
218 return true;
219 }
220 return false;
221 }
222
223 @Override
224 public boolean removeAction(String actionCode) {
225 return actionSet.remove(actionCode);
226 }
227
228 @Override
229 public boolean hasApprove() {
230 return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
231 }
232
233 @Override
234 public boolean hasComplete() {
235 return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
236 }
237
238 @Override
239 public boolean hasAcknowledge() {
240 return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
241 }
242
243 @Override
244 public boolean hasFyi() {
245 return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
246 }
247
248 @Override
249 public boolean hasDisapprove() {
250 return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
251 }
252
253 @Override
254 public boolean hasCancel() {
255 return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
256 }
257
258 @Override
259 public boolean hasRouted() {
260 return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
261 }
262
263 @Override
264 public boolean addApprove() {
265 return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
266 }
267
268 @Override
269 public boolean addComplete() {
270 return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
271 }
272
273
274
275
276
277
278 @Override
279 public boolean addAcknowledge() {
280 return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
281 }
282
283 @Override
284 public boolean addFyi() {
285 return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
286 }
287
288 @Override
289 public boolean addDisapprove() {
290 return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
291 }
292
293 @Override
294 public boolean addCancel() {
295 return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
296 }
297
298 @Override
299 public boolean addRouted() {
300 return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
301 }
302 }
303
304
305
306
307
308 static class Constants {
309
310 final static String ROOT_ELEMENT_NAME = "actionSet";
311 final static String TYPE_NAME = "ActionSetType";
312 }
313
314
315
316
317
318 static class Elements {
319
320 final static String ACTION_SET_LIST = "actionSetList";
321 }
322 }