Class UpdatePricesImportBatchHandler

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

public class UpdatePricesImportBatchHandler extends com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
Updates the product and variant prices. The "sku" column is required.
Author:
Dima Myroniuk (dmyroniuk)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    UpdatePricesImportBatchHandler(com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator, ProductService<Product> productService, VariantService<Variant> variantService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canHandle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
     
     
    protected static String
     
    protected static String
     
    protected com.fasterxml.jackson.databind.ObjectMapper
     
     
    protected static String
     
     
    protected Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord>
    groupRecordsBySku(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)
     
    com.broadleafcommerce.common.dataimport.messaging.BatchCompletion
    handle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
    Updates the product and variant prices.
    protected void
    updateProductPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus)
    Updates the product prices.
    protected void
    updateVariantPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus)
    Updates the variant prices.

    Methods inherited from class com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler

    addFailedConversionCompletions, buildAndAddCompletionRecords, buildContextInfo, buildCreateContextInfo, buildNonValidationErrorCompletions, buildReadContextInfo, buildSuccessfulCompletionsForRequest, buildUpdateContextInfo, buildValidationErrorCompletions, failRecordAndDependentsEarly, generateAndAddCompletions, generateAndAddCompletions, generateAndAddValidationErrorCompletions, getCompletionError, getFormattedEmbeddedValidationErrorString, getFormattedValidationErrorString, getHydrator, persist, persist, removeAndReturnFieldErrorsUnderPath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • UpdatePricesImportBatchHandler

      public UpdatePricesImportBatchHandler(com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator, ProductService<Product> productService, VariantService<Variant> variantService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
  • Method Details

    • canHandle

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

      @SuppressNotification("SINGLE_INDEX_REQUEST") public com.broadleafcommerce.common.dataimport.messaging.BatchCompletion handle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
      Updates the product and variant prices. If the batch contains records with duplicate SKUs, the records will be processed only once, and other records will be marked as invalid. If there are no products or variants with the specified SKU the records will be marked as invalid.
      Parameters:
      batch - a batch of records that this handler should deal with
      Returns:
      the result of handling a batch
    • groupRecordsBySku

      protected Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> groupRecordsBySku(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)
    • updateProductPrices

      protected void updateProductPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus)
      Updates the product prices. Note: This method removes the processed records from the "recordBySkus" map. This is needed to track the unprocessed records.
      Parameters:
      batch - a batch of records that this handler should deal with
      allCompletions - contains completed records
      recordBySkus - the map of the records grouped by the sku
    • updateVariantPrices

      protected void updateVariantPrices(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions, Map<String,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> recordBySkus)
      Updates the variant prices. Note: This method removes the processed records from the "recordBySkus" map. This is needed to track the unprocessed records.
      Parameters:
      batch - a batch of records that this handler should deal with
      allCompletions - contains completed records
      recordBySkus - the map of the records grouped by the sku
    • getDataRouteKey

      public String getDataRouteKey()
    • getDUPLICATE_SKU_ERROR

      protected static String getDUPLICATE_SKU_ERROR()
    • getNOT_PROCESSED_RECORD

      protected static String getNOT_PROCESSED_RECORD()
    • getSKU

      protected static String getSKU()
    • getProductService

      protected ProductService<Product> getProductService()
    • getVariantService

      protected VariantService<Variant> getVariantService()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()