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