jbpm系列之八--fork节点

在实际的流程操作中,我们会遇到一些这样的情况,ABC必须同时完成某项事情时,才能进行下一步的操作。这时候我们就用到了fork和join节点。fork即为分,join即为合。jpdl图为如下所示:

jbpm系列之八--fork节点_第1张图片
我们部署完流程后,当拿当前节点的时候我们会同时拿到三个节点,即ABC,当ABC各自完成他们的task任务时。流程就会走到合并节点。这就是简单的fork和join节点的简单特性。
附属测试代码:
<?xml version="1.0" encoding="UTF-8"?>

<process key="fork" name="fork" xmlns="http://jbpm.org/4.4/jpdl">
   <start g="56,154,48,48" name="start1">
      <transition g="-63,-25" name="to fork1" to="fork1"/>
   </start>
   <end g="623,278,48,48" name="end1"/>
   <fork g="191,158,48,48" name="fork1">
      <transition g="-36,-25" name="to A" to="A"/>
      <transition g="-34,-25" name="to B" to="B"/>
      <transition g="-35,-25" name="to C" to="C"/>
   </fork>
   <join g="509,168,48,48" name="join1">
      <transition g="-25,-26" name="to task1" to="合并"/>
   </join>
   <task assignee="userA" g="362,54,92,52" name="A">
      <transition g="-61,-25" name="to join1" to="join1"/>
   </task>
   <task assignee="userB" g="360,160,92,52" name="B">
      <transition g="-61,-25" name="to join1" to="join1"/>
   </task>
   <task assignee="userC" g="369,270,92,52" name="C">
      <transition g="-61,-25" name="to join1" to="join1"/>
   </task>
   <task assignee="userM" g="607,167,92,52" name="合并">
      <transition g="-54,-12" name="to end1" to="end1"/>
   </task>
</process>

package com.tgb.node.fork;

import java.util.List;

import org.jbpm.api.ProcessInstance;
import org.jbpm.api.task.Task;

import com.tgb.video.JbpmTestCase;
import com.tgb.video.JbpmUtil;

public class TestFork extends JbpmTestCase implements JbpmUtil {

	@Override
	public void deploy() {
		super.startUp();
		repositoryService.createDeployment().addResourceFromClasspath("com/tgb/node/fork/fork.jpdl.xml").deploy();
		
	}

	@Override
	public void createInstance() {
		super.startUp();
		ProcessInstance processInstance = executionService.startProcessInstanceByKey("fork");
		print("流程实例ID",processInstance.getId());
	}

	@Override
	public void getCurrectActivity() {
		super.startUp();
		String name = executionService.createProcessInstanceQuery().processInstanceId("fork.10001").uniqueResult().findActiveActivityNames().toString();
		print("当前节点",name);
	}

	@Override
	public void getTask() {
		super.startUp();
		List<Task> tasks = taskService.findPersonalTasks("userC");
		print("任务节点名称",tasks.get(0).getActivityName());
		print("任务节点ID",tasks.get(0).getId());
	}

	@Override
	public void completeTask() {
		super.startUp();
		taskService.completeTask("10007");
	}

}


你可能感兴趣的:(jbpm系列之八--fork节点)