Package com.commercetools.sync.customers
Class CustomerSync
- java.lang.Object
-
- com.commercetools.sync.commons.BaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>
-
- com.commercetools.sync.customers.CustomerSync
-
public class CustomerSync extends BaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>
This class syncs customer drafts with the corresponding customers in the CTP project.
-
-
Field Summary
-
Fields inherited from class com.commercetools.sync.commons.BaseSync
statistics, syncOptions
-
-
Constructor Summary
Constructors Modifier Constructor Description CustomerSync(CustomerSyncOptions customerSyncOptions)Takes aCustomerSyncOptionsto instantiate a newCustomerSyncinstance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncinstance.protectedCustomerSync(CustomerSyncOptions customerSyncOptions, CustomerService customerService, TypeService typeService, CustomerGroupService customerGroupService)Takes aCustomerSyncOptionsand service instances to instantiate a newCustomerSyncinstance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncOptionsinstance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.CompletionStage<CustomerSyncStatistics>process(java.util.List<io.sphere.sdk.customers.CustomerDraft> customerDrafts)Iterates through the wholecustomerDraftslist and accumulates its valid drafts to batches.protected java.util.concurrent.CompletionStage<CustomerSyncStatistics>processBatch(java.util.List<io.sphere.sdk.customers.CustomerDraft> batch)-
Methods inherited from class com.commercetools.sync.commons.BaseSync
executeSupplierIfConcurrentModificationException, getStatistics, getSyncOptions, handleError, sync, syncBatches
-
-
-
-
Constructor Detail
-
CustomerSync
public CustomerSync(@Nonnull CustomerSyncOptions customerSyncOptions)Takes aCustomerSyncOptionsto instantiate a newCustomerSyncinstance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncinstance.- Parameters:
customerSyncOptions- the container of all the options of the sync process including the CTP project client and/or configuration and other sync-specific options.
-
CustomerSync
protected CustomerSync(@Nonnull CustomerSyncOptions customerSyncOptions, @Nonnull CustomerService customerService, @Nonnull TypeService typeService, @Nonnull CustomerGroupService customerGroupService)Takes aCustomerSyncOptionsand service instances to instantiate a newCustomerSyncinstance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncOptionsinstance.NOTE: This constructor is mainly to be used for tests where the services can be mocked and passed to.
- Parameters:
customerSyncOptions- the container of all the options of the sync process including the CTP project client and/or configuration and other sync-specific options.customerService- the customer service which is responsible for fetching/caching the Customers from the CTP project.typeService- the type service which is responsible for fetching/caching the Types from the CTP project.customerGroupService- the customer group service which is responsible for fetching/caching the CustomerGroups from the CTP project.
-
-
Method Detail
-
process
protected java.util.concurrent.CompletionStage<CustomerSyncStatistics> process(@Nonnull java.util.List<io.sphere.sdk.customers.CustomerDraft> customerDrafts)
Iterates through the wholecustomerDraftslist and accumulates its valid drafts to batches. Every batch is then processed byprocessBatch(List).Inherited doc: Given a list of resource (e.g. categories, products, etc..) drafts. This method compares each new resource in this list with it's corresponding old resource in a given CTP project, and in turn it either issues update actions on the existing resource if it exists or create it if it doesn't.
- Specified by:
processin classBaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>- Parameters:
customerDrafts-ListofCustomerDraft's that would be synced into CTP project.- Returns:
CompletionStagewithCustomerSyncStatisticsholding statistics of all sync processes performed by this sync instance.
-
processBatch
protected java.util.concurrent.CompletionStage<CustomerSyncStatistics> processBatch(@Nonnull java.util.List<io.sphere.sdk.customers.CustomerDraft> batch)
- Specified by:
processBatchin classBaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>
-
-