Coverage Report - org.kuali.rice.kew.web.WorkflowRoutingForm
 
Classes in this File Line Coverage Branch Coverage Complexity
WorkflowRoutingForm
0%
0/86
0%
0/28
1.417
 
 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.web;
 18  
 
 19  
 import java.util.ArrayList;
 20  
 import java.util.HashMap;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.apache.struts.action.ActionForm;
 25  
 import org.kuali.rice.kew.doctype.bo.DocumentType;
 26  
 import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
 27  
 import org.kuali.rice.kew.service.KEWServiceLocator;
 28  
 import org.kuali.rice.kew.service.WorkflowDocument;
 29  
 import org.kuali.rice.kew.util.CodeTranslator;
 30  
 import org.kuali.rice.kew.util.KEWConstants;
 31  
 import org.kuali.rice.kim.bo.Group;
 32  
 import org.kuali.rice.kim.service.KIMServiceLocator;
 33  
 
 34  
 
 35  
 /**
 36  
  * A Struts ActionForm which can be extended by ActionForms which need to add
 37  
  * support for document routing to a Struts Action.
 38  
  *
 39  
  * @author Kuali Rice Team (rice.collab@kuali.org)
 40  
  */
 41  0
 public class WorkflowRoutingForm extends ActionForm {
 42  
 
 43  
         private static final long serialVersionUID = -3537002710069757806L;
 44  
         private WorkflowDocument workflowDocument;
 45  
     private Long docId;
 46  
     private String docTypeName;
 47  
     private String initiateURL;
 48  
     private String command;
 49  
     private String annotation;
 50  
 
 51  
     //private Integer destRouteLevel;
 52  
     private boolean showBlanketApproveButton;
 53  0
     protected Map appSpecificRouteActionRequestCds = new HashMap();
 54  0
     protected AppSpecificRouteRecipient appSpecificRouteRecipient = new AppSpecificRouteRecipient();
 55  0
     protected List appSpecificRouteList = new ArrayList();
 56  
 
 57  0
     protected String appSpecificRouteRecipientType = "person";
 58  
     protected String appSpecificRouteActionRequestCd;
 59  
     protected Integer recipientIndex;
 60  
     protected String docHandlerReturnUrl;
 61  
     protected String removedAppSpecificRecipient;
 62  
 
 63  
     public void resetAppSpecificRoute(){
 64  0
         appSpecificRouteRecipient = new AppSpecificRouteRecipient();
 65  0
     }
 66  
 
 67  
     public Map getAppSpecificRouteActionRequestCds() {
 68  0
         return appSpecificRouteActionRequestCds;
 69  
     }
 70  
 
 71  
     /**
 72  
      * @return Returns the destRouteLevel.
 73  
      */
 74  
     /*public Integer getDestRouteLevel() {
 75  
         return destRouteLevel;
 76  
     }*/
 77  
 
 78  
     /**
 79  
      * @param destRouteLevel The destRouteLevel to set.
 80  
      */
 81  
     /*public void setDestRouteLevel(Integer destRouteLevel) {
 82  
         this.destRouteLevel = destRouteLevel;
 83  
     }*/
 84  
     /**
 85  
      * @return Returns the initiateURL.
 86  
      */
 87  
     public String getInitiateURL() {
 88  0
         return initiateURL;
 89  
     }
 90  
     /**
 91  
      * @param initiateURL The initiateURL to set.
 92  
      */
 93  
     public void setInitiateURL(String initiateURL) {
 94  0
         this.initiateURL = initiateURL;
 95  0
     }
 96  
     /**
 97  
      * @return Returns the command.
 98  
      */
 99  
     public String getCommand() {
 100  0
         return command;
 101  
     }
 102  
     /**
 103  
      * @param command The command to set.
 104  
      */
 105  
     public void setCommand(String command) {
 106  0
         this.command = command;
 107  0
     }
 108  
     /**
 109  
      * @return Returns the annotation.
 110  
      */
 111  
     public String getAnnotation() {
 112  0
         return annotation;
 113  
     }
 114  
     /**
 115  
      * @param annotation The annotation to set.
 116  
      */
 117  
     public void setAnnotation(String annotation) {
 118  0
         this.annotation = annotation;
 119  0
     }
 120  
     /**
 121  
      * @return Returns the showBlanketApproveButton.
 122  
      */
 123  
     public boolean isShowBlanketApproveButton() {
 124  0
         return showBlanketApproveButton;
 125  
     }
 126  
     /**
 127  
      * @param showBlanketApproveButton The showBlanketApproveButton to set.
 128  
      */
 129  
     public void setShowBlanketApproveButton(boolean blanketApprove) {
 130  0
         this.showBlanketApproveButton = blanketApprove;
 131  0
     }
 132  
     /**
 133  
      * @return Returns the docId.
 134  
      */
 135  
     public Long getDocId() {
 136  0
         return docId;
 137  
     }
 138  
     /**
 139  
      * @param docId The docId to set.
 140  
      */
 141  
     public void setDocId(Long docId) {
 142  0
         this.docId = docId;
 143  0
     }
 144  
     /**
 145  
      * @return Returns the workflowDocument.
 146  
      */
 147  
     public WorkflowDocument getWorkflowDocument() {
 148  0
         return workflowDocument;
 149  
     }
 150  
     /**
 151  
      * @param workflowDocument The workflowDocument to set.
 152  
      */
 153  
     public void setWorkflowDocument(WorkflowDocument workflowDocument) {
 154  0
         this.workflowDocument = workflowDocument;
 155  0
     }
 156  
     /**
 157  
      * @return Returns the previousRouteLevels.
 158  
      */
 159  
     /*public List getPreviousRouteLevels() {
 160  
         List previousRouteLevels = new ArrayList();
 161  
         if (flexDoc != null && flexDoc.getDocRouteLevel() != null) {
 162  
             for (int i = flexDoc.getDocRouteLevel().intValue(); i > 0; --i) {
 163  
                 previousRouteLevels.add(new KeyValue(Integer.toString(i - 1), Integer.toString(i - 1)));
 164  
             }
 165  
         }
 166  
         return previousRouteLevels;
 167  
     }*/
 168  
     /**
 169  
      * @return Returns the superUserSearch.
 170  
      */
 171  
     public boolean isSuperUserSearch() {
 172  0
         return (command != null && command.equals(KEWConstants.SUPERUSER_COMMAND));
 173  
     }
 174  
 
 175  
     public String getDocTypeName() {
 176  0
         return docTypeName;
 177  
     }
 178  
 
 179  
     public void setDocTypeName(String docTypeName) {
 180  0
         this.docTypeName = docTypeName;
 181  0
     }
 182  
 
 183  
     public void setAppSpecificPersonId(String networkId){
 184  0
         if(networkId != null && !networkId.trim().equals("")){
 185  0
             getAppSpecificRouteRecipient().setId(networkId);
 186  
         }
 187  0
         getAppSpecificRouteRecipient().setType("person");
 188  0
     }
 189  
 
 190  
     public void setAppSpecificWorkgroupId(String workgroupId){
 191  0
         if(workgroupId != null){
 192  0
             Group workgroup = KIMServiceLocator.getIdentityManagementService().getGroup(workgroupId);
 193  0
             if(workgroup != null){
 194  0
                 getAppSpecificRouteRecipient().setId(workgroup.getGroupId());
 195  
             }
 196  
         }
 197  0
         getAppSpecificRouteRecipient().setType("workgroup");
 198  0
     }
 199  
 
 200  
     public AppSpecificRouteRecipient getAppSpecificRouteRecipient() {
 201  0
         return appSpecificRouteRecipient;
 202  
     }
 203  
     public void setAppSpecificRouteRecipient(AppSpecificRouteRecipient appSpecificRouteRecipient) {
 204  0
         this.appSpecificRouteRecipient = appSpecificRouteRecipient;
 205  0
     }
 206  
     public List getAppSpecificRouteList() {
 207  0
         return appSpecificRouteList;
 208  
     }
 209  
     public void setAppSpecificRouteList(List appSpecificRouteList) {
 210  0
         this.appSpecificRouteList = appSpecificRouteList;
 211  0
     }
 212  
 
 213  
 
 214  
     public void setAppSpecificRouteRecipientType(
 215  
             String appSpecificRouteRecipientType) {
 216  0
         this.appSpecificRouteRecipientType = appSpecificRouteRecipientType;
 217  0
     }
 218  
     public String getAppSpecificRouteRecipientType() {
 219  0
         return appSpecificRouteRecipientType;
 220  
     }
 221  
 
 222  
     public AppSpecificRouteRecipient getAppSpecificRoute(int index) {
 223  0
         while (getAppSpecificRouteList().size() <= index) {
 224  0
             getAppSpecificRouteList().add(new AppSpecificRouteRecipient());
 225  
         }
 226  0
         return (AppSpecificRouteRecipient) getAppSpecificRouteList().get(index);
 227  
     }
 228  
 
 229  
 
 230  
     public void setAppSpecificRoute(int index, AppSpecificRouteRecipient appSpecificRouteRecipient) {
 231  0
         appSpecificRouteList.set(index, appSpecificRouteRecipient);
 232  0
     }
 233  
 
 234  
 
 235  
     public String getAppSpecificRouteActionRequestCd() {
 236  0
         return appSpecificRouteActionRequestCd;
 237  
     }
 238  
     public void setAppSpecificRouteActionRequestCd(
 239  
             String appSpecificRouteActionRequestCd) {
 240  0
         this.appSpecificRouteActionRequestCd = appSpecificRouteActionRequestCd;
 241  0
     }
 242  
     public Integer getRecipientIndex() {
 243  0
         return recipientIndex;
 244  
     }
 245  
     public void setRecipientIndex(Integer recipientIndex) {
 246  0
         this.recipientIndex = recipientIndex;
 247  0
     }
 248  
 
 249  
 
 250  
     public void establishVisibleActionRequestCds(){
 251  
             try {
 252  0
                 if(getWorkflowDocument() != null){
 253  0
                             Long docId = workflowDocument.getRouteHeaderId();
 254  0
                             DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(docId);
 255  0
                             DocumentType documentType = document.getDocumentType();
 256  0
                             boolean isSuperUser = KEWServiceLocator.getDocumentTypePermissionService().canAdministerRouting(workflowDocument.getPrincipalId(), documentType);
 257  0
                             if (isSuperUser){
 258  0
                                     appSpecificRouteActionRequestCds = CodeTranslator.arLabels;
 259  0
                             }else if(workflowDocument.isFYIRequested()){
 260  0
                         appSpecificRouteActionRequestCds.clear();
 261  0
                         appSpecificRouteActionRequestCds.put(KEWConstants.ACTION_REQUEST_FYI_REQ, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL);
 262  0
                     } else if (workflowDocument.isAcknowledgeRequested()){
 263  0
                         appSpecificRouteActionRequestCds.clear();
 264  0
                         appSpecificRouteActionRequestCds.put(KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KEWConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL);
 265  0
                         appSpecificRouteActionRequestCds.put(KEWConstants.ACTION_REQUEST_FYI_REQ, KEWConstants.ACTION_REQUEST_FYI_REQ_LABEL);
 266  0
                     } else if(workflowDocument.isApprovalRequested() || workflowDocument.isCompletionRequested() || workflowDocument.stateIsInitiated()){
 267  0
                         appSpecificRouteActionRequestCds = CodeTranslator.arLabels;
 268  
                     }
 269  
                 }
 270  0
             } catch (Exception e) {
 271  0
                     throw new RuntimeException("Caught exception building ad hoc action dropdown", e);
 272  0
             }
 273  0
     }
 274  
     public String getDocHandlerReturnUrl() {
 275  0
         return docHandlerReturnUrl;
 276  
     }
 277  
     public void setDocHandlerReturnUrl(String docHandlerReturnUrl) {
 278  0
         this.docHandlerReturnUrl = docHandlerReturnUrl;
 279  0
     }
 280  
 
 281  
     public String getRemovedAppSpecificRecipient() {
 282  0
         return removedAppSpecificRecipient;
 283  
     }
 284  
     public void setRemovedAppSpecificRecipient(
 285  
             String removedAppSpecificRecipient) {
 286  0
         this.removedAppSpecificRecipient = removedAppSpecificRecipient;
 287  0
     }
 288  
 }