001/** 002 * Copyright 2005-2016 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.documentoperation.web; 017 018import org.apache.commons.collections.Factory; 019import org.apache.commons.collections.ListUtils; 020import org.kuali.rice.kew.actionitem.ActionItem; 021import org.kuali.rice.kew.actionrequest.ActionRequestValue; 022import org.kuali.rice.kew.actiontaken.ActionTakenValue; 023import org.kuali.rice.kew.api.KewApiConstants; 024import org.kuali.rice.kew.api.action.ActionRequestStatus; 025import org.kuali.rice.kew.api.action.RecipientType; 026import org.kuali.rice.kew.engine.node.Branch; 027import org.kuali.rice.kew.engine.node.RouteNodeInstance; 028import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; 029import org.kuali.rice.kew.service.KEWServiceLocator; 030import org.kuali.rice.kns.web.struts.form.KualiForm; 031 032import java.util.ArrayList; 033import java.util.HashMap; 034import java.util.List; 035import java.util.Map; 036 037/** 038 * struts form bean for {@link DocumentOperationAction}. 039 * 040 * @author Kuali Rice Team (rice.collab@kuali.org) 041 */ 042public class DocumentOperationForm extends KualiForm { 043 044 private static final long serialVersionUID = 2994179393392218743L; 045 private DocumentRouteHeaderValue routeHeader; 046 private String documentId; 047 048 private List actionRequestOps = new ArrayList(); 049 private List actionTakenOps = new ArrayList(); 050 private List actionItemOps = new ArrayList(); 051 052 053 private String routeHeaderOp; 054 055 private String dateModified; 056 private String createDate; 057 private String approvedDate; 058 private String finalizedDate; 059 private String routeStatusDate; 060 private String lookupableImplServiceName; 061 private String lookupType; 062 private Map docStatuses = KewApiConstants.DOCUMENT_STATUSES; 063 private Map actionRequestCds = KewApiConstants.ACTION_REQUEST_CD; 064 private Map actionTakenCds = KewApiConstants.ACTION_TAKEN_CD; 065 private List routeModules; 066 private String routeModuleName; 067 068 //variabes for RouteNodeInstances and branches 069 private List routeNodeInstances=ListUtils.lazyList(new ArrayList(), 070 new Factory() { 071 public Object create() { 072 return new RouteNodeInstance(); 073 } 074 }); 075 076 private List routeNodeInstanceOps=new ArrayList(); 077 private List branches=ListUtils.lazyList(new ArrayList(), 078 new Factory() { 079 public Object create() { 080 return new Branch(); 081 } 082 }); 083 private List branchOps=new ArrayList(); 084 private List nodeStateDeleteOps=new ArrayList(); 085 private String nodeStatesDelete; 086 private String branchStatesDelete; 087 private String initialNodeInstances; 088 089 private String annotation; 090 091 private String blanketApproveUser; 092 private String blanketApproveActionTakenId; 093 private String blanketApproveNodes; 094 private String actionInvocationUser; 095 private String actionInvocationActionItemId; 096 private String actionInvocationActionCode; 097 098 private List<ActionRequestValue> actionRequests = new ArrayList<ActionRequestValue>(); 099 private List<ActionTakenValue> actionsTaken = new ArrayList<ActionTakenValue>(); 100 private List<ActionItem> actionItems = new ArrayList<ActionItem>(); 101 102 public String getAnnotation() { 103 return annotation; 104 } 105 106 public void setAnnotation(String annotation) { 107 this.annotation = annotation; 108 } 109 110 public String getInitialNodeInstances(){ 111 return initialNodeInstances; 112 } 113 114 public void setInitialNodeInstances(String initialNodeInstances){ 115 this.initialNodeInstances=initialNodeInstances; 116 } 117 118 public String getNodeStatesDelete(){ 119 return nodeStatesDelete; 120 } 121 122 public void setNodeStatesDelete(String nodeStatesDelete){ 123 this.nodeStatesDelete=nodeStatesDelete; 124 } 125 126 public String getBranchStatesDelete(){ 127 return branchStatesDelete; 128 } 129 130 public void setBranchStatesDelete(String branchStatesDelete){ 131 this.branchStatesDelete=branchStatesDelete; 132 } 133 134 public DocumentOperationForm(){ 135 routeHeader = new DocumentRouteHeaderValue(); 136 } 137 138 public DocumentRouteHeaderValue getRouteHeader() { 139 return routeHeader; 140 } 141 public void setRouteHeader(DocumentRouteHeaderValue routeHeader) { 142 this.routeHeader = routeHeader; 143 } 144 145 public DocOperationIndexedParameter getActionRequestOp(int index) { 146 while (actionRequestOps.size() <= index) { 147 actionRequestOps.add(new DocOperationIndexedParameter(new Integer(index), KewApiConstants.NOOP)); 148 } 149 return (DocOperationIndexedParameter) getActionRequestOps().get(index); 150 } 151 152 public DocOperationIndexedParameter getActionTakenOp(int index) { 153 while (actionTakenOps.size() <= index) { 154 actionTakenOps.add(new DocOperationIndexedParameter(new Integer(index), KewApiConstants.NOOP)); 155 } 156 return (DocOperationIndexedParameter) getActionTakenOps().get(index); 157 } 158 159 public DocOperationIndexedParameter getRouteNodeInstanceOp(int index) { 160 while (routeNodeInstanceOps.size() <= index) { 161 routeNodeInstanceOps.add(new DocOperationIndexedParameter(new Integer(index), KewApiConstants.NOOP)); 162 } 163 return (DocOperationIndexedParameter) getRouteNodeInstanceOps().get(index); 164 } 165 166 public DocOperationIndexedParameter getBranchOp(int index) { 167 while (branchOps.size() <= index) { 168 branchOps.add(new DocOperationIndexedParameter(new Integer(index), KewApiConstants.NOOP)); 169 } 170 return (DocOperationIndexedParameter) getBranchOps().get(index); 171 } 172 173 public DocOperationIndexedParameter getActionItemOp(int index) { 174 while (actionItemOps.size() <= index) { 175 actionItemOps.add(new DocOperationIndexedParameter(new Integer(index), KewApiConstants.NOOP)); 176 } 177 return (DocOperationIndexedParameter) getActionItemOps().get(index); 178 } 179 180 public DocOperationIndexedParameter getNodeStateDeleteOp(int index){ 181 while(nodeStateDeleteOps.size()<=index){ 182 nodeStateDeleteOps.add(new DocOperationIndexedParameter(new Integer(index),"")); 183 } 184 return(DocOperationIndexedParameter) getNodeStateDeleteOps().get(index); 185 } 186 187 public List getActionItemOps() { 188 return actionItemOps; 189 } 190 public void setActionItemOps(List actionItemOps) { 191 this.actionItemOps = actionItemOps; 192 } 193 public List getActionRequestOps() { 194 return actionRequestOps; 195 } 196 public void setActionRequestOps(List actionRequestOps) { 197 this.actionRequestOps = actionRequestOps; 198 } 199 public List getActionTakenOps() { 200 return actionTakenOps; 201 } 202 public List getRouteNodeInstanceOps() { 203 return routeNodeInstanceOps; 204 } 205 206 public List getBranchOps(){ 207 return branchOps; 208 } 209 210 public List getNodeStateDeleteOps(){ 211 return nodeStateDeleteOps; 212 } 213 214 public void setActionTakenOps(List actionTakenOps) { 215 this.actionTakenOps = actionTakenOps; 216 } 217 218 public void setRouteNodeInstanceOps(List routeNodeInstanceOps) { 219 this.routeNodeInstanceOps = routeNodeInstanceOps; 220 } 221 222 public void setBranchOps(List branchOps){ 223 this.branchOps=branchOps; 224 } 225 226 public void setNodeStateDeleteOps(List nodeStateDeleteOps){ 227 this.nodeStateDeleteOps=nodeStateDeleteOps; 228 } 229 230 public String getRouteHeaderOp() { 231 return routeHeaderOp; 232 } 233 public void setRouteHeaderOp(String routeHeaderOp) { 234 this.routeHeaderOp = routeHeaderOp; 235 } 236 public String getApprovedDate() { 237 return approvedDate; 238 } 239 public void setApprovedDate(String approvedDate) { 240 this.approvedDate = approvedDate; 241 } 242 public String getCreateDate() { 243 return createDate; 244 } 245 public void setCreateDate(String createDate) { 246 this.createDate = createDate; 247 } 248 public String getFinalizedDate() { 249 return finalizedDate; 250 } 251 public void setFinalizedDate(String finalizedDate) { 252 this.finalizedDate = finalizedDate; 253 } 254 public String getRouteStatusDate() { 255 return routeStatusDate; 256 } 257 public void setRouteStatusDate(String routeStatusDate) { 258 this.routeStatusDate = routeStatusDate; 259 } 260 public String getDateModified() { 261 return dateModified; 262 } 263 public void setDateModified(String dateModified) { 264 this.dateModified = dateModified; 265 } 266 267 268 public String getLookupableImplServiceName() { 269 return lookupableImplServiceName; 270 } 271 public void setLookupableImplServiceName(String lookupableImplServiceName) { 272 this.lookupableImplServiceName = lookupableImplServiceName; 273 } 274 public String getLookupType() { 275 return lookupType; 276 } 277 public void setLookupType(String lookupType) { 278 this.lookupType = lookupType; 279 } 280 281 public Map getDocStatuses() { 282 return docStatuses; 283 } 284 285 public Map getActionRequestCds() { 286 return actionRequestCds; 287 } 288 public Map<String, String> getActionRequestRecipientTypes() { 289 Map<String, String> actionRequestRecipientTypes = new HashMap<String, String>(); 290 for (RecipientType recipientType : RecipientType.values()) { 291 actionRequestRecipientTypes.put(recipientType.getCode(), recipientType.getLabel()); 292 } 293 return actionRequestRecipientTypes; 294 } 295 public Map<String, String> getActionRequestStatuses() { 296 Map<String, String> actionRequestStatuses = new HashMap<String, String>(); 297 for (ActionRequestStatus requestStatus : ActionRequestStatus.values()) { 298 actionRequestStatuses.put(requestStatus.getCode(), requestStatus.getLabel()); 299 } 300 return actionRequestStatuses; 301 } 302 303 public List<ActionRequestValue> getActionRequests() { 304 if (actionRequests == null || actionRequests.isEmpty()) { 305 List<ActionRequestValue> actionRequestsList = KEWServiceLocator.getActionRequestService().findByDocumentIdIgnoreCurrentInd(documentId); 306 this.actionRequests = actionRequestsList; 307 } 308 return actionRequests; 309 } 310 311 public List<ActionTakenValue> getActionsTaken() { 312 if (actionsTaken == null || actionsTaken.isEmpty()) { 313 List<ActionTakenValue> actionsTakenList = KEWServiceLocator.getActionTakenService().findByDocumentIdIgnoreCurrentInd(documentId); 314 this.actionsTaken = actionsTakenList; 315 } 316 return actionsTaken; 317 } 318 319 public List<ActionItem> getActionItems() { 320 if (actionItems == null || actionItems.isEmpty()) { 321 List<ActionItem> actionItemsList = (List<ActionItem>)KEWServiceLocator.getActionListService().findByDocumentId(documentId); 322 this.actionItems = actionItemsList; 323 } 324 return actionItems; 325 } 326 327 public Map getActionTakenCds() { 328 return actionTakenCds; 329 } 330 331 public String getDocumentId() { 332 return documentId; 333 } 334 public void setDocumentId(String documentId) { 335 this.documentId = documentId; 336 } 337 338 public List getRouteModules() { 339 return routeModules; 340 } 341 342 public void setRouteModules(List routeModules) { 343 this.routeModules = routeModules; 344 } 345 346 public String getRouteModuleName() { 347 return routeModuleName; 348 } 349 350 public void setRouteModuleName(String routeModuleName) { 351 this.routeModuleName = routeModuleName; 352 } 353 354 /* 355 * methods for route node instances 356 */ 357 358 public List getRouteNodeInstances(){ 359 return routeNodeInstances; 360 } 361 362 public void setRouteNodeInstances(List routeNodeInstances){ 363 this.routeNodeInstances=routeNodeInstances; 364 } 365 366 public RouteNodeInstance getRouteNodeInstance(int index){ 367 while (getRouteNodeInstances().size() <= index) { 368 getRouteNodeInstances().add(new RouteNodeInstance()); 369 } 370 return (RouteNodeInstance) getRouteNodeInstances().get(index); 371 } 372 373 public List getBranches(){ 374 return branches; 375 } 376 377 public void setBranches(List branches){ 378 this.branches=branches; 379 } 380 381 public Branch getBranche(int index){ 382 while(getBranches().size()<=index){ 383 getBranches().add(new Branch()); 384 } 385 return (Branch) getBranches().get(index); 386 } 387 388 public void resetOps(){ 389 routeNodeInstanceOps=new ArrayList(); 390 branchOps=new ArrayList(); 391 actionRequestOps = new ArrayList(); 392 actionTakenOps = new ArrayList(); 393 actionItemOps = new ArrayList(); 394 } 395 396 public String getActionInvocationActionCode() { 397 return actionInvocationActionCode; 398 } 399 400 public void setActionInvocationActionCode(String actionInvocationActionCode) { 401 this.actionInvocationActionCode = actionInvocationActionCode; 402 } 403 404 public String getActionInvocationActionItemId() { 405 return actionInvocationActionItemId; 406 } 407 408 public void setActionInvocationActionItemId(String actionInvocationActionItemId) { 409 this.actionInvocationActionItemId = actionInvocationActionItemId; 410 } 411 412 public String getActionInvocationUser() { 413 return actionInvocationUser; 414 } 415 416 public void setActionInvocationUser(String actionInvocationUser) { 417 this.actionInvocationUser = actionInvocationUser; 418 } 419 420 public String getBlanketApproveActionTakenId() { 421 return blanketApproveActionTakenId; 422 } 423 424 public void setBlanketApproveActionTakenId(String blanketApproveActionTakenId) { 425 this.blanketApproveActionTakenId = blanketApproveActionTakenId; 426 } 427 428 public String getBlanketApproveNodes() { 429 return blanketApproveNodes; 430 } 431 432 public void setBlanketApproveNodes(String blanketApproveNodes) { 433 this.blanketApproveNodes = blanketApproveNodes; 434 } 435 436 public String getBlanketApproveUser() { 437 return blanketApproveUser; 438 } 439 440 public void setBlanketApproveUser(String blanketApproveUser) { 441 this.blanketApproveUser = blanketApproveUser; 442 } 443 444 445}