Coverage Report - org.kuali.rice.kew.actionitem.ActionItem
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionItem
0%
0/100
0%
0/16
1.186
 
 1  
 /*
 2  
  * Copyright 2005-2007 The Kuali Foundation
 3  
  *
 4  
  *
 5  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 6  
  * you may not use this file except in compliance with the License.
 7  
  * You may obtain a copy of the License at
 8  
  *
 9  
  * http://www.opensource.org/licenses/ecl2.php
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 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.bo.Group;
 30  
 import org.kuali.rice.kim.bo.Person;
 31  
 import org.kuali.rice.kim.bo.entity.KimPrincipal;
 32  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 33  
 
 34  
 import javax.persistence.*;
 35  
 import java.io.Serializable;
 36  
 import java.sql.Timestamp;
 37  
 import java.util.HashMap;
 38  
 import java.util.Map;
 39  
 
 40  
 
 41  
 /**
 42  
  * This is the model for action items. These are displayed as the action list as well.  Mapped to ActionItemService.
 43  
  * NOTE: This object contains denormalized fields that have been copied from related ActionRequestValue and DocumentRouteHeaderValue
 44  
  * objects for performance reasons.  These should be preserved and their related objects should not be added to the OJB
 45  
  * mapping as we do not want them loaded for each ActionItem object.
 46  
  *
 47  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 48  
  *
 49  
  */
 50  
 
 51  
 
 52  
 @Entity
 53  
 @Inheritance(strategy=InheritanceType.TABLE_PER_CLASS)
 54  
 @Table(name="KREW_ACTN_ITM_T")
 55  
 //@Sequence(name="KREW_ACTN_ITM_S",property="actionItemId")
 56  
 @NamedQueries({
 57  
     @NamedQuery(name="ActionItem.QuickLinks.FindActionListStatsByPrincipalId", query="SELECT docName, COUNT(*) FROM ActionItem WHERE principalId = :principalId " +
 58  
         "AND (delegationType IS null OR delegationType != '" + KEWConstants.DELEGATION_SECONDARY + "') GROUP BY docName")
 59  
 })
 60  0
 public class ActionItem implements RowStyleable, Serializable {
 61  
 
 62  
     private static final long serialVersionUID = -1079562205125660151L;
 63  
 
 64  
     @Id
 65  
     @GeneratedValue(generator="KREW_ACTN_ITM_S")
 66  
         @GenericGenerator(name="KREW_ACTN_ITM_S",strategy="org.hibernate.id.enhanced.SequenceStyleGenerator",parameters={
 67  
                         @Parameter(name="sequence_name",value="KREW_ACTN_ITM_S"),
 68  
                         @Parameter(name="value_column",value="id")
 69  
         })
 70  
     @Column(name="ACTN_ITM_ID")
 71  
         private Long actionItemId;
 72  
     @Column(name="PRNCPL_ID")
 73  
         private String principalId;
 74  
         @Column(name="ASND_DT")
 75  
         private Timestamp dateAssigned;
 76  
     @Column(name="RQST_CD")
 77  
         private String actionRequestCd;
 78  
     @Column(name="ACTN_RQST_ID", nullable=false)
 79  
         private Long actionRequestId;
 80  
     @Column(name="DOC_HDR_ID")//, insertable=false, updatable=false)
 81  
         private Long routeHeaderId;
 82  
     @Column(name="GRP_ID")
 83  
         private String groupId;
 84  
     @Column(name="DOC_HDR_TTL")
 85  
         private String docTitle;
 86  
     @Column(name="DOC_TYP_LBL")
 87  
         private String docLabel;
 88  
     @Column(name="DOC_HDLR_URL")
 89  
         private String docHandlerURL;
 90  
     @Version
 91  
         @Column(name="VER_NBR")
 92  
         private Integer lockVerNbr;
 93  
     @Column(name="DOC_TYP_NM")
 94  
         private String docName;
 95  0
     @Column(name="RSP_ID")
 96  
     private Long responsibilityId = new Long(1);
 97  
     @Column(name="ROLE_NM")
 98  
         private String roleName;
 99  
     @Column(name="DLGN_PRNCPL_ID")
 100  
         private String delegatorWorkflowId;
 101  
     @Column(name="DLGN_GRP_ID")
 102  
         private String delegatorGroupId;
 103  
     @Column(name="DLGN_TYP")
 104  
         private String delegationType;
 105  
     @Column(name="RQST_LBL")
 106  
     private String requestLabel;
 107  
 
 108  
     //@ManyToOne(fetch=FetchType.EAGER)
 109  
     //@JoinColumn(name="DOC_HDR_ID")
 110  
         //private DocumentRouteHeaderValue routeHeader;
 111  
         
 112  
     @Transient
 113  
     private Timestamp lastApprovedDate;
 114  
     @Transient
 115  
     private Integer actionItemIndex;
 116  0
     @Transient
 117  
     private Map customActions = new HashMap();
 118  
     @Transient
 119  
     private String dateAssignedString;
 120  
     @Transient
 121  
     private String actionToTake;
 122  
     @Transient
 123  
     private String rowStyleClass;
 124  
 
 125  
 
 126  
     //@PrePersist
 127  
     public void beforeInsert(){
 128  0
         OrmUtils.populateAutoIncValue(this, KEWServiceLocator.getEntityManagerFactory().createEntityManager());
 129  0
     }
 130  
     
 131  
     public Long getActionItemId() {
 132  0
         return actionItemId;
 133  
     }
 134  
     
 135  
     public String getPrincipalId() {
 136  0
         return principalId;
 137  
     }
 138  
     
 139  
     public Timestamp getDateAssigned() {
 140  0
         return dateAssigned;
 141  
     }
 142  
     
 143  
     public String getActionRequestCd() {
 144  0
         return actionRequestCd;
 145  
     }
 146  
     
 147  
     public Long getActionRequestId() {
 148  0
         return actionRequestId;
 149  
     }
 150  
     
 151  
     public Long getRouteHeaderId() {
 152  0
         return routeHeaderId;
 153  
     }
 154  
     
 155  
     public String getGroupId() {
 156  0
         return groupId;
 157  
     }
 158  
 
 159  
     public String getDocTitle() {
 160  0
         return docTitle;
 161  
     }
 162  
     
 163  
     public String getDocLabel() {
 164  0
         return docLabel;
 165  
     }
 166  
     
 167  
     public String getDocHandlerURL() {
 168  0
         return docHandlerURL;
 169  
     }
 170  
     
 171  
     public Integer getLockVerNbr() {
 172  0
         return lockVerNbr;
 173  
     }
 174  
 
 175  
     public String getDocName() {
 176  0
         return docName;
 177  
     }
 178  
 
 179  
     public Long getResponsibilityId() {
 180  0
         return responsibilityId;
 181  
     }
 182  
 
 183  
     public String getRoleName() {
 184  0
         return roleName;
 185  
     }
 186  
 
 187  
     public String getDelegatorWorkflowId() {
 188  0
         return delegatorWorkflowId;
 189  
     }
 190  
 
 191  
     public String getDelegatorGroupId() {
 192  0
         return delegatorGroupId;
 193  
     }
 194  
 
 195  
     public String getDelegationType() {
 196  0
         return delegationType;
 197  
     }
 198  
 
 199  
     public String getRequestLabel() {
 200  0
         return this.requestLabel;
 201  
     }
 202  
     
 203  
     public Timestamp getLastApprovedDate() {
 204  0
         return this.lastApprovedDate;
 205  
     }
 206  
 
 207  
     public Integer getActionItemIndex() {
 208  0
         return actionItemIndex;
 209  
     }
 210  
     
 211  
     public Map getCustomActions() {
 212  0
         return customActions;
 213  
     }
 214  
 
 215  
     public String getDateAssignedString() {
 216  0
         if(dateAssignedString == null || dateAssignedString.trim().equals("")){
 217  0
             return RiceConstants.getDefaultDateFormat().format(getDateAssigned());
 218  
         } else {
 219  0
             return dateAssignedString;
 220  
         }
 221  
     }
 222  
 
 223  
     public String getActionToTake() {
 224  0
         return actionToTake;
 225  
     }
 226  
 
 227  
     public String getRowStyleClass() {
 228  0
         return rowStyleClass;
 229  
     }
 230  
 
 231  
     private Group getGroup(String groupId) {
 232  0
             if (StringUtils.isBlank(groupId)) {
 233  0
                     return null;
 234  
             }
 235  0
             return KIMServiceLocator.getIdentityManagementService().getGroup(groupId);
 236  
     }
 237  
 
 238  
     public Group getGroup(){
 239  0
             return getGroup(groupId);
 240  
     }
 241  
 
 242  
     private Person getPerson(String workflowId) {
 243  0
             if (StringUtils.isBlank(workflowId)) {
 244  0
                     return null;
 245  
             }
 246  0
             return KIMServiceLocator.getPersonService().getPerson(workflowId);
 247  
     }
 248  
 
 249  
     public Person getPerson() {
 250  0
         return getPerson(principalId);
 251  
     }
 252  
 
 253  
     public Person getDelegatorPerson() {
 254  0
         return getPerson(delegatorWorkflowId);
 255  
     }
 256  
 
 257  
     public String getRecipientTypeCode() {
 258  0
         String recipientTypeCode = KEWConstants.ACTION_REQUEST_USER_RECIPIENT_CD;
 259  0
         if (getRoleName() != null) {
 260  0
             recipientTypeCode = KEWConstants.ACTION_REQUEST_ROLE_RECIPIENT_CD;
 261  
         }
 262  0
         if (getGroupId() != null) {
 263  0
             recipientTypeCode = KEWConstants.ACTION_REQUEST_GROUP_RECIPIENT_CD;
 264  
         }
 265  0
         return recipientTypeCode;
 266  
     }
 267  
     
 268  
     public String getActionRequestLabel() {
 269  0
             if (StringUtils.isNotBlank(getRequestLabel())) {
 270  0
                     return getRequestLabel();
 271  
             }
 272  0
             return CodeTranslator.getActionRequestLabel(getActionRequestCd());
 273  
     }
 274  
 
 275  
     public boolean isWorkgroupItem() {
 276  0
         return getGroupId() != null;
 277  
     }
 278  
     
 279  
     public KimPrincipal getPrincipal(){
 280  0
         return KIMServiceLocator.getIdentityManagementService().getPrincipal(principalId);
 281  
     }
 282  
 
 283  
     public void setRowStyleClass(String rowStyleClass) {
 284  0
         this.rowStyleClass = rowStyleClass;
 285  0
     }
 286  
     
 287  
     public void setResponsibilityId(Long responsibilityId) {
 288  0
         this.responsibilityId = responsibilityId;
 289  0
     }
 290  
     
 291  
     public void setDocName(String docName) {
 292  0
         this.docName = docName;
 293  0
     }
 294  
 
 295  
     public void setActionRequestCd(String actionRequestCd) {
 296  0
         this.actionRequestCd = actionRequestCd;
 297  0
     }
 298  
 
 299  
     public void setDateAssigned(Timestamp dateAssigned) {
 300  0
         this.dateAssigned = dateAssigned;
 301  0
     }
 302  
 
 303  
     public void setPrincipalId(String principalId) {
 304  0
         this.principalId = principalId;
 305  0
     }
 306  
     
 307  
     public void setLockVerNbr(Integer lockVerNbr) {
 308  0
         this.lockVerNbr = lockVerNbr;
 309  0
     }
 310  
 
 311  
     public void setRouteHeaderId(Long routeHeaderId) {
 312  0
         this.routeHeaderId = routeHeaderId;
 313  0
     }
 314  
 
 315  
     public void setActionItemId(Long actionItemId) {
 316  0
         this.actionItemId = actionItemId;
 317  0
     }
 318  
 
 319  
     public void setActionRequestId(Long actionRequestId) {
 320  0
         this.actionRequestId = actionRequestId;
 321  0
     }
 322  
 
 323  
     public void setDocHandlerURL(String docHandlerURL) {
 324  0
         this.docHandlerURL = docHandlerURL;
 325  0
     }
 326  
 
 327  
     public void setGroupId(String groupId) {
 328  0
         this.groupId = groupId;
 329  0
     }
 330  
 
 331  
     public void setDocLabel(String docLabel) {
 332  0
         this.docLabel = docLabel;
 333  0
     }
 334  
 
 335  
     public void setDocTitle(String docTitle) {
 336  0
         this.docTitle = docTitle;
 337  0
     }
 338  
     
 339  
     public void setRoleName(String roleName) {
 340  0
         this.roleName = roleName;
 341  0
     }
 342  
     
 343  
     public void setDelegatorWorkflowId(String delegatorWorkflowId) {
 344  0
         this.delegatorWorkflowId = delegatorWorkflowId;
 345  0
     }
 346  
     
 347  
     public void setDelegatorGroupId(String delegatorGroupId) {
 348  0
         this.delegatorGroupId = delegatorGroupId;
 349  0
     }
 350  
 
 351  
     public void setDateAssignedString(String dateAssignedString) {
 352  0
         this.dateAssignedString = dateAssignedString;
 353  0
     }
 354  
 
 355  
     public void setActionToTake(String actionToTake) {
 356  0
         this.actionToTake = actionToTake;
 357  0
     }
 358  
 
 359  
     public void setActionItemIndex(Integer actionItemIndex) {
 360  0
         this.actionItemIndex = actionItemIndex;
 361  0
     }
 362  
 
 363  
     public void setCustomActions(Map customActions) {
 364  0
         this.customActions = customActions;
 365  0
     }
 366  
     
 367  
     public void setDelegationType(String delegationType) {
 368  0
         this.delegationType = delegationType;
 369  0
     }
 370  
 
 371  
 
 372  
     public void setLastApprovedDate(Timestamp lastApprovedDate) {
 373  0
         this.lastApprovedDate = lastApprovedDate;
 374  0
     }
 375  
     
 376  
     public void setRequestLabel(String requestLabel) {
 377  0
         this.requestLabel = requestLabel;
 378  0
     }
 379  
     
 380  
     public String toString() {
 381  0
         return new ToStringBuilder(this).append("actionItemId", actionItemId)
 382  
                                         .append("workflowId", principalId)
 383  
                                         .append("actionItemId", actionItemId)
 384  
                                         .append("workflowId", principalId)
 385  
                                         .append("dateAssigned", dateAssigned)
 386  
                                         .append("actionRequestCd", actionRequestCd)
 387  
                                         .append("actionRequestId", actionRequestId)
 388  
                                         .append("routeHeaderId", routeHeaderId)
 389  
                                         .append("groupId", groupId)
 390  
                                         .append("docTitle", docTitle)
 391  
                                         .append("docLabel", docLabel)
 392  
                                         .append("docHandlerURL", docHandlerURL)
 393  
                                         .append("lockVerNbr", lockVerNbr)
 394  
                                         .append("docName", docName)
 395  
                                         .append("responsibilityId", responsibilityId)
 396  
                                         .append("rowStyleClass", rowStyleClass)
 397  
                                         .append("roleName", roleName)
 398  
                                         .append("delegatorWorkflowId", delegatorWorkflowId)
 399  
                                         .append("delegatorGroupId", delegatorGroupId)
 400  
                                         .append("dateAssignedString", dateAssignedString)
 401  
                                         .append("actionToTake", actionToTake)
 402  
                                         .append("delegationType", delegationType)
 403  
                                         .append("actionItemIndex", actionItemIndex)
 404  
                                         .append("customActions", customActions)
 405  
                                         .append("lastApprovedDate", lastApprovedDate)
 406  
                                         .toString();
 407  
     }
 408  
 
 409  
 }