<?xml version="1.0" encoding="UTF-8"?>
<process key="task" name="task" xmlns="http://jbpm.org/4.4/jpdl"> <start name="start1" g="243,29,48,48"> <transition name="提交到任务A" to="任务A" g="-63,-11"/> </start> <end name="end1" g="243,393,48,48"/> <task name="任务A" g="224,115,92,52"> <assignment-handler class="com.tgb.node.task.handler.AssignTask"> </assignment-handler> <transition name="提交到任务B" to="任务B" g="-77,-11"/> </task> <task name="任务B" g="220,221,92,52"> <assignment-handler class="com.tgb.node.task.handler.AssignTaskB"> </assignment-handler> <transition name="提交到任务C" to="任务C" g="-83,-14"/> </task> <task name="任务C" g="224,308,92,52"> <transition name="通过" to="end1" g="-62,-25"/> </task></process> JAVA监听类以AssignTask为例,实现AssignmentHandler接口,即可在JPDL里应用监听
public class AssignTask implements AssignmentHandler {private static final long serialVersionUID = 1L;
@Override
public void assign(Assignable assignable, OpenExecution execution) throws Exception { //设置流程处理(受理)人 assignable.setAssignee("userA"); }}
流程操作代码与前一章相同部署流程
repositoryService.createDeployment().addResourceFromClasspath("com/tgb/node/task/task.jpdl.xml").deploy();
创建流程实例//流程部署KEY
ProcessInstance processInstance = executionService.startProcessInstanceByKey("task"); print("流程实例ID",processInstance.getId());获取当前节点
//流程实例ID String name = executionService.createProcessInstanceQuery().processInstanceId("task.290001").uniqueResult().findActiveActivityNames().toString(); print("当前节点名词:",name);获得任务列表
List<Task> tasks = taskService.findPersonalTasks("A"); print("任务数量",tasks.size()); print("任务名词",tasks.get(0).getActivityName()); print("任务ID",tasks.get(0).getId());完成任务
//任务ID taskService.completeTask("290002");