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