package com.clj;
import java.util.List;
import org.jbpm.api.Configuration;
import org.jbpm.api.NewDeployment;
import org.jbpm.api.ProcessDefinition;
import org.jbpm.api.ProcessDefinitionQuery;
import org.jbpm.api.ProcessEngine;
import org.jbpm.api.RepositoryService;
import org.junit.Test;
public class HellowTest {
ProcessEngine processEngine;
public HellowTest() {
// 流程引擎初始化
processEngine = Configuration.getProcessEngine();
}
@Test
public void testDeploy() {
RepositoryService repositoryService = processEngine
.getRepositoryService();
//1.流程发布
//1.1创建一个发布包
NewDeployment newDeployment1 = repositoryService.createDeployment();
//1.2指定流程定义配置文件
NewDeployment newDeployment2 = newDeployment1
.addResourceFromClasspath("HellowWord.jpdl.xml");
//1.3 发布流程定义
String deploymentId=newDeployment2.deploy();
System.out.println("流程发布成功:"+deploymentId);
//2.查询发布的流程
//2.1创建一个流程搜索类
ProcessDefinitionQuery processDefinitionQuery=repositoryService.createProcessDefinitionQuery();
//2.2搜索流程定义
List processDefitionList=processDefinitionQuery.list();
//2.3循环输出流程定义ID(看看和流程定义文件:jpdl.xml的name哦)
for(ProcessDefinition pd : processDefitionList){
System.out.println("流程ID:"+pd.getId());
}
//3.删除流程
repositoryService.deleteDeploymentCascade(deploymentId);
System.out.println("成功删除流程!");
}
}