Reputation: 779
I'm using Activiti 5.22.0.
I use Activiti Designer plugin in Eclispe to create a process.
Now I want to use a service task to get process diagram with current task higlighted and save it to database to show on web later.
I'm new to Activiti so I really don't know what I should to write in Java class of Service Task to get process diagram image.
Can you help me?
Thank you very much.
Upvotes: 0
Views: 1015
Reputation: 1254
Activiti comes with a Diagram generator in the org.activiti.image
module. use can use the DefaultDiagramGenerator
for your case. below is a sample code to get you started. please inject the required services.
/**
* Get Process instance diagram
*/
public InputStream getProcessDiagram(String processInstanceId) {
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
.processInstanceId(processInstanceId).singleResult();
// null check
if (processInstance != null) {
// get process model
BpmnModel model = repositoryService.getBpmnModel(processInstance.getProcessDefinitionId());
if (model != null && model.getLocationMap().size() > 0) {
ProcessDiagramGenerator generator = new DefaultProcessDiagramGenerator();
return generator.generateDiagram(model, ActivitiConstants.PROCESS_INSTANCE_IMAGE_FORMAT,
runtimeService.getActiveActivityIds(processInstanceId));
}
}
return null;
}
Upvotes: 2