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.AbstractDataTransferObject;
32 import org.kuali.rice.core.api.mo.ModelBuilder;
33 import org.kuali.rice.kew.api.KewApiConstants;
34 import org.kuali.rice.kew.api.actionlist.DisplayParameters;
35 import org.w3c.dom.Element;
36
37
38
39
40
41
42
43 @XmlRootElement(name = ActionSet.Constants.ROOT_ELEMENT_NAME)
44 @XmlAccessorType(XmlAccessType.NONE)
45 @XmlType(name = ActionSet.Constants.TYPE_NAME, propOrder = {
46 ActionSet.Elements.ACTION_SET_LIST,
47 CoreConstants.CommonElements.FUTURE_ELEMENTS
48 })
49 public final class ActionSet extends AbstractDataTransferObject implements ActionSetContract {
50
51 private static final long serialVersionUID = 7857749268529671300L;
52
53 @XmlElement(name = Elements.ACTION_SET_LIST, required = false)
54 private List<String> actionSetList;
55
56 @SuppressWarnings("unused")
57 @XmlAnyElement
58 private final Collection<Element> _futureElements = null;
59
60
61
62
63
64 private ActionSet() {
65 this.actionSetList = null;
66 }
67
68
69
70
71
72
73
74 private ActionSet(Builder builder) {
75 this.actionSetList = builder.getActionSet();
76 }
77
78 @Override
79 public boolean hasAction(String actionCode) {
80 return actionSetList != null && actionSetList.contains(actionCode);
81 }
82
83
84
85
86
87
88
89
90 @Override
91 @Deprecated public boolean addAction(String actionCode) {
92 if (!actionSetList.contains(actionCode)) {
93 actionSetList.add(actionCode);
94 return true;
95 }
96 return false;
97 }
98
99
100
101
102
103
104
105
106 @Override
107 @Deprecated public boolean removeAction(String actionCode) {
108 return actionSetList.remove(actionCode);
109 }
110
111
112 @Override
113 public boolean hasApprove() {
114 return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
115 }
116
117 @Override
118 public boolean hasComplete() {
119 return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
120 }
121
122 @Override
123 public boolean hasAcknowledge() {
124 return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
125 }
126
127 @Override
128 public boolean hasFyi() {
129 return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
130 }
131
132 @Override
133 public boolean hasDisapprove() {
134 return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
135 }
136
137 @Override
138 public boolean hasCancel() {
139 return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
140 }
141
142 @Override
143 public boolean hasRouted() {
144 return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
145 }
146
147
148
149
150
151
152
153 @Override
154 @Deprecated public boolean addApprove() {
155 return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
156 }
157
158
159
160
161
162
163
164 @Override
165 @Deprecated public boolean addComplete() {
166 return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
167 }
168
169
170
171
172
173
174
175 @Override
176 @Deprecated public boolean addAcknowledge() {
177 return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
178 }
179
180
181
182
183
184
185
186 @Override
187 @Deprecated public boolean addFyi() {
188 return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
189 }
190
191
192
193
194
195
196
197 @Override
198 @Deprecated public boolean addDisapprove() {
199 return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
200 }
201
202
203
204
205
206
207
208 @Override
209 @Deprecated public boolean addCancel() {
210 return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
211 }
212
213
214
215
216
217
218
219 @Override
220 @Deprecated public boolean addRouted() {
221 return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
222 }
223
224
225
226
227 public final static class Builder implements Serializable, ModelBuilder, ActionSetContract {
228
229 private List<String> actionSet;
230
231
232
233
234 private Builder(List<String> actionSet) {
235 setActionSetList(actionSet);
236 }
237
238 public static Builder create() {
239 return new Builder(new ArrayList<String>());
240 }
241
242
243
244
245
246
247
248 public static Builder create(ActionSetContract contract) {
249 if (contract == null) {
250 throw new IllegalArgumentException("contract was null");
251 }
252 Builder builder = create();
253 return builder;
254 }
255
256 public ActionSet build() {
257 return new ActionSet(this);
258 }
259 public List<String> getActionSet() {
260 return this.actionSet;
261 }
262 public void setActionSetList(List<String> actionSet) {
263 this.actionSet = actionSet;
264 }
265
266 @Override
267 public boolean hasAction(String actionCode) {
268 return actionSet.contains(actionCode);
269 }
270
271 @Override
272 public boolean addAction(String actionCode) {
273 if (!actionSet.contains(actionCode)) {
274 actionSet.add(actionCode);
275 return true;
276 }
277 return false;
278 }
279
280 @Override
281 public boolean removeAction(String actionCode) {
282 return actionSet.remove(actionCode);
283 }
284
285 @Override
286 public boolean hasApprove() {
287 return hasAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
288 }
289
290 @Override
291 public boolean hasComplete() {
292 return hasAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
293 }
294
295 @Override
296 public boolean hasAcknowledge() {
297 return hasAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
298 }
299
300 @Override
301 public boolean hasFyi() {
302 return hasAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
303 }
304
305 @Override
306 public boolean hasDisapprove() {
307 return hasAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
308 }
309
310 @Override
311 public boolean hasCancel() {
312 return hasAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
313 }
314
315 @Override
316 public boolean hasRouted() {
317 return hasAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
318 }
319
320 @Override
321 public boolean addApprove() {
322 return addAction(KewApiConstants.ACTION_TAKEN_APPROVED_CD);
323 }
324
325 @Override
326 public boolean addComplete() {
327 return addAction(KewApiConstants.ACTION_TAKEN_COMPLETED_CD);
328 }
329
330
331
332
333
334
335 @Override
336 public boolean addAcknowledge() {
337 return addAction(KewApiConstants.ACTION_TAKEN_ACKNOWLEDGED_CD);
338 }
339
340 @Override
341 public boolean addFyi() {
342 return addAction(KewApiConstants.ACTION_TAKEN_FYI_CD);
343 }
344
345 @Override
346 public boolean addDisapprove() {
347 return addAction(KewApiConstants.ACTION_TAKEN_DENIED_CD);
348 }
349
350 @Override
351 public boolean addCancel() {
352 return addAction(KewApiConstants.ACTION_TAKEN_CANCELED_CD);
353 }
354
355 @Override
356 public boolean addRouted() {
357 return addAction(KewApiConstants.ACTION_TAKEN_ROUTED_CD);
358 }
359 }
360
361
362
363
364
365 static class Constants {
366
367 final static String ROOT_ELEMENT_NAME = "actionSet";
368 final static String TYPE_NAME = "ActionSetType";
369 }
370
371
372
373
374
375 static class Elements {
376
377 final static String ACTION_SET_LIST = "actionSetList";
378 }
379 }