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