10 Replies Latest reply on May 22, 2007 8:57 AM by Edward Staub

    Contexts of variables in forked processing

    Vedavyas N Rao Newbie

      Hi All,

      I am using forked proceesing where in there are two transitions from the fork. Both the transitions are going to a particular decision node.

      From the decision node, based on my logic, the task ends or it goes to a different <task-node>. in the task-node i am not able to retrieve the variables.

      In the decision node i can properly retrieve the variable. Only when i reach the task-node the value of the variables are not as expected.

      From which context can i retrieve the variables?

      This is a part of the process definition file

      <fork name="fork">
       <transition name="transition" to="user-needs-lead-approval">
       <action class="com.techm.gisv.osl.cvsportal.actions.Fork1">
       <index>0</index>
       </action>
       </transition>
      
       <transition name="transition1" to="user-needs-lead-approval">
       <action class="com.techm.gisv.osl.cvsportal.actions.Fork1">
       <index>1</index>
       </action>
       </transition>
      </fork>
      
      <decision name="user-needs-lead-approval" expression="#
      workflow.whatIsUserRegisteringAs}">
       <transition name="r3" to="assign-to-tech-lead">
       <action class="com.techm.gisv.osl.cvsportal.actions.ActorAction"/>
       </transition>
      
       <transition name="r1" to="done">
       <action class="com.techm.gisv.osl.cvsportal.actions.PersistAction"/>
       <action class="com.techm.gisv.osl.cvsportal.actions.Mail"/>
       </transition>
      
       <transition name="r2" to="done">
       <action class="com.techm.gisv.osl.cvsportal.actions.PersistAction"/>
       <action class="com.techm.gisv.osl.cvsportal.actions.Mail"/>
       </transition>
      </decision>
      
      <task-node name="assign-to-tech-lead">
       <task name="for-approval" description="team lead creation request">
       <assignment pooled-actors="#{pooledActors.pooledActor}"/>
       </task>
       <transition name="approved and assigned back to admin" to="assign-admin">
       <action class="com.techm.gisv.osl.cvsportal.actions.LeadAction"/>
       </transition>
      </task-node>
      



      Please help me out

      Thanks


        • 1. Re: Contexts of variables in forked processing
          Ronald van Kuijk Master

          What are you trying to achieve? This is a very weird way of modelling things, and probably (as you describe) does not work correctly.

          • 2. Re: Contexts of variables in forked processing
            Edward Staub Expert

            vedavyas,

            Do you really want a fork?
            Forks are used for starting pseudo-concurrent execution of multiple paths.

            -Ed Staub

            • 3. Re: Contexts of variables in forked processing
              Vedavyas N Rao Newbie

              This is what i'm trying:

              The process starts by assigning a task to a particular actor(in this case it is ADMIN). Now based on the business logic the ADMIN may require approval from one or more actors(here it is PROJECTLEADS).

              So a single task for the ADMIN has to be split into multiple tasks and assigned to LEADS.

              My exact problem statement goes like this:

              A user can request for one or more projects when he registers. This request is assigned to the ADMIN as a single task. The ADMIN has to assign the task to the LEADS of these projects. There can be multiple LEADS for each project. So Project1 should be assigned to concerned LEADS and Project2 to its concerned LEADS and so on.

              This may sound wierd as i'm trying to use the features of jBPM.

              How can i model the process-definition?

              Thanks

              • 4. Re: Contexts of variables in forked processing
                Ronald van Kuijk Master

                Yes, you use features of jBPM, but it is the way that you use them that leads to problems (compare: you can use a knife to cut meat ot to stab people, the latter leads to problems although it is a feature of a knife).

                Use a foreachforkhandler for this (see the wiki). Adapt it slightly to accustom for the different actors.

                • 5. Re: Contexts of variables in forked processing
                  Vedavyas N Rao Newbie

                  As u said i used the ForEachForkHandler and it works for a particular case.
                  This is my process definition file

                  <task-node name="assign-to-admin">
                   <task name="for-approval" description="team member creation request">
                   <assignment pooled-actors="user1"/>
                   </task>
                   <transition name="does user need lead approval" to="foreachfork">
                   <action class="com.techm.gisv.osl.cvsportal.actions.AdminAction"/>
                   </transition>
                  </task-node>
                  
                  <node name="foreachfork">
                   <action class="com.techm.gisv.osl.cvsportal.actions.ForEachForkHandler" config-type="bean">
                   <list>projects1</list>
                   <as>project</as>
                   </action>
                   <transition name="assign" to="user-needs-lead-approval">
                   </transition>
                  </node>
                  
                  <decision name="user-needs-lead-approval" expression="#{workflow.isUserDev}">
                   <transition name="yes" to="assign-to-tech-lead">
                   <action class="com.techm.gisv.osl.cvsportal.actions.ActorAction"/>
                   </transition>
                   <transition name="no" to="action"/>
                  </decision>
                  
                  <task-node name="assign-to-tech-lead">
                   <task name="for-approval" description="team lead creation request">
                   <assignment pooled-actors="#{pooledActors.pooledActor}"/>
                   </task>
                   <transition name="approved and assigned back to admin" to="assign-admin">
                   <action class="com.techm.gisv.osl.cvsportal.actions.LeadAction"/>
                   </transition>
                  </task-node>
                  


                  According to my process definition and based on my logic if the control comes to the <task node> "assign-to-tech-lead" then none of the attributes are available. So no value can be displayed in the tasklist.

                  how can i solve this?

                  • 6. Re: Contexts of variables in forked processing
                    Vedavyas N Rao Newbie

                    I am trying to split a single process into multiple process using ForEachForkHandler

                    In this case a single task for the ADMIN is split into two or more tasks and assigned to more than one actor(LEADS). In the task list for LEADS none of the attributes of the parent process is visible in the child process.

                    Should i manually copy these values to the next process and if yes how can this be done? or is it available in any of the contexts?

                    Thanks

                    • 7. Re: Contexts of variables in forked processing
                      Edward Staub Expert

                      Vedavyas,

                      You wrote:

                      I am trying to split a single process into multiple process using ForEachForkHandler

                      Do you literally mean multiple process instances, or just multiple tokens?

                      If process instances, look at
                      jpdl\examples\variable\src\main\java\org\jbpm\tutorial\context\ContextTest.java

                      If tokens, it should work, I think. Tokens are in a tree; variables are searched for by swimming recursively toward the root token until one with the matching name is found. See the user guide on "Variable Scope". There may be something specific in how you are (perhaps implicitly) scoping them; you didn't show anything about where they are created, etc., so it's hard to guess.

                      -Ed Staub





                      • 8. Re: Contexts of variables in forked processing
                        Edward Staub Expert

                        I wrote:

                        If tokens, it should work, I think.

                        Sorry, I was unclear, by "it should work" I meant "you shouldn't have to do anything special to see the process instance variables"; you shouldn't need to copy them.

                        • 9. Re: Contexts of variables in forked processing
                          Vedavyas N Rao Newbie

                          I have created those variables in a stateful session bean.
                          From this class i am triggering the process definition
                          In the process definition from the start state, the transition occurs to assign-to-admin

                          • 10. Re: Contexts of variables in forked processing
                            Edward Staub Expert

                            Right, so you're creating separate process instances.
                            See the example I pointed at earlier for "seeding" the instance with variables when you start it.

                            -Ed Staub