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);
}
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;
}
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;
}
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;
}
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;
}
Aggregations