| 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.lang.StringUtils; |
| 19 | |
import org.joda.time.DateTime; |
| 20 | |
import org.kuali.rice.core.api.CoreConstants; |
| 21 | |
import org.kuali.rice.core.api.delegation.DelegationType; |
| 22 | |
import org.kuali.rice.core.api.mo.AbstractDataTransferObject; |
| 23 | |
import org.kuali.rice.core.api.mo.ModelBuilder; |
| 24 | |
import org.kuali.rice.core.api.util.jaxb.DateTimeAdapter; |
| 25 | |
import org.kuali.rice.kew.api.KewApiConstants; |
| 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.XmlElementWrapper; |
| 33 | |
import javax.xml.bind.annotation.XmlRootElement; |
| 34 | |
import javax.xml.bind.annotation.XmlType; |
| 35 | |
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; |
| 36 | |
import java.io.Serializable; |
| 37 | |
import java.util.ArrayList; |
| 38 | |
import java.util.Collection; |
| 39 | |
import java.util.Collections; |
| 40 | |
import java.util.List; |
| 41 | |
|
| 42 | 0 | @XmlRootElement(name = ActionRequest.Constants.ROOT_ELEMENT_NAME) |
| 43 | |
@XmlAccessorType(XmlAccessType.NONE) |
| 44 | |
@XmlType(name = ActionRequest.Constants.TYPE_NAME, propOrder = { |
| 45 | |
ActionRequest.Elements.ID, |
| 46 | |
ActionRequest.Elements.ACTION_REQUESTED_CODE, |
| 47 | |
ActionRequest.Elements.STATUS_CODE, |
| 48 | |
ActionRequest.Elements.CURRENT, |
| 49 | |
ActionRequest.Elements.DATE_CREATED, |
| 50 | |
ActionRequest.Elements.RESPONSIBILITY_ID, |
| 51 | |
ActionRequest.Elements.DOCUMENT_ID, |
| 52 | |
ActionRequest.Elements.PRIORITY, |
| 53 | |
ActionRequest.Elements.ROUTE_LEVEL, |
| 54 | |
ActionRequest.Elements.ANNOTATION, |
| 55 | |
ActionRequest.Elements.RECIPIENT_TYPE_CODE, |
| 56 | |
ActionRequest.Elements.PRINCIPAL_ID, |
| 57 | |
ActionRequest.Elements.GROUP_ID, |
| 58 | |
ActionRequest.Elements.REQUEST_POLICY_CODE, |
| 59 | |
ActionRequest.Elements.RESPONSIBILITY_DESCRIPTION, |
| 60 | |
ActionRequest.Elements.FORCE_ACTION, |
| 61 | |
ActionRequest.Elements.DELEGATION_TYPE_CODE, |
| 62 | |
ActionRequest.Elements.ROLE_NAME, |
| 63 | |
ActionRequest.Elements.QUALIFIED_ROLE_NAME, |
| 64 | |
ActionRequest.Elements.QUALIFIED_ROLE_NAME_LABEL, |
| 65 | |
ActionRequest.Elements.ROUTE_NODE_INSTANCE_ID, |
| 66 | |
ActionRequest.Elements.NODE_NAME, |
| 67 | |
ActionRequest.Elements.REQUEST_LABEL, |
| 68 | |
ActionRequest.Elements.PARENT_ACTION_REQUEST_ID, |
| 69 | |
ActionRequest.Elements.ACTION_TAKEN, |
| 70 | |
ActionRequest.Elements.CHILD_REQUESTS, |
| 71 | |
CoreConstants.CommonElements.FUTURE_ELEMENTS |
| 72 | |
}) |
| 73 | 0 | public final class ActionRequest extends AbstractDataTransferObject implements ActionRequestContract { |
| 74 | |
|
| 75 | |
private static final long serialVersionUID = -7581089059447119201L; |
| 76 | |
|
| 77 | |
@XmlElement(name = Elements.ID, required = true) |
| 78 | |
private final String id; |
| 79 | |
|
| 80 | |
@XmlElement(name = Elements.ACTION_REQUESTED_CODE, required = true) |
| 81 | |
private final String actionRequestedCode; |
| 82 | |
|
| 83 | |
@XmlElement(name = Elements.STATUS_CODE, required = true) |
| 84 | |
private final String statusCode; |
| 85 | |
|
| 86 | |
@XmlElement(name = Elements.CURRENT, required = true) |
| 87 | |
private final boolean current; |
| 88 | |
|
| 89 | |
@XmlElement(name = Elements.DATE_CREATED, required = true) |
| 90 | |
@XmlJavaTypeAdapter(DateTimeAdapter.class) |
| 91 | |
private final DateTime dateCreated; |
| 92 | |
|
| 93 | |
@XmlElement(name = Elements.RESPONSIBILITY_ID, required = true) |
| 94 | |
private final String responsibilityId; |
| 95 | |
|
| 96 | |
@XmlElement(name = Elements.DOCUMENT_ID, required = true) |
| 97 | |
private final String documentId; |
| 98 | |
|
| 99 | |
@XmlElement(name = Elements.PRIORITY, required = true) |
| 100 | |
private final int priority; |
| 101 | |
|
| 102 | |
@XmlElement(name = Elements.ROUTE_LEVEL, required = true) |
| 103 | |
private final int routeLevel; |
| 104 | |
|
| 105 | |
@XmlElement(name = Elements.ANNOTATION, required = false) |
| 106 | |
private final String annotation; |
| 107 | |
|
| 108 | |
@XmlElement(name = Elements.RECIPIENT_TYPE_CODE, required = true) |
| 109 | |
private final String recipientTypeCode; |
| 110 | |
|
| 111 | |
@XmlElement(name = Elements.PRINCIPAL_ID, required = false) |
| 112 | |
private final String principalId; |
| 113 | |
|
| 114 | |
@XmlElement(name = Elements.GROUP_ID, required = false) |
| 115 | |
private final String groupId; |
| 116 | |
|
| 117 | |
@XmlElement(name = Elements.REQUEST_POLICY_CODE, required = false) |
| 118 | |
private final String requestPolicyCode; |
| 119 | |
|
| 120 | |
@XmlElement(name = Elements.RESPONSIBILITY_DESCRIPTION, required = false) |
| 121 | |
private final String responsibilityDescription; |
| 122 | |
|
| 123 | |
@XmlElement(name = Elements.FORCE_ACTION, required = true) |
| 124 | |
private final boolean forceAction; |
| 125 | |
|
| 126 | |
@XmlElement(name = Elements.DELEGATION_TYPE_CODE, required = false) |
| 127 | |
private final String delegationTypeCode; |
| 128 | |
|
| 129 | |
@XmlElement(name = Elements.ROLE_NAME, required = false) |
| 130 | |
private final String roleName; |
| 131 | |
|
| 132 | |
@XmlElement(name = Elements.QUALIFIED_ROLE_NAME, required = false) |
| 133 | |
private final String qualifiedRoleName; |
| 134 | |
|
| 135 | |
@XmlElement(name = Elements.QUALIFIED_ROLE_NAME_LABEL, required = false) |
| 136 | |
private final String qualifiedRoleNameLabel; |
| 137 | |
|
| 138 | |
@XmlElement(name = Elements.ROUTE_NODE_INSTANCE_ID, required = false) |
| 139 | |
private final String routeNodeInstanceId; |
| 140 | |
|
| 141 | |
@XmlElement(name = Elements.NODE_NAME, required = false) |
| 142 | |
private final String nodeName; |
| 143 | |
|
| 144 | |
@XmlElement(name = Elements.REQUEST_LABEL, required = false) |
| 145 | |
private final String requestLabel; |
| 146 | |
|
| 147 | |
@XmlElement(name = Elements.PARENT_ACTION_REQUEST_ID, required = false) |
| 148 | |
private final String parentActionRequestId; |
| 149 | |
|
| 150 | |
@XmlElement(name = Elements.ACTION_TAKEN, required = false) |
| 151 | |
private final ActionTaken actionTaken; |
| 152 | |
|
| 153 | |
@XmlElementWrapper(name = Elements.CHILD_REQUESTS, required = false) |
| 154 | |
@XmlElement(name = Elements.CHILD_REQUEST, required = false) |
| 155 | |
private final List<ActionRequest> childRequests; |
| 156 | |
|
| 157 | 0 | @SuppressWarnings("unused") |
| 158 | |
@XmlAnyElement |
| 159 | |
private final Collection<Element> _futureElements = null; |
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | 0 | private ActionRequest() { |
| 165 | 0 | this.id = null; |
| 166 | 0 | this.actionRequestedCode = null; |
| 167 | 0 | this.statusCode = null; |
| 168 | 0 | this.current = false; |
| 169 | 0 | this.dateCreated = null; |
| 170 | 0 | this.responsibilityId = null; |
| 171 | 0 | this.documentId = null; |
| 172 | 0 | this.priority = 0; |
| 173 | 0 | this.routeLevel = 0; |
| 174 | 0 | this.annotation = null; |
| 175 | 0 | this.recipientTypeCode = null; |
| 176 | 0 | this.principalId = null; |
| 177 | 0 | this.groupId = null; |
| 178 | 0 | this.requestPolicyCode = null; |
| 179 | 0 | this.responsibilityDescription = null; |
| 180 | 0 | this.forceAction = false; |
| 181 | 0 | this.delegationTypeCode = null; |
| 182 | 0 | this.roleName = null; |
| 183 | 0 | this.qualifiedRoleName = null; |
| 184 | 0 | this.qualifiedRoleNameLabel = null; |
| 185 | 0 | this.routeNodeInstanceId = null; |
| 186 | 0 | this.nodeName = null; |
| 187 | 0 | this.requestLabel = null; |
| 188 | 0 | this.parentActionRequestId = null; |
| 189 | 0 | this.actionTaken = null; |
| 190 | 0 | this.childRequests = null; |
| 191 | 0 | } |
| 192 | |
|
| 193 | 0 | private ActionRequest(Builder builder) { |
| 194 | 0 | this.id = builder.getId(); |
| 195 | 0 | this.actionRequestedCode = builder.getActionRequested().getCode(); |
| 196 | 0 | this.statusCode = builder.getStatus().getCode(); |
| 197 | 0 | this.current = builder.isCurrent(); |
| 198 | 0 | this.dateCreated = builder.getDateCreated(); |
| 199 | 0 | this.responsibilityId = builder.getResponsibilityId(); |
| 200 | 0 | this.documentId = builder.getDocumentId(); |
| 201 | 0 | this.priority = builder.getPriority(); |
| 202 | 0 | this.routeLevel = builder.getRouteLevel(); |
| 203 | 0 | this.annotation = builder.getAnnotation(); |
| 204 | 0 | this.recipientTypeCode = builder.getRecipientType().getCode(); |
| 205 | 0 | this.principalId = builder.getPrincipalId(); |
| 206 | 0 | this.groupId = builder.getGroupId(); |
| 207 | 0 | if (builder.getRequestPolicy() == null) { |
| 208 | 0 | this.requestPolicyCode = null; |
| 209 | |
} else { |
| 210 | 0 | this.requestPolicyCode = builder.getRequestPolicy().getCode(); |
| 211 | |
} |
| 212 | 0 | this.responsibilityDescription = builder.getResponsibilityDescription(); |
| 213 | 0 | this.forceAction = builder.isForceAction(); |
| 214 | 0 | if (builder.getDelegationType() == null) { |
| 215 | 0 | this.delegationTypeCode = null; |
| 216 | |
} else { |
| 217 | 0 | this.delegationTypeCode = builder.getDelegationType().getCode(); |
| 218 | |
} |
| 219 | 0 | this.roleName = builder.getRoleName(); |
| 220 | 0 | this.qualifiedRoleName = builder.getQualifiedRoleName(); |
| 221 | 0 | this.qualifiedRoleNameLabel = builder.getQualifiedRoleNameLabel(); |
| 222 | 0 | this.routeNodeInstanceId = builder.getRouteNodeInstanceId(); |
| 223 | 0 | this.nodeName = builder.getNodeName(); |
| 224 | 0 | this.requestLabel = builder.getRequestLabel(); |
| 225 | 0 | this.parentActionRequestId = builder.getParentActionRequestId(); |
| 226 | 0 | ActionTaken.Builder actionTakenBuilder = builder.getActionTaken(); |
| 227 | 0 | if (actionTakenBuilder == null) { |
| 228 | 0 | this.actionTaken = null; |
| 229 | |
} else { |
| 230 | 0 | this.actionTaken = actionTakenBuilder.build(); |
| 231 | |
} |
| 232 | 0 | this.childRequests = new ArrayList<ActionRequest>(); |
| 233 | 0 | List<ActionRequest.Builder> childRequestBuilders = builder.getChildRequests(); |
| 234 | 0 | if (childRequestBuilders != null) { |
| 235 | 0 | for (ActionRequest.Builder childRequestBuilder : childRequestBuilders) { |
| 236 | 0 | this.childRequests.add(childRequestBuilder.build()); |
| 237 | |
} |
| 238 | |
} |
| 239 | 0 | } |
| 240 | |
|
| 241 | |
@Override |
| 242 | |
public String getAnnotation() { |
| 243 | 0 | return this.annotation; |
| 244 | |
} |
| 245 | |
|
| 246 | |
@Override |
| 247 | |
public int getPriority() { |
| 248 | 0 | return this.priority; |
| 249 | |
} |
| 250 | |
|
| 251 | |
@Override |
| 252 | |
public int getRouteLevel() { |
| 253 | 0 | return this.routeLevel; |
| 254 | |
} |
| 255 | |
|
| 256 | |
@Override |
| 257 | |
public String getId() { |
| 258 | 0 | return this.id; |
| 259 | |
} |
| 260 | |
|
| 261 | |
@Override |
| 262 | |
public ActionRequestType getActionRequested() { |
| 263 | 0 | return ActionRequestType.fromCode(this.actionRequestedCode); |
| 264 | |
} |
| 265 | |
|
| 266 | |
@Override |
| 267 | |
public ActionRequestStatus getStatus() { |
| 268 | 0 | return ActionRequestStatus.fromCode(this.statusCode); |
| 269 | |
} |
| 270 | |
|
| 271 | |
@Override |
| 272 | |
public boolean isCurrent() { |
| 273 | 0 | return this.current; |
| 274 | |
} |
| 275 | |
|
| 276 | |
@Override |
| 277 | |
public DateTime getDateCreated() { |
| 278 | 0 | return this.dateCreated; |
| 279 | |
} |
| 280 | |
|
| 281 | |
@Override |
| 282 | |
public String getResponsibilityId() { |
| 283 | 0 | return this.responsibilityId; |
| 284 | |
} |
| 285 | |
|
| 286 | |
@Override |
| 287 | |
public String getDocumentId() { |
| 288 | 0 | return this.documentId; |
| 289 | |
} |
| 290 | |
|
| 291 | |
@Override |
| 292 | |
public RecipientType getRecipientType() { |
| 293 | 0 | return RecipientType.fromCode(this.recipientTypeCode); |
| 294 | |
} |
| 295 | |
|
| 296 | |
@Override |
| 297 | |
public String getPrincipalId() { |
| 298 | 0 | return this.principalId; |
| 299 | |
} |
| 300 | |
|
| 301 | |
@Override |
| 302 | |
public String getGroupId() { |
| 303 | 0 | return this.groupId; |
| 304 | |
} |
| 305 | |
|
| 306 | |
@Override |
| 307 | |
public ActionRequestPolicy getRequestPolicy() { |
| 308 | 0 | if (this.requestPolicyCode == null) { |
| 309 | 0 | return null; |
| 310 | |
} |
| 311 | 0 | return ActionRequestPolicy.fromCode(this.requestPolicyCode); |
| 312 | |
} |
| 313 | |
|
| 314 | |
@Override |
| 315 | |
public String getResponsibilityDescription() { |
| 316 | 0 | return this.responsibilityDescription; |
| 317 | |
} |
| 318 | |
|
| 319 | |
@Override |
| 320 | |
public boolean isForceAction() { |
| 321 | 0 | return this.forceAction; |
| 322 | |
} |
| 323 | |
|
| 324 | |
@Override |
| 325 | |
public DelegationType getDelegationType() { |
| 326 | 0 | if (this.delegationTypeCode == null) { |
| 327 | 0 | return null; |
| 328 | |
} |
| 329 | 0 | return DelegationType.fromCode(this.delegationTypeCode); |
| 330 | |
} |
| 331 | |
|
| 332 | |
@Override |
| 333 | |
public String getRoleName() { |
| 334 | 0 | return this.roleName; |
| 335 | |
} |
| 336 | |
|
| 337 | |
@Override |
| 338 | |
public String getQualifiedRoleName() { |
| 339 | 0 | return this.qualifiedRoleName; |
| 340 | |
} |
| 341 | |
|
| 342 | |
@Override |
| 343 | |
public String getQualifiedRoleNameLabel() { |
| 344 | 0 | return this.qualifiedRoleNameLabel; |
| 345 | |
} |
| 346 | |
|
| 347 | |
@Override |
| 348 | |
public String getRouteNodeInstanceId() { |
| 349 | 0 | return this.routeNodeInstanceId; |
| 350 | |
} |
| 351 | |
|
| 352 | |
@Override |
| 353 | |
public String getNodeName() { |
| 354 | 0 | return this.nodeName; |
| 355 | |
} |
| 356 | |
|
| 357 | |
@Override |
| 358 | |
public String getRequestLabel() { |
| 359 | 0 | return this.requestLabel; |
| 360 | |
} |
| 361 | |
|
| 362 | |
@Override |
| 363 | |
public String getParentActionRequestId() { |
| 364 | 0 | return this.parentActionRequestId; |
| 365 | |
} |
| 366 | |
|
| 367 | |
@Override |
| 368 | |
public ActionTaken getActionTaken() { |
| 369 | 0 | return this.actionTaken; |
| 370 | |
} |
| 371 | |
|
| 372 | |
@Override |
| 373 | |
public List<ActionRequest> getChildRequests() { |
| 374 | 0 | if (this.childRequests == null) { |
| 375 | 0 | return Collections.emptyList(); |
| 376 | |
} else { |
| 377 | 0 | return Collections.unmodifiableList(this.childRequests); |
| 378 | |
} |
| 379 | |
} |
| 380 | |
|
| 381 | |
public boolean isAdHocRequest() { |
| 382 | 0 | return KewApiConstants.ADHOC_REQUEST_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 383 | |
} |
| 384 | |
|
| 385 | |
public boolean isGeneratedRequest() { |
| 386 | 0 | return KewApiConstants.MACHINE_GENERATED_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 387 | |
} |
| 388 | |
|
| 389 | |
public boolean isExceptionRequest() { |
| 390 | 0 | return KewApiConstants.EXCEPTION_REQUEST_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 391 | |
} |
| 392 | |
|
| 393 | |
public boolean isRouteModuleRequest() { |
| 394 | 0 | return getResponsibilityId() != null && Long.parseLong(getResponsibilityId()) > 0; |
| 395 | |
} |
| 396 | |
|
| 397 | |
public boolean isNotificationRequest() { |
| 398 | 0 | return isAcknowledgeRequest() || isFyiRequest(); |
| 399 | |
} |
| 400 | |
|
| 401 | |
public boolean isApprovalRequest() { |
| 402 | 0 | return ActionRequestType.APPROVE == getActionRequested() || ActionRequestType.COMPLETE == getActionRequested(); |
| 403 | |
} |
| 404 | |
|
| 405 | |
public boolean isAcknowledgeRequest() { |
| 406 | 0 | return ActionRequestType.ACKNOWLEDGE == getActionRequested(); |
| 407 | |
} |
| 408 | |
|
| 409 | |
public boolean isFyiRequest() { |
| 410 | 0 | return ActionRequestType.FYI == getActionRequested(); |
| 411 | |
} |
| 412 | |
|
| 413 | |
public boolean isPending() { |
| 414 | 0 | return isInitialized() || isActivated(); |
| 415 | |
} |
| 416 | |
|
| 417 | |
public boolean isCompleteRequest() { |
| 418 | 0 | return ActionRequestType.COMPLETE == getActionRequested(); |
| 419 | |
} |
| 420 | |
|
| 421 | |
public boolean isInitialized() { |
| 422 | 0 | return ActionRequestStatus.INITIALIZED == getStatus(); |
| 423 | |
} |
| 424 | |
|
| 425 | |
public boolean isActivated() { |
| 426 | 0 | return ActionRequestStatus.ACTIVATED == getStatus(); |
| 427 | |
} |
| 428 | |
|
| 429 | |
public boolean isDone() { |
| 430 | 0 | return ActionRequestStatus.DONE == getStatus(); |
| 431 | |
} |
| 432 | |
|
| 433 | |
public boolean isUserRequest() { |
| 434 | 0 | return RecipientType.PRINCIPAL == getRecipientType(); |
| 435 | |
} |
| 436 | |
|
| 437 | |
public boolean isGroupRequest() { |
| 438 | 0 | return RecipientType.GROUP == getRecipientType(); |
| 439 | |
} |
| 440 | |
|
| 441 | |
public boolean isRoleRequest() { |
| 442 | 0 | return RecipientType.ROLE == getRecipientType(); |
| 443 | |
} |
| 444 | |
|
| 445 | |
public List<ActionRequest> flatten() { |
| 446 | 0 | List<ActionRequest> flattenedRequests = new ArrayList<ActionRequest>(); |
| 447 | 0 | flattenedRequests.add(this); |
| 448 | 0 | for (ActionRequest childRequest : getChildRequests()) { |
| 449 | 0 | flattenedRequests.addAll(childRequest.flatten()); |
| 450 | |
} |
| 451 | 0 | return Collections.unmodifiableList(flattenedRequests); |
| 452 | |
} |
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | |
|
| 457 | 0 | public final static class Builder implements Serializable, ModelBuilder, ActionRequestContract { |
| 458 | |
|
| 459 | |
private static final long serialVersionUID = -1354211147778354091L; |
| 460 | |
|
| 461 | |
private String id; |
| 462 | |
private ActionRequestType actionRequested; |
| 463 | |
private ActionRequestStatus status; |
| 464 | |
private boolean current; |
| 465 | |
private DateTime dateCreated; |
| 466 | |
private String responsibilityId; |
| 467 | |
private String documentId; |
| 468 | |
private int priority; |
| 469 | |
private int routeLevel; |
| 470 | |
private String annotation; |
| 471 | |
private RecipientType recipientType; |
| 472 | |
private String principalId; |
| 473 | |
private String groupId; |
| 474 | |
private ActionRequestPolicy requestPolicy; |
| 475 | |
private String responsibilityDescription; |
| 476 | |
private boolean forceAction; |
| 477 | |
private DelegationType delegationType; |
| 478 | |
private String roleName; |
| 479 | |
private String qualifiedRoleName; |
| 480 | |
private String qualifiedRoleNameLabel; |
| 481 | |
private String routeNodeInstanceId; |
| 482 | |
private String nodeName; |
| 483 | |
private String requestLabel; |
| 484 | |
private String parentActionRequestId; |
| 485 | |
private ActionTaken.Builder actionTaken; |
| 486 | |
private List<ActionRequest.Builder> childRequests; |
| 487 | |
|
| 488 | 0 | private Builder(String id, ActionRequestType actionRequested, ActionRequestStatus status, String responsibilityId, String documentId, RecipientType recipientType) { |
| 489 | 0 | setId(id); |
| 490 | 0 | setActionRequested(actionRequested); |
| 491 | 0 | setStatus(status); |
| 492 | 0 | setResponsibilityId(responsibilityId); |
| 493 | 0 | setDocumentId(documentId); |
| 494 | 0 | setRecipientType(recipientType); |
| 495 | 0 | setCurrent(true); |
| 496 | 0 | setDateCreated(new DateTime()); |
| 497 | 0 | } |
| 498 | |
|
| 499 | |
public static Builder create(String id, ActionRequestType actionRequested, ActionRequestStatus status, String responsibilityId, String documentId, RecipientType recipientType) { |
| 500 | 0 | return new Builder(id, actionRequested, status, responsibilityId, documentId, recipientType); |
| 501 | |
} |
| 502 | |
|
| 503 | |
public static Builder create(ActionRequestContract contract) { |
| 504 | 0 | if (contract == null) { |
| 505 | 0 | throw new IllegalArgumentException("contract was null"); |
| 506 | |
} |
| 507 | |
|
| 508 | 0 | Builder builder = create(contract.getId(), contract.getActionRequested(), contract.getStatus(), contract.getResponsibilityId(), contract.getDocumentId(), contract.getRecipientType()); |
| 509 | 0 | builder.setCurrent(contract.isCurrent()); |
| 510 | 0 | builder.setDateCreated(contract.getDateCreated()); |
| 511 | 0 | builder.setPriority(contract.getPriority()); |
| 512 | 0 | builder.setRouteLevel(contract.getRouteLevel()); |
| 513 | 0 | builder.setAnnotation(contract.getAnnotation()); |
| 514 | 0 | builder.setPrincipalId(contract.getPrincipalId()); |
| 515 | 0 | builder.setGroupId(contract.getGroupId()); |
| 516 | 0 | builder.setRequestPolicy(contract.getRequestPolicy()); |
| 517 | 0 | builder.setResponsibilityDescription(contract.getResponsibilityDescription()); |
| 518 | 0 | builder.setForceAction(contract.isForceAction()); |
| 519 | 0 | builder.setDelegationType(contract.getDelegationType()); |
| 520 | 0 | builder.setRoleName(contract.getRoleName()); |
| 521 | 0 | builder.setQualifiedRoleName(contract.getQualifiedRoleName()); |
| 522 | 0 | builder.setQualifiedRoleNameLabel(contract.getQualifiedRoleNameLabel()); |
| 523 | 0 | builder.setNodeName(contract.getNodeName()); |
| 524 | 0 | builder.setRequestLabel(contract.getRequestLabel()); |
| 525 | 0 | builder.setParentActionRequestId(contract.getParentActionRequestId()); |
| 526 | 0 | if (contract.getActionTaken() != null) { |
| 527 | 0 | builder.setActionTaken(ActionTaken.Builder.create(contract.getActionTaken())); |
| 528 | |
} |
| 529 | 0 | List<ActionRequest.Builder> actionRequestBuilders = new ArrayList<ActionRequest.Builder>(); |
| 530 | 0 | for (ActionRequestContract actionRequest : contract.getChildRequests()) { |
| 531 | 0 | actionRequestBuilders.add(ActionRequest.Builder.create(actionRequest)); |
| 532 | |
} |
| 533 | 0 | builder.setChildRequests(actionRequestBuilders); |
| 534 | 0 | return builder; |
| 535 | |
} |
| 536 | |
|
| 537 | |
public ActionRequest build() { |
| 538 | 0 | return new ActionRequest(this); |
| 539 | |
} |
| 540 | |
|
| 541 | |
@Override |
| 542 | |
public String getId() { |
| 543 | 0 | return this.id; |
| 544 | |
} |
| 545 | |
|
| 546 | |
@Override |
| 547 | |
public ActionRequestType getActionRequested() { |
| 548 | 0 | return this.actionRequested; |
| 549 | |
} |
| 550 | |
|
| 551 | |
@Override |
| 552 | |
public ActionRequestStatus getStatus() { |
| 553 | 0 | return this.status; |
| 554 | |
} |
| 555 | |
|
| 556 | |
@Override |
| 557 | |
public boolean isCurrent() { |
| 558 | 0 | return this.current; |
| 559 | |
} |
| 560 | |
|
| 561 | |
@Override |
| 562 | |
public DateTime getDateCreated() { |
| 563 | 0 | return this.dateCreated; |
| 564 | |
} |
| 565 | |
|
| 566 | |
@Override |
| 567 | |
public String getResponsibilityId() { |
| 568 | 0 | return this.responsibilityId; |
| 569 | |
} |
| 570 | |
|
| 571 | |
@Override |
| 572 | |
public String getDocumentId() { |
| 573 | 0 | return this.documentId; |
| 574 | |
} |
| 575 | |
|
| 576 | |
@Override |
| 577 | |
public int getPriority() { |
| 578 | 0 | return this.priority; |
| 579 | |
} |
| 580 | |
|
| 581 | |
@Override |
| 582 | |
public int getRouteLevel() { |
| 583 | 0 | return this.routeLevel; |
| 584 | |
} |
| 585 | |
|
| 586 | |
@Override |
| 587 | |
public String getAnnotation() { |
| 588 | 0 | return this.annotation; |
| 589 | |
} |
| 590 | |
|
| 591 | |
@Override |
| 592 | |
public RecipientType getRecipientType() { |
| 593 | 0 | return this.recipientType; |
| 594 | |
} |
| 595 | |
|
| 596 | |
@Override |
| 597 | |
public String getPrincipalId() { |
| 598 | 0 | return this.principalId; |
| 599 | |
} |
| 600 | |
|
| 601 | |
@Override |
| 602 | |
public String getGroupId() { |
| 603 | 0 | return this.groupId; |
| 604 | |
} |
| 605 | |
|
| 606 | |
@Override |
| 607 | |
public ActionRequestPolicy getRequestPolicy() { |
| 608 | 0 | return this.requestPolicy; |
| 609 | |
} |
| 610 | |
|
| 611 | |
@Override |
| 612 | |
public String getResponsibilityDescription() { |
| 613 | 0 | return this.responsibilityDescription; |
| 614 | |
} |
| 615 | |
|
| 616 | |
@Override |
| 617 | |
public boolean isForceAction() { |
| 618 | 0 | return this.forceAction; |
| 619 | |
} |
| 620 | |
|
| 621 | |
@Override |
| 622 | |
public DelegationType getDelegationType() { |
| 623 | 0 | return this.delegationType; |
| 624 | |
} |
| 625 | |
|
| 626 | |
@Override |
| 627 | |
public String getRoleName() { |
| 628 | 0 | return this.roleName; |
| 629 | |
} |
| 630 | |
|
| 631 | |
@Override |
| 632 | |
public String getQualifiedRoleName() { |
| 633 | 0 | return this.qualifiedRoleName; |
| 634 | |
} |
| 635 | |
|
| 636 | |
@Override |
| 637 | |
public String getQualifiedRoleNameLabel() { |
| 638 | 0 | return this.qualifiedRoleNameLabel; |
| 639 | |
} |
| 640 | |
|
| 641 | |
@Override |
| 642 | |
public String getRouteNodeInstanceId() { |
| 643 | 0 | return this.routeNodeInstanceId; |
| 644 | |
} |
| 645 | |
|
| 646 | |
@Override |
| 647 | |
public String getNodeName() { |
| 648 | 0 | return this.nodeName; |
| 649 | |
} |
| 650 | |
|
| 651 | |
@Override |
| 652 | |
public String getRequestLabel() { |
| 653 | 0 | return this.requestLabel; |
| 654 | |
} |
| 655 | |
|
| 656 | |
@Override |
| 657 | |
public String getParentActionRequestId() { |
| 658 | 0 | return this.parentActionRequestId; |
| 659 | |
} |
| 660 | |
|
| 661 | |
@Override |
| 662 | |
public ActionTaken.Builder getActionTaken() { |
| 663 | 0 | return this.actionTaken; |
| 664 | |
} |
| 665 | |
|
| 666 | |
@Override |
| 667 | |
public List<ActionRequest.Builder> getChildRequests() { |
| 668 | 0 | return this.childRequests; |
| 669 | |
} |
| 670 | |
|
| 671 | |
public void setId(String id) { |
| 672 | 0 | if (StringUtils.isWhitespace(id)) { |
| 673 | 0 | throw new IllegalArgumentException("id was null or blank"); |
| 674 | |
} |
| 675 | 0 | this.id = id; |
| 676 | 0 | } |
| 677 | |
|
| 678 | |
public void setActionRequested(ActionRequestType actionRequested) { |
| 679 | 0 | if (actionRequested == null) { |
| 680 | 0 | throw new IllegalArgumentException("actionRequested was null"); |
| 681 | |
} |
| 682 | 0 | this.actionRequested = actionRequested; |
| 683 | 0 | } |
| 684 | |
|
| 685 | |
public void setStatus(ActionRequestStatus status) { |
| 686 | 0 | if (status == null) { |
| 687 | 0 | throw new IllegalArgumentException("status was null"); |
| 688 | |
} |
| 689 | 0 | this.status = status; |
| 690 | 0 | } |
| 691 | |
|
| 692 | |
public void setCurrent(boolean current) { |
| 693 | 0 | this.current = current; |
| 694 | 0 | } |
| 695 | |
|
| 696 | |
public void setDateCreated(DateTime dateCreated) { |
| 697 | 0 | if (dateCreated == null) { |
| 698 | 0 | throw new IllegalArgumentException("dateCreated was null"); |
| 699 | |
} |
| 700 | 0 | this.dateCreated = dateCreated; |
| 701 | 0 | } |
| 702 | |
|
| 703 | |
public void setResponsibilityId(String responsibilityId) { |
| 704 | 0 | if (StringUtils.isBlank(responsibilityId)) { |
| 705 | 0 | throw new IllegalArgumentException("responsibilityId was null or blank"); |
| 706 | |
} |
| 707 | 0 | this.responsibilityId = responsibilityId; |
| 708 | 0 | } |
| 709 | |
|
| 710 | |
public void setDocumentId(String documentId) { |
| 711 | 0 | if (StringUtils.isBlank(documentId)) { |
| 712 | 0 | throw new IllegalArgumentException("documentId was null or blank"); |
| 713 | |
} |
| 714 | 0 | this.documentId = documentId; |
| 715 | 0 | } |
| 716 | |
|
| 717 | |
public void setPriority(int priority) { |
| 718 | 0 | this.priority = priority; |
| 719 | 0 | } |
| 720 | |
|
| 721 | |
public void setRouteLevel(int routeLevel) { |
| 722 | 0 | this.routeLevel = routeLevel; |
| 723 | 0 | } |
| 724 | |
|
| 725 | |
public void setAnnotation(String annotation) { |
| 726 | 0 | this.annotation = annotation; |
| 727 | 0 | } |
| 728 | |
|
| 729 | |
public void setRecipientType(RecipientType recipientType) { |
| 730 | 0 | if (recipientType == null) { |
| 731 | 0 | throw new IllegalArgumentException("recipientType was null"); |
| 732 | |
} |
| 733 | 0 | this.recipientType = recipientType; |
| 734 | 0 | } |
| 735 | |
|
| 736 | |
public void setPrincipalId(String principalId) { |
| 737 | 0 | this.principalId = principalId; |
| 738 | 0 | } |
| 739 | |
|
| 740 | |
public void setGroupId(String groupId) { |
| 741 | 0 | this.groupId = groupId; |
| 742 | 0 | } |
| 743 | |
|
| 744 | |
public void setRequestPolicy(ActionRequestPolicy requestPolicy) { |
| 745 | 0 | this.requestPolicy = requestPolicy; |
| 746 | 0 | } |
| 747 | |
|
| 748 | |
public void setResponsibilityDescription(String responsibilityDescription) { |
| 749 | 0 | this.responsibilityDescription = responsibilityDescription; |
| 750 | 0 | } |
| 751 | |
|
| 752 | |
public void setForceAction(boolean forceAction) { |
| 753 | 0 | this.forceAction = forceAction; |
| 754 | 0 | } |
| 755 | |
|
| 756 | |
public void setDelegationType(DelegationType delegationType) { |
| 757 | 0 | this.delegationType = delegationType; |
| 758 | 0 | } |
| 759 | |
|
| 760 | |
public void setRoleName(String roleName) { |
| 761 | 0 | this.roleName = roleName; |
| 762 | 0 | } |
| 763 | |
|
| 764 | |
public void setQualifiedRoleName(String qualifiedRoleName) { |
| 765 | 0 | this.qualifiedRoleName = qualifiedRoleName; |
| 766 | 0 | } |
| 767 | |
|
| 768 | |
public void setQualifiedRoleNameLabel(String qualifiedRoleNameLabel) { |
| 769 | 0 | this.qualifiedRoleNameLabel = qualifiedRoleNameLabel; |
| 770 | 0 | } |
| 771 | |
|
| 772 | |
public void setRouteNodeInstanceId(String routeNodeInstanceId) { |
| 773 | 0 | this.routeNodeInstanceId = routeNodeInstanceId; |
| 774 | 0 | } |
| 775 | |
|
| 776 | |
public void setNodeName(String nodeName) { |
| 777 | 0 | this.nodeName = nodeName; |
| 778 | 0 | } |
| 779 | |
|
| 780 | |
public void setRequestLabel(String requestLabel) { |
| 781 | 0 | this.requestLabel = requestLabel; |
| 782 | 0 | } |
| 783 | |
|
| 784 | |
public void setParentActionRequestId(String parentActionRequestId) { |
| 785 | 0 | this.parentActionRequestId = parentActionRequestId; |
| 786 | 0 | } |
| 787 | |
|
| 788 | |
public void setActionTaken(ActionTaken.Builder actionTaken) { |
| 789 | 0 | this.actionTaken = actionTaken; |
| 790 | 0 | } |
| 791 | |
|
| 792 | |
public void setChildRequests(List<ActionRequest.Builder> childRequests) { |
| 793 | 0 | this.childRequests = childRequests; |
| 794 | 0 | } |
| 795 | |
|
| 796 | |
} |
| 797 | |
|
| 798 | |
|
| 799 | |
|
| 800 | |
|
| 801 | |
|
| 802 | |
|
| 803 | 0 | static class Constants { |
| 804 | |
final static String ROOT_ELEMENT_NAME = "actionRequest"; |
| 805 | |
final static String TYPE_NAME = "ActionRequestType"; |
| 806 | |
} |
| 807 | |
|
| 808 | |
|
| 809 | |
|
| 810 | |
|
| 811 | |
|
| 812 | |
|
| 813 | 0 | static class Elements { |
| 814 | |
final static String ANNOTATION = "annotation"; |
| 815 | |
final static String PRIORITY = "priority"; |
| 816 | |
final static String ID = "id"; |
| 817 | |
final static String ACTION_REQUESTED_CODE = "actionRequestedCode"; |
| 818 | |
final static String STATUS_CODE = "statusCode"; |
| 819 | |
final static String CURRENT = "current"; |
| 820 | |
final static String ROUTE_LEVEL = "routeLevel"; |
| 821 | |
final static String DATE_CREATED = "dateCreated"; |
| 822 | |
final static String RESPONSIBILITY_ID = "responsibilityId"; |
| 823 | |
final static String DOCUMENT_ID = "documentId"; |
| 824 | |
final static String RECIPIENT_TYPE_CODE = "recipientTypeCode"; |
| 825 | |
final static String PRINCIPAL_ID = "principalId"; |
| 826 | |
final static String GROUP_ID = "groupId"; |
| 827 | |
final static String REQUEST_POLICY_CODE = "requestPolicyCode"; |
| 828 | |
final static String RESPONSIBILITY_DESCRIPTION = "responsibilityDescription"; |
| 829 | |
final static String FORCE_ACTION = "forceAction"; |
| 830 | |
final static String DELEGATION_TYPE_CODE = "delegationTypeCode"; |
| 831 | |
final static String ROLE_NAME = "roleName"; |
| 832 | |
final static String QUALIFIED_ROLE_NAME = "qualifiedRoleName"; |
| 833 | |
final static String QUALIFIED_ROLE_NAME_LABEL = "qualifiedRoleNameLabel"; |
| 834 | |
final static String ROUTE_NODE_INSTANCE_ID = "routeNodeInstanceId"; |
| 835 | |
final static String NODE_NAME = "nodeName"; |
| 836 | |
final static String REQUEST_LABEL = "requestLabel"; |
| 837 | |
final static String PARENT_ACTION_REQUEST_ID = "parentActionRequestId"; |
| 838 | |
final static String ACTION_TAKEN = "actionTaken"; |
| 839 | |
final static String CHILD_REQUESTS = "childRequests"; |
| 840 | |
final static String CHILD_REQUEST = "childRequest"; |
| 841 | |
} |
| 842 | |
|
| 843 | |
} |
| 844 | |
|