1.启动流程实例

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

  

2.设置流程变量

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

//设置流程变量
@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) 所有设置流程变量方法

用到变量的类型:

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>();

  具体方法:

// 根据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) 一个获取流程变量实例

//获取流程变量
@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) 所有获取流程变量方法

用到变量的类型:

String executionId = "";
String taskId = "";
String variableName = "";
Set<String> variableNames = new HashSet<String>();

  具体方法:

// 根据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. 工作流学习——Activiti流程变量五步曲 (zhuan)

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

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

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

  3. Lua的五种变量类型、局部变量、全局变量、lua运算符、流程控制if语句_学习笔记02

    Lua的五种变量类型.局部变量.全局变量 .lua运算符 .流程控制if语句 Lua代码的注释方式: --当行注释 --[[    多行注释    ]]-- Lua的5种变量类型: 1.null 表示 ...

  4. JBPM学习(四):执行流程实例

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

  5. JBPM工作流(六)——流程变量

    1.启动流程实例 ? 1 2 3 4 5 6 7 // 启动流程实例 @Test public void startProcessInstance() {     // 使用指定key的最新版本的流程 ...

  6. (C/C++学习笔记) 五. 常变量(只读变量)和宏

    五. 常变量(只读变量)和宏 ● 常变量 常变量 #include <iostream.h>                    //预处理文件 int main() { const d ...

  7. JBPM学习(四):运行流程实例

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

  8. Activiti流程变量五步曲 ——by fightingKing

    http://blog.csdn.net/zwk626542417/article/details/46648139 一.前言 上一篇文章我们将流程实例的启动与查询,任务的办理查询都进行了介绍,我们这 ...

  9. Flowable实战(五)表单和流程变量

    一.流程变量   流程实例按步骤执行时,需要保存并使用一些数据,在Flowable中,这些数据称为变量(variable).   流程实例可以持有变量,称作流程变量(process variables ...

随机推荐

  1. [CC150] 八皇后问题

    Write an algorithm to print all ways of arranging eight queens on an 8*8 chess board so that none of ...

  2. HDU1395+快速幂

    #include<stdio.h> int fast_pow( int a,int b,int mod ){ ; ){ == ){ res = res*a%mod; } a = a*a%m ...

  3. Tomcat HTTP/1.1 Connector 参数整理

    HTTP/1.1 Connector 概述 Coyote HTTP/1.1 Connector元素是一个支持HTTP/1.1协议的Connector组件.它使Catalina除了能够执行servlet ...

  4. 李洪强实现横向滚动的View<一>

    今天做一个小的view的效果(纯代码),虽然这个view做起来 并不是很难,但是他是为后面我要实现的功能做一个铺垫. 01 创建CFTyreView,继承自UIView 02 来到.m文件. 2.1 ...

  5. yii 验证器和验证码

    http://www.yiiframework.com/doc/api/1.1/CCaptcha http://www.cnblogs.com/analyzer/articles/1673015.ht ...

  6. XSD标准架构-----<xsd:element> 元素详解

    声明一个元素.     <element abstract = Boolean : false block = (#all | List of (extension | restriction ...

  7. Hibernate java.lang.NoSuchFieldError: INSTANCE

    在使用hibernate3.6.2是我遇到了一个有趣的错误java.lang.NoSuchFieldError: INSTANCEat org.hibernate.type.BasicTypeRegi ...

  8. MySQL sql_slave_skip_counter

    因为mysql的主从复制是逻辑复制,所以slave在apply relay log的过程中,经常会遇到错误,而参数sql_slave_skip_counter可以设置跳过多少个event,让slave ...

  9. Apache FileUpload实现文件上传

    今天,我来介绍一个Apache FileUpload这个插件的使用. 首先,到官网下载相关jar包点击这里下载,这里提供是v1.2. 1.在项目中导入相关jar包commons-fileupload- ...

  10. Embedding Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office

    Download the sample code This visual how-to article presents a solution that creates a Word 2007 doc ...