1 2 Previous Next 20 Replies Latest reply on Sep 14, 2007 8:45 AM by Ronald van Kuijk

    Decision node always taking first option

    Arutha Belron Newbie


      Hey,
      I've encountered a small problem in one of my decision-nodes in the process definition. When evaluating an object stored as a jbpm variable, named 'object' for simplicity, it seems it always takes the first transition, no matter if the condition is true or false. Here is the node-code:

      <decision name="decrypt?">
       <transition name="no" to="ForwardResult1">
       <condition expression="#{object.encrypted == true}"/>
       </transition>
       <transition name="yes" to="ForwardResult2">
       <condition expression="#{object.encrypted == false}"/>
       </transition>
       </decision>


      I know the object is accesible because:

      <event type="node-enter">
       <script>
       System.out.println("Deciding action..." + object.encrypted );
       </script>
      </event>
      


      returns false in this situation, meaning the second transition should be taken.

      Is this because it's a boolean value?

        • 1. Re: Decision node always taking first option
          Arutha Belron Newbie


          Tested it with other Java basetypes, doesn't matter.

          However, I rebuilt to a DecisionHandler class making the choice, the node-code:

           <decision name="decrypt?">
           <handler class="process.ProcessDecision" />
           <transition name="decrypt" to="ForwardResult1" />
           <transition name="nodecrypt" to="ForwardResult2" />
           </decision>


          And that works fine. However, it's practical in most of the situations I need these nodes to make DecisionHandler subclasses. So, any idea what could cause the original code to always take the first option?

          • 2. Re: Decision node always taking first option
            Ronald van Kuijk Master

            there have been some small things related to database types etc... please search the forum first for related items and check if they apply to your case. If not, please report which ones you found and tried and from then on we can look further

            • 3. Re: Decision node always taking first option
              Arutha Belron Newbie



              Well, that was the first step I took, and nothing really directly applied.

              For example, this guy seems to have the same problem:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=118091
              But you suggested to him to search this fine, fine forum. I agree, it's a fine forum. Blue's my fav colour.

              Next, I read this post:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=118015
              It's how I came up with the workaround, but it still doesn't talk about this problem at all.

              Closest thing in description-terms was this one:
              http://www.jboss.com/index.html?module=bb&op=viewtopic&t=117835
              But it talks of troubles in JSF-world, I'm not running a front-end, no JSF/JSP comes to play here. It's a pretty straight-forward process I'm running.

              If you know a thread on the forum that I missed, I'd be much obliged if you could paste the URL...

              • 4. Re: Decision node always taking first option
                razieh islami Newbie

                public void approve(long id) {
                User user = (User) em.createQuery("select u from User u where u.id=" + id).getSingleResult();
                TaskInstance ti = taskInfo.findTaskInstance(taskId);
                ti.start();
                this.dossierAssignee = user;
                ti.end("taskCreatePetition");
                }
                public void cancel(long id) {
                User user = (User) em.createQuery("select u from User u where u.id=" + id).getSingleResult();
                TaskInstance ti = taskInfo.findTaskInstance(taskId);
                ti.start();
                this.dossierAssignee = user;
                ti.end("taskPrepareLetterForDossierSource");
                }
                i hope it can help you.

                • 5. Re: Decision node always taking first option
                  razieh islami Newbie

                  sorry.actually this code can help you.

                  public void approve(long id) {
                  TaskInstance ti = taskInfo.findTaskInstance(taskId);
                  ti.start();
                  this.dossierAssignee = user;
                  ti.end("ForwardResult1");
                  }
                  public void cancel(long id) {
                  TaskInstance ti = taskInfo.findTaskInstance(taskId);
                  ti.start();
                  this.dossierAssignee = user;
                  ti.end("ForwardResult2");
                  }

                  • 6. Re: Decision node always taking first option
                    Arutha Belron Newbie


                    Razieh,
                    I don't see the connection with my question.
                    It seems you're talking about buttons or such on JSP/JSF by the looks of the names on your Java-code, I'm not using any JSP/JSF. In fact, I'd like to solve this without any Java-code at all.. or SQL, for that matter. Purely in the process definition file, using the decision nodes....

                    I can get it to work writing a class extending DecisionHandler, but it's not practical to code a new class or even part of the same for each decision node.

                    My problem is simply this: the decision node always takes the first transition, no matter the condition. I want to be able to make choices based on a Pojo in working memory. The Pojo is accesible (read first post) and getters work fine. It must be a problem with the condition of the condition node.

                    • 7. Re: Decision node always taking first option
                      Petia Wohed Newbie

                      Hi,

                      The following worked for me (in jBPM 3.1.4). 'scenario' is a variable to which I enter value earlier in the process.

                      Hope it will help you. (It took me while to figure out how to extract a variable value, even if it is a very basic thing.)

                      Cheers, Petia

                       <decision name="xor">
                       <transition name="urgent" to="task-b">
                       <condition expression="#{contextInstance.variables['scenario']== 1}"/>
                       </transition>
                       <transition name="dont care" to="task-c">
                       <condition expression="#{contextInstance.variables['scenario']== 2}"/>
                       </transition>
                       <transition name="forget about it" to="task-d">
                       <condition expression="#{contextInstance.variables['scenario'] != 2 and contextInstance.variables['scenario'] != 1}"/>
                       </transition>
                       </decision>
                      


                      • 8. Re: Decision node always taking first option
                        Edward Staub Expert

                        Petia,

                        This shouldn't be necessary.
                        I'm not saying it ISN'T necessary in some context - but I can't imagine what it is. It'll be interesting to see if it helps Arutha.

                        This is the kind of problem I'd debug into JBPM to figure out. However, be warned - the variable-handling code is probably a lot more complex than you would expect.

                        -Ed Staub

                        • 9. Re: Decision node always taking first option
                          Ronald van Kuijk Master

                          I think (not sure) the Script 'engine' does have access to normal objects in memory and the EL resolver only has access to variables.

                          There was a request from the SEAM guys (Gavin himself afaik) to make the jbpm resolver pluggable, so it *could* use the same one as seam does. There was something in the jira related to this

                          • 10. Re: Decision node always taking first option
                            Arutha Belron Newbie


                            I'm certain the Script-engine has access to Objects in memory, since I can call any function in the object from the script in the process definition and get a valid response. (See my node-enter action above, that works)

                            I'm also sure Objects can be accessed in conditions, as it is one of the examples in the jBPM folder, like so:

                            <decision name="decline?">
                             <transition name="no" to="base rating">
                             <condition expression="#{quoteWorkingObject.declineCount == 0}"/>
                             </transition>
                             <transition name="yes" to="end1">
                             condition expression="#{quoteWorkingObject.declineCount > 0}"/>
                             </transition>
                            </decision>
                            


                            I'm about to give Peta's example a shot, though the syntax differs from the example given in jBPM.



                            • 11. Re: Decision node always taking first option
                              Ronald van Kuijk Master

                              ths script enginge I'm sure, the EL not. In the example you describe, the quoteWorkingObject IS a processvariable and not just an object in memory.

                              Ignore petia's example since that also uses a processvariable and just another (imo less wanted) syntax.

                              • 12. Re: Decision node always taking first option
                                Edward Staub Expert

                                >> Ignore petia's example since that also uses a processvariable and just another (imo less wanted) syntax.

                                That is, of course, unless it works! ;-)
                                I have a vague memory of running into the same problem and using Petia's workaround early this year., when I was just starting with JBPM. Unfortunately, I don't remember anything useful, like what the underlying problem was, except that as you'd guess, it had to do with variable resolution.

                                -Ed Staub

                                • 13. Re: Decision node always taking first option
                                  Arutha Belron Newbie


                                  Indeed, I'd rather use the straight-forward syntax, you're right about that.

                                  Doesn't the object become a process variable by using the mapping in ESB?
                                  As follows (thursday already...?):

                                  <property name="esb-to-jbpm">
                                   <!-- esb-name maps to getBody().get("eVar1") -->
                                   <variables>
                                   <variable esb-name="some_object" jbpm-name="jbpm_object" />
                                   </variables>
                                  </property>


                                  Meaning the process 'should' have acces to the 'jbpm_object'-variable?

                                  • 14. Re: Decision node always taking first option
                                    Petia Wohed Newbie

                                    I am too very interested in a more straight-forward syntax (but the syntax given in the documentation did not work for me), so please let me know when you have solved it. (Note also that I am working in version 3.1.4 and the syntax in 3.2 may be different.)

                                    1 2 Previous Next