[jboss-user] [JBoss jBPM] - problems creating task instances
sgrassie
do-not-reply at jboss.com
Tue Jan 22 09:23:56 EST 2008
Hi,
I'm having a problem creating task instances, specifically for the 1st task node in the fairly simple workflow I've created. I can create the first task ok, and I can end it, and save the instance.
However upon creating the context again and reloading the process instance, things go badly - I can't create a task instance from there.
Here is a JUnit4 test case that illustrates what I am trying to do, and the processdefinition.xml is below. If anyone can point out what I'm doing wrong or point me in the right direction, I'd be most grateful.
| @Test
| public void nativeTaskInstanceCommits() {
| File f = TestFiles.getFile("SimpleWorkflow");
| JbpmContext context = JbpmConfiguration.getInstance().createJbpmContext();
|
| try {
| jbpmContext.setActorId("user");
| ProcessDefinition processDefinition = ProcessDefinition.parseXmlReader(new FileReader(f));
| context.deployProcessDefinition(processDefinition);
|
| ProcessInstance processInstance = new ProcessInstance(processDefinition);
| context.save(processInstance);
|
| TaskInstance taskInstance = processInstance.getTaskMgmtInstance().createStartTaskInstance();
| Long id = processInstance.getId();
| Assert.assertTrue("startTask".equals(taskInstance.getName()));
| taskInstance.end();
| context.save(taskInstance);
| context.close();
|
| context = JbpmConfiguration.getInstance().createJbpmContext();
|
| //this doesn't seem to work for me
| processInstance = context.loadProcessInstanceForUpdate(id);
| taskInstance = processInstance.getTaskMgmtInstance().createTaskInstance();
| Assert.assertTrue("firstTask".equals(taskInstance.getName()));
|
| List<?> list = taskInstance.getToken().getNode().getLeavingTransitions();
|
| for(Object o : list) {
| Transition trans = (Transition)o;
| String name = trans.getName();
| Assert.assertTrue( (name.equals("finish")) || (name.equals("to taskNode2")) );
| }
|
| taskInstance.end("finish");
| Assert.assertTrue("end".equals(taskInstance.getToken().getNode().getName()));
|
| } catch (RuntimeException e) {
| Assert.fail(e.getMessage());
| }
| catch (Exception e) {
| Assert.fail(e.getMessage());
| }
| }
|
| <?xml version="1.0" encoding="UTF-8"?>
|
| <process-definition xmlns="" name="SimpleWorkflow">
|
|
| <swimlane name="swimlane1">
| <assignment expression="user(test)"></assignment>
| </swimlane>
|
|
| <start-state name="start">
| <task name="startTask" swimlane="swimlane1">
| <description>
| The start node's Task
| </description>
| </task>
| <transition to="taskNode1" name="starting transition"></transition>
| </start-state>
|
|
| <task-node name="taskNode1">
| <task swimlane="swimlane1" name="firstTask">
| <description>
| The first task in the workflow
| </description>
| </task>
| <transition to="taskNode2" name="to taskNode2"></transition>
| <transition to="end" name="finish"></transition>
| </task-node>
|
| <task-node name="taskNode2">
| <task name="secondTask" swimlane="swimlane1">
| <description>
| The second task in the workflow
| </description>
| </task>
| <transition to="end" name="to end"></transition>
| </task-node>
|
|
| <end-state name="end"></end-state>
|
|
| </process-definition>
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4122220#4122220
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4122220
More information about the jboss-user
mailing list