Class RecordProcessingUtils

java.lang.Object
com.broadleafcommerce.dataimport.processor.support.RecordProcessingUtils

public final class RecordProcessingUtils extends Object
Utility class containing helpful constants for processing of BatchRecord during reading and parsing.
Author:
Samarth Dhruva (samarthd)
  • Method Details

    • organizeIntoHierarchy

      public static RecordProcessingUtils.OrganizationResponse organizeIntoHierarchy(String importId, List<com.broadleafcommerce.common.dataimport.messaging.BatchRecord> flattenedRecords, Set<String> validBaseRecordTypes, Map<String,Set<String>> recordTypesToDirectDependents)
      The records as read from the file will be a flat list, with dependents directly following their parents. This method will build and return a new list of records where dependents and dependents-of-dependents are in the BatchRecord.dependents of their appropriate parent.

      The original list and elements are not modified, as this method returns a new list that contains newly constructed clones of the original BatchRecords.

      Parameters:
      importId - the import ID for which this is being performed
      flattenedRecords - a list of batch records in a flattened list, with dependents directly following their parents
      validBaseRecordTypes - the record types that are the "root" or "parent-less" types for the given list.
      recordTypesToDirectDependents - a map from record types to their direct dependent record types
      Returns:
      a response containing a new list of dependents, organized into a hierarchy where dependents and dependents-of-dependents are in the BatchRecord.dependents of their appropriate parent. Any invalid records will be reported in the errors.
    • createInvalidRecordTypeErrors

      public static List<BatchItemCompletion> createInvalidRecordTypeErrors(String importId, List<com.broadleafcommerce.common.dataimport.messaging.BatchRecord> invalidRecords)
    • createInvalidRecordTypeError

      public static BatchItemCompletion createInvalidRecordTypeError(String importId, com.broadleafcommerce.common.dataimport.messaging.BatchRecord invalidRecord)