Class RecordProcessingUtils
java.lang.Object
com.broadleafcommerce.dataimport.processor.support.RecordProcessingUtils
Utility class containing helpful constants for processing of
BatchRecord
during reading
and parsing.- Author:
- Samarth Dhruva (samarthd)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A response detailing the results of attempting to organize flattened records into a hierarchy. -
Method Summary
Modifier and TypeMethodDescriptionstatic BatchItemCompletion
createInvalidRecordTypeError
(String importId, com.broadleafcommerce.common.dataimport.messaging.BatchRecord invalidRecord) static List<BatchItemCompletion>
createInvalidRecordTypeErrors
(String importId, List<com.broadleafcommerce.common.dataimport.messaging.BatchRecord> invalidRecords) 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.
-
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 theBatchRecord.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 performedflattenedRecords
- a list of batch records in a flattened list, with dependents directly following their parentsvalidBaseRecordTypes
- 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)
-