001 package org.kuali.rice.kew.api.action; 002 003 import java.io.Serializable; 004 import java.util.Collection; 005 import javax.xml.bind.annotation.XmlAccessType; 006 import javax.xml.bind.annotation.XmlAccessorType; 007 import javax.xml.bind.annotation.XmlAnyElement; 008 import javax.xml.bind.annotation.XmlElement; 009 import javax.xml.bind.annotation.XmlRootElement; 010 import javax.xml.bind.annotation.XmlType; 011 012 import org.apache.commons.lang.StringUtils; 013 import org.joda.time.DateTime; 014 import org.kuali.rice.core.api.CoreConstants; 015 import org.kuali.rice.core.api.mo.AbstractDataTransferObject; 016 import org.kuali.rice.core.api.mo.ModelBuilder; 017 import org.w3c.dom.Element; 018 019 @XmlRootElement(name = ActionItem.Constants.ROOT_ELEMENT_NAME) 020 @XmlAccessorType(XmlAccessType.NONE) 021 @XmlType(name = ActionItem.Constants.TYPE_NAME, propOrder = { 022 ActionItem.Elements.ID, 023 ActionItem.Elements.DATE_TIME_ASSIGNED, 024 ActionItem.Elements.ACTION_REQUEST_CD, 025 ActionItem.Elements.ACTION_REQUEST_ID, 026 ActionItem.Elements.DOCUMENT_ID, 027 ActionItem.Elements.DOC_TITLE, 028 ActionItem.Elements.DOC_LABEL, 029 ActionItem.Elements.DOC_HANDLER_U_R_L, 030 ActionItem.Elements.DOC_NAME, 031 ActionItem.Elements.RESPONSIBILITY_ID, 032 ActionItem.Elements.ROLE_NAME, 033 ActionItem.Elements.DATE_ASSIGNED_STRING, 034 ActionItem.Elements.ACTION_TO_TAKE, 035 ActionItem.Elements.DELEGATION_TYPE, 036 ActionItem.Elements.ACTION_ITEM_INDEX, 037 ActionItem.Elements.GROUP_ID, 038 ActionItem.Elements.PRINCIPAL_ID, 039 ActionItem.Elements.DELEGATOR_GROUP_ID, 040 ActionItem.Elements.DELEGATOR_PRINCIPAL_ID, 041 CoreConstants.CommonElements.FUTURE_ELEMENTS 042 }) 043 public final class ActionItem 044 extends AbstractDataTransferObject 045 implements ActionItemContract 046 { 047 048 @XmlElement(name = Elements.ID, required = false) 049 private final String id; 050 @XmlElement(name = Elements.DATE_TIME_ASSIGNED, required = true) 051 private final DateTime dateTimeAssigned; 052 @XmlElement(name = Elements.ACTION_REQUEST_CD, required = true) 053 private final String actionRequestCd; 054 @XmlElement(name = Elements.ACTION_REQUEST_ID, required = true) 055 private final String actionRequestId; 056 @XmlElement(name = Elements.DOCUMENT_ID, required = true) 057 private final String documentId; 058 @XmlElement(name = Elements.DOC_TITLE, required = true) 059 private final String docTitle; 060 @XmlElement(name = Elements.DOC_LABEL, required = true) 061 private final String docLabel; 062 @XmlElement(name = Elements.DOC_HANDLER_U_R_L, required = true) 063 private final String docHandlerURL; 064 @XmlElement(name = Elements.DOC_NAME, required = true) 065 private final String docName; 066 @XmlElement(name = Elements.RESPONSIBILITY_ID, required = true) 067 private final String responsibilityId; 068 @XmlElement(name = Elements.ROLE_NAME, required = false) 069 private final String roleName; 070 @XmlElement(name = Elements.DATE_ASSIGNED_STRING, required = false) 071 private final String dateAssignedString; 072 @XmlElement(name = Elements.ACTION_TO_TAKE, required = false) 073 private final String actionToTake; 074 @XmlElement(name = Elements.DELEGATION_TYPE, required = false) 075 private final String delegationType; 076 @XmlElement(name = Elements.ACTION_ITEM_INDEX, required = false) 077 private final Integer actionItemIndex; 078 @XmlElement(name = Elements.GROUP_ID, required = false) 079 private final String groupId; 080 @XmlElement(name = Elements.PRINCIPAL_ID, required = true) 081 private final String principalId; 082 @XmlElement(name = Elements.DELEGATOR_GROUP_ID, required = false) 083 private final String delegatorGroupId; 084 @XmlElement(name = Elements.DELEGATOR_PRINCIPAL_ID, required = false) 085 private final String delegatorPrincipalId; 086 @SuppressWarnings("unused") 087 @XmlAnyElement 088 private final Collection<Element> _futureElements = null; 089 090 /** 091 * Private constructor used only by JAXB. 092 * 093 */ 094 private ActionItem() { 095 this.id = null; 096 this.dateTimeAssigned = null; 097 this.actionRequestCd = null; 098 this.actionRequestId = null; 099 this.documentId = null; 100 this.docTitle = null; 101 this.docLabel = null; 102 this.docHandlerURL = null; 103 this.docName = null; 104 this.responsibilityId = null; 105 this.roleName = null; 106 this.dateAssignedString = null; 107 this.actionToTake = null; 108 this.delegationType = null; 109 this.actionItemIndex = null; 110 this.groupId = null; 111 this.principalId = null; 112 this.delegatorGroupId = null; 113 this.delegatorPrincipalId = null; 114 } 115 116 private ActionItem(Builder builder) { 117 this.id = builder.getId(); 118 this.dateTimeAssigned = builder.getDateTimeAssigned(); 119 this.actionRequestCd = builder.getActionRequestCd(); 120 this.actionRequestId = builder.getActionRequestId(); 121 this.documentId = builder.getDocumentId(); 122 this.docTitle = builder.getDocTitle(); 123 this.docLabel = builder.getDocLabel(); 124 this.docHandlerURL = builder.getDocHandlerURL(); 125 this.docName = builder.getDocName(); 126 this.responsibilityId = builder.getResponsibilityId(); 127 this.roleName = builder.getRoleName(); 128 this.dateAssignedString = builder.getDateAssignedString(); 129 this.actionToTake = builder.getActionToTake(); 130 this.delegationType = builder.getDelegationType(); 131 this.actionItemIndex = builder.getActionItemIndex(); 132 this.groupId = builder.getGroupId(); 133 this.principalId = builder.getPrincipalId(); 134 this.delegatorGroupId = builder.getDelegatorGroupId(); 135 this.delegatorPrincipalId = builder.getDelegatorPrincipalId(); 136 } 137 138 @Override 139 public String getId() { 140 return this.id; 141 } 142 143 @Override 144 public DateTime getDateTimeAssigned() { 145 return this.dateTimeAssigned; 146 } 147 148 @Override 149 public String getActionRequestCd() { 150 return this.actionRequestCd; 151 } 152 153 @Override 154 public String getActionRequestId() { 155 return this.actionRequestId; 156 } 157 158 @Override 159 public String getDocumentId() { 160 return this.documentId; 161 } 162 163 @Override 164 public String getDocTitle() { 165 return this.docTitle; 166 } 167 168 @Override 169 public String getDocLabel() { 170 return this.docLabel; 171 } 172 173 @Override 174 public String getDocHandlerURL() { 175 return this.docHandlerURL; 176 } 177 178 @Override 179 public String getDocName() { 180 return this.docName; 181 } 182 183 @Override 184 public String getResponsibilityId() { 185 return this.responsibilityId; 186 } 187 188 @Override 189 public String getRoleName() { 190 return this.roleName; 191 } 192 193 @Override 194 public String getDateAssignedString() { 195 return this.dateAssignedString; 196 } 197 198 @Override 199 public String getActionToTake() { 200 return this.actionToTake; 201 } 202 203 @Override 204 public String getDelegationType() { 205 return this.delegationType; 206 } 207 208 @Override 209 public Integer getActionItemIndex() { 210 return this.actionItemIndex; 211 } 212 213 @Override 214 public String getGroupId() { 215 return this.groupId; 216 } 217 218 @Override 219 public String getPrincipalId() { 220 return this.principalId; 221 } 222 223 @Override 224 public String getDelegatorGroupId() { 225 return this.delegatorGroupId; 226 } 227 228 @Override 229 public String getDelegatorPrincipalId() { 230 return this.delegatorPrincipalId; 231 } 232 233 234 /** 235 * A builder which can be used to construct {@link ActionItem} instances. Enforces the constraints of the {@link ActionItemContract}. 236 * 237 */ 238 public final static class Builder 239 implements Serializable, ModelBuilder, ActionItemContract 240 { 241 242 private String id; 243 private DateTime dateTimeAssigned; 244 private String actionRequestCd; 245 private String actionRequestId; 246 private String documentId; 247 private String docTitle; 248 private String docLabel; 249 private String docHandlerURL; 250 private String docName; 251 private String responsibilityId; 252 private String roleName; 253 private String dateAssignedString; 254 private String actionToTake; 255 private String delegationType; 256 private Integer actionItemIndex; 257 private String groupId; 258 private String principalId; 259 private String delegatorGroupId; 260 private String delegatorPrincipalId; 261 262 private Builder(String documentId, String actionRequestCd, String actionRequestId, 263 DateTime dateTimeAssigned, String docLabel, String docHanderlURL, 264 String docName, String responsibilityId, String principalId) { 265 setDocumentId(documentId); 266 setActionRequestCd(actionRequestCd); 267 setActionRequestId(actionRequestId); 268 setDateTimeAssigned(dateTimeAssigned); 269 setDocLabel(docLabel); 270 setDocHandlerURL(docHanderlURL); 271 setDocName(docName); 272 setResponsibilityId(responsibilityId); 273 setPrincipalId(principalId); 274 } 275 276 public static Builder create(String documentId, String actionRequestCd, String actionRequestId, 277 DateTime dateTimeAssigned, String docLabel, String docHanderlURL, 278 String docName, String responsibilityId, String principalId) { 279 return new Builder(documentId, actionRequestCd, actionRequestId, dateTimeAssigned, docLabel, 280 docHanderlURL, docName, responsibilityId, principalId); 281 } 282 283 public static Builder create(ActionItemContract contract) { 284 if (contract == null) { 285 throw new IllegalArgumentException("contract was null"); 286 } 287 Builder builder = create(contract.getDocumentId(), contract.getActionRequestCd(), contract.getActionRequestId(), 288 contract.getDateTimeAssigned(), contract.getDocLabel(), contract.getDocHandlerURL(), contract.getDocName(), 289 contract.getResponsibilityId(), contract.getPrincipalId()); 290 builder.setId(contract.getId()); 291 builder.setRoleName(contract.getRoleName()); 292 builder.setDocTitle(contract.getDocTitle()); 293 builder.setDateAssignedString(contract.getDateAssignedString()); 294 builder.setActionToTake(contract.getActionToTake()); 295 builder.setDelegationType(contract.getDelegationType()); 296 builder.setActionItemIndex(contract.getActionItemIndex()); 297 builder.setGroupId(contract.getGroupId()); 298 builder.setPrincipalId(contract.getPrincipalId()); 299 builder.setDelegatorGroupId(contract.getDelegatorGroupId()); 300 builder.setDelegatorPrincipalId(contract.getDelegatorPrincipalId()); 301 return builder; 302 } 303 304 public ActionItem build() { 305 return new ActionItem(this); 306 } 307 308 @Override 309 public String getId() { 310 return this.id; 311 } 312 313 @Override 314 public DateTime getDateTimeAssigned() { 315 return this.dateTimeAssigned; 316 } 317 318 @Override 319 public String getActionRequestCd() { 320 return this.actionRequestCd; 321 } 322 323 @Override 324 public String getActionRequestId() { 325 return this.actionRequestId; 326 } 327 328 @Override 329 public String getDocumentId() { 330 return this.documentId; 331 } 332 333 @Override 334 public String getDocTitle() { 335 return this.docTitle; 336 } 337 338 @Override 339 public String getDocLabel() { 340 return this.docLabel; 341 } 342 343 @Override 344 public String getDocHandlerURL() { 345 return this.docHandlerURL; 346 } 347 348 @Override 349 public String getDocName() { 350 return this.docName; 351 } 352 353 @Override 354 public String getResponsibilityId() { 355 return this.responsibilityId; 356 } 357 358 @Override 359 public String getRoleName() { 360 return this.roleName; 361 } 362 363 @Override 364 public String getDateAssignedString() { 365 return this.dateAssignedString; 366 } 367 368 @Override 369 public String getActionToTake() { 370 return this.actionToTake; 371 } 372 373 @Override 374 public String getDelegationType() { 375 return this.delegationType; 376 } 377 378 @Override 379 public Integer getActionItemIndex() { 380 return this.actionItemIndex; 381 } 382 383 @Override 384 public String getGroupId() { 385 return this.groupId; 386 } 387 388 @Override 389 public String getPrincipalId() { 390 return this.principalId; 391 } 392 393 @Override 394 public String getDelegatorGroupId() { 395 return this.delegatorGroupId; 396 } 397 398 @Override 399 public String getDelegatorPrincipalId() { 400 return this.delegatorPrincipalId; 401 } 402 403 public void setId(String id) { 404 if (StringUtils.isWhitespace(id)) { 405 throw new IllegalArgumentException("id is blank"); 406 } 407 this.id = id; 408 } 409 410 public void setDateTimeAssigned(DateTime dateTimeAssigned) { 411 if (dateTimeAssigned == null) { 412 throw new IllegalArgumentException("dateTimeAssigned is null"); 413 } 414 this.dateTimeAssigned = dateTimeAssigned; 415 } 416 417 public void setActionRequestCd(String actionRequestCd) { 418 if (StringUtils.isBlank(actionRequestCd)) { 419 throw new IllegalArgumentException("actionRequestCd is blank"); 420 } 421 this.actionRequestCd = actionRequestCd; 422 } 423 424 public void setActionRequestId(String actionRequestId) { 425 if (StringUtils.isBlank(actionRequestId)) { 426 throw new IllegalArgumentException("actionRequestId is blank"); 427 } 428 this.actionRequestId = actionRequestId; 429 } 430 431 public void setDocumentId(String documentId) { 432 if (StringUtils.isBlank(documentId)) { 433 throw new IllegalArgumentException("documentId is blank"); 434 } 435 this.documentId = documentId; 436 } 437 438 public void setDocTitle(String docTitle) { 439 if (StringUtils.isBlank(docTitle)) { 440 throw new IllegalArgumentException("docTitle is blank"); 441 } 442 this.docTitle = docTitle; 443 } 444 445 public void setDocLabel(String docLabel) { 446 if (StringUtils.isBlank(docLabel)) { 447 throw new IllegalArgumentException("docLabel is blank"); 448 } 449 this.docLabel = docLabel; 450 } 451 452 public void setDocHandlerURL(String docHandlerURL) { 453 if (StringUtils.isBlank(docHandlerURL)) { 454 throw new IllegalArgumentException("docHandlerURL is blank"); 455 } 456 this.docHandlerURL = docHandlerURL; 457 } 458 459 public void setDocName(String docName) { 460 if (StringUtils.isBlank(docName)) { 461 throw new IllegalArgumentException("docName is blank"); 462 } 463 this.docName = docName; 464 } 465 466 public void setResponsibilityId(String responsibilityId) { 467 if (StringUtils.isBlank(responsibilityId)) { 468 throw new IllegalArgumentException("responsibilityId is blank"); 469 } 470 this.responsibilityId = responsibilityId; 471 } 472 473 public void setRoleName(String roleName) { 474 this.roleName = roleName; 475 } 476 477 public void setDateAssignedString(String dateAssignedString) { 478 this.dateAssignedString = dateAssignedString; 479 } 480 481 public void setActionToTake(String actionToTake) { 482 this.actionToTake = actionToTake; 483 } 484 485 public void setDelegationType(String delegationType) { 486 this.delegationType = delegationType; 487 } 488 489 public void setActionItemIndex(Integer actionItemIndex) { 490 this.actionItemIndex = actionItemIndex; 491 } 492 493 public void setGroupId(String groupId) { 494 this.groupId = groupId; 495 } 496 497 public void setPrincipalId(String principalId) { 498 if (StringUtils.isBlank(principalId)) { 499 throw new IllegalArgumentException("principalId is blank"); 500 } 501 this.principalId = principalId; 502 } 503 504 public void setDelegatorGroupId(String delegatorGroupId) { 505 this.delegatorGroupId = delegatorGroupId; 506 } 507 508 public void setDelegatorPrincipalId(String delegatorPrincipalId) { 509 this.delegatorPrincipalId = delegatorPrincipalId; 510 } 511 512 } 513 514 515 /** 516 * Defines some internal constants used on this class. 517 * 518 */ 519 static class Constants { 520 521 final static String ROOT_ELEMENT_NAME = "actionItem"; 522 final static String TYPE_NAME = "ActionItemType"; 523 524 } 525 526 527 /** 528 * A private class which exposes constants which define the XML element names to use when this object is marshalled to XML. 529 * 530 */ 531 static class Elements { 532 533 final static String ID = "id"; 534 final static String DATE_TIME_ASSIGNED = "dateTimeAssigned"; 535 final static String ACTION_REQUEST_CD = "actionRequestCd"; 536 final static String ACTION_REQUEST_ID = "actionRequestId"; 537 final static String DOCUMENT_ID = "documentId"; 538 final static String DOC_TITLE = "docTitle"; 539 final static String DOC_LABEL = "docLabel"; 540 final static String DOC_HANDLER_U_R_L = "docHandlerURL"; 541 final static String DOC_NAME = "docName"; 542 final static String RESPONSIBILITY_ID = "responsibilityId"; 543 final static String ROLE_NAME = "roleName"; 544 final static String DATE_ASSIGNED_STRING = "dateAssignedString"; 545 final static String ACTION_TO_TAKE = "actionToTake"; 546 final static String DELEGATION_TYPE = "delegationType"; 547 final static String ACTION_ITEM_INDEX = "actionItemIndex"; 548 final static String GROUP_ID = "groupId"; 549 final static String PRINCIPAL_ID = "principalId"; 550 final static String DELEGATOR_GROUP_ID = "delegatorGroupId"; 551 final static String DELEGATOR_PRINCIPAL_ID = "delegatorPrincipalId"; 552 553 } 554 555 }