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 Details

  • Constructor Details

    • FlowableExpressionCollectionUtils

      public FlowableExpressionCollectionUtils(CmmnRuntimeService cmmnRuntimeService, RuntimeService runtimeService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • 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 added
      variableValue - 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 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