2 Replies Latest reply on Feb 12, 2009 3:21 PM by Elifarley Cruz

    Dynamically creating task  * nodes * for each group of actor

    Elifarley Cruz Newbie

      Consider the following pseudo code:

      
      // List whose elements are arrays of actor ids.
      // Its contents are not known in advance
      List<String[]> listOfArrays = { {"actor-A", "actor-B"}, {"actor-C", "actor-D"} };
      
      for (String[] actorIds : listOfArrays ) {
      
       ! create a task-node assigned to all actors in actorIds;
       ! wait until any of those actors completes his/her task by selecting either YES or NO;
       ! If the actor selected "NO", abort. Otherwise, continue.
      
      }
      
      


      Example of execution:

      
      List<String[]> listOfArrays = { {"actor-A", "actor-B"}, {"actor-C", "actor-D"} };
      
      ! create task node assigned to {"actor-A", "actor-B"};
      ! wait for the task to be completed by either actor;
      (Suppose actor selected "YES")
      ! create task node assigned to {"actor-C", "actor-D"};
      ! wait for the task to be completed by either actor;
      (Suppose actor selected "YES")
      ! Done.
      
      



      What would be the best way to implement this with jBPM ?

      Maybe there's a way of achieving the same goal without creating task nodes...

      Thanks for any ideas you may have.

        • 1. Clarification
          Elifarley Cruz Newbie

          Let me clarify the last post with an imaginary use case (close to the real one).

          A node in my workflow loads a text file describing stages through which an order request must pass in order to be approved:

          --
          actor-A, actor-B;
          actor-C, actor-D, actor-E;
          actor-F;
          --

          Each order request has its associated text file (otherwise I could simply design a fixed workflow with the appropriate task nodes).

          For each line, a task should be assigned to the group of actors listed on that line.

          I tried to parse the text file and create a transient, dynamic process definition based on it, so that I could persist it, call it using a process-state node, and then purge it from the database - all from the same master process.

          Unfortunately, it doesn't seem to work like that.

          I'll try to create this transient process definition and post a JMS message to be later processed. At least it sounds more promising...

          • 2. [SOLVED]
            Elifarley Cruz Newbie

            There's no need to create one task node for each line of the input file.

            I've created only one task node and a decision node pointing to each other in a loop. They've allowed me to iterate through each input line, reusing the single task node.

            Cheers,
            Elifarley