use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.
the class StartProcessInterceptor method extractVariables.
private Map<String, Object> extractVariables(StartProcess startProcessAnnotation, InvocationContext ctx) throws Exception {
VariableMap variables = new VariableMapImpl();
for (Field field : ctx.getMethod().getDeclaringClass().getDeclaredFields()) {
if (!field.isAnnotationPresent(ProcessVariable.class) && !field.isAnnotationPresent(ProcessVariableTyped.class)) {
continue;
}
field.setAccessible(true);
String fieldName = null;
ProcessVariable processStartVariable = field.getAnnotation(ProcessVariable.class);
if (processStartVariable != null) {
fieldName = processStartVariable.value();
} else {
ProcessVariableTyped processStartVariableTyped = field.getAnnotation(ProcessVariableTyped.class);
fieldName = processStartVariableTyped.value();
}
if (fieldName == null || fieldName.length() == 0) {
fieldName = field.getName();
}
Object value = field.get(ctx.getTarget());
variables.put(fieldName, value);
}
return variables;
}
use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.
the class GetTaskFormVariablesCmd method execute.
public VariableMap execute(CommandContext commandContext) {
final TaskManager taskManager = commandContext.getTaskManager();
TaskEntity task = taskManager.findTaskById(resourceId);
ensureNotNull(BadUserRequestException.class, "Cannot find task with id '" + resourceId + "'.", "task", task);
checkGetTaskFormVariables(task, commandContext);
VariableMapImpl result = new VariableMapImpl();
// first, evaluate form fields
TaskDefinition taskDefinition = task.getTaskDefinition();
if (taskDefinition != null) {
TaskFormData taskFormData = taskDefinition.getTaskFormHandler().createTaskForm(task);
for (FormField formField : taskFormData.getFormFields()) {
if (formVariableNames == null || formVariableNames.contains(formField.getId())) {
result.put(formField.getId(), createVariable(formField, task));
}
}
}
// collect remaining variables from task scope and parent scopes
task.collectVariables(result, formVariableNames, false, deserializeObjectValues);
return result;
}
use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.
the class BusinessProcess method getAndClearCachedVariableMap.
/**
* Get the {@link VariableMap} of cached variables and clear the internal variable cache.
*
* @return the {@link VariableMap} of cached variables
*
* @since 7.3
*/
public VariableMap getAndClearCachedVariableMap() {
VariableMap cachedVariables = associationManager.getCachedVariables();
VariableMap copy = new VariableMapImpl(cachedVariables);
cachedVariables.clear();
return copy;
}
use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.
the class BusinessProcess method getAndClearCachedLocalVariableMap.
/**
* Get the {@link VariableMap} of local cached variables and clear the internal variable cache.
*
* @return the {@link VariableMap} of cached variables
*
* @since 7.3
*/
public VariableMap getAndClearCachedLocalVariableMap() {
VariableMap cachedVariablesLocal = associationManager.getCachedLocalVariables();
VariableMap copy = new VariableMapImpl(cachedVariablesLocal);
cachedVariablesLocal.clear();
return copy;
}
use of org.camunda.bpm.engine.variable.impl.VariableMapImpl in project camunda-bpm-platform by camunda.
the class RestartProcessInstancesCmd method collectLastVariables.
protected VariableMap collectLastVariables(CommandContext commandContext, HistoricProcessInstance processInstance) {
HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService();
List<HistoricVariableInstance> historicVariables = historyService.createHistoricVariableInstanceQuery().executionIdIn(processInstance.getId()).list();
VariableMap variables = new VariableMapImpl();
for (HistoricVariableInstance variable : historicVariables) {
variables.putValueTyped(variable.getName(), variable.getTypedValue());
}
return variables;
}
Aggregations