I have to expose the Activiti API process using a service of my project.
My requirement is as under:
I want to know the details about Tasks in Activiti Process Definition, using Java, before running the Process, ie. before creating the Activiti ProcessInstance. Is there any way to achieve this?
I have gone through the Java docs and User guide of Activiti API lots of times but couldn't find a way.
Any help will be appreciated, Thanks.
You can use the getBpmnModel(processDefinitionId) method available in the RepositoryService interface.
The result is a Pojo that you can use in o order to introspect the process. The initial pojo represents the model, which can have multiple Processes (but usually only one). From a given Process, you can find all tasks using the findFlowElementsOfType(Class type).
For instance, this snippet should get you a list of UserTasks in a process (not tested but should give you an idea of what is needed):
BpmnModel model = processEngine.getRepositoryService().getBpmnModel(someProcessId);
List<Process> processes = model.getProcesses();
List<UserTask> userTasks = new ArrayList<>();
for( Process p : processes ) {
userTasks.addAll( p.findFlowElementsOfType(UserTask.class))
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With