Search in sources :

Example 1 with GetTasksForProcessCommand

use of org.jbpm.services.task.commands.GetTasksForProcessCommand in project jbpm by kiegroup.

the class TaskCleanUpProcessEventListener method afterProcessCompleted.

@Override
public void afterProcessCompleted(ProcessCompletedEvent event) {
    List<Status> statuses = new ArrayList<Status>();
    statuses.add(Status.Error);
    statuses.add(Status.Failed);
    statuses.add(Status.Obsolete);
    statuses.add(Status.Suspended);
    statuses.add(Status.Completed);
    statuses.add(Status.Exited);
    List<TaskSummary> completedTasksByProcessId = ((InternalTaskService) taskService).execute(new GetTasksForProcessCommand(event.getProcessInstance().getId(), statuses, "en-UK"));
    // archive and remove
    taskService.archiveTasks(completedTasksByProcessId);
    taskService.removeTasks(completedTasksByProcessId);
}
Also used : Status(org.kie.api.task.model.Status) GetTasksForProcessCommand(org.jbpm.services.task.commands.GetTasksForProcessCommand) ArrayList(java.util.ArrayList) TaskSummary(org.kie.api.task.model.TaskSummary) InternalTaskService(org.kie.internal.task.api.InternalTaskService)

Aggregations

ArrayList (java.util.ArrayList)1 GetTasksForProcessCommand (org.jbpm.services.task.commands.GetTasksForProcessCommand)1 Status (org.kie.api.task.model.Status)1 TaskSummary (org.kie.api.task.model.TaskSummary)1 InternalTaskService (org.kie.internal.task.api.InternalTaskService)1