Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.impl.document;
 
 import java.util.List;
 
A service which effectively "refreshes" and requeues a document. It first deletes any pending action requests on the documents and then requeues the document for standard routing. Addionally, it adds duplicate notification suppression state to RouteNodeInstanceS for which ActionRequestS will be regenerated.

Intended to be called async and wired that way in server/client spring beans.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class DocumentRefreshQueueImpl implements DocumentRefreshQueue {
 	
 	private RouteHelper helper = new RouteHelper();
    
Requeues a document, and sets notification suppression data

 
 	public void refreshDocument(String documentId) {
 		if (StringUtils.isBlank(documentId)) {
             throw new RiceIllegalArgumentException("documentId is null or blank");
         }
 
         PerformanceLogger performanceLogger = new PerformanceLogger();
         KEWServiceLocator.getRouteHeaderService().lockRouteHeader(documentIdtrue);
         Collection<RouteNodeInstanceactiveNodes = getRouteNodeService().getActiveNodeInstances(documentId);
         List<ActionRequestValuerequestsToDelete = new ArrayList<ActionRequestValue>();
         
 		NotificationSuppression notificationSuppression = new NotificationSuppression();
 		
         for (RouteNodeInstance nodeInstance : activeNodes) {
             // only "requeue" if we're dealing with a request activation node
             if (.isRequestActivationNode(nodeInstance.getRouteNode())) {
             	List<ActionRequestValuedeletesForThisNode = 
             		getActionRequestService().findPendingRootRequestsByDocIdAtRouteNode(documentIdnodeInstance.getRouteNodeInstanceId());
             	
             	for (ActionRequestValue deleteForThisNode : deletesForThisNode) {
             		// only delete the request if it was generated by a route module (or the rules system)
             		if (deleteForThisNode.isRouteModuleRequest()) {
             			requestsToDelete.add(deleteForThisNode);
 
             			// suppress duplicate notifications
             			notificationSuppression.addNotificationSuppression(nodeInstancedeleteForThisNode);
             		}
             	}
                 // this will trigger a regeneration of requests
                 nodeInstance.setInitial(true);
                 getRouteNodeService().save(nodeInstance);
             }
         }
         for (ActionRequestValue requestToDelete : requestsToDelete) {
             getActionRequestService().deleteActionRequestGraph(requestToDelete);
         }
         try {
             OrchestrationConfig config = new OrchestrationConfig(.);
         	KEWServiceLocator.getWorkflowEngineFactory().newEngine(config).process(documentIdnull);
         } catch (Exception e) {
         	throw new WorkflowRuntimeException(e);
         }
         performanceLogger.log("Time to run DocumentRequeuer for document " + documentId);	
	}
        return KEWServiceLocator.getActionRequestService();
    }
    
        return KEWServiceLocator.getRouteNodeService();
    }
New to GrepCode? Check out our FAQ X