package com.itheima.activiti;
import org.activiti.engine.ProcessEngine;
import org.activiti.engine.ProcessEngines;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.repository.Deployment;
import java.io.InputStream;
import java.util.zip.ZipInputStream;
/**
* 流程定义的部署
* activiti表有哪些?
* act_re_deployment 部署信息
act_re_procdef 流程定义的一些信息
act_ge_bytearray 流程定义的bpmn文件及png文件
*/
public class ActivitiDeployment {
public static void main(String[] args) {
//1.创建ProcessEngine对象
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
//2.得到RepositoryService实例
RepositoryService repositoryService = processEngine.getRepositoryService();
//3.进行部署
// Deployment deployment = repositoryService.createDeployment()
// .addClasspathResource("diagram/holiday.bpmn") // bpmn文件
// .addClasspathResource("diagram/holiday.png") // 图片文件
// .name("请假申请单流程")
// .deploy();
//3.转化出ZipInputStream流对象
InputStream is = ActivitiDeployment.class.getClassLoader().getResourceAsStream("diagram/holiday.zip");
//将 inputstream流转化为ZipInputStream流
ZipInputStream zipInputStream = new ZipInputStream(is);
Deployment deployment = repositoryService.createDeployment()
.addZipInputStream(zipInputStream)
.name("请假申请单流程")
.deploy();
System.out.println("流程部署id:" + deployment.getId());
System.out.println("流程部署名称:" + deployment.getName());
}
}