Class FlowableExpressionCollectionUtils

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

public class FlowableExpressionCollectionUtils
extends java.lang.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 java.lang.String REGEX_DOT  
  • Constructor Summary

    Constructors 
    Constructor Description
    FlowableExpressionCollectionUtils​(org.flowable.cmmn.api.CmmnRuntimeService cmmnRuntimeService, org.flowable.engine.RuntimeService runtimeService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)  
  • Method Summary

    Modifier and Type Method Description
    com.fasterxml.jackson.databind.JsonNode addVariable​(java.lang.Object planItemOrExecution, java.lang.String baseVariableName, java.lang.String variableName, java.lang.Object variableValue)
    adds a variable to a case (planItem) or process (execution) if the baseVariable (e.g.
    protected com.fasterxml.jackson.databind.JsonNode addVariableToExecution​(org.flowable.engine.runtime.Execution execution, java.lang.String baseVariableName, java.lang.String variableName, java.lang.Object variableValue)  
    protected com.fasterxml.jackson.databind.JsonNode addVariableToNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, com.fasterxml.jackson.databind.node.ObjectNode existingVariableNode, java.lang.String nestedVariableName, java.lang.Object variableValue)  
    protected com.fasterxml.jackson.databind.JsonNode addVariableToObjectNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String nestedVariableName, java.lang.Object variableValue)  
    protected com.fasterxml.jackson.databind.JsonNode addVariableToPlanItem​(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, java.lang.String baseVariableName, java.lang.String variableName, java.lang.Object variableValue)  
    protected com.fasterxml.jackson.databind.node.ObjectNode checkNode​(java.lang.Object jsonNode)  
    protected com.fasterxml.jackson.databind.JsonNode createSubNodes​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String[] nestedVariableNames, java.lang.Object variableValue, int index)  
    protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists​(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, java.lang.String baseVariableName)  
    protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists​(org.flowable.engine.runtime.Execution execution, java.lang.String baseVariableName)  
    protected com.fasterxml.jackson.databind.JsonNode createVariableNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String nestedVariableName, java.lang.Object variableValue)  
    <T> java.util.List<T> distinct​(java.util.Collection<T> collection)
    Deletes all duplicates from a list while retaining order.
    java.util.List emptyList()
    Creates a new list, for instance to be used in an Initialize Variables Service Task.
    java.util.Map emptyMap()
    Creates a new map, for instance to be used in an Initialize Variables Service Task.
    com.fasterxml.jackson.databind.JsonNode emptyNode()  
    <T> java.util.List<T> extractValues​(java.lang.Iterable iterable, java.lang.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, java.lang.String nestedVariableName)  
    <T> java.util.List<T> listWithElements​(T... elements)
    Creates a new list with as many elements as desired.
    <T> java.util.List<T> mergeCollections​(java.util.Collection<T>... collections)
    Merges several collections into a list.
    <K,​ V> java.util.Map<K,​V> updateMap​(java.util.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 java.lang.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, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • addVariable

      public com.fasterxml.jackson.databind.JsonNode addVariable​(java.lang.Object planItemOrExecution, java.lang.String baseVariableName, java.lang.String variableName, java.lang.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​(org.flowable.engine.runtime.Execution execution, java.lang.String baseVariableName, java.lang.String variableName, java.lang.Object variableValue)
    • addVariableToPlanItem

      protected com.fasterxml.jackson.databind.JsonNode addVariableToPlanItem​(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, java.lang.String baseVariableName, java.lang.String variableName, java.lang.Object variableValue)
    • createTopNodeIfNotExists

      protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists​(org.flowable.cmmn.api.runtime.PlanItemInstance planItemInstance, java.lang.String baseVariableName)
    • createTopNodeIfNotExists

      protected com.fasterxml.jackson.databind.node.ObjectNode createTopNodeIfNotExists​(org.flowable.engine.runtime.Execution execution, java.lang.String baseVariableName)
    • createSubNodes

      protected com.fasterxml.jackson.databind.JsonNode createSubNodes​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String[] nestedVariableNames, java.lang.Object variableValue, int index)
    • createVariableNode

      protected com.fasterxml.jackson.databind.JsonNode createVariableNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String nestedVariableName, java.lang.Object variableValue)
    • addVariableToNode

      protected com.fasterxml.jackson.databind.JsonNode addVariableToNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, com.fasterxml.jackson.databind.node.ObjectNode existingVariableNode, java.lang.String nestedVariableName, java.lang.Object variableValue)
    • isNotExisting

      protected boolean isNotExisting​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String nestedVariableName)
    • addVariableToObjectNode

      protected com.fasterxml.jackson.databind.JsonNode addVariableToObjectNode​(com.fasterxml.jackson.databind.node.ObjectNode objectNode, java.lang.String nestedVariableName, java.lang.Object variableValue)
    • getEmptyNode

      protected com.fasterxml.jackson.databind.node.ObjectNode getEmptyNode()
    • checkNode

      protected com.fasterxml.jackson.databind.node.ObjectNode checkNode​(java.lang.Object jsonNode)
    • emptyList

      public java.util.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 java.util.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> java.util.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> java.util.List<T> mergeCollections​(java.util.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> java.util.List<T> distinct​(java.util.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> java.util.List<T> extractValues​(java.lang.Iterable iterable, java.lang.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> java.util.Map<K,​V> updateMap​(java.util.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