JBPM4.4---ForEach测试Dome

通过ForEach生成的是并发流程

流程定义XML:


<?xml version="1.0" encoding="UTF-8"?>

<process key="FOR_EACH" name="forEach" xmlns="http://jbpm.org/4.4/jpdl">
	<start g="57,196,48,48" name="start1">
		<transition g="-72,-22" name="to foreach1" to="foreach1" />
	</start>

	<foreach g="157,194,48,48" name="foreach1" var="deptId" in="#{deptIds}">
		<transition g="-45,-22" name="" to="主管" />
	</foreach>

	<task g="268,195,92,52" name="主管" assignee="zg#{deptId}">
		<transition g="-52,-22" name="" to="经理" />
	</task>

	<task g="393,198,92,52" name="经理" assignee="jl#{deptId}">
		<transition g="-49,-22" name="to join1" to="join1" />
	</task>


	<join g="562,197,48,48" name="join1" multiplicity="#{deptIds.size()}"><!-- 根据deptIds的长度,进行合并,必须  -->
		<transition g="-45,-22" name="" to="总监" />
	</join>

	<task g="670,196,92,52" name="总监" assignee="zj">
		<transition g="-50,-22" name="" to="end1" />
	</task>

	<end g="808,193,48,48" name="end1" />


</process>

测试类Java:

public class FlowServiceTest {
	ProcessEngine processEngine;
	String jdplPath;
	String pdKey;

    @Before
    public void setUp() throws Exception {
    	processEngine = Configuration.getProcessEngine();// 获取流程引擎
    	jdplPath = "jpdl/forEach.jpdl.xml";
    	pdKey = "FOR_EACH";
    }
    
	/**
	 * @description 发布流程 no.1
	 */
    @Test
	public void deploy() {
		RepositoryService repositoryService = processEngine.getRepositoryService();
		repositoryService.createDeployment().addResourceFromClasspath(jdplPath).deploy();
	}

    /**
	 * @description 提交申请 no.2
	 */
    @Test
    public void testApply() {
        Map<String, Object> values = new HashMap<String, Object>();
        List<Integer> deptIds = new ArrayList<Integer>();
        deptIds.add(1);
        deptIds.add(2);

        values.put("deptIds", deptIds);
        values.put("deptIdsLenght", deptIds.size());
        
       
        ExecutionService executionService = processEngine.getExecutionService();
        executionService.startProcessInstanceByKey(pdKey, values);
    }
    
    /**
   	 * @description 完成任务 no.3
   	 */
    @Test
    public void takeTask() {
       String taskId = "30001";	//直接接查数据库任务表获取
    
       TaskService taskService = processEngine.getTaskService();
       taskService.completeTask(taskId);
    }

}


等待合并的join状态

jbpm.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>

<jbpm-configuration>

  <import resource="jbpm.default.cfg.xml" />
  <import resource="jbpm.businesscalendar.cfg.xml" />
  <import resource="jbpm.tx.hibernate.cfg.xml" />
  <import resource="jbpm.jpdl.cfg.xml" />
  <import resource="jbpm.bpmn.cfg.xml" />
  <import resource="jbpm.identity.cfg.xml" />
  
 
  <!-- 这里设置成spring的配置文件,工作流引擎会使用默认的spring配置文件applicationContext.xml 
  <import resource="jbpm.tx.spring.cfg.xml" />-->
 

  <process-engine-context>
  	<!-- 如果需要添加spring配置文件,可在这里添加
    <string name="spring.cfg" value="applicationContext.xml" /> -->
  </process-engine-context>

</jbpm-configuration>

jbpm.hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE hibernate-configuration PUBLIC
          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
  <session-factory>
     <property name="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</property>
 
     <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/jbpm</property>
      <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
     <property name="hibernate.connection.username">root</property>
     <property name="hibernate.connection.password">123456</property>
     <property name="hibernate.format_sql">true</property>
      <property name="hibernate.show_sql">true</property>
     
     
     <mapping resource="jbpm.repository.hbm.xml" />
     <mapping resource="jbpm.execution.hbm.xml" />
     <mapping resource="jbpm.history.hbm.xml" />
     <mapping resource="jbpm.task.hbm.xml" />
     <mapping resource="jbpm.identity.hbm.xml" />
     
  </session-factory>
</hibernate-configuration>


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值