Class CategoryReferenceResolutionUtils


  • public final class CategoryReferenceResolutionUtils
    extends java.lang.Object
    Util class which provides utilities that can be used when syncing resources 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.categories.queries.CategoryQuery buildCategoryQuery()
      Builds a CategoryQuery for fetching categories from a source CTP project with all the needed references expanded for the sync: Custom Type Assets Custom Types Parent Category
      static java.util.List<io.sphere.sdk.categories.CategoryDraft> mapToCategoryDrafts​(java.util.List<io.sphere.sdk.categories.Category> categories)
      Returns an List<CategoryDraft> consisting of the results of applying the mapping from Category to CategoryDraft with considering reference resolution.
      • Methods inherited from class java.lang.Object

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

      • mapToCategoryDrafts

        @Nonnull
        public static java.util.List<io.sphere.sdk.categories.CategoryDraft> mapToCategoryDrafts​(@Nonnull
                                                                                                 java.util.List<io.sphere.sdk.categories.Category> categories)
        Returns an List<CategoryDraft> consisting of the results of applying the mapping from Category to CategoryDraft with considering reference resolution.
        Mapping of Reference fields for the reference resolution
        Reference field from to
        parent Reference<Category> ResourceIdentifier<Category>
        custom.type Reference<Type> ResourceIdentifier<Type>
        asset.custom.type Reference<Type> ResourceIdentifier<Type>

        Note: The Category and Type references should be expanded with a key. Any reference that is not expanded will have its id in place and not replaced by the key 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:
        categories - the categories with expanded references.
        Returns:
        a List of CategoryDraft built from the supplied List of Category.
      • buildCategoryQuery

        public static io.sphere.sdk.categories.queries.CategoryQuery buildCategoryQuery()
        Builds a CategoryQuery for fetching categories from a source CTP project with all the needed references expanded for the sync:
        • Custom Type
        • Assets Custom Types
        • Parent Category

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

        Returns:
        the query for fetching categories from the source CTP project with all the aforementioned references expanded.