Class CompleteProductImportSpecification

java.lang.Object
com.broadleafcommerce.dataimport.processor.specification.DefaultSpecification
com.broadleafcommerce.dataimport.processor.specification.product.CompleteProductImportSpecification
All Implemented Interfaces:
GlobalImportSpecification, ImportSpecification

public class CompleteProductImportSpecification extends DefaultSpecification implements GlobalImportSpecification
Specification for 'complete product' imports, where the input files are typically defining full new products and variants (and related entities) to create in the data store. As a result, this requires more fields to be provided than a more granular 'update' specification (such as UpdatePricesSpecification) would.

This specification and its corresponding resource-tier handler do support 'updates', but mainly for simple use-cases. Consumers with more complex update use-cases should opt to create separate specifications/batch-handlers for those purposes.

Author:
Kelly Tisdell (ktisdell)
  • Field Details

    • DEFAULT_COMPLETE_PRODUCT_IMPORT_SPECIFICATION_NAME

      public static final String DEFAULT_COMPLETE_PRODUCT_IMPORT_SPECIFICATION_NAME
      See Also:
  • Constructor Details

  • Method Details

    • canHandle

      public boolean canHandle(String importType)
      Description copied from interface: ImportSpecification
      Whether or not this specification can actually handle the given import. Checks will generally be based on the import type.
      Specified by:
      canHandle in interface ImportSpecification
      Overrides:
      canHandle in class DefaultSpecification
      Returns:
      whether or not this specification can actually handle the given import
    • isCatalogDiscriminated

      public boolean isCatalogDiscriminated()
      Description copied from interface: ImportSpecification
      Whether or not the entity is catalog discriminated.
      Specified by:
      isCatalogDiscriminated in interface ImportSpecification
      Returns:
      true if the entity is catalog discriminated or false otherwise
    • isSandboxDiscriminated

      public boolean isSandboxDiscriminated()
      Description copied from interface: ImportSpecification
      Whether or not the entity is sandbox discriminated.
      Specified by:
      isSandboxDiscriminated in interface ImportSpecification
      Returns:
      true if the entity is sandbox discriminated or false otherwise
    • shouldAutoGenerateOperationTypeForEachRecord

      public boolean shouldAutoGenerateOperationTypeForEachRecord(String rowType)
      Description copied from interface: ImportSpecification
      This method describes whether imports processed with this specification should have the BatchRecord.getOperation() eagerly auto-generated by the import service for each record if not explicitly supplied in the input file.

      In situations where the resource tier import handler is expected to automatically recognize which records represent updates and which records represent creates, it makes sense for this method to just return false.

      If this method returns true, then the import service will eagerly guess and set the operation type for each record that does not explicitly provide one. See OperationResolver.

      Specified by:
      shouldAutoGenerateOperationTypeForEachRecord in interface ImportSpecification
      Parameters:
      rowType - the row type for which this method should return a preference. Allows for different behavior for different row types within an import
      Returns:
      whether operation type should be eagerly auto-generated by the import service if not explicitly requested for each record processed for this specification
    • shouldAutoGenerateResourceTierIdForEachRecord

      public boolean shouldAutoGenerateResourceTierIdForEachRecord(String rowType)
      Description copied from interface: ImportSpecification
      This method describes whether imports processed with this specification should have BatchRecord.getResourceTierIdentifier() eagerly auto-generated by the import service for each record if not explicitly supplied in the input file.

      It's possible that an import type has heavy reliance on resource-tier identifiers for entities it imports and expects to deal with those values in the files it accepts. For example, an import may have records creating certain entities, and additional records that reference those entities by resource tier ID. Such a situation is a great candidate for use of correlation IDs, where the input file only provides and references correlation IDs which the import service will eagerly resolve into resource tier identifier values. However, in order to do this, the import service needs to be able to eagerly generate those resource tier IDs (assuming the input file is not expected to provide those directly). For such situations, this method should return true. See IdResolver.

      Conversely, some import types may not expect files to provide resource-tier identifiers or correlation IDs to identify or reference records. They may use a different approach altogether and entirely delegate all ID-related behavior to the resource tier import handler instead. In those cases, eager generation of resource tier IDs by the import service would be undesirable. For such situations, this method should return false.

      Specified by:
      shouldAutoGenerateResourceTierIdForEachRecord in interface ImportSpecification
      Parameters:
      rowType - the row type for which this method should return a preference. Allows for different behavior for different row types within an import
      Returns:
      whether resource tier IDs should be eagerly auto-generated by the import service if not explicitly requested for each record processed for this specification
    • shouldAllowUnmappedHeaders

      public boolean shouldAllowUnmappedHeaders(String rowType)
      Description copied from interface: ImportSpecification
      This method describes whether imports processed with this specification should allow passthrough of headers with no explicit mapping.

      Essentially, when a record is being processed, if there is no explicit header-to-field mapping possible for a given input via ImportSpecification.getHeaderFieldConfigsByRowType(), or via ImportSpecification.mapDynamicHeaderToField(String, String), this method describes the behavior that should be used.

      Some import types may choose to allow such 'unmapped' fields to be passed through with just the raw unmapped header and its corresponding value. For those situations, this method should return true. Other import types may want to intentionally ignore any unmappable headers and exclude them to force strict adherence to the specification. For those, this method should return false.

      Note that 'meta' headers/fields such as DefaultImportProcessor.OPERATION_COLUMN have special meaning and thus may not be affected by this setting. See DefaultImportProcessor to understand how such fields are processed.

      Specified by:
      shouldAllowUnmappedHeaders in interface ImportSpecification
      Parameters:
      rowType - the row type for which this method should return a preference. Allows for different behavior for different row types within an import
      Returns:
      true if unmapped headers should be allowed, else false
    • populateHeaderFieldConfigsByRowType

      protected void populateHeaderFieldConfigsByRowType(Map<String,Map<String,ImportFieldConfig>> headerFieldConfigsByRowType)
      Description copied from class: DefaultSpecification
      This method is always invoked in the constructor - see DefaultSpecification.createUnmodifiableHeaderFieldConfigsByRowType().

      Extensions of this class should override this method and use it to populate the values that they want to ultimately be in DefaultSpecification.getHeaderFieldConfigsByRowType().

      Overrides:
      populateHeaderFieldConfigsByRowType in class DefaultSpecification
      Parameters:
      headerFieldConfigsByRowType - a special, mutable map instance which implementations should populate with field configurations. This map will ultimately be copied into an unmodifiable separate instance that will actually be used for DefaultSpecification.getHeaderFieldConfigsByRowType().
    • initializeDependencyMappings

      protected void initializeDependencyMappings()
    • getInventoryTypeValidator

      protected ImportFieldValidator getInventoryTypeValidator()
    • getInventoryCheckStrategyValidator

      protected ImportFieldValidator getInventoryCheckStrategyValidator()
    • getInventoryReservationStrategyValidator

      protected ImportFieldValidator getInventoryReservationStrategyValidator()
    • getMergingTypeValidator

      protected ImportFieldValidator getMergingTypeValidator()
    • getMoneyValidator

      protected ImportFieldValidator getMoneyValidator()
    • populateDynamicHeaderMappingsByRowType

      protected void populateDynamicHeaderMappingsByRowType(Map<String,List<DynamicHeaderFieldMapping>> dynamicHeaderMappingConfigsByRowType)
      Description copied from class: DefaultSpecification
      This method is always invoked in the constructor - see DefaultSpecification.createUnmodifiableDynamicHeaderMappingsByRowType().

      Extensions of this class should override this method and use it to populate the values that they want to ultimately be in DefaultSpecification.getDynamicHeaderMappingConfigsByRowType().

      Overrides:
      populateDynamicHeaderMappingsByRowType in class DefaultSpecification
      Parameters:
      dynamicHeaderMappingConfigsByRowType - a special, mutable map instance which implementations should populate with dynamic header mappings. This map will ultimately be copied into an unmodifiable separate instance that will actually be used for DefaultSpecification.getDynamicHeaderMappingConfigsByRowType().
    • getImportDataNormalizers

      public List<ImportDataNormalizer> getImportDataNormalizers()
      Description copied from interface: ImportSpecification
      The list of ImportDataNormalizer that will be executed to pre-process the data parsed out from the file.
      Specified by:
      getImportDataNormalizers in interface ImportSpecification
      Returns:
      the list of ImportDataNormalizer