3 Replies Latest reply on May 14, 2008 4:52 PM by kukeltje

    Optional actor-id

    tom_goring

      Hi,

      I'd like to be able to optionally assign a task to a person in a group.
      I.e. #{someexpression} may be an actorid but it maybe null
      If #{someexpression} == null jBPM stack traces
      If #{someexpression}== "" the assignment does not work (it belongs to the "" actor.

      Any idea how to do this?

      <task-node name="reviewContractor">
       <task name="Review" description="Xyz">
       <assignment pooled-actors="#{group}" actor-id="#{someexpression}"/>
       </task>
       <transition to="done"></transition>
      </task-node>
      


        • 1. Re: Optional actor-id
          kukeltje

          write your own assignmenthandler

          • 2. Re: Optional actor-id
            tom_goring

            Thanks for that...

            I've looked though the examples... can you give me a pointer to as to how best to pass arguments to the handler? Or do I need to use the process variables?

            I was hoping I could do the below but as soon as I change:

            <assignment class="jnet.faces.PersonAssignmentHandler"></assignment>
            

            To
            <assignment class="jnet.faces.PersonAssignmentHandler" pooled-actors="#{accountantCompany.entityId}" actor-id="#{personRelations.getPersonManagerActorId(accountantCompany)}"></assignment>
            


            My handler is nolonger called:

            public class PersonAssignmentHandler implements AssignmentHandler {
            
             public void assign(Assignable assignable, ExecutionContext executionContext)
             throws Exception {
             String groupId = Interpolator.instance().interpolate(executionContext.getTask().getPooledActorsExpression());
             String actorId = Interpolator.instance().interpolate(executionContext.getTask().getActorIdExpression());
             if ( !StringUtil.isNullOrBlank(actorId) ) {
             assignable.setActorId(actorId);
             }
             if ( !StringUtil.isNullOrBlank(groupId) ) {
             assignable.setPooledActors(new String[] {groupId});
             }
             }
            


            • 3. Re: Optional actor-id
              kukeltje

              correct, you have to pass parameters like you do with normal actionhandlers, so something like

              <assignment class="jnet.faces.PersonAssignmentHandler">
               <pooled-actors>#{accountantCompany.entityId}</pooled-actors>
               <actor-id>#{personRelations.getPersonManagerActorId(accountantCompany)}</actor-id>
              </assignment>
              


              Then have the properties/setters/getters called pooled-actors and actor-id as strings, and then in the assign method, parse these strings as EL (see jbpm source for some examples) and you're there.

              Nice btw that you experimented yourself. Often people just reply 'how do I do that', which makes me less interested in replying. This however does the opposite. Neat...