Class SkuInventoryImportBatchHandler

  • All Implemented Interfaces:
    com.broadleafcommerce.common.dataimport.ImportBatchHandler

    @DataRouteByKey("inventory")
    public class SkuInventoryImportBatchHandler
    extends com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
    Author:
    Kelly Tisdell (ktisdell)
    • Method Detail

      • canHandle

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

        public com.broadleafcommerce.common.dataimport.messaging.BatchCompletion handle​(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)
      • buildPersistenceRequests

        protected List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<SkuInventory>> buildPersistenceRequests​(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch,
                                                                                                                               List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> erroredCompletions)
        Builds the list of PersistenceRequest for the SkuInventory. In case error during conversion, adds failed conversion response to the erroredCompletions, otherwise creates and adds the persistence request to the result.
        Parameters:
        batch - the original record batch
        erroredCompletions - the list to which any errored completion records should be added
        Returns:
        the list of PersistenceRequest for the SkuInventory
      • resolveOperationType

        protected com.broadleafcommerce.data.tracking.core.type.OperationType resolveOperationType​(com.broadleafcommerce.common.dataimport.messaging.BatchRecord skuInventoryRecord)
        Resolves operation type for the sku inventory record.
        Parameters:
        skuInventoryRecord - the record represents SkuInventory from file
        Returns:
        type for a change operation
      • initializeSkuInventory

        protected SkuInventory initializeSkuInventory​(String inventoryLocationId,
                                                      com.broadleafcommerce.common.dataimport.messaging.BatchRecord skuInventoryRecord,
                                                      SkuInventory convertedSkuInventory)
        Initializes the defaults on an existing SkuInventory object.
        Parameters:
        inventoryLocationId - the id of the parent inventory location
        skuInventoryRecord - the record represents SkuInventory from file
        convertedSkuInventory - the results of performing the conversion
        Returns:
        instance of SkuInventory with populated properties
      • setVendorRefFromBatchContext

        protected void setVendorRefFromBatchContext​(SkuInventory skuInventory,
                                                    com.broadleafcommerce.common.dataimport.messaging.BatchRequest.BatchContext batchContext)
        Sets the SkuInventory.getVendorRef() from BatchRequest.BatchContext.getVendorRef().

        This is important, as it ensures all changes will only occur within the import's defined vendor (or not in a vendor, if null).

        • ensures any vendorRef value provided for the row within the file is ignored and only the pre-validated vendorRef is used
        • if a row is trying to update a record that currently exists in a different vendor, this will cause the update payload to have a different vendor and will fail the vendor-ref immutability validation in DefaultSkuInventoryService. This guarantees the change will fail.
        • if the specified parent inventory location belongs to a different vendor, the validation in SkuInventoryValidator will fail and the row will be rejected
        Parameters:
        skuInventory - a SkuInventory instance converted from a row in a file
        batchContext - the batch context provided for the import
      • resolveSkuInventoryId

        protected void resolveSkuInventoryId​(com.broadleafcommerce.common.dataimport.messaging.BatchRecord skuInventoryRecord,
                                             SkuInventory skuInventory)
        Resolves and sets the id for SkuInventory.
        Parameters:
        skuInventoryRecord - the record represents SkuInventory from file
        skuInventory - the SkuInventory for which the id should be resolved
      • persistPersistenceRequests

        protected void persistPersistenceRequests​(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch,
                                                  List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<SkuInventory>> skuInventories,
                                                  List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)
        Perform a persist of the parsed out domain specified as PersistenceRequests and adds persistence result to allCompletions
        Parameters:
        batch - the original record batch
        skuInventories - a list of the sku inventory persistence requests
        allCompletions - a list to which the completion records should be added
      • getDataRouteKey

        public String getDataRouteKey()
      • getIdResolver

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

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

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

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