2 Replies Latest reply on Apr 26, 2006 5:36 AM by vitali kiruta

    API access to decision node's expression

    vitali kiruta Newbie

      Hi all,

      is there any way to set expression of the decision node (or conditions for transitions) programmatically, via API. I can specify it via xml definition of course. for example:

       <decision name="decision1" >
       <transition name='one' to="one">
       <condition>#{money=="one"}</condition>
       </transition>
       <transition name='two' to="two">
       <condition>#{money=="two"}</condition>
       </transition>
       </decision>
      


      But I need to build a process definition in memory at run-time.

      Thanks,
      kv

        • 1. Re: API access to decision node's expression
          tansdale tan Newbie

          yes you can do that.

          first, get List decisionConditions from decision(Decision' object)

          second, get DecisionCondition's expression and transitionName
          by calling
          DecisionCondition.getExpression();
          getTransitionName()

          the following code can help you to understand what DecisionCondition is.

          ////
          public class DecisionCondition implements Serializable {
          
           private static final long serialVersionUID = 1L;
          
           String transitionName;
           String expression;
          
           public DecisionCondition() {
           }
          
           public DecisionCondition(String transitionName, String expression) {
           this.transitionName = transitionName;
           this.expression = expression;
           }
          
           public String getExpression() {
           return expression;
           }
           public String getTransitionName() {
           return transitionName;
           }
          }


          • 2. Re: API access to decision node's expression
            vitali kiruta Newbie

            Sorry if I was not clear enough. I do not need to get expression. I need to set it. So instead of getExpression I need something like setExpression. I could use public constructor of DecisionCondition maybe but when I do something like this:

            Decision decision1 = (Decision) procDef.getNode("decision1");
            decision1.getDecisionConditions().add(new DecisionCondition("one", "#{money==\"one\"}"));
            

            I get NullPointerException cause getDecisionConditions() returns null and not empty list.

            Another thing is Decision class has decisionExpression field
            public class Decision extends Node implements Parsable {
             ...
             String decisionExpression = null;
            
            

            And again there is no way to set it programmaticaly.

            Any suggestions?