Class ProductTypeSync


  • public class ProductTypeSync
    extends BaseSync<com.commercetools.api.models.product_type.ProductType,​com.commercetools.api.models.product_type.ProductTypeDraft,​com.commercetools.api.models.product_type.ProductTypeUpdateAction,​ProductTypeSyncStatistics,​ProductTypeSyncOptions>
    This class syncs product type drafts with the corresponding product types in the CTP project.
    • Constructor Detail

    • Method Detail

      • process

        protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics> process​(@Nonnull
                                                                                          java.util.List<com.commercetools.api.models.product_type.ProductTypeDraft> productTypeDrafts)
        Iterates through the whole productTypeDrafts list and accumulates its valid drafts to batches. Every batch is then processed by processBatch(java.util.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 class BaseSync<com.commercetools.api.models.product_type.ProductType,​com.commercetools.api.models.product_type.ProductTypeDraft,​com.commercetools.api.models.product_type.ProductTypeUpdateAction,​ProductTypeSyncStatistics,​ProductTypeSyncOptions>
        Parameters:
        productTypeDrafts - List of ProductTypeDraft's that would be synced into CTP project.
        Returns:
        CompletionStage with ProductTypeSyncStatistics holding statistics of all sync processes performed by this sync instance.
      • processBatch

        protected java.util.concurrent.CompletionStage<ProductTypeSyncStatistics> processBatch​(@Nonnull
                                                                                               java.util.List<com.commercetools.api.models.product_type.ProductTypeDraft> batch)
        This method first creates a new Set of valid ProductTypeDraft elements. For more on the rules of validation, check: ProductTypeBatchValidator.validateAndCollectReferencedKeys(java.util.List<com.commercetools.api.models.product_type.ProductTypeDraft>). Using the resulting set of validProductTypeDrafts, the matching productTypes in the target CTP project are fetched then the method syncBatch(java.util.Set, java.util.Set, java.util.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(java.util.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:
        processBatch in class BaseSync<com.commercetools.api.models.product_type.ProductType,​com.commercetools.api.models.product_type.ProductTypeDraft,​com.commercetools.api.models.product_type.ProductTypeUpdateAction,​ProductTypeSyncStatistics,​ProductTypeSyncOptions>
        Parameters:
        batch - batch of drafts that need to be synced
        Returns:
        a CompletionStage containing an instance of ProductTypeSyncStatistics which contains information about the result of syncing the supplied batch to the target project.