cancel
Showing results for 
Search instead for 
Did you mean: 

Access to 'assembled' process definitions

mackking-ns
Champ in-the-making
Champ in-the-making
Greetings,

We are currently working on building up a sort of 'wizard' style application that leverages Activiti under the covers to define the steps in the wizard. As a result, we have a number of User Tasks chained together in our Process Definitions, many/all of which are to be completed by a single user (often in quick succession).

START -> User Task 1 -> User Task 2 -> User Task 3 -> Service Task 1 -> Service Task 2 -> END

While we've figured out the steps as far as walking through the process instance(s) and populating/completing the user tasks, we were hoping to be able to retrieve and display the 'steps'  (User Tasks) metadata (name) of the process out of the Process Definition to display alongside the data collection elements rather than having to define them in some parallel location.

We have found the RepositoryService.getBpmnModel() API for retrieving a process's definition but our issue/concern with this method is that the structure (order) of the Processes (via BpmnModel.getMainProcess().getFlowElements()) are in source file order and not reflective of the actual process definition/structure.

Is there an API available whereby we can query a specific Process Definition and retrieve the list/collection/tree of User Tasks in their order as defined within the process? If not solely the User Tasks, is there an API that will return the full Process Definition in it's assembled list/tree structure which we can then walk through ourselves to locate the User Tasks?

Thanks in advance,
Mackenzie
5 REPLIES 5

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mackenzie,

Yes there is. You have to find start activity (In your case it is none start event). After that you can follow sequence flows to get to the right nodes.

Regards
Martin

Hi Martin,

So I have to effectively walk the contents of BpmnModel and build up the representation by hand?

ie:
<java>

BpmnModel bpmn = repositoryService.getBpmnModel(…);

FlowElements start = bpmn.getMainProcess().getFlowElement("startElementId");

List<SequenceFlows> outgoing = start.getOutgoingFlows();

for (SequenceFlows out : outgoing) {
  String nextStep = out.getTargetRef();
   bpmn.getMainProcess().getFlowElement(nextStep);
  // repeat, walking my way through the model ??
}
</java>

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mackenzie,

Another possibility is to search by type.

Regards
Martin

You mean via List &lt;FlowElementType&gt; Process.findFlowElementsOfType(FlowElementType.class) ??

This seems to return the list of UserTasks in XML file source order. Is there no way to retrieve them in logical/process order?

jbarrez
Star Contributor
Star Contributor
No, there isn't.  Order is not fixed, as you can have cycles in the process graph.