Activiti gets a flowchart instance

  • 2020-04-01 03:24:12
  • OfStack

In this paper, an example is given to illustrate the method of obtaining flow chart for activiti. The specific operation steps are as follows:

1. The release process code is as follows:


repositoryService.createDeployment() 
 .name("expense-process.bar") 
 .addClasspathResource("org/activiti/expenseProcess.bpmn20.xml") 
 .addClasspathResource("org/activiti/expenseProcess.png") 
 .deploy(); 

2. Get the flowchart code according to the key as follows:


ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery() 
                            .processDefinitionKey("expense") 
                            .singleResult(); 
 
String diagramResourceName = processDefinition.getDiagramResourceName(); 
InputStream imageStream = repositoryService.getResourceAsStream(processDefinition.getDeploymentId(), diagramResourceName); 
 

3. If the flowchart is not generated when the process is published, the following configuration is needed:


<property name="createDiagramOnDeploy" value="false" /> 

Related articles: