Class ProductImportBatchHandler

java.lang.Object
com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
com.broadleafcommerce.catalog.dataimport.ProductImportBatchHandler
All Implemented Interfaces:
com.broadleafcommerce.common.dataimport.ImportBatchHandler

@Deprecated @DataRouteByKey("catalog") public class ProductImportBatchHandler extends com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
Deprecated.
Author:
Phillip Verheyden (phillipuniverse)
See Also:
  • Constructor Details

  • Method Details

    • canHandle

      public boolean canHandle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
      Deprecated.
    • handle

      @SuppressNotification("SINGLE_INDEX_REQUEST") public com.broadleafcommerce.common.dataimport.messaging.BatchCompletion handle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
      Deprecated.
    • setProductTypeBasedOnRecord

      protected void setProductTypeBasedOnRecord(Product product, com.broadleafcommerce.common.dataimport.messaging.BatchRecord productRecord)
      Deprecated.
      Set Product.getProductType() based on whether or not the given BatchRecord for product has any variants. If it does, Product.getProductType() is set to VARIANT_BASED. Otherwise, STANDARD. This way, the Product.getProductType() wouldn't need to be explicitly declared.

      The Product.getProductType() should only be set if the BatchRecord.getOperation() is CREATE, since Product.getProductType() should never be changed once it's set.

      Parameters:
      product - product created from the BatchRecord
      productRecord - BatchRecord for the product
    • clearEmptyEmbeddedItems

      protected void clearEmptyEmbeddedItems(Product product)
      Deprecated.
      In the case where a product is being updated and no embedded items are specified (ex: a simple product name update wouldn't include product option rows), the collections may have a non-null empty value. This would cause the items to be removed from the product. Instead, this method sets those fields directly to null, preventing CrudEntityService.updateAllAllowingPartialSuccess(List, ContextInfo) from updating them.
      Parameters:
      product - the product being updated, with any embedded items already set
    • getDataRouteKey

      public String getDataRouteKey()
      Deprecated.
    • processVariantRecord

      protected void processVariantRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord variantRecord, String parentProductResourceId, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Variant>> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
    • initializeVariantAndBuildPersistenceRequest

      protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Variant> initializeVariantAndBuildPersistenceRequest(Variant variant, com.broadleafcommerce.common.dataimport.messaging.BatchRecord variantRecord, String parentProductResourceId)
      Deprecated.
    • processCategoryProductRecord

      protected void processCategoryProductRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord categoryProductRecord, String parentProductResourceId, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<CategoryProduct>> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
    • processProductTagRecord

      protected void processProductTagRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord productTagRecord, String parentProductResourceId, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<ProductTag>> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
    • initializeCategoryProductAndBuildPersistenceRequest

      protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<CategoryProduct> initializeCategoryProductAndBuildPersistenceRequest(CategoryProduct categoryProduct, com.broadleafcommerce.common.dataimport.messaging.BatchRecord categoryProductRecord, String parentProductResourceId)
      Deprecated.
    • initializeProductTagAndBuildPersistenceRequest

      protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<ProductTag> initializeProductTagAndBuildPersistenceRequest(ProductTag productTag, com.broadleafcommerce.common.dataimport.messaging.BatchRecord productTagRecord, String parentProductResourceID)
      Deprecated.
    • processProductAssetRecord

      protected void processProductAssetRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord productAssetRecord, String parentProductResourceId, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<ProductAsset>> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed, com.broadleafcommerce.common.dataimport.messaging.BatchRequest.BatchContext context)
      Deprecated.
    • initializeProductAssetAndBuildPersistenceRequest

      protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<ProductAsset> initializeProductAssetAndBuildPersistenceRequest(ProductAsset productAsset, com.broadleafcommerce.common.dataimport.messaging.BatchRecord productAssetRecord, String productResourceId, com.broadleafcommerce.common.dataimport.messaging.BatchRequest.BatchContext context)
      Deprecated.
    • processIncludedProductRecord

      protected void processIncludedProductRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord includedProductRecord, Product parent, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest.EmbeddedItemRequest> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
    • processOptionRecord

      protected void processOptionRecord(com.broadleafcommerce.common.dataimport.messaging.BatchRecord optionRecord, Product parent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest.EmbeddedItemRequest> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
    • overrideChangeContainerForChildOfProduct

      protected void overrideChangeContainerForChildOfProduct(String parentProductResourceId, com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable child)
      Deprecated.
      Sets the override change container for the child of product with the container ID as the parent Product ID, the container name as the Product container name, and the sub container name as the child's container name.
      Parameters:
      parentProductResourceId - the parent product ID
      child - the overridable child
    • containsNonBlankValueForKey

      protected boolean containsNonBlankValueForKey(String key, Map<String,String> map)
      Deprecated.
    • addOptionToProductFromTemplate

      protected void addOptionToProductFromTemplate(String correlationId, String optionTemplateId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Product productToAddOptionTo, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest.EmbeddedItemRequest> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
      Finds the option template in the data store, and adds its option to the given product (the product is not yet persisted with this change).

      If the template was successfully found and the option was added to the product, a new PersistenceRequest.EmbeddedItemRequest will be created and added to the successful.

      If the option template could not be found, a BatchCompletionRecord will be created for the record and added to the failed. The product is not modified in this case.

      Parameters:
      correlationId - the correlation ID of the record requesting the options
      optionTemplateId - the ID of the option template to find
      contextInfo - read context to use for finding the option template in the data store
      productToAddOptionTo - the product to which the template's option should be added
      successful - a list of the product's embedded item requests to which the option will be added if successfully found
      failed - a list of batch completion records to which the option will be added if not successfully found
    • findOptionTemplate

      @Nullable protected OptionTemplate findOptionTemplate(String optionTemplateId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
    • addOptionsToProductFromTemplateGroup

      protected void addOptionsToProductFromTemplateGroup(String correlationId, String optionTemplateGroupId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Product productToAddOptionsTo, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest.EmbeddedItemRequest> successful, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
      Finds the option template group in the data store, finds each of the group's templates in the data store, and adds each of their options to the given product (the product is not yet persisted with this change).

      If the template group was successfully found and the options from its templates were added to the product, a new PersistenceRequest.EmbeddedItemRequest will be created and added to the successful. Note that this will be a single PersistenceRequest.EmbeddedItemRequest that represents all of the added options. This is because the options do not have their own correlation IDs (since all of them are tied to a single BatchRecord in the file). They all come from the same row, and thus tracing success/failure of each option is not possible. This is fine, since theoretically any options that come from a template should already be validated and not have individual errors anyways.

      If the group could not be found, a BatchCompletionRecord will be created for the record and added to the failed. Again, this will be a single completion record for the reasons explained before. The product is not modified in this case.

      Parameters:
      correlationId - the correlation ID of the record requesting the options
      optionTemplateGroupId - the ID of the option template group to find
      contextInfo - read context to use for finding the option template group and its templates in the data store
      productToAddOptionsTo - the product to which the options from all of the group's templates should be added
      successful - a list of the product's embedded item requests to which this record will be added if successfully found
      failed - a list of batch completion records to which this record will be added if not successfully found
    • findOptionTemplateGroup

      @Nullable protected OptionTemplateGroup findOptionTemplateGroup(String optionTemplateGroupId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated.
    • generateEmbeddedItemRequestsAndUpdateParent

      protected List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest.EmbeddedItemRequest> generateEmbeddedItemRequestsAndUpdateParent(List<com.broadleafcommerce.common.dataimport.messaging.BatchRecord> embeddedItemRecords, ProductOption parent, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> failed)
      Deprecated.
      This method is responsible for generating the nested embedded item requests for a particular product option batch record. This will produce a list of PersistenceRequest.EmbeddedItemRequest for any specific choice or allowed value records that are under this option. Furthermore, the successfully converted values will be set on the parent.
      Parameters:
      embeddedItemRecords - the dependent records of an option who need to be converted and set on the parent
      parent - the product option on which the converted values should be set
      failed - if there is a conversion failure, an error completion will be generated for the record and added to this list
      Returns:
      a list of embedded item requests for nested dependents of this option record (only those which are successfully converted)
    • setAttributeChoiceAllowedValues

      protected void setAttributeChoiceAllowedValues(ProductOption productOption, List<AttributeChoiceValue> allowedValues)
      Deprecated.
    • setItemChoiceSpecificChoices

      protected void setItemChoiceSpecificChoices(ProductOption productOption, List<SpecificItemChoice> specificItemChoices)
      Deprecated.
    • removeDependentsOfFailedParents

      protected <T> List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> removeDependentsOfFailedParents(Map<String,String> failedParentCorrelationIdsByResourceId, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<T>> dependentRequests, Function<T,String> idExtractor, Function<T,String> parentIdExtractor)
      Deprecated.
      Finds and removes any dependent persistence requests from dependentRequests which refer to a "parent" item which was not successfully persisted. For each of these removed requests, a BatchCompletionRecord is created. These are collected in a list and returned.
      Parameters:
      failedParentCorrelationIdsByResourceId - a map of resource IDs to correlation IDs of "parent" items which could not be successfully persisted
      dependentRequests - all of the persistence requests who may potentially have references to the failed parent items
      idExtractor - a function which can retrieve the resource ID from any given dependent request entity
      parentIdExtractor - a function which can retrieve the parent resource ID reference from any given dependent request entity
      Returns:
      a list of BatchCompletionRecord with BatchCompletionRecordStatus.ERROR for the dependent requests which referred to a failed parent
    • getNonPersistableDependents

      protected <T> Set<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<T>> getNonPersistableDependents(Set<String> resourceIdsOfFailedParents, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<T>> dependentRequests, Function<T,String> parentIdExtractor)
      Deprecated.
      We do not want to even attempt to persist requests which reference a parent item that was not successfully persisted. This method iterates through the dependentRequests, finding those who refer to a parent item which failed. These are collected and returned.
      Parameters:
      resourceIdsOfFailedParents - the resource IDs of "parent" items which could not be successfully persisted
      dependentRequests - all of the persistence requests who may potentially have references to the failed parent items
      parentIdExtractor - a function which can retrieve the parent resource ID reference from any given dependent request entity
      Returns:
      the set of PersistenceRequest which referred to a failed product
    • getProductConverter

      protected ProductConverter getProductConverter()
      Deprecated.
    • getVariantConverter

      protected VariantConverter getVariantConverter()
      Deprecated.
    • getIncludedProductConverter

      protected IncludedProductConverter getIncludedProductConverter()
      Deprecated.
    • getProductOptionConverter

      protected ProductOptionConverter getProductOptionConverter()
      Deprecated.
    • getAttributeChoiceValueConverter

      protected AttributeChoiceValueConverter getAttributeChoiceValueConverter()
      Deprecated.
    • getSpecificItemChoiceConverter

      protected SpecificItemChoiceConverter getSpecificItemChoiceConverter()
      Deprecated.
    • getCategoryProductConverter

      protected CategoryProductConverter getCategoryProductConverter()
      Deprecated.
    • getProductAssetConverter

      protected ProductAssetConverter getProductAssetConverter()
      Deprecated.
    • getProductTagConverter

      protected ProductTagConverter getProductTagConverter()
      Deprecated.
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
      Deprecated.
    • getProductService

      protected ProductService<Product> getProductService()
      Deprecated.
    • getVariantService

      protected VariantService<Variant> getVariantService()
      Deprecated.
    • getProductAssetService

      protected ProductAssetService<ProductAsset> getProductAssetService()
      Deprecated.
    • getCategoryProductService

      protected CategoryProductService<CategoryProduct> getCategoryProductService()
      Deprecated.
    • getOptionTemplateGroupService

      protected OptionTemplateGroupService<OptionTemplateGroup> getOptionTemplateGroupService()
      Deprecated.
    • getOptionTemplateService

      protected OptionTemplateService<OptionTemplate> getOptionTemplateService()
      Deprecated.
    • getProductTagService

      protected ProductTagService<ProductTag> getProductTagService()
      Deprecated.
    • getIdResolver

      protected com.broadleafcommerce.common.dataimport.util.IdResolver getIdResolver()
      Deprecated.
    • setIdResolver

      protected void setIdResolver(com.broadleafcommerce.common.dataimport.util.IdResolver idResolver)
      Deprecated.
    • getOperationResolver

      protected com.broadleafcommerce.common.dataimport.util.OperationResolver getOperationResolver()
      Deprecated.
    • setOperationResolver

      protected void setOperationResolver(com.broadleafcommerce.common.dataimport.util.OperationResolver operationResolver)
      Deprecated.