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 aCustomerSyncOptions
to instantiate a newCustomerSync
instance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSync
instance.protected
CustomerSync(CustomerSyncOptions customerSyncOptions, CustomerService customerService, TypeService typeService, CustomerGroupService customerGroupService)
Takes aCustomerSyncOptions
and service instances to instantiate a newCustomerSync
instance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncOptions
instance.
-
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 wholecustomerDrafts
list 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 aCustomerSyncOptions
to instantiate a newCustomerSync
instance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSync
instance.- 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 aCustomerSyncOptions
and service instances to instantiate a newCustomerSync
instance that could be used to sync customer drafts in the CTP project specified in the injectedCustomerSyncOptions
instance.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 wholecustomerDrafts
list 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:
process
in classBaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>
- Parameters:
customerDrafts
-List
ofCustomerDraft
's that would be synced into CTP project.- Returns:
CompletionStage
withCustomerSyncStatistics
holding 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:
processBatch
in classBaseSync<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.Customer,CustomerSyncStatistics,CustomerSyncOptions>
-
-