Class ProductBatchValidator

    • Method Detail

      • validateAndCollectReferencedKeys

        public org.apache.commons.lang3.tuple.ImmutablePair<java.util.Set<io.sphere.sdk.products.ProductDraft>,​ProductBatchValidator.ReferencedKeys> validateAndCollectReferencedKeys​(@Nonnull
                                                                                                                                                                                            java.util.List<io.sphere.sdk.products.ProductDraft> productDrafts)
        Given the List<ProductDraft> of drafts this method attempts to validate drafts and collect referenced keys from the draft and return an ImmutablePair<Set< ProductDraft>,ProductBatchValidator.ReferencedKeys> which contains the Set of valid drafts and referenced keys within a wrapper.

        A valid product draft is one which satisfies the following conditions:

        1. It is not null
        2. It has a key which is not blank (null/empty)
        3. It has all variants AND master variant valid
        4. A variant is valid if it satisfies the following conditions:
          1. It has a key which is not blank (null/empty)
          2. It has a SKU which is not blank (null/empty)
        Specified by:
        validateAndCollectReferencedKeys in class BaseBatchValidator<io.sphere.sdk.products.ProductDraft,​ProductSyncOptions,​ProductSyncStatistics>
        Parameters:
        productDrafts - the product drafts to validate and collect referenced keys.
        Returns:
        ImmutablePair<Set<ProductDraft>, ProductBatchValidator.ReferencedKeys> which contains the Set of valid drafts and referenced keys within a wrapper.
      • getReferencedProductKeys

        @Nonnull
        public static java.util.Set<java.lang.String> getReferencedProductKeys​(@Nonnull
                                                                               io.sphere.sdk.products.ProductVariantDraft variantDraft)
        Get a set of referenced product keys on all attribute drafts on the supplied Product Variant Draft.

        Note: Null attributes are skipped since they are validated at a later stage in (ProductVariantUpdateActionUtils)

        Parameters:
        variantDraft - the variant draft to get the referenced product keys from.
        Returns:
        the set of referenced product keys.