Package org.camunda.bpm.engine.runtime

Examples of org.camunda.bpm.engine.runtime.VariableInstanceQuery


  private void createVariableInstanceMock() {
    List<VariableInstance> variables = new ArrayList<VariableInstance>();
    VariableInstance mockInstance = MockProvider.createMockVariableInstance();
    variables.add(mockInstance);

    VariableInstanceQuery mockVariableInstanceQuery = mock(VariableInstanceQuery.class);
    when(mockVariableInstanceQuery.list()).thenReturn(variables);
    when(mockRuntimeService.createVariableInstanceQuery()).thenReturn(mockVariableInstanceQuery);
  }
View Full Code Here


    // then
    assertNotNull(caseInstance);

    // there should exist two variables
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();

    List<VariableInstance> result = query
      .caseInstanceIdIn(caseInstance.getId())
      .orderByVariableName()
      .asc()
      .list();
View Full Code Here

    // then
    assertNotNull(caseInstance);

    // there should exist two variables
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();

    List<VariableInstance> result = query
      .caseInstanceIdIn(caseInstance.getId())
      .orderByVariableName()
      .asc()
      .list();
View Full Code Here

    // then
    assertNotNull(caseInstance);

    // there should exist two variables
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();

    List<VariableInstance> result = query
      .caseInstanceIdIn(caseInstance.getId())
      .orderByVariableName()
      .asc()
      .list();
View Full Code Here

    // then
    assertNotNull(caseInstance);

    // there should exist two variables
    VariableInstanceQuery query = runtimeService.createVariableInstanceQuery();

    List<VariableInstance> result = query
      .caseInstanceIdIn(caseInstance.getId())
      .orderByVariableName()
      .asc()
      .list();
View Full Code Here

    caseService
      .withCaseExecution(humanTaskId)
      .setVariable("variable", "initial")
      .execute();

    VariableInstanceQuery query = runtimeService
      .createVariableInstanceQuery()
      .variableName("variable")
      .caseInstanceIdIn(caseInstanceId);

    Assert.assertNotNull(query.singleResult());
    Assert.assertEquals("listener-notified-1", query.singleResult().getValue());

    caseService
      .withCaseExecution(humanTaskId)
      .setVariable("variable", "manual-start")
      .manualStart();

    Assert.assertNotNull(query.singleResult());
    Assert.assertEquals("listener-notified-2", query.singleResult().getValue());

  }
View Full Code Here

    // the listener should execute successfully
    caseService
      .withCaseExecution(humanTaskId)
      .manualStart();

    VariableInstanceQuery query = runtimeService
        .createVariableInstanceQuery()
        .variableName("listener")
        .caseInstanceIdIn(caseInstanceId);

    Assert.assertNotNull(query.singleResult());
    Assert.assertEquals("listener-notified", query.singleResult().getValue());

    caseService
      .withCaseExecution(caseInstanceId)
      .removeVariable("listener")
      .execute();

    Assert.assertEquals(0, query.count());

    // the delegate expression listener should execute successfully
    caseService
      .withCaseExecution(humanTaskId)
      .complete();

    Assert.assertNotNull(query.singleResult());
    Assert.assertEquals("listener-notified", query.singleResult().getValue());

  }
View Full Code Here

    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();

    // get process instance
    ProcessInstance pi = processInstanceQuery.processDefinitionKey(key).singleResult();

    VariableInstanceQuery variableInstanceQuery = getClearVariableInstanceQuery(pi.getId());
    ExecutionQuery executionQuery = runtimeService.createExecutionQuery().processInstanceId(pi.getId());
    TaskQuery taskQuery = taskService.createTaskQuery().processInstanceId(pi.getId());
    JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi.getId());

    Task task = taskQuery.singleResult();

    // there should be five variable instance (3 process instance variables) and...
    Assert.assertEquals(5, variableInstanceQuery.count());

    // ...2 task variable
    Assert.assertEquals(2, variableInstanceQuery.taskIdIn(task.getId()).count());

    // add a new task variable
    taskService.setVariableLocal(task.getId(), "aNewLocalTaskVariableName", "aNewLockTaskVariableValue");

    // change task variable value
    taskService.setVariableLocal(task.getId(), "aLocalTaskVariableName", "aNewValue");

    Assert.assertEquals(3, variableInstanceQuery.taskIdIn(task.getId()).count());

    // complete task
    taskService.complete(task.getId());

    variableInstanceQuery = getClearVariableInstanceQuery(pi.getId());

    // there should be three variables...
    Assert.assertEquals(3, variableInstanceQuery.count());

    Execution execution = executionQuery.singleResult();

    // update existing variable
    runtimeService.setVariableLocal(execution.getId(), "anotherVariableName", "aNewFinalValue");
View Full Code Here

  @Override
  public List<VariableInstanceDto> queryVariableInstances(VariableInstanceQueryDto queryDto, Integer firstResult, Integer maxResults, boolean deserializeObjectValues) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    VariableInstanceQuery query = queryDto.toQuery(engine);

    // disable binary fetching by default.
    query.disableBinaryFetching();

    // disable custom object fetching by default. Cannot be done to not break existing API
    if (!deserializeObjectValues) {
      query.disableCustomObjectDeserialization();
    }

    List<VariableInstance> matchingInstances;
    if (firstResult != null || maxResults != null) {
      matchingInstances = executePaginatedQuery(query, firstResult, maxResults);
    } else {
      matchingInstances = query.list();
    }

    List<VariableInstanceDto> instanceResults = new ArrayList<VariableInstanceDto>();
    for (VariableInstance instance : matchingInstances) {
      VariableInstanceDto resultInstance = VariableInstanceDto.fromVariableInstance(instance);
View Full Code Here

  @Override
  public CountResultDto queryVariableInstancesCount(VariableInstanceQueryDto queryDto) {
    ProcessEngine engine = getProcessEngine();
    queryDto.setObjectMapper(getObjectMapper());
    VariableInstanceQuery query = queryDto.toQuery(engine);

    long count = query.count();
    CountResultDto result = new CountResultDto();
    result.setCount(count);

    return result;
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.runtime.VariableInstanceQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.