04-21-2014 04:33 AM
public class MyEventListener implements ActivitiEventListener{
@Override
public boolean isFailOnException() {
// TODO Auto-generated method stub
return false;
}
@Override
public void onEvent(ActivitiEvent event) {
// TODO Auto-generated method stub
switch(event.getType()){
case TASK_ASSIGNED:
System.out.println("From Event handler TASK_ASSIGNED:");
TaskService ts = event.getEngineServices().getTaskService();
System.out.println("No of Task: " + ts.createTaskQuery().processInstanceId(event.getProcessInstanceId()).count());
List<Task> tasks = ts.createTaskQuery().processInstanceId(event.getProcessInstanceId()).list();
for(Task task : tasks)
{
System.out.println("Task Name: " + task.getName());
System.out.println("Task Assignee: " + task.getAssignee());
System.out.println("Task Description: " + task.getDescription());
}
break;
case TASK_COMPLETED:
System.out.println("From Event handler TASK_COMPLETED:");
TaskService ts2 = event.getEngineServices().getTaskService();
System.out.println("No of Task: " + ts2.createTaskQuery().processInstanceId(event.getProcessInstanceId()).count());
tasks = ts2.createTaskQuery().processInstanceId(event.getProcessInstanceId()).list();
for(Task task : tasks)
{
System.out.println("Task Name: " + task.getName());
System.out.println("Task Assignee: " + task.getAssignee());
System.out.println("Task Description: " + task.getDescription());
}
break;
}
}
}
TaskService ts = activitiRule.getTaskService();
System.out.println("From Junit Test");
System.out.println("No of Tasks from UnitTest: " +ts.createTaskQuery().processInstanceId(processInstance.getId()).count() );
List<Task> tasks = ts.createTaskQuery().processInstanceId(processInstance.getId()).list();
for(Task task : tasks)
{
System.out.println("Task Name: " + task.getName());
System.out.println("Task Assignee: " + task.getAssignee());
System.out.println("Task Description: " + task.getDescription());
ts.complete(task.getId());
}
From Event handler TASK_ASSIGNED:
No of Task: 0
From Junit Test
No of Tasks from UnitTest: 1
Task Name: Approval
Task Assignee: kermit
Task Description: This is Simple Approval Task
From Event handler TASK_COMPLETED:
No of Task: 1
Task Name: Approval
Task Assignee: kermit
Task Description: This is Simple Approval Task
04-22-2014 04:37 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.