Package org.jbpm.graph.def

Examples of org.jbpm.graph.def.Transition


        DefaultElement bpmToEsbVars = (DefaultElement) secondMiddleState.element("transition").element("action").element("bpmToEsbVars");

        Token token = processInstance.getRootToken();
        ExecutionContext executionContext = new ExecutionContext(token);
        Node node = executionContext.getNode();
        Transition transition = (Transition) node.getLeavingTransitions().get(0);

        JBpmObjectMapper mapper = new JBpmObjectMapper();
        Message message = mapper.mapFromJBpmToEsbMessage(bpmToEsbVars, Boolean.FALSE, executionContext);

        assertEquals(message.getBody().getNames().length,6);
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("TokenId"))), String.valueOf(token.getId()));
        //The token name is null.
        assertNull(message.getBody().get("TokenName"));
        //Get info about the node.
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("NodeName"))), String.valueOf(node.getName()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("esbNodeId"))), String.valueOf(node.getId()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("transName"))), String.valueOf(transition.getName()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piId"))), String.valueOf(processInstance.getId()));
        assertEquals(String.valueOf(String.valueOf(message.getBody().get("piVersion"))), String.valueOf(processInstance.getVersion()));
        logger.info("Message=" + message);
    }
View Full Code Here


      return conditionElement.getText();
    }
  }

  public void execute(ExecutionContext executionContext) {
    Transition transition = null;
   
    try {
      if (decisionDelegation!=null) {
        DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
        String transitionName = decisionHandler.decide(executionContext);
        transition = getLeavingTransition(transitionName);
        if (transition==null) {
          throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
        }
       
      } else if (decisionExpression!=null) {
        Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
        if (result==null) {
          throw new JbpmException("decision expression '"+decisionExpression+"' returned null");
        }
        String transitionName = result.toString();
        transition = getLeavingTransition(transitionName);
        if (transition==null) {
          throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
        }
       
      } else if (decisionConditions!=null) {
        // backwards compatible mode based on separate DecisionCondition's
        Iterator iter = decisionConditions.iterator();
        while (iter.hasNext() && (transition==null)) {
          DecisionCondition decisionCondition = (DecisionCondition) iter.next();
          Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(), executionContext);
          if (Boolean.TRUE.equals(result)) {
            transition.removeConditionEnforcement();
            String transitionName = decisionCondition.getTransitionName();
            transition = getLeavingTransition(transitionName);
          }
        }
       
      } else {
        // new mode based on conditions in the transition itself
        Iterator iter = leavingTransitions.iterator();
        while (iter.hasNext() && (transition==null)) {
          Transition candidate = (Transition) iter.next();
         
          String conditionExpression = candidate.getCondition();
          if (conditionExpression!=null) {
            Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
            if (Boolean.TRUE.equals(result)) {
              transition = candidate;
            }
View Full Code Here

   * name will be used in the signal.
   * If this task completion does not trigger execution to move on,
   * the transitionName is ignored.
   */
  public void end(String transitionName) {
    Transition leavingTransition = null;
   
    if (task!=null) {
      Node node = task.getTaskNode();
      if (node==null) {
        node = (Node) task.getParent();
View Full Code Here

      resolveTransitionDestination(transitionElement, node);
    }
  }

  public void resolveTransitionDestination(Element transitionElement, Node node) {
    Transition transition = new Transition();
    transition.setProcessDefinition(processDefinition);

    transition.setName(transitionElement.attributeValue("name"));
    transition.setDescription(transitionElement.elementTextTrim("description"));

    String condition = transitionElement.attributeValue("condition");
    if (condition==null) {
      Element conditionElement = transitionElement.element("condition");
      if (conditionElement!=null) {
        condition = conditionElement.getTextTrim();
        // for backwards compatibility
        if (condition==null) {
          condition = conditionElement.attributeValue("expression");
        }
      }
    }
    transition.setCondition(condition);

    // add the transition to the node
    node.addLeavingTransition(transition);

    // set destinationNode of the transition
View Full Code Here

      throw new JbpmException("token '" + this + "' can't be signalled cause it is currently not positioned in a node");
    }
    if (node.getDefaultLeavingTransition() == null) {
      throw new JbpmException("couldn't signal token '" + this + "' : node '" + node + "' doesn't have a default transition");
    }
    Transition leavingTransition = node.getLeavingTransition(transitionName);
    if (leavingTransition==null) {
      throw new JbpmException("transition '"+transitionName+"' does not exist on "+node);
    }
    signal(leavingTransition, new ExecutionContext(this));
  }
View Full Code Here

      List leavingTransitions = node.getLeavingTransitions();
      if (leavingTransitions!=null) {
        availableTransitions = new HashSet();
        Iterator iter = leavingTransitions.iterator();
        while (iter.hasNext()) {
          Transition transition = (Transition) iter.next();
          String conditionExpression = transition.getCondition();
          if (conditionExpression!=null) {
            Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, new ExecutionContext(this));
            if ( (result instanceof Boolean)
                 && (((Boolean)result).booleanValue())
               ) {
View Full Code Here

    for ( int i = 0; i < transitions.length; i++ ) {
      String[] parsedTransition = cutTransitionText( transitions[i] );
      Node from = pd.getNode( parsedTransition[0] );
      Node to = pd.getNode( parsedTransition[2] );
      Transition t = new Transition( parsedTransition[1] );
      from.addLeavingTransition(t);
      to.addArrivingTransition(t);
    }
  }
View Full Code Here

   * name will be used in the signal.
   * If this task completion does not trigger execution to move on,
   * the transitionName is ignored.
   */
  public void end(String transitionName) {
    Transition leavingTransition = null;
   
    if (task!=null) {
      Node node = task.getTaskNode();
      if (node==null) {
        node = (Node) task.getParent();
View Full Code Here

      return conditionElement.getText();
    }
  }

  public void execute(ExecutionContext executionContext) {
    Transition transition = null;
   
    try {
      if (decisionDelegation!=null) {
        DecisionHandler decisionHandler = (DecisionHandler) decisionDelegation.instantiate();
        String transitionName = decisionHandler.decide(executionContext);
        transition = getLeavingTransition(transitionName);
        if (transition==null) {
          throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
        }
       
      } else if (decisionExpression!=null) {
        Object result = JbpmExpressionEvaluator.evaluate(decisionExpression, executionContext);
        if (result==null) {
          throw new JbpmException("decision expression '"+decisionExpression+"' returned null");
        }
        String transitionName = result.toString();
        transition = getLeavingTransition(transitionName);
        if (transition==null) {
          throw new JbpmException("decision '"+name+"' selected non existing transition '"+transitionName+"'" );
        }
       
      } else if (decisionConditions!=null && !decisionConditions.isEmpty()) {
        // backwards compatible mode based on separate DecisionCondition's
        Iterator iter = decisionConditions.iterator();
        while (iter.hasNext() && (transition==null)) {
          DecisionCondition decisionCondition = (DecisionCondition) iter.next();
          Object result = JbpmExpressionEvaluator.evaluate(decisionCondition.getExpression(), executionContext);
          if (Boolean.TRUE.equals(result)) {
            if (transition!=null) {
              transition.removeConditionEnforcement();
            }
            String transitionName = decisionCondition.getTransitionName();
            transition = getLeavingTransition(transitionName);
          }
        }
       
      } else {
        // new mode based on conditions in the transition itself
        Iterator iter = leavingTransitions.iterator();
        while (iter.hasNext() && (transition==null)) {
          Transition candidate = (Transition) iter.next();
         
          String conditionExpression = candidate.getCondition();
          if (conditionExpression!=null) {
            Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
            if (Boolean.TRUE.equals(result)) {
              transition = candidate;
            }
View Full Code Here

      throw new JbpmException("token '" + this + "' can't be signalled cause it is currently not positioned in a node");
    }
    if (node.getDefaultLeavingTransition() == null) {
      throw new JbpmException("couldn't signal token '" + this + "' : node '" + node + "' doesn't have a default transition");
    }
    Transition leavingTransition = node.getLeavingTransition(transitionName);
    if (leavingTransition==null) {
      throw new JbpmException("transition '"+transitionName+"' does not exist on "+node);
    }
    signal(leavingTransition, new ExecutionContext(this));
  }
View Full Code Here

TOP

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

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.