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 org.apache.commons.lang.StringUtils; |
20 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
21 | |
import org.hibernate.annotations.GenericGenerator; |
22 | |
import org.hibernate.annotations.Parameter; |
23 | |
import org.kuali.rice.core.framework.persistence.jpa.OrmUtils; |
24 | |
import org.kuali.rice.core.util.RiceConstants; |
25 | |
import org.kuali.rice.kew.api.action.RecipientType; |
26 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
27 | |
import org.kuali.rice.kew.util.CodeTranslator; |
28 | |
import org.kuali.rice.kew.web.RowStyleable; |
29 | |
import org.kuali.rice.kim.api.group.Group; |
30 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
31 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
32 | |
import org.kuali.rice.kim.bo.Person; |
33 | |
|
34 | |
import javax.persistence.Column; |
35 | |
import javax.persistence.Entity; |
36 | |
import javax.persistence.GeneratedValue; |
37 | |
import javax.persistence.Id; |
38 | |
import javax.persistence.Inheritance; |
39 | |
import javax.persistence.InheritanceType; |
40 | |
import javax.persistence.NamedQueries; |
41 | |
import javax.persistence.NamedQuery; |
42 | |
import javax.persistence.Table; |
43 | |
import javax.persistence.Transient; |
44 | |
import javax.persistence.Version; |
45 | |
import java.io.Serializable; |
46 | |
import java.sql.Timestamp; |
47 | |
import java.util.HashMap; |
48 | |
import java.util.Map; |
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
@Entity |
63 | |
@Inheritance(strategy=InheritanceType.TABLE_PER_CLASS) |
64 | |
@Table(name="KREW_ACTN_ITM_T") |
65 | |
|
66 | |
@NamedQueries({ |
67 | |
@NamedQuery(name="ActionItem.QuickLinks.FindActionListStatsByPrincipalId", query="SELECT docName, COUNT(*) FROM ActionItem WHERE principalId = :principalId " + |
68 | |
"AND (delegationType IS null OR delegationType != :delegationType) GROUP BY docName") |
69 | |
}) |
70 | 0 | public class ActionItem implements RowStyleable, Serializable { |
71 | |
|
72 | |
private static final long serialVersionUID = -1079562205125660151L; |
73 | |
|
74 | |
@Id |
75 | |
@GeneratedValue(generator="KREW_ACTN_ITM_S") |
76 | |
@GenericGenerator(name="KREW_ACTN_ITM_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={ |
77 | |
@Parameter(name="sequence_name",value="KREW_ACTN_ITM_S"), |
78 | |
@Parameter(name="value_column",value="id") |
79 | |
}) |
80 | |
@Column(name="ACTN_ITM_ID") |
81 | |
private String actionItemId; |
82 | |
@Column(name="PRNCPL_ID") |
83 | |
private String principalId; |
84 | |
@Column(name="ASND_DT") |
85 | |
private Timestamp dateAssigned; |
86 | |
@Column(name="RQST_CD") |
87 | |
private String actionRequestCd; |
88 | |
@Column(name="ACTN_RQST_ID", nullable=false) |
89 | |
private String actionRequestId; |
90 | |
@Column(name="DOC_HDR_ID") |
91 | |
private String documentId; |
92 | |
@Column(name="GRP_ID") |
93 | |
private String groupId; |
94 | |
@Column(name="DOC_HDR_TTL") |
95 | |
private String docTitle; |
96 | |
@Column(name="DOC_TYP_LBL") |
97 | |
private String docLabel; |
98 | |
@Column(name="DOC_HDLR_URL") |
99 | |
private String docHandlerURL; |
100 | |
@Version |
101 | |
@Column(name="VER_NBR") |
102 | |
private Integer lockVerNbr; |
103 | |
@Column(name="DOC_TYP_NM") |
104 | |
private String docName; |
105 | 0 | @Column(name="RSP_ID") |
106 | |
private String responsibilityId = "1"; |
107 | |
@Column(name="ROLE_NM") |
108 | |
private String roleName; |
109 | |
@Column(name="DLGN_PRNCPL_ID") |
110 | |
private String delegatorWorkflowId; |
111 | |
@Column(name="DLGN_GRP_ID") |
112 | |
private String delegatorGroupId; |
113 | |
@Column(name="DLGN_TYP") |
114 | |
private String delegationType; |
115 | |
@Column(name="RQST_LBL") |
116 | |
private String requestLabel; |
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
@Transient |
123 | |
private Timestamp lastApprovedDate; |
124 | |
@Transient |
125 | |
private Integer actionItemIndex; |
126 | 0 | @Transient |
127 | |
private Map customActions = new HashMap(); |
128 | |
@Transient |
129 | |
private String dateAssignedString; |
130 | |
@Transient |
131 | |
private String actionToTake; |
132 | |
@Transient |
133 | |
private String rowStyleClass; |
134 | |
|
135 | |
|
136 | |
|
137 | |
public void beforeInsert(){ |
138 | 0 | OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager()); |
139 | 0 | } |
140 | |
|
141 | |
public String getActionItemId() { |
142 | 0 | return actionItemId; |
143 | |
} |
144 | |
|
145 | |
public String getPrincipalId() { |
146 | 0 | return principalId; |
147 | |
} |
148 | |
|
149 | |
public Timestamp getDateAssigned() { |
150 | 0 | return dateAssigned; |
151 | |
} |
152 | |
|
153 | |
public String getActionRequestCd() { |
154 | 0 | return actionRequestCd; |
155 | |
} |
156 | |
|
157 | |
public String getActionRequestId() { |
158 | 0 | return actionRequestId; |
159 | |
} |
160 | |
|
161 | |
public String getDocumentId() { |
162 | 0 | return documentId; |
163 | |
} |
164 | |
|
165 | |
public String getGroupId() { |
166 | 0 | return groupId; |
167 | |
} |
168 | |
|
169 | |
public String getDocTitle() { |
170 | 0 | return docTitle; |
171 | |
} |
172 | |
|
173 | |
public String getDocLabel() { |
174 | 0 | return docLabel; |
175 | |
} |
176 | |
|
177 | |
public String getDocHandlerURL() { |
178 | 0 | return docHandlerURL; |
179 | |
} |
180 | |
|
181 | |
public Integer getLockVerNbr() { |
182 | 0 | return lockVerNbr; |
183 | |
} |
184 | |
|
185 | |
public String getDocName() { |
186 | 0 | return docName; |
187 | |
} |
188 | |
|
189 | |
public String getResponsibilityId() { |
190 | 0 | return responsibilityId; |
191 | |
} |
192 | |
|
193 | |
public String getRoleName() { |
194 | 0 | return roleName; |
195 | |
} |
196 | |
|
197 | |
public String getDelegatorWorkflowId() { |
198 | 0 | return delegatorWorkflowId; |
199 | |
} |
200 | |
|
201 | |
public String getDelegatorGroupId() { |
202 | 0 | return delegatorGroupId; |
203 | |
} |
204 | |
|
205 | |
public String getDelegationType() { |
206 | 0 | return delegationType; |
207 | |
} |
208 | |
|
209 | |
public String getRequestLabel() { |
210 | 0 | return this.requestLabel; |
211 | |
} |
212 | |
|
213 | |
public Timestamp getLastApprovedDate() { |
214 | 0 | return this.lastApprovedDate; |
215 | |
} |
216 | |
|
217 | |
public Integer getActionItemIndex() { |
218 | 0 | return actionItemIndex; |
219 | |
} |
220 | |
|
221 | |
public Map getCustomActions() { |
222 | 0 | return customActions; |
223 | |
} |
224 | |
|
225 | |
public String getDateAssignedString() { |
226 | 0 | if(dateAssignedString == null || dateAssignedString.trim().equals("")){ |
227 | 0 | return RiceConstants.getDefaultDateFormat().format(getDateAssigned()); |
228 | |
} else { |
229 | 0 | return dateAssignedString; |
230 | |
} |
231 | |
} |
232 | |
|
233 | |
public String getActionToTake() { |
234 | 0 | return actionToTake; |
235 | |
} |
236 | |
|
237 | |
public String getRowStyleClass() { |
238 | 0 | return rowStyleClass; |
239 | |
} |
240 | |
|
241 | |
private Group getGroup(String groupId) { |
242 | 0 | if (StringUtils.isBlank(groupId)) { |
243 | 0 | return null; |
244 | |
} |
245 | 0 | return KimApiServiceLocator.getGroupService().getGroup(groupId); |
246 | |
} |
247 | |
|
248 | |
public Group getGroup(){ |
249 | 0 | return getGroup(groupId); |
250 | |
} |
251 | |
|
252 | |
private Person getPerson(String workflowId) { |
253 | 0 | if (StringUtils.isBlank(workflowId)) { |
254 | 0 | return null; |
255 | |
} |
256 | 0 | return KimApiServiceLocator.getPersonService().getPerson(workflowId); |
257 | |
} |
258 | |
|
259 | |
public Person getPerson() { |
260 | 0 | return getPerson(principalId); |
261 | |
} |
262 | |
|
263 | |
public Person getDelegatorPerson() { |
264 | 0 | return getPerson(delegatorWorkflowId); |
265 | |
} |
266 | |
|
267 | |
public String getRecipientTypeCode() { |
268 | 0 | String recipientTypeCode = RecipientType.PRINCIPAL.getCode(); |
269 | 0 | if (getRoleName() != null) { |
270 | 0 | recipientTypeCode = RecipientType.ROLE.getCode(); |
271 | |
} |
272 | 0 | if (getGroupId() != null) { |
273 | 0 | recipientTypeCode = RecipientType.GROUP.getCode(); |
274 | |
} |
275 | 0 | return recipientTypeCode; |
276 | |
} |
277 | |
|
278 | |
public String getActionRequestLabel() { |
279 | 0 | if (StringUtils.isNotBlank(getRequestLabel())) { |
280 | 0 | return getRequestLabel(); |
281 | |
} |
282 | 0 | return CodeTranslator.getActionRequestLabel(getActionRequestCd()); |
283 | |
} |
284 | |
|
285 | |
public boolean isWorkgroupItem() { |
286 | 0 | return getGroupId() != null; |
287 | |
} |
288 | |
|
289 | |
public Principal getPrincipal(){ |
290 | 0 | return KimApiServiceLocator.getIdentityService().getPrincipal(principalId); |
291 | |
} |
292 | |
|
293 | |
public void setRowStyleClass(String rowStyleClass) { |
294 | 0 | this.rowStyleClass = rowStyleClass; |
295 | 0 | } |
296 | |
|
297 | |
public void setResponsibilityId(String responsibilityId) { |
298 | 0 | this.responsibilityId = responsibilityId; |
299 | 0 | } |
300 | |
|
301 | |
public void setDocName(String docName) { |
302 | 0 | this.docName = docName; |
303 | 0 | } |
304 | |
|
305 | |
public void setActionRequestCd(String actionRequestCd) { |
306 | 0 | this.actionRequestCd = actionRequestCd; |
307 | 0 | } |
308 | |
|
309 | |
public void setDateAssigned(Timestamp dateAssigned) { |
310 | 0 | this.dateAssigned = dateAssigned; |
311 | 0 | } |
312 | |
|
313 | |
public void setPrincipalId(String principalId) { |
314 | 0 | this.principalId = principalId; |
315 | 0 | } |
316 | |
|
317 | |
public void setLockVerNbr(Integer lockVerNbr) { |
318 | 0 | this.lockVerNbr = lockVerNbr; |
319 | 0 | } |
320 | |
|
321 | |
public void setDocumentId(String documentId) { |
322 | 0 | this.documentId = documentId; |
323 | 0 | } |
324 | |
|
325 | |
public void setActionItemId(String actionItemId) { |
326 | 0 | this.actionItemId = actionItemId; |
327 | 0 | } |
328 | |
|
329 | |
public void setActionRequestId(String actionRequestId) { |
330 | 0 | this.actionRequestId = actionRequestId; |
331 | 0 | } |
332 | |
|
333 | |
public void setDocHandlerURL(String docHandlerURL) { |
334 | 0 | this.docHandlerURL = docHandlerURL; |
335 | 0 | } |
336 | |
|
337 | |
public void setGroupId(String groupId) { |
338 | 0 | this.groupId = groupId; |
339 | 0 | } |
340 | |
|
341 | |
public void setDocLabel(String docLabel) { |
342 | 0 | this.docLabel = docLabel; |
343 | 0 | } |
344 | |
|
345 | |
public void setDocTitle(String docTitle) { |
346 | 0 | this.docTitle = docTitle; |
347 | 0 | } |
348 | |
|
349 | |
public void setRoleName(String roleName) { |
350 | 0 | this.roleName = roleName; |
351 | 0 | } |
352 | |
|
353 | |
public void setDelegatorWorkflowId(String delegatorWorkflowId) { |
354 | 0 | this.delegatorWorkflowId = delegatorWorkflowId; |
355 | 0 | } |
356 | |
|
357 | |
public void setDelegatorGroupId(String delegatorGroupId) { |
358 | 0 | this.delegatorGroupId = delegatorGroupId; |
359 | 0 | } |
360 | |
|
361 | |
public void setDateAssignedString(String dateAssignedString) { |
362 | 0 | this.dateAssignedString = dateAssignedString; |
363 | 0 | } |
364 | |
|
365 | |
public void setActionToTake(String actionToTake) { |
366 | 0 | this.actionToTake = actionToTake; |
367 | 0 | } |
368 | |
|
369 | |
public void setActionItemIndex(Integer actionItemIndex) { |
370 | 0 | this.actionItemIndex = actionItemIndex; |
371 | 0 | } |
372 | |
|
373 | |
public void setCustomActions(Map customActions) { |
374 | 0 | this.customActions = customActions; |
375 | 0 | } |
376 | |
|
377 | |
public void setDelegationType(String delegationType) { |
378 | 0 | this.delegationType = delegationType; |
379 | 0 | } |
380 | |
|
381 | |
|
382 | |
public void setLastApprovedDate(Timestamp lastApprovedDate) { |
383 | 0 | this.lastApprovedDate = lastApprovedDate; |
384 | 0 | } |
385 | |
|
386 | |
public void setRequestLabel(String requestLabel) { |
387 | 0 | this.requestLabel = requestLabel; |
388 | 0 | } |
389 | |
|
390 | |
public String toString() { |
391 | 0 | return new ToStringBuilder(this).append("actionItemId", actionItemId) |
392 | |
.append("workflowId", principalId) |
393 | |
.append("actionItemId", actionItemId) |
394 | |
.append("workflowId", principalId) |
395 | |
.append("dateAssigned", dateAssigned) |
396 | |
.append("actionRequestCd", actionRequestCd) |
397 | |
.append("actionRequestId", actionRequestId) |
398 | |
.append("documentId", documentId) |
399 | |
.append("groupId", groupId) |
400 | |
.append("docTitle", docTitle) |
401 | |
.append("docLabel", docLabel) |
402 | |
.append("docHandlerURL", docHandlerURL) |
403 | |
.append("lockVerNbr", lockVerNbr) |
404 | |
.append("docName", docName) |
405 | |
.append("responsibilityId", responsibilityId) |
406 | |
.append("rowStyleClass", rowStyleClass) |
407 | |
.append("roleName", roleName) |
408 | |
.append("delegatorWorkflowId", delegatorWorkflowId) |
409 | |
.append("delegatorGroupId", delegatorGroupId) |
410 | |
.append("dateAssignedString", dateAssignedString) |
411 | |
.append("actionToTake", actionToTake) |
412 | |
.append("delegationType", delegationType) |
413 | |
.append("actionItemIndex", actionItemIndex) |
414 | |
.append("customActions", customActions) |
415 | |
.append("lastApprovedDate", lastApprovedDate) |
416 | |
.toString(); |
417 | |
} |
418 | |
|
419 | |
} |