9 Replies Latest reply on May 11, 2006 8:37 AM by fassihi

    jbpm+decision Node

    medjbpm

      hi

      Can any one tell me or give me an exemple witch inclule a decision Node
      (i work with jbpm3.1
      gpd3.0.8)

      thanks

        • 1. Re: jbpm+decision Node
          saviola

          Hi, medjbpm!
          Here is an example:

          <decision name="Payment Decision" expression="#{contextInstance.variables['Payment Decision']}">
           <transition name="To Cash Paid" to="Cash Paid"/>
           <transition name="To Bank Paid" to="Bank Paid"/>
           <transition to="Cash Paid"/>
           </decision>
          

          Or you can use this one:
          <decision name="Payment Decision" >
           <transition name="To Cash Paid" to="Cash Paid"/>
           <transition name="To Bank Paid" to="Bank Paid"/>
           <transition to="Cash Paid">
           <condition expression="#contextInstance.variables['Payment Decision'] ge 5"/>
           </transition>
           </decision>
          

          Or this one:
           <decision name="Payment Decision" >
           <handler class="bla.bli.MyDecisionHandler"/>
           <transition name="To Cash Paid" to="Cash Paid"/>
           <transition name="To Bank Paid" to="Bank Paid"/>
           <transition to="Cash Paid"/>
           </decision>
          


          • 2. Re: jbpm+decision Node
            medjbpm

            thank you for replay
            in this example :





            <condition expression="#contextInstance.variables['Payment Decision'] ge 5"/>



            what did you mean with
            "['Payment Decision'] ge 5"
            if you mean Payment Decision=5
            how can i use other operation (<,>)

            • 3. Re: jbpm+decision Node
              senhce

              If you wanna add more manipulation and quering database use the handler. All you have to do is write a handler class which implements DecisionHandler of JBPM and configure the same in xml as shown below.
              DecisionHandler will have a method decide the return type will determine which way to go. Hope this helps.








              Thanks,
              Senthil

              • 4. Re: jbpm+decision Node
                hornsbyr

                Hi,
                I want to use a decision which takes a particular transition based on a process variable, and takes a default transition if the variable has not been set. The decision I am using is



                <condition expression="#contextInstance.variables['tran'] eq null"/>


                <condition expression="#contextInstance.variables['tran'] eq 'optionalState1'"/>


                <condition expression="#contextInstance.variables['tran'] eq 'optionalState2'"/>



                However I get an exception

                org.jbpm.graph.def.DelegationException
                ...
                Caused by: java.lang.NullPointerException
                at org.jbpm.graph.node.Decision.execute(Decision.java:70)

                Even though I set
                contextInstance.setVariable("tran", "optionalState1");

                Any ideas what could be causing this?
                Also how can I check if an instance variable has not been set?
                Is "#contextInstance.variables['tran'] eq null" the correct way?
                Thanks

                • 5. Re: jbpm+decision Node
                  hornsbyr

                  Note: repost for readability, sorry, please ignore previous
                  Hi,
                  I want to use a decision which takes a particular transition based on a process variable, and takes a default transition if the variable has not been set. The decision I am using is

                  <decision name="intelligentState">
                   <transition to="workFlowStart">
                   <condition expression="#contextInstance.variables['tran'] eq null"/>
                   </transition>
                   <transition to="optionalState1">
                   <condition expression="#contextInstance.variables['tran'] eq 'optionalState1'"/>
                   </transition>
                   <transition to="optionalState2">
                   <condition expression="#contextInstance.variables['tran'] eq 'optionalState2'"/>
                   </transition>
                   </decision>


                  However I get an exception

                  org.jbpm.graph.def.DelegationException
                  ...
                  Caused by: java.lang.NullPointerException
                  at org.jbpm.graph.node.Decision.execute(Decision.java:70)

                  Even though I set
                  contextInstance.setVariable("tran", "optionalState1");

                  Any ideas what could be causing this?
                  Also how can I check if an instance variable has not been set?
                  Is "#contextInstance.variables['tran'] eq null" the correct way?
                  Thanks

                  • 6. Re: jbpm+decision Node
                    saviola

                    Hi, hornsbyr!
                    Maybe the problem is that the variable you are using is not mapped.
                    You can map it like this.

                    <node name="The node before the decision node">
                    .
                    .
                    .
                    <variable name="Var" mapped-name="Mapped Name" />
                    .
                    .
                    .
                    
                    </node>
                    


                    Remember that AFAIK you must use the mapped name in the transition condition.
                    I hope this could be helpfull.

                    Saviola

                    • 7. Re: jbpm+decision Node
                      jeffgordon

                      You can try brackets around your expression:

                      <condition expression="#{contextInstance.variables['tran'] eq 'optionalState1'}"/>

                      [unless the forum software stripped them]

                      • 8. Re: jbpm+decision Node
                        jeffgordon

                        You may also want to try wrapping your expression in a CDATA section and not using the expression attribute:

                        <condition><![CDATA[#contextInstance.variables['tran'] eq 'optionalState1'}]]></condition>
                        


                        • 9. Re: jbpm+decision Node
                          fassihi

                          I have the same problem and have tested all these solutions but none have worked so far.
                          The error that I get is :
                          "Can't evaluate bean shell script!"