12 Replies Latest reply on Apr 11, 2007 3:09 AM by ygiriyap

    (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help req

    ygiriyap

      Hi All ...
      (Note: I am working with JBPM 3.2)

      I am not able to get the decision node make a proper decision based on static values or the task variables by defining the conditions in the decision node(processdefinition.xml file).
      (I could get this working using a handler class to make my decisions,though)

      I expect this to be a trivial issue.I am posting this after searching the forum trying out different things and for some reasons not able to get this thro.


      USE CASE:-
      step1: Am reading 2 variables in a task node.
      step2: I have a decision node.Where,based on the values of variables I need to take any of the three paths.

      <decision name="DN_P1CompareP2">
       <transition name="TN_P1LesserP2" to="TN_P1LesserP2">
       <condition><![CDATA[#{P1 < P1}]]></condition>
       </transition>
       <transition name="TN_P1GreaterP2" to="TN_P1GreaterP2">
       <condition><![CDATA[#{P1 > P1}]]></condition>
       </transition>
       <transition name="TN_P1EqualsP2" to="TN_P1CompareP2Else">
       </transition>
       </decision>
      


      Somehow ... always it takes the first transition.This means the conditions are not getting evaluated properly.

      Note:- As it was mentioned by Ronald in one of the threads ... I have defined the type of the variables P1 and P2 as "Integer" in the form.xhtml

      I am fighting for 3 days to know where I have gone wrong.
      Please let me know how to describe the decision using static values or process/task variables in the decision node.

      Thanks in advance.
      --Yash

        • 1. Re: (NOTE: In JBPM 3.2)Decison nodes - tricky - help req
          ygiriyap

          Not able to get the decision node work based on the static values either.

          In the following case ... always the first transition is taken !!!

          <decision name="DN_P1CompareP2">
           <transition name="TN_P1LesserP2" to="TN_P1LesserP2">
           <condition><![CDATA[#{2 < 1}]]></condition>
           </transition>
           <transition name="TN_P1GreaterP2" to="TN_P1GreaterP2">
           <condition><![CDATA[#{2 > 1}]]></condition>
           </transition>
           <transition name="TN_P1EqualsP2" to="TN_P1CompareP2Else">
           </transition>
           </decision>
          


          Any pointers pls.
          Thanks,
          --Yash

          • 2. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
            ygiriyap

            Could someone help me out here.Have spent quite sometime on this.!!!

            This seems to be a minor issue.
            Any pointers??

            Thanks for your time.
            --Yash

            • 3. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
              koen.aers

              Yash,

              Did you try something like this?

              <condition expression="#{P1 > P2}"/>


              I am not sure about this, would have to check the source code, but I think the EL evaluation is not used on the text contents of the condition element. I think it is using beanshell instead in that case.

              Cheers,
              Koen

              • 4. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                ygiriyap

                This works for me.

                <decision name="DN_P1CompareP2" expression='#{ ( P1 > P2 ) ? "TN_P1GreaterP2" : "TN_P1CompareP2Else" }'>
                 <transition name="TN_P1GreaterP2" to="TN_P1GreaterP2"></transition>
                 <transition name="TN_P1CompareP2Else" to="TN_P1CompareP2Else">
                 </decision>


                But,my requirement is a decision node with 3 conditions.So I cant do this way.
                I want to mention the condition as the part of transition.

                Pls provide some pointers.

                Thanks for the reply,Koen.
                --Yash

                • 5. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                  brittm

                  The third transition will never be taken because it has no condition to verify--that's just how the system works (if there are no conditions that evaluate to true, the default (first) transition will be taken).

                  Try removing the CDATA tags and using a character representation for '>' and '<'. What are those, &gt and &lt I think.

                  -Britt

                  • 6. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                    koen.aers

                    Yash,

                    You can also use the 'expression' attribute on the embedded condition within a transition element. I think that should work.

                    Regards,
                    Koen

                    • 7. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                      ygiriyap

                      Thanks for your time guys.

                      Let me make my query clear ...
                      Have a decision node like below ...

                      <decision name="DN_P1CompareP2">
                       <transition name="TN_P1GreaterP2" to="TN_P1GreaterP2">
                       <condition>P1 > P2</condition>
                       </transition>
                       <transition name="TN_P1LesserP2" to="TN_P1LesserP2">
                       <condition>P1 < P2</condition>
                       </transition>
                       </decision>


                      I will provide values as P1=11 and P2=12
                      So P1 < P2.Hence 2nd transition should be taken.
                      But it always takes the first transition.

                      Pls let me know ...
                      How to write the condition tags for this simple use case??

                      Many thanks for your time.
                      --Yash



                      • 8. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                        ygiriyap

                        Meanwhile I have tried to use expression,CDATA and other options.
                        Nothing has worked for me !!!

                        This should be a trivial matter I suppose.I am not able to make where I am going wrong.

                        Thank you.
                        --Yash

                        • 9. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help

                          (You probably showed the encoding, and it got translated in posting, but...) Did you use &lt; (ampersand l t semicolon) for less than and &gt; (ampersand g t semicolon) for greater than?
                          Otherwise, it's not valid XML.

                          I really wonder whether taking the first transition when none match is the best default in most cases. I think most authors would probably prefer to explicitly describe the transition to be taken for all cases. If none of them are met, it's an exception!

                          -Ed Staub

                          FORUM MASTERS: It looks like you lose spelled-out character entities when you go through "Preview" in the forum. If you don't preview, they're left verbatim, but they're converted to single characters when the editing form is filled in.

                          • 10. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                            ygiriyap

                            Hi estaub,

                            Tried that as well.!! No better.
                            I tried the following code. Didnt work.

                            <decision name="DN_P1CompareP2">
                             <transition name="TN_P1GreaterP2" to="TN_P1GreaterP2">
                             <condition expression="#{P1 > P2}"></condition>
                             </transition>
                             <transition name="TN_P1LesserP2" to="TN_P1LesserP2">
                             <condition expression="#{P1 < P2}"></condition>
                             </transition>
                             </decision>



                            Has it worked for you?Could you pls let me know how exactly to write these lines.

                            1. <condition>P1 > P2</condition>
                            2. <condition>P1 < P2</condition>
                            3. <condition>P1 == P2</condition>
                            
                            


                            Many thanks for your time and help,
                            --Yash

                            • 11. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                              marka4

                              You may be aware of this already, but another thought here if your conditions don't seem to be doing anything... Look here: http://jira.jboss.com/jira/browse/JBPM-854

                              org.jbpm.graph.node.Decision is broken in 3.2. We had processes that were totally ignoring all conditions after we upgraded to 3.2. 3.2 was trying to load conditions from the old JBPM_DECISIONCONDITION table (they're not there anymore) instead of the new DECISION_ column in table JBPM_TRANSITIONS. Compiling the new Decision.java from the 3.2.1 source fixed it.

                              • 12. Re: (NOTE: In JBPM 3.2)Decison nodes - trivial issues - help
                                ygiriyap

                                Hey MarkA4 ... Thanks.

                                Coooolll !! Took the Decision.java class from 3.2.1 version and it works now.

                                Many thanks to those you took time to reply and help.
                                --Yash