Class FlowableExpressionCollectionUtils
- java.lang.Object
-
- com.flowable.platform.expressions.FlowableExpressionCollectionUtils
-
public class FlowableExpressionCollectionUtils extends Object
Expression Bean Name: flwCollectionUtils Offers utilities to work withCollection
s (List
s,Set
s etc.) as well asMap
s.
-
-
Constructor Summary
Constructors Constructor Description FlowableExpressionCollectionUtils(CmmnRuntimeService cmmnRuntimeService, RuntimeService runtimeService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description com.fasterxml.jackson.databind.JsonNode
addVariable(Object planItemOrExecution, String baseVariableName, String variableName, Object variableValue)
adds a variable to a case (planItem) or process (execution) if the baseVariable (e.g.protected com.fasterxml.jackson.databind.JsonNode
addVariableToExecution(Execution execution, String baseVariableName, String variableName, Object variableValue)
protected com.fasterxml.jackson.databind.JsonNode
addVariableToNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, com.fasterxml.jackson.databind.node.ObjectNode existingVariableNode, String nestedVariableName, Object variableValue)
protected com.fasterxml.jackson.databind.JsonNode
addVariableToObjectNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName, Object variableValue)
protected com.fasterxml.jackson.databind.JsonNode
addVariableToPlanItem(PlanItemInstance planItemInstance, String baseVariableName, String variableName, Object variableValue)
protected com.fasterxml.jackson.databind.node.ObjectNode
checkNode(Object jsonNode)
protected com.fasterxml.jackson.databind.JsonNode
createSubNodes(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String[] nestedVariableNames, Object variableValue, int index)
protected com.fasterxml.jackson.databind.node.ObjectNode
createTopNodeIfNotExists(PlanItemInstance planItemInstance, String baseVariableName)
protected com.fasterxml.jackson.databind.node.ObjectNode
createTopNodeIfNotExists(Execution execution, String baseVariableName)
protected com.fasterxml.jackson.databind.JsonNode
createVariableNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName, Object variableValue)
<T> List<T>
distinct(Collection<T> collection)
Deletes all duplicates from a list while retaining order.List
emptyList()
Creates a new list, for instance to be used in an Initialize Variables Service Task.Map
emptyMap()
Creates a new map, for instance to be used in an Initialize Variables Service Task.com.fasterxml.jackson.databind.JsonNode
emptyNode()
<T> List<T>
extractValues(Iterable iterable, String variableName)
Extracts a single variable/element from a collection and stores in a flattened list.protected com.fasterxml.jackson.databind.node.ObjectNode
getEmptyNode()
protected boolean
isNotExisting(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName)
<T> List<T>
listWithElements(T... elements)
Creates a new list with as many elements as desired.<T> List<T>
mergeCollections(Collection<T>... collections)
Merges several collections into a list.<K,V>
Map<K,V>updateMap(Map<K,V> map, K key, V newValue)
Inserts or updates a value depending on whether it exists or not and returns the updated map.
-
-
-
Field Detail
-
REGEX_DOT
public static final String REGEX_DOT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FlowableExpressionCollectionUtils
public FlowableExpressionCollectionUtils(CmmnRuntimeService cmmnRuntimeService, RuntimeService runtimeService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Detail
-
addVariable
public com.fasterxml.jackson.databind.JsonNode addVariable(Object planItemOrExecution, String baseVariableName, String variableName, Object variableValue)
adds a variable to a case (planItem) or process (execution) if the baseVariable (e.g. root.test) does not exist, it will be created and the variable added- Parameters:
planItemOrExecution
- can be the case instance (planItemInstance) or the process instance (execution)baseVariableName
- base variable in within the instance (e.g. root.test would be just 'test')variableName
- variable name that should be addedvariableValue
- variable value of the variable- Returns:
- returns a JsonNode with the added variable
-
emptyNode
public com.fasterxml.jackson.databind.JsonNode emptyNode()
-
addVariableToExecution
protected com.fasterxml.jackson.databind.JsonNode addVariableToExecution(Execution execution, String baseVariableName, String variableName, Object variableValue)
-
addVariableToPlanItem
protected com.fasterxml.jackson.databind.JsonNode addVariableToPlanItem(PlanItemInstance planItemInstance, String baseVariableName, String variableName, Object variableValue)
-
createTopNodeIfNotExists
protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists(PlanItemInstance planItemInstance, String baseVariableName)
-
createTopNodeIfNotExists
protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists(Execution execution, String baseVariableName)
-
createSubNodes
protected com.fasterxml.jackson.databind.JsonNode createSubNodes(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String[] nestedVariableNames, Object variableValue, int index)
-
createVariableNode
protected com.fasterxml.jackson.databind.JsonNode createVariableNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName, Object variableValue)
-
addVariableToNode
protected com.fasterxml.jackson.databind.JsonNode addVariableToNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, com.fasterxml.jackson.databind.node.ObjectNode existingVariableNode, String nestedVariableName, Object variableValue)
-
isNotExisting
protected boolean isNotExisting(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName)
-
addVariableToObjectNode
protected com.fasterxml.jackson.databind.JsonNode addVariableToObjectNode(com.fasterxml.jackson.databind.node.ObjectNode objectNode, String nestedVariableName, Object variableValue)
-
getEmptyNode
protected com.fasterxml.jackson.databind.node.ObjectNode getEmptyNode()
-
checkNode
protected com.fasterxml.jackson.databind.node.ObjectNode checkNode(Object jsonNode)
-
emptyList
public List emptyList()
Creates a new list, for instance to be used in an Initialize Variables Service Task. Example: #{flwCollectionUtils.emptyList()}- Returns:
- An empty
List
-
emptyMap
public Map emptyMap()
Creates a new map, for instance to be used in an Initialize Variables Service Task. Example: #{flwCollectionUtils.emptyMap()}- Returns:
- An empty
Map
-
listWithElements
@SafeVarargs public final <T> List<T> listWithElements(T... elements)
Creates a new list with as many elements as desired. Example: #{flwCollectionUtils.listWithElements('green', 'yellow', 'red')}- Type Parameters:
T
- the type of the list- Parameters:
elements
- the elements to add to the new collection- Returns:
- A new list with the given elements
-
mergeCollections
@SafeVarargs public final <T> List<T> mergeCollections(Collection<T>... collections)
Merges several collections into a list. #{flwCollectionUtils.mergeCollections(candidateGroupIds, newGroups)}- Type Parameters:
T
- type of the collection- Parameters:
collections
- collections to be merged- Returns:
- The merged collections
-
distinct
public <T> List<T> distinct(Collection<T> collection)
Deletes all duplicates from a list while retaining order. Example: #{flwCollectionUtils.distinct(myListWithDuplicates)}- Type Parameters:
T
- type of the list- Parameters:
collection
- the base collection- Returns:
- List without any duplicates
-
extractValues
public <T> List<T> extractValues(Iterable iterable, String variableName)
Extracts a single variable/element from a collection and stores in a flattened list. The following types are supported: - VariableContainer (e.g. executions, case instances, data objects) - JSON ObjectNode - Map- Type Parameters:
T
- The type of the output variable- Parameters:
iterable
- An iterable (JSON array, lists etc.) containing VariableContainers, ObjectNodes or MapsvariableName
- The name of the variable to extract- Returns:
- A list of extracted values
-
updateMap
public <K,V> Map<K,V> updateMap(Map<K,V> map, K key, V newValue)
Inserts or updates a value depending on whether it exists or not and returns the updated map.- Type Parameters:
K
- the type of the keyV
- the type of the value- Parameters:
map
- the map to be updatedkey
- the key within the map to be updatednewValue
- the new value- Returns:
- The updated map
-
-