I am currently trying to get the diagram of the workflow.
current environment: Spring boot with Kotlin.
val process: ProcessDefinition? =
myService?.getRepositoryService()?.createProcessDefinitionQuery()?.processDefinitionKey(“submissionProcess”)?.latestVersion()
?.singleResult()
val bpmnModel: BpmnModel? =myService?.getRepositoryService()?.getBpmnModel(process?.id)
val processDiagramGenerator: ProcessDiagramGenerator = DefaultProcessDiagramGenerator()
val inputSt = processDiagramGenerator.generateJpgDiagram(bpmnModel)// here is where the exception happens
Following is a picture from where the exception first starts
Hello thank you for the fast reply.
I used the BpmnAutoLayout class to solve the problem.
Below is the code for anyone who might face the same problem in the future.
Basically this code retrieves the workflow diagram image and then return it as an array of Bytes.
Note: Since I am using spring boot, I had to add the following Maven dependency in order to be able to import the BpmnAutoLayout class: <dependency> <groupId>org.flowable</groupId> <artifactId>flowable-bpmn-layout</artifactId> <version>6.5.0</version> </dependency>
val process: ProcessDefinition? =
myService?.getRepositoryService()?.createProcessDefinitionQuery()?.processDefinitionKey(pid)?.latestVersion()
?.singleResult()
val bpmnModel: BpmnModel? = myService?.getRepositoryService()?.getBpmnModel(process?.id)
val bpmnLayout: BpmnAutoLayout = BpmnAutoLayout(bpmnModel)
bpmnLayout.taskHeight = 120
bpmnLayout.taskWidth = 120
bpmnLayout.execute()
val processDiagramGenerator: ProcessDiagramGenerator = DefaultProcessDiagramGenerator()
val inputSt = processDiagramGenerator.generateJpgDiagram(bpmnModel)
val bos = ByteArrayOutputStream()
org.apache.commons.io.IOUtils.copy(inputSt, bos)
return bos.toByteArray()