+ pi.getProcessDefinition().getVersion());
return null;
}
private void changeTokenVersion(JbpmContext jbpmContext, Token token) {
Node oldNode = token.getNode();
ProcessDefinition oldDef = token.getProcessInstance()
.getProcessDefinition();
ProcessDefinition newDef = jbpmContext.getGraphSession()
.findProcessDefinition(oldDef.getName(), newVersion);
Node newNode = newDef.findNode(getNewNodeName(oldNode));
if (newNode == null) {
throw new JbpmException("node with name '"
+ getNewNodeName(oldNode)
+ "' not found in new process definition");
}
log.debug("change token id " + token.getId() + " from version "
+ oldDef.getVersion() + " to new version "
+ newDef.getVersion());
token.setNode(newNode);
// TODO: Change timers too!
// change tasks
Iterator iter = getTasksForToken(token).iterator();
while (iter.hasNext()) {
TaskInstance ti = (TaskInstance) iter.next();
Task oldTask = ti.getTask();
// find new task
Query q = jbpmContext.getSession().getNamedQuery(
"TaskMgmtSession.findTaskForNode");
q.setString("taskName", oldTask.getName());
q.setLong("taskNodeId", newNode.getId());
// TODO: q.setLong("processDefinitionId", newDef.getId());
Task newTask = (Task) q.uniqueResult();
if (newTask == null) {
throw new JbpmException(
"node '"
+ newNode.getName()
+ "' has no Task configured! Check the new process definition");
}
ti.setTask(newTask);
log.debug("change dependent task-instance with id "