6 Replies Latest reply on Nov 4, 2008 7:41 AM by salaboy21

    Fork that have conditions.. how??

    aben

      Hi All,

      I need a way to create a FORK that have conditions on the transitions,
      so it will take only the transitions only if the conditions on them evaluate to true ,

      how can it be done ?

      the documentation talks only on conditions inside decision..

      Thanks For your help

        • 1. Re: Fork that have conditions.. how??
          salaboy21

          If you need to that i think you can extend the Node class to make your custom Fork, because this involves the number of child tokens that you need to create. So, my question is, do you need a tag to do that? or just the behevior..??

          Let me know what approach need your requierments and we can do it together..

          • 2. Re: Fork that have conditions.. how??
            aben

            Hi, thanks for the reply

            I need just the behaviour.

            my requirement is a fork with several transitions , on some of them / all of them will be conditions . the jbpm will take only the transitions that their condition evaluate to true

            for ex :




            <condition expression=#{true=true}


            <condition expression=#{true=false}



            only the first and the second transition shuold be processed.


            • 3. Re: Fork that have conditions.. how??
              salaboy21

              Ok, I wil try to write in my blog how to do that.. I think I will start with something like multichoicefork
              http://www.jboss.org/community/docs/DOC-11442
              You can try to do an approach too and then we can compare it.

              • 4. Re: Fork that have conditions.. how??
                aben

                without writing new tags,
                what is the default behaviour of FORK , is it ignoring the conditions on its transitions ?

                can the regular FORK tag can be somehow used in order to process only the transitions that its condition is true ? ,

                <FORK name="fork">
                <transition to="x">
                <condition expression=#{true=true}/>
                </transition>
                <transition to="y">
                <condition expression=#{true=false}/>
                </transition>
                </FORK>


                • 5. Re: Fork that have conditions.. how??
                  salaboy21

                  I don't think so, but let me review the code..
                  for what I have in my head the Fork code look for the leaving transitions to create sub tokens.. so.. i doesn't evaluate the conditions inside them...
                  I hope it helps..

                  • 6. Re: Fork that have conditions.. how??
                    salaboy21

                    I was looking into the code and I find this that can help you:

                     // by default, the fork spawns a token for each leaving transition
                     if (script==null) {
                     transitionNames = getLeavingTransitionsMap().keySet();
                    
                     } else { // a script is specified
                     // if a script is specified, use that script to calculate the set
                     // of leaving transitions to be used for forking tokens.
                     Map outputMap = null;
                     try {
                     outputMap = script.eval(token);
                     } catch (Exception e) {
                     this.raiseException(e, executionContext);
                     }
                     if (outputMap.size()==1) {
                     Object result = outputMap.values().iterator().next();
                     if (result instanceof Collection) {
                     transitionNames = (Collection) result;
                     }
                     }
                    

                    This means that you can add a script to tell the fork node with transitions you want to take.
                    Hope it helps