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