一、Activiti介绍与搭建开发环境
二、运行官方例子
三、编写第一个Activiti程序
3.1 流程部署
代码
@Test
public void test2 ( ) {
ProcessEngine engine = ProcessEngines . getDefaultProcessEngine ( ) ;
RepositoryService repositoryService = engine. getRepositoryService ( ) ;
repositoryService. createDeployment ( ) . addClasspathResource ( "flow/test1.bpmn20.xml" ) . deploy ( ) ;
}
涉及到的表
act_ge_bytearray
act_re_deployment
act_re_procdef
3.2 流程发起
代码
@Test
public void test3 ( ) {
ProcessEngine engine = ProcessEngines . getDefaultProcessEngine ( ) ;
RuntimeService runtimeService = engine. getRuntimeService ( ) ;
ProcessInstance instance = runtimeService. startProcessInstanceByKey ( "myTest1" ) ;
}
涉及到的表
act_hi_actinst
act_hi_procinst
act_hi_taskinst
act_ru_execution
act_ru_task
3.3 进行查询任务且进行审批
@Test
public void test4 ( ) {
ProcessEngine engine = ProcessEngines . getDefaultProcessEngine ( ) ;
RuntimeService runtimeService = engine. getRuntimeService ( ) ;
ProcessInstance instance = runtimeService. startProcessInstanceByKey ( "myTest1" ) ;
TaskService taskService = engine. getTaskService ( ) ;
Task task = taskService. createTaskQuery ( ) . processInstanceId ( instance. getId ( ) ) . singleResult ( ) ;
System . out. println ( "当前流程节点:" + task. getName ( ) ) ;
taskService. complete ( task. getId ( ) ) ;
task = taskService. createTaskQuery ( ) . processInstanceId ( instance. getId ( ) ) . singleResult ( ) ;
System . out. println ( "当前流程节点:" + task. getName ( ) ) ;
taskService. complete ( task. getId ( ) ) ;
task = taskService. createTaskQuery ( ) . processInstanceId ( instance. getId ( ) ) . singleResult ( ) ;
System . out. println ( "当前流程节点:" + task) ;
engine. close ( ) ;
System . exit ( 0 ) ;
}