Class VariableScopeImpl
java.lang.Object
org.flowable.common.engine.impl.persistence.entity.AbstractEntity
org.flowable.variable.service.impl.persistence.entity.VariableScopeImpl
- All Implemented Interfaces:
Serializable,VariableContainer,HasRevision,Entity,VariableScope
- Direct Known Subclasses:
AbstractBpmnEngineVariableScopeEntity,AbstractCmmnEngineVariableScopeEntity,AbstractTaskServiceVariableScopeEntity
public abstract class VariableScopeImpl
extends AbstractEntity
implements Serializable, VariableScope
- Author:
- Tom Baeyens, Joram Barrez, Tijs Rademakers, Saeid Mirzaei
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ELContextprotected Map<String,VariableInstance> protected Map<String,VariableInstanceEntity> protected Map<String,VariableInstanceEntity> Fields inherited from class org.flowable.common.engine.impl.persistence.entity.AbstractEntity
id, isDeleted, isInserted, isUpdated, originalPersistentState, revision -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddLoggingSessionInfo(com.fasterxml.jackson.databind.node.ObjectNode loggingNode) collectTransientVariables(HashMap<String, Object> variables) protected Map<String,VariableInstance> collectVariableInstances(HashMap<String, VariableInstance> variables) collectVariableNames(Set<String> variableNames) collectVariables(HashMap<String, Object> variables) protected VariableInstanceEntitycreateVariableInstance(String variableName, Object value) protected voidcreateVariableLocal(String variableName, Object value) only called when a new variable is created on this variable scope.voidcreateVariablesLocal(Map<String, ? extends Object> variables) protected voiddeleteVariableInstanceForExplicitUserCall(VariableInstanceEntity variableInstance) protected voidprotected abstract VariableScopeImplprotected abstract VariableInstanceEntitygetSpecificVariable(String variableName) protected abstract List<VariableInstanceEntity>getSpecificVariables(Collection<String> variableNames) getTransientVariable(String variableName) Similar toVariableScope.getVariable(String), including the searching via the parent scopes, but for transient variables only.getTransientVariableLocal(String variableName) Similar toVariableScope.getVariableLocal(String), but for a transient variable.Similar toVariableScope.getVariables(), but for transient variables only.Similar toVariableScope.getVariableLocal(String), but for transient variables only.getVariable(String variableName) Returns the variable value for one specific variable.getVariable(String variableName, boolean fetchAllVariables) The same operation asgetVariable(String), but with an extra parameter to indicate whether or not all variables need to be fetched.<T> TgetVariable(String variableName, Class<T> variableClass) Typed version of theVariableScope.getVariable(String)method.getVariableInstance(String variableName) Similar toVariableScope.getVariable(String), but returns aVariableInstanceinstance, which contains more information than just the value.getVariableInstance(String variableName, boolean fetchAllVariables) Similar toVariableScope.getVariable(String, boolean), but returns an instance ofVariableInstance, which has some additional information beyond the value.getVariableInstanceLocal(String variableName) Similar toVariableScope.getVariableLocal(String), but returns an instance ofVariableInstance, which has some additional information beyond the value.getVariableInstanceLocal(String variableName, boolean fetchAllVariables) Similar toVariableScope.getVariableLocal(String, boolean), but returns an instance ofVariableInstance, which has some additional information beyond the value.Returns all variables, as instances of theVariableInstanceinterface, which gives more information than only the value (type, execution id, etc.)getVariableInstances(Collection<String> variableNames) Similar toVariableScope.getVariableInstances(), but limited to only the variables with the provided names.getVariableInstances(Collection<String> variableNames, boolean fetchAllVariables) Similar toVariableScope.getVariables(Collection, boolean)but returns the variables as instances of theVariableInstanceinterface, which gives more information than only the value (type, execution id, etc.)Returns the variables local to this scope as instances of theVariableInstanceinterface, which provided additional information about the variable.getVariableInstancesLocal(Collection<String> variableNames) Similar toVariableScope.getVariableInstances(Collection), but only for variables local to this scope.getVariableInstancesLocal(Collection<String> variableNames, boolean fetchAllVariables) Similar toVariableScope.getVariableInstances(Collection, boolean), but only for variables local to this scope.getVariableLocal(String variableName) Returns the value for the specific variable and only checks this scope and not any parent scope.getVariableLocal(String variableName, boolean fetchAllVariables) Similar toVariableScope.getVariableLocal(String), but has an extra flag that indicates whether or not all variables need to be fetched when getting one variable.<T> TgetVariableLocal(String variableName, Class<T> variableClass) Typed version of theVariableScope.getVariableLocal(String)method.Returns all the names of the variables for this scope and all parent scopes.Returns all the names of the variables for this scope (no parent scopes).Returns all variables.getVariables(Collection<String> variableNames) Similar toVariableScope.getVariables(), but limited to only the variables with the provided names.getVariables(Collection<String> variableNames, boolean fetchAllVariables) Similar toVariableScope.getVariables(Collection), but with a flag that indicates that all variables should be fetched when fetching the specific variables.protected abstract VariableServiceConfigurationReturns the variable local to this scope only.getVariablesLocal(Collection<String> variableNames) Similar toVariableScope.getVariables(Collection), but only for variables local to this scope.getVariablesLocal(Collection<String> variableNames, boolean fetchAllVariables) Similar toVariableScope.getVariables(Collection, boolean), but only for variables local to this scope.booleanhasVariable(String variableName) Returns whether this scope or any parent scope has a specific variable.booleanhasVariableLocal(String variableName) Returns whether this scope has a specific variable.booleanReturns whether this scope or any parent scope has variables.booleanReturns whether this scope has variables.protected abstract voidinitializeVariableInstanceBackPointer(VariableInstance variableInstance) voidinternalSetVariableInstances(Map<String, VariableInstanceEntity> variableInstances) Only to be used when creating a new entity, to avoid an extra call to the database.protected booleanisExpression(String variableName) protected abstract booleanReturn whether changes to the variables are propagated to the history storage.protected abstract Collection<VariableInstanceEntity>voidremoveTransientVariable(String variableName) Removes a specific transient variable.voidremoveTransientVariableLocal(String variableName) Removes a specific transient variable (also searching parent scopes).voidRemove all transient variable of this scope and its parent scopes.voidRemoves all local transient variables.voidremoveVariable(String variableName) Removes the variable and creates a new HistoricVariableUpdate.voidremoveVariableLocal(String variableName) Removes the local variable and creates a new HistoricVariableUpdate.voidRemoves the (local) variables and creates a new HistoricVariableUpdate for each of them.voidremoveVariables(Collection<String> variableNames) Removes the variables and creates a new HistoricVariableUpdate for each of them.voidRemoves the (local) variables and creates a new HistoricVariableUpdate for each of them.voidremoveVariablesLocal(Collection<String> variableNames) Removes the local variables and creates a new HistoricVariableUpdate for each of them.voidsetCachedElContext(ELContext cachedElContext) voidsetTransientVariable(String variableName, Object variableValue) Similar toVariableScope.setVariable(String, Object), but the variable is transient: - no history is kept for the variable - the variable is only available until a waitstate is reached in the process - transient variables 'shadow' persistent variable (when getVariable('abc') where 'abc' is both persistent and transient, the transient value is returned.voidsetTransientVariableLocal(String variableName, Object variableValue) Similar toVariableScope.setVariableLocal(String, Object), but for a transient variable.voidsetTransientVariables(Map<String, Object> transientVariables) Similar toVariableScope.setVariables(Map), but for transient variables.voidsetTransientVariablesLocal(Map<String, Object> transientVariables) Similar toVariableScope.setVariablesLocal(Map), but for transient variables.voidsetVariable(String variableName, Object value) Sets the variable with the provided name to the provided value.voidsetVariable(String variableName, Object value, boolean fetchAllVariables) The defaultsetVariable(String, Object)fetches all variables (for historical and backwards compatible reasons) while setting the variables.setVariableLocal(String variableName, Object value) Similar toVariableScope.setVariable(String, Object), but the variable is set to this scope specifically.setVariableLocal(String variableName, Object value, boolean fetchAllVariables) The defaultsetVariableLocal(String, Object)fetches all variables (for historical and backwards compatible reasons) while setting the variables.voidsetVariables(Map<String, ? extends Object> variables) Sets the provided variables to the variable scope.voidsetVariablesLocal(Map<String, ? extends Object> variables) Similar toVariableScope.setVariables(Map), but the variable are set on this scope specifically.protected booleanstoreVariableLocal(String variableName) protected voidupdateVariableInstance(VariableInstanceEntity variableInstance, Object newVariableValue) Methods inherited from class org.flowable.common.engine.impl.persistence.entity.AbstractEntity
getId, getOriginalPersistentState, getRevision, getRevisionNext, isDeleted, isInserted, isUpdated, setDeleted, setId, setInserted, setOriginalPersistentState, setRevision, setUpdatedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.flowable.common.engine.impl.persistence.entity.Entity
getIdPrefix, getPersistentStateMethods inherited from interface org.flowable.common.engine.api.variable.VariableContainer
getTenantId
-
Field Details
-
variableInstances
-
usedVariablesCache
-
transientVariables
-
cachedElContext
-
-
Constructor Details
-
VariableScopeImpl
public VariableScopeImpl()
-
-
Method Details
-
loadVariableInstances
-
getParentVariableScope
-
initializeVariableInstanceBackPointer
-
addLoggingSessionInfo
protected abstract void addLoggingSessionInfo(com.fasterxml.jackson.databind.node.ObjectNode loggingNode) -
ensureVariableInstancesInitialized
protected void ensureVariableInstancesInitialized() -
internalSetVariableInstances
Only to be used when creating a new entity, to avoid an extra call to the database. -
getVariables
Description copied from interface:VariableScopeReturns all variables. This will include all variables of parent scopes too.- Specified by:
getVariablesin interfaceVariableScope
-
getVariableInstances
Description copied from interface:VariableScopeReturns all variables, as instances of theVariableInstanceinterface, which gives more information than only the value (type, execution id, etc.)- Specified by:
getVariableInstancesin interfaceVariableScope
-
getVariables
Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(), but limited to only the variables with the provided names.- Specified by:
getVariablesin interfaceVariableScope
-
getVariableInstances
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableInstances(), but limited to only the variables with the provided names.- Specified by:
getVariableInstancesin interfaceVariableScope
-
getVariables
Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(Collection), but with a flag that indicates that all variables should be fetched when fetching the specific variables. If set to false, only the specific variables will be fetched. Depending on the use case, this can be better for performance, as it avoids fetching and processing the other variables. However, if the other variables are needed further on, getting them in one go is probably better (and the variables are cached during one Command execution).- Specified by:
getVariablesin interfaceVariableScope
-
getVariableInstances
public Map<String,VariableInstance> getVariableInstances(Collection<String> variableNames, boolean fetchAllVariables) Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(Collection, boolean)but returns the variables as instances of theVariableInstanceinterface, which gives more information than only the value (type, execution id, etc.)- Specified by:
getVariableInstancesin interfaceVariableScope
-
collectVariables
-
collectVariableInstances
protected Map<String,VariableInstance> collectVariableInstances(HashMap<String, VariableInstance> variables) -
getVariable
Description copied from interface:VariableScopeReturns the variable value for one specific variable. Will look in parent scopes when the variable does not exist on this particular scope.- Specified by:
getVariablein interfaceVariableContainer- Specified by:
getVariablein interfaceVariableScope
-
getVariableInstance
Description copied from interface:VariableScopeSimilar toVariableScope.getVariable(String), but returns aVariableInstanceinstance, which contains more information than just the value.- Specified by:
getVariableInstancein interfaceVariableScope
-
getVariable
The same operation asgetVariable(String), but with an extra parameter to indicate whether or not all variables need to be fetched. Note that the default way (because of backwards compatibility) is to fetch all the variables when doing a get/set of variables. So this means 'true' is the default value for this method, and in fact it will simply delegate togetVariable(String). This can also be the most performant, if you're doing a lot of variable gets in the same transaction (eg in service tasks). In case 'false' is used, only the specific variable will be fetched.- Specified by:
getVariablein interfaceVariableScope
-
getVariableInstance
Description copied from interface:VariableScopeSimilar toVariableScope.getVariable(String, boolean), but returns an instance ofVariableInstance, which has some additional information beyond the value.- Specified by:
getVariableInstancein interfaceVariableScope
-
getSpecificVariable
-
getVariableLocal
Description copied from interface:VariableScopeReturns the value for the specific variable and only checks this scope and not any parent scope.- Specified by:
getVariableLocalin interfaceVariableScope
-
getVariableInstanceLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableLocal(String), but returns an instance ofVariableInstance, which has some additional information beyond the value.- Specified by:
getVariableInstanceLocalin interfaceVariableScope
-
getVariableLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableLocal(String), but has an extra flag that indicates whether or not all variables need to be fetched when getting one variable. By default true (for backwards compatibility reasons), which means that callingVariableScope.getVariableLocal(String)will fetch all variables, of the current scope. Setting this flag to false can thus be better for performance. However, variables are cached, and if other variables are used later on, setting this true might actually be better for performance.- Specified by:
getVariableLocalin interfaceVariableScope
-
getVariableInstanceLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableLocal(String, boolean), but returns an instance ofVariableInstance, which has some additional information beyond the value.- Specified by:
getVariableInstanceLocalin interfaceVariableScope
-
hasVariables
public boolean hasVariables()Description copied from interface:VariableScopeReturns whether this scope or any parent scope has variables.- Specified by:
hasVariablesin interfaceVariableScope
-
hasVariablesLocal
public boolean hasVariablesLocal()Description copied from interface:VariableScopeReturns whether this scope has variables.- Specified by:
hasVariablesLocalin interfaceVariableScope
-
hasVariable
Description copied from interface:VariableScopeReturns whether this scope or any parent scope has a specific variable.- Specified by:
hasVariablein interfaceVariableContainer- Specified by:
hasVariablein interfaceVariableScope
-
hasVariableLocal
Description copied from interface:VariableScopeReturns whether this scope has a specific variable.- Specified by:
hasVariableLocalin interfaceVariableScope
-
collectVariableNames
-
getVariableNames
Description copied from interface:VariableScopeReturns all the names of the variables for this scope and all parent scopes.- Specified by:
getVariableNamesin interfaceVariableScope
-
getVariablesLocal
Description copied from interface:VariableScopeReturns the variable local to this scope only. So, in contrary toVariableScope.getVariables(), the variables from the parent scope won't be returned.- Specified by:
getVariablesLocalin interfaceVariableScope
-
getVariableInstancesLocal
Description copied from interface:VariableScopeReturns the variables local to this scope as instances of theVariableInstanceinterface, which provided additional information about the variable.- Specified by:
getVariableInstancesLocalin interfaceVariableScope
-
getVariablesLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(Collection), but only for variables local to this scope.- Specified by:
getVariablesLocalin interfaceVariableScope
-
getVariableInstancesLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableInstances(Collection), but only for variables local to this scope.- Specified by:
getVariableInstancesLocalin interfaceVariableScope
-
getVariablesLocal
public Map<String,Object> getVariablesLocal(Collection<String> variableNames, boolean fetchAllVariables) Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(Collection, boolean), but only for variables local to this scope.- Specified by:
getVariablesLocalin interfaceVariableScope
-
getVariableInstancesLocal
public Map<String,VariableInstance> getVariableInstancesLocal(Collection<String> variableNames, boolean fetchAllVariables) Description copied from interface:VariableScopeSimilar toVariableScope.getVariableInstances(Collection, boolean), but only for variables local to this scope.- Specified by:
getVariableInstancesLocalin interfaceVariableScope
-
getSpecificVariables
protected abstract List<VariableInstanceEntity> getSpecificVariables(Collection<String> variableNames) -
getVariableNamesLocal
Description copied from interface:VariableScopeReturns all the names of the variables for this scope (no parent scopes).- Specified by:
getVariableNamesLocalin interfaceVariableScope
-
getVariableInstanceEntities
-
getUsedVariablesCache
-
createVariablesLocal
-
setVariables
Description copied from interface:VariableScopeSets the provided variables to the variable scope.Variables are set according algorithm for
VariableScope.setVariable(String, Object), applied separately to each variable.- Specified by:
setVariablesin interfaceVariableScope- Parameters:
variables- a map of keys and values for the variables to be set
-
setVariablesLocal
Description copied from interface:VariableScopeSimilar toVariableScope.setVariables(Map), but the variable are set on this scope specifically.- Specified by:
setVariablesLocalin interfaceVariableScope
-
removeVariables
public void removeVariables()Description copied from interface:VariableScopeRemoves the (local) variables and creates a new HistoricVariableUpdate for each of them.- Specified by:
removeVariablesin interfaceVariableScope
-
removeVariablesLocal
public void removeVariablesLocal()Description copied from interface:VariableScopeRemoves the (local) variables and creates a new HistoricVariableUpdate for each of them.- Specified by:
removeVariablesLocalin interfaceVariableScope
-
removeVariables
Description copied from interface:VariableScopeRemoves the variables and creates a new HistoricVariableUpdate for each of them.- Specified by:
removeVariablesin interfaceVariableScope
-
removeVariablesLocal
Description copied from interface:VariableScopeRemoves the local variables and creates a new HistoricVariableUpdate for each of them.- Specified by:
removeVariablesLocalin interfaceVariableScope
-
setVariable
Description copied from interface:VariableScopeSets the variable with the provided name to the provided value. In the case when variable name is an expression which is resolved by expression manager, the value is set in the object resolved from the expression.A variable is set according to the following algorithm:
- If variable name is an expression, resolve expression and set the value on the resolved object.
- If this scope already contains a variable by the provided name as a local variable, its value is overwritten to the provided value.
- If this scope does not contain a variable by the provided name as a local variable, the variable is set to this scope's parent scope, if there is one. If there is no parent scope (meaning this scope is the root scope of the hierarchy it belongs to), this scope is used. This applies recursively up the parent scope chain until, if no scope contains a local variable by the provided name, ultimately the root scope is reached and the variable value is set on that scope.
- Specified by:
setVariablein interfaceVariableContainer- Specified by:
setVariablein interfaceVariableScope- Parameters:
variableName- the name of the variable to be setvalue- the value of the variable to be set
-
setVariable
The defaultsetVariable(String, Object)fetches all variables (for historical and backwards compatible reasons) while setting the variables. Setting the fetchAllVariables parameter to true is the default behaviour (ie fetching all variables) Setting the fetchAllVariables parameter to false does not do that.- Specified by:
setVariablein interfaceVariableScope
-
setVariableLocal
Description copied from interface:VariableScopeSimilar toVariableScope.setVariable(String, Object), but the variable is set to this scope specifically. Variable name is handled as a variable name string without resolving an expression.- Specified by:
setVariableLocalin interfaceVariableScope
-
setVariableLocal
The defaultsetVariableLocal(String, Object)fetches all variables (for historical and backwards compatible reasons) while setting the variables. Setting the fetchAllVariables parameter to true is the default behaviour (ie fetching all variables) Setting the fetchAllVariables parameter to false does not do that.- Specified by:
setVariableLocalin interfaceVariableScope
-
createVariableLocal
only called when a new variable is created on this variable scope. This method is also responsible for propagating the creation of this variable to the history. -
removeVariable
Description copied from interface:VariableScopeRemoves the variable and creates a new HistoricVariableUpdate.- Specified by:
removeVariablein interfaceVariableScope
-
removeVariableLocal
Description copied from interface:VariableScopeRemoves the local variable and creates a new HistoricVariableUpdate.- Specified by:
removeVariableLocalin interfaceVariableScope
-
deleteVariableInstanceForExplicitUserCall
-
updateVariableInstance
protected void updateVariableInstance(VariableInstanceEntity variableInstance, Object newVariableValue) -
createVariableInstance
-
storeVariableLocal
-
setTransientVariablesLocal
Description copied from interface:VariableScopeSimilar toVariableScope.setVariablesLocal(Map), but for transient variables. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
setTransientVariablesLocalin interfaceVariableScope
-
setTransientVariableLocal
Description copied from interface:VariableScopeSimilar toVariableScope.setVariableLocal(String, Object), but for a transient variable. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
setTransientVariableLocalin interfaceVariableScope
-
setTransientVariables
Description copied from interface:VariableScopeSimilar toVariableScope.setVariables(Map), but for transient variables. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
setTransientVariablesin interfaceVariableScope
-
setTransientVariable
Description copied from interface:VariableScopeSimilar toVariableScope.setVariable(String, Object), but the variable is transient: - no history is kept for the variable - the variable is only available until a waitstate is reached in the process - transient variables 'shadow' persistent variable (when getVariable('abc') where 'abc' is both persistent and transient, the transient value is returned.- Specified by:
setTransientVariablein interfaceVariableContainer- Specified by:
setTransientVariablein interfaceVariableScope
-
getTransientVariableLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableLocal(String), but for a transient variable. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
getTransientVariableLocalin interfaceVariableScope
-
getTransientVariablesLocal
Description copied from interface:VariableScopeSimilar toVariableScope.getVariableLocal(String), but for transient variables only. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
getTransientVariablesLocalin interfaceVariableScope
-
getTransientVariable
Description copied from interface:VariableScopeSimilar toVariableScope.getVariable(String), including the searching via the parent scopes, but for transient variables only. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
getTransientVariablein interfaceVariableScope
-
getTransientVariables
Description copied from interface:VariableScopeSimilar toVariableScope.getVariables(), but for transient variables only. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
getTransientVariablesin interfaceVariableScope
-
collectTransientVariables
-
removeTransientVariableLocal
Description copied from interface:VariableScopeRemoves a specific transient variable (also searching parent scopes). SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
removeTransientVariableLocalin interfaceVariableScope
-
removeTransientVariablesLocal
public void removeTransientVariablesLocal()Description copied from interface:VariableScopeRemoves all local transient variables. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
removeTransientVariablesLocalin interfaceVariableScope
-
removeTransientVariable
Description copied from interface:VariableScopeRemoves a specific transient variable. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
removeTransientVariablein interfaceVariableScope
-
removeTransientVariables
public void removeTransientVariables()Description copied from interface:VariableScopeRemove all transient variable of this scope and its parent scopes. SeeVariableScope.setTransientVariable(String, Object)for the rules on 'transient' variables.- Specified by:
removeTransientVariablesin interfaceVariableScope
-
isPropagateToHistoricVariable
protected abstract boolean isPropagateToHistoricVariable()Return whether changes to the variables are propagated to the history storage. -
getVariableServiceConfiguration
-
getCachedElContext
-
setCachedElContext
-
getVariable
Description copied from interface:VariableScopeTyped version of theVariableScope.getVariable(String)method.- Specified by:
getVariablein interfaceVariableScope
-
getVariableLocal
Description copied from interface:VariableScopeTyped version of theVariableScope.getVariableLocal(String)method.- Specified by:
getVariableLocalin interfaceVariableScope
-
isExpression
-