activiti工作流引擎(4)绘图API

activiti提供了比较完善的画图API

(1) 可在deploy的时候,显式导入流程定义图片

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

(2) 通过流程引擎自动创建流程定义图

<!-- 流程定义的xml中的流程图自动生成配置 -->
<property name="createDiagramOnDeploy" value="true" />
// 代码中部署流程的时候不提供图片路径
repositoryService.createDeployment()
  .name("expense-process.bar")
  .addClasspathResource("org/activiti/expenseProcess.bpmn20.xml")
  .deploy();

(3) 可获取某一流程的流程定义图片

ProcessDefinition processDefinition = 
                repositoryService.createProcessDefinitionQuery()
                                 .processDefinitionKey("expense")
                                 .singleResult();

String diagramResourceName = processDefinition.getDiagramResourceName();
InputStream imageStream =
        repositoryService.getResourceAsStream(
                processDefinition.getDeploymentId(), 
                diagramResourceName
        );

(4) 可获取某一流程实例的流程图片,可高亮显示当前处理节点

// 通过REST API
GET /process-instance/{processInstanceId}/diagram
// 通过Java API
ProcessDiagramGenerator.generateDiagram(
        pde, 
        "png", 
        getRuntimeService().getActiveActivityIds(processInstanceId)
);

你可能感兴趣的:(activiti工作流引擎(4)绘图API)