6 Replies Latest reply on Jul 31, 2006 12:32 PM by cpob

    How to dynamically create fork's transitions

    luowp

      HI all,

      I have a requirement to use fork. In one situation, I need have three tasks follow, but in another situation, it just have two tasks. How to do that? Thanks!

        • 1. Re: How to dynamically create fork's transitions
          newbie007

          Add an action handler on the fork node and do whatever you want to do in the handler.

          Thanks.

          • 2. Re: How to dynamically create fork's transitions
            cpob

            Decision node to two separate forks.

            The first fork would go to each of the three tasks. The second fork would go to only two of them. All three of the tasks would go to the single join.

            Something like this

            <?xml version="1.0" encoding="UTF-8"?>
            
            <process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="super">
            
             <start-state name="start">
             <transition name="" to="task1"></transition>
             </start-state>
             <task-node name="task1">
             <transition name="" to="fork1"></transition>
             <transition name="tr2" to="fork2"></transition>
             </task-node>
             <fork name="fork1">
             <transition name="" to="task2"></transition>
             <transition name="tr2" to="task3"></transition>
             <transition name="tr3" to="task4"></transition>
             </fork>
             <fork name="fork2">
             <transition name="" to="task3"></transition>
             <transition name="tr2" to="task4"></transition>
             </fork>
             <join name="join1">
             <transition name="" to="end1"></transition>
             </join>
             <task-node name="task2">
             <transition name="" to="join1"></transition>
             </task-node>
             <task-node name="task3">
             <transition name="" to="join1"></transition>
             </task-node>
             <task-node name="task4">
             <transition name="" to="join1"></transition>
             </task-node>
             <end-state name="end1"></end-state>
            </process-definition>


            • 3. Re: How to dynamically create fork's transitions
              asauvage

              Hi all,

              To expand on the previous question, is there a way to use jBPM to support the "Multiple Instances Requiring Synchronisation" workflow pattern without having to define all the possible numbers of multiple instances in the PDL file? (In my case, this number of instances can only be known at run-time and can vary greatly from a few to hundreds).

              Many thanks.


              • 4. Re: How to dynamically create fork's transitions
                cpob

                There are test cases for each of the workflow patterns.

                However, some of the code used to 'enable' these patterns aren't really supported yet in the PDL or Database.

                I know the join has a .setNOutofM() (or something like taht) which will allow a join to only require 2 out of 4 (for example) tokens until completion.

                You could perhaps programmatically change that during runtime for the instance. However, I don't know if that changes the instance of the definition which would be bad.

                • 5. Re: How to dynamically create fork's transitions
                  luowp

                  Thanks for the replies.

                  I am a new guy in jbpm. Questions based on the solutions:

                  1. how to add a action handler for a fork. Is that using ?
                  2. how to disable one of the transition in this handler?

                  • 6. Re: How to dynamically create fork's transitions
                    cpob

                    I'd suggest just digging through jBPM's source code, tests, documentation, etc. so you feel more comfortable with jBPM if you are going to be writing your own nodes.

                    There are examples of creating action handlers (not on forks, but in general) in the JUnit tests provided. Plus, the documentation/api gives good insights.