Search in sources :

Example 91 with RuntimeService

use of org.activiti.engine.RuntimeService in project tutorials-java by Artister.

the class RuntimeServiceTests method testVariables.

/**
 * 测试修改参数
 */
@Deployment(resources = { "my-process.bpmn20.xml" })
@Test
public void testVariables() {
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variables = Maps.newHashMap();
    variables.put("key1", "value1");
    variables.put("key2", "value2");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process", variables);
    logger.info("processInstance = {}", processInstance);
    // 添加及修改变量
    runtimeService.setVariable(processInstance.getId(), "key1", "change1");
    runtimeService.setVariable(processInstance.getId(), "key3", "value3");
    Map<String, Object> map = runtimeService.getVariables(processInstance.getId());
    logger.info("map = {}", map);
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Example 92 with RuntimeService

use of org.activiti.engine.RuntimeService in project tutorials-java by Artister.

the class RuntimeServiceTests method testExecutionQuery.

/**
 * 查询流程执行对象
 */
@Deployment(resources = { "my-process.bpmn20.xml" })
@Test
public void testExecutionQuery() {
    RuntimeService runtimeService = activitiRule.getRuntimeService();
    Map<String, Object> variables = Maps.newHashMap();
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process", variables);
    logger.info("processInstance = {}", processInstance);
    // 查询流程执行对象
    ExecutionQuery executionQuery = runtimeService.createExecutionQuery();
    List<Execution> executions = executionQuery.list();
    for (Execution execution : executions) {
        logger.info("execution = {}", execution);
    }
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) Test(org.junit.Test) Deployment(org.activiti.engine.test.Deployment)

Aggregations

RuntimeService (org.activiti.engine.RuntimeService)92 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)35 Test (org.junit.Test)25 ProcessEngine (org.activiti.engine.ProcessEngine)16 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)15 TaskService (org.activiti.engine.TaskService)14 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)14 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)13 Deployment (org.activiti.engine.test.Deployment)13 RestVariable (org.wso2.carbon.bpmn.rest.engine.variable.RestVariable)12 RepositoryService (org.activiti.engine.RepositoryService)10 HashMap (java.util.HashMap)8 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)8 Task (org.activiti.engine.task.Task)8 ArrayList (java.util.ArrayList)7 Path (javax.ws.rs.Path)7 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)7 Execution (org.activiti.engine.runtime.Execution)7 Produces (javax.ws.rs.Produces)6 ProcessDefinition (org.activiti.engine.repository.ProcessDefinition)6