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 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 protected Map appSpecificRouteActionRequestCds = new HashMap();
51
52 protected AppSpecificRouteRecipient appSpecificRouteRecipient = new AppSpecificRouteRecipient();
53 protected AppSpecificRouteRecipient appSpecificRouteRecipient2 = new AppSpecificRouteRecipient();
54 protected List appSpecificRouteList = new ArrayList();
55
56 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 appSpecificRouteRecipient = new AppSpecificRouteRecipient();
66 appSpecificRouteRecipient2 = new AppSpecificRouteRecipient();
67 }
68
69 public Map getAppSpecificRouteActionRequestCds() {
70 return appSpecificRouteActionRequestCds;
71 }
72
73
74
75
76 public String getInitiateURL() {
77 return initiateURL;
78 }
79
80
81
82 public void setInitiateURL(String initiateURL) {
83 this.initiateURL = initiateURL;
84 }
85
86
87
88 public String getCommand() {
89 return command;
90 }
91
92
93
94 public void setCommand(String command) {
95 this.command = command;
96 }
97
98
99
100 public String getAnnotation() {
101 return annotation;
102 }
103
104
105
106 public void setAnnotation(String annotation) {
107 this.annotation = annotation;
108 }
109
110
111
112 public boolean isShowBlanketApproveButton() {
113 return showBlanketApproveButton;
114 }
115
116
117
118 public void setShowBlanketApproveButton(boolean blanketApprove) {
119 this.showBlanketApproveButton = blanketApprove;
120 }
121
122
123
124 public String getDocId() {
125 return docId;
126 }
127
128
129
130 public void setDocId(String docId) {
131 this.docId = docId;
132 }
133
134
135
136 public WorkflowDocument getWorkflowDocument() {
137 return workflowDocument;
138 }
139
140
141
142 public void setWorkflowDocument(WorkflowDocument workflowDocument) {
143 this.workflowDocument = workflowDocument;
144 }
145
146
147
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 }