Class CorrelationIdUtil

java.lang.Object
com.broadleafcommerce.common.dataimport.util.CorrelationIdUtil

public final class CorrelationIdUtil extends Object
By default, this detects correlation id values that ends with () and optionally tokenized by | for columns that can contain multiple correlation ids
Author:
Phillip Verheyden (phillipuniverse)
  • Field Details

  • Method Details

    • parseCorrelationIds

      public static List<String> parseCorrelationIds(@Nullable String value)

      Given a column that can contain correlation id references, returns only the correlation id(s) that are within the column. If there are no correlation ids this will return an empty list. If there is a mix of values (in the case of multiple values embedded within value) this will only return the discovered correlation ids from those values.

      Parameters:
      value - potentially contains correlation ids. Allows muliple values separated by DEFAULT_MULTIVALUE_SEPARATOR
      Returns:
      the correlation ids within the column
      See Also:
    • parseCorrelationIds

      public static List<String> parseCorrelationIds(@Nullable String value, @Nullable String multiValuedSeparator)
      Given a column that can contain correlation id references, returns only the correlation id(s) that are within the column. If there are no correlation ids this will return an empty list. If there is a mix of values (in the case of multiple values embedded within value) this will only return the discovered correlation ids from those values.
      Parameters:
      value - potentially contains correlation ids
      multiValuedSeparator - optional separator column that can split the given value for multiple values. If null, defaults to DEFAULT_MULTIVALUE_SEPARATOR
      Returns:
      the correlation ids within the column
    • correlationIdsFor

      public static List<String> correlationIdsFor(Map<String,String> resolvedRow)
    • replaceWithMappedCorrelationIds

      public static Map<String,String> replaceWithMappedCorrelationIds(Map<String,String> row, UnaryOperator<String> correlationIdToIdentifierResolver)
    • populateCorrelationIds

      @Nullable public static String populateCorrelationIds(@Nullable String value, UnaryOperator<String> correlationIdToIdentifierResolver)
      Replaces the contents of value with the appropriate value from the result of correlationIdToIdentifierResolver. This is flexible enough to only perform the operation if there are correlation ids to begin with contained with value and those correlationIds have corresponding non-null results from the correlationIdToIdentifierResolver.
      Parameters:
      value - what should be inspected and potentially replaced
      correlationIdToIdentifierResolver - given a correlationId, can resolve a resource tier id
      Returns:
      value replaced with the the parsed correlation ids. If value is null, this will also return null. If there are no correlation ids within value, the original is returned unchanged.
    • populateCorrelationIds

      @Nullable public static String populateCorrelationIds(@Nullable String value, @Nullable String multiValuedSeparator, UnaryOperator<String> correlationIdToIdentifierResolver)
      Replaces the contents of value with the appropriate value from the result of correlationIdToIdentifierResolver. This is flexible enough to only perform the operation if there are correlation ids to begin with contained with value and those correlationIds have corresponding non-null results from the correlationIdToIdentifierResolver.
      Parameters:
      value - what should be inspected and potentially replaced
      multiValuedSeparator - if value could contain multiple entries this is the separation between them
      correlationIdToIdentifierResolver - given a correlationId, can resolve a resource tier id
      Returns:
      value replaced with the the parsed correlation ids. If value is null, this will also return null. If there are no correlation ids within value, the original is returned unchanged.