package com.zcc.activiti02;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngineConfiguration;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.ProcessDefinition;
import org.activiti.engine.repository.ProcessDefinitionQuery;
import java.util.List;
/**
* 查询流程定义的相关信息
*/
public class QueryProcessDefinition {
public static void main(String[] args) {
//创建流程引擎配置类
ProcessEngineConfiguration processEngineConfiguration=
ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
//流程引擎对象
ProcessEngine processEngine = processEngineConfiguration.buildProcessEngine();
RepositoryService repositoryService = processEngine.getRepositoryService();
//获取查询器
ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery();
List<ProcessDefinition> list = processDefinitionQuery.processDefinitionKey("myProcess")
.orderByProcessDefinitionVersion().desc().list();
for (int i=0;i<list.size();i++){
ProcessDefinition processDefinition = list.get(i);
System.out.println("流程定义id:" + processDefinition.getId());
System.out.println("流程定义名称:" + processDefinition.getName());
System.out.println("流程定义key:" + processDefinition.getKey());
System.out.println("流程定义版本:" + processDefinition.getVersion());
System.out.println("流程部署id:" + processDefinition.getDeploymentId());
}
}
}