Class ShoppingListReferenceResolutionUtils


  • public final class ShoppingListReferenceResolutionUtils
    extends java.lang.Object
    Util class which provides utilities that can be used when syncing shopping lists from a source commercetools project to a target one.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static io.sphere.sdk.shoppinglists.queries.ShoppingListQuery buildShoppingListQuery()
      Builds a ShoppingListQuery for fetching shopping lists from a source CTP project with only the Variants expanded for the sync: Variants of the LineItems
      static io.sphere.sdk.shoppinglists.ShoppingListDraft mapToShoppingListDraft​(io.sphere.sdk.shoppinglists.ShoppingList shoppingList, ReferenceIdToKeyCache referenceIdToKeyCache)
      Returns a @link ShoppingListDraft} consisting of the result of applying the mapping from ShoppingList to ShoppingListDraft with considering reference resolution.
      static java.util.List<io.sphere.sdk.shoppinglists.ShoppingListDraft> mapToShoppingListDrafts​(java.util.List<io.sphere.sdk.shoppinglists.ShoppingList> shoppingLists, ReferenceIdToKeyCache referenceIdToKeyCache)
      Returns a List<ShoppingListDraft> consisting of the results of applying the mapping from ShoppingList to ShoppingListDraft with considering reference resolution.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • mapToShoppingListDrafts

        @Nonnull
        public static java.util.List<io.sphere.sdk.shoppinglists.ShoppingListDraft> mapToShoppingListDrafts​(@Nonnull
                                                                                                            java.util.List<io.sphere.sdk.shoppinglists.ShoppingList> shoppingLists,
                                                                                                            @Nonnull
                                                                                                            ReferenceIdToKeyCache referenceIdToKeyCache)
        Returns a List<ShoppingListDraft> consisting of the results of applying the mapping from ShoppingList to ShoppingListDraft with considering reference resolution.
        Mapping of Reference fields for the reference resolution
        Reference field from to
        customer Reference<Customer> ResourceIdentifier<Customer>
        custom.type Reference<Type> ResourceIdentifier<Type>
        lineItems.custom.type Set<Reference<Type>> Set<ResourceIdentifier<Type>>
        textLineItems.custom.type Set<Reference<Type>> Set<ResourceIdentifier<Type>>

        Note: The aforementioned references should contain Id in the map(cache) with a key value. Any reference, which have its id in place and not replaced by the key, it would not be found in the map. In this case, this reference will be considered as existing resources on the target commercetools project and the library will issues an update/create API request without reference resolution.

        Parameters:
        shoppingLists - the shopping lists without expansion of references.
        referenceIdToKeyCache - the instance that manages cache.
        Returns:
        a List of ShoppingListDraft built from the supplied List of ShoppingList.
      • mapToShoppingListDraft

        @Nonnull
        public static io.sphere.sdk.shoppinglists.ShoppingListDraft mapToShoppingListDraft​(@Nonnull
                                                                                           io.sphere.sdk.shoppinglists.ShoppingList shoppingList,
                                                                                           @Nonnull
                                                                                           ReferenceIdToKeyCache referenceIdToKeyCache)
        Returns a @link ShoppingListDraft} consisting of the result of applying the mapping from ShoppingList to ShoppingListDraft with considering reference resolution.
        Mapping of Reference fields for the reference resolution
        Reference field from to
        customer Reference<Customer> ResourceIdentifier<Customer>
        custom.type Reference<Type> ResourceIdentifier<Type>
        lineItems.custom.type Set<Reference<Type>> Set<ResourceIdentifier<Type>>
        textLineItems.custom.type Set<Reference<Type>> Set<ResourceIdentifier<Type>>

        Note: The aforementioned references should contain Id in the map(cache) with a key value. Any reference, which have its id in place and not replaced by the key, it would not be found in the map. In this case, this reference will be considered as existing resources on the target commercetools project and the library will issues an update/create API request without reference resolution.

        Parameters:
        shoppingList - the shopping list without expansion of references.
        referenceIdToKeyCache - the instance that manages cache.
        Returns:
        a ShoppingListDraft built from the supplied ShoppingList.
      • buildShoppingListQuery

        public static io.sphere.sdk.shoppinglists.queries.ShoppingListQuery buildShoppingListQuery()
        Builds a ShoppingListQuery for fetching shopping lists from a source CTP project with only the Variants expanded for the sync:
        • Variants of the LineItems

        Note: Please only use this util if you desire to sync the aforementioned reference from a source commercetools project. Otherwise, it is more efficient to build the query without expansion, if it is not needed, to avoid unnecessarily bigger payloads fetched from the source project.

        Returns:
        the query for fetching shopping lists from the source CTP project without references expanded except for Variants of the LineItems.