1 Reply Latest reply on Nov 20, 2008 6:36 AM by Mauricio Salatino

    Skipped process state

    Don Tjandra Newbie

      Hi, I am trying to signal a process state node but its always skipped in my test program. Here is the test program. The process state "p" is skipped. Is there some error on my part?

      iimport java.util.HashMap;
      import java.util.Map;
      
      import junit.framework.TestCase;
      
      import org.dom4j.Element;
      import org.jbpm.graph.def.ProcessDefinition;
      import org.jbpm.graph.exe.ProcessInstance;
      import org.jbpm.graph.node.ProcessState;
      import org.jbpm.graph.node.SubProcessResolver;
      
      public class TestSubprocess extends TestCase {
      
       private static class MapBasedProcessRepository implements SubProcessResolver {
      
       private Map<String,ProcessDefinition> processes =
       new HashMap<String,ProcessDefinition>();
      
       public void add(ProcessDefinition processDefinition) {
       processes.put(processDefinition.getName(), processDefinition);
       }
      
       @Override
       public ProcessDefinition findSubProcess(Element element) {
       // TODO Auto-generated method stub
       return processes.get(element.attributeValue("name"));
       }
       }
      
       public void testProcessInstance() {
      
       MapBasedProcessRepository subProcessResolver = new MapBasedProcessRepository();
       ProcessDefinition subProcessDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='sub'>" +
       " <start-state>" +
       " <transition to='end' />" +
       " </start-state>" +
       " <end-state name='end' />" +
       "</process-definition>"
       );
       subProcessResolver.add(subProcessDefinition);
      
       ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
       "<process-definition name='super'>" +
       " <start-state name='start'>" +
       " <transition to='p' />" +
       " </start-state>" +
       " <process-state name='p'>" +
       " <sub-process name='sub' binding='late' />" +
       " <transition to='end' />" +
       " </process-state>" +
       " <end-state name='end' />" +
       "</process-definition>"
       );
       subProcessResolver.add(processDefinition);
      
       ProcessState.setDefaultSubProcessResolver(subProcessResolver);
       ProcessInstance processInstance = new ProcessInstance(processDefinition);
      
       System.out.println( processInstance.getRootToken().getNode().getName() );
       processInstance.signal();
       System.out.println( processInstance.getRootToken().getNode().getName() );
       processInstance.signal();
       System.out.println( processInstance.getRootToken().getNode().getName() );
       }
      }