cancel
Showing results for 
Search instead for 
Did you mean: 

Public API for process instance diagram

arkadi
Champ in-the-making
Champ in-the-making
I checked activiti-rest component to borrow some code to create process diagram with active tasks highlighted. Then I fond that a little bit of non-official API is required for that.

public InputStream diagram() {
    // from activiti-rest
    ProcessDefinitionEntity pde = (ProcessDefinitionEntity) ((RepositoryServiceImpl) engine.getRepositoryService()).getDeployedProcessDefinition(task.getProcessDefinitionId());
    // the following doesn't work
    //ProcessDefinitionEntity pde = (ProcessDefinitionEntity) engine.getRepositoryService().createProcessDefinitionQuery().processDefinitionId(task.getProcessDefinitionId()).singleResult();
    if (pde == null || !pde.isGraphicalNotationDefined()) {
        log.warn("No diagram defined for process definition id " + task.getProcessDefinitionId());
        return null;
    }
    return ProcessDiagramGenerator.generateDiagram(pde, "png",
            engine.getRuntimeService().getActiveActivityIds(task.getProcessInstanceId()));
}
Is there a better way to generate the diagram or should I raise an issue to track the required enhancement?
1 REPLY 1

jbarrez
Star Contributor
Star Contributor
That's indeed the current way to do it. We will make it public in the future.