Search in sources :

Example 16 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class CaseTaskTest method testVariablesRoundtrip.

/**
 * assertion on variables - change subprocess definition
 */
@Deployment(resources = { "org/camunda/bpm/engine/test/cmmn/casetask/CaseTaskTest.testVariablesRoundtrip.cmmn", "org/camunda/bpm/engine/test/api/cmmn/oneTaskCaseWithManualActivation.cmmn" })
public void testVariablesRoundtrip() {
    // given
    VariableMap vars = new VariableMapImpl();
    vars.putValue("aVariable", "xyz");
    vars.putValue("anotherVariable", 123);
    String superCaseInstanceId = createCaseInstanceByKey(ONE_CASE_TASK_CASE, vars).getId();
    String subCaseInstanceId = queryOneTaskCaseInstance().getId();
    caseService.withCaseExecution(subCaseInstanceId).setVariable("aVariable", "abc").setVariable("anotherVariable", 999).execute();
    String humanTaskId = queryCaseExecutionByActivityId("PI_HumanTask_1").getId();
    caseService.withCaseExecution(humanTaskId).manualStart();
    caseService.withCaseExecution(humanTaskId).complete();
    // when
    caseService.withCaseExecution(subCaseInstanceId).close();
    // then
    List<VariableInstance> variables = runtimeService.createVariableInstanceQuery().caseInstanceIdIn(superCaseInstanceId).list();
    assertFalse(variables.isEmpty());
    assertEquals(2, variables.size());
    for (VariableInstance variable : variables) {
        String name = variable.getName();
        if ("aVariable".equals(name)) {
            assertEquals("aVariable", name);
            assertEquals("abc", variable.getValue());
        } else if ("anotherVariable".equals(name)) {
            assertEquals("anotherVariable", name);
            assertEquals(999, variable.getValue());
        } else {
            fail("Found an unexpected variable: '" + name + "'");
        }
    }
    // complete ////////////////////////////////////////////////////////
    close(superCaseInstanceId);
    assertCaseEnded(superCaseInstanceId);
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) VariableInstance(org.camunda.bpm.engine.runtime.VariableInstance) Deployment(org.camunda.bpm.engine.test.Deployment)

Example 17 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class GetExecutionVariablesCmd method execute.

public VariableMap execute(CommandContext commandContext) {
    ensureNotNull("executionId", executionId);
    ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
    ensureNotNull("execution " + executionId + " doesn't exist", "execution", execution);
    checkGetExecutionVariables(execution, commandContext);
    VariableMapImpl executionVariables = new VariableMapImpl();
    // collect variables from execution
    execution.collectVariables(executionVariables, variableNames, isLocal, deserializeValues);
    return executionVariables;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 18 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class GetStartFormVariablesCmd method execute.

public VariableMap execute(final CommandContext commandContext) {
    StartFormData startFormData = commandContext.runWithoutAuthorization(new Callable<StartFormData>() {

        public StartFormData call() throws Exception {
            return new GetStartFormCmd(resourceId).execute(commandContext);
        }
    });
    ProcessDefinition definition = startFormData.getProcessDefinition();
    checkGetStartFormVariables((ProcessDefinitionEntity) definition, commandContext);
    VariableMap result = new VariableMapImpl();
    for (FormField formField : startFormData.getFormFields()) {
        if (formVariableNames == null || formVariableNames.contains(formField.getId())) {
            result.put(formField.getId(), createVariable(formField, null));
        }
    }
    return result;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) StartFormData(org.camunda.bpm.engine.form.StartFormData) ProcessDefinition(org.camunda.bpm.engine.repository.ProcessDefinition) FormField(org.camunda.bpm.engine.form.FormField)

Example 19 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class LockedExternalTaskImpl method fromEntity.

/**
 * Construct representation of locked ExternalTask from corresponding entity.
 * During mapping variables will be collected,during collection variables will not be deserialized
 * and scope will not be set to local.
 *
 * @see {@link org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope#collectVariables(VariableMapImpl, Collection, boolean, boolean)}
 *
 * @param externalTaskEntity - source persistent entity to use for fields
 * @param variablesToFetch - list of variable names to fetch, if null then all variables will be fetched
 *
 * @return object with all fields copied from the ExternalTaskEntity, error details fetched from the
 * database and variables attached
 */
public static LockedExternalTaskImpl fromEntity(ExternalTaskEntity externalTaskEntity, List<String> variablesToFetch, boolean deserializeVariables) {
    LockedExternalTaskImpl result = new LockedExternalTaskImpl();
    result.id = externalTaskEntity.getId();
    result.topicName = externalTaskEntity.getTopicName();
    result.workerId = externalTaskEntity.getWorkerId();
    result.lockExpirationTime = externalTaskEntity.getLockExpirationTime();
    result.retries = externalTaskEntity.getRetries();
    result.errorMessage = externalTaskEntity.getErrorMessage();
    result.errorDetails = externalTaskEntity.getErrorDetails();
    result.processInstanceId = externalTaskEntity.getProcessInstanceId();
    result.executionId = externalTaskEntity.getExecutionId();
    result.activityId = externalTaskEntity.getActivityId();
    result.activityInstanceId = externalTaskEntity.getActivityInstanceId();
    result.processDefinitionId = externalTaskEntity.getProcessDefinitionId();
    result.processDefinitionKey = externalTaskEntity.getProcessDefinitionKey();
    result.tenantId = externalTaskEntity.getTenantId();
    result.priority = externalTaskEntity.getPriority();
    ExecutionEntity execution = externalTaskEntity.getExecution();
    result.variables = new VariableMapImpl();
    execution.collectVariables(result.variables, variablesToFetch, false, deserializeVariables);
    return result;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 20 with VariableMapImpl

use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.

the class AbstractVariableScope method getVariablesLocalTyped.

public VariableMapImpl getVariablesLocalTyped(boolean deserializeObjectValues) {
    VariableMapImpl variables = new VariableMapImpl();
    collectVariables(variables, null, true, deserializeObjectValues);
    return variables;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl)

Aggregations

VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)22 VariableMap (org.camunda.bpm.engine.variable.VariableMap)15 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)7 Deployment (org.camunda.bpm.engine.test.Deployment)7 VariableInstance (org.camunda.bpm.engine.runtime.VariableInstance)4 CaseExecution (org.camunda.bpm.engine.runtime.CaseExecution)3 HistoryService (org.camunda.bpm.engine.HistoryService)2 FormField (org.camunda.bpm.engine.form.FormField)2 ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)2 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)2 Field (java.lang.reflect.Field)1 ProcessVariable (org.camunda.bpm.engine.cdi.annotation.ProcessVariable)1 ProcessVariableTyped (org.camunda.bpm.engine.cdi.annotation.ProcessVariableTyped)1 StartFormData (org.camunda.bpm.engine.form.StartFormData)1 TaskFormData (org.camunda.bpm.engine.form.TaskFormData)1 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)1 HistoricDetail (org.camunda.bpm.engine.history.HistoricDetail)1 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)1 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)1 HistoricDetailQueryImpl (org.camunda.bpm.engine.impl.HistoricDetailQueryImpl)1