Have you found a solution for this? We are have the same use case were we have a process with a lot of subprocesses that create several tasks and we need a simple way to query for all the tasks for the process including tasks generated by its subprocesses. The interfaces have some limitations and we have seen the need to create our own custom repositories that works over the jbpm tables for some of these queries using oracle specific features to do queries over tree structures.
jBPM seems very configurable and I think many projects will need to extend the basic service interfaces and the out of box query support using their own commands and extensions. The service interfaces cover the basic and most used features and I can understand that the jBPM development team wants to keep them slim.
You could create a custom command, but for me it seems like you will not come away from a downcast if you for example need to create custom queries using the hibernate critereia api.
I would try :
List<Task> currentTasks = yourProcessEngine.getTaskService() .createTaskQuery() .processInstanceId(yourProcessInstanceId) .list()
You can also add various filters and/or order them by Name/ Priority, etc ...
If you want all the subprocesses, you could also look at the following methods in org.jbpm.api.Execution
getExecutions() findActiveActivityNames() getExecutionsMap()
hope this helps.
The TaskQuery won't let search by Parent ProcessInstance.
getActiveActivityNames return the name of the active subprocess but not the ID. So it's useless for querying with TaskQuery.
getExecutions() on the Parent ProcessInstance return empty since the execution is in the sub-process
And I havn't checked the ExecutionsMap but should be the same as Executions I guess.
So I'll keep the cast to ExcecutionImpl for now I guess...
I encountered the same problem with the History. TaskHistory and ActivityHistory doesn't keep their parent / child relationship. Since the relationship is lost, there is no way to know which sub-process task is related to the parent ProcessInstance. The database keep no track of that information. Kinda bad, guess I'll have to keep a relationship table on the side.