AnsweredAssumed Answered

getting tasklist size as zero even though task has been assigned to specific user

Question asked by dhayanidhypazhaniandy on Jun 24, 2013
Latest reply on Jul 1, 2013 by dhayanidhypazhaniandy

I am working on a POC to retrive the tasklist assigned to specific user - (after the task has been assigned), I am using task listeners and execution listeners to call java class user defined method, where i wrote the code to retrive the task list. I tried with task listeners event like create, assignment, complete and execution listeners event like start and end but everytime the java method prints the task size as zero only. please find below the expression used to call user defined method and java code.


public void task3(ArrayList<String> map1,DelegateExecution execution)throws Exception
   EngineServices engineServices  = execution.getEngineServices();
   TaskService taskService = engineServices.getTaskService();
   List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit")
   System.out.println("Task Size" + tasks.size());
Task myTask = tasks.get(0);
   HashMap<String, Object> errorMessage = new HashMap<String, Object>();
   errorMessage.put("list", map1);
   taskService.setVariables(myTask.getId(),errorMessage );
but the same code works fine when i specify at Junit test java class. It retuns the list size as 1.
please find below the code for the same.

public class ProcessTestMyProcess3 {

   private String filename = "C:\\Documents and Settings\\xx50532\\workspace\\Samples\\src\\test\\main\\resources\\diagrams\\MyProcess3.bpmn";
   //private String filename1 = "C:\\Documents and Settings\\xx50532\\workspace\\Samples\\src\\test\\main\\resources\\diagrams\\FollowUpProcess.bpmn";
   public ActivitiRule activitiRule;

   RuntimeService runtimeService;

   TaskService taskService;

   RepositoryService repositoryService;

   public void startProcess() throws Exception {
            new FileInputStream(filename)).deploy();
            //new FileInputStream(filename1)).deploy();
      List<String> variableMap_0 = new ArrayList<String>();
      variableMap_0.add(0, "Payment");
      variableMap_0.add(1, "ACH");
      Map<String, Object> variableMap = new HashMap<String, Object>();
      variableMap.put("Test", "Test1");
      variableMap.put("fileDetails", variableMap_0);
      //variableMap.put("taskService", taskService);
      System.out.println("taskService 1 "+ taskService);
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess3", variableMap);
      System.out.println("id " + processInstance.getId() + " "
            + processInstance.getProcessDefinitionId());
         List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit")
      System.out.println("Task Size" + tasks.size());

I not wrote any java code to create and assign the task, I used Activiti designer to create and to assign the task to specific user.
please help me out in fixing the issue.

Thanks and Regards
Dhayanidhy P.