jbpm中的流程變數

來源:互聯網
上載者:User
package com.njupt.jbpm;import java.util.Map;import java.util.Set;import org.jbpm.api.Configuration;import org.jbpm.api.ExecutionService;import org.jbpm.api.ProcessEngine;import org.jbpm.api.ProcessInstance;import org.jbpm.api.TaskService;import org.junit.Test;public class ProcessVariableTest {private ProcessEngine processEngine = Configuration.getProcessEngine();private ExecutionService executionService = processEngine.getExecutionService();private TaskService taskService = processEngine.getTaskService();// 啟動流程執行個體@Testpublic void testStartProcessInstance() throws Exception {ProcessInstance pi = processEngine.getExecutionService().startProcessInstanceByKey("test");System.out.println("id=" + pi.getId() + ", processDefinitionId=" + pi.getProcessDefinitionId());}// 設定流程變數@Testpublic void testSetVariable() throws Exception {String executionId = "test.110001";// processEngine.getExecutionService().setVariable(executionId, "請假天數", new Integer(3));Form form = new Form();form.setId(1L); // 通過設定id讓其與資料庫中的id為1的記錄對應form.setTitle("張三要請假3天");processEngine.getExecutionService().setVariable(executionId, "form", form);// 通過Execution設定流程變數// executionService.setVariable(executionId, name, value); // 設定一個// executionService.setVariables(executionId, variablesMap); // 設定多個// 通過Task設定流程變數// taskService.setVariables(taskId, variablesMap); // 設定多個// 在啟動流程執行個體時,同時設定一些流程變數// executionService.startProcessInstanceByKey(key);// executionService.startProcessInstanceByKey(key, variablesMap);// 在完成任務時,同時設定一些流程變數// taskService.completeTask(taskId);// taskService.completeTask(taskId, variablesMap);}// 擷取流程變數@Testpublic void testGetVariable() throws Exception {String executionId = "test.110001";// Integer days = (Integer) processEngine.getExecutionService().getVariable(executionId, "請假天數");// System.out.println("請假天數 = " + days);Form form = (Form) processEngine.getExecutionService().getVariable(executionId, "form");System.out.println(form);// // 通過Execution擷取流程變數// Object value = executionService.getVariable(executionId, variableName); // 擷取一個// Set<String> namesSet = executionService.getVariableNames(executionId); // 擷取所有變數的名稱// Map<String, Object> map = executionService.getVariables(executionId, variableNamesSet); // 擷取多個// 通過Task擷取流程變數// taskService.getVariable(taskId, variableName);// taskService.getVariableNames(taskId);// taskService.getVariables(taskId, variableNames);}}

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.