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