0 Replies Latest reply on Feb 1, 2008 8:24 AM by Debnath Mukherjee

    subprocess token positioned at next node

    Debnath Mukherjee Newbie

      Hi

      I am trying to execute a subprocess but after signalling the main
      process, the token seems to go past the first state of the subprocess
      and position itself at the second state. I was expecting it to stop at
      the first state of the subprocess.

      The print statements after executing the test case are as below:

      After processInstance
      Node is: ProcessState(process-state1)
      Subprocess node is:fork1

      Please let me know what's wrong.

      Thanks,

      Debnath

      The test case and setup details are as follows:

      Test case

      package com.jbpm.tutorial.subprocess;
      
      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.graph.node.ProcessState;
      
      public class SubProcessTest extends TestCase {
       public void setUp()
       {
      
       }
      
       public void testSubProcess()
       {
       ProcessDefinition mainprocessDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='mainprocess'>" +
       "<start-state name='start'>" +
       "<transition to='process-state1'></transition>" +
       "</start-state>" +
       "<process-state name='process-state1'>" +
       "<sub-process name='subprocess'></sub-process>" +
       "<transition to='task-node1'></transition>" +
       "</process-state>" +
       "<task-node name='task-node1'>" +
       "<task name='TaskNode1Task'></task>" +
       "<transition to='end'></transition>" +
       "</task-node>" +
       "<end-state name='end'></end-state>" +
       "</process-definition>");
       ProcessInstance mainprocessInstance = new ProcessInstance(mainprocessDefinition);
       System.out.println("After processInstance");
      
       assertEquals(false, mainprocessInstance == null);
       Token token = mainprocessInstance.getRootToken();
       token.signal();
       assertEquals(true, token.getNode() instanceof ProcessState);
       System.out.println("Node is: " + token.getNode());
       ProcessInstance subProcessInstance = token.getSubProcessInstance();
       Token subprocessToken = subProcessInstance.getRootToken();
       System.out.println("Subprocess node is:" + subprocessToken.getNode().getName());
       assertEquals(true, subprocessToken.getNode().getName().equals("start"));
       //System.out.println("Subprocess node is:" + subprocessToken.getNode().getName());
       }
      }


      The Subprocess Resolver is as follows:


      package com.jbpm.tutorial.subprocess;
      
      import org.jbpm.graph.node.SubProcessResolver;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.dom4j.Element;
      
      public class CustomSubProcessResolver implements SubProcessResolver
      {
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
      
       public ProcessDefinition findSubProcess(Element subProcessElement)
       {
       ProcessDefinition subprocessDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='subprocess'> " +
       "<start-state name='start'> " +
       "<task name='StartNodeTask'> " +
       "<assignment actor-id='user'></assignment> " +
       "</task>" +
       "<transition to='fork1'></transition>" +
       "</start-state>" +
       "<fork name='fork1'>" +
       "<transition to='task-node1' name='to_task_node_1'></transition>" +
       "<transition to='task-node2' name='to_task_node_2'></transition>" +
       "</fork>" +
       "<task-node name='task-node1'>" +
       "<task name='TaskNode1Task'>" +
       "<assignment actor-id='user'></assignment>" +
       "</task>" +
       "<transition to='join1' name='to_join_1'></transition>" +
       "</task-node>" +
       "<task-node name='task-node2'>" +
       "<task name='TaskNode2Task'>" +
       "<assignment actor-id='user'></assignment>" +
       "</task>" +
       "<transition to='join1' name='to_join_2'></transition>" +
       "</task-node>" +
       "<join name='join1'>" +
       "<transition to='end'></transition>" +
       "</join>" +
       "<end-state name='end'></end-state>" +
       "</process-definition>");
       return subprocessDefinition;
       }
      
      }
      


      The jbpm.cfg.xml is as follows:

      <jbpm-configuration>
      
       <bean name="jbpm.sub.process.resolver" class="com.jbpm.tutorial.subprocess.CustomSubProcessResolver" singleton="false" />
      
      </jbpm-configuration>