[JBoss jBPM] - Persistance
by maxip
Hi,
i want to save a process instance (seems to work) and to get back a saved instance.
But the fetched list is empty
heres my code:
whats wrong?
in the log i can see that my process is started and saved...
|
| import java.util.List;
|
| import org.jbpm.JbpmConfiguration;
| import org.jbpm.JbpmContext;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.identity.Entity;
| import org.jbpm.identity.xml.IdentityXmlParser;
|
| public class TestClass {
|
| /**
| * @param args
| */
| public static void main(String[] args) {
| JbpmConfiguration.getInstance().createSchema();
| JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
|
| try {
| //jbpmContext.setActorId("1");
| deployProcessDefinition();
|
| ProcessInstance processInstance = jbpmContext.newProcessInstanceForUpdate( "SimpleDefinition1" );
| System.out.println( "definition: " + processInstance.getProcessDefinition().getName());
| processInstance.signal();
| jbpmContext.save(processInstance);
|
|
| List mylist = jbpmContext.getTaskList("1");
| processInstance = (ProcessInstance) mylist.get(0);
|
| System.out.println( "definition: " + processInstance.getProcessDefinition().getName());
| }
| finally {
| jbpmContext.close();
| }
| }
|
| public static void deployProcessDefinition() {
| ProcessDefinition processDefinition = ProcessDefinition
| .parseXmlString( "<process-definition name='SimpleDefinition1'>"
| + " <start-state name='start'>"
| + " <transition to='s' />"
| + " </start-state>"
| + " <state name='s'>"
| + " <transition to='end' />"
| + " </state>"
| + " <end-state name='end' />"
| + "</process-definition>" );
|
| JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
| try {
| jbpmContext.deployProcessDefinition( processDefinition );
| }
| finally {
| jbpmContext.close();
| }
| }
| }
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962100#3962100
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962100
18 years, 5 months
[JBoss jBPM] - Re: Bugs in org.jbpm.graph.node.Decision?
by ujay68
Ronald, thanks for responding. Regardless of whether the "otherwise" transition should be first or last (which is just a matter of convention), the current behavior is wrong. Here's a test case:
| package test;
|
| import junit.framework.TestCase;
| import org.jbpm.context.exe.ContextInstance;
| import org.jbpm.graph.def.ProcessDefinition;
| import org.jbpm.graph.exe.ProcessInstance;
| import org.jbpm.graph.exe.Token;
|
|
| public class TestDecision extends TestCase {
|
| public void testDecison0() {
| runProcess(0, "end");
| }
|
| public void testDecison1() {
| runProcess(1, "s1");
| }
|
| public void testDecison2() {
| runProcess(2, "s2");
| }
|
| private void runProcess(int value, String expectedState) {
|
| ProcessDefinition processDefinition = ProcessDefinition.parseXmlInputStream(getClass().getResourceAsStream("processdefinition.xml"));
| ProcessInstance processInstance = new ProcessInstance(processDefinition);
|
| ContextInstance contextInstance = processInstance.getContextInstance();
| contextInstance.setVariable("myVar", new Integer(value));
|
| Token token = processInstance.getRootToken();
|
| token.signal();
| assertSame(processDefinition.getNode(expectedState), token.getNode());
|
| }
| }
|
With this processdefinition.xml:
| <process-definition name='Test Decision'
| xmlns='urn:jbpm.org:jpdl-3.1'
| xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
| xsi:schemaLocation='urn:jbpm.org:jpdl-3.1 http://jbpm.org/jpdl-3.1.xsd'>
|
| <start-state>
| <transition to='d'/>
| </start-state>
|
| <decision name='d'>
| <transition to='s1'>
| <condition>#{myVar == 1}</condition>
| </transition>
| <transition to='s2'>
| <condition>#{myVar == 2}</condition>
| </transition>
| <transition to='end'/>
| </decision>
|
| <state name='s1'/>
|
| <state name='s2'/>
|
| <end-state name='end'/>
|
| </process-definition>
|
testDecision0 and testDecision2 fail, the task being in the s1 state in both cases. When I put the otherwise transition at the first position, nothing changes.
Note that if you replace the conditions with an expression, like this, all works fine:
| <decision name='d' expression='#{ myVar }'>
| <transition name='0' to='end'/>
| <transition name='1' to='s1'/>
| <transition name='2' to='s2'/>
| </decision>
|
Regards,
Jay
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3962090#3962090
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3962090
18 years, 5 months