}
protected void initializeCommandWithVariables(CaseExecutionCommandBuilder commandBuilder, Map<String, TriggerVariableValueDto> variables, String transition) {
for(String variableName : variables.keySet()) {
try {
TriggerVariableValueDto variableValue = variables.get(variableName);
if (variableValue.isLocal()) {
commandBuilder.setVariableLocal(variableName, variableValue.toTypedValue(engine, objectMapper));
} else {
commandBuilder.setVariable(variableName, variableValue.toTypedValue(engine, objectMapper));
}
} catch (RestException e) {
String errorMessage = String.format("Cannot %s case instance %s due to invalid variable %s: %s", transition, caseInstanceId, variableName, e.getMessage());
throw new RestException(e.getStatus(), e, errorMessage);