1.启动流程实例

1
2
3
4
5
6
7
// 启动流程实例
@Test
public void startProcessInstance() {
    // 使用指定key的最新版本的流程定义启动流程实例
    ProcessInstance pi = processEngine.getExecutionService().startProcessInstanceByKey("test");
    System.out.println("processInstanceId=" + pi.getId());
}

  

2.设置流程变量

a) 一个设置流程变量实例

1
2
3
4
5
6
7
8
9
10
//设置流程变量
@Test
public void setVariable() {
    String executionId = "test.140001";
    String name = "请假天数";
    Integer value = 3;
 
    //将name为"请假天数",value=3的流程变量设置到executionId为test.140001的执行对象上
    processEngine.getExecutionService().setVariable(executionId, name, value);
}

b) 所有设置流程变量方法

用到变量的类型:

1
2
3
4
5
6
7
8
Object value = "";
String executionId = "";
String taskId = "";
String name = "";
String processDefinitionKey = "";
String variableName = "";
Set<String> variableNames = new HashSet<String>();
Map<String, Object> variablesMap = new HashMap<String, Object>();

  具体方法:

1
2
3
4
5
6
7
8
9
10
11
12
// 根据Execution设置一个流程变量
processEngine.getExecutionService().setVariable(executionId, name, value);
// 根据Execution设置多个流程变量(需要先把流程变量放到一个Map中)
processEngine.getExecutionService().setVariables(executionId, variablesMap);
 
// 根据Task设置多个流程变量(需要先把流程变量放到一个Map中,通过Task方法,它会先找到它所属的Execution然后设置流程变量)
processEngine.getTaskService().setVariables(taskId, variablesMap);
 
// 使用指定key的最新版本的流程定义启动流程实例,并设置一些流程变量
processEngine.getExecutionService().startProcessInstanceByKey(processDefinitionKey, variablesMap);
// 办理完指定的任务,并设置一些流程变量
processEngine.getTaskService().completeTask(taskId, variablesMap);

  

3.获取流程变量

a) 一个获取流程变量实例

1
2
3
4
5
6
7
8
9
10
//获取流程变量
@Test
public void getVariable() {
    String executionId = "test.140001";
    String variableName = "请假天数";
 
    //从executionId为test.140001的执行对象上取出流程变量名为"请假天数"的流程变量的value
    Integer value = (Integer) processEngine.getExecutionService().getVariable(executionId, variableName);
    System.out.println(variableName + " = " + value);
}

  

b) 所有获取流程变量方法

用到变量的类型:

1
2
3
4
String executionId = "";
String taskId = "";
String variableName = "";
Set<String> variableNames = new HashSet<String>();

  具体方法:

1
2
3
4
5
6
7
8
9
10
11
12
13
// 根据Execution获取指定名称的一个流程变量
processEngine.getExecutionService().getVariable(executionId, variableName);
// 根据Execution获取所有流程变量的名称
processEngine.getExecutionService().getVariableNames(executionId);
// 根据Execution获取指定名称的所有流程变量
processEngine.getExecutionService().getVariables(executionId, variableNames);
 
// 根据Task获取指定名称的一个流程变量
processEngine.getTaskService().getVariable(taskId, variableName);
// 根据Task获取所有流程变量的名称
processEngine.getTaskService().getVariableNames(taskId);
// 根据Task获取指定名称的所有流程变量
processEngine.getTaskService().getVariables(taskId, variableNames);

  

4.流程变量所支持的值的类型(jBPM User Guide,7.2. Variable types)

jBPM supports following Java types as process variables:

  • java.lang.String
  • java.lang.Long
  • java.lang.Double
  • java.util.Date
  • java.lang.Boolean
  • java.lang.Character
  • java.lang.Byte
  • java.lang.Short
  • java.lang.Integer
  • java.lang.Float
  • byte[] (byte array)
  • char[] (char array)
  • hibernate entity with a long id
  • hibernate entity with a string id
  • serializable

For persistence of these variable, the type of the variable is checked in the order of this list. The first match will determine how the variable is stored.

JBPM工作流(六)——流程变量的更多相关文章

  1. 工作流Activiti5流程变量 任务变量 setVariables 跟 setVariablesLocal区别

    工作流Activiti5流程变量 任务变量 setVariables 和 setVariablesLocal区别 因为网上的资料比较少.结合源码把相关API写下来. 设置流程级别变量: runtime ...

  2. 工作流JBPM_day01:7-使用流程变量

    工作流JBPM_day01:7-使用流程变量 工作流就像流水线 对应数据库中的一张表 ProcessVariableTest.Java import java.util.List; import or ...

  3. 工作流学习——Activiti流程变量五步曲 (zhuan)

    http://blog.csdn.net/zwk626542417/article/details/46648139 ***************************************** ...

  4. JBPM学习(五):流程变量

    1.启动流程实例 // 启动流程实例 @Test public void startProcessInstance() { // 使用指定key的最新版本的流程定义启动流程实例 ProcessInst ...

  5. JBPM工作流(五)——执行流程实例

    概念: ProcessInstance,流程实例:代表流程定义的一次执行.如:张三昨天按请假流程请了一次假.一个流程实例包括了所有运行阶段,其中最典型的属性就是跟踪当前节点的指针,如下图. Execu ...

  6. 工作流学习——Activiti流程变量五步曲

    一.前言 上一篇文章我们将流程实例的启动与查询,任务的办理查询都进行了介绍,我们这篇文章来介绍activiti中的流程变量. 二.正文 流程变量与我们寻常理解的变量是一样的,仅仅只是是用在了我们act ...

  7. Activiti工作流(三)——流程变量

    流程变量可以是流程中一系列参数,比如办理人(Assignee),消息(message)等.这些流程变量使得activiti能够应用于更为复杂的业务中,使得流程变得更加灵活可控. 场景(一) 图一:没有 ...

  8. JBPM工作流

    一.开发环境的搭建 1.下载Jbpm4.4 1.1下载地址: https://sourceforge.net/projects/jbpm/files/jBPM%204/jbpm-4.4/ 1.2解压后 ...

  9. 【Java EE 学习 67 下】【OA项目练习】【SSH整合JBPM工作流】【JBPM项目实战】

    一.SSH整合JBPM JBPM基础见http://www.cnblogs.com/kuangdaoyizhimei/p/4981551.html 现在将要实现SSH和JBPM的整合. 1.添加jar ...

随机推荐

  1. JS中的算法与数据结构——排序(Sort)

    排序算法(Sort) 引言 我们平时对计算机中存储的数据执行的两种最常见的操作就是排序和查找,对于计算机的排序和查找的研究,自计算机诞生以来就没有停止过.如今又是大数据,云计算的时代,对数据的排序和查 ...

  2. mysql [索引优化] -- in or替换为union all

    一个文章库,里面有两个表:category和article.category里面有10条分类数据.article里面有 20万条.article里面有一个"article_category& ...

  3. wget整站抓取、网站抓取功能;下载整个网站;下载网站到本地

    wget -r   -p -np -k -E  http://www.xxx.com 抓取整站 wget -l 1 -p -np -k       http://www.xxx.com 抓取第一级 - ...

  4. Catch a Memory Access Violation in C++

    From:  https://stackoverflow.com/questions/16612444/catch-a-memory-access-violation-in-c In C++, is ...

  5. CVPR论文《100+ Times Faster Weighted Median Filter (WMF)》的实现和解析(附源代码)。

    四年前第一次看到<100+ Times FasterWeighted Median Filter (WMF)>一文时,因为他附带了源代码,而且还是CVPR论文,因此,当时也对代码进行了一定 ...

  6. ionic1页面切换动画卡顿优化

    https://github.com/shprink/ionic-native-transitions https://www.npmjs.com/package/ionic-native-trans ...

  7. R语言中的回归诊断-- car包

    如何判断我们的线性回归模型是正确的? 1.回归诊断的基本方法opar<-par(no.readOnly=TRUE) fit <- lm(weight ~ height, data = wo ...

  8. iOS 内购讲解

    一.总说内购的内容 1.协议.税务和银行业务 信息填写 2.内购商品的添加 3.添加沙盒测试账号 4.内购代码的具体实现 5.内购的注意事项 二.协议.税务和银行业务 信息填写 2.1.协议.税务和银 ...

  9. centos7磁盘挂载及取消

    磁盘挂载查看已经挂载磁盘数 cat /proc/scsi/scsi | grep HostHost: scsi1 Channel: 00 Id: 00 Lun: 00Host: scsi2 Chann ...

  10. k8s 组件介绍__单Master集群部署

    参考链接:https://github.com/opsnull/follow-me-install-kubernetes-cluster kubernetes 概述 1.kubernetes 是什么 ...