[jboss-user] [jBPM Users] - Re: Implementing Escalation in jBPM 4.1
sebastian.s
do-not-reply at jboss.com
Sun Sep 27 10:26:31 EDT 2009
I do not know what exactly is the problem with the BusinessCalendar but I created my process and my unit test within the examples project and the error has gone away. Now back to the actual goal.
Please disregard my old post since there were some mistakes and things missing.
My process definition looks like this:
| <process key="escalation" name="escalation" xmlns="http://jbpm.org/4.0/jpdl">
| <start g="130,8,48,48" name="start1">
| <transition g="-93,-21" name="to timeout_task" to="timeout_task"/>
| </start>
| <task g="106,105,92,52" name="timeout_task" assignee="alex">
| <transition g="7,-32" name="to escalated" to="escalated">
| <timer duedate="5 seconds"/>
| <timer duedate="5 seconds"/>
| <timer duedate="5 seconds"/>
| <timer duedate="5 seconds"/>
| </transition>
| <transition g="-50,-21" name="to task2" to="task2"/>
| </task>
| <task g="303,211,92,52" name="escalated" assignee="mike">
| <transition g="-50,-21" name="to task2" to="task2"/>
| </task>
| <task g="109,256,92,52" name="task2" assignee="peter">
| <transition g="-48,-21" name="to end1" to="end1"/>
| </task>
| <end g="132,367,48,48" name="end1"/>
| </process>
|
My unit test follows:
| package org.jbpm.examples.userescalation;
| import java.util.List;
|
| import org.jbpm.api.Execution;
| import org.jbpm.api.ProcessInstance;
| import org.jbpm.api.job.Job;
| import org.jbpm.api.task.Task;
| import org.jbpm.test.JbpmTestCase;
|
| public class EscalationTest extends JbpmTestCase {
|
| String deploymentId;
|
| protected void setUp() throws Exception {
| super.setUp();
|
| deploymentId = repositoryService.createDeployment()
| .addResourceFromClasspath("org/jbpm/examples/userescalation/escalation.jpdl.xml")
| .deploy();
| }
|
| protected void tearDown() throws Exception {
| repositoryService.deleteDeploymentCascade(deploymentId);
|
| super.tearDown();
| }
|
| public void testTaskEscalaton() {
|
| ProcessInstance processInstance = executionService.startProcessInstanceByKey("escalation");
|
| List<Task> tasksAlex = taskService.findPersonalTasks("alex");
|
| // check if Alex's task has been created
| if(tasksAlex.size() == 0) {
| fail();
| }
|
| // executing the job which would normally be executed by the JobExecutor
| Job job = managementService.createJobQuery()
| .timers()
| .processInstanceId(processInstance.getId())
| .uniqueResult();
|
| managementService.executeJob(job.getId());
| processInstance = executionService.findProcessInstanceById(processInstance.getId());
|
| // we now should have arrived in the node "escalated"
| assertTrue(processInstance.isActive("escalated"));
|
| // there should be an item in Mike's tasklist now
| List<Task> tasksMike = taskService.findPersonalTasks("mike");
| if(tasksMike.size() == 0) {
| fail();
| } else {
| taskService.completeTask(tasksMike.get(0).getId());
| }
|
| // after Mike has completed his task we should have arrived in the node "task2"
| processInstance = executionService.findProcessInstanceById(processInstance.getId());
| assertTrue(processInstance.isActive("task2"));
|
| // Alex's tasks still exists although it is obsolete now
| tasksAlex = taskService.findPersonalTasks("alex");
|
| // deleting is not possible since this task belongs to an execution
| //taskService.deleteTask(tasksAlex.get(0).getId(), "obsolete");
|
| // so we have to complete it, what is unwanted for BAM
| taskService.completeTask(tasksAlex.get(0).getId());
|
| // ########### but this fails with an exception ########
|
| // there shouldn't be any tasks left for alex
| //tasksAlex = taskService.findPersonalTasks("alex");
| //assertEquals(0, tasksAlex.size());
|
| }
|
| }
|
The exception thrown when completeTask() is called:
| ### EXCEPTION ###########################################
| 16:19:12,140 INF | [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.CompleteTaskCmd at ff45de
| org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.jbpm.pvm.internal.model.ExecutionImpl#2]
|
Am I doing anything wrong or does this mean you should not put timers on transitions coming from user tasks?
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4257213#4257213
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4257213
More information about the jboss-user
mailing list