-
1. Re: Getting the last actor of the completed task
swiderski.maciej May 4, 2010 12:18 PM (in response to matrixpooh)Hi,
in general you can do it using TaskService and TaskQuery, as follows:
List<Task> tasks = taskService.createTaskQuery(). processInstanceId(processInstance.getId()).activityName("activityName").list();
You can use as well orderByDesc or Asc to sort the result.
HTH
Maciej
-
2. Re: Getting the last actor of the completed task
swiderski.maciej May 4, 2010 12:30 PM (in response to matrixpooh)Hi,
sorry, I gave you wrong examples. It should be:
List<HistoryTask> history = historyService.createHistoryTaskQuery().executionId(processInstance.getId()).list();
Unfortunately there is no way to narrow down the search by activity name but you can either use task id or outcome.
In the worst case you will get all completed task for execution and the filter it manually.
Cheers,
Maciej
-
3. Re: Getting the last actor of the completed task
matrixpooh May 4, 2010 4:58 PM (in response to matrixpooh)Thanks Maceij,
I went with a work-around:
I made transitions to the tasks match tasks names: if a task is called 'task-1', then transition is 'to-task-1'. Holding the pattern, i can do:
processEngine.getHistoryService().createHistoryTaskQuery().executionId(executionId+".to-"+activityName).state(Task.STATE_COMPLETED).uniqueResult();
where activityName is 'task-1'
Thanks again for help!
-
4. Re: Getting the last actor of the completed task
matrixpooh Aug 17, 2010 1:06 PM (in response to matrixpooh)Found a better way to get a history task via HistoryActivityInstance:
HistoryActivityInstance hai = historyService.createHistoryActivityInstanceQuery().processInstanceId(pid).activityName(activityName).uniqueResult();
if (hai.getClass() == HistoryTaskInstanceImpl.class)
HistoryTask ht = ((HistoryTask)hai).getHistoryTask();