9 Replies Latest reply on Nov 28, 2012 1:46 AM by Maciej Swiderski

    Could not getting tasks for business administrators through task client

    tom sebastian Newbie

      Hi all ,

           We are using WSHumantask handler for human tasks. The problem is that we couldn't get tasks for busineness administrator on taskstatus=Ready , through

      client.getTasksAssignedAsBusinessAdministrator() method.But it is getting for other statuses(Reserved,suspended etc.) . In WS humantask specification, the business administrator

      can accesss task on Ready state, and can perform forward operation on that. Is that a bug? Please reply..

        • 1. Re: Could not getting tasks for business administrators through task client
          Maciej Swiderski Master

          if you have a test case that illustrates it please file an jira issue

           

          Cheers

          • 2. Re: Could not getting tasks for business administrators through task client
            tom sebastian Newbie

            This was my class.

             

            public class BusinessAdminTest {

             

             

                      private static final long DEFAULT_WAIT_TIME = 10000l;

                      private TaskClient client;

                      private WorkItemManager manager;

                      private String ipAddress="192.168.1.111";

                      private int port=9123;

             

                      private void createClient() {

                                if (client == null) {

                                          client = new TaskClient(new MinaTaskClientConnector("com.task.BusinessAdminTest",

                                                                                                                new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                                          boolean connected = client.connect(ipAddress, port);

                                          if (!connected) {

                                                    throw new IllegalArgumentException("Could not connect task client");

                                          }

                                }

                      }

                      public void test() throws Throwable{

             

             

             

                                // Create the task

                                //assumed testGroup contain 'Mary','John' users

                                Task task1 = createTask("TaskName", "Comment","Tom","testGroup");

                                BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();

                                client.addTask(task1, null, null);

             

             

                                Thread.sleep(500);

             

                                // Test if the task is successfully created

                                BlockingTaskSummaryResponseHandler responseHandler = new BlockingTaskSummaryResponseHandler();

                                client.getTasksAssignedAsPotentialOwner("Tom", "en-UK",

                                                    responseHandler);

                                responseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                                List tasks = responseHandler.getResults();

                                if(tasks!=null){

                                          System.out.println(tasks.size());

                                          TaskSummary summary=(TaskSummary) tasks.get(0);

                                          System.out.println(summary.getStatus().toString());//will be 'Ready'

             

                                }

                                //Try to get task as business administrator

                                responseHandler = new BlockingTaskSummaryResponseHandler();

                                client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",

                                                    responseHandler);

                                responseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                                tasks = responseHandler.getResults();

                                if(tasks!=null){// according to WS specification, we expect to get task

                                          System.out.println(tasks.size());

                                          TaskSummary summary=(TaskSummary) tasks.get(0);

                                          System.out.println(summary.getStatus().toString());

             

                                }

             

                      }

                      public TaskClient getClient() {

                                return client;

                      }

                      public void setClient(TaskClient client) {

                                this.client = client;

                      }

                      private Task createTask(String taskName, String comment, String actorId,String groupId) {

                                Task task = new Task();

                                if (taskName != null) {

                                          List names = new ArrayList();

                                          names.add(new I18NText("en-UK", taskName));

                                          task.setNames(names);

                                }

                                if (comment != null) {

                                          List descriptions = new ArrayList();

                                          descriptions.add(new I18NText("en-UK", comment));

                                          task.setDescriptions(descriptions);

                                          List subjects = new ArrayList();

                                          subjects.add(new I18NText("en-UK", comment));

                                          task.setSubjects(subjects);

                                }

                                task.setPriority(10);

             

             

                                TaskData taskData = new TaskData();

             

             

             

                                PeopleAssignments assignments = new PeopleAssignments();

                                List potentialOwners = new ArrayList();

             

             

                                if (actorId != null && actorId.trim().length() > 0) {

             

                                                    potentialOwners.add(new User(actorId.trim()));

                                          }

                                if (groupId != null && groupId.trim().length() > 0) {

             

                                                    potentialOwners.add(new Group(groupId.trim()));

             

                                }

                                // Set the first user as creator ID??? hmmm might be wrong

                                          if (potentialOwners.size() > 0) {

                                                    taskData.setCreatedBy((User) potentialOwners.get(0));

                                          }

             

                                assignments.setPotentialOwners(potentialOwners);

                                List businessAdministrators = new ArrayList();

                                businessAdministrators.add(new User("administrator"));

                                assignments.setBusinessAdministrators(businessAdministrators);

                                task.setPeopleAssignments(assignments);

             

                                taskData.setSkipable(true);

             

                                task.setTaskData(taskData);

             

                                return task;

                      }

             

                      public void setManager(WorkItemManager manager) {

                                this.manager = manager;

                      }

                      public WorkItemManager getManager() {

                                return manager;

                      }

             

                      public static void main(String[] a){

                                BusinessAdminTest baTest = new BusinessAdminTest();

                                baTest.createClient();

                                try {

                                          baTest.test();

                                } catch (Throwable e) {

                                          // TODO Auto-generated catch block

                                          e.printStackTrace();

                                }

                      }

            }

             

             

             

             

             

             

            When i run this ,the output was(the first 2 lines indicate the number of tasks and its status as potential owner, while the remaining as business admin for the same task)

             

            1

            Ready

            0

            java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

            • 3. Re: Could not getting tasks for business administrators through task client
              Maciej Swiderski Master

              retrieving business admin's tasks works properly. Looks like a small typo in your test case:

               

                client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",

                                                      responseHandler);

               

              should be rather

               

                client.getTasksAssignedAsBusinessAdministrator("administrator", "en-UK",

                                                      responseHandler);

               

              HTH

              • 4. Re: Could not getting tasks for business administrators through task client
                tom sebastian Newbie

                Hi ,

                 

                Sorry i couldn't get u . You mean , i have to change the code to get tasks for business administrator  to:

                    

                client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",

                                                        responseHandler);

                 

                ?

                 

                Can u please explain a little more.

                • 5. Re: Could not getting tasks for business administrators through task client
                  Maciej Swiderski Master

                  No, it fact the problem was that you used getTasksAssignedAsPotentialOwner method instead of one dedicated to get tasks assigned as business user, see in bold:

                   

                  tom sebastian wrote:

                   

                  This was my class.

                   

                  public class BusinessAdminTest {

                   

                   

                            private static final long DEFAULT_WAIT_TIME = 10000l;

                            private TaskClient client;

                            private WorkItemManager manager;

                            private String ipAddress="192.168.1.111";

                            private int port=9123;

                   

                            private void createClient() {

                                      if (client == null) {

                                                client = new TaskClient(new MinaTaskClientConnector("com.task.BusinessAdminTest",

                                                                                                                      new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                                                boolean connected = client.connect(ipAddress, port);

                                                if (!connected) {

                                                          throw new IllegalArgumentException("Could not connect task client");

                                                }

                                      }

                            }

                            public void test() throws Throwable{

                   

                   

                   

                                      // Create the task

                                      //assumed testGroup contain 'Mary','John' users

                                      Task task1 = createTask("TaskName", "Comment","Tom","testGroup");

                                      BlockingTaskOperationResponseHandler operationResponseHandler = new BlockingTaskOperationResponseHandler();

                                      client.addTask(task1, null, null);

                   

                   

                                      Thread.sleep(500);

                   

                                      // Test if the task is successfully created

                                      BlockingTaskSummaryResponseHandler responseHandler = new BlockingTaskSummaryResponseHandler();

                                      client.getTasksAssignedAsPotentialOwner("Tom", "en-UK",

                                                          responseHandler);

                                      responseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                                      List tasks = responseHandler.getResults();

                                      if(tasks!=null){

                                                System.out.println(tasks.size());

                                                TaskSummary summary=(TaskSummary) tasks.get(0);

                                                System.out.println(summary.getStatus().toString());//will be 'Ready'

                   

                                      }

                                      //Try to get task as business administrator

                                      responseHandler = new BlockingTaskSummaryResponseHandler();

                                      client.getTasksAssignedAsPotentialOwner("administrator", "en-UK",

                                                          responseHandler);

                                      responseHandler.waitTillDone(DEFAULT_WAIT_TIME);

                                      tasks = responseHandler.getResults();

                                      if(tasks!=null){// according to WS specification, we expect to get task

                                                System.out.println(tasks.size());

                                                TaskSummary summary=(TaskSummary) tasks.get(0);

                                                System.out.println(summary.getStatus().toString());

                   

                                      }

                   

                            }

                            public TaskClient getClient() {

                                      return client;

                            }

                            public void setClient(TaskClient client) {

                                      this.client = client;

                            }

                            private Task createTask(String taskName, String comment, String actorId,String groupId) {

                                      Task task = new Task();

                                      if (taskName != null) {

                                                List names = new ArrayList();

                                                names.add(new I18NText("en-UK", taskName));

                                                task.setNames(names);

                                      }

                                      if (comment != null) {

                                                List descriptions = new ArrayList();

                                                descriptions.add(new I18NText("en-UK", comment));

                                                task.setDescriptions(descriptions);

                                                List subjects = new ArrayList();

                                                subjects.add(new I18NText("en-UK", comment));

                                                task.setSubjects(subjects);

                                      }

                                      task.setPriority(10);

                   

                   

                                      TaskData taskData = new TaskData();

                   

                   

                   

                                      PeopleAssignments assignments = new PeopleAssignments();

                                      List potentialOwners = new ArrayList();

                   

                   

                                      if (actorId != null && actorId.trim().length() > 0) {

                   

                                                          potentialOwners.add(new User(actorId.trim()));

                                                }

                                      if (groupId != null && groupId.trim().length() > 0) {

                   

                                                          potentialOwners.add(new Group(groupId.trim()));

                   

                                      }

                                      // Set the first user as creator ID??? hmmm might be wrong

                                                if (potentialOwners.size() > 0) {

                                                          taskData.setCreatedBy((User) potentialOwners.get(0));

                                                }

                   

                                      assignments.setPotentialOwners(potentialOwners);

                                      List businessAdministrators = new ArrayList();

                                      businessAdministrators.add(new User("administrator"));

                                      assignments.setBusinessAdministrators(businessAdministrators);

                                      task.setPeopleAssignments(assignments);

                   

                                      taskData.setSkipable(true);

                   

                                      task.setTaskData(taskData);

                   

                                      return task;

                            }

                   

                            public void setManager(WorkItemManager manager) {

                                      this.manager = manager;

                            }

                            public WorkItemManager getManager() {

                                      return manager;

                            }

                   

                            public static void main(String[] a){

                                      BusinessAdminTest baTest = new BusinessAdminTest();

                                      baTest.createClient();

                                      try {

                                                baTest.test();

                                      } catch (Throwable e) {

                                                // TODO Auto-generated catch block

                                                e.printStackTrace();

                                      }

                            }

                  }

                   

                   

                   

                   

                   

                   

                  When i run this ,the output was(the first 2 lines indicate the number of tasks and its status as potential owner, while the remaining as business admin for the same task)

                   

                  1

                  Ready

                  0

                  java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

                  • 6. Re: Could not getting tasks for business administrators through task client
                    tom sebastian Newbie

                    Oh. ok. Iam extremely sorry, that was my mistake.I also meant that bold portion might be :

                     

                    client.getTasksAssignedAsBusinessAdministrator("administrator", "en-UK",

                                                            responseHandler);

                     

                    Unfortunately when i post that code it was changed, but i forgot to correct that. But output i pasted was the correct one.

                    But even i used this code i couldnt get the BA's tasks in 'Ready' state.

                     

                    What might be the issue. If task go to 'Reserved','InProgress' etc . status , i could task as BA.

                     

                    Thanks

                    Tom

                    • 7. Re: Could not getting tasks for business administrators through task client
                      Maciej Swiderski Master

                      hmm unfortunately I can't reproduce it, what jbpm version do you run on?

                      • 8. Re: Could not getting tasks for business administrators through task client
                        tom sebastian Newbie

                        i am using jbpm 5.2 and humantask version 5.2 (downloaded  jbpm-human-task-war-5.2.0.Final)

                        • 9. Re: Could not getting tasks for business administrators through task client
                          Maciej Swiderski Master

                          maybe it was an issue in 5.2 as I tested it with 5.4 and master. Could you give a try and upgrade?