5 Replies Latest reply on Apr 23, 2007 3:50 AM by Arjan van Bentem

    Assign a generic sub-process task in the parent process?

    Arjan van Bentem Novice

      I'd like to define my actors on process level, not on task level. Doing so I'd like re-use a sub-process for different actors who, in my opinion, are not really part of the same swimlane. Like both a helpdesk employee and the customer would need to fill in the same questionnaire at different points in the main process. The employee is, at some earlier stage, assigned from a pool of actors.

      Of course, before getting to the task I could outject some Actor that is used like:

      <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="survey">
       :
       <task-node name="survey">
       <task name="survey">
       <assignment actor-id="#{outjectedActor.id}"/>
       </task>
       :
       </task-node>
      </process-definition>


      Above, the survey process would be included in multiple places in my main process definition, like:
      <process-state name="Customer survey">
       <sub-process name="survey" />
       :
      </process-state>
      :
      :
      <process-state name="Employee survey">
       <sub-process name="survey" />
       :
      </process-state>


      So, above I'd need to make sure to outject the (different) Actor in multiple places as well.

      Alternatively maybe I should include some variable, which can then be retrieved in some component that is used in the assignment expression:
      <task name="survey">
       <assignment actor-id="#{taskAssignerComponent.surveyActor.id}"/>
      </task>

      referred to by, for example,
      <process-state name="Employee survey">
       <sub-process name="survey">
       <variable name="surveySwimlane" .../>
       </sub-process>
       :
      </process-state>


      In either case, to directly outject the Actor property, or to invoke a getSurveyActor() method on some TaskAssigner component, I'd need to know who's filling in the survey, or which parent process invoked the generic sub-process.

      I wonder if there's a better way?

      Thanks,
      Arjan.

        • 1. Re: Assign a generic sub-process task in the parent process?
          Ronald van Kuijk Master

          we did it like in the second solution (not using seam yet). So not sure there is a better way. We don't have many problems with this.

          • 2. Re: Assign a generic sub-process task in the parent process?
            Arjan van Bentem Novice

            I guess I could use TaskInstance#setSwimlaneInstance to change the swimlane on the fly.

            The documentation states that the actor is "remembered in the process for all subsequent tasks that are in the same swimlane". I hope this also applies to sub-processes. If so, then I can set a specific Actor for the employee and customer swimlanes at the beginning of the process. Next, within the sub-processes I would then alternate the swimlane using #setSwimlanceInstance (well -- if I can get to the parent process, given a sub-process). jBPM would then still know which Actor was assigned to that specific swimlane.

            Just for the archives: see also the post "asign swimlanes in execution time".

            I'll give it a try; any thoughts on this? For example I wonder if I could abandon an existing SwimlaneInstance when changing the swimlane on the fly. In other words: I wonder if I need to do some clean-up when the process ends, if I changed swimlane instances myself?

            To be continued...
            Arjan.

            • 3. Re: Assign a generic sub-process task in the parent process?
              Ronald van Kuijk Master

              Additional info reagarding the assignment in swimlanes

              • 4. Re: Assign a generic sub-process task in the parent process?
                Arjan van Bentem Novice

                 

                "kukeltje" wrote:
                <a href="http://jira.jboss.com/jira/browse/JBPM-743">Additional info reagarding the assignment in swimlanes</a>

                Thanks!

                But so far no luck setting the swimlane to start with; no matter where I try to get my event handler invoked, the injected TaskInstance is always null when invoked from a parent process.

                For example:
                <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="survey">
                 :
                 <task-node name="survey">
                 <task name="survey">
                 <!-- The same results for task-start or task-assign -->
                 <event type="task-create">
                 <action name=".." expression="#{taskAssigner.setSwimlane}" />
                 </event>
                 </task>
                 :
                 </task-node>
                </process-definition>


                And likewise when setting the event handler on the task-node:
                <process-definition xmlns="urn:jbpm.org:jpdl-3.2" name="survey">
                 :
                 <task-node name="survey">
                 <event type="node-enter">
                 <action name=".." expression="#{taskAssigner.setSwimlane}" />
                 </event>
                 <task name="survey">
                 :
                 </task>
                 :
                 </task-node>
                </process-definition>


                When starting the sub-process directly (so, not from within some process-state in a parent process) then I do get a TaskInstance injected though...

                Like I said: to be continued... I hope!
                Arjan.

                • 5. Re: Assign a generic sub-process task in the parent process?
                  Arjan van Bentem Novice


                  The only option that seems doable is

                  <process-state name="Employee survey">
                   <sub-process name="survey">
                   <variable name="surveySwimlane" .../>
                   </sub-process>
                   :
                  </process-state>

                  So, I've issued a feature request to allow for setting Actor or Swimlane on process level: JBPM-955.