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