001/** 002 * Copyright 2005-2017 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.rice.kew.web; 017 018import org.kuali.rice.kew.api.WorkflowDocument; 019import org.kuali.rice.kew.api.util.CodeTranslator; 020import org.kuali.rice.kew.doctype.bo.DocumentType; 021import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; 022import org.kuali.rice.kew.service.KEWServiceLocator; 023import org.kuali.rice.kew.api.KewApiConstants; 024import org.kuali.rice.kim.api.group.Group; 025import org.kuali.rice.kim.api.services.KimApiServiceLocator; 026import org.kuali.rice.kns.web.struts.form.KualiForm; 027 028import java.util.ArrayList; 029import java.util.HashMap; 030import java.util.List; 031import java.util.Map; 032 033/** 034 * This is a description of what this class does - jjhanso don't forget to fill this in. 035 * 036 * @author Kuali Rice Team (rice.collab@kuali.org) 037 * 038 */ 039public class KewRoutingKualiForm extends KualiForm { 040 private static final long serialVersionUID = -3537002710069757806L; 041 private WorkflowDocument workflowDocument; 042 private String docId; 043 private String docTypeName; 044 private String initiateURL; 045 private String command; 046 private String annotation; 047 048 049 private boolean showBlanketApproveButton; 050 protected Map appSpecificRouteActionRequestCds = new HashMap(); 051 // KULRICE-2924: Added appSpecificRouteRecipient2 to allow for better separation between person and group routing. 052 protected AppSpecificRouteRecipient appSpecificRouteRecipient = new AppSpecificRouteRecipient(); 053 protected AppSpecificRouteRecipient appSpecificRouteRecipient2 = new AppSpecificRouteRecipient(); 054 protected List appSpecificRouteList = new ArrayList(); 055 056 protected String appSpecificRouteRecipientType = "person"; 057 // KULRICE-2924: Added appSpecificRouteActionRequestCd2 to allow for better separation between person and group routing. 058 protected String appSpecificRouteActionRequestCd; 059 protected String appSpecificRouteActionRequestCd2; 060 protected Integer recipientIndex; 061 protected String docHandlerReturnUrl; 062 protected String removedAppSpecificRecipient; 063 064 public void resetAppSpecificRoute(){ 065 appSpecificRouteRecipient = new AppSpecificRouteRecipient(); 066 appSpecificRouteRecipient2 = new AppSpecificRouteRecipient(); 067 } 068 069 public Map getAppSpecificRouteActionRequestCds() { 070 return appSpecificRouteActionRequestCds; 071 } 072 073 /** 074 * @return Returns the initiateURL. 075 */ 076 public String getInitiateURL() { 077 return initiateURL; 078 } 079 /** 080 * @param initiateURL The initiateURL to set. 081 */ 082 public void setInitiateURL(String initiateURL) { 083 this.initiateURL = initiateURL; 084 } 085 /** 086 * @return Returns the command. 087 */ 088 public String getCommand() { 089 return command; 090 } 091 /** 092 * @param command The command to set. 093 */ 094 public void setCommand(String command) { 095 this.command = command; 096 } 097 /** 098 * @return Returns the annotation. 099 */ 100 public String getAnnotation() { 101 return annotation; 102 } 103 /** 104 * @param annotation The annotation to set. 105 */ 106 public void setAnnotation(String annotation) { 107 this.annotation = annotation; 108 } 109 /** 110 * @return Returns the showBlanketApproveButton. 111 */ 112 public boolean isShowBlanketApproveButton() { 113 return showBlanketApproveButton; 114 } 115 /** 116 * @param showBlanketApproveButton The showBlanketApproveButton to set. 117 */ 118 public void setShowBlanketApproveButton(boolean blanketApprove) { 119 this.showBlanketApproveButton = blanketApprove; 120 } 121 /** 122 * @return Returns the docId. 123 */ 124 public String getDocId() { 125 return docId; 126 } 127 /** 128 * @param docId The docId to set. 129 */ 130 public void setDocId(String docId) { 131 this.docId = docId; 132 } 133 /** 134 * @return Returns the workflowDocument. 135 */ 136 public WorkflowDocument getWorkflowDocument() { 137 return workflowDocument; 138 } 139 /** 140 * @param workflowDocument The workflowDocument to set. 141 */ 142 public void setWorkflowDocument(WorkflowDocument workflowDocument) { 143 this.workflowDocument = workflowDocument; 144 } 145 146 /** 147 * @return Returns the superUserSearch. 148 */ 149 public boolean isSuperUserSearch() { 150 return (command != null && command.equals(KewApiConstants.SUPERUSER_COMMAND)); 151 } 152 153 public String getDocTypeName() { 154 return docTypeName; 155 } 156 157 public void setDocTypeName(String docTypeName) { 158 this.docTypeName = docTypeName; 159 } 160 161 public void setAppSpecificPersonId(String networkId){ 162 if(networkId != null && !networkId.trim().equals("")){ 163 getAppSpecificRouteRecipient().setId(networkId); 164 } 165 getAppSpecificRouteRecipient().setType("person"); 166 } 167 168 public void setAppSpecificWorkgroupId(String workgroupId){ 169 if(workgroupId != null){ 170 Group workgroup = KimApiServiceLocator.getGroupService().getGroup(workgroupId); 171 if(workgroup != null){ 172 getAppSpecificRouteRecipient2().setId(workgroup.getId()); 173 } 174 } 175 getAppSpecificRouteRecipient2().setType("workgroup"); 176 } 177 178 public AppSpecificRouteRecipient getAppSpecificRouteRecipient() { 179 return appSpecificRouteRecipient; 180 } 181 public void setAppSpecificRouteRecipient(AppSpecificRouteRecipient appSpecificRouteRecipient) { 182 this.appSpecificRouteRecipient = appSpecificRouteRecipient; 183 } 184 185 public AppSpecificRouteRecipient getAppSpecificRouteRecipient2() { 186 return appSpecificRouteRecipient2; 187 } 188 public void setAppSpecificRouteRecipient2(AppSpecificRouteRecipient appSpecificRouteRecipient2) { 189 this.appSpecificRouteRecipient2 = appSpecificRouteRecipient2; 190 } 191 192 public List getAppSpecificRouteList() { 193 return appSpecificRouteList; 194 } 195 public void setAppSpecificRouteList(List appSpecificRouteList) { 196 this.appSpecificRouteList = appSpecificRouteList; 197 } 198 199 200 public void setAppSpecificRouteRecipientType( 201 String appSpecificRouteRecipientType) { 202 this.appSpecificRouteRecipientType = appSpecificRouteRecipientType; 203 } 204 public String getAppSpecificRouteRecipientType() { 205 return appSpecificRouteRecipientType; 206 } 207 208 public AppSpecificRouteRecipient getAppSpecificRoute(int index) { 209 while (getAppSpecificRouteList().size() <= index) { 210 getAppSpecificRouteList().add(new AppSpecificRouteRecipient()); 211 } 212 return (AppSpecificRouteRecipient) getAppSpecificRouteList().get(index); 213 } 214 215 216 public void setAppSpecificRoute(int index, AppSpecificRouteRecipient appSpecificRouteRecipient) { 217 appSpecificRouteList.set(index, appSpecificRouteRecipient); 218 } 219 220 221 public String getAppSpecificRouteActionRequestCd() { 222 return appSpecificRouteActionRequestCd; 223 } 224 public void setAppSpecificRouteActionRequestCd( 225 String appSpecificRouteActionRequestCd) { 226 this.appSpecificRouteActionRequestCd = appSpecificRouteActionRequestCd; 227 } 228 229 public String getAppSpecificRouteActionRequestCd2() { 230 return appSpecificRouteActionRequestCd2; 231 } 232 public void setAppSpecificRouteActionRequestCd2( 233 String appSpecificRouteActionRequestCd2) { 234 this.appSpecificRouteActionRequestCd2 = appSpecificRouteActionRequestCd2; 235 } 236 237 public Integer getRecipientIndex() { 238 return recipientIndex; 239 } 240 public void setRecipientIndex(Integer recipientIndex) { 241 this.recipientIndex = recipientIndex; 242 } 243 244 245 public void establishVisibleActionRequestCds(){ 246 try { 247 if(getWorkflowDocument() != null){ 248 String docId = workflowDocument.getDocumentId(); 249 DocumentRouteHeaderValue document = KEWServiceLocator.getRouteHeaderService().getRouteHeader(docId); 250 DocumentType documentType = document.getDocumentType(); 251 boolean isSuperUser = KEWServiceLocator.getDocumentTypePermissionService().canAdministerRouting(workflowDocument.getPrincipalId(), documentType); 252 if (isSuperUser){ 253 if (workflowDocument.isInitiated() || workflowDocument.isSaved() || workflowDocument.isEnroute()) { 254 appSpecificRouteActionRequestCds.clear(); 255 appSpecificRouteActionRequestCds.putAll(CodeTranslator.arLabels); 256 } 257 else if (workflowDocument.isProcessed() || workflowDocument.isApproved() || workflowDocument.isDisapproved()) { 258 appSpecificRouteActionRequestCds.clear(); 259 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL); 260 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL); 261 } 262 else { 263 appSpecificRouteActionRequestCds.clear(); 264 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL); 265 } 266 } else if(workflowDocument.isFYIRequested()){ 267 appSpecificRouteActionRequestCds.clear(); 268 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL); 269 } else if (workflowDocument.isAcknowledgeRequested()){ 270 appSpecificRouteActionRequestCds.clear(); 271 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ, KewApiConstants.ACTION_REQUEST_ACKNOWLEDGE_REQ_LABEL); 272 appSpecificRouteActionRequestCds.put(KewApiConstants.ACTION_REQUEST_FYI_REQ, KewApiConstants.ACTION_REQUEST_FYI_REQ_LABEL); 273 } else if(workflowDocument.isApprovalRequested() || workflowDocument.isCompletionRequested() || workflowDocument.isInitiated()){ 274 appSpecificRouteActionRequestCds.clear(); 275 appSpecificRouteActionRequestCds.putAll(CodeTranslator.arLabels); 276 } 277 } 278 } catch (Exception e) { 279 throw new RuntimeException("Caught exception building ad hoc action dropdown", e); 280 } 281 } 282 public String getDocHandlerReturnUrl() { 283 return docHandlerReturnUrl; 284 } 285 public void setDocHandlerReturnUrl(String docHandlerReturnUrl) { 286 this.docHandlerReturnUrl = docHandlerReturnUrl; 287 } 288 289 public String getRemovedAppSpecificRecipient() { 290 return removedAppSpecificRecipient; 291 } 292 public void setRemovedAppSpecificRecipient( 293 String removedAppSpecificRecipient) { 294 this.removedAppSpecificRecipient = removedAppSpecificRecipient; 295 } 296}