-
1. Re: pass from one task-node to the following task-node
chprvkmr Nov 19, 2005 10:41 AM (in response to pedrosacosta)Hi pedrosacosta
Did you tried token.singnal() method. -
2. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 5:18 AM (in response to pedrosacosta)Yes, tried the signal() method, but nothing happened.
Here is the example that i'm trying to put to work.package com.sample.jbpm.taskmgmt; import junit.framework.TestCase; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.Token; import org.jbpm.taskmgmt.exe.TaskInstance; public class TaskAssignmentTest extends TestCase { public void testTaskAssignment() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition name='the baby process'>" + " <start-state>" + " <transition name='baby cries' to='t' />" + " </start-state>" + " <task-node name='t'>" + " <task name='change nappy'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t2' />" + " </task-node>" + " <task-node name='t2'>" + " <task name='change nappy2'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t3' />" + " </task-node>" + " <task-node name='t3'>" + " <task name='change nappy3'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='end' />" + " </task-node>" + " <end-state name='end' />" + "</process-definition>" ); ProcessInstance processInstance = new ProcessInstance(processDefinition); Token token = processInstance.getRootToken(); token.signal(); assertSame(processDefinition.getNode("t"), token.getNode()); // When execution arrived in the task-node, a task 'change nappy' // was created and the NappyAssignmentHandler was called to determine // to whom the task should be assigned. The NappyAssignmentHandler // returned 'papa'. // In a real environment, the tasks would be fetched from the // database with the methods in the org.jbpm.db.TaskMgmtSession. // Since we don't want to include the persistence complexity in // this example, we just take the first task-instance of this // process instance (we know there is only one in this test // scenario. TaskInstance taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); token.signal(); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); /* taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); */ // Since this was the last (only) task to do, the completion of this // task triggered the continuation of the process instance execution. assertSame(processDefinition.getNode("end"), token.getNode()); } }
-
3. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 5:21 AM (in response to pedrosacosta)The snippet below doesn't have the comments tags. The right snippet is without the comments.
/* taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator() .next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); */
-
4. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 5:24 AM (in response to pedrosacosta)Ok. To avoid any misunderstanding, here is the right code.
package com.sample.jbpm.taskmgmt; import junit.framework.TestCase; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.Token; import org.jbpm.taskmgmt.exe.TaskInstance; public class TaskAssignmentTest extends TestCase { public void testTaskAssignment() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition name='the baby process'>" + " <start-state>" + " <transition name='baby cries' to='t' />" + " </start-state>" + " <task-node name='t'>" + " <task name='change nappy'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t2' />" + " </task-node>" + " <task-node name='t2'>" + " <task name='change nappy2'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='end' />" + " </task-node>" + " <task-node name='t3'>" + " <task name='change nappy3'>" + " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='end' />" + " </task-node>" + " <end-state name='end' />" + "</process-definition>" ); ProcessInstance processInstance = new ProcessInstance(processDefinition); Token token = processInstance.getRootToken(); token.signal(); assertSame(processDefinition.getNode("t"), token.getNode()); // When execution arrived in the task-node, a task 'change nappy' // was created and the NappyAssignmentHandler was called to determine // to whom the task should be assigned. The NappyAssignmentHandler // returned 'papa'. // In a real environment, the tasks would be fetched from the // database with the methods in the org.jbpm.db.TaskMgmtSession. // Since we don't want to include the persistence complexity in // this example, we just take the first task-instance of this // process instance (we know there is only one in this test // scenario. TaskInstance taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); token.signal(); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // Now, we check if the taskInstance was actually assigned to 'papa'. assertEquals("papa", taskInstance.getActorId() ); // Now suppose that 'papa' has done his duties and marks the task // as done. taskInstance.end(); // Since this was the last (only) task to do, the completion of this // task triggered the continuation of the process instance execution. assertSame(processDefinition.getNode("end"), token.getNode()); } }
-
5. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 5:43 AM (in response to pedrosacosta)This is weird. Now i can work with 3 task-nodes, but not with 4 task-nodes.
Does anyone know what is happenning?
Here is the code again.package com.sample.jbpm.taskmgmt; import junit.framework.TestCase; import org.jbpm.graph.def.ProcessDefinition; import org.jbpm.graph.exe.ProcessInstance; import org.jbpm.graph.exe.Token; import org.jbpm.taskmgmt.exe.TaskInstance; public class TaskAssignmentTest extends TestCase { public void testTaskAssignment() { ProcessDefinition processDefinition = ProcessDefinition.parseXmlString( "<process-definition name='the baby process'>" + " <start-state>" + " <transition name='baby cries' to='t' />" + " </start-state>" + " <task-node name='t'>" + " <task name='change nappy'>" + // " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t2' />" + " </task-node>" + " <task-node name='t2'>" + " <task name='change nappy2'>" + // " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t3' />" + " </task-node>" + " <task-node name='t3'>" + " <task name='change nappy3'>" + // " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='t4' />" + " </task-node>" + " <task-node name='t4'>" + " <task name='change nappy4'>" + // " <assignment class='com.sample.jbpm.taskmgmt.NappyAssignmentHandler' />" + " </task>" + " <transition to='end' />" + " </task-node>" + " <end-state name='end' />" + "</process-definition>" ); ProcessInstance processInstance = new ProcessInstance(processDefinition); Token token = processInstance.getRootToken(); token.signal(); System.out.println("---> " + token.getNode().getName()); assertSame(processDefinition.getNode("t"), token.getNode()); TaskInstance taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // assertEquals("papa", taskInstance.getActorId() ); taskInstance.end(); System.out.println("---> " + token.getNode().getName()); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // assertEquals("papa", taskInstance.getActorId() ); taskInstance.end(); System.out.println("---> " + token.getNode().getName()); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // assertEquals("papa", taskInstance.getActorId() ); taskInstance.end(); System.out.println("---> " + token.getNode().getName()); taskInstance = (TaskInstance)processInstance.getTaskMgmtInstance().getTaskInstances().iterator().next(); // assertEquals("papa", taskInstance.getActorId() ); taskInstance.end(); System.out.println("---> " + token.getNode().getName()); assertSame(processDefinition.getNode("end"), token.getNode()); } }
-
6. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 5:51 AM (in response to pedrosacosta)This is a hint. This problem occurs because it's related to the deployment of my process definition in a database? Well, if it really occurs. I don't know if it's what must happen for my xml run correctly.
-
7. Re: pass from one task-node to the following task-node
pedrosacosta Nov 21, 2005 6:26 AM (in response to pedrosacosta)Adding my previous questions, what this error means?
java.lang.IllegalStateException: task instance '0'is already started at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:306) at org.jbpm.taskmgmt.exe.TaskInstance.end(TaskInstance.java:272) at com.sample.jbpm.taskmgmt.TaskAssignmentTest.testTaskAssignment(TaskAssignmentTest.java:89) at com.sample.jbpm.taskmgmt.TaskAssignmentTest.main(TaskAssignmentTest.java:96) Exception in thread "main"
-
8. Re: pass from one task-node to the following task-node
tobysaville Dec 13, 2005 2:35 PM (in response to pedrosacosta)In TaskInstance.end() it tests if the end time is not null, and if thats true, throws the error that your getting.
This seems to be a contradiction to me. Basically, it says if the end date has been set already, report that this task has already started. In other words, if the task has already been ended, and you try to end it again, it reports that it has already been started. This confuses me. Perhaps its just a bad error message, raised when you try to stop a task that is already stopped.
Sorry i dont have an answer, but thought i would contribute all the same.