Hi,
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.
#{test.task3(fileDetails,execution)}
public void task3(ArrayList<String> map1,DelegateExecution execution)throws Exception
{
EngineServices engineServices = execution.getEngineServices();
TaskService taskService = engineServices.getTaskService();
System.out.println("+++++++++++++++++++++++++");
List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit")
.list();
System.out.println("Task Size" + tasks.size());
if(tasks.size()!=0)
{
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";
@Autowired
@Rule
public ActivitiRule activitiRule;
@Autowired
RuntimeService runtimeService;
@Autowired
TaskService taskService;
@Autowired
RepositoryService repositoryService;
@Test
public void startProcess() throws Exception {
repositoryService.createDeployment().addInputStream("myProcess3.bpmn20.xml",
new FileInputStream(filename)).deploy();
//repositoryService.createDeployment().addInputStream("FollowupProcess.bpmn20.xml",
//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);
assertNotNull(processInstance.getId());
System.out.println("id " + processInstance.getId() + " "
+ processInstance.getProcessDefinitionId());
List<Task> tasks = taskService.createTaskQuery().taskAssignee("kermit")
.list();
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.