View Javadoc

1   /**
2    * Copyright 2005-2012 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kew.superuser.web;
17  
18  import org.apache.commons.lang.ArrayUtils;
19  import org.apache.struts.action.ActionMapping;
20  import org.kuali.rice.core.api.util.ConcreteKeyValue;
21  import org.kuali.rice.core.api.util.KeyValue;
22  import org.kuali.rice.kew.actionrequest.ActionRequestValue;
23  import org.kuali.rice.kew.api.KewApiServiceLocator;
24  import org.kuali.rice.kew.doctype.bo.DocumentType;
25  import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue;
26  import org.kuali.rice.kew.web.KewRoutingKualiForm;
27  
28  import javax.servlet.http.HttpServletRequest;
29  import java.util.ArrayList;
30  import java.util.Arrays;
31  import java.util.HashSet;
32  import java.util.List;
33  import java.util.Set;
34  
35  
36  /**
37   * A Struts ActionForm for the {@link SuperUserAction}.
38   *
39   * @author Kuali Rice Team (rice.collab@kuali.org)
40   */
41  public class SuperUserForm extends KewRoutingKualiForm {
42  
43      private static final long serialVersionUID = 982228198266403397L;
44      private String documentId;
45      private String docHandlerUrl;
46      private Integer routeLevel;
47      private List<String> futureNodeNames = new ArrayList<String>();
48      private String destNodeName;
49      private String returnDestNodeName;
50      private String action;
51      private List<ActionRequestValue> actionRequests = new ArrayList<ActionRequestValue>();
52      private String actionTakenActionRequestId;
53      private String actionTakenNetworkId;
54      private String actionTakenWorkGroupId;
55      private String actionTakenRecipientCode;
56      private boolean authorized;
57      private boolean blanketApprove;
58      private String methodToCall = "";
59      private boolean runPostProcessorLogic = true;
60      private String[] actionRequestRunPostProcessorCheck;
61  
62      private String lookupableImplServiceName;
63      private String lookupType;
64  
65      private DocumentRouteHeaderValue routeHeader;
66  
67      // KULRICE-3035: Added the ability to store the doc search's "returnLocation" property so that the superuser form can create a proper "cancel" button.
68      private String returnLocation;
69      
70      @Override
71  	public String getMethodToCall() {
72          return methodToCall;
73      }
74      @Override
75  	public void setMethodToCall(String methodToCall) {
76          this.methodToCall = methodToCall;
77      }
78  
79      public boolean isBlanketApprove() {
80          return blanketApprove;
81      }
82  
83      public void setBlanketApprove(boolean blanketApprove) {
84          this.blanketApprove = blanketApprove;
85      }
86  
87      public DocumentRouteHeaderValue getRouteHeader() {
88          return routeHeader;
89      }
90  
91      public void setRouteHeader(DocumentRouteHeaderValue routeHeader) {
92          this.routeHeader = routeHeader;
93      }
94  
95      public String getDocumentId() {
96          return documentId;
97      }
98  
99      public void setDocumentId(String documentId) {
100         this.documentId = documentId;
101     }
102 
103     public String getDocHandlerUrl() {
104         return docHandlerUrl;
105     }
106 
107     public void setDocHandlerUrl(String docHandlerUrl) {
108         this.docHandlerUrl = docHandlerUrl;
109     }
110 
111     public Integer getRouteLevel() {
112         return routeLevel;
113     }
114 
115     public void setRouteLevel(Integer routeLevel) {
116         this.routeLevel = routeLevel;
117     }
118 
119     public String getAction() {
120         return action;
121     }
122 
123     public void setAction(String action) {
124         this.action = action;
125     }
126 
127     public List<ActionRequestValue> getActionRequests() {
128         return actionRequests;
129     }
130 
131     public void setActionRequests(List<ActionRequestValue> actionRequests) {
132         this.actionRequests = actionRequests;
133     }
134 
135     public String getActionTakenActionRequestId() {
136         return actionTakenActionRequestId;
137     }
138 
139     public void setActionTakenActionRequestId(String actionTakenActionRequestId) {
140         this.actionTakenActionRequestId = actionTakenActionRequestId;
141     }
142 
143     public String getActionTakenNetworkId() {
144         return actionTakenNetworkId;
145     }
146 
147     public void setActionTakenNetworkId(String actionTakenNetworkId) {
148         this.actionTakenNetworkId = actionTakenNetworkId;
149     }
150 
151     public String getActionTakenWorkGroupId() {
152         return actionTakenWorkGroupId;
153     }
154 
155     public void setActionTakenWorkGroupId(String actionTakenWorkGroupId) {
156         this.actionTakenWorkGroupId = actionTakenWorkGroupId;
157     }
158 
159     /*public List getRouteLevels() {
160         return routeLevels;
161     }
162 
163     public void setRouteLevels(List routeLevels) {
164         this.routeLevels = routeLevels;
165     }*/
166 
167     public boolean isAuthorized() {
168         return authorized;
169     }
170 
171     public void setAuthorized(boolean authorized) {
172         this.authorized = authorized;
173     }
174 
175     @Override
176 	public void reset(ActionMapping mapping, HttpServletRequest request){
177         this.futureNodeNames = new ArrayList<String>();
178     }
179 
180     public String getActionTakenRecipientCode() {
181         return actionTakenRecipientCode;
182     }
183 
184     public void setActionTakenRecipientCode(String actionTakenRecipientCode) {
185         this.actionTakenRecipientCode = actionTakenRecipientCode;
186     }
187 
188     public boolean isSUDocument() {
189 	if (routeHeader.isStateInitiated() || routeHeader.isStateSaved()) {
190             return false;
191         }
192         return true;
193     }
194 
195     public boolean isStateAllowsAction() {
196         if ( routeHeader.isProcessed() || routeHeader.isDisaproved() ) {
197             return false;
198         }
199         return true;
200     }
201 
202     public DocumentType getDocumentType() {
203         return getRouteHeader().getDocumentType();
204     }
205 
206     public Set<KeyValue> getPreviousNodes() throws Exception {
207     	List<String> nodeNames = KewApiServiceLocator.getWorkflowDocumentService().getPreviousRouteNodeNames(routeHeader.getDocumentId());
208         Set<KeyValue> previousNodes = new HashSet<KeyValue>();
209         for (String nodeName : nodeNames) {
210 			previousNodes.add(new ConcreteKeyValue(nodeName, nodeName));
211 		}
212         return previousNodes;
213     }
214 
215     public String getDestNodeName() {
216         return destNodeName;
217     }
218     public void setDestNodeName(String previousNodeName) {
219         this.destNodeName = previousNodeName;
220     }
221     public List<String> getFutureNodeNames() {
222         return futureNodeNames;
223     }
224     public void setFutureNodeNames(List<String> futureNodeNames) {
225         this.futureNodeNames = futureNodeNames;
226     }
227     public String getReturnDestNodeName() {
228         return returnDestNodeName;
229     }
230     public void setReturnDestNodeName(String returnDestNodeName) {
231         this.returnDestNodeName = returnDestNodeName;
232     }
233     public String getLookupableImplServiceName() {
234         return lookupableImplServiceName;
235     }
236     public void setLookupableImplServiceName(String lookupableImplServiceName) {
237         this.lookupableImplServiceName = lookupableImplServiceName;
238     }
239     public String getLookupType() {
240         return lookupType;
241     }
242     public void setLookupType(String lookupType) {
243         this.lookupType = lookupType;
244     }
245     public boolean isRunPostProcessorLogic() {
246         return this.runPostProcessorLogic;
247     }
248     public void setRunPostProcessorLogic(boolean runPostProcessorLogic) {
249         this.runPostProcessorLogic = runPostProcessorLogic;
250     }
251     public String[] getActionRequestRunPostProcessorCheck() {
252         return this.actionRequestRunPostProcessorCheck;
253     }
254     public void setActionRequestRunPostProcessorCheck(String[] actionRequestRunPostProcessorCheck) {
255         this.actionRequestRunPostProcessorCheck = actionRequestRunPostProcessorCheck;
256     }
257     public Boolean getActionRequestPostProcessorCheck(String actionRequestId) {
258         return ArrayUtils.contains(getActionRequestRunPostProcessorCheck(), actionRequestId);
259     }
260     public List<String> getActionRequestPostProcessorCheck() {
261         if (getActionRequestRunPostProcessorCheck() == null) {
262             return null;
263         }
264         return Arrays.asList(getActionRequestRunPostProcessorCheck());
265     }
266 
267     public String getReturnLocation() {
268     	return returnLocation;
269     }
270     public void setReturnLocation(String returnLocation) {
271     	this.returnLocation = returnLocation;
272     }
273     public boolean getActionRequestPostProcessorDisplayCheck(){
274     	return getDocumentType().getSuPostprocessorOverridePolicy().getPolicyValue().booleanValue();
275     }
276 }