| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
package org.kuali.rice.kew.actionrequest; |
| 17 | |
|
| 18 | |
import org.apache.commons.lang.StringUtils; |
| 19 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 20 | |
import org.apache.commons.lang.builder.ToStringStyle; |
| 21 | |
import org.hibernate.annotations.Fetch; |
| 22 | |
import org.hibernate.annotations.FetchMode; |
| 23 | |
import org.hibernate.annotations.GenericGenerator; |
| 24 | |
import org.hibernate.annotations.Parameter; |
| 25 | |
import org.joda.time.DateTime; |
| 26 | |
import org.kuali.rice.core.api.delegation.DelegationType; |
| 27 | |
import org.kuali.rice.core.api.util.RiceConstants; |
| 28 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
| 29 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
| 30 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
| 31 | |
import org.kuali.rice.kew.api.action.ActionRequest; |
| 32 | |
import org.kuali.rice.kew.api.action.ActionRequestPolicy; |
| 33 | |
import org.kuali.rice.kew.api.action.ActionRequestStatus; |
| 34 | |
import org.kuali.rice.kew.api.action.ActionRequestType; |
| 35 | |
import org.kuali.rice.kew.api.action.ActionTaken; |
| 36 | |
import org.kuali.rice.kew.api.action.RecipientType; |
| 37 | |
import org.kuali.rice.kew.api.util.CodeTranslator; |
| 38 | |
import org.kuali.rice.kew.dto.DTOConverter.RouteNodeInstanceLoader; |
| 39 | |
import org.kuali.rice.kew.engine.CompatUtils; |
| 40 | |
import org.kuali.rice.kew.engine.node.RouteNode; |
| 41 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
| 42 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
| 43 | |
import org.kuali.rice.kew.rule.RuleBaseValues; |
| 44 | |
import org.kuali.rice.kew.rule.service.RuleServiceInternal; |
| 45 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
| 46 | |
import org.kuali.rice.kew.user.RoleRecipient; |
| 47 | |
import org.kuali.rice.kew.api.KewApiConstants; |
| 48 | |
import org.kuali.rice.kim.api.group.Group; |
| 49 | |
import org.kuali.rice.kim.api.identity.Person; |
| 50 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
| 51 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
| 52 | |
|
| 53 | |
import javax.persistence.CascadeType; |
| 54 | |
import javax.persistence.Column; |
| 55 | |
import javax.persistence.Entity; |
| 56 | |
import javax.persistence.FetchType; |
| 57 | |
import javax.persistence.GeneratedValue; |
| 58 | |
import javax.persistence.Id; |
| 59 | |
import javax.persistence.JoinColumn; |
| 60 | |
import javax.persistence.ManyToOne; |
| 61 | |
import javax.persistence.NamedQueries; |
| 62 | |
import javax.persistence.NamedQuery; |
| 63 | |
import javax.persistence.OneToMany; |
| 64 | |
import javax.persistence.Table; |
| 65 | |
import javax.persistence.Transient; |
| 66 | |
import java.io.Serializable; |
| 67 | |
import java.sql.Timestamp; |
| 68 | |
import java.util.ArrayList; |
| 69 | |
import java.util.Arrays; |
| 70 | |
import java.util.Iterator; |
| 71 | |
import java.util.List; |
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
@Entity |
| 79 | |
@Table(name="KREW_ACTN_RQST_T") |
| 80 | |
|
| 81 | |
@NamedQueries({ |
| 82 | |
@NamedQuery(name="ActionRequestValue.FindByDocumentId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId"), |
| 83 | |
@NamedQuery(name="ActionRequestValue.GetUserRequestCount", query="select count(arv) from ActionRequestValue arv where arv.documentId = :documentId and arv.recipientTypeCd = :recipientTypeCd and arv.principalId = :principalId and arv.currentIndicator = :currentIndicator"), |
| 84 | |
@NamedQuery(name="ActionRequestValue.FindActivatedByGroup", query="select count(arv) from ActionRequestValue arv where arv.groupId = :groupId and arv.currentIndicator = :currentIndicator and arv.status = :status"), |
| 85 | |
@NamedQuery(name="ActionRequestValue.FindAllByDocId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator"), |
| 86 | |
@NamedQuery(name="ActionRequestValue.FindAllPendingByDocId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and (arv.status = :actionRequestStatus1 or arv.status = :actionRequestStatus2)"), |
| 87 | |
@NamedQuery(name="ActionRequestValue.FindAllRootByDocId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null"), |
| 88 | |
@NamedQuery(name="ActionRequestValue.FindByStatusAndDocId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.status = :status"), |
| 89 | |
@NamedQuery(name="ActionRequestValue.FindPendingByActionRequestedAndDocId", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.actionRequested = :actionRequested and (arv.status = :actionRequestStatus1 or arv.status = :actionRequestStatus2)"), |
| 90 | |
@NamedQuery(name="ActionRequestValue.FindPendingByDocIdAtOrBelowRouteLevel", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.status <> :status and arv.routeLevel <= :routeLevel"), |
| 91 | |
@NamedQuery(name="ActionRequestValue.FindPendingRootRequestsByDocIdAtOrBelowRouteLevel", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null and arv.status <> :status and routeLevel <= :routeLevel"), |
| 92 | |
@NamedQuery(name="ActionRequestValue.FindPendingRootRequestsByDocIdAtRouteLevel", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null and arv.status <> :status and routeLevel = :routeLevel"), |
| 93 | |
@NamedQuery(name="ActionRequestValue.FindPendingRootRequestsByDocIdAtRouteNode", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null and arv.nodeInstance.routeNodeInstanceId = :routeNodeInstanceId and (arv.status = :actionRequestStatus1 or arv.status = :actionRequestStatus2)"), |
| 94 | |
@NamedQuery(name="ActionRequestValue.FindPendingRootRequestsByDocumentType", query="select arv from ActionRequestValue arv where arv.documentId in (select drhv.documentId from DocumentRouteHeaderValue drhv where drhv.documentTypeId = :documentTypeId) and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null and (arv.status = :actionRequestStatus1 or arv.status = :actionRequestStatus2)"), |
| 95 | |
@NamedQuery(name="ActionRequestValue.FindRootRequestsByDocIdAtRouteNode", query="select arv from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.parentActionRequest is null and arv.nodeInstance.routeNodeInstanceId = :routeNodeInstanceId"), |
| 96 | |
@NamedQuery(name="ActionRequestValue.GetRequestGroupIds", query="select arv.groupId from ActionRequestValue arv where arv.documentId = :documentId and arv.currentIndicator = :currentIndicator and arv.recipientTypeCd = :recipientTypeCd"), |
| 97 | |
@NamedQuery(name="ActionRequestValue.FindByStatusAndGroupId", query="select arv from ActionRequestValue arv where arv.groupId = :groupId and arv.currentIndicator = :currentIndicator and arv.status = :status") |
| 98 | |
}) |
| 99 | |
public class ActionRequestValue implements Serializable { |
| 100 | |
|
| 101 | |
private static final long serialVersionUID = 8781414791855848385L; |
| 102 | |
|
| 103 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionRequestValue.class); |
| 104 | |
|
| 105 | |
private static final String ACTION_CODE_RANK = "FKACB"; |
| 106 | |
private static final String RECIPIENT_TYPE_RANK = "RWU"; |
| 107 | 0 | private static final List DELEGATION_TYPE_RANK = Arrays.asList(new Object[]{DelegationType.SECONDARY, DelegationType.PRIMARY, null}); |
| 108 | |
|
| 109 | |
@Id |
| 110 | |
@GeneratedValue(generator="KREW_ACTN_RQST_S") |
| 111 | |
@GenericGenerator(name="KREW_ACTN_RQST_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
| 112 | |
@Parameter(name="sequence_name",value="KREW_ACTN_RQST_S"), |
| 113 | |
@Parameter(name="value_column",value="id") |
| 114 | |
}) |
| 115 | |
@Column(name="ACTN_RQST_ID") |
| 116 | |
private String actionRequestId; |
| 117 | |
@Column(name="ACTN_RQST_CD") |
| 118 | |
private String actionRequested; |
| 119 | |
@Column(name="DOC_HDR_ID") |
| 120 | |
private String documentId; |
| 121 | |
@Column(name="STAT_CD") |
| 122 | |
private String status; |
| 123 | |
@Column(name="RSP_ID") |
| 124 | |
private String responsibilityId; |
| 125 | |
@Column(name="GRP_ID") |
| 126 | |
private String groupId; |
| 127 | |
@Column(name="RECIP_TYP_CD") |
| 128 | |
private String recipientTypeCd; |
| 129 | |
@Column(name="PRIO_NBR") |
| 130 | |
private Integer priority; |
| 131 | |
@Column(name="RTE_LVL_NBR") |
| 132 | |
private Integer routeLevel; |
| 133 | |
@Column(name="ACTN_TKN_ID", insertable=false, updatable=false) |
| 134 | |
private String actionTakenId; |
| 135 | 0 | @Column(name="DOC_VER_NBR") |
| 136 | |
private Integer docVersion = 1; |
| 137 | |
@Column(name="CRTE_DT") |
| 138 | |
private java.sql.Timestamp createDate; |
| 139 | |
@Column(name="RSP_DESC_TXT") |
| 140 | |
private String responsibilityDesc; |
| 141 | |
@Column(name="ACTN_RQST_ANNOTN_TXT") |
| 142 | |
private String annotation; |
| 143 | |
@Column(name="VER_NBR") |
| 144 | |
private Integer jrfVerNbr; |
| 145 | |
@Column(name="PRNCPL_ID") |
| 146 | |
private String principalId; |
| 147 | |
@Column(name="FRC_ACTN") |
| 148 | |
private Boolean forceAction; |
| 149 | |
@Column(name="PARNT_ID", insertable=false, updatable=false) |
| 150 | |
private String parentActionRequestId; |
| 151 | |
@Column(name="QUAL_ROLE_NM") |
| 152 | |
private String qualifiedRoleName; |
| 153 | |
@Column(name="ROLE_NM") |
| 154 | |
private String roleName; |
| 155 | |
@Column(name="QUAL_ROLE_NM_LBL_TXT") |
| 156 | |
private String qualifiedRoleNameLabel; |
| 157 | |
@Transient |
| 158 | |
private String displayStatus; |
| 159 | |
@Column(name="RULE_ID") |
| 160 | |
private String ruleBaseValuesId; |
| 161 | |
|
| 162 | |
@Column(name="DLGN_TYP") |
| 163 | |
private String delegationTypeCode; |
| 164 | |
@Column(name="APPR_PLCY") |
| 165 | |
private String approvePolicy; |
| 166 | |
|
| 167 | |
@ManyToOne(fetch=FetchType.EAGER) |
| 168 | |
@JoinColumn(name="PARNT_ID") |
| 169 | |
private ActionRequestValue parentActionRequest; |
| 170 | 0 | @Fetch(value = FetchMode.SELECT) |
| 171 | |
@OneToMany(mappedBy="parentActionRequest",cascade={CascadeType.PERSIST, CascadeType.MERGE},fetch=FetchType.EAGER) |
| 172 | |
private List<ActionRequestValue> childrenRequests = new ArrayList<ActionRequestValue>(); |
| 173 | |
@ManyToOne(fetch=FetchType.EAGER) |
| 174 | |
@JoinColumn(name="ACTN_TKN_ID") |
| 175 | |
private ActionTakenValue actionTaken; |
| 176 | |
|
| 177 | |
|
| 178 | 0 | @Column(name="CUR_IND") |
| 179 | |
private Boolean currentIndicator = true; |
| 180 | |
@Transient |
| 181 | |
private String createDateString; |
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
@ManyToOne(fetch=FetchType.EAGER) |
| 186 | |
@JoinColumn(name="RTE_NODE_INSTN_ID") |
| 187 | |
private RouteNodeInstance nodeInstance; |
| 188 | |
|
| 189 | |
@Column(name="RQST_LBL") |
| 190 | |
private String requestLabel; |
| 191 | |
|
| 192 | 0 | @Transient |
| 193 | |
private boolean resolveResponsibility = true; |
| 194 | |
@Transient |
| 195 | |
private DocumentRouteHeaderValue routeHeader; |
| 196 | |
@Transient |
| 197 | |
private List<ActionItem> simulatedActionItems; |
| 198 | |
|
| 199 | 0 | public ActionRequestValue() { |
| 200 | 0 | createDate = new Timestamp(System.currentTimeMillis()); |
| 201 | 0 | } |
| 202 | |
|
| 203 | |
|
| 204 | |
public void beforeInsert(){ |
| 205 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
| 206 | 0 | } |
| 207 | |
|
| 208 | |
public Group getGroup() { |
| 209 | 0 | if (getGroupId() == null) { |
| 210 | 0 | LOG.error("Attempting to get a group with a blank group id"); |
| 211 | 0 | return null; |
| 212 | |
} |
| 213 | 0 | return KimApiServiceLocator.getGroupService().getGroup(getGroupId()); |
| 214 | |
} |
| 215 | |
|
| 216 | |
public String getRouteLevelName() { |
| 217 | |
|
| 218 | 0 | if (CompatUtils.isRouteLevelRequest(this)) { |
| 219 | 0 | int routeLevelInt = getRouteLevel(); |
| 220 | 0 | if (routeLevelInt == KewApiConstants.EXCEPTION_ROUTE_LEVEL) { |
| 221 | 0 | return "Exception"; |
| 222 | |
} |
| 223 | |
|
| 224 | 0 | List<RouteNode> routeLevelNodes = CompatUtils.getRouteLevelCompatibleNodeList(KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId).getDocumentType()); |
| 225 | 0 | if (!(routeLevelInt < routeLevelNodes.size())) { |
| 226 | 0 | return "Not Found"; |
| 227 | |
} |
| 228 | 0 | return ((RouteNode)routeLevelNodes.get(routeLevelInt)).getRouteNodeName(); |
| 229 | |
} else { |
| 230 | 0 | return (nodeInstance == null ? "Exception" : nodeInstance.getName()); |
| 231 | |
} |
| 232 | |
} |
| 233 | |
|
| 234 | |
public boolean isUserRequest() { |
| 235 | 0 | return principalId != null; |
| 236 | |
} |
| 237 | |
|
| 238 | |
public Principal getPrincipal() { |
| 239 | 0 | if (getPrincipalId() == null) { |
| 240 | 0 | return null; |
| 241 | |
} |
| 242 | 0 | return KEWServiceLocator.getIdentityHelperService().getPrincipal(getPrincipalId()); |
| 243 | |
} |
| 244 | |
|
| 245 | |
public Person getPerson() { |
| 246 | 0 | if (getPrincipalId() == null) { |
| 247 | 0 | return null; |
| 248 | |
} |
| 249 | 0 | return KimApiServiceLocator.getPersonService().getPerson(getPrincipalId()); |
| 250 | |
} |
| 251 | |
|
| 252 | |
public String getDisplayName() { |
| 253 | 0 | if (isUserRequest()) { |
| 254 | 0 | return getPerson().getName(); |
| 255 | 0 | } else if (isGroupRequest()) { |
| 256 | 0 | return getGroup().getName(); |
| 257 | 0 | } else if (isRoleRequest()) { |
| 258 | 0 | return getRoleName(); |
| 259 | |
} |
| 260 | 0 | return ""; |
| 261 | |
} |
| 262 | |
|
| 263 | |
public Recipient getRecipient() { |
| 264 | 0 | if (getPrincipalId() != null) { |
| 265 | 0 | return new KimPrincipalRecipient(getPrincipal()); |
| 266 | 0 | } else if (getGroupId() != null){ |
| 267 | 0 | return new KimGroupRecipient(getGroup()); |
| 268 | |
} else { |
| 269 | 0 | return new RoleRecipient(this.getRoleName()); |
| 270 | |
} |
| 271 | |
} |
| 272 | |
|
| 273 | |
public boolean isPending() { |
| 274 | 0 | return ActionRequestStatus.INITIALIZED.getCode().equals(getStatus()) || ActionRequestStatus.ACTIVATED.getCode().equals(getStatus()); |
| 275 | |
} |
| 276 | |
|
| 277 | |
public String getStatusLabel() { |
| 278 | 0 | return CodeTranslator.getActionRequestStatusLabel(getStatus()); |
| 279 | |
} |
| 280 | |
|
| 281 | |
public String getActionRequestedLabel() { |
| 282 | 0 | if (StringUtils.isNotBlank(getRequestLabel())) { |
| 283 | 0 | return getRequestLabel(); |
| 284 | |
} |
| 285 | 0 | return CodeTranslator.getActionRequestLabel(getActionRequested()); |
| 286 | |
} |
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
public ActionTakenValue getActionTaken() { |
| 292 | 0 | return actionTaken; |
| 293 | |
} |
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
public void setActionTaken(ActionTakenValue actionTaken) { |
| 300 | 0 | this.actionTaken = actionTaken; |
| 301 | 0 | } |
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
|
| 306 | |
public String getActionRequested() { |
| 307 | 0 | return actionRequested; |
| 308 | |
} |
| 309 | |
|
| 310 | |
|
| 311 | |
|
| 312 | |
|
| 313 | |
|
| 314 | |
public void setActionRequested(String actionRequested) { |
| 315 | 0 | this.actionRequested = actionRequested; |
| 316 | 0 | } |
| 317 | |
|
| 318 | |
|
| 319 | |
|
| 320 | |
|
| 321 | |
public String getActionRequestId() { |
| 322 | 0 | return actionRequestId; |
| 323 | |
} |
| 324 | |
|
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
public void setActionRequestId(String actionRequestId) { |
| 330 | 0 | this.actionRequestId = actionRequestId; |
| 331 | 0 | } |
| 332 | |
|
| 333 | |
|
| 334 | |
|
| 335 | |
|
| 336 | |
public String getActionTakenId() { |
| 337 | 0 | return actionTakenId; |
| 338 | |
} |
| 339 | |
|
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
public void setActionTakenId(String actionTakenId) { |
| 345 | 0 | this.actionTakenId = actionTakenId; |
| 346 | 0 | } |
| 347 | |
|
| 348 | |
|
| 349 | |
|
| 350 | |
|
| 351 | |
public String getAnnotation() { |
| 352 | 0 | return annotation; |
| 353 | |
} |
| 354 | |
|
| 355 | |
|
| 356 | |
|
| 357 | |
|
| 358 | |
|
| 359 | |
public void setAnnotation(String annotation) { |
| 360 | 0 | this.annotation = annotation; |
| 361 | 0 | } |
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
public java.sql.Timestamp getCreateDate() { |
| 367 | 0 | return createDate; |
| 368 | |
} |
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
|
| 374 | |
public void setCreateDate(java.sql.Timestamp createDate) { |
| 375 | 0 | this.createDate = createDate; |
| 376 | 0 | } |
| 377 | |
|
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
public Integer getDocVersion() { |
| 382 | 0 | return docVersion; |
| 383 | |
} |
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | |
|
| 388 | |
|
| 389 | |
public void setDocVersion(Integer docVersion) { |
| 390 | 0 | this.docVersion = docVersion; |
| 391 | 0 | } |
| 392 | |
|
| 393 | |
public String getPrincipalId() { |
| 394 | 0 | return principalId; |
| 395 | |
} |
| 396 | |
|
| 397 | |
public void setPrincipalId(String principalId) { |
| 398 | 0 | this.principalId = principalId; |
| 399 | 0 | } |
| 400 | |
|
| 401 | |
|
| 402 | |
|
| 403 | |
|
| 404 | |
public Boolean getForceAction() { |
| 405 | 0 | return forceAction; |
| 406 | |
} |
| 407 | |
|
| 408 | |
|
| 409 | |
|
| 410 | |
|
| 411 | |
|
| 412 | |
public void setForceAction(Boolean forceAction) { |
| 413 | 0 | this.forceAction = forceAction; |
| 414 | 0 | } |
| 415 | |
|
| 416 | |
|
| 417 | |
|
| 418 | |
|
| 419 | |
public Integer getJrfVerNbr() { |
| 420 | 0 | return jrfVerNbr; |
| 421 | |
} |
| 422 | |
|
| 423 | |
|
| 424 | |
|
| 425 | |
|
| 426 | |
|
| 427 | |
public void setJrfVerNbr(Integer jrfVerNbr) { |
| 428 | 0 | this.jrfVerNbr = jrfVerNbr; |
| 429 | 0 | } |
| 430 | |
|
| 431 | |
|
| 432 | |
|
| 433 | |
|
| 434 | |
public Integer getPriority() { |
| 435 | 0 | return priority; |
| 436 | |
} |
| 437 | |
|
| 438 | |
|
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
public void setPriority(Integer priority) { |
| 443 | 0 | this.priority = priority; |
| 444 | 0 | } |
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
public String getRecipientTypeCd() { |
| 450 | 0 | return recipientTypeCd; |
| 451 | |
} |
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | |
|
| 457 | |
public void setRecipientTypeCd(String recipientTypeCd) { |
| 458 | 0 | this.recipientTypeCd = recipientTypeCd; |
| 459 | 0 | } |
| 460 | |
|
| 461 | |
|
| 462 | |
|
| 463 | |
|
| 464 | |
public String getResponsibilityDesc() { |
| 465 | 0 | return responsibilityDesc; |
| 466 | |
} |
| 467 | |
|
| 468 | |
|
| 469 | |
|
| 470 | |
|
| 471 | |
|
| 472 | |
public void setResponsibilityDesc(String responsibilityDesc) { |
| 473 | 0 | this.responsibilityDesc = responsibilityDesc; |
| 474 | 0 | } |
| 475 | |
|
| 476 | |
|
| 477 | |
|
| 478 | |
|
| 479 | |
public String getResponsibilityId() { |
| 480 | 0 | return responsibilityId; |
| 481 | |
} |
| 482 | |
|
| 483 | |
|
| 484 | |
|
| 485 | |
|
| 486 | |
|
| 487 | |
public void setResponsibilityId(String responsibilityId) { |
| 488 | 0 | this.responsibilityId = responsibilityId; |
| 489 | 0 | } |
| 490 | |
|
| 491 | |
|
| 492 | |
|
| 493 | |
|
| 494 | |
public String getDocumentId() { |
| 495 | 0 | return documentId; |
| 496 | |
} |
| 497 | |
|
| 498 | |
public void setDocumentId(String documentId) { |
| 499 | 0 | this.documentId = documentId; |
| 500 | 0 | } |
| 501 | |
|
| 502 | |
public Integer getRouteLevel() { |
| 503 | 0 | return routeLevel; |
| 504 | |
} |
| 505 | |
|
| 506 | |
public void setRouteLevel(Integer routeLevel) { |
| 507 | 0 | this.routeLevel = routeLevel; |
| 508 | 0 | } |
| 509 | |
|
| 510 | |
public String getStatus() { |
| 511 | 0 | return status; |
| 512 | |
} |
| 513 | |
|
| 514 | |
public void setStatus(String status) { |
| 515 | 0 | this.status = status; |
| 516 | 0 | } |
| 517 | |
|
| 518 | |
public String getGroupId() { |
| 519 | 0 | return groupId; |
| 520 | |
} |
| 521 | |
|
| 522 | |
public void setGroupId(String groupId) { |
| 523 | 0 | this.groupId = groupId; |
| 524 | 0 | } |
| 525 | |
|
| 526 | |
public boolean isInitialized() { |
| 527 | 0 | return ActionRequestStatus.INITIALIZED.getCode().equals(getStatus()); |
| 528 | |
} |
| 529 | |
|
| 530 | |
public boolean isActive() { |
| 531 | 0 | return ActionRequestStatus.ACTIVATED.getCode().equals(getStatus()); |
| 532 | |
} |
| 533 | |
|
| 534 | |
public boolean isApproveOrCompleteRequest() { |
| 535 | 0 | return KewApiConstants.ACTION_REQUEST_APPROVE_REQ.equals(getActionRequested()) || KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(getActionRequested()); |
| 536 | |
} |
| 537 | |
|
| 538 | |
public boolean isDone() { |
| 539 | 0 | return ActionRequestStatus.DONE.getCode().equals(getStatus()); |
| 540 | |
} |
| 541 | |
|
| 542 | |
public boolean isReviewerUser() { |
| 543 | 0 | return RecipientType.PRINCIPAL.getCode().equals(getRecipientTypeCd()); |
| 544 | |
} |
| 545 | |
|
| 546 | |
public boolean isRecipientRoutedRequest(String principalId) { |
| 547 | |
|
| 548 | |
|
| 549 | 0 | if (principalId == null || "".equals(principalId)) { |
| 550 | 0 | return false; |
| 551 | |
} |
| 552 | |
|
| 553 | 0 | boolean isRecipientInGraph = false; |
| 554 | 0 | if (isReviewerUser()) { |
| 555 | 0 | isRecipientInGraph = getPrincipalId().equals(principalId); |
| 556 | 0 | } else if (isGroupRequest()) { |
| 557 | 0 | Group group = getGroup(); |
| 558 | 0 | if (group == null){ |
| 559 | 0 | LOG.error("Was unable to retrieve workgroup " + getGroupId()); |
| 560 | |
} |
| 561 | 0 | isRecipientInGraph = KimApiServiceLocator.getGroupService().isMemberOfGroup(principalId, group.getId()); |
| 562 | |
} |
| 563 | |
|
| 564 | |
|
| 565 | 0 | for (ActionRequestValue childRequest : getChildrenRequests()) |
| 566 | |
{ |
| 567 | 0 | isRecipientInGraph = isRecipientInGraph || childRequest.isRecipientRoutedRequest(principalId); |
| 568 | |
} |
| 569 | |
|
| 570 | 0 | return isRecipientInGraph; |
| 571 | |
} |
| 572 | |
|
| 573 | |
public boolean isRecipientRoutedRequest(Recipient recipient) { |
| 574 | |
|
| 575 | |
|
| 576 | 0 | if (recipient == null) { |
| 577 | 0 | return false; |
| 578 | |
} |
| 579 | |
|
| 580 | 0 | boolean isRecipientInGraph = false; |
| 581 | 0 | if (isReviewerUser()) { |
| 582 | 0 | if (recipient instanceof KimPrincipalRecipient) { |
| 583 | 0 | isRecipientInGraph = getPrincipalId().equals(((KimPrincipalRecipient) recipient).getPrincipalId()); |
| 584 | 0 | } else if (recipient instanceof KimGroupRecipient){ |
| 585 | 0 | isRecipientInGraph = KimApiServiceLocator.getGroupService().isMemberOfGroup(getPrincipalId(), ((KimGroupRecipient)recipient).getGroup().getId()); |
| 586 | |
} |
| 587 | |
|
| 588 | 0 | } else if (isGroupRequest()) { |
| 589 | 0 | Group group = getGroup(); |
| 590 | 0 | if (group == null){ |
| 591 | 0 | LOG.error("Was unable to retrieve workgroup " + getGroupId()); |
| 592 | |
} |
| 593 | 0 | if (recipient instanceof KimPrincipalRecipient) { |
| 594 | 0 | KimPrincipalRecipient principalRecipient = (KimPrincipalRecipient)recipient; |
| 595 | 0 | isRecipientInGraph = KimApiServiceLocator.getGroupService().isMemberOfGroup(principalRecipient.getPrincipalId(), group.getId()); |
| 596 | 0 | } else if (recipient instanceof KimGroupRecipient) { |
| 597 | 0 | isRecipientInGraph = ((KimGroupRecipient) recipient).getGroup().getId().equals(group.getId()); |
| 598 | |
} |
| 599 | |
} |
| 600 | |
|
| 601 | |
|
| 602 | 0 | for (ActionRequestValue childRequest : getChildrenRequests()) |
| 603 | |
{ |
| 604 | 0 | isRecipientInGraph = isRecipientInGraph || childRequest.isRecipientRoutedRequest(recipient); |
| 605 | |
} |
| 606 | |
|
| 607 | 0 | return isRecipientInGraph; |
| 608 | |
} |
| 609 | |
|
| 610 | |
public boolean isGroupRequest(){ |
| 611 | 0 | return RecipientType.GROUP.getCode().equals(getRecipientTypeCd()); |
| 612 | |
} |
| 613 | |
|
| 614 | |
public boolean isRoleRequest() { |
| 615 | 0 | return RecipientType.ROLE.getCode().equals(getRecipientTypeCd()); |
| 616 | |
} |
| 617 | |
|
| 618 | |
public boolean isAcknowledgeRequest() { |
| 619 | 0 | return KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ.equals(getActionRequested()); |
| 620 | |
} |
| 621 | |
|
| 622 | |
public boolean isApproveRequest() { |
| 623 | 0 | return KewApiConstants.ACTION_REQUEST_APPROVE_REQ.equals(getActionRequested()); |
| 624 | |
} |
| 625 | |
|
| 626 | |
public boolean isCompleteRequst() { |
| 627 | 0 | return KewApiConstants.ACTION_REQUEST_COMPLETE_REQ.equals(getActionRequested()); |
| 628 | |
} |
| 629 | |
|
| 630 | |
public boolean isFYIRequest() { |
| 631 | 0 | return KewApiConstants.ACTION_REQUEST_FYI_REQ.equals(getActionRequested()); |
| 632 | |
} |
| 633 | |
|
| 634 | |
|
| 635 | |
|
| 636 | |
|
| 637 | |
|
| 638 | |
|
| 639 | |
|
| 640 | |
|
| 641 | |
|
| 642 | |
public static int compareActionCode(String code1, String code2, boolean completeAndApproveTheSame) { |
| 643 | 0 | int cutoff = Integer.MAX_VALUE; |
| 644 | 0 | if (completeAndApproveTheSame) { |
| 645 | |
|
| 646 | 0 | cutoff = ACTION_CODE_RANK.length() - 3; |
| 647 | |
} |
| 648 | 0 | Integer code1Index = Math.min(ACTION_CODE_RANK.indexOf(code1), cutoff); |
| 649 | 0 | Integer code2Index = Math.min(ACTION_CODE_RANK.indexOf(code2), cutoff); |
| 650 | 0 | return code1Index.compareTo(code2Index); |
| 651 | |
} |
| 652 | |
|
| 653 | |
|
| 654 | |
|
| 655 | |
|
| 656 | |
|
| 657 | |
|
| 658 | |
|
| 659 | |
|
| 660 | |
public static int compareRecipientType(String type1, String type2) { |
| 661 | 0 | Integer type1Index = RECIPIENT_TYPE_RANK.indexOf(type1); |
| 662 | 0 | Integer type2Index = RECIPIENT_TYPE_RANK.indexOf(type2); |
| 663 | 0 | return type1Index.compareTo(type2Index); |
| 664 | |
} |
| 665 | |
|
| 666 | |
public static int compareDelegationType(DelegationType type1, DelegationType type2) { |
| 667 | 0 | Integer type1Index = DELEGATION_TYPE_RANK.indexOf(type1); |
| 668 | 0 | Integer type2Index = DELEGATION_TYPE_RANK.indexOf(type2); |
| 669 | 0 | return type1Index.compareTo(type2Index); |
| 670 | |
} |
| 671 | |
|
| 672 | |
public List<ActionItem> getActionItems() { |
| 673 | 0 | if (this.simulatedActionItems == null || this.simulatedActionItems.isEmpty()) { |
| 674 | 0 | return (List<ActionItem>) KEWServiceLocator.getActionListService().findByActionRequestId(actionRequestId); |
| 675 | |
} else { |
| 676 | 0 | return this.simulatedActionItems; |
| 677 | |
} |
| 678 | |
} |
| 679 | |
|
| 680 | |
public List<ActionItem> getSimulatedActionItems() { |
| 681 | 0 | if (this.simulatedActionItems == null) { |
| 682 | 0 | this.simulatedActionItems = new ArrayList<ActionItem>(); |
| 683 | |
} |
| 684 | 0 | return this.simulatedActionItems; |
| 685 | |
} |
| 686 | |
|
| 687 | |
public void setSimulatedActionItems(List<ActionItem> simulatedActionItems) { |
| 688 | 0 | this.simulatedActionItems = simulatedActionItems; |
| 689 | 0 | } |
| 690 | |
|
| 691 | |
public Boolean getCurrentIndicator() { |
| 692 | 0 | return currentIndicator; |
| 693 | |
} |
| 694 | |
|
| 695 | |
public void setCurrentIndicator(Boolean currentIndicator) { |
| 696 | 0 | this.currentIndicator = currentIndicator; |
| 697 | 0 | } |
| 698 | |
|
| 699 | |
public String getParentActionRequestId() { |
| 700 | 0 | return parentActionRequestId; |
| 701 | |
} |
| 702 | |
|
| 703 | |
public void setParentActionRequestId(String parentActionRequestId) { |
| 704 | 0 | this.parentActionRequestId = parentActionRequestId; |
| 705 | 0 | } |
| 706 | |
|
| 707 | |
public ActionRequestValue getParentActionRequest() { |
| 708 | 0 | return parentActionRequest; |
| 709 | |
} |
| 710 | |
|
| 711 | |
public void setParentActionRequest(ActionRequestValue parentActionRequest) { |
| 712 | 0 | this.parentActionRequest = parentActionRequest; |
| 713 | 0 | } |
| 714 | |
|
| 715 | |
public List<ActionRequestValue> getChildrenRequests() { |
| 716 | 0 | return childrenRequests; |
| 717 | |
} |
| 718 | |
|
| 719 | |
public void setChildrenRequests(List<ActionRequestValue> childrenRequests) { |
| 720 | 0 | this.childrenRequests = childrenRequests; |
| 721 | 0 | } |
| 722 | |
|
| 723 | |
public String getQualifiedRoleName() { |
| 724 | 0 | return qualifiedRoleName; |
| 725 | |
} |
| 726 | |
|
| 727 | |
public void setQualifiedRoleName(String roleName) { |
| 728 | 0 | this.qualifiedRoleName = roleName; |
| 729 | 0 | } |
| 730 | |
|
| 731 | |
public DelegationType getDelegationType() { |
| 732 | 0 | return DelegationType.fromCode(delegationTypeCode); |
| 733 | |
} |
| 734 | |
|
| 735 | |
public void setDelegationType(DelegationType delegationPolicy) { |
| 736 | 0 | this.delegationTypeCode = delegationPolicy == null ? null : delegationPolicy.getCode(); |
| 737 | 0 | } |
| 738 | |
|
| 739 | |
|
| 740 | |
public String getDelegationTypeCode() { |
| 741 | 0 | return delegationTypeCode; |
| 742 | |
} |
| 743 | |
|
| 744 | |
public void setDelegationTypeCode(String delegationTypeCode) { |
| 745 | 0 | this.delegationTypeCode = delegationTypeCode; |
| 746 | 0 | } |
| 747 | |
|
| 748 | |
public String getRoleName() { |
| 749 | 0 | return roleName; |
| 750 | |
} |
| 751 | |
|
| 752 | |
public void setRoleName(String roleName) { |
| 753 | 0 | this.roleName = roleName; |
| 754 | 0 | } |
| 755 | |
|
| 756 | |
public String getApprovePolicy() { |
| 757 | 0 | return approvePolicy; |
| 758 | |
} |
| 759 | |
|
| 760 | |
public void setApprovePolicy(String requestType) { |
| 761 | 0 | this.approvePolicy = requestType; |
| 762 | 0 | } |
| 763 | |
|
| 764 | |
public boolean getHasApprovePolicy() { |
| 765 | 0 | return getApprovePolicy() != null; |
| 766 | |
} |
| 767 | |
|
| 768 | |
public boolean isDeactivated() { |
| 769 | 0 | return ActionRequestStatus.DONE.getCode().equals(getStatus()); |
| 770 | |
} |
| 771 | |
|
| 772 | |
public boolean hasParent() { |
| 773 | 0 | return getParentActionRequest() != null; |
| 774 | |
} |
| 775 | |
|
| 776 | |
public boolean hasChild(ActionRequestValue actionRequest) { |
| 777 | 0 | if (actionRequest == null) |
| 778 | 0 | return false; |
| 779 | 0 | String actionRequestId = actionRequest.getActionRequestId(); |
| 780 | 0 | for (Iterator<ActionRequestValue> iter = getChildrenRequests().iterator(); iter.hasNext();) { |
| 781 | 0 | ActionRequestValue childRequest = iter.next(); |
| 782 | 0 | if (childRequest.equals(actionRequest) || (actionRequestId != null && actionRequestId.equals(childRequest.getActionRequestId()))) { |
| 783 | 0 | return true; |
| 784 | |
} |
| 785 | 0 | } |
| 786 | 0 | return false; |
| 787 | |
} |
| 788 | |
|
| 789 | |
public String getDisplayStatus() { |
| 790 | 0 | return displayStatus; |
| 791 | |
} |
| 792 | |
|
| 793 | |
public void setDisplayStatus(String displayStatus) { |
| 794 | 0 | this.displayStatus = displayStatus; |
| 795 | 0 | } |
| 796 | |
|
| 797 | |
public String getQualifiedRoleNameLabel() { |
| 798 | 0 | return qualifiedRoleNameLabel; |
| 799 | |
} |
| 800 | |
|
| 801 | |
public void setQualifiedRoleNameLabel(String qualifiedRoleNameLabel) { |
| 802 | 0 | this.qualifiedRoleNameLabel = qualifiedRoleNameLabel; |
| 803 | 0 | } |
| 804 | |
|
| 805 | |
public String getCreateDateString() { |
| 806 | 0 | if (createDateString == null || createDateString.trim().equals("")) { |
| 807 | 0 | return RiceConstants.getDefaultDateFormat().format(getCreateDate()); |
| 808 | |
} else { |
| 809 | 0 | return createDateString; |
| 810 | |
} |
| 811 | |
} |
| 812 | |
|
| 813 | |
public void setCreateDateString(String createDateString) { |
| 814 | 0 | this.createDateString = createDateString; |
| 815 | 0 | } |
| 816 | |
|
| 817 | |
public RouteNodeInstance getNodeInstance() { |
| 818 | 0 | return nodeInstance; |
| 819 | |
} |
| 820 | |
|
| 821 | |
public String getPotentialNodeName() { |
| 822 | 0 | return (getNodeInstance() == null ? "" : getNodeInstance().getName()); |
| 823 | |
} |
| 824 | |
|
| 825 | |
public void setNodeInstance(RouteNodeInstance nodeInstance) { |
| 826 | 0 | this.nodeInstance = nodeInstance; |
| 827 | 0 | } |
| 828 | |
|
| 829 | |
public String getRecipientTypeLabel() { |
| 830 | 0 | return RecipientType.fromCode(getRecipientTypeCd()).getLabel(); |
| 831 | |
} |
| 832 | |
|
| 833 | |
public RuleBaseValues getRuleBaseValues(){ |
| 834 | 0 | if(ruleBaseValuesId != null){ |
| 835 | 0 | return getRuleService().findRuleBaseValuesById(ruleBaseValuesId); |
| 836 | |
} |
| 837 | 0 | return null; |
| 838 | |
} |
| 839 | |
public String getRuleBaseValuesId() { |
| 840 | 0 | return ruleBaseValuesId; |
| 841 | |
} |
| 842 | |
|
| 843 | |
public void setRuleBaseValuesId(String ruleBaseValuesId) { |
| 844 | 0 | this.ruleBaseValuesId = ruleBaseValuesId; |
| 845 | 0 | } |
| 846 | |
|
| 847 | |
private RuleServiceInternal getRuleService() { |
| 848 | 0 | return (RuleServiceInternal) KEWServiceLocator.getService(KEWServiceLocator.RULE_SERVICE); |
| 849 | |
} |
| 850 | |
|
| 851 | |
public boolean isPrimaryDelegator() { |
| 852 | 0 | boolean primaryDelegator = false; |
| 853 | 0 | for (Iterator<ActionRequestValue> iter = childrenRequests.iterator(); iter.hasNext();) { |
| 854 | 0 | ActionRequestValue childRequest = iter.next(); |
| 855 | 0 | primaryDelegator = DelegationType.PRIMARY.equals(childRequest.getDelegationType()) || primaryDelegator; |
| 856 | 0 | } |
| 857 | 0 | return primaryDelegator; |
| 858 | |
} |
| 859 | |
|
| 860 | |
|
| 861 | |
|
| 862 | |
|
| 863 | |
|
| 864 | |
|
| 865 | |
|
| 866 | |
|
| 867 | |
public List<ActionRequestValue> getPrimaryDelegateRequests() { |
| 868 | 0 | List<ActionRequestValue> primaryDelegateRequests = new ArrayList<ActionRequestValue>(); |
| 869 | 0 | for (ActionRequestValue childRequest : childrenRequests) |
| 870 | |
{ |
| 871 | 0 | if (DelegationType.PRIMARY.equals(childRequest.getDelegationType())) |
| 872 | |
{ |
| 873 | 0 | if (childRequest.isRoleRequest()) |
| 874 | |
{ |
| 875 | 0 | for (ActionRequestValue actionRequestValue : childRequest.getChildrenRequests()) |
| 876 | |
{ |
| 877 | 0 | primaryDelegateRequests.add(actionRequestValue); |
| 878 | |
} |
| 879 | |
} else |
| 880 | |
{ |
| 881 | 0 | primaryDelegateRequests.add(childRequest); |
| 882 | |
} |
| 883 | |
} |
| 884 | |
} |
| 885 | 0 | return primaryDelegateRequests; |
| 886 | |
} |
| 887 | |
|
| 888 | |
public boolean isAdHocRequest() { |
| 889 | 0 | return KewApiConstants.ADHOC_REQUEST_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 890 | |
} |
| 891 | |
|
| 892 | |
public boolean isGeneratedRequest() { |
| 893 | 0 | return KewApiConstants.MACHINE_GENERATED_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 894 | |
} |
| 895 | |
|
| 896 | |
public boolean isExceptionRequest() { |
| 897 | 0 | return KewApiConstants.EXCEPTION_REQUEST_RESPONSIBILITY_ID.equals(getResponsibilityId()); |
| 898 | |
} |
| 899 | |
|
| 900 | |
public boolean isRouteModuleRequest() { |
| 901 | |
|
| 902 | |
|
| 903 | |
|
| 904 | 0 | return getResponsibilityId() != null && !KewApiConstants.SPECIAL_RESPONSIBILITY_ID_SET.contains(getResponsibilityId()); |
| 905 | |
} |
| 906 | |
|
| 907 | |
public String toString() { |
| 908 | 0 | return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) |
| 909 | |
.append("actionRequestId", actionRequestId) |
| 910 | |
.append("actionRequested", actionRequested) |
| 911 | |
.append("documentId", documentId) |
| 912 | |
.append("status", status) |
| 913 | |
.append("responsibilityId", responsibilityId) |
| 914 | |
.append("groupId", groupId) |
| 915 | |
.append("recipientTypeCd", recipientTypeCd) |
| 916 | |
.append("priority", priority) |
| 917 | |
.append("routeLevel", routeLevel) |
| 918 | |
.append("actionTakenId", actionTakenId) |
| 919 | |
.append("docVersion", docVersion) |
| 920 | |
.append("createDate", createDate) |
| 921 | |
.append("responsibilityDesc", responsibilityDesc) |
| 922 | |
.append("annotation", annotation) |
| 923 | |
.append("jrfVerNbr", jrfVerNbr) |
| 924 | |
.append("principalId", principalId) |
| 925 | |
.append("forceAction", forceAction) |
| 926 | |
.append("parentActionRequestId", parentActionRequestId) |
| 927 | |
.append("qualifiedRoleName", qualifiedRoleName) |
| 928 | |
.append("roleName", roleName) |
| 929 | |
.append("qualifiedRoleNameLabel", qualifiedRoleNameLabel) |
| 930 | |
.append("displayStatus", displayStatus) |
| 931 | |
.append("ruleBaseValuesId", ruleBaseValuesId) |
| 932 | |
.append("delegationType", delegationTypeCode) |
| 933 | |
.append("approvePolicy", approvePolicy) |
| 934 | |
.append("childrenRequests", childrenRequests == null ? null : childrenRequests.size()) |
| 935 | |
.append("actionTaken", actionTaken) |
| 936 | |
.append("currentIndicator", currentIndicator) |
| 937 | |
.append("createDateString", createDateString) |
| 938 | |
.append("nodeInstance", nodeInstance).toString(); |
| 939 | |
} |
| 940 | |
|
| 941 | |
public String getRequestLabel() { |
| 942 | 0 | return this.requestLabel; |
| 943 | |
} |
| 944 | |
|
| 945 | |
public void setRequestLabel(String requestLabel) { |
| 946 | 0 | this.requestLabel = requestLabel; |
| 947 | 0 | } |
| 948 | |
|
| 949 | |
public String getGroupName() { |
| 950 | 0 | return KimApiServiceLocator.getGroupService().getGroup(this.groupId).getName(); |
| 951 | |
} |
| 952 | |
|
| 953 | |
|
| 954 | |
|
| 955 | |
|
| 956 | |
public boolean getResolveResponsibility() { |
| 957 | 0 | return this.resolveResponsibility; |
| 958 | |
} |
| 959 | |
|
| 960 | |
|
| 961 | |
|
| 962 | |
|
| 963 | |
public void setResolveResponsibility(boolean resolveResponsibility) { |
| 964 | 0 | this.resolveResponsibility = resolveResponsibility; |
| 965 | 0 | } |
| 966 | |
|
| 967 | |
public DocumentRouteHeaderValue getRouteHeader() { |
| 968 | 0 | if (this.routeHeader == null && this.documentId != null) { |
| 969 | 0 | this.routeHeader = KEWServiceLocator.getRouteHeaderService().getRouteHeader(this.documentId); |
| 970 | |
} |
| 971 | 0 | return this.routeHeader; |
| 972 | |
} |
| 973 | |
|
| 974 | |
public void setRouteHeader(DocumentRouteHeaderValue routeHeader) { |
| 975 | 0 | this.routeHeader = routeHeader; |
| 976 | 0 | } |
| 977 | |
|
| 978 | |
public static ActionRequest to(ActionRequestValue actionRequestBo) { |
| 979 | 0 | if (actionRequestBo == null) { |
| 980 | 0 | return null; |
| 981 | |
} |
| 982 | 0 | return createActionRequestBuilder(actionRequestBo).build(); |
| 983 | |
} |
| 984 | |
|
| 985 | |
private static ActionRequest.Builder createActionRequestBuilder(ActionRequestValue actionRequestBo) { |
| 986 | 0 | ActionRequest.Builder builder = ActionRequest.Builder.create(actionRequestBo.getActionRequestId(), |
| 987 | |
ActionRequestType.fromCode(actionRequestBo.getActionRequested()), |
| 988 | |
ActionRequestStatus.fromCode(actionRequestBo.getStatus()), |
| 989 | |
actionRequestBo.getResponsibilityId(), |
| 990 | |
actionRequestBo.getDocumentId(), |
| 991 | |
RecipientType.fromCode(actionRequestBo.getRecipientTypeCd())); |
| 992 | 0 | if (actionRequestBo.getActionTaken() != null) { |
| 993 | 0 | builder.setActionTaken(ActionTaken.Builder.create(ActionTakenValue.to(actionRequestBo.getActionTaken()))); |
| 994 | |
} |
| 995 | 0 | builder.setAnnotation(actionRequestBo.getAnnotation()); |
| 996 | 0 | builder.setCurrent(actionRequestBo.getCurrentIndicator().booleanValue()); |
| 997 | 0 | builder.setDateCreated(new DateTime(actionRequestBo.getCreateDate().getTime())); |
| 998 | 0 | if (actionRequestBo.getDelegationType() != null) { |
| 999 | 0 | builder.setDelegationType(actionRequestBo.getDelegationType()); |
| 1000 | |
} |
| 1001 | 0 | builder.setForceAction(actionRequestBo.getForceAction().booleanValue()); |
| 1002 | 0 | builder.setGroupId(actionRequestBo.getGroupId()); |
| 1003 | 0 | builder.setNodeName(actionRequestBo.getPotentialNodeName()); |
| 1004 | 0 | if (actionRequestBo.getParentActionRequestId() != null) { |
| 1005 | 0 | builder.setParentActionRequestId(actionRequestBo.getParentActionRequestId()); |
| 1006 | |
} |
| 1007 | 0 | builder.setPrincipalId(actionRequestBo.getPrincipalId()); |
| 1008 | 0 | if (actionRequestBo.getPriority() == null) { |
| 1009 | 0 | builder.setPriority(KewApiConstants.ACTION_REQUEST_DEFAULT_PRIORITY); |
| 1010 | |
} else { |
| 1011 | 0 | builder.setPriority(actionRequestBo.getPriority().intValue()); |
| 1012 | |
} |
| 1013 | 0 | if (actionRequestBo.getRouteLevel() == null ) { |
| 1014 | 0 | builder.setRouteLevel(0); |
| 1015 | |
} else { |
| 1016 | 0 | builder.setRouteLevel(actionRequestBo.getRouteLevel().intValue()); |
| 1017 | |
} |
| 1018 | 0 | builder.setQualifiedRoleName(actionRequestBo.getQualifiedRoleName()); |
| 1019 | 0 | builder.setQualifiedRoleNameLabel(actionRequestBo.getQualifiedRoleNameLabel()); |
| 1020 | 0 | builder.setRequestLabel(actionRequestBo.getRequestLabel()); |
| 1021 | 0 | if (!StringUtils.isBlank(actionRequestBo.getApprovePolicy())) { |
| 1022 | 0 | builder.setRequestPolicy(ActionRequestPolicy.fromCode(actionRequestBo.getApprovePolicy())); |
| 1023 | |
} |
| 1024 | 0 | builder.setResponsibilityDescription(actionRequestBo.getResponsibilityDesc()); |
| 1025 | 0 | builder.setRoleName(actionRequestBo.getRoleName()); |
| 1026 | 0 | if (actionRequestBo.getNodeInstance() != null) { |
| 1027 | 0 | builder.setRouteNodeInstanceId(actionRequestBo.getNodeInstance().getRouteNodeInstanceId()); |
| 1028 | |
} |
| 1029 | |
|
| 1030 | 0 | List<ActionRequest.Builder> childRequests = new ArrayList<ActionRequest.Builder>(); |
| 1031 | 0 | if (actionRequestBo.getChildrenRequests() != null) { |
| 1032 | 0 | for (ActionRequestValue childActionRequestBo : actionRequestBo.getChildrenRequests()) { |
| 1033 | 0 | childRequests.add(createActionRequestBuilder(childActionRequestBo)); |
| 1034 | |
} |
| 1035 | |
} |
| 1036 | 0 | builder.setChildRequests(childRequests); |
| 1037 | 0 | return builder; |
| 1038 | |
} |
| 1039 | |
|
| 1040 | |
|
| 1041 | |
|
| 1042 | |
|
| 1043 | |
|
| 1044 | |
|
| 1045 | |
|
| 1046 | |
|
| 1047 | |
|
| 1048 | |
|
| 1049 | |
|
| 1050 | |
public static ActionRequestValue from(ActionRequest actionRequest) { |
| 1051 | 0 | return ActionRequestValue.from(actionRequest, null); |
| 1052 | |
} |
| 1053 | |
|
| 1054 | |
|
| 1055 | |
|
| 1056 | |
|
| 1057 | |
|
| 1058 | |
|
| 1059 | |
|
| 1060 | |
public static ActionRequestValue from(ActionRequest actionRequest, |
| 1061 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
| 1062 | 0 | return convertActionRequest(actionRequest, null, routeNodeInstanceLoader); |
| 1063 | |
} |
| 1064 | |
|
| 1065 | |
private static ActionRequestValue convertActionRequest(ActionRequest actionRequest, ActionRequestValue parentActionRequestBo, |
| 1066 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
| 1067 | 0 | if (actionRequest == null) { |
| 1068 | 0 | return null; |
| 1069 | |
} |
| 1070 | 0 | ActionRequestValue actionRequestBo = new ActionRequestFactory().createBlankActionRequest(); |
| 1071 | 0 | populateActionRequest(actionRequestBo, actionRequest, routeNodeInstanceLoader); |
| 1072 | 0 | if (parentActionRequestBo != null) { |
| 1073 | 0 | actionRequestBo.setParentActionRequest(parentActionRequestBo); |
| 1074 | 0 | actionRequestBo.setParentActionRequestId(parentActionRequestBo.getActionRequestId()); |
| 1075 | |
} |
| 1076 | 0 | if (actionRequest.getChildRequests() != null) { |
| 1077 | 0 | for (ActionRequest childRequest : actionRequest.getChildRequests()) { |
| 1078 | 0 | actionRequestBo.getChildrenRequests().add(ActionRequestValue.convertActionRequest(childRequest, actionRequestBo, routeNodeInstanceLoader)); |
| 1079 | |
} |
| 1080 | |
} |
| 1081 | 0 | return actionRequestBo; |
| 1082 | |
} |
| 1083 | |
|
| 1084 | |
|
| 1085 | |
|
| 1086 | |
|
| 1087 | |
private static void populateActionRequest(ActionRequestValue actionRequestBo, ActionRequest actionRequest, |
| 1088 | |
RouteNodeInstanceLoader routeNodeInstanceLoader) { |
| 1089 | |
|
| 1090 | 0 | actionRequestBo.setActionRequested(actionRequest.getActionRequested().getCode()); |
| 1091 | 0 | if (!StringUtils.isBlank(actionRequest.getId())) { |
| 1092 | 0 | actionRequestBo.setActionRequestId(actionRequest.getId()); |
| 1093 | |
} |
| 1094 | |
|
| 1095 | 0 | if (actionRequest.getActionTaken() != null) { |
| 1096 | |
|
| 1097 | 0 | if (!StringUtils.isBlank(actionRequest.getActionTaken().getId())) { |
| 1098 | 0 | actionRequestBo.setActionTakenId(actionRequest.getActionTaken().getId()); |
| 1099 | |
} |
| 1100 | |
} |
| 1101 | 0 | actionRequestBo.setAnnotation(actionRequest.getAnnotation()); |
| 1102 | 0 | if (actionRequest.getRequestPolicy() != null) { |
| 1103 | 0 | actionRequestBo.setApprovePolicy(actionRequest.getRequestPolicy().getCode()); |
| 1104 | |
} |
| 1105 | 0 | actionRequestBo.setCreateDate(new Timestamp(actionRequest.getDateCreated().getMillis())); |
| 1106 | 0 | actionRequestBo.setCurrentIndicator(actionRequest.isCurrent()); |
| 1107 | 0 | if (actionRequest.getDelegationType() != null) { |
| 1108 | 0 | actionRequestBo.setDelegationType(actionRequest.getDelegationType()); |
| 1109 | |
} |
| 1110 | |
|
| 1111 | 0 | actionRequestBo.setForceAction(actionRequest.isForceAction()); |
| 1112 | 0 | actionRequestBo.setPriority(actionRequest.getPriority()); |
| 1113 | 0 | actionRequestBo.setRouteLevel(actionRequest.getRouteLevel()); |
| 1114 | 0 | actionRequestBo.setQualifiedRoleName(actionRequest.getQualifiedRoleName()); |
| 1115 | 0 | actionRequestBo.setQualifiedRoleNameLabel(actionRequest.getQualifiedRoleNameLabel()); |
| 1116 | 0 | actionRequestBo.setRecipientTypeCd(actionRequest.getRecipientType().getCode()); |
| 1117 | 0 | actionRequestBo.setResponsibilityDesc(actionRequest.getResponsibilityDescription()); |
| 1118 | 0 | if (!StringUtils.isBlank(actionRequest.getResponsibilityId())) { |
| 1119 | 0 | actionRequestBo.setResponsibilityId(actionRequest.getResponsibilityId()); |
| 1120 | |
} |
| 1121 | 0 | actionRequestBo.setRoleName(actionRequest.getRoleName()); |
| 1122 | 0 | String documentId = actionRequest.getDocumentId(); |
| 1123 | 0 | if (documentId != null) { |
| 1124 | 0 | actionRequestBo.setDocumentId(documentId); |
| 1125 | 0 | actionRequestBo.setRouteHeader(KEWServiceLocator.getRouteHeaderService().getRouteHeader(documentId)); |
| 1126 | |
} |
| 1127 | |
|
| 1128 | 0 | actionRequestBo.setStatus(actionRequest.getStatus().getCode()); |
| 1129 | 0 | actionRequestBo.setPrincipalId(actionRequest.getPrincipalId()); |
| 1130 | 0 | actionRequestBo.setGroupId(actionRequest.getGroupId()); |
| 1131 | |
|
| 1132 | 0 | if (routeNodeInstanceLoader != null && !StringUtils.isBlank(actionRequest.getRouteNodeInstanceId())) { |
| 1133 | 0 | actionRequestBo.setNodeInstance(routeNodeInstanceLoader.load(actionRequest.getRouteNodeInstanceId())); |
| 1134 | |
} |
| 1135 | 0 | } |
| 1136 | |
|
| 1137 | |
} |