Hi
I want to know if there is any such API that gives the names of all states/service tasks for a given process definition. I tried to find it but no luck.
Thanks!
Hi
I want to know if there is any such API that gives the names of all states/service tasks for a given process definition. I tried to find it but no luck.
Thanks!
Hi @Urvashi_Prasad,
there is no API to get all activity names of a process definition. But you can easily do it by yourself. Get the process definition (e.g. via RepositoryService) and use the BPMN Model API to iterate over all activities.
Does this help you?
Best regards,
Philipp
Thanks @Philipp_Ossler. The API was indeed helpful and easier than parsing the xml.
Here’s my function is anyone else needs it:
public List<String> getAllStatesFromBpmn(String xmlContent){
List<String> result=new ArrayList<>();
InputStream stream = new ByteArrayInputStream(xmlContent.getBytes(StandardCharsets.UTF_8));
BpmnModelInstance modelInstance = org.camunda.bpm.model.bpmn.Bpmn.readModelFromStream(stream);
// find all elements of the type service task
ModelElementType taskType = modelInstance.getModel().getType(ServiceTask.class);
Collection<ModelElementInstance> taskInstances = modelInstance.getModelElementsByType(taskType);
for(ModelElementInstance oneServiceTask:taskInstances){
result.add(oneServiceTask.getAttributeValue("name"));
}
return result;
}