Class FlowableExpressionCollectionUtils

java.lang.Object
com.flowable.platform.expressions.FlowableExpressionCollectionUtils

public class FlowableExpressionCollectionUtils extends Object
Expression Bean Name: flwCollectionUtils Offers utilities to work with Collections (Lists, Sets etc.) as well as Maps.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    FlowableExpressionCollectionUtils(org.flowable.cmmn.api.CmmnRuntimeService cmmnRuntimeService, org.flowable.engine.RuntimeService runtimeService, tools.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.json.VariableJsonMapper variableJsonMapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    addVariableToExecution(org.flowable.engine.runtime.Execution execution, String baseVariableName, String variableName, Object variableValue)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    addVariableToNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, org.flowable.common.engine.impl.json.FlowableObjectNode existingVariableNode, String nestedVariableName, Object variableValue)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    addVariableToObjectNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName, Object variableValue)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    addVariableToPlanItem(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, String baseVariableName, String variableName, Object variableValue)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    checkNode(Object jsonNode)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    createSubNodes(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String[] nestedVariableNames, Object variableValue, int index)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    createTopNodeIfNotExists(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, String baseVariableName)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    createTopNodeIfNotExists(org.flowable.engine.runtime.Execution execution, String baseVariableName)
     
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
    createVariableNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName, Object variableValue)
     
    <T> List<T>
    distinct(Collection<T> collection)
    Deletes all duplicates from a list while retaining order.
    Creates a new list, for instance to be used in an Initialize Variables Service Task.
    Creates a new map, for instance to be used in an Initialize Variables Service Task.
     
    <T> List<T>
    extractValues(Iterable iterable, String variableName)
    Extracts a single variable/element from a collection and stores in a flattened list.
    protected org.flowable.common.engine.impl.json.FlowableObjectNode
     
    static Object
    getRawValue(org.flowable.common.engine.impl.json.FlowableJsonNode jsonNode)
     
    protected boolean
    isNotExisting(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName)
     
    final <T> List<T>
    listWithElements(T... elements)
    Creates a new list with as many elements as desired.
    final <T> List<T>
    mergeCollections(Collection<T>... collections)
    Merges several collections into a list.
    protected void
    nullSafeSet(org.flowable.common.engine.impl.json.FlowableObjectNode jsonNode, String fieldName, Object value)
     
    <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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • FlowableExpressionCollectionUtils

      public FlowableExpressionCollectionUtils(org.flowable.cmmn.api.CmmnRuntimeService cmmnRuntimeService, org.flowable.engine.RuntimeService runtimeService, tools.jackson.databind.ObjectMapper objectMapper, org.flowable.common.engine.impl.json.VariableJsonMapper variableJsonMapper)
  • Method Details

    • addVariable

      public Object 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 added
      variableValue - variable value of the variable
      Returns:
      returns a JsonNode with the added variable
    • emptyNode

      public Object emptyNode()
    • addVariableToExecution

      protected org.flowable.common.engine.impl.json.FlowableObjectNode addVariableToExecution(org.flowable.engine.runtime.Execution execution, String baseVariableName, String variableName, Object variableValue)
    • addVariableToPlanItem

      protected org.flowable.common.engine.impl.json.FlowableObjectNode addVariableToPlanItem(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, String baseVariableName, String variableName, Object variableValue)
    • createTopNodeIfNotExists

      protected org.flowable.common.engine.impl.json.FlowableObjectNode createTopNodeIfNotExists(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, String baseVariableName)
    • createTopNodeIfNotExists

      protected org.flowable.common.engine.impl.json.FlowableObjectNode createTopNodeIfNotExists(org.flowable.engine.runtime.Execution execution, String baseVariableName)
    • createSubNodes

      protected org.flowable.common.engine.impl.json.FlowableObjectNode createSubNodes(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String[] nestedVariableNames, Object variableValue, int index)
    • createVariableNode

      protected org.flowable.common.engine.impl.json.FlowableObjectNode createVariableNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName, Object variableValue)
    • addVariableToNode

      protected org.flowable.common.engine.impl.json.FlowableObjectNode addVariableToNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, org.flowable.common.engine.impl.json.FlowableObjectNode existingVariableNode, String nestedVariableName, Object variableValue)
    • isNotExisting

      protected boolean isNotExisting(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName)
    • addVariableToObjectNode

      protected org.flowable.common.engine.impl.json.FlowableObjectNode addVariableToObjectNode(org.flowable.common.engine.impl.json.FlowableObjectNode objectNode, String nestedVariableName, Object variableValue)
    • getEmptyNode

      protected org.flowable.common.engine.impl.json.FlowableObjectNode getEmptyNode()
    • checkNode

      protected org.flowable.common.engine.impl.json.FlowableObjectNode 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 Maps
      variableName - 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 key
      V - the type of the value
      Parameters:
      map - the map to be updated
      key - the key within the map to be updated
      newValue - the new value
      Returns:
      The updated map
    • nullSafeSet

      protected void nullSafeSet(org.flowable.common.engine.impl.json.FlowableObjectNode jsonNode, String fieldName, Object value)
    • getRawValue

      public static Object getRawValue(org.flowable.common.engine.impl.json.FlowableJsonNode jsonNode)