[jbpm-commits] JBoss JBPM SVN: r6443 - jbpm3/trunk/modules/core/src/main/java/org/jbpm/command.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Jun 30 02:54:24 EDT 2010
Author: camunda
Date: 2010-06-30 02:54:24 -0400 (Wed, 30 Jun 2010)
New Revision: 6443
Modified:
jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
Log:
JBPM-2903: Added changing the process instance version for a job as well
Modified: jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java
===================================================================
--- jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2010-06-29 17:57:11 UTC (rev 6442)
+++ jbpm3/trunk/modules/core/src/main/java/org/jbpm/command/ChangeProcessInstanceVersionCommand.java 2010-06-30 06:54:24 UTC (rev 6443)
@@ -9,6 +9,7 @@
import org.apache.commons.logging.LogFactory;
import org.hibernate.Query;
import org.jbpm.JbpmException;
+import org.jbpm.graph.def.Action;
import org.jbpm.graph.def.GraphElement;
import org.jbpm.graph.def.Node;
import org.jbpm.graph.def.ProcessDefinition;
@@ -16,6 +17,8 @@
import org.jbpm.graph.exe.Token;
import org.jbpm.graph.node.ProcessState;
import org.jbpm.graph.node.TaskNode;
+import org.jbpm.job.ExecuteActionJob;
+import org.jbpm.job.ExecuteNodeJob;
import org.jbpm.job.Job;
import org.jbpm.job.Timer;
import org.jbpm.logging.log.ProcessLog;
@@ -145,8 +148,8 @@
Node newNode = findReplacementNode(newDef, oldNode);
token.setNode(newNode);
- // Change timers too!
- adjustTimersForToken(token);
+ // Change timers and jobs
+ adjustJobsAndTimersForToken(token);
// change tasks
adjustTaskInstancesForToken(token);
@@ -182,7 +185,7 @@
}
}
- private void adjustTimersForToken(Token token)
+ private void adjustJobsAndTimersForToken(Token token)
{
ProcessDefinition newDef = getNewProcessDefinition(token);
List<Job> jobs = getJbpmContext().getJobSession().findJobsByToken(token);
@@ -211,6 +214,29 @@
}
}
}
+ else if (job instanceof ExecuteNodeJob)
+ {
+ ExecuteNodeJob nodeJob = (ExecuteNodeJob)job;
+
+ if (nodeJob.getNode()!=null) {
+ // change to new node
+ GraphElement oldNode = nodeJob.getNode();
+ // TODO: What with other GraphElements?
+ nodeJob.setNode(
+ findReplacementNode(newDef, oldNode));
+ }
+ }
+ else if (job instanceof ExecuteActionJob)
+ {
+ ExecuteActionJob actionJob = (ExecuteActionJob)job;
+
+ if (actionJob.getAction()!=null) {
+ // change to new action
+ Action oldAction = actionJob.getAction();
+ actionJob.setAction(
+ findReplacementAction(newDef, oldAction));
+ }
+ }
}
}
@@ -241,6 +267,23 @@
}
return newTask;
}
+
+ private Action findReplacementAction(ProcessDefinition newDef, Action oldAction)
+ {
+ // if there exists an action not connected to a process definition (Check if there is a use case for this)
+ if (oldAction.getProcessDefinition()==null) {
+ return oldAction;
+ }
+
+ // TODO: We do not have a mapping for action names in place yet
+ String name = oldAction.getName();
+ Action newAction = newDef.getAction(name);
+ if (newAction == null)
+ {
+ throw new JbpmException("action with name '" + name + "' not found in new process definition");
+ }
+ return newAction;
+ }
/**
* @param oldNode
More information about the jbpm-commits
mailing list