5 Replies Latest reply on Mar 3, 2010 4:23 AM by Maciej Swiderski

    running decision node(jbpm 4.0) multiple times for single processInstance

    praneet nandan Newbie

      hey everyone,

         is it possible to run decision node multiple times for single processinstance.

       

        my usecase is like this there is a form which contains list of multiple student. i have to mark whether student is selected or not

      using combo box which contains value {Selected, Rejected} .the above work i have placed in task node. now after completing task(form is submitted)

      there is decision node which check whether student is selected or not if selected it will go to the mail node and all the selected student will receive 

      the mail.and finally process go to end state.

                      so how to move decision node multiple time for single processInstance so that all selected student receive the mail in single instance of process,becoz if first student got selected decision node will execute ,it goes to mail node and finally it will go to end state and that instance of process will terminate.

        • 1. Re: running decision node(jbpm 4.0) multiple times for single processInstance
          Maciej Swiderski Master

          Hi,

           

          Perhaps you do not need to go through decision node many times, instead you could send mail to many recipients at once unless each mail is personalized for particular student?!

           

          If your use case requires personalized email to be sent you could achieve it by using additional decision point after mail node to check if there are more emails in the queue. You can use event listener on mail node (on end) to inspect if there are any more emails to be sent. If there are waiting messages to be sent you navigate back to mail node if not go on to end state.

           

          HTH

          Maciej

          • 2. Re: running decision node(jbpm 4.0) multiple times for single processInstance
            praneet nandan Newbie

            thanks Maciej for quick rply,

             

            suppose in my usecase 5 students are selected and 2 not then how can i handle these situation while moving from task node to decision node,what to write in decision node to handle these 5 students(talking abt personal email for each student).

            • 3. Re: running decision node(jbpm 4.0) multiple times for single processInstance
              Maciej Swiderski Master

              you could write your DecisionHandler class that would do all required work for you, for instance get process variables that defined what students should receive e-mail. Depending on what your task will do while processing the form.

              Keep in mind that you can also you EventListner (for a task node) to adjust some process variables if needed.

               

              Cheers,

              Maciej

              • 4. Re: running decision node(jbpm 4.0) multiple times for single processInstance
                praneet nandan Newbie

                thanks for replying

                  ya i have done in my decision handler as u have said

                  my decide method is like this

                 

                public String decide(OpenExecution execution) {

                 

                // in email i got email address of all student

                List<String> email=(List<String>) execution.getVariable("email");

                 

                // in actions i got action of all student suppose for 7 it is 'Select'

                and for 3 it is 'Reject'

                List<String>actions=(List<String>) execution.getVariable("action");

                 

                // count contains the no of students

                   int count=(Integer)execution.getVariable("count");

                 

                 

                // what to write here so that for each student corresponding

                transitions will be matched for particular student,means how to extract values from action

                list for each student so that corresponding transition takes place

                 

                 

                   

                 

                 

                }

                 

                this is my handler node

                 

                <decision name="Selected?" g="96,102,48,48" >

                    <handler class="jbpm.MyHandler" />

                    <transition name="Select" to="send-interview-email" g="120,60:-36,23" />

                    <transition name="Reject"  to="end1" g=":-15,-21" />

                  </decision>

                • 5. Re: running decision node(jbpm 4.0) multiple times for single processInstance
                  Maciej Swiderski Master

                  I would try something like that:

                   

                  1. set count variable to 0 if it does not exist or increment by one if exists

                  2. extract information (email address, name, etc) for a student from list of selected students - for one student - use count to get correct student info

                  3. check is user is selected or rejected, id selected proceed with following steps if rejected repeat step 1 and 2

                  3. set variable that consists of this information - this information will be used by mail node to populate email message

                  4. forward flow to mail node

                  5. mail node sends the message end gets back to decision node for another verification

                  6. if there are more students to be notified repeat above steps

                   

                  Have not tested that but I would give it a try...I think it is a one way to go to achieve your goal.

                   

                  Cheers,

                  Maciej