1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kew.documentoperation.web; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.apache.struts.action.ActionForm; |
20 | |
import org.apache.struts.action.ActionForward; |
21 | |
import org.apache.struts.action.ActionMapping; |
22 | |
import org.apache.struts.action.ActionMessage; |
23 | |
import org.apache.struts.action.ActionMessages; |
24 | |
import org.kuali.rice.core.api.util.RiceConstants; |
25 | |
import org.kuali.rice.core.api.util.RiceKeyConstants; |
26 | |
import org.kuali.rice.kew.actionitem.ActionItem; |
27 | |
import org.kuali.rice.kew.actionlist.service.ActionListService; |
28 | |
import org.kuali.rice.kew.actionrequest.ActionRequestValue; |
29 | |
import org.kuali.rice.kew.actionrequest.service.ActionRequestService; |
30 | |
import org.kuali.rice.kew.api.document.DocumentOrchestrationQueue; |
31 | |
import org.kuali.rice.kew.api.document.DocumentProcessingOptions; |
32 | |
import org.kuali.rice.kew.api.document.DocumentRefreshQueue; |
33 | |
import org.kuali.rice.kew.api.action.ActionInvocation; |
34 | |
import org.kuali.rice.kew.api.action.ActionInvocationQueue; |
35 | |
import org.kuali.rice.kew.actiontaken.ActionTakenValue; |
36 | |
import org.kuali.rice.kew.actiontaken.service.ActionTakenService; |
37 | |
import org.kuali.rice.kew.api.KewApiServiceLocator; |
38 | |
import org.kuali.rice.kew.api.WorkflowDocument; |
39 | |
import org.kuali.rice.kew.api.WorkflowDocumentFactory; |
40 | |
import org.kuali.rice.kew.api.WorkflowRuntimeException; |
41 | |
import org.kuali.rice.kew.api.action.ActionType; |
42 | |
import org.kuali.rice.kew.api.document.DocumentProcessingQueue; |
43 | |
import org.kuali.rice.kew.api.document.OrchestrationConfig; |
44 | |
import org.kuali.rice.kew.api.document.attribute.DocumentAttributeIndexingQueue; |
45 | |
import org.kuali.rice.kew.doctype.bo.DocumentType; |
46 | |
import org.kuali.rice.kew.doctype.service.DocumentTypeService; |
47 | |
import org.kuali.rice.kew.engine.node.Branch; |
48 | |
import org.kuali.rice.kew.engine.node.BranchState; |
49 | |
import org.kuali.rice.kew.engine.node.NodeState; |
50 | |
import org.kuali.rice.kew.engine.node.RouteNodeInstance; |
51 | |
import org.kuali.rice.kew.engine.node.service.BranchService; |
52 | |
import org.kuali.rice.kew.engine.node.service.RouteNodeService; |
53 | |
import org.kuali.rice.kew.exception.WorkflowServiceErrorException; |
54 | |
import org.kuali.rice.kew.exception.WorkflowServiceErrorImpl; |
55 | |
import org.kuali.rice.kew.messaging.MessageServiceNames; |
56 | |
import org.kuali.rice.kew.routeheader.DocumentRouteHeaderValue; |
57 | |
import org.kuali.rice.kew.routeheader.service.RouteHeaderService; |
58 | |
import org.kuali.rice.kew.rule.bo.RuleTemplateBo; |
59 | |
import org.kuali.rice.kew.service.KEWServiceLocator; |
60 | |
import org.kuali.rice.kew.api.KewApiConstants; |
61 | |
import org.kuali.rice.kew.web.KewKualiAction; |
62 | |
import org.kuali.rice.kim.api.identity.principal.Principal; |
63 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator; |
64 | |
import org.kuali.rice.krad.util.GlobalVariables; |
65 | |
|
66 | |
import javax.servlet.ServletException; |
67 | |
import javax.servlet.http.HttpServletRequest; |
68 | |
import javax.servlet.http.HttpServletResponse; |
69 | |
import java.io.IOException; |
70 | |
import java.sql.Timestamp; |
71 | |
import java.text.ParseException; |
72 | |
import java.util.ArrayList; |
73 | |
import java.util.HashMap; |
74 | |
import java.util.HashSet; |
75 | |
import java.util.Iterator; |
76 | |
import java.util.List; |
77 | |
import java.util.Map; |
78 | |
import java.util.Set; |
79 | |
import java.util.StringTokenizer; |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | 0 | public class DocumentOperationAction extends KewKualiAction { |
88 | 0 | private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(DocumentOperationAction.class); |
89 | |
private static final String DEFAULT_LOG_MSG = "Admin change via document operation"; |
90 | |
|
91 | |
public ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
92 | 0 | return mapping.findForward("basic"); |
93 | |
} |
94 | |
|
95 | |
public ActionForward getDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
96 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
97 | 0 | String docId = null; |
98 | |
|
99 | |
|
100 | 0 | if (StringUtils.isEmpty(docForm.getDocumentId())) { |
101 | 0 | GlobalVariables.getMessageMap().putError("documentId", RiceKeyConstants.ERROR_REQUIRED, "Document ID"); |
102 | |
} else { |
103 | |
try { |
104 | 0 | docId = docForm.getDocumentId().trim(); |
105 | 0 | } catch (NumberFormatException nfe) { |
106 | 0 | GlobalVariables.getMessageMap().putError("documentId", RiceKeyConstants.ERROR_NUMERIC, "Document ID"); |
107 | 0 | } |
108 | |
} |
109 | |
|
110 | 0 | if (docId != null) { |
111 | |
|
112 | 0 | docForm.resetOps(); |
113 | 0 | DocumentRouteHeaderValue routeHeader = getRouteHeaderService().getRouteHeader(docId); |
114 | 0 | List routeNodeInstances=getRouteNodeService().findRouteNodeInstances(docId); |
115 | 0 | Map branches1=new HashMap(); |
116 | 0 | List branches=new ArrayList(); |
117 | |
|
118 | 0 | if (routeHeader == null) { |
119 | 0 | GlobalVariables.getMessageMap().putError("documentId", RiceKeyConstants.ERROR_EXISTENCE, "document"); |
120 | |
} else { |
121 | 0 | materializeDocument(routeHeader); |
122 | 0 | docForm.setRouteHeader(routeHeader); |
123 | 0 | setRouteHeaderTimestampsToString(docForm); |
124 | 0 | docForm.setRouteHeaderOp(KewApiConstants.NOOP); |
125 | 0 | docForm.setDocumentId(docForm.getDocumentId().trim()); |
126 | 0 | String initials=""; |
127 | 0 | for(Iterator lInitials=routeHeader.getInitialRouteNodeInstances().iterator();lInitials.hasNext();){ |
128 | 0 | String initial=((RouteNodeInstance)lInitials.next()).getRouteNodeInstanceId(); |
129 | 0 | LOG.debug(initial); |
130 | 0 | initials=initials+initial+", "; |
131 | 0 | } |
132 | 0 | if(initials.trim().length()>1){ |
133 | 0 | initials=initials.substring(0,initials.lastIndexOf(",")); |
134 | |
} |
135 | 0 | docForm.setInitialNodeInstances(initials); |
136 | 0 | request.getSession().setAttribute("routeNodeInstances",routeNodeInstances); |
137 | 0 | docForm.setRouteNodeInstances(routeNodeInstances); |
138 | 0 | if(routeNodeInstances!=null){ |
139 | 0 | Iterator routeNodeInstanceIter=routeNodeInstances.iterator(); |
140 | 0 | while(routeNodeInstanceIter.hasNext()){ |
141 | 0 | RouteNodeInstance routeNodeInstance=(RouteNodeInstance) routeNodeInstanceIter.next(); |
142 | 0 | Branch branch=routeNodeInstance.getBranch(); |
143 | 0 | if (! branches1.containsKey(branch.getName())){ |
144 | 0 | branches1.put(branch.getName(),branch); |
145 | 0 | branches.add(branch); |
146 | 0 | LOG.debug(branch.getName()+"; "+branch.getBranchState()); |
147 | |
} |
148 | 0 | } |
149 | 0 | if(branches.size()<1){ |
150 | 0 | branches=null; |
151 | |
} |
152 | |
} |
153 | 0 | branches1.clear(); |
154 | 0 | request.getSession().setAttribute("branches",branches); |
155 | 0 | docForm.setBranches(branches); |
156 | |
} |
157 | |
} |
158 | |
|
159 | 0 | return mapping.findForward("basic"); |
160 | |
} |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
|
168 | |
private void materializeDocument(DocumentRouteHeaderValue document) { |
169 | 0 | for (Iterator iterator = document.getActionRequests().iterator(); iterator.hasNext();) { |
170 | 0 | ActionRequestValue request = (ActionRequestValue) iterator.next(); |
171 | 0 | if (request.getNodeInstance() == null) { |
172 | 0 | request.setNodeInstance(new RouteNodeInstance()); |
173 | |
} |
174 | 0 | } |
175 | 0 | } |
176 | |
|
177 | |
public ActionForward clear(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
178 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
179 | 0 | docForm.setRouteHeader(new DocumentRouteHeaderValue()); |
180 | 0 | docForm.setDocumentId(null); |
181 | 0 | return mapping.findForward("basic"); |
182 | |
} |
183 | |
|
184 | |
public ActionMessages establishRequiredState(HttpServletRequest request, ActionForm form) throws Exception { |
185 | 0 | return null; |
186 | |
} |
187 | |
|
188 | |
public ActionForward save(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { |
189 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
190 | 0 | boolean change = false; |
191 | |
|
192 | 0 | String routeHeaderOp = docForm.getRouteHeaderOp(); |
193 | 0 | if (!KewApiConstants.UPDATE.equals(routeHeaderOp) && !KewApiConstants.NOOP.equals(routeHeaderOp)) { |
194 | 0 | throw new WorkflowServiceErrorException("Document operation not defined", new WorkflowServiceErrorImpl("Document operation not defined", "docoperation.operation.invalid")); |
195 | |
} |
196 | 0 | if (KewApiConstants.UPDATE.equals(routeHeaderOp)) { |
197 | 0 | setRouteHeaderTimestamps(docForm); |
198 | 0 | DocumentRouteHeaderValue dHeader = docForm.getRouteHeader(); |
199 | 0 | String initials=docForm.getInitialNodeInstances(); |
200 | 0 | List<RouteNodeInstance> lInitials = new ArrayList<RouteNodeInstance>(); |
201 | 0 | if (StringUtils.isNotEmpty(initials)){ |
202 | 0 | StringTokenizer tokenInitials=new StringTokenizer(initials,","); |
203 | 0 | while (tokenInitials.hasMoreTokens()) { |
204 | 0 | String instanceId = tokenInitials.nextToken().trim(); |
205 | 0 | LOG.debug(instanceId); |
206 | 0 | RouteNodeInstance instance = getRouteNodeService().findRouteNodeInstanceById(instanceId); |
207 | 0 | lInitials.add(instance); |
208 | 0 | } |
209 | |
} |
210 | 0 | dHeader.setInitialRouteNodeInstances(lInitials); |
211 | 0 | getRouteHeaderService().validateRouteHeader(docForm.getRouteHeader()); |
212 | 0 | getRouteHeaderService().saveRouteHeader(docForm.getRouteHeader()); |
213 | 0 | change = true; |
214 | |
} |
215 | |
|
216 | 0 | for (Iterator actionRequestIter = docForm.getActionRequestOps().iterator(); actionRequestIter.hasNext();) { |
217 | 0 | DocOperationIndexedParameter actionRequestOp = (DocOperationIndexedParameter) actionRequestIter.next(); |
218 | 0 | int index = actionRequestOp.getIndex().intValue(); |
219 | 0 | String opValue = actionRequestOp.getValue(); |
220 | 0 | ActionRequestValue actionRequest = docForm.getRouteHeader().getDocActionRequest(index); |
221 | 0 | String createDateParamName = "actionRequestCreateDate" + index; |
222 | |
|
223 | 0 | if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) { |
224 | 0 | throw new WorkflowServiceErrorException("Action request operation not defined", new WorkflowServiceErrorImpl("Action request operation not defined", "docoperation.actionrequest.operation.invalid")); |
225 | |
} |
226 | 0 | if (KewApiConstants.UPDATE.equals(opValue)) { |
227 | |
try { |
228 | 0 | actionRequest.setCreateDate(new Timestamp(RiceConstants.getDefaultDateFormat().parse(request.getParameter(createDateParamName)).getTime())); |
229 | 0 | actionRequest.setCreateDateString(RiceConstants.getDefaultDateFormat().format(actionRequest.getCreateDate())); |
230 | 0 | actionRequest.setDocumentId(docForm.getRouteHeader().getDocumentId()); |
231 | 0 | actionRequest.setParentActionRequest(getActionRequestService().findByActionRequestId(actionRequest.getParentActionRequestId())); |
232 | 0 | actionRequest.setActionTaken(getActionTakenService().findByActionTakenId(actionRequest.getActionTakenId())); |
233 | 0 | if (actionRequest.getNodeInstance() != null && actionRequest.getNodeInstance().getRouteNodeInstanceId() == null) { |
234 | 0 | actionRequest.setNodeInstance(null); |
235 | 0 | } else if (actionRequest.getNodeInstance() != null && actionRequest.getNodeInstance().getRouteNodeInstanceId() != null) { |
236 | 0 | actionRequest.setNodeInstance(KEWServiceLocator.getRouteNodeService().findRouteNodeInstanceById(actionRequest.getNodeInstance().getRouteNodeInstanceId())); |
237 | |
} |
238 | |
|
239 | 0 | getActionRequestService().saveActionRequest(actionRequest); |
240 | 0 | change = true; |
241 | 0 | } catch (ParseException pe) { |
242 | 0 | throw new WorkflowServiceErrorException("Action request create date parsing error", new WorkflowServiceErrorImpl("Action request create date parsing error", "docoperation.actionrequests.dateparsing.error", actionRequest.getActionRequestId().toString())); |
243 | 0 | } |
244 | |
|
245 | |
} |
246 | 0 | if (KewApiConstants.DELETE.equals(opValue)) { |
247 | 0 | getActionRequestService().deleteActionRequestGraph(actionRequest); |
248 | 0 | change = true; |
249 | |
} |
250 | 0 | } |
251 | |
|
252 | 0 | for (Iterator actionTakenIter = docForm.getActionTakenOps().iterator(); actionTakenIter.hasNext();) { |
253 | 0 | DocOperationIndexedParameter actionTakenOp = (DocOperationIndexedParameter) actionTakenIter.next(); |
254 | 0 | int index = actionTakenOp.getIndex().intValue(); |
255 | 0 | String opValue = actionTakenOp.getValue(); |
256 | |
|
257 | 0 | String actionDateParamName = "actionTakenActionDate" + index; |
258 | 0 | ActionTakenValue actionTaken = docForm.getRouteHeader().getDocActionTaken(index); |
259 | 0 | if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) { |
260 | 0 | throw new WorkflowServiceErrorException("Action taken operation not defined", new WorkflowServiceErrorImpl("Action taken operation not defined", "docoperation.actiontaken.operation.invalid")); |
261 | |
} |
262 | 0 | if (KewApiConstants.UPDATE.equals(opValue)) { |
263 | |
try { |
264 | 0 | actionTaken.setActionDate(new Timestamp(RiceConstants.getDefaultDateFormat().parse(request.getParameter(actionDateParamName)).getTime())); |
265 | 0 | actionTaken.setActionDateString(RiceConstants.getDefaultDateFormat().format(actionTaken.getActionDate())); |
266 | |
|
267 | 0 | getActionTakenService().saveActionTaken(actionTaken); |
268 | 0 | change = true; |
269 | 0 | } catch (ParseException pe) { |
270 | 0 | throw new WorkflowServiceErrorException("Action taken action date parsing error", new WorkflowServiceErrorImpl("Action taken action date parse error", "docoperation.actionstaken.dateparsing.error", actionTaken.getActionTakenId().toString())); |
271 | 0 | } |
272 | |
} |
273 | 0 | if (KewApiConstants.DELETE.equals(opValue)) { |
274 | 0 | getActionTakenService().delete(actionTaken); |
275 | 0 | change = true; |
276 | |
} |
277 | 0 | } |
278 | |
|
279 | 0 | for (Iterator actionItemIter = docForm.getActionItemOps().iterator(); actionItemIter.hasNext();) { |
280 | 0 | DocOperationIndexedParameter actionItemOp = (DocOperationIndexedParameter) actionItemIter.next(); |
281 | 0 | int index = actionItemOp.getIndex().intValue(); |
282 | 0 | String opValue = actionItemOp.getValue(); |
283 | |
|
284 | 0 | String dateAssignedParamName = "actionItemDateAssigned" + index; |
285 | 0 | ActionItem actionItem = docForm.getRouteHeader().getDocActionItem(index); |
286 | 0 | if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) { |
287 | 0 | throw new WorkflowServiceErrorException("Action Item operation not defined", new WorkflowServiceErrorImpl("Action Item operation not defined", "docoperation.operation.invalid")); |
288 | |
} |
289 | 0 | if (KewApiConstants.UPDATE.equals(opValue)) { |
290 | |
try { |
291 | 0 | actionItem.setDateAssigned(new Timestamp(RiceConstants.getDefaultDateFormat().parse(request.getParameter(dateAssignedParamName)).getTime())); |
292 | 0 | actionItem.setDateAssignedString(RiceConstants.getDefaultDateFormat().format(actionItem.getDateAssigned())); |
293 | 0 | actionItem.setDocumentId(docForm.getRouteHeader().getDocumentId()); |
294 | |
|
295 | 0 | getActionListService().saveActionItem(actionItem); |
296 | 0 | change = true; |
297 | 0 | } catch (ParseException pe) { |
298 | 0 | throw new WorkflowServiceErrorException("Action item date assigned parsing error", new WorkflowServiceErrorImpl("Action item date assigned parse error", "docoperation.actionitem.dateassignedparsing.error", actionItem.getId().toString())); |
299 | 0 | } |
300 | |
} |
301 | 0 | if (KewApiConstants.DELETE.equals(opValue)) { |
302 | |
try { |
303 | 0 | actionItem.setDateAssigned(new Timestamp(RiceConstants.getDefaultDateFormat().parse(request.getParameter(dateAssignedParamName)).getTime())); |
304 | 0 | actionItem.setDateAssignedString(RiceConstants.getDefaultDateFormat().format(actionItem.getDateAssigned())); |
305 | 0 | actionItem.setDocumentId(docForm.getRouteHeader().getDocumentId()); |
306 | 0 | getActionListService().deleteActionItem(actionItem); |
307 | 0 | change = true; |
308 | 0 | } catch (ParseException pe) { |
309 | 0 | throw new WorkflowServiceErrorException("Action item date assigned parsing error", new WorkflowServiceErrorImpl("Action item date assigned parse error", "docoperation.actionitem.dateassignedparsing.error", actionItem.getId().toString())); |
310 | 0 | } |
311 | |
} |
312 | 0 | } |
313 | |
|
314 | 0 | List routeNodeInstances=(List)(request.getSession().getAttribute("routeNodeInstances")); |
315 | 0 | String ids = (docForm.getNodeStatesDelete() != null) ? docForm.getNodeStatesDelete().trim() : null; |
316 | 0 | List statesToBeDeleted=new ArrayList(); |
317 | 0 | if(ids!=null && !ids.equals("")){ |
318 | 0 | StringTokenizer idSets=new StringTokenizer(ids); |
319 | 0 | while (idSets.hasMoreTokens()) { |
320 | 0 | String id=idSets.nextToken().trim(); |
321 | 0 | statesToBeDeleted.add(Long.valueOf(id)); |
322 | 0 | } |
323 | |
} |
324 | |
|
325 | 0 | for (Iterator routeNodeInstanceIter = docForm.getRouteNodeInstanceOps().iterator(); routeNodeInstanceIter.hasNext();) { |
326 | 0 | DocOperationIndexedParameter routeNodeInstanceOp = (DocOperationIndexedParameter) routeNodeInstanceIter.next(); |
327 | 0 | int index = routeNodeInstanceOp.getIndex().intValue(); |
328 | 0 | String opValue = routeNodeInstanceOp.getValue(); |
329 | 0 | LOG.debug(opValue); |
330 | 0 | RouteNodeInstance routeNodeInstance = (RouteNodeInstance)(routeNodeInstances.get(index)); |
331 | 0 | RouteNodeInstance routeNodeInstanceNew = (RouteNodeInstance)(docForm.getRouteNodeInstance(index)); |
332 | 0 | if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.DELETE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) { |
333 | 0 | throw new WorkflowServiceErrorException("Route Node Instance Operation not defined", new WorkflowServiceErrorImpl("Route Node Instance Operation not defined", "docoperation.routenodeinstance.operation.invalid")); |
334 | |
} |
335 | 0 | if (KewApiConstants.UPDATE.equals(opValue)) { |
336 | |
|
337 | |
|
338 | 0 | routeNodeInstance.setActive(routeNodeInstanceNew.isActive()); |
339 | 0 | LOG.debug(Boolean.toString(routeNodeInstanceNew.isActive())); |
340 | 0 | routeNodeInstance.setComplete(routeNodeInstanceNew.isComplete()); |
341 | 0 | routeNodeInstance.setInitial(routeNodeInstanceNew.isInitial()); |
342 | 0 | List nodeStates=routeNodeInstance.getState(); |
343 | 0 | List nodeStatesNew=routeNodeInstanceNew.getState(); |
344 | |
|
345 | 0 | if(nodeStates!=null){ |
346 | 0 | for(int i=0;i<nodeStates.size();i++){ |
347 | 0 | NodeState nodeState=(NodeState)nodeStates.get(i); |
348 | 0 | NodeState nodeStateNew=(NodeState)nodeStatesNew.get(i); |
349 | 0 | if(nodeStateNew.getKey()!=null && ! nodeStateNew.getKey().trim().equals("")){ |
350 | 0 | nodeState.setKey(nodeStateNew.getKey()); |
351 | 0 | LOG.debug(nodeState.getKey()); |
352 | 0 | nodeState.setValue(nodeStateNew.getValue()); |
353 | 0 | LOG.debug(nodeState.getValue()); |
354 | |
} |
355 | |
} |
356 | |
} |
357 | 0 | getRouteNodeService().save(routeNodeInstance); |
358 | 0 | LOG.debug("saved"); |
359 | 0 | change = true; |
360 | |
} |
361 | |
|
362 | |
|
363 | 0 | if (KewApiConstants.DELETE.equals(opValue)) { |
364 | 0 | List nodeStates=routeNodeInstance.getState(); |
365 | 0 | List nodeStatesNew=routeNodeInstanceNew.getState(); |
366 | |
|
367 | 0 | if(nodeStates!=null){ |
368 | 0 | for(int i=0;i<nodeStates.size();i++){ |
369 | 0 | NodeState nodeState=(NodeState)nodeStates.get(i); |
370 | 0 | NodeState nodeStateNew=(NodeState)nodeStatesNew.get(i); |
371 | 0 | if(nodeStateNew.getKey()==null || nodeStateNew.getKey().trim().equals("")){ |
372 | 0 | statesToBeDeleted.remove(nodeState.getNodeStateId()); |
373 | |
} |
374 | |
} |
375 | |
} |
376 | 0 | getRouteNodeService().deleteByRouteNodeInstance(routeNodeInstance); |
377 | 0 | LOG.debug(routeNodeInstance.getRouteNodeInstanceId()+" is deleted"); |
378 | 0 | change = true; |
379 | 0 | break; |
380 | |
} |
381 | |
|
382 | 0 | if (KewApiConstants.NOOP.equals(opValue)){ |
383 | 0 | routeNodeInstanceNew.setActive(routeNodeInstance.isActive()); |
384 | 0 | routeNodeInstanceNew.setComplete(routeNodeInstance.isComplete()); |
385 | 0 | routeNodeInstanceNew.setInitial(routeNodeInstance.isInitial()); |
386 | 0 | List nodeStates=routeNodeInstance.getState(); |
387 | 0 | List nodeStatesNew=routeNodeInstanceNew.getState(); |
388 | 0 | if(nodeStates!=null){ |
389 | 0 | for(int i=0;i<nodeStates.size();i++){ |
390 | 0 | NodeState nodeState=(NodeState)nodeStates.get(i); |
391 | 0 | NodeState nodeStateNew=(NodeState)nodeStatesNew.get(i); |
392 | 0 | if(nodeStateNew.getKey()==null || nodeStateNew.getKey().trim().equals("")){ |
393 | 0 | statesToBeDeleted.remove(nodeState.getNodeStateId()); |
394 | |
} |
395 | 0 | nodeStateNew.setKey(nodeState.getKey()); |
396 | 0 | nodeStateNew.setValue(nodeState.getValue()); |
397 | |
} |
398 | |
} |
399 | |
} |
400 | |
|
401 | |
|
402 | 0 | } |
403 | |
|
404 | 0 | if(statesToBeDeleted!=null && statesToBeDeleted.size()>0){ |
405 | 0 | getRouteNodeService().deleteNodeStates(statesToBeDeleted); |
406 | |
} |
407 | |
|
408 | |
|
409 | 0 | List branches=(List)(request.getSession().getAttribute("branches")); |
410 | 0 | String branchStateIds = (docForm.getBranchStatesDelete() != null) ? docForm.getBranchStatesDelete().trim() : null; |
411 | 0 | List branchStatesToBeDeleted=new ArrayList(); |
412 | 0 | if(branchStateIds!=null && !branchStateIds.equals("")){ |
413 | 0 | StringTokenizer idSets=new StringTokenizer(branchStateIds); |
414 | 0 | while (idSets.hasMoreTokens()) { |
415 | 0 | String id=idSets.nextToken().trim(); |
416 | 0 | branchStatesToBeDeleted.add(Long.valueOf(id)); |
417 | 0 | } |
418 | |
} |
419 | |
|
420 | 0 | for (Iterator branchesOpIter = docForm.getBranchOps().iterator(); branchesOpIter.hasNext();) { |
421 | 0 | DocOperationIndexedParameter branchesOp = (DocOperationIndexedParameter) branchesOpIter.next(); |
422 | 0 | int index = branchesOp.getIndex().intValue(); |
423 | 0 | String opValue = branchesOp.getValue(); |
424 | 0 | LOG.debug(opValue); |
425 | 0 | Branch branch = (Branch)(branches.get(index)); |
426 | 0 | Branch branchNew = (Branch)(docForm.getBranche(index)); |
427 | 0 | if (!KewApiConstants.UPDATE.equals(opValue) && !KewApiConstants.NOOP.equals(opValue)) { |
428 | 0 | throw new WorkflowServiceErrorException("Route Node Instance Operation not defined", new WorkflowServiceErrorImpl("Route Node Instance Operation not defined", "docoperation.routenodeinstance.operation.invalid")); |
429 | |
} |
430 | 0 | if (KewApiConstants.UPDATE.equals(opValue)) { |
431 | |
|
432 | |
|
433 | 0 | branch.setName(branchNew.getName()); |
434 | 0 | List branchStates=branch.getBranchState(); |
435 | 0 | List branchStatesNew=branchNew.getBranchState(); |
436 | 0 | if(branchStates!=null){ |
437 | 0 | for(int i=0;i<branchStates.size();i++){ |
438 | 0 | BranchState branchState=(BranchState)branchStates.get(i); |
439 | 0 | BranchState branchStateNew=(BranchState)branchStatesNew.get(i); |
440 | 0 | if(branchStateNew.getKey()!=null && ! branchStateNew.getKey().trim().equals("")){ |
441 | 0 | branchState.setKey(branchStateNew.getKey()); |
442 | 0 | LOG.debug(branchState.getKey()); |
443 | 0 | branchState.setValue(branchStateNew.getValue()); |
444 | 0 | LOG.debug(branchState.getValue()); |
445 | |
} |
446 | |
} |
447 | |
} |
448 | 0 | getBranchService().save(branch); |
449 | 0 | LOG.debug("branch saved"); |
450 | 0 | change = true; |
451 | |
|
452 | |
} |
453 | |
|
454 | |
|
455 | 0 | if (KewApiConstants.NOOP.equals(opValue)){ |
456 | 0 | branchNew.setName(branch.getName()); |
457 | 0 | List branchStates=branch.getBranchState(); |
458 | 0 | List branchStatesNew=branchNew.getBranchState(); |
459 | 0 | if(branchStates!=null){ |
460 | 0 | for(int i=0;i<branchStates.size();i++){ |
461 | 0 | BranchState branchState=(BranchState)branchStates.get(i); |
462 | 0 | BranchState branchStateNew=(BranchState)branchStatesNew.get(i); |
463 | 0 | if(branchStateNew.getKey()==null || branchStateNew.getKey().trim().equals("")){ |
464 | 0 | branchStatesToBeDeleted.remove(branchState.getBranchStateId()); |
465 | |
} |
466 | 0 | branchStateNew.setKey(branchState.getKey()); |
467 | 0 | LOG.debug(branchState.getKey()); |
468 | 0 | branchStateNew.setValue(branchState.getValue()); |
469 | 0 | LOG.debug(branchState.getValue()); |
470 | |
} |
471 | |
} |
472 | |
} |
473 | |
|
474 | 0 | } |
475 | |
|
476 | 0 | if(branchStatesToBeDeleted!=null && branchStatesToBeDeleted.size()>0){ |
477 | 0 | getBranchService().deleteBranchStates(branchStatesToBeDeleted); |
478 | |
} |
479 | |
|
480 | 0 | WorkflowDocument workflowDocument = WorkflowDocumentFactory.loadDocument(GlobalVariables.getUserSession().getPrincipalId(), docForm.getDocumentId()); |
481 | |
|
482 | 0 | String annotation = docForm.getAnnotation(); |
483 | 0 | if (StringUtils.isEmpty(annotation)) { |
484 | 0 | annotation = DEFAULT_LOG_MSG; |
485 | |
} |
486 | 0 | workflowDocument.logAnnotation(annotation); |
487 | |
|
488 | 0 | ActionMessages messages = new ActionMessages(); |
489 | 0 | String forward = null; |
490 | 0 | if (change) { |
491 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("docoperation.operation.saved")); |
492 | 0 | docForm.setRouteHeader(getRouteHeaderService().getRouteHeader(docForm.getRouteHeader().getDocumentId())); |
493 | 0 | forward = "summary"; |
494 | |
} else { |
495 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("docoperation.operation.noop")); |
496 | 0 | forward = "basic"; |
497 | |
} |
498 | 0 | saveMessages(request, messages); |
499 | 0 | return mapping.findForward(forward); |
500 | |
|
501 | |
} |
502 | |
|
503 | |
private RouteHeaderService getRouteHeaderService() { |
504 | 0 | return (RouteHeaderService) KEWServiceLocator.getService(KEWServiceLocator.DOC_ROUTE_HEADER_SRV); |
505 | |
} |
506 | |
|
507 | |
private RouteNodeService getRouteNodeService(){ |
508 | 0 | return (RouteNodeService) KEWServiceLocator.getService(KEWServiceLocator.ROUTE_NODE_SERVICE); |
509 | |
} |
510 | |
|
511 | |
private ActionRequestService getActionRequestService() { |
512 | 0 | return (ActionRequestService) KEWServiceLocator.getService(KEWServiceLocator.ACTION_REQUEST_SRV); |
513 | |
} |
514 | |
|
515 | |
private ActionTakenService getActionTakenService() { |
516 | 0 | return (ActionTakenService) KEWServiceLocator.getService(KEWServiceLocator.ACTION_TAKEN_SRV); |
517 | |
} |
518 | |
|
519 | |
private ActionListService getActionListService() { |
520 | 0 | return (ActionListService) KEWServiceLocator.getActionListService(); |
521 | |
} |
522 | |
|
523 | |
private void setRouteHeaderTimestamps(DocumentOperationForm docForm) { |
524 | 0 | if (docForm.getCreateDate() == null || docForm.getCreateDate().trim().equals("")) { |
525 | 0 | throw new WorkflowServiceErrorException("Document create date empty", new WorkflowServiceErrorImpl("Document create date empty", "docoperation.routeheader.createdate.empty")); |
526 | |
} else { |
527 | |
try { |
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
|
540 | 0 | docForm.getRouteHeader().setCreateDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getCreateDate()).getTime())); |
541 | 0 | } catch (ParseException pe) { |
542 | 0 | throw new WorkflowServiceErrorException("RouteHeader create date parsing error", new WorkflowServiceErrorImpl("Date parsing error", "docoperation.routeheader.createdate.invalid")); |
543 | 0 | } |
544 | |
} |
545 | |
|
546 | 0 | if (docForm.getStatusModDate() == null || docForm.getStatusModDate().trim().equals("")) { |
547 | 0 | throw new WorkflowServiceErrorException("Document doc status mod date empty", new WorkflowServiceErrorImpl("Document doc status mod date empty", "docoperation.routeheader.statusmoddate.empty")); |
548 | |
} else { |
549 | |
try { |
550 | 0 | docForm.getRouteHeader().setStatusModDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getStatusModDate()).getTime())); |
551 | 0 | } catch (ParseException pe) { |
552 | 0 | throw new WorkflowServiceErrorException("Document doc status date parsing error", new WorkflowServiceErrorImpl("Document doc status mod date parsing error", "docoperation.routeheader.statusmoddate.invalid")); |
553 | 0 | } |
554 | |
} |
555 | |
|
556 | 0 | if (docForm.getApprovedDate() != null && !docForm.getApprovedDate().trim().equals("")) { |
557 | |
try { |
558 | 0 | docForm.getRouteHeader().setApprovedDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getApprovedDate()).getTime())); |
559 | 0 | } catch (ParseException pe) { |
560 | 0 | throw new WorkflowServiceErrorException("Document approved date parsing error", new WorkflowServiceErrorImpl("Document approved date parsing error", "docoperation.routeheader.approveddate.invalid")); |
561 | 0 | } |
562 | |
|
563 | |
} |
564 | |
|
565 | 0 | if (docForm.getFinalizedDate() != null && !docForm.getFinalizedDate().trim().equals("")) { |
566 | |
try { |
567 | 0 | docForm.getRouteHeader().setFinalizedDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getFinalizedDate()).getTime())); |
568 | 0 | } catch (ParseException pe) { |
569 | 0 | throw new WorkflowServiceErrorException("Document finalized date parsing error", new WorkflowServiceErrorImpl("Document finalized date parsing error", "docoperation.routeheader.finalizeddate.invalid")); |
570 | 0 | } |
571 | |
} |
572 | |
|
573 | 0 | if (docForm.getRouteStatusDate() != null && !docForm.getRouteStatusDate().trim().equals("")) { |
574 | |
try { |
575 | 0 | docForm.getRouteHeader().setRouteStatusDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getRouteStatusDate()).getTime())); |
576 | 0 | } catch (ParseException pe) { |
577 | 0 | throw new WorkflowServiceErrorException("Document route status date parsing error", new WorkflowServiceErrorImpl("Document route status date parsing error", "docoperation.routeheader.routestatusdate.invalid")); |
578 | 0 | } |
579 | |
|
580 | |
} |
581 | |
|
582 | 0 | if (docForm.getRouteLevelDate() != null && !docForm.getRouteLevelDate().trim().equals("")) { |
583 | |
try { |
584 | 0 | docForm.getRouteHeader().setRouteLevelDate(new Timestamp(RiceConstants.getDefaultDateAndTimeFormat().parse(docForm.getRouteLevelDate()).getTime())); |
585 | 0 | } catch (ParseException pe) { |
586 | 0 | throw new WorkflowServiceErrorException("Document route level date parsing error", new WorkflowServiceErrorImpl("Document route level date parsing error", "docoperation.routeheader.routeleveldate.invalid")); |
587 | 0 | } |
588 | |
} |
589 | 0 | } |
590 | |
|
591 | |
private void setRouteHeaderTimestampsToString(DocumentOperationForm docForm) { |
592 | |
try { |
593 | 0 | docForm.setCreateDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getCreateDate())); |
594 | 0 | docForm.setStatusModDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getStatusModDate())); |
595 | 0 | docForm.setApprovedDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getApprovedDate())); |
596 | 0 | docForm.setFinalizedDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getFinalizedDate())); |
597 | 0 | docForm.setRouteStatusDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getRouteStatusDate())); |
598 | 0 | docForm.setRouteLevelDate(RiceConstants.getDefaultDateAndTimeFormat().format(docForm.getRouteHeader().getRouteLevelDate())); |
599 | |
|
600 | 0 | } catch (Exception e) { |
601 | 0 | LOG.info("One or more of the dates in routeHeader may be null"); |
602 | 0 | } |
603 | 0 | } |
604 | |
|
605 | |
public ActionForward refresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
606 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
607 | 0 | String lookupInvocationModule = docForm.getLookupInvocationModule(); |
608 | 0 | docForm.getRouteHeader().setDocumentId(docForm.getDocumentId()); |
609 | |
|
610 | 0 | if (lookupInvocationModule != null && !lookupInvocationModule.trim().equals("")) { |
611 | 0 | String lookupField = docForm.getLookupInvocationField(); |
612 | 0 | int lookupIndex = new Integer(docForm.getLookupInvocationIndex()).intValue(); |
613 | 0 | String networkId = request.getParameter("networkId"); |
614 | 0 | String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(networkId); |
615 | |
|
616 | 0 | if (lookupInvocationModule.equals("RouteHeader")) { |
617 | 0 | DocumentRouteHeaderValue routeHeader = docForm.getRouteHeader(); |
618 | 0 | if ("initiatorWorkflowId".equals(lookupField)) { |
619 | 0 | routeHeader.setInitiatorWorkflowId(principalId); |
620 | |
} |
621 | 0 | if ("documentTypeId".equals(lookupField)) { |
622 | 0 | DocumentType docType = getDocumentTypeService().findByName(request.getParameter("docTypeFullName")); |
623 | 0 | routeHeader.setDocumentTypeId(docType.getDocumentTypeId()); |
624 | |
} |
625 | |
} |
626 | |
|
627 | 0 | if (lookupInvocationModule.equals("ActionRequest")) { |
628 | 0 | ActionRequestValue actionRequest = docForm.getRouteHeader().getDocActionRequest(lookupIndex); |
629 | 0 | if ("routeMethodName".equals(lookupField)) { |
630 | |
|
631 | 0 | String id = request.getParameter("ruleTemplate.ruleTemplateId"); |
632 | 0 | if (id != null && !"".equals(id.trim())) { |
633 | 0 | RuleTemplateBo ruleTemplate = KEWServiceLocator.getRuleTemplateService().findByRuleTemplateId(id); |
634 | |
|
635 | |
|
636 | |
|
637 | |
} |
638 | |
} |
639 | 0 | if ("workflowId".equals(lookupField)) { |
640 | 0 | actionRequest.setPrincipalId(principalId); |
641 | |
} |
642 | 0 | if ("workgroupId".equals(lookupField)) { |
643 | 0 | if (request.getParameter("workgroupId") != null && !"".equals(request.getParameter("workgroupId").trim())) { |
644 | 0 | actionRequest.setGroupId(request.getParameter("workgroupId")); |
645 | |
} else { |
646 | 0 | actionRequest.setGroupId(null); |
647 | |
} |
648 | |
} |
649 | 0 | if ("roleName".equals(lookupField)) { |
650 | 0 | actionRequest.setRoleName(request.getParameter("roleName")); |
651 | |
} |
652 | |
} |
653 | 0 | if (lookupInvocationModule.equals("ActionTaken")) { |
654 | 0 | ActionTakenValue actionTaken = docForm.getRouteHeader().getDocActionTaken(lookupIndex); |
655 | 0 | if ("workflowId".equals(lookupField)) { |
656 | 0 | Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(networkId); |
657 | 0 | if (principal != null) { |
658 | 0 | actionTaken.setPrincipalId(principal.getPrincipalId()); |
659 | |
} else { |
660 | 0 | LOG.info("action taken user not found"); |
661 | 0 | actionTaken.setPrincipalId(null); |
662 | |
} |
663 | |
} |
664 | 0 | if ("delegatorPrincipalId".equals(lookupField)) { |
665 | 0 | Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(networkId); |
666 | 0 | if (principal != null) { |
667 | 0 | actionTaken.setDelegatorPrincipalId(principal.getPrincipalId()); |
668 | |
} else { |
669 | 0 | LOG.info("action taken delegator user not found"); |
670 | 0 | actionTaken.setDelegatorPrincipalId(null); |
671 | |
} |
672 | |
} |
673 | 0 | if ("delegatorGroupId".equals(lookupField)) { |
674 | 0 | if (request.getParameter("workgroupId") != null && !"".equals(request.getParameter("workgroupId").trim())) { |
675 | 0 | actionTaken.setDelegatorGroupId(request.getParameter("workgroupId")); |
676 | |
} else { |
677 | 0 | actionTaken.setDelegatorGroupId(null); |
678 | |
} |
679 | |
} |
680 | |
} |
681 | |
|
682 | 0 | if (lookupInvocationModule.equals("ActionItem")) { |
683 | 0 | ActionItem actionItem = docForm.getRouteHeader().getDocActionItem(lookupIndex); |
684 | 0 | if ("workflowId".equals(lookupField)) { |
685 | 0 | Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(networkId); |
686 | 0 | if (principal != null) { |
687 | 0 | actionItem.setPrincipalId(principal.getPrincipalId()); |
688 | |
} else { |
689 | 0 | LOG.info("action item user not found"); |
690 | 0 | actionItem.setPrincipalId(null); |
691 | |
} |
692 | |
} |
693 | |
|
694 | 0 | if ("workgroupId".equals(lookupField)) { |
695 | 0 | if (request.getParameter("workgroupId") != null && !"".equals(request.getParameter("workgroupId").trim())) { |
696 | 0 | actionItem.setGroupId(request.getParameter("workgroupId")); |
697 | |
} else { |
698 | 0 | actionItem.setGroupId(null); |
699 | |
} |
700 | |
} |
701 | 0 | if ("roleName".equals(lookupField)) { |
702 | 0 | actionItem.setRoleName(request.getParameter("roleName")); |
703 | |
} |
704 | 0 | if ("delegatorPrincipalId".equals(lookupField)) { |
705 | 0 | Principal principal = KimApiServiceLocator.getIdentityService().getPrincipalByPrincipalName(networkId); |
706 | 0 | if (principal != null) { |
707 | 0 | actionItem.setDelegatorPrincipalId(principal.getPrincipalId()); |
708 | |
} else { |
709 | 0 | LOG.info("action item delegator user not found"); |
710 | 0 | actionItem.setDelegatorPrincipalId(null); |
711 | |
} |
712 | |
} |
713 | 0 | if ("delegatorGroupId".equals(lookupField)) { |
714 | 0 | if (request.getParameter("workgroupId") != null && !"".equals(request.getParameter("workgroupId").trim())) { |
715 | 0 | actionItem.setDelegatorGroupId(request.getParameter("workgroupId")); |
716 | |
} else { |
717 | 0 | actionItem.setDelegatorGroupId(null); |
718 | |
} |
719 | |
} |
720 | 0 | if ("docName".equals(lookupField)) { |
721 | 0 | DocumentType docType = getDocumentTypeService().findByName(request.getParameter("docTypeFullName")); |
722 | 0 | actionItem.setDocName(docType.getName()); |
723 | 0 | actionItem.setDocLabel(docType.getLabel()); |
724 | 0 | actionItem.setDocHandlerURL(docType.getDocHandlerUrl()); |
725 | |
} |
726 | |
} |
727 | |
} |
728 | |
|
729 | 0 | return mapping.findForward("basic"); |
730 | |
} |
731 | |
|
732 | |
public ActionForward queueDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
733 | |
try { |
734 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
735 | 0 | DocumentProcessingQueue documentProcessingQueue = MessageServiceNames.getDocumentProcessingQueue(docForm.getRouteHeader()); |
736 | 0 | documentProcessingQueue.process(docForm.getDocumentId()); |
737 | 0 | ActionMessages messages = new ActionMessages(); |
738 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Document was successfully queued")); |
739 | 0 | saveMessages(request, messages); |
740 | 0 | return mapping.findForward("basic"); |
741 | 0 | } catch (Exception e) { |
742 | 0 | throw new WorkflowRuntimeException(e); |
743 | |
} |
744 | |
} |
745 | |
|
746 | |
public ActionForward indexSearchableAttributes(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
747 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
748 | 0 | DocumentAttributeIndexingQueue queue = KewApiServiceLocator.getDocumentAttributeIndexingQueue(docForm.getRouteHeader().getDocumentType().getApplicationId()); |
749 | 0 | queue.indexDocument(docForm.getRouteHeader().getDocumentId()); |
750 | 0 | ActionMessages messages = new ActionMessages(); |
751 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Searchable Attribute Indexing was successfully scheduled")); |
752 | 0 | saveMessages(request, messages); |
753 | 0 | return mapping.findForward("basic"); |
754 | |
} |
755 | |
|
756 | |
public ActionForward queueDocumentRefresh(ActionMapping mapping, ActionForm form, HttpServletRequest request, |
757 | |
HttpServletResponse response) throws IOException, ServletException { |
758 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
759 | 0 | DocumentRefreshQueue docRequeue = MessageServiceNames.getDocumentRequeuerService(docForm.getRouteHeader().getDocumentType().getApplicationId(), docForm.getRouteHeader().getDocumentId(), 0); |
760 | 0 | docRequeue.refreshDocument(docForm.getRouteHeader().getDocumentId()); |
761 | 0 | ActionMessages messages = new ActionMessages(); |
762 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Document Requeuer was successfully scheduled")); |
763 | 0 | saveMessages(request, messages); |
764 | 0 | return mapping.findForward("basic"); |
765 | |
} |
766 | |
|
767 | |
public ActionForward blanketApproveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
768 | |
try { |
769 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
770 | 0 | String principalId = KimApiServiceLocator.getPersonService().getPersonByPrincipalName(docForm.getBlanketApproveUser()).getPrincipalId(); |
771 | 0 | Set<String> nodeNames = new HashSet<String>(); |
772 | 0 | if (!StringUtils.isBlank(docForm.getBlanketApproveNodes())) { |
773 | 0 | String[] nodeNameArray = docForm.getBlanketApproveNodes().split(","); |
774 | 0 | for (String nodeName : nodeNameArray) { |
775 | 0 | nodeNames.add(nodeName.trim()); |
776 | |
} |
777 | |
} |
778 | 0 | DocumentOrchestrationQueue blanketApprove = MessageServiceNames.getDocumentOrchestrationQueue( |
779 | |
docForm.getRouteHeader()); |
780 | 0 | OrchestrationConfig orchestrationConfig = OrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames); |
781 | 0 | DocumentProcessingOptions options = DocumentProcessingOptions.createDefault(); |
782 | 0 | blanketApprove.orchestrateDocument(docForm.getRouteHeader().getDocumentId(), principalId, |
783 | |
orchestrationConfig, options); |
784 | 0 | ActionMessages messages = new ActionMessages(); |
785 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Blanket Approve Processor was successfully scheduled")); |
786 | 0 | saveMessages(request, messages); |
787 | 0 | return mapping.findForward("basic"); |
788 | 0 | } catch (Exception e) { |
789 | 0 | throw new WorkflowRuntimeException(e); |
790 | |
} |
791 | |
} |
792 | |
|
793 | |
public ActionForward moveDocument(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
794 | |
try { |
795 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
796 | 0 | String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getBlanketApproveUser()); |
797 | 0 | Set<String> nodeNames = new HashSet<String>(); |
798 | 0 | if (!StringUtils.isBlank(docForm.getBlanketApproveNodes())) { |
799 | 0 | String[] nodeNameArray = docForm.getBlanketApproveNodes().split(","); |
800 | 0 | for (String nodeName : nodeNameArray) { |
801 | 0 | nodeNames.add(nodeName.trim()); |
802 | |
} |
803 | |
} |
804 | 0 | DocumentOrchestrationQueue orchestrationQueue = MessageServiceNames.getDocumentOrchestrationQueue( |
805 | |
docForm.getRouteHeader()); |
806 | 0 | OrchestrationConfig orchestrationConfig = OrchestrationConfig.create(docForm.getBlanketApproveActionTakenId(), nodeNames); |
807 | 0 | DocumentProcessingOptions options = DocumentProcessingOptions.create(true, true, false); |
808 | 0 | orchestrationQueue.orchestrateDocument(docForm.getDocumentId(), principalId, orchestrationConfig, options); |
809 | |
|
810 | 0 | ActionMessages messages = new ActionMessages(); |
811 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Move Document Processor was successfully scheduled")); |
812 | 0 | saveMessages(request, messages); |
813 | 0 | return mapping.findForward("basic"); |
814 | 0 | } catch (Exception e) { |
815 | 0 | throw new WorkflowRuntimeException(e); |
816 | |
} |
817 | |
} |
818 | |
|
819 | |
public ActionForward queueActionInvocation(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { |
820 | |
try { |
821 | 0 | DocumentOperationForm docForm = (DocumentOperationForm) form; |
822 | 0 | String principalId = KEWServiceLocator.getIdentityHelperService().getIdForPrincipalName(docForm.getActionInvocationUser()); |
823 | 0 | ActionInvocation invocation = ActionInvocation.create(ActionType.fromCode( |
824 | |
docForm.getActionInvocationActionCode()), docForm.getActionInvocationActionItemId()); |
825 | 0 | ActionInvocationQueue actionInvocationQueue = MessageServiceNames.getActionInvocationProcessorService(docForm.getRouteHeader()); |
826 | 0 | actionInvocationQueue.invokeAction(principalId, docForm.getRouteHeader().getDocumentId(), invocation); |
827 | 0 | ActionMessages messages = new ActionMessages(); |
828 | 0 | messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("general.message", "Action Invocation Processor was successfully scheduled")); |
829 | 0 | saveMessages(request, messages); |
830 | 0 | return mapping.findForward("basic"); |
831 | 0 | } catch (Exception e) { |
832 | 0 | throw new WorkflowRuntimeException(e); |
833 | |
} |
834 | |
} |
835 | |
|
836 | |
private DocumentTypeService getDocumentTypeService() { |
837 | 0 | return (DocumentTypeService) KEWServiceLocator.getService(KEWServiceLocator.DOCUMENT_TYPE_SERVICE); |
838 | |
} |
839 | |
|
840 | |
private BranchService getBranchService(){ |
841 | 0 | return (BranchService) KEWServiceLocator.getService(KEWServiceLocator.BRANCH_SERVICE); |
842 | |
} |
843 | |
} |