public virtual void setVariableLocal(string variableName, TypedValue value, AbstractVariableScope sourceActivityExecution) { checkJavaSerialization(variableName, value); VariableStore <CoreVariableInstance> variableStore = VariableStore; if (variableStore.containsKey(variableName)) { CoreVariableInstance existingInstance = variableStore.getVariable(variableName); existingInstance.Value = value; invokeVariableLifecycleListenersUpdate(existingInstance, sourceActivityExecution); } else if (variableStore.isRemoved(variableName)) { CoreVariableInstance existingInstance = variableStore.getRemovedVariable(variableName); existingInstance.Value = value; VariableStore.addVariable(existingInstance); invokeVariableLifecycleListenersUpdate(existingInstance, sourceActivityExecution); DbEntityManager dbEntityManager = Context.CommandContext.DbEntityManager; dbEntityManager.undoDelete((VariableInstanceEntity)existingInstance); } else { CoreVariableInstance variableValue = VariableInstanceFactory.build(variableName, value, false); VariableStore.addVariable(variableValue); invokeVariableLifecycleListenersCreate(variableValue, sourceActivityExecution); } }
protected internal virtual void handleEvent(VariableEvent @event) { AbstractVariableScope sourceScope = @event.SourceScope; if (sourceScope is ExecutionEntity) { addEventToScopeExecution((ExecutionEntity)sourceScope, @event); } else if (sourceScope is TaskEntity) { TaskEntity task = (TaskEntity)sourceScope; ExecutionEntity execution = task.getExecution(); if (execution != null) { addEventToScopeExecution(execution, @event); } } else if (sourceScope.ParentVariableScope is ExecutionEntity) { addEventToScopeExecution((ExecutionEntity)sourceScope.ParentVariableScope, @event); } else { throw new ProcessEngineException("BPMN execution scope expected"); } }
protected internal virtual void removeVariableLocal(string variableName, AbstractVariableScope sourceActivityExecution) { if (VariableStore.containsKey(variableName)) { CoreVariableInstance variableInstance = VariableStore.getVariable(variableName); invokeVariableLifecycleListenersDelete(variableInstance, sourceActivityExecution); VariableStore.removeVariable(variableName); } }
public virtual bool hasVariable(string variableName) { if (hasVariableLocal(variableName)) { return(true); } AbstractVariableScope parentScope = ParentVariableScope; return(parentScope != null && parentScope.hasVariable(variableName)); }
public virtual bool hasVariables() { if (!VariableStore.Empty) { return(true); } AbstractVariableScope parentScope = ParentVariableScope; return(parentScope != null && parentScope.hasVariables()); }
protected internal virtual ISet <string> collectVariableNames(ISet <string> variableNames) { AbstractVariableScope parentScope = ParentVariableScope; if (parentScope != null) { variableNames.addAll(parentScope.collectVariableNames(variableNames)); } foreach (CoreVariableInstance variableInstance in VariableStore.Variables) { variableNames.Add(variableInstance.Name); } return(variableNames); }
public virtual CoreVariableInstance getVariableInstance(string variableName) { CoreVariableInstance variableInstance = getVariableInstanceLocal(variableName); if (variableInstance != null) { return(variableInstance); } AbstractVariableScope parentScope = ParentVariableScope; if (parentScope != null) { return(parentScope.getVariableInstance(variableName)); } return(null); }
protected internal virtual void setVariable(string variableName, TypedValue value, AbstractVariableScope sourceActivityVariableScope) { if (hasVariableLocal(variableName)) { TypedValue previousTypeValue = getVariableInstanceLocal(variableName).getTypedValue(false); if (value.Transient != previousTypeValue.Transient) { throw ProcessEngineLogger.CORE_LOGGER.transientVariableException(variableName); } if (value.Transient) { setVariableLocalTransient(variableName, value, sourceActivityVariableScope); } else { setVariableLocal(variableName, value, sourceActivityVariableScope); } return; } AbstractVariableScope parentVariableScope = ParentVariableScope; if (parentVariableScope != null) { if (sourceActivityVariableScope == null) { parentVariableScope.setVariable(variableName, value); } else { parentVariableScope.setVariable(variableName, value, sourceActivityVariableScope); } return; } if (value.Transient) { setVariableLocalTransient(variableName, value, sourceActivityVariableScope); } else { setVariableLocal(variableName, value, sourceActivityVariableScope); } }
protected internal virtual void removeVariable(string variableName, AbstractVariableScope sourceActivityExecution) { if (VariableStore.containsKey(variableName)) { removeVariableLocal(variableName, sourceActivityExecution); return; } AbstractVariableScope parentVariableScope = ParentVariableScope; if (parentVariableScope != null) { if (sourceActivityExecution == null) { parentVariableScope.removeVariable(variableName); } else { parentVariableScope.removeVariable(variableName, sourceActivityExecution); } } }
public virtual void collectVariables(VariableMapImpl resultVariables, ICollection <string> variableNames, bool isLocal, bool deserializeValues) { bool collectAll = (variableNames == null); IList <CoreVariableInstance> localVariables = getVariableInstancesLocal(variableNames); foreach (CoreVariableInstance var in localVariables) { if (!resultVariables.containsKey(var.Name) && (collectAll || variableNames.Contains(var.Name))) { resultVariables.put(var.Name, var.getTypedValue(deserializeValues)); } } if (!isLocal) { AbstractVariableScope parentScope = ParentVariableScope; // Do not propagate to parent if all variables in 'variableNames' are already collected! if (parentScope != null && (collectAll || !resultVariables.Keys.Equals(variableNames))) { parentScope.collectVariables(resultVariables, variableNames, isLocal, deserializeValues); } } }
public VariableListenerInvocationListener(AbstractVariableScope targetScope) { this.targetScope = targetScope; }
public virtual void onUpdate(VariableInstanceEntity variable, AbstractVariableScope sourceScope) { sourceScope.dispatchEvent(new VariableEvent(variable, [email protected]_Fields.UPDATE, sourceScope)); }
public virtual void setVariableLocalTransient(string variableName, object value, AbstractVariableScope sourceActivityVariableScope) { VariableStore <CoreVariableInstance> variableStore = VariableStore; if (variableStore.containsKey(variableName)) { CoreVariableInstance existingInstance = variableStore.getVariable(variableName); existingInstance.Value = (TypedValue)value; invokeVariableLifecycleListenersUpdate(existingInstance, sourceActivityVariableScope); } else { setVariableLocalTransient(variableName, value); invokeVariableLifecycleListenersCreate(variableStore.getVariable(variableName), sourceActivityVariableScope); } }
protected internal virtual void invokeVariableLifecycleListenersUpdate(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope, IList <VariableInstanceLifecycleListener <CoreVariableInstance> > lifecycleListeners) { foreach (VariableInstanceLifecycleListener <CoreVariableInstance> lifecycleListener in lifecycleListeners) { lifecycleListener.onUpdate(variableInstance, sourceScope); } }
public virtual void onDelete(VariableInstanceEntity variable, AbstractVariableScope sourceScope) { handleEvent(new VariableEvent(variable, [email protected]_Fields.DELETE, sourceScope)); }
protected internal virtual void invokeVariableLifecycleListenersUpdate(CoreVariableInstance variableInstance, AbstractVariableScope sourceScope) { invokeVariableLifecycleListenersUpdate(variableInstance, sourceScope, VariableInstanceLifecycleListeners); }
public virtual void onDelete(VariableInstanceEntity variable, AbstractVariableScope sourceScope) { execution.handleVariableTransition(variable.Name, VariableTransition.delete.name()); }