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.Collection;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlAnyElement;
23 import javax.xml.bind.annotation.XmlElement;
24 import javax.xml.bind.annotation.XmlRootElement;
25 import javax.xml.bind.annotation.XmlType;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.joda.time.DateTime;
29 import org.kuali.rice.core.api.CoreConstants;
30 import org.kuali.rice.core.api.delegation.DelegationType;
31 import org.kuali.rice.core.api.mo.AbstractDataTransferObject;
32 import org.kuali.rice.core.api.mo.ModelBuilder;
33 import org.w3c.dom.Element;
34
35 @XmlRootElement(name = ActionItem.Constants.ROOT_ELEMENT_NAME)
36 @XmlAccessorType(XmlAccessType.NONE)
37 @XmlType(name = ActionItem.Constants.TYPE_NAME, propOrder = {
38 ActionItem.Elements.ID,
39 ActionItem.Elements.DATE_TIME_ASSIGNED,
40 ActionItem.Elements.ACTION_REQUEST_CD,
41 ActionItem.Elements.ACTION_REQUEST_ID,
42 ActionItem.Elements.DOCUMENT_ID,
43 ActionItem.Elements.DOC_TITLE,
44 ActionItem.Elements.DOC_LABEL,
45 ActionItem.Elements.DOC_HANDLER_U_R_L,
46 ActionItem.Elements.DOC_NAME,
47 ActionItem.Elements.RESPONSIBILITY_ID,
48 ActionItem.Elements.ROLE_NAME,
49 ActionItem.Elements.DATE_ASSIGNED_STRING,
50 ActionItem.Elements.ACTION_TO_TAKE,
51 ActionItem.Elements.DELEGATION_TYPE,
52 ActionItem.Elements.ACTION_ITEM_INDEX,
53 ActionItem.Elements.GROUP_ID,
54 ActionItem.Elements.PRINCIPAL_ID,
55 ActionItem.Elements.DELEGATOR_GROUP_ID,
56 ActionItem.Elements.DELEGATOR_PRINCIPAL_ID,
57 CoreConstants.CommonElements.FUTURE_ELEMENTS
58 })
59 public final class ActionItem
60 extends AbstractDataTransferObject
61 implements ActionItemContract
62 {
63
64 @XmlElement(name = Elements.ID, required = false)
65 private final String id;
66 @XmlElement(name = Elements.DATE_TIME_ASSIGNED, required = true)
67 private final DateTime dateTimeAssigned;
68 @XmlElement(name = Elements.ACTION_REQUEST_CD, required = true)
69 private final String actionRequestCd;
70 @XmlElement(name = Elements.ACTION_REQUEST_ID, required = true)
71 private final String actionRequestId;
72 @XmlElement(name = Elements.DOCUMENT_ID, required = true)
73 private final String documentId;
74 @XmlElement(name = Elements.DOC_TITLE, required = false)
75 private final String docTitle;
76 @XmlElement(name = Elements.DOC_LABEL, required = true)
77 private final String docLabel;
78 @XmlElement(name = Elements.DOC_HANDLER_U_R_L, required = true)
79 private final String docHandlerURL;
80 @XmlElement(name = Elements.DOC_NAME, required = true)
81 private final String docName;
82 @XmlElement(name = Elements.RESPONSIBILITY_ID, required = true)
83 private final String responsibilityId;
84 @XmlElement(name = Elements.ROLE_NAME, required = false)
85 private final String roleName;
86 @XmlElement(name = Elements.DATE_ASSIGNED_STRING, required = false)
87 private final String dateAssignedString;
88 @XmlElement(name = Elements.ACTION_TO_TAKE, required = false)
89 private final String actionToTake;
90 @XmlElement(name = Elements.DELEGATION_TYPE, required = false)
91 private final String delegationType;
92 @XmlElement(name = Elements.ACTION_ITEM_INDEX, required = false)
93 private final Integer actionItemIndex;
94 @XmlElement(name = Elements.GROUP_ID, required = false)
95 private final String groupId;
96 @XmlElement(name = Elements.PRINCIPAL_ID, required = true)
97 private final String principalId;
98 @XmlElement(name = Elements.DELEGATOR_GROUP_ID, required = false)
99 private final String delegatorGroupId;
100 @XmlElement(name = Elements.DELEGATOR_PRINCIPAL_ID, required = false)
101 private final String delegatorPrincipalId;
102 @SuppressWarnings("unused")
103 @XmlAnyElement
104 private final Collection<Element> _futureElements = null;
105
106
107
108
109
110 private ActionItem() {
111 this.id = null;
112 this.dateTimeAssigned = null;
113 this.actionRequestCd = null;
114 this.actionRequestId = null;
115 this.documentId = null;
116 this.docTitle = null;
117 this.docLabel = null;
118 this.docHandlerURL = null;
119 this.docName = null;
120 this.responsibilityId = null;
121 this.roleName = null;
122 this.dateAssignedString = null;
123 this.actionToTake = null;
124 this.delegationType = null;
125 this.actionItemIndex = null;
126 this.groupId = null;
127 this.principalId = null;
128 this.delegatorGroupId = null;
129 this.delegatorPrincipalId = null;
130 }
131
132 private ActionItem(Builder builder) {
133 this.id = builder.getId();
134 this.dateTimeAssigned = builder.getDateTimeAssigned();
135 this.actionRequestCd = builder.getActionRequestCd();
136 this.actionRequestId = builder.getActionRequestId();
137 this.documentId = builder.getDocumentId();
138 this.docTitle = builder.getDocTitle();
139 this.docLabel = builder.getDocLabel();
140 this.docHandlerURL = builder.getDocHandlerURL();
141 this.docName = builder.getDocName();
142 this.responsibilityId = builder.getResponsibilityId();
143 this.roleName = builder.getRoleName();
144 this.dateAssignedString = builder.getDateAssignedString();
145 this.actionToTake = builder.getActionToTake();
146 this.delegationType = builder.getDelegationType() != null ? builder.getDelegationType().getCode() : null;
147 this.actionItemIndex = builder.getActionItemIndex();
148 this.groupId = builder.getGroupId();
149 this.principalId = builder.getPrincipalId();
150 this.delegatorGroupId = builder.getDelegatorGroupId();
151 this.delegatorPrincipalId = builder.getDelegatorPrincipalId();
152 }
153
154 @Override
155 public String getId() {
156 return this.id;
157 }
158
159 @Override
160 public DateTime getDateTimeAssigned() {
161 return this.dateTimeAssigned;
162 }
163
164 @Override
165 public String getActionRequestCd() {
166 return this.actionRequestCd;
167 }
168
169 @Override
170 public String getActionRequestId() {
171 return this.actionRequestId;
172 }
173
174 @Override
175 public String getDocumentId() {
176 return this.documentId;
177 }
178
179 @Override
180 public String getDocTitle() {
181 return this.docTitle;
182 }
183
184 @Override
185 public String getDocLabel() {
186 return this.docLabel;
187 }
188
189 @Override
190 public String getDocHandlerURL() {
191 return this.docHandlerURL;
192 }
193
194 @Override
195 public String getDocName() {
196 return this.docName;
197 }
198
199 @Override
200 public String getResponsibilityId() {
201 return this.responsibilityId;
202 }
203
204 @Override
205 public String getRoleName() {
206 return this.roleName;
207 }
208
209 @Override
210 public String getDateAssignedString() {
211 return this.dateAssignedString;
212 }
213
214 @Override
215 public String getActionToTake() {
216 return this.actionToTake;
217 }
218
219 @Override
220 public DelegationType getDelegationType() {
221 return DelegationType.fromCode(this.delegationType);
222 }
223
224 @Override
225 public Integer getActionItemIndex() {
226 return this.actionItemIndex;
227 }
228
229 @Override
230 public String getGroupId() {
231 return this.groupId;
232 }
233
234 @Override
235 public String getPrincipalId() {
236 return this.principalId;
237 }
238
239 @Override
240 public String getDelegatorGroupId() {
241 return this.delegatorGroupId;
242 }
243
244 @Override
245 public String getDelegatorPrincipalId() {
246 return this.delegatorPrincipalId;
247 }
248
249
250
251
252
253
254 public final static class Builder
255 implements Serializable, ModelBuilder, ActionItemContract
256 {
257
258 private String id;
259 private DateTime dateTimeAssigned;
260 private String actionRequestCd;
261 private String actionRequestId;
262 private String documentId;
263 private String docTitle;
264 private String docLabel;
265 private String docHandlerURL;
266 private String docName;
267 private String responsibilityId;
268 private String roleName;
269 private String dateAssignedString;
270 private String actionToTake;
271 private DelegationType delegationType;
272 private Integer actionItemIndex;
273 private String groupId;
274 private String principalId;
275 private String delegatorGroupId;
276 private String delegatorPrincipalId;
277
278 private Builder(String documentId, String actionRequestCd, String actionRequestId,
279 DateTime dateTimeAssigned, String docLabel, String docHanderlURL,
280 String docName, String responsibilityId, String principalId) {
281 setDocumentId(documentId);
282 setActionRequestCd(actionRequestCd);
283 setActionRequestId(actionRequestId);
284 setDateTimeAssigned(dateTimeAssigned);
285 setDocLabel(docLabel);
286 setDocHandlerURL(docHanderlURL);
287 setDocName(docName);
288 setResponsibilityId(responsibilityId);
289 setPrincipalId(principalId);
290 }
291
292 public static Builder create(String documentId, String actionRequestCd, String actionRequestId,
293 DateTime dateTimeAssigned, String docLabel, String docHanderlURL,
294 String docName, String responsibilityId, String principalId) {
295 return new Builder(documentId, actionRequestCd, actionRequestId, dateTimeAssigned, docLabel,
296 docHanderlURL, docName, responsibilityId, principalId);
297 }
298
299 public static Builder create(ActionItemContract contract) {
300 if (contract == null) {
301 throw new IllegalArgumentException("contract was null");
302 }
303 Builder builder = create(contract.getDocumentId(), contract.getActionRequestCd(), contract.getActionRequestId(),
304 contract.getDateTimeAssigned(), contract.getDocLabel(), contract.getDocHandlerURL(), contract.getDocName(),
305 contract.getResponsibilityId(), contract.getPrincipalId());
306 builder.setId(contract.getId());
307 builder.setRoleName(contract.getRoleName());
308 builder.setDocTitle(contract.getDocTitle());
309 builder.setDateAssignedString(contract.getDateAssignedString());
310 builder.setActionToTake(contract.getActionToTake());
311 builder.setDelegationType(contract.getDelegationType());
312 builder.setActionItemIndex(contract.getActionItemIndex());
313 builder.setGroupId(contract.getGroupId());
314 builder.setPrincipalId(contract.getPrincipalId());
315 builder.setDelegatorGroupId(contract.getDelegatorGroupId());
316 builder.setDelegatorPrincipalId(contract.getDelegatorPrincipalId());
317 return builder;
318 }
319
320 public ActionItem build() {
321 return new ActionItem(this);
322 }
323
324 @Override
325 public String getId() {
326 return this.id;
327 }
328
329 @Override
330 public DateTime getDateTimeAssigned() {
331 return this.dateTimeAssigned;
332 }
333
334 @Override
335 public String getActionRequestCd() {
336 return this.actionRequestCd;
337 }
338
339 @Override
340 public String getActionRequestId() {
341 return this.actionRequestId;
342 }
343
344 @Override
345 public String getDocumentId() {
346 return this.documentId;
347 }
348
349 @Override
350 public String getDocTitle() {
351 return this.docTitle;
352 }
353
354 @Override
355 public String getDocLabel() {
356 return this.docLabel;
357 }
358
359 @Override
360 public String getDocHandlerURL() {
361 return this.docHandlerURL;
362 }
363
364 @Override
365 public String getDocName() {
366 return this.docName;
367 }
368
369 @Override
370 public String getResponsibilityId() {
371 return this.responsibilityId;
372 }
373
374 @Override
375 public String getRoleName() {
376 return this.roleName;
377 }
378
379 @Override
380 public String getDateAssignedString() {
381 return this.dateAssignedString;
382 }
383
384 @Override
385 public String getActionToTake() {
386 return this.actionToTake;
387 }
388
389 @Override
390 public DelegationType getDelegationType() {
391 return this.delegationType;
392 }
393
394 @Override
395 public Integer getActionItemIndex() {
396 return this.actionItemIndex;
397 }
398
399 @Override
400 public String getGroupId() {
401 return this.groupId;
402 }
403
404 @Override
405 public String getPrincipalId() {
406 return this.principalId;
407 }
408
409 @Override
410 public String getDelegatorGroupId() {
411 return this.delegatorGroupId;
412 }
413
414 @Override
415 public String getDelegatorPrincipalId() {
416 return this.delegatorPrincipalId;
417 }
418
419 public void setId(String id) {
420 if (StringUtils.isWhitespace(id)) {
421 throw new IllegalArgumentException("id is blank");
422 }
423 this.id = id;
424 }
425
426 public void setDateTimeAssigned(DateTime dateTimeAssigned) {
427 if (dateTimeAssigned == null) {
428 throw new IllegalArgumentException("dateTimeAssigned is null");
429 }
430 this.dateTimeAssigned = dateTimeAssigned;
431 }
432
433 public void setActionRequestCd(String actionRequestCd) {
434 if (StringUtils.isBlank(actionRequestCd)) {
435 throw new IllegalArgumentException("actionRequestCd is blank");
436 }
437 this.actionRequestCd = actionRequestCd;
438 }
439
440 public void setActionRequestId(String actionRequestId) {
441 if (StringUtils.isBlank(actionRequestId)) {
442 throw new IllegalArgumentException("actionRequestId is blank");
443 }
444 this.actionRequestId = actionRequestId;
445 }
446
447 public void setDocumentId(String documentId) {
448 if (StringUtils.isBlank(documentId)) {
449 throw new IllegalArgumentException("documentId is blank");
450 }
451 this.documentId = documentId;
452 }
453
454 public void setDocTitle(String docTitle) {
455 this.docTitle = docTitle;
456 }
457
458 public void setDocLabel(String docLabel) {
459 if (StringUtils.isBlank(docLabel)) {
460 throw new IllegalArgumentException("docLabel is blank");
461 }
462 this.docLabel = docLabel;
463 }
464
465 public void setDocHandlerURL(String docHandlerURL) {
466 if (StringUtils.isBlank(docHandlerURL)) {
467 throw new IllegalArgumentException("docHandlerURL is blank");
468 }
469 this.docHandlerURL = docHandlerURL;
470 }
471
472 public void setDocName(String docName) {
473 if (StringUtils.isBlank(docName)) {
474 throw new IllegalArgumentException("docName is blank");
475 }
476 this.docName = docName;
477 }
478
479 public void setResponsibilityId(String responsibilityId) {
480 if (StringUtils.isBlank(responsibilityId)) {
481 throw new IllegalArgumentException("responsibilityId is blank");
482 }
483 this.responsibilityId = responsibilityId;
484 }
485
486 public void setRoleName(String roleName) {
487 this.roleName = roleName;
488 }
489
490 public void setDateAssignedString(String dateAssignedString) {
491 this.dateAssignedString = dateAssignedString;
492 }
493
494 public void setActionToTake(String actionToTake) {
495 this.actionToTake = actionToTake;
496 }
497
498 public void setDelegationType(DelegationType delegationType) {
499 this.delegationType = delegationType;
500 }
501
502 public void setActionItemIndex(Integer actionItemIndex) {
503 this.actionItemIndex = actionItemIndex;
504 }
505
506 public void setGroupId(String groupId) {
507 this.groupId = groupId;
508 }
509
510 public void setPrincipalId(String principalId) {
511 if (StringUtils.isBlank(principalId)) {
512 throw new IllegalArgumentException("principalId is blank");
513 }
514 this.principalId = principalId;
515 }
516
517 public void setDelegatorGroupId(String delegatorGroupId) {
518 this.delegatorGroupId = delegatorGroupId;
519 }
520
521 public void setDelegatorPrincipalId(String delegatorPrincipalId) {
522 this.delegatorPrincipalId = delegatorPrincipalId;
523 }
524
525 }
526
527
528
529
530
531
532 static class Constants {
533
534 final static String ROOT_ELEMENT_NAME = "actionItem";
535 final static String TYPE_NAME = "ActionItemType";
536
537 }
538
539
540
541
542
543
544 static class Elements {
545
546 final static String ID = "id";
547 final static String DATE_TIME_ASSIGNED = "dateTimeAssigned";
548 final static String ACTION_REQUEST_CD = "actionRequestCd";
549 final static String ACTION_REQUEST_ID = "actionRequestId";
550 final static String DOCUMENT_ID = "documentId";
551 final static String DOC_TITLE = "docTitle";
552 final static String DOC_LABEL = "docLabel";
553 final static String DOC_HANDLER_U_R_L = "docHandlerURL";
554 final static String DOC_NAME = "docName";
555 final static String RESPONSIBILITY_ID = "responsibilityId";
556 final static String ROLE_NAME = "roleName";
557 final static String DATE_ASSIGNED_STRING = "dateAssignedString";
558 final static String ACTION_TO_TAKE = "actionToTake";
559 final static String DELEGATION_TYPE = "delegationType";
560 final static String ACTION_ITEM_INDEX = "actionItemIndex";
561 final static String GROUP_ID = "groupId";
562 final static String PRINCIPAL_ID = "principalId";
563 final static String DELEGATOR_GROUP_ID = "delegatorGroupId";
564 final static String DELEGATOR_PRINCIPAL_ID = "delegatorPrincipalId";
565
566 }
567
568 }