4 Replies Latest reply on Jan 29, 2012 7:52 PM by Charlie B

    User Task Assignment and Assignment Restrictions

    Charlie B Newbie

      Hi,

       

      I have just started using JBPM5, and have a few questions concerning user task assignments and restrictions.

       

      I have built my process using various User Tasks. Each time I complete a Task, I pass in specific parameters which a gateway uses to determine the next possible course of action (which task to execute next) and who to assign the next task to. For instance, when completing the 'Develop' task, I pass in 'assignTo=johnsmith' and 'result=SubmitForReview'.

      This is working quite fine, but if there is a better way to do this, please do tell. I am open to suggestions.

       

      Rules.jpg

      What I am trying to figure out, if there is someway (progromatically through the API) to determine:

       

      1. What are the next possible courses of action? (From Development it can be 'Review' or 'Approve')

      2. Who can perform each one of these tasks?

       

      The only way I can figure to achieve somethiing like this, is provide the information in each tasks 'Content' property. If this is the way to do it, how do I access the 'Content' of each task through the API?

       

      While I can determine all these things quite easily in my application logic, it would be a great benefit if I can keep all this logic in JBPM and seperate my business rules from the workflow logic.

       

      I know from my knowledge of JBPM3, that you can achieve somethinig like this quite simply. Is it possible in JBPM5?

       

      Thanks

       

      Charlie B

        • 1. Re: User Task Assignment and Assignment Restrictions
          jemmerling Newbie

          Here is a code snippet from the Human Task Example in jbpm-examples that accesses content via the API. Is this what you have in mind?

           

           

            BlockingGetTaskResponseHandler getTaskResponseHandler = new BlockingGetTaskResponseHandler();
            taskClient.getTask(task4.getId(), getTaskResponseHandler);
            Task task = getTaskResponseHandler.getTask();
            BlockingGetContentResponseHandler getContentResponseHandler = new BlockingGetContentResponseHandler();
            taskClient.getContent(task.getTaskData().getDocumentContentId(), getContentResponseHandler);
            Content content = getContentResponseHandler.getContent();
            ByteArrayInputStream bis = new ByteArrayInputStream(content.getContent());
            ObjectInputStream in;
            try {
              in = new ObjectInputStream(bis);
              Object result = in.readObject();
              in.close();
              Map<?, ?> map = (Map<?, ?>) result;
              for (Map.Entry<?, ?> entry: map.entrySet()) {
              System.out.println(entry.getKey() + " = " + entry.getValue());
              }
            } catch (IOException e) {
              e.printStackTrace();
            } catch (ClassNotFoundException e) {
              e.printStackTrace();
            }

          • 2. Re: User Task Assignment and Assignment Restrictions
            Charlie B Newbie

            So I guess I can place "flow" data into the Content of each User Task indicating the next possible steps. That way, I can dynamically render pages for users depending on the current task, and the next possible outcome?

             

            Do you think this is the best approach?

             

            For example, when a user loads their task, say a REVIEW task, I want to dynamically determine what are the next possible outcomes (APPROVE -> Go to Test, REJECT -> Go back to development) and display those buttons on the screen for the user.

             

            Is the Content field, the best place to store this information?

             

            Thanks in advance.

             

            Charlie

            • 3. Re: User Task Assignment and Assignment Restrictions
              Chris Melas Apprentice

              Hello,

              You could also use process variables i.e. have a colleciton with possible outcomes that gets populated on the entry action of each task.

               

              The advantage of these approaches is the simplicity in implementing them, however the downside is that you enter data to your process that is already there.... if i understand correctly. So i guess it would be best to just use the data that is already defined within your bpmn.

               

              Have you tried traversing your process and examine each of the nodes to see whether you can retrieve such data?

              Take a look at the following post on how to traverse your process,

              https://community.jboss.org/message/630192

              • 4. Re: User Task Assignment and Assignment Restrictions
                Charlie B Newbie

                Thanks.

                 

                I will traverse the process to achieve what I need.

                 

                Charlie