Search in sources :

Example 1 with VariableMapImpl

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;
}
Also used : Field(java.lang.reflect.Field) VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) ProcessVariable(org.camunda.bpm.engine.cdi.annotation.ProcessVariable) ProcessVariableTyped(org.camunda.bpm.engine.cdi.annotation.ProcessVariableTyped)

Example 2 with VariableMapImpl

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;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) TaskDefinition(org.camunda.bpm.engine.impl.task.TaskDefinition) TaskManager(org.camunda.bpm.engine.impl.persistence.entity.TaskManager) TaskEntity(org.camunda.bpm.engine.impl.persistence.entity.TaskEntity) TaskFormData(org.camunda.bpm.engine.form.TaskFormData) FormField(org.camunda.bpm.engine.form.FormField)

Example 3 with VariableMapImpl

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;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 4 with VariableMapImpl

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;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap)

Example 5 with VariableMapImpl

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;
}
Also used : VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricVariableInstance(org.camunda.bpm.engine.history.HistoricVariableInstance)

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