cancel
Showing results for 
Search instead for 
Did you mean: 

Listing all tasks from a bpmnModel, including those from a called activity

hiravgandhi
Champ in-the-making
Champ in-the-making
Currently, I am retrieving a bpmnModel from runtimeService and using code from ProcessDiagramGenerator to get a list of all tasks in a process. However, I would like to be able to retrieve the tasks from the subprocesses called from CallActivities. How would I go about doing that?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
You should use the BpmnModel you can get from the RepositoryService. That allows you to inspect the whole process definition using java pojo's.

hiravgandhi
Champ in-the-making
Champ in-the-making
Thank you Joram. I made a typo in my original question - I am using RepositoryService but I am a little confused as to how to go about doing printing out that list of tasks. The documentation on BpmnModel doesn't seem to be the greatest.

frederikherema1
Star Contributor
Star Contributor
Use getFlowElements() on the Process (fetched from the BPMNModel). If it's a UserTask, print it. If it's a CallActivity, use the "calledElement" property to get hold of the key of the referenced definition. With this key, fetch the ID of the latest definition and fetch it's BPMNModel -  and do the same handling as you did with the BPMNModel you're currently looping (recursively).

Do bare in mind that it's possible to use expressions in the calledElement value of a CallActivity XML. Make sure you only use process-definitions with a fixed pointer to a process definition key in order for the mechanism described above, to work.