Java Code Examples for org.flowable.engine.history.HistoricProcessInstance#getProcessVariables()
The following examples show how to use
org.flowable.engine.history.HistoricProcessInstance#getProcessVariables() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HistoricProcessInstanceQueryVersionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testHistoricProcessInstanceQueryByProcessDefinitionVersion() { assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).list().get(0).getProcessDefinitionVersion().intValue()); assertEquals(2, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list().get(0).getProcessDefinitionVersion().intValue()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list().size()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).list().size()); // Variables Case if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", 123).processDefinitionVersion(1).singleResult(); assertEquals(1, processInstance.getProcessDefinitionVersion().intValue()); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(123, variableMap.get("test")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(1).singleResult(); assertNull(processInstance); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(2).singleResult(); assertEquals(2, processInstance.getProcessDefinitionVersion().intValue()); variableMap = processInstance.getProcessVariables(); assertEquals(456, variableMap.get("anothertest")); } }
Example 2
Source File: HistoricProcessInstanceQueryVersionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testHistoricProcessInstanceOrQueryByProcessDefinitionVersion() { assertEquals(1, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(1).processDefinitionId("undefined").endOr().count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(2).processDefinitionId("undefined").endOr().count()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(3).processDefinitionId("undefined").endOr().count()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(1).processDefinitionId("undefined").endOr().list().size()); assertEquals(1, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(2).processDefinitionId("undefined").endOr().list().size()); assertEquals(0, historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(3).processDefinitionId("undefined").endOr().list().size()); // Variables Case if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("test", "invalid").processDefinitionVersion(1).endOr().singleResult(); assertEquals(1, processInstance.getProcessDefinitionVersion().intValue()); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(123, variableMap.get("test")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("anothertest", "invalid").processDefinitionVersion(2).endOr().singleResult(); assertEquals(2, processInstance.getProcessDefinitionVersion().intValue()); variableMap = processInstance.getProcessVariables(); assertEquals(456, variableMap.get("anothertest")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", "invalid").processDefinitionVersion(3).singleResult(); assertNull(processInstance); } }
Example 3
Source File: HistoricProcessInstanceAndVariablesQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testQueryByprocessDefinition() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { // DeploymentId String deploymentId = repositoryService.createDeploymentQuery().list().get(0).getId(); HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).deploymentId(deploymentId).singleResult(); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); assertEquals(deploymentId, processInstance.getDeploymentId()); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", "invalid").deploymentId(deploymentId).singleResult(); assertNull(processInstance); // ProcessDefinitionName processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); assertEquals(PROCESS_DEFINITION_NAME_2, processInstance.getProcessDefinitionName()); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); assertNull(processInstance); // ProcessDefinitionCategory processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); assertNull(processInstance); } }
Example 4
Source File: RestResponseFactory.java From flowable-engine with Apache License 2.0 | 5 votes |
public HistoricProcessInstanceResponse createHistoricProcessInstanceResponse(HistoricProcessInstance processInstance, RestUrlBuilder urlBuilder) { HistoricProcessInstanceResponse result = new HistoricProcessInstanceResponse(); result.setBusinessKey(processInstance.getBusinessKey()); result.setDeleteReason(processInstance.getDeleteReason()); result.setDurationInMillis(processInstance.getDurationInMillis()); result.setEndActivityId(processInstance.getEndActivityId()); result.setEndTime(processInstance.getEndTime()); result.setId(processInstance.getId()); result.setName(processInstance.getName()); result.setProcessDefinitionId(processInstance.getProcessDefinitionId()); result.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, processInstance.getProcessDefinitionId())); result.setStartActivityId(processInstance.getStartActivityId()); result.setStartTime(processInstance.getStartTime()); result.setStartUserId(processInstance.getStartUserId()); result.setSuperProcessInstanceId(processInstance.getSuperProcessInstanceId()); result.setUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE, processInstance.getId())); if (processInstance.getProcessVariables() != null) { Map<String, Object> variableMap = processInstance.getProcessVariables(); for (String name : variableMap.keySet()) { result.addVariable(createRestVariable(name, variableMap.get(name), RestVariableScope.LOCAL, processInstance.getId(), VARIABLE_HISTORY_PROCESS, false, urlBuilder)); } } result.setCallbackId(processInstance.getCallbackId()); result.setCallbackType(processInstance.getCallbackType()); result.setReferenceId(processInstance.getReferenceId()); result.setReferenceType(processInstance.getReferenceType()); result.setTenantId(processInstance.getTenantId()); return result; }
Example 5
Source File: HistoricProcessInstanceQueryVersionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testHistoricProcessInstanceQueryByProcessDefinitionVersion() { assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).list().get(0).getProcessDefinitionVersion().intValue()) .isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list().get(0).getProcessDefinitionVersion().intValue()) .isEqualTo(2); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()).isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).count()).isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).count()).isZero(); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(1).count()).isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(2).list()).hasSize(1); assertThat(historyService.createHistoricProcessInstanceQuery().processDefinitionVersion(3).list()).isEmpty(); // Variables Case if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", 123).processDefinitionVersion(1).singleResult(); assertThat(processInstance.getProcessDefinitionVersion().intValue()).isEqualTo(1); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsOnly(entry("test", 123)); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(1).singleResult(); assertThat(processInstance).isNull(); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 456).processDefinitionVersion(2).singleResult(); assertThat(processInstance.getProcessDefinitionVersion().intValue()).isEqualTo(2); variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsOnly(entry("anothertest", 456)); } }
Example 6
Source File: HistoricProcessInstanceQueryVersionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testHistoricProcessInstanceOrQueryByProcessDefinitionVersion() { assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(1).processDefinitionId("undefined").endOr().count()) .isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(2).processDefinitionId("undefined").endOr().count()) .isEqualTo(1); assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(3).processDefinitionId("undefined").endOr().count()) .isZero(); assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(1).processDefinitionId("undefined").endOr().list()) .hasSize(1); assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(2).processDefinitionId("undefined").endOr().list()) .hasSize(1); assertThat(historyService.createHistoricProcessInstanceQuery().or().processDefinitionVersion(3).processDefinitionId("undefined").endOr().list()) .isEmpty(); // Variables Case if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("test", "invalid").processDefinitionVersion(1).endOr().singleResult(); assertThat(processInstance.getProcessDefinitionVersion().intValue()).isEqualTo(1); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsOnly(entry("test", 123)); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("anothertest", "invalid").processDefinitionVersion(2).endOr().singleResult(); assertThat(processInstance.getProcessDefinitionVersion().intValue()).isEqualTo(2); variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsOnly(entry("anothertest", 456)); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", "invalid").processDefinitionVersion(3).singleResult(); assertThat(processInstance).isNull(); } }
Example 7
Source File: HistoricProcessInstanceAndVariablesQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@Test public void testQueryByprocessDefinition() { if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { // DeploymentId String deploymentId = repositoryService.createDeploymentQuery().list().get(0).getId(); HistoricProcessInstance processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).deploymentId(deploymentId).singleResult(); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsExactly(entry("anothertest", 123)); assertThat(processInstance.getDeploymentId()).isEqualTo(deploymentId); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", "invalid").deploymentId(deploymentId).singleResult(); assertThat(processInstance).isNull(); // ProcessDefinitionName processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsExactly(entry("anothertest", 123)); assertThat(processInstance.getProcessDefinitionName()).isEqualTo(PROCESS_DEFINITION_NAME_2); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionName(PROCESS_DEFINITION_NAME_2).singleResult(); assertThat(processInstance).isNull(); // ProcessDefinitionCategory processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("anothertest", 123).processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsExactly(entry("anothertest", 123)); processInstance = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .variableValueEquals("test", "test").processDefinitionCategory(PROCESS_DEFINITION_CATEGORY_2).singleResult(); assertThat(processInstance).isNull(); } }
Example 8
Source File: HistoricProcessInstanceAndVariablesQueryTest.java From flowable-engine with Apache License 2.0 | 4 votes |
public void testOrQueryMultipleVariableValues() { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) { HistoricProcessInstanceQuery query0 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or(); for (int i = 0; i < 20; i++) { query0 = query0.variableValueEquals("anothertest", i); } query0 = query0.processDefinitionId("undefined").endOr(); assertNull(query0.singleResult()); HistoricProcessInstanceQuery query1 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or().variableValueEquals("anothertest", 123); for (int i = 0; i < 20; i++) { query1 = query1.variableValueEquals("anothertest", i); } query1 = query1.processDefinitionId("undefined").endOr(); HistoricProcessInstance processInstance = query1.singleResult(); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); HistoricProcessInstanceQuery query2 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or(); for (int i = 0; i < 20; i++) { query2 = query2.variableValueEquals("anothertest", i); } query2 = query2.processDefinitionId("undefined") .endOr() .or() .processDefinitionKey(PROCESS_DEFINITION_KEY_2) .processDefinitionId("undefined") .endOr(); assertNull(query2.singleResult()); HistoricProcessInstanceQuery query3 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("anothertest", 123); for (int i = 0; i < 20; i++) { query3 = query3.variableValueEquals("anothertest", i); } query3 = query3.processDefinitionId("undefined") .endOr() .or() .processDefinitionKey(PROCESS_DEFINITION_KEY_2) .processDefinitionId("undefined") .endOr(); variableMap = query3.singleResult().getProcessVariables(); assertEquals(1, variableMap.size()); assertEquals(123, variableMap.get("anothertest")); } }
Example 9
Source File: HistoricProcessInstanceTest.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Validation for https://activiti.atlassian.net/browse/ACT-2182 */ public void testNameAndTenantIdSetWhenFetchingVariables() { String tenantId = "testTenantId"; String processInstanceName = "myProcessInstance"; String deploymentId = repositoryService.createDeployment() .addClasspathResource("org/activiti/engine/test/history/oneTaskProcess.bpmn20.xml") .tenantId(tenantId) .deploymentProperty(DeploymentProperties.DEPLOY_AS_FLOWABLE5_PROCESS_DEFINITION, Boolean.TRUE) .deploy() .getId(); Map<String, Object> vars = new HashMap<String, Object>(); vars.put("name", "Kermit"); vars.put("age", 60); ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("oneTaskProcess", vars, tenantId); runtimeService.setProcessInstanceName(processInstance.getId(), processInstanceName); // Verify name and tenant id (didn't work on mssql and db2) on process instance List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().includeProcessVariables().list(); assertEquals(1, processInstances.size()); processInstance = processInstances.get(0); assertEquals(processInstanceName, processInstance.getName()); assertEquals(tenantId, processInstance.getTenantId()); Map<String, Object> processInstanceVars = processInstance.getProcessVariables(); assertEquals(2, processInstanceVars.size()); assertEquals("Kermit", processInstanceVars.get("name")); assertEquals(60, processInstanceVars.get("age")); // Verify name and tenant id (didn't work on mssql and db2) on historic process instance List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().list(); assertEquals(1, historicProcessInstances.size()); HistoricProcessInstance historicProcessInstance = historicProcessInstances.get(0); // Verify name and tenant id (didn't work on mssql and db2) on process instance assertEquals(processInstanceName, historicProcessInstance.getName()); assertEquals(tenantId, historicProcessInstance.getTenantId()); Map<String, Object> historicProcessInstanceVars = historicProcessInstance.getProcessVariables(); assertEquals(2, historicProcessInstanceVars.size()); assertEquals("Kermit", historicProcessInstanceVars.get("name")); assertEquals(60, historicProcessInstanceVars.get("age")); // cleanup repositoryService.deleteDeployment(deploymentId, true); }
Example 10
Source File: HistoricProcessInstanceAndVariablesQueryTest.java From flowable-engine with Apache License 2.0 | 4 votes |
@Test public void testOrQueryMultipleVariableValues() { if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) { HistoricProcessInstanceQuery query0 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or(); for (int i = 0; i < 20; i++) { query0 = query0.variableValueEquals("anothertest", i); } query0 = query0.processDefinitionId("undefined").endOr(); assertThat(query0.singleResult()).isNull(); HistoricProcessInstanceQuery query1 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().or() .variableValueEquals("anothertest", 123); for (int i = 0; i < 20; i++) { query1 = query1.variableValueEquals("anothertest", i); } query1 = query1.processDefinitionId("undefined").endOr(); HistoricProcessInstance processInstance = query1.singleResult(); Map<String, Object> variableMap = processInstance.getProcessVariables(); assertThat(variableMap) .containsExactly(entry("anothertest", 123)); HistoricProcessInstanceQuery query2 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or(); for (int i = 0; i < 20; i++) { query2 = query2.variableValueEquals("anothertest", i); } query2 = query2.processDefinitionId("undefined") .endOr() .or() .processDefinitionKey(PROCESS_DEFINITION_KEY_2) .processDefinitionId("undefined") .endOr(); assertThat(query2.singleResult()).isNull(); HistoricProcessInstanceQuery query3 = historyService.createHistoricProcessInstanceQuery().includeProcessVariables() .or().variableValueEquals("anothertest", 123); for (int i = 0; i < 20; i++) { query3 = query3.variableValueEquals("anothertest", i); } query3 = query3.processDefinitionId("undefined") .endOr() .or() .processDefinitionKey(PROCESS_DEFINITION_KEY_2) .processDefinitionId("undefined") .endOr(); variableMap = query3.singleResult().getProcessVariables(); assertThat(variableMap) .containsExactly(entry("anothertest", 123)); } }
Example 11
Source File: TestCacheTaskListener.java From flowable-engine with Apache License 2.0 | 4 votes |
@Override public void notify(DelegateTask delegateTask) { ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(); TaskService taskService = processEngineConfiguration.getTaskService(); Task task = taskService.createTaskQuery().taskId(delegateTask.getId()).singleResult(); if (task != null && task.getId().equals(delegateTask.getId())) { TASK_ID = task.getId(); } HistoryService historyService = processEngineConfiguration.getHistoryService(); HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(delegateTask.getId()).singleResult(); if (historicTask != null && historicTask.getId().equals(delegateTask.getId())) { HISTORIC_TASK_ID = historicTask.getId(); } delegateTask.setVariable("varFromTheListener", "valueFromTheListener"); delegateTask.setVariableLocal("localVar", "localValue"); // Used in CacheTaskTest#testTaskQueryWithIncludeVariables ProcessInstance processInstance = processEngineConfiguration.getRuntimeService().createProcessInstanceQuery() .processInstanceId(task.getProcessInstanceId()) .includeProcessVariables() .singleResult(); PROCESS_VARIABLES = processInstance.getProcessVariables(); HistoricProcessInstance historicProcessInstance = processEngineConfiguration.getHistoryService().createHistoricProcessInstanceQuery() .processInstanceId(task.getProcessInstanceId()) .includeProcessVariables() .singleResult(); HISTORIC_PROCESS_VARIABLES = historicProcessInstance.getProcessVariables(); // Used in CacheTaskTest#testTaskQueryWithIncludeVariables Task taskFromQuery = processEngineConfiguration.getTaskService().createTaskQuery() .taskId(delegateTask.getId()) .includeProcessVariables() .includeTaskLocalVariables() .singleResult(); TASK_PROCESS_VARIABLES = taskFromQuery.getProcessVariables(); TASK_LOCAL_VARIABLES = taskFromQuery.getTaskLocalVariables(); HistoricTaskInstance historicTaskFromQuery = processEngineConfiguration.getHistoryService().createHistoricTaskInstanceQuery() .taskId(delegateTask.getId()) .includeProcessVariables() .includeTaskLocalVariables() .singleResult(); HISTORIC_TASK_PROCESS_VARIABLES = historicTaskFromQuery.getProcessVariables(); HISTORIC_TASK_LOCAL_VARIABLES = historicTaskFromQuery.getTaskLocalVariables(); }
Example 12
Source File: HistoricProcessInstanceTest.java From flowable-engine with Apache License 2.0 | 4 votes |
/** * Validation for https://jira.codehaus.org/browse/ACT-2182 */ @Test public void testNameAndTenantIdSetWhenFetchingVariables() { String tenantId = "testTenantId"; String processInstanceName = "myProcessInstance"; String deploymentId = repositoryService.createDeployment().addClasspathResource("org/flowable/engine/test/history/oneTaskProcess.bpmn20.xml").tenantId(tenantId).deploy().getId(); Map<String, Object> vars = new HashMap<>(); vars.put("name", "Kermit"); vars.put("age", 60); ProcessInstance processInstance = runtimeService.startProcessInstanceByKeyAndTenantId("oneTaskProcess", vars, tenantId); runtimeService.setProcessInstanceName(processInstance.getId(), processInstanceName); // Verify name and tenant id (didn't work on mssql and db2) on process instance List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().includeProcessVariables().list(); assertThat(processInstances).hasSize(1); processInstance = processInstances.get(0); assertThat(processInstance.getName()).isEqualTo(processInstanceName); assertThat(processInstance.getTenantId()).isEqualTo(tenantId); Map<String, Object> processInstanceVars = processInstance.getProcessVariables(); assertThat(processInstanceVars).hasSize(2); assertThat(processInstanceVars.get("name")).isEqualTo("Kermit"); assertThat(processInstanceVars.get("age")).isEqualTo(60); waitForHistoryJobExecutorToProcessAllJobs(10000, 200); // Verify name and tenant id (didn't work on mssql and db2) on historic process instance List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().includeProcessVariables().list(); assertThat(historicProcessInstances).hasSize(1); HistoricProcessInstance historicProcessInstance = historicProcessInstances.get(0); // Verify name and tenant id (didn't work on mssql and db2) on process instance assertThat(historicProcessInstance.getName()).isEqualTo(processInstanceName); assertThat(historicProcessInstance.getTenantId()).isEqualTo(tenantId); Map<String, Object> historicProcessInstanceVars = historicProcessInstance.getProcessVariables(); assertThat(historicProcessInstanceVars).hasSize(2); assertThat(historicProcessInstanceVars.get("name")).isEqualTo("Kermit"); assertThat(historicProcessInstanceVars.get("age")).isEqualTo(60); waitForHistoryJobExecutorToProcessAllJobs(10000, 200); // cleanup deleteDeployment(deploymentId); }