This is a basic functionality and I see repeated questions , but unfortunately no clear answer yet.
How do I print/list all the tasks in the given process ( finished / unfinished ) in the order of execution.
The two solution I found on the forum are working as expected
repositoryService.getBpmnModel().getFlowElements() - Does not print in the order of execution . Printed in the order of definition
historyService.createHistoricActivityQuery - Does not print all Service task
How do I just list all the task under the given process.
If by tasks you mean all the elements in the process then you can use the HistoricActivityInstanceQuery
to get the information about them.
The code would look something like:
List<HistoricActivityInstance> activityInstances = historyService
.createHistoricActivityInstanceQuery().
.processInstanceId(processInstanceId)
.orderByHistoricActivityInstanceStartTime().asc()
.list();
In order to see if a HistoricActivityInstance
is finished or not you'll need to check the HistoricActivityInstance#getEndTime()
. When that is null
it means that the activity is not finished, if it is null
then it means it is finished.