Package org.jbpm.graph.def

Examples of org.jbpm.graph.def.Node


   * @throws JbpmException if text is null.
   */
  public static Node createNode(String text) {
    if (text==null) throw new JbpmException("text is null");
   
    Node node = null;
   
    String typeName;
    String name;
   
    text = text.trim();
    int spaceIndex = text.indexOf(' ');
    if (spaceIndex!=-1) {
      typeName = text.substring(0, spaceIndex);
      name = text.substring(spaceIndex + 1);
    } else {
      typeName = text;
      name = null;
    }

    Class<? extends Node> nodeType = NodeTypes.getNodeType(typeName);
    if ( nodeType==null ) throw new IllegalArgumentException("unknown node type name '" + typeName + "'");
    try {
      node = nodeType.newInstance();
      node.setName(name);
    } catch (Exception e) {
      throw new JbpmException("couldn't instantiate nodehandler for type '" + typeName + "'");
    }
    return node;
  }
View Full Code Here


    super(name);
  }

  public void execute(ExecutionContext executionContext) {
    Token token = executionContext.getToken();
    Node mergeNode = token.getNode();
   
    // if this is a simple merge
    if ( ! isSynchronized ) {
      mergeNode.leave(executionContext);

    // this is a synchronizing multi merge
    } else {
     
      Collection<Token> concurrentTokens = token.getParent().getChildren().values();
      boolean reactivate = true;
      for (Token concurrentToken : concurrentTokens) {
        if (! mergeNode.equals(concurrentToken.getNode())) {
          reactivate = false;
          break;
        }       
      }
     
      if ( reactivate ) {
        for (Token concurrentToken : concurrentTokens) {
          mergeNode.leave(new ExecutionContext(concurrentToken));         
        }
      }
    }
  }
View Full Code Here

    // pass the token over the selected transition
    token.getNode().leave(executionContext, nextTransition);
  }

  protected Collection<String> getTransitionNames(Token token) {
    Node node = token.getNode();
    return node.getLeavingTransitionsMap().keySet();
  }
View Full Code Here

            if (! (tokenValue instanceof Token)) {
                context.setError("Error moving token", "Attempted to move something other than a token");
                return;
            }
            final Token token = (Token) tokenValue;
            final Node node;
            final Object nodeValue = nodeExpression.getValue(elContext);
            if (nodeValue == null) {
                context.setError("Error moving token", "Node value is null");
                return;
            }
            if (nodeValue instanceof Node) {
                node = (Node) nodeValue;
            } else {
                final String nodeName = nodeValue.toString();
                node = token.getProcessInstance().getProcessDefinition().getNode(nodeName);
                if (node == null) {
                    context.setError("Error moving token", "No node found by name of '" + nodeName + "'");
                    return;
                }
            }
            token.setNode(node);
            context.addSuccessMessage("Token moved to node '" + node.getName() + "'");
            context.getJbpmContext().getSession().flush();
            context.selectOutcome("success");
        } catch (Exception ex) {
            context.setError("Error moving token", ex);
            return;
View Full Code Here

    ExecutionContext executionContext = new ExecutionContext(token);
    executionContext.setAction(action);
    executionContext.setEvent(action.getEvent());

    // then execute the action
    Node node = token != null ? token.getNode() : null;
    if (node != null) {
      node.executeAction(action, executionContext);
    }
    else {
      action.execute(executionContext);
    }
View Full Code Here

    rootToken.addLog(new ProcessInstanceCreateLog());

    // set the variables
    addInitialContextVariables(variables);

    Node initialNode = rootToken.getNode();
    fireStartEvent(initialNode);
  }
View Full Code Here

      "    <transition to='b' />" +
      "  </node>" +
      "  <node name='b' />" +
      "</process-definition>"
    );
    Node a = processDefinition.getNode("a");
    Node b = processDefinition.getNode("b");
    assertSame(a, a.getDefaultLeavingTransition().getFrom());
    assertSame(b, a.getDefaultLeavingTransition().getTo());
  }
View Full Code Here

    assertSame(b, a.getDefaultLeavingTransition().getTo());
  }

  public void testWriteNodeTransition() throws Exception {
    ProcessDefinition processDefinition = new ProcessDefinition();
    Node a = new Node("a");
    Node b = new Node("b");
    processDefinition.addNode(a);
    processDefinition.addNode(b);

    Transition t = new Transition();
    a.addLeavingTransition(t);
    b.addArrivingTransition(t);
   
    Element element = AbstractXmlTestCase.toXmlAndParse( processDefinition, "/process-definition/node[1]/transition" );
    assertNotNull(element);
    assertEquals("transition", element.getName());
    assertEquals(1, element.attributeCount());
View Full Code Here

    assertEquals("hertransition", element.attributeValue("name"));
  }

  public void testWriteNodeTransitionName() throws Exception {
    ProcessDefinition processDefinition = new ProcessDefinition();
    Node a = new Node("a");
    Node b = new Node("b");
    processDefinition.addNode(a);
    processDefinition.addNode(b);

    Transition t = new Transition("hertransition");
    a.addLeavingTransition(t);
    b.addArrivingTransition(t);

    Element element = AbstractXmlTestCase.toXmlAndParse( processDefinition, "/process-definition/node[1]/transition" );
    assertNotNull(element);
    assertEquals("hertransition", element.attributeValue("name"));
  }
View Full Code Here

    assertEquals("hertransition", element.attributeValue("name"));
  }

  public void testTransitionOrder() throws Exception {
    ProcessDefinition processDefinition = new ProcessDefinition();
    Node a = new Node("a");
    Node b = new Node("b");
    processDefinition.addNode(a);
    processDefinition.addNode(b);

    Transition t = new Transition("one");
    a.addLeavingTransition(t);
    b.addArrivingTransition(t);

    t = new Transition("two");
    a.addLeavingTransition(t);
    b.addArrivingTransition(t);

    t = new Transition("three");
    a.addLeavingTransition(t);
    b.addArrivingTransition(t);

    Element element = AbstractXmlTestCase.toXmlAndParse( processDefinition );
    assertNotNull(element);
    assertEquals( "one", ((Element)element.selectSingleNode("/process-definition/node[1]/transition[1]")).attributeValue("name"));
    assertEquals( "two", ((Element)element.selectSingleNode("/process-definition/node[1]/transition[2]")).attributeValue("name"));
View Full Code Here

TOP

Related Classes of org.jbpm.graph.def.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.