工作流JBPM_day01:6-执行流程实例
执行流程
启动流程实例
查询任务列表
办理任务
向后执行一步
先部署流程定义在启动流程实例
Jbpm4_execution表表示正在执行的流程实例的的信息
查询个人任务列表
ProcessInstanceTest .java
import java.util.List; import org.jbpm.api.Configuration; import org.jbpm.api.ProcessEngine; import org.jbpm.api.ProcessInstance; import org.jbpm.api.task.Task; import org.junit.Test; public class ProcessInstanceTest { private ProcessEngine processEngine = Configuration.getProcessEngine(); //部署流程定义 @Test public void deplyProcessDefinition() { processEngine.getRepositoryService()// .createDeployment()// .addResourceFromClasspath("cn/itcast/b_processinstance/test.jpdl.xml")// .addResourceFromClasspath("cn/itcast/b_processinstance/test.png")// .deploy(); } // 启动流程实例 // jbpm4_execution @Test public void testStartProcessInstance() { ProcessInstance pi = processEngine.getExecutionService().startProcessInstanceByKey("helloworld"); System.out.println("流程实例启动成功:id=" + pi.getId()// + ", state=" + pi.getState()// 状态 + ", processDefinitionId=" + pi.getProcessDefinitionId());// 所使用的流程定义的Id } // 查询个人任务列表 @Test public void testFindMyPersonalTaskList() { String userId = "张三"; //查询 // List<Task> list = processEngine.getTaskService().findPersonalTasks(userId); //分页 List<Task> list = processEngine.getTaskService()// .createTaskQuery()// .assignee(userId)// .page(0, 100)// .list(); //显示 System.out.println("======= 【" + userId + "】的个人任务列表 ========"); for(Task task : list) { System.out.println("id=" + task.getId() + ", name=" + task.getName() + ", assignee=" + task.getCreateTime() + ", createTime=" + task.getCreateTime() + ", executionId=" + task.getExecutionId()); } } // 办理任务 @Test public void testCompleteTask() { String taskId = "140002"; processEngine.getTaskService().completeTask(taskId); } // 向后执行一步 @Test public void testNext() { String executionId = "helloworld.140001"; processEngine.getExecutionService().signalExecutionById(executionId); } }
Execution与ProcessInstance说明
最能让人感到快乐的事,莫过于经过一番努力后,所有东西正慢慢变成你想要的样子!