Search in sources :

Example 6 with CoreVariableInstance

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

the class AbstractVariableScope method getVariableInstance.

public CoreVariableInstance getVariableInstance(String variableName) {
    CoreVariableInstance variableInstance = getVariableInstanceLocal(variableName);
    if (variableInstance != null) {
        return variableInstance;
    }
    AbstractVariableScope parentScope = getParentVariableScope();
    if (parentScope != null) {
        return parentScope.getVariableInstance(variableName);
    }
    return null;
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance)

Example 7 with CoreVariableInstance

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

the class AbstractVariableScope method collectVariables.

public void collectVariables(VariableMapImpl resultVariables, Collection<String> variableNames, boolean isLocal, boolean deserializeValues) {
    boolean collectAll = (variableNames == null);
    List<CoreVariableInstance> localVariables = getVariableInstancesLocal(variableNames);
    for (CoreVariableInstance var : localVariables) {
        if (!resultVariables.containsKey(var.getName()) && (collectAll || variableNames.contains(var.getName()))) {
            resultVariables.put(var.getName(), var.getTypedValue(deserializeValues));
        }
    }
    if (!isLocal) {
        AbstractVariableScope parentScope = getParentVariableScope();
        // Do not propagate to parent if all variables in 'variableNames' are already collected!
        if (parentScope != null && (collectAll || !resultVariables.keySet().equals(variableNames))) {
            parentScope.collectVariables(resultVariables, variableNames, isLocal, deserializeValues);
        }
    }
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance)

Example 8 with CoreVariableInstance

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

the class AbstractVariableScope method setVariableLocal.

public void setVariableLocal(String variableName, TypedValue value, AbstractVariableScope sourceActivityExecution) {
    checkJavaSerialization(variableName, value);
    VariableStore<CoreVariableInstance> variableStore = getVariableStore();
    if (variableStore.containsKey(variableName)) {
        CoreVariableInstance existingInstance = variableStore.getVariable(variableName);
        existingInstance.setValue(value);
        invokeVariableLifecycleListenersUpdate(existingInstance, sourceActivityExecution);
    } else if (variableStore.isRemoved(variableName)) {
        CoreVariableInstance existingInstance = variableStore.getRemovedVariable(variableName);
        existingInstance.setValue(value);
        getVariableStore().addVariable(existingInstance);
        invokeVariableLifecycleListenersUpdate(existingInstance, sourceActivityExecution);
        DbEntityManager dbEntityManager = Context.getCommandContext().getDbEntityManager();
        dbEntityManager.undoDelete((VariableInstanceEntity) existingInstance);
    } else {
        CoreVariableInstance variableValue = getVariableInstanceFactory().build(variableName, value, false);
        getVariableStore().addVariable(variableValue);
        invokeVariableLifecycleListenersCreate(variableValue, sourceActivityExecution);
    }
}
Also used : CoreVariableInstance(org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance) DbEntityManager(org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager) VariableInstanceEntity(org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)

Aggregations

CoreVariableInstance (org.camunda.bpm.engine.impl.core.variable.CoreVariableInstance)8 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)2 TypedValue (org.camunda.bpm.engine.variable.value.TypedValue)2 VariableInstanceLifecycleListener (org.camunda.bpm.engine.impl.core.variable.scope.VariableInstanceLifecycleListener)1 DbEntityManager (org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager)1 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)1