Class VariableBehavior
Note that for EventApplier
, you should just use the
mutable state directly.
-
Constructor Summary
ConstructorsConstructorDescriptionVariableBehavior
(VariableState variableState, StateWriter stateWriter, KeyGenerator keyGenerator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
mergeDocument
(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document) Merges the given document, propagating its changes from the bottom to the top of the scope hierarchy.void
mergeLocalDocument
(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document) Merges the given document directly on the given scope key.void
setLocalVariable
(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer name, org.agrona.DirectBuffer value, int valueOffset, int valueLength) Publishes a follow up event to create or update the variable with namename
on the given scope with keyscopeKey
, with additionalprocessDefinitionKey
andprocessInstanceKey
context.
-
Constructor Details
-
VariableBehavior
public VariableBehavior(VariableState variableState, StateWriter stateWriter, KeyGenerator keyGenerator)
-
-
Method Details
-
mergeLocalDocument
public void mergeLocalDocument(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document) Merges the given document directly on the given scope key.If any variable from the document already exists on the current scope, a
Variable.UPDATED
record is produced as a follow up event.For all variables from the document which do not exist in the current scope, a
Variable.CREATED
record is produced as a follow up event.- Parameters:
scopeKey
- the scope key for each variableprocessDefinitionKey
- the process key to be associated with each variableprocessInstanceKey
- the process instance key to be associated with each variabledocument
- the document to merge
-
mergeDocument
public void mergeDocument(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer document) Merges the given document, propagating its changes from the bottom to the top of the scope hierarchy.Starting at the given
scopeKey
, it will overwrite any variables that exist in that scope with the corresponding values from the given document. Variables that were not set because they did not exist in the current scope are collected as a sub document, which will then be merged with the parent scope, recursively, until there are no more. If we reach a scope with no parent, then any remaining variables are created there.If any variable from the document already exists on the current scope, a
Variable.UPDATED
record is produced as a follow up event.For all variables from the document which do not exist in the current scope, a
Variable.CREATED
record is produced as a follow up event.- Parameters:
scopeKey
- the scope key for each variableprocessDefinitionKey
- the process key to be associated with each variableprocessInstanceKey
- the process instance key to be associated with each variabledocument
- the document to merge
-
setLocalVariable
public void setLocalVariable(long scopeKey, long processDefinitionKey, long processInstanceKey, org.agrona.DirectBuffer name, org.agrona.DirectBuffer value, int valueOffset, int valueLength) Publishes a follow up event to create or update the variable with namename
on the given scope with keyscopeKey
, with additionalprocessDefinitionKey
andprocessInstanceKey
context.If the scope is the process instance itself, then
scopeKey
should be equal toprocessInstanceKey
.- Parameters:
scopeKey
- the key of the scope on which to set the variableprocessDefinitionKey
- the associated process keyprocessInstanceKey
- the associated process instance keyname
- a buffer containing only the name of the variablevalue
- a buffer containing the value of the variable as MessagePackvalueOffset
- the offset of the value in thevalue
buffervalueLength
- the length of the value in thevalue
buffer
-