Class CustomerImportBatchHandler
- java.lang.Object
 - 
- com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
 - 
- com.broadleafcommerce.customer.dataimport.CustomerImportBatchHandler
 
 
 
- 
- All Implemented Interfaces:
 com.broadleafcommerce.common.dataimport.ImportBatchHandler
@DataRouteByKey("customer") public class CustomerImportBatchHandler extends com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler- Author:
 - Vitalii Voronkov (vvoronkov)
 
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCustomerImportBatchHandler.ImportTypes 
- 
Constructor Summary
Constructors Constructor Description CustomerImportBatchHandler(CustomerConverter customerConverter, CustomerService<Customer> customerService, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator) 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer>buildPersistenceRequest(String requestedCustomerEmail, org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> requestedCustomerAndBatchRecord, Map<String,Customer> existingCustomersByEmailAddress)Determines id, operation type and builds thePersistenceRequestfor theCustomer.protected List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer>>buildPersistenceRequests(Map<String,org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord>> requestedCustomersByEmailAddress, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Builds the list ofPersistenceRequestsfor the givenCustomers.booleancanHandle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)protected Map<String,org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord>>convertBatchRecords(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> erroredCompletions)Converts all of the batch records in the batch request to customer.protected Optional<Customer>convertToCustomer(com.broadleafcommerce.common.dataimport.messaging.BatchRecord customerRecord, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)protected CustomerConvertergetCustomerConverter()protected CustomerService<Customer>getCustomerService()StringgetDataRouteKey()protected Map<String,Customer>getExistingCustomers(Set<String> customerEmails, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)protected com.broadleafcommerce.common.dataimport.util.IdResolvergetIdResolver()protected com.broadleafcommerce.common.dataimport.util.OperationResolvergetOperationResolver()com.broadleafcommerce.common.dataimport.messaging.BatchCompletionhandle(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch)protected voidpersistPersistenceRequests(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer>> customerRequests, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)Perform a persist of the parsed out domain specified asPersistenceRequests and adds persistence result toallCompletionsprotected voidsetIdResolver(com.broadleafcommerce.common.dataimport.util.IdResolver idResolver)protected voidsetOperationResolver(com.broadleafcommerce.common.dataimport.util.OperationResolver operationResolver)- 
Methods inherited from class com.broadleafcommerce.common.dataimport.AbstractImportBatchHandler
addFailedConversionCompletions, buildAndAddCompletionRecords, buildContextInfo, buildCreateContextInfo, buildNonValidationErrorCompletions, buildReadContextInfo, buildSuccessfulCompletionsForRequest, buildUpdateContextInfo, buildValidationErrorCompletions, generateAndAddCompletions, generateAndAddCompletions, generateAndAddValidationErrorCompletions, getCompletionError, getFormattedEmbeddedValidationErrorString, getFormattedValidationErrorString, getHydrator, persist, removeAndReturnFieldErrorsUnderPath 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
CustomerImportBatchHandler
public CustomerImportBatchHandler(CustomerConverter customerConverter, CustomerService<Customer> customerService, com.broadleafcommerce.data.tracking.core.web.ContextRequestHydrator hydrator)
 
 - 
 
- 
Method Detail
- 
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) 
- 
convertBatchRecords
protected Map<String,org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord>> convertBatchRecords(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> erroredCompletions)
Converts all of the batch records in the batch request to customer.If conversion fails for a record, a
BatchCompletionRecordwill be created for it and added toerroredCompletions, and it will not appear in the converted result.If multiple batch records are attempting to import the same customer email address, all but the first will be considered errored. A
BatchCompletionRecordwill be created for the duplicates and added toerroredCompletions, and they will not appear in the converted result.- Parameters:
 batch- the original record batcherroredCompletions- the list to which any errored completion records should be added- Returns:
 - a map of the converted 
Customerand originalBatchRecordpairs grouped by email address value 
 
- 
buildPersistenceRequests
protected List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer>> buildPersistenceRequests(Map<String,org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord>> requestedCustomersByEmailAddress, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Builds the list ofPersistenceRequestsfor the givenCustomers.This method will query the data-store for existing customers to determine whether each item should be an update or a create.
 
- 
buildPersistenceRequest
protected com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer> buildPersistenceRequest(String requestedCustomerEmail, org.apache.commons.lang3.tuple.Pair<Customer,com.broadleafcommerce.common.dataimport.messaging.BatchRecord> requestedCustomerAndBatchRecord, Map<String,Customer> existingCustomersByEmailAddress)
Determines id, operation type and builds thePersistenceRequestfor theCustomer. 
- 
persistPersistenceRequests
protected void persistPersistenceRequests(com.broadleafcommerce.common.dataimport.messaging.BatchRequest batch, List<com.broadleafcommerce.common.dataimport.util.PersistenceRequest<Customer>> customerRequests, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)Perform a persist of the parsed out domain specified asPersistenceRequests and adds persistence result toallCompletions- Parameters:
 batch- the original record batchcustomerRequests- a list of the customer persistence requestsallCompletions- the list to which the completion records should be added
 
- 
getDataRouteKey
public String getDataRouteKey()
 
- 
convertToCustomer
protected Optional<Customer> convertToCustomer(com.broadleafcommerce.common.dataimport.messaging.BatchRecord customerRecord, List<com.broadleafcommerce.common.dataimport.messaging.BatchCompletionRecord> allCompletions)
 
- 
getExistingCustomers
protected Map<String,Customer> getExistingCustomers(Set<String> customerEmails, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
 
- 
getCustomerConverter
protected CustomerConverter getCustomerConverter()
 
- 
getCustomerService
protected CustomerService<Customer> getCustomerService()
 
- 
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)
 
 - 
 
 -