Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-1173

Fork Node doesn't support conditions on Transitions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Do
    • Icon: Major Major
    • jBPM 3.2.11
    • jBPM 3.2.0
    • Runtime Engine
    • None

      Documentation does not clearly provide any limits to where conditions on Transitions can be used, but the Fork Node doesn't support Transition conditions. For instance

      <fork name='FORK_1' >
      <transition name='t1' to='NODE_A'>
      <condition>#

      {false}</condition>
      </transition>
      <transition name='t2' to='NODE_B'/>
      </fork>

      will fail with a "transition condition #{false}

      evaluated to 'false'" error when the fork attempts to take transition 't1'. Why provide for this? Someone might want to:

      <fork name='FORK_1' >
      <transition name='startMyProject' to='...'/>
      <transition name='orderEngine to='...'>
      <condition>#

      {needsEngine}

      </condition>
      </transition>
      <transition name='orderWheels to='...'>
      <condition>#

      {needsWheels}

      </condition>
      </transition>
      ...etc...
      </fork>

      Correcting the issue is as simple as making the following change to org.jbpm.graph.node.Fork.java:

      // BRITT --replace the following line with the code below
      // to check conditions before adding valid transitions...
      //transitionNames = getLeavingTransitionsMap().keySet(); //original line

      Iterator iter = leavingTransitions.iterator();
      while (iter.hasNext()) {
      Transition candidate = (Transition) iter.next();

      String conditionExpression = candidate.getCondition();
      if (conditionExpression != null) {
      Object result = JbpmExpressionEvaluator.evaluate(conditionExpression, executionContext);
      if (Boolean.TRUE.equals(result))

      { transitionNames.add(candidate.getName()); }

      }else

      { transitionNames.add(candidate.getName()); }

      }
      if (transitionNames.size() == 0)

      { transitionNames.add(this.getDefaultLeavingTransition().getName()); this.getDefaultLeavingTransition().removeConditionEnforcement(); log.warn("All transition conditions have evaluated to 'false'. Taking the default transition."); }

      // --BRITT

            marco.rietveld Marco Rietveld (Inactive)
            brittm_jira brittm (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: