1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kew.actionitem; |
18 | |
|
19 | |
import java.sql.Timestamp; |
20 | |
import java.util.HashMap; |
21 | |
import java.util.Map; |
22 | |
|
23 | |
import javax.persistence.Column; |
24 | |
import javax.persistence.Entity; |
25 | |
import javax.persistence.FetchType; |
26 | |
import javax.persistence.Id; |
27 | |
import javax.persistence.JoinColumn; |
28 | |
import javax.persistence.ManyToOne; |
29 | |
import javax.persistence.NamedQueries; |
30 | |
import javax.persistence.NamedQuery; |
31 | |
import javax.persistence.PrePersist; |
32 | |
import javax.persistence.Table; |
33 | |
import javax.persistence.Transient; |
34 | |
import javax.persistence.Version; |
35 | |
|
36 | |
import org.apache.commons.beanutils.BeanUtils; |
37 | |
import org.apache.commons.lang.StringUtils; |
38 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
39 | |
import org.kuali.rice.core.jpa.annotations.Sequence; |
40 | |
import org.kuali.rice.core.util.OrmUtils; |
41 | |
import org.kuali.rice.core.util.RiceConstants; |
42 | |
import org.kuali.rice.kew.bo.WorkflowPersistable; |
43 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
44 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
45 | |
import org.kuali.rice.kew.util.CodeTranslator; |
46 | |
import org.kuali.rice.kew.util.KEWConstants; |
47 | |
import org.kuali.rice.kew.web.RowStyleable; |
48 | |
import org.kuali.rice.kim.bo.Group; |
49 | |
import org.kuali.rice.kim.bo.Person; |
50 | |
import org.kuali.rice.kim.bo.entity.KimPrincipal; |
51 | |
import org.kuali.rice.kim.service.KIMServiceLocator; |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
@Entity |
66 | |
|
67 | |
@Table(name="KREW_ACTN_ITM_T") |
68 | |
@Sequence(name="KREW_ACTN_ITM_S",property="actionItemId") |
69 | |
@NamedQueries({ |
70 | |
@NamedQuery(name="ActionItem.QuickLinks.FindActionListStatsByPrincipalId", query="SELECT docName, COUNT(*) FROM ActionItem WHERE principalId = :principalId " + |
71 | |
"AND (delegationType IS null OR delegationType != '" + KEWConstants.DELEGATION_SECONDARY + "') GROUP BY docName") |
72 | |
}) |
73 | 0 | public class ActionItem implements WorkflowPersistable, RowStyleable { |
74 | |
|
75 | |
private static final long serialVersionUID = -1079562205125660151L; |
76 | |
|
77 | |
@Id |
78 | |
@Column(name="ACTN_ITM_ID") |
79 | |
private Long actionItemId; |
80 | |
@Column(name="PRNCPL_ID") |
81 | |
private String principalId; |
82 | |
@Column(name="ASND_DT") |
83 | |
private Timestamp dateAssigned; |
84 | |
@Column(name="RQST_CD") |
85 | |
private String actionRequestCd; |
86 | |
@Column(name="ACTN_RQST_ID", nullable=false) |
87 | |
private Long actionRequestId; |
88 | |
@Column(name="DOC_HDR_ID", insertable=false, updatable=false) |
89 | |
private Long routeHeaderId; |
90 | |
@Column(name="GRP_ID") |
91 | |
private String groupId; |
92 | |
@Column(name="DOC_HDR_TTL") |
93 | |
private String docTitle; |
94 | |
@Column(name="DOC_TYP_LBL") |
95 | |
private String docLabel; |
96 | |
@Column(name="DOC_HDLR_URL") |
97 | |
private String docHandlerURL; |
98 | |
@Version |
99 | |
@Column(name="VER_NBR") |
100 | |
private Integer lockVerNbr; |
101 | |
@Column(name="DOC_TYP_NM") |
102 | |
private String docName; |
103 | 0 | @Column(name="RSP_ID") |
104 | |
private Long responsibilityId = new Long(1); |
105 | |
@Column(name="ROLE_NM") |
106 | |
private String roleName; |
107 | |
@Column(name="DLGN_PRNCPL_ID") |
108 | |
private String delegatorWorkflowId; |
109 | |
@Column(name="DLGN_GRP_ID") |
110 | |
private String delegatorGroupId; |
111 | |
@Column(name="DLGN_TYP") |
112 | |
private String delegationType; |
113 | |
@Column(name="RQST_LBL") |
114 | |
private String requestLabel; |
115 | |
|
116 | |
private transient DocumentRouteHeaderValue routeHeader; |
117 | |
|
118 | |
@Transient |
119 | |
private Timestamp lastApprovedDate; |
120 | |
@Transient |
121 | |
private Integer actionItemIndex; |
122 | 0 | @Transient |
123 | |
private Map customActions = new HashMap(); |
124 | |
@Transient |
125 | |
private String dateAssignedString; |
126 | |
@Transient |
127 | |
private String actionToTake; |
128 | |
@Transient |
129 | |
private String rowStyleClass; |
130 | |
|
131 | |
|
132 | |
@PrePersist |
133 | |
public void beforeInsert(){ |
134 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
135 | 0 | } |
136 | |
|
137 | |
@Id |
138 | |
@Column(name="ACTN_ITM_ID") |
139 | |
public Long getActionItemId() { |
140 | 0 | return actionItemId; |
141 | |
} |
142 | |
|
143 | |
@Column(name="PRNCPL_ID") |
144 | |
public String getPrincipalId() { |
145 | 0 | return principalId; |
146 | |
} |
147 | |
|
148 | |
@Column(name="ASND_DT") |
149 | |
public Timestamp getDateAssigned() { |
150 | 0 | return dateAssigned; |
151 | |
} |
152 | |
|
153 | |
@Column(name="RQST_CD") |
154 | |
public String getActionRequestCd() { |
155 | 0 | return actionRequestCd; |
156 | |
} |
157 | |
|
158 | |
@Column(name="ACTN_RQST_ID", nullable=false) |
159 | |
public Long getActionRequestId() { |
160 | 0 | return actionRequestId; |
161 | |
} |
162 | |
|
163 | |
@Column(name="DOC_HDR_ID", insertable=false, updatable=false) |
164 | |
public Long getRouteHeaderId() { |
165 | 0 | return routeHeaderId; |
166 | |
} |
167 | |
|
168 | |
@Column(name="GRP_ID") |
169 | |
public String getGroupId() { |
170 | 0 | return groupId; |
171 | |
} |
172 | |
|
173 | |
@Column(name="DOC_HDR_TTL") |
174 | |
public String getDocTitle() { |
175 | 0 | return docTitle; |
176 | |
} |
177 | |
|
178 | |
@Column(name="DOC_TYP_LBL") |
179 | |
public String getDocLabel() { |
180 | 0 | return docLabel; |
181 | |
} |
182 | |
|
183 | |
@Column(name="DOC_HDLR_URL") |
184 | |
public String getDocHandlerURL() { |
185 | 0 | return docHandlerURL; |
186 | |
} |
187 | |
|
188 | |
@Version |
189 | |
@Column(name="VER_NBR") |
190 | |
public Integer getLockVerNbr() { |
191 | 0 | return lockVerNbr; |
192 | |
} |
193 | |
|
194 | |
@Column(name="DOC_TYP_NM") |
195 | |
public String getDocName() { |
196 | 0 | return docName; |
197 | |
} |
198 | |
|
199 | |
@Column(name="RSP_ID") |
200 | |
public Long getResponsibilityId() { |
201 | 0 | return responsibilityId; |
202 | |
} |
203 | |
|
204 | |
@Column(name="ROLE_NM") |
205 | |
public String getRoleName() { |
206 | 0 | return roleName; |
207 | |
} |
208 | |
|
209 | |
@Column(name="DLGN_PRNCPL_ID") |
210 | |
public String getDelegatorWorkflowId() { |
211 | 0 | return delegatorWorkflowId; |
212 | |
} |
213 | |
|
214 | |
@Column(name="DLGN_GRP_ID") |
215 | |
public String getDelegatorGroupId() { |
216 | 0 | return delegatorGroupId; |
217 | |
} |
218 | |
|
219 | |
@Column(name="DLGN_TYP") |
220 | |
public String getDelegationType() { |
221 | 0 | return delegationType; |
222 | |
} |
223 | |
|
224 | |
@Column(name="RQST_LBL") |
225 | |
public String getRequestLabel() { |
226 | 0 | return this.requestLabel; |
227 | |
} |
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
|
233 | |
@Deprecated |
234 | |
@ManyToOne(fetch=FetchType.EAGER) |
235 | |
@JoinColumn(name="DOC_HDR_ID") |
236 | |
public DocumentRouteHeaderValue getRouteHeader() { |
237 | 0 | return routeHeader; |
238 | |
} |
239 | |
|
240 | |
|
241 | |
@Transient |
242 | |
public Timestamp getLastApprovedDate() { |
243 | 0 | return this.lastApprovedDate; |
244 | |
} |
245 | |
|
246 | |
@Transient |
247 | |
public Integer getActionItemIndex() { |
248 | 0 | return actionItemIndex; |
249 | |
} |
250 | |
|
251 | |
@Transient |
252 | |
public Map getCustomActions() { |
253 | 0 | return customActions; |
254 | |
} |
255 | |
|
256 | |
@Transient |
257 | |
public String getDateAssignedString() { |
258 | 0 | if(dateAssignedString == null || dateAssignedString.trim().equals("")){ |
259 | 0 | return RiceConstants.getDefaultDateFormat().format(getDateAssigned()); |
260 | |
} else { |
261 | 0 | return dateAssignedString; |
262 | |
} |
263 | |
} |
264 | |
|
265 | |
@Transient |
266 | |
public String getActionToTake() { |
267 | 0 | return actionToTake; |
268 | |
} |
269 | |
|
270 | |
@Transient |
271 | |
public String getRowStyleClass() { |
272 | 0 | return rowStyleClass; |
273 | |
} |
274 | |
|
275 | |
|
276 | |
private Group getGroup(String groupId) { |
277 | 0 | if( groupId ==null ) return null; |
278 | 0 | return KIMServiceLocator.getIdentityManagementService().getGroup(groupId); |
279 | |
} |
280 | |
|
281 | |
@Transient |
282 | |
public Group getGroup(){ |
283 | 0 | return getGroup(groupId.toString()); |
284 | |
} |
285 | |
|
286 | |
private Person getPerson(String workflowId) { |
287 | 0 | if (StringUtils.isBlank(workflowId)) { |
288 | 0 | return null; |
289 | |
} |
290 | 0 | return KIMServiceLocator.getPersonService().getPerson(workflowId); |
291 | |
} |
292 | |
|
293 | |
@Transient |
294 | |
public Person getPerson() { |
295 | 0 | return getPerson(principalId); |
296 | |
} |
297 | |
|
298 | |
@Transient |
299 | |
public Person getDelegatorPerson() { |
300 | 0 | return getPerson(delegatorWorkflowId); |
301 | |
} |
302 | |
|
303 | |
@Transient |
304 | |
public String getRecipientTypeCode() { |
305 | 0 | String recipientTypeCode = KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD; |
306 | 0 | if (getRoleName() != null) { |
307 | 0 | recipientTypeCode = KEWConstants.ACTION_REQUEST_ROLE_RECIPIENT_CD; |
308 | |
} |
309 | 0 | if (getGroupId() != null) { |
310 | 0 | recipientTypeCode = KEWConstants.ACTION_REQUEST_GROUP_RECIPIENT_CD; |
311 | |
} |
312 | 0 | return recipientTypeCode; |
313 | |
} |
314 | |
|
315 | |
@Transient |
316 | |
public String getActionRequestLabel() { |
317 | 0 | if (StringUtils.isNotBlank(getRequestLabel())) { |
318 | 0 | return getRequestLabel(); |
319 | |
} |
320 | 0 | return CodeTranslator.getActionRequestLabel(getActionRequestCd()); |
321 | |
} |
322 | |
|
323 | |
@Transient |
324 | |
public boolean isWorkgroupItem() { |
325 | 0 | return getGroupId() != null; |
326 | |
} |
327 | |
|
328 | |
@Transient |
329 | |
public KimPrincipal getPrincipal(){ |
330 | 0 | return KIMServiceLocator.getIdentityManagementService().getPrincipal(principalId); |
331 | |
} |
332 | |
|
333 | |
|
334 | |
public Object copy(boolean preserveKeys) { |
335 | 0 | ActionItem clone = new ActionItem(); |
336 | |
try { |
337 | 0 | BeanUtils.copyProperties(clone, this); |
338 | 0 | } catch (Exception e) { |
339 | 0 | throw new RuntimeException(e); |
340 | 0 | } |
341 | |
|
342 | 0 | return clone; |
343 | |
} |
344 | |
|
345 | |
public void setRowStyleClass(String rowStyleClass) { |
346 | 0 | this.rowStyleClass = rowStyleClass; |
347 | 0 | } |
348 | |
|
349 | |
public void setResponsibilityId(Long responsibilityId) { |
350 | 0 | this.responsibilityId = responsibilityId; |
351 | 0 | } |
352 | |
|
353 | |
public void setDocName(String docName) { |
354 | 0 | this.docName = docName; |
355 | 0 | } |
356 | |
|
357 | |
|
358 | |
|
359 | |
|
360 | |
@Deprecated |
361 | |
public void setRouteHeader(DocumentRouteHeaderValue routeHeader) { |
362 | 0 | this.routeHeader = routeHeader; |
363 | 0 | } |
364 | |
|
365 | |
public void setActionRequestCd(String actionRequestCd) { |
366 | 0 | this.actionRequestCd = actionRequestCd; |
367 | 0 | } |
368 | |
|
369 | |
public void setDateAssigned(Timestamp dateAssigned) { |
370 | 0 | this.dateAssigned = dateAssigned; |
371 | 0 | } |
372 | |
|
373 | |
public void setPrincipalId(String principalId) { |
374 | 0 | this.principalId = principalId; |
375 | 0 | } |
376 | |
|
377 | |
public void setLockVerNbr(Integer lockVerNbr) { |
378 | 0 | this.lockVerNbr = lockVerNbr; |
379 | 0 | } |
380 | |
|
381 | |
public void setRouteHeaderId(Long routeHeaderId) { |
382 | 0 | this.routeHeaderId = routeHeaderId; |
383 | 0 | } |
384 | |
|
385 | |
public void setActionItemId(Long actionItemId) { |
386 | 0 | this.actionItemId = actionItemId; |
387 | 0 | } |
388 | |
|
389 | |
public void setActionRequestId(Long actionRequestId) { |
390 | 0 | this.actionRequestId = actionRequestId; |
391 | 0 | } |
392 | |
|
393 | |
public void setDocHandlerURL(String docHandlerURL) { |
394 | 0 | this.docHandlerURL = docHandlerURL; |
395 | 0 | } |
396 | |
|
397 | |
public void setGroupId(String groupId) { |
398 | 0 | this.groupId = groupId; |
399 | 0 | } |
400 | |
|
401 | |
public void setDocLabel(String docLabel) { |
402 | 0 | this.docLabel = docLabel; |
403 | 0 | } |
404 | |
|
405 | |
public void setDocTitle(String docTitle) { |
406 | 0 | this.docTitle = docTitle; |
407 | 0 | } |
408 | |
|
409 | |
public void setRoleName(String roleName) { |
410 | 0 | this.roleName = roleName; |
411 | 0 | } |
412 | |
|
413 | |
public void setDelegatorWorkflowId(String delegatorWorkflowId) { |
414 | 0 | this.delegatorWorkflowId = delegatorWorkflowId; |
415 | 0 | } |
416 | |
|
417 | |
public void setDelegatorGroupId(String delegatorGroupId) { |
418 | 0 | this.delegatorGroupId = delegatorGroupId; |
419 | 0 | } |
420 | |
|
421 | |
public void setDateAssignedString(String dateAssignedString) { |
422 | 0 | this.dateAssignedString = dateAssignedString; |
423 | 0 | } |
424 | |
|
425 | |
public void setActionToTake(String actionToTake) { |
426 | 0 | this.actionToTake = actionToTake; |
427 | 0 | } |
428 | |
|
429 | |
public void setActionItemIndex(Integer actionItemIndex) { |
430 | 0 | this.actionItemIndex = actionItemIndex; |
431 | 0 | } |
432 | |
|
433 | |
public void setCustomActions(Map customActions) { |
434 | 0 | this.customActions = customActions; |
435 | 0 | } |
436 | |
|
437 | |
public void setDelegationType(String delegationType) { |
438 | 0 | this.delegationType = delegationType; |
439 | 0 | } |
440 | |
|
441 | |
|
442 | |
public void setLastApprovedDate(Timestamp lastApprovedDate) { |
443 | 0 | this.lastApprovedDate = lastApprovedDate; |
444 | 0 | } |
445 | |
|
446 | |
public void setRequestLabel(String requestLabel) { |
447 | 0 | this.requestLabel = requestLabel; |
448 | 0 | } |
449 | |
|
450 | |
public String toString() { |
451 | 0 | return new ToStringBuilder(this).append("actionItemId", actionItemId) |
452 | |
.append("workflowId", principalId) |
453 | |
.append("actionItemId", actionItemId) |
454 | |
.append("workflowId", principalId) |
455 | |
.append("dateAssigned", dateAssigned) |
456 | |
.append("actionRequestCd", actionRequestCd) |
457 | |
.append("actionRequestId", actionRequestId) |
458 | |
.append("routeHeaderId", routeHeaderId) |
459 | |
.append("groupId", groupId) |
460 | |
.append("docTitle", docTitle) |
461 | |
.append("docLabel", docLabel) |
462 | |
.append("docHandlerURL", docHandlerURL) |
463 | |
.append("lockVerNbr", lockVerNbr) |
464 | |
.append("docName", docName) |
465 | |
.append("responsibilityId", responsibilityId) |
466 | |
.append("rowStyleClass", rowStyleClass) |
467 | |
.append("roleName", roleName) |
468 | |
.append("delegatorWorkflowId", delegatorWorkflowId) |
469 | |
.append("delegatorGroupId", delegatorGroupId) |
470 | |
.append("dateAssignedString", dateAssignedString) |
471 | |
.append("actionToTake", actionToTake) |
472 | |
.append("delegationType", delegationType) |
473 | |
.append("actionItemIndex", actionItemIndex) |
474 | |
.append("customActions", customActions) |
475 | |
.append("lastApprovedDate", lastApprovedDate) |
476 | |
.toString(); |
477 | |
} |
478 | |
|
479 | |
} |