[jboss-user] [JBoss jBPM] - Re: Re-routing Tokens

dleerob do-not-reply at jboss.com
Thu Dec 20 09:31:24 EST 2007


Thanks Ronald for the quick reply.
Okay I have done the following, and it seems to reroute to the new node okay. 

//remove current incomplete task instances---------------------------------------------------
  | 		log.info("Removing task instances found at token with ID '"+tokenId+"'");
  | 		List deleteTaskInstanceList = new ArrayList();
  | 		//create a seperate list of those task instances to delete. If deleting them
  | 		//straight from iterator, a ConcurrentModificationException will occur when calling it.next(); 
  | 		for(Iterator it = processInstance.getTaskMgmtInstance().getTaskInstances().iterator();it.hasNext();) {
  | 			TaskInstance taskInstance = (TaskInstance)it.next();
  | 			if(tokenId.equals(taskInstance.getToken().getId()+"")) {
  | 				if (taskInstance.getEnd() == null) { //not complete task
  | 					deleteTaskInstanceList.add(taskInstance);
  | 				}
  | 			}
  | 		}
  | 		for (int x = 0; x < deleteTaskInstanceList.size(); x++) {
  | 			TaskInstance taskInstance = (TaskInstance)deleteTaskInstanceList.get(x);
  | 			log.info("Removing task instance with ID '"+taskInstance.getId()+"'");
  | 			processInstance.getTaskMgmtInstance().removeTaskInstance(taskInstance);
  | 		}
  | //----------------------------------------------------------------------------------------------
  | 		
  | 		//enter new node
  | 		Node newNode = processInstance.getProcessDefinition().getNode(nodeName);
  | 		newNode.enter(new ExecutionContext(token));

It seems to have the desired effect. You obviously have to keep in mind that you may break something, depending on what your actions etc do, but if you understand how your flow works, you can use this method appropriatly. Can anyone see anything that may cause problems here?

The only thing that isn't working at the moment is the code 
processInstance.getTaskMgmtInstance().removeTaskInstance(taskInstance);
The task instance doesn't actually get deleted. Any ideas why?

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4114659#4114659

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4114659



More information about the jboss-user mailing list