4 Replies Latest reply on May 24, 2011 6:02 PM by slelarge

    Group assignment and action on tasks

    sasir

      Am able to define and assign the groupid tohuman task and able to pull the list of tasks  using TaskClient. Howwever am unable to action further(like release/claim/start/complete) on the items assigned to the group using the member of group as userid.

       

      How does TaskServer behave in this scenario? Am i missing something here??

       

       

      Code Snippet

      *******

       

      For Group Assignment

       

      MinaTaskServer server;

      EntityManagerFactory emf = Persistence.createEntityManagerFactory("org.jbpm.task");
      TaskService taskService = new TaskService(emf, SystemEventListenerFactory.getSystemEventListener());
      TaskServiceSession taskSession= taskService.createSession();

      server = new MinaTaskServer(taskService);
      Thread thread = new Thread(server);

       

      List<OrganizationalEntity> usersList=new ArrayList<OrganizationalEntity>();

       

      usersList.add(new User("sasi"

      ));

       

      usersList.add(new User("venkat"

      ));

      usersList.add(new User("krisv"

      ));

      usersList.add(new User("mary"));

      BPMTaskUserInfo userInfo = new

      BPMTaskUserInfo();

       

      taskService.setUserinfo(userInfo);

       

      userInfo.getGroups().put(new Group("Group1"

      ), usersList);

      userInfo.getGroups().put(new Group("Group2"

      ), usersList);

      userInfo.getGroups().put(new Group("Group3"), usersList);

       

       

       

       

      For retrieving tasks

       

      public static void getTasks(StatefulKnowledgeSession ksession){
        WorkItemHandler htHandler = new WSHumanTaskHandler();
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", htHandler);

       

        TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1",new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
        boolean isConnected = client.connect("127.0.0.1", 9123);
       
        System.out.println("client conencted :"+isConnected);
        BlockingTaskSummaryResponseHandler summaryHandler = new BlockingTaskSummaryResponseHandler();
        int timeoutCounter = 0;
        List<TaskSummary> tasks;
        List<String> groups= new ArrayList<String>();
        groups.add("Group1");

        do {
        client.getTasksAssignedAsPotentialOwner("sasi",groups, "en-UK", summaryHandler);
        tasks = summaryHandler.getResults();
       
         TaskSummary task = null; 
         for (TaskSummary taskSummary : tasks)
         {  
         System.out.println(taskSummary.getId() + " : "     + taskSummary.getName());  
         
         }
        //wait until the task is registered with the server or timeout expires
        if (timeoutCounter != 0) {
        try {
         Thread.sleep(10);
        } catch (InterruptedException e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
        }
        }
        } while (tasks.isEmpty() && timeoutCounter++ < 10);
        System.out.println("Tasks size is"+tasks.size());

        TaskSummary task = tasks.get(0);
       
        System.out.println("Task details are "+task.getId());
       
        BlockingTaskOperationResponseHandler operationHandler =
         new BlockingTaskOperationResponseHandler();
         client.release(task.getId(), "Administrator", operationHandler);
         operationHandler.waitTillDone(5000);
        
         operationHandler =
         new BlockingTaskOperationResponseHandler();
         client.claim(task.getId(), "sasi", operationHandler);
         operationHandler.waitTillDone(5000);

         operationHandler =
         new BlockingTaskOperationResponseHandler();
         client.start(task.getId(), "sasi", operationHandler);
         operationHandler.waitTillDone(5000);

         operationHandler =
         new BlockingTaskOperationResponseHandler();
         client.complete(task.getId(), "sasi", null,
         operationHandler);
         operationHandler.waitTillDone(5000);

       
        
      }


      Error:

      [2011:03:83 11:03:898:debug] Arguments : [[org.jbpm.task.query.TaskSummary@3585d013, org.jbpm.task.query.TaskSummary@7fc4f753, org.jbpm.task.query.TaskSummary@c2579d8d, org.jbpm.task.query.TaskSummary@73ef06e5, org.jbpm.task.query.TaskSummary@2d60e703, org.jbpm.task.query.TaskSummary@aa5cc20b, org.jbpm.task.query.TaskSummary@33aad8e3, org.jbpm.task.query.TaskSummary@105b609b, org.jbpm.task.query.TaskSummary@9a153a13, org.jbpm.task.query.TaskSummary@2398c26b, org.jbpm.task.query.TaskSummary@63ece17b]]
      5105 : Event-Ready-Task
      9905 : Event-Ready-Task
      3755 : Event-Ready-Task
      4355 : Event-Ready-Task
      8705 : Event-Ready-Task
      5705 : Event-Ready-Task
      6305 : Event-Ready-Task
      6905 : Event-Ready-Task
      7505 : Event-Ready-Task
      8105 : Event-Ready-Task
      9305 : Event-Ready-Task
      Tasks size is11
      Task details are 5105
      org.jbpm.task.service.PermissionDeniedException: Server-side Exception: User '[User:'Administrator']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.jbpm.task.service.responsehandlers.AbstractBaseResponseHandler.createSideException(AbstractBaseResponseHandler.java:74)
      at org.jbpm.task.service.responsehandlers.AbstractBlockingResponseHandler.waitTillDone(AbstractBlockingResponseHandler.java:48)
      at com.sample.CorporateActionsNewTest.getTasks(CorporateActionsNewTest.java:132)
      at com.sample.CorporateActionsNewTest.main(CorporateActionsNewTest.java:60)
      [2011:03:83 11:03:37:debug] Message receieved on client : OperationResponse
      [2011:03:83 11:03:38:debug] Arguments : [org.jbpm.task.service.PermissionDeniedException: User '[User:'Administrator']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines]


      If i try with Sasi for release

      org.jbpm.task.service.PermissionDeniedException: Server-side Exception: User '[User:'sasi']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
      at java.lang.reflect.Constructor.newInstance(Unknown Source)
      at org.jbpm.task.service.responsehandlers.AbstractBaseResponseHandler.createSideException(AbstractBaseResponseHandler.java:74)
      at org.jbpm.task.service.responsehandlers.AbstractBlockingResponseHandler.waitTillDone(AbstractBlockingResponseHandler.java:48)[2011:03:83 11:03:626:debug] Message receieved on client : OperationResponse
      [2011:03:83 11:03:627:debug] Arguments : [org.jbpm.task.service.PermissionDeniedException: User '[User:'sasi']' was unable to execution operation 'Release' on task id 5105 due to no 'current status' matchines]

      at com.sample.CorporateActionsNewTest.getTasks(CorporateActionsNewTest.java:132)
      at com.sample.CorporateActionsNewTest.main(CorporateActionsNewTest.java:60)

       

       

      5105 task is with 'Ready' status in datasbase

        • 1. Group assignment and action on tasks
          salaboy21

          Did you claim the task before calling the release method?? I think that you should claim the task first and then you can release it. If you have a fixed assignee to the task you cannot claim it because it's already asigned, so it should be asigned as a Group Task to be able to do the claim/release calls.

          Greetings.

          • 2. Group assignment and action on tasks
            sasir

            If i claim the Group task as 'Administrator'(Default) and delegate it to 'sasi', then am able to execute the next steps liek start/complete. But do we have to follow those steps always for acting on the task even though 'sasi' is part of the defined group?  Then whats the point of adding group information to the user and making the task server aware?

             

            I believe I am missing soemthing here. Can you please advise??

            • 3. Group assignment and action on tasks
              jlgranda81

              I try to assign human task to group trow

              <potentialOwner>

                      <resourceAssignmentExpression>

                        <formalExpression>ridrensur.financiero.secretaria</formalExpression>

                      </resourceAssignmentExpression>

                    </potentialOwner>

               

              I have ridrensur.financiero.secretaria defined how Group in organizationalentity table. Whe start the process, jbpm5 assign createdby_id and actualowner_id to ridrensur.financiero.secretaria. Finally, whe I try to list user member of ridrensur.financiero.secretaria task, no is posible, but jbpm list only task for potentialowner. If change manually actualowner_id to null and then can list tasks

               

              I trace the code https://github.com/krisv/jbpm/blob/master/jbpm-bpmn2/src/main/java/org/jbpm/bpmn2/xml/UserTaskHandler.java, no exists way for defined groups like jbpm4.4, setting user o group in xml tag.

               

              Is posible that feature are added in next release, How I can suggest it?

              • 4. Re: Group assignment and action on tasks
                slelarge

                Hi Sasi,

                 

                i will be really interested on how you implemented the BPMTaskUserInfo.

                For now I am not yet able to use group assignment successfully...

                 

                Can you help me ?

                Thanks