Search in sources :

Example 81 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class TransientVariableTest method testMessageCorrelationWithTransientVariable.

@Test
public void testMessageCorrelationWithTransientVariable() {
    // given
    BpmnModelInstance instance = Bpmn.createExecutableProcess("process").startEvent().intermediateCatchEvent().message("message").scriptTask("scriptTask").scriptFormat("javascript").camundaResultVariable("abc").scriptText("execution.setVariable('abc', blob);").endEvent().done();
    testRule.deploy(instance);
    runtimeService.startProcessInstanceByKey("process", Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", false)));
    // when
    VariableMap correlationKeys = Variables.createVariables().putValueTyped("foo", Variables.stringValue("foo", true));
    VariableMap variables = Variables.createVariables().putValueTyped("blob", Variables.stringValue("blob", true));
    runtimeService.correlateMessage("message", correlationKeys, variables);
    // then
    VariableInstance variableInstance = runtimeService.createVariableInstanceQuery().singleResult();
    assertNull(variableInstance);
    HistoricVariableInstance historicVariableInstance = historyService.createHistoricVariableInstanceQuery().variableName("abc").singleResult();
    assertNotNull(historicVariableInstance);
    assertEquals("blob", historicVariableInstance.getValue());
}
Also used : VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) BpmnModelInstance(org.camunda.bpm.model.bpmn.BpmnModelInstance) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Test(org.junit.Test)

Example 82 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class UpdateHistoricValueDelegate method execute.

public void execute(DelegateExecution execution) throws Exception {
    HistoryService historyService = execution.getProcessEngineServices().getHistoryService();
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult();
    List<String> list = (List<String>) variableInstance.getValue();
    // implicit update of the list, should not trigger an update
    // of the value since we deal with historic variables
    list.add(NEW_ELEMENT);
}
Also used : HistoryService(org.camunda.bpm.engine.HistoryService) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) List(java.util.List)

Example 83 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class UpdateHistoricDetailValueDelegate method execute.

public void execute(DelegateExecution execution) throws Exception {
    HistoryService historyService = execution.getProcessEngineServices().getHistoryService();
    HistoricVariableInstance variableInstance = historyService.createHistoricVariableInstanceQuery().variableName("listVar").singleResult();
    HistoricVariableUpdate initialUpdate = (HistoricVariableUpdate) historyService.createHistoricDetailQuery().variableUpdates().variableInstanceId(variableInstance.getId()).orderPartiallyByOccurrence().asc().list().get(0);
    List<String> list = (List<String>) initialUpdate.getValue();
    // implicit update of the list, should not trigger an update
    // of the value since we deal with historic variables
    list.add(NEW_ELEMENT);
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) List(java.util.List)

Example 84 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableOnServiceTaskInsideParallelBranch.

@Deployment
public void testSetVariableOnServiceTaskInsideParallelBranch() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("process");
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(1, query.count());
    HistoricVariableInstance variable = query.singleResult();
    // the variable is in the process instance scope
    assertEquals(pi.getId(), variable.getActivityInstanceId());
    assertProcessEnded(pi.getId());
}
Also used : HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 85 with HistoricVariableInstance

use of org.camunda.bpm.engine.history.HistoricVariableInstance in project camunda-bpm-platform by camunda.

the class HistoricVariableInstanceScopeTest method testSetVariableLocalOnUserTask.

@Deployment(resources = { "org/camunda/bpm/engine/test/api/oneTaskProcess.bpmn20.xml" })
public void testSetVariableLocalOnUserTask() {
    ProcessInstance pi = runtimeService.startProcessInstanceByKey("oneTaskProcess");
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
    taskService.setVariableLocal(task.getId(), "testVar", "testValue");
    ExecutionEntity taskExecution = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(task.getExecutionId()).singleResult();
    assertNotNull(taskExecution);
    HistoricVariableInstanceQuery query = historyService.createHistoricVariableInstanceQuery();
    assertEquals(1, query.count());
    HistoricVariableInstance variable = query.singleResult();
    assertNotNull(variable);
    // the variable is in the task scope
    assertEquals(taskExecution.getActivityInstanceId(), variable.getActivityInstanceId());
    taskService.complete(task.getId());
    assertProcessEnded(pi.getId());
}
Also used : Task(org.camunda.bpm.engine.task.Task) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) HistoricVariableInstanceQuery(org.camunda.bpm.engine.history.HistoricVariableInstanceQuery) ProcessInstance(org.camunda.bpm.engine.runtime.ProcessInstance) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Aggregations

HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)88 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)44 Test (org.junit.Test)42 Deployment (org.camunda.bpm.engine.test.Deployment)39 HistoricVariableInstanceQuery (org.camunda.bpm.engine.history.HistoricVariableInstanceQuery)18 Task (org.camunda.bpm.engine.task.Task)17 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)14 BpmnModelInstance (org.camunda.bpm.model.bpmn.BpmnModelInstance)13 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)12 RequiredHistoryLevel (org.camunda.bpm.engine.test.RequiredHistoryLevel)12 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)10 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)10 AbstractRestServiceTest (org.camunda.bpm.engine.rest.AbstractRestServiceTest)10 HashMap (java.util.HashMap)8 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)8 VariableMap (org.camunda.bpm.engine.variable.VariableMap)8 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)7 Date (java.util.Date)6 ProcessDefinition (org.camunda.bpm.engine.repository.ProcessDefinition)6 MockHistoricVariableInstanceBuilder (org.camunda.bpm.engine.rest.helper.MockHistoricVariableInstanceBuilder)6