Class ProductTypeSync
- java.lang.Object
-
- com.commercetools.sync.commons.BaseSync<io.sphere.sdk.producttypes.ProductTypeDraft,io.sphere.sdk.producttypes.ProductType,ProductTypeSyncStatistics,ProductTypeSyncOptions>
-
- com.commercetools.sync.producttypes.ProductTypeSync
-
public class ProductTypeSync extends BaseSync<io.sphere.sdk.producttypes.ProductTypeDraft,io.sphere.sdk.producttypes.ProductType,ProductTypeSyncStatistics,ProductTypeSyncOptions>
This class syncs product type drafts with the corresponding product types in the CTP project.
-
-
Field Summary
-
Fields inherited from class com.commercetools.sync.commons.BaseSync
statistics, syncOptions
-
-
Constructor Summary
Constructors Constructor Description ProductTypeSync(ProductTypeSyncOptions productTypeSyncOptions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics>process(java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> productTypeDrafts)Iterates through the wholeproductTypeDraftslist and accumulates its valid drafts to batches.protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics>processBatch(java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> batch)This method first creates a newSetof validProductTypeDraftelements.-
Methods inherited from class com.commercetools.sync.commons.BaseSync
executeSupplierIfConcurrentModificationException, getStatistics, getSyncOptions, handleError, sync, syncBatches
-
-
-
-
Constructor Detail
-
ProductTypeSync
public ProductTypeSync(@Nonnull ProductTypeSyncOptions productTypeSyncOptions)
-
-
Method Detail
-
process
protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics> process(@Nonnull java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> productTypeDrafts)
Iterates through the wholeproductTypeDraftslist 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.producttypes.ProductTypeDraft,io.sphere.sdk.producttypes.ProductType,ProductTypeSyncStatistics,ProductTypeSyncOptions>- Parameters:
productTypeDrafts-ListofProductTypeDraft's that would be synced into CTP project.- Returns:
CompletionStagewithProductTypeSyncStatisticsholding statistics of all sync processes performed by this sync instance.
-
processBatch
protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics> processBatch(@Nonnull java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft> batch)
This method first creates a newSetof validProductTypeDraftelements. For more on the rules of validation, check:ProductTypeBatchValidator.validateAndCollectReferencedKeys(java.util.List<io.sphere.sdk.producttypes.ProductTypeDraft>). Using the resulting set ofvalidProductTypeDrafts, the matching productTypes in the target CTP project are fetched then the methodsyncBatch(Set, Set, Map)is called to perform the sync (update or create requests accordingly) on the target project.After the batch is synced, the method resolves all missing nested references that could have been created after execution of sync of batch. For more info check
resolveMissingNestedReferences(Map).In case of error during of fetching of existing productTypes, the error callback will be triggered. And the sync process would stop for the given batch.
- Specified by:
processBatchin classBaseSync<io.sphere.sdk.producttypes.ProductTypeDraft,io.sphere.sdk.producttypes.ProductType,ProductTypeSyncStatistics,ProductTypeSyncOptions>- Parameters:
batch- batch of drafts that need to be synced- Returns:
- a
CompletionStagecontaining an instance ofProductTypeSyncStatisticswhich contains information about the result of syncing the supplied batch to the target project.
-
-