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