-
1. Re: process versioning + swimlane with pooledActors
kukeltje Apr 4, 2007 8:52 PM (in response to morpheus_jboss)If it realy behaves that way it is a bug. Could you make a testcase (unit test like all the other jbpm tests) that demonstrates the 'failing' behaviour?
-
2. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 5, 2007 4:16 AM (in response to morpheus_jboss)Thanks for the reply. I can not access my project till the end of next week. By then I will try your suggestion and post my results.
-
3. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 12, 2007 7:17 PM (in response to morpheus_jboss)import java.util.Iterator; import java.util.List; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.jbpm.JbpmConfiguration; import org.jbpm.JbpmContext; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.taskmgmt.def.Swimlane; import org.jbpm.taskmgmt.exe.TaskInstance; public class JbpmTest extends TestCase { JbpmConfiguration jbpmCfg; JbpmContext jbpmContext; public JbpmDelegatorTest(String name) { super(name); } protected void setUp() { this.jbpmCfg = JbpmConfiguration.getInstance(); this.jbpmContext = jbpmCfg.createJbpmContext(); } protected void tearDown() { jbpmContext.close(); } public void testDeployProcessXml() { String xmlResource = "returngoods.swimlane-pooled-actors/processdefinition.xml"; ProcessDefinition processDefinition = ProcessDefinition.parseXmlResource(xmlResource); jbpmContext.deployProcessDefinition(processDefinition); } public void testCreateStartTaskInstance() { ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("returngoods.swimlane-pooled-actors"); // long processDefinitionId = processDefinition.getId(); ProcessInstance processInstance = processDefinition.createProcessInstance(); TaskInstance startTaskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance(); startTaskInstance.end(); jbpmContext.save(processInstance); List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo"); assertTrue(pooledTaskInstances.size() > 0); //the 'Receive Item' task should be there according to the process definition TaskInstance taskInstanceOld = (TaskInstance) pooledTaskInstances.get(0); assertEquals("Receive Item", taskInstanceOld.getName()); int oldVersion = taskInstanceOld.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion(); System.out.println("oldVersion " + oldVersion); } public void testChangeProcessDefinition() { ProcessDefinition processDefinition = jbpmContext.getGraphSession().findLatestProcessDefinition("returngoods.swimlane-pooled-actors"); //removing yoyo from all swimlanes Swimlane swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Shipping"); swimlane.setActorIdExpression(null); swimlane.setPooledActorsExpression("grover"); swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Sales"); swimlane.setActorIdExpression(null); swimlane.setPooledActorsExpression("ernie"); swimlane = processDefinition.getTaskMgmtDefinition().getSwimlane("Accounting"); swimlane.setActorIdExpression(null); swimlane.setPooledActorsExpression("bert"); jbpmContext.deployProcessDefinition(processDefinition); } public void testCompleteTask() { List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo"); assertTrue(pooledTaskInstances.size() > 0); //the 'Receive Item' task should be there according to the process definition TaskInstance taskInstanceNew = (TaskInstance) pooledTaskInstances.get(0); assertEquals("Receive Item", taskInstanceNew.getName()); int newVersion = taskInstanceNew.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion(); //The taskInstance is still there, but with new process version! System.out.println("newVersion "+ newVersion); taskInstanceNew.end(); } public void testPooledTaskInstances() { List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo"); // the suite failed here! assertTrue(pooledTaskInstances.size() > 0); for (Iterator iter = pooledTaskInstances.iterator(); iter.hasNext();) { TaskInstance taskInstance = (TaskInstance) iter.next(); System.out.println("taskInstanceName " + taskInstance.getName()); System.out.println("version " + taskInstance.getTaskMgmtInstance().getTaskMgmtDefinition().getProcessDefinition().getVersion()); } } //clean up all pooledTaskInstances for yoyo to make the result clear public void testCleanUp() { List pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo"); for (Iterator iter = pooledTaskInstances.iterator(); iter.hasNext();) { TaskInstance taskInstance = (TaskInstance) iter.next(); taskInstance.end(); ProcessInstance processInstance = taskInstance.getTaskMgmtInstance().getProcessInstance(); processInstance.end(); jbpmContext.save(processInstance); } pooledTaskInstances = jbpmContext.getTaskMgmtSession().findPooledTaskInstances("yoyo"); // assertNull(pooledTaskInstances); assertEquals(0, pooledTaskInstances.size()); } public static Test suite() { TestSuite suite = new TestSuite("Test for jbpm"); //$JUnit-BEGIN$ suite.addTest(new JbpmDelegatorTest("testCleanUp")); suite.addTest(new JbpmDelegatorTest("testDeployProcessXml")); //start a process instance suite.addTest(new JbpmDelegatorTest("testCreateStartTaskInstance")); //do some changes in TaskMgmtDefinition suite.addTest(new JbpmDelegatorTest("testChangeProcessDefinition")); //complete the already assigned taskInstance suite.addTest(new JbpmDelegatorTest("testCompleteTask")); //test if the processInstance is still using the old process definition, but failed here suite.addTest(new JbpmDelegatorTest("testPooledTaskInstances")); //$JUnit-END$ return suite; }
-
4. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 12, 2007 7:19 PM (in response to morpheus_jboss)<?xml version="1.0" encoding="UTF-8"?> <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="returngoods.swimlane-pooled-actors"> <swimlane name="Shipping"> <assignment pooled-actors="grover, yoyo"></assignment> </swimlane> <swimlane name="Sales"> <assignment pooled-actors="ernie, yoyo"></assignment> </swimlane> <swimlane name="Accounting"> <assignment pooled-actors="bert, yoyo"></assignment> </swimlane> <start-state name="Ship Order Return"> <task name="Send Item"> <controller> <variable name="tracking number" access="read,write,required"></variable> </controller> </task> <transition name="Shipping" to="Receive Return"></transition> </start-state> <task-node name="Receive Return"> <task name="Receive Item" swimlane="Shipping"> <controller> <variable name="tracking number" access="read"></variable> <variable name="received date" access="read,write,required"></variable> </controller> </task> <transition name="Process Return" to="fork 1"></transition> </task-node> <fork name="fork 1"> <transition name="Ordering" to="Update Order"></transition> <transition name="Accounting" to="Return Money"></transition> </fork> <task-node name="Update Order"> <task name="Send Updated Order" swimlane="Sales"> <controller> <variable name="address" access="read,write,required"></variable> </controller> </task> <transition name="" to="join1"></transition> </task-node> <task-node name="Return Money"> <task name="Update Books" swimlane="Accounting"> <controller> <variable name="amount" access="read,write,required"></variable> </controller> </task> <transition name="" to="join1"></transition> </task-node> <join name="join1"> <transition name="" to="Process End"></transition> </join> <end-state name="Process End"></end-state> </process-definition>
-
5. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 12, 2007 7:31 PM (in response to morpheus_jboss)After the process instance is started, actor "yoyo" was in all three swimlanes. We remove him from all swimlanes in the processdefinition (programatically) and deploy this new definition. This change in taskMgmt takes effect immediately on the running processInstance, which is not a expected behaviour.
Based on the test suite and processdefinition.xml posted above, i suspect the process versioning is not working, at least not working together with taskMgmt. However, taskMgmt is the part that needs to be changed most frequently IMHO. -
6. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 12, 2007 7:36 PM (in response to morpheus_jboss)Sorry there was a typo. But the claim remains. The code for the suite should be:
public static Test suite() { TestSuite suite = new TestSuite("Test for jbpm"); //$JUnit-BEGIN$ suite.addTest(new JbpmTest("testCleanUp")); suite.addTest(new JbpmTest("testDeployProcessXml")); //start a process instance suite.addTest(new JbpmTest("testCreateStartTaskInstance")); //do some changes in TaskMgmtDefinition suite.addTest(new JbpmTest("testChangeProcessDefinition")); //complete the already assigned taskInstance suite.addTest(new JbpmTest("testCompleteTask")); //test if the processInstance is still using the old process definition, but failed here suite.addTest(new JbpmTest("testPooledTaskInstances")); //$JUnit-END$ return suite; }
-
7. Re: process versioning + swimlane with pooledActors
kukeltje Apr 13, 2007 5:40 AM (in response to morpheus_jboss)hmmm... afaik, because of the way hibernate works, you cannot read a pd, update it programatically and deploy it as a new version. The way you do it now, you not only deploy a new processdefinition, but also update the current one.... (or maybe only update the current one).
Try working with 2 xml based processdefinitions and see if the problem still occurs... -
8. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 13, 2007 6:28 AM (in response to morpheus_jboss)I think working with two xml based pd's the problem should not be there any more. I have not tested that yet. But that is not what we want. I also agree with you about the hibernate part.
To summarize the problem, we want to have process versioning working while changing process definition programmatically and without parsing the xml again. IMHO this method, jbpmContext.deployProcessDefinition(pd), should in any case support process versioning. -
9. Re: process versioning + swimlane with pooledActors
kukeltje Apr 13, 2007 8:07 AM (in response to morpheus_jboss)I think the api does deploy a new process, but....
you modify a processdefinition and when the context is closed, it is saved, so the one you retrieve is modified in addition to deploying a new one. Maybe you should make a kind of deep copy before modifiing and saving that. -
10. Re: process versioning + swimlane with pooledActors
morpheus_jboss Apr 14, 2007 11:58 AM (in response to morpheus_jboss)"kukeltje" wrote:
I think the api does deploy a new process, but....
you modify a processdefinition and when the context is closed, it is saved, so the one you retrieve is modified in addition to deploying a new one.
I checked in the database, there is no new pd entry inserted by jbpmContext.deployProcessDefinition(). The old entry is still there, with only its version number increased, or the old entry is just overwritten by the new one.
Maybe you should make a kind of deep copy before modifiing and saving that.
How to do that? Please could you give more details on this? -
11. Re: process versioning + swimlane with pooledActors
kukeltje Apr 14, 2007 2:39 PM (in response to morpheus_jboss)I would if I new how to... this is a hibernate thing, so you might want to search the hibernate docs