首先还是先获取连接
private ProcessEngine processEngine;
@Before
public void initProcessEngine(){
processEngine = ProcessEngines.getDefaultProcessEngine();
}
流程定义(流程图的设计)
流程部署涉及到的几个动作和表
流程部署表 act_re_deployment
流程定义表 act_re_procdef
流程资源表 act_ge_bytearray
@Test
public void testProcessDeployment(){
InputStream inputStream = this.getClass()
.getClassLoader()
.getResourceAsStream("diagram/leave.zip");
ZipInputStream zipInputStream = new ZipInputStream(inputStream);
Deployment deployment = processEngine.getRepositoryService()
.createDeployment()
.addZipInputStream(zipInputStream)
.name("请假流程")
.deploy();
System.out.println("流程部署ID:"+deployment.getId());
System.out.println("流程部署名称:"+deployment.getName());
}
流程图
leave.bpmn代码
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
<process id="leave" name="leaveProcess" isExecutable="true">
<startEvent id="startevent1" name="Start"></startEvent>
<userTask id="usertask1" name="请假申请" activiti:assignee="张三"></userTask>
<userTask id="usertask2" name="领导审批" activiti:assignee="李四"></userTask>
<endEvent id="endevent1" name="End">