Class CategoryTransformUtils
- java.lang.Object
-
- com.commercetools.sync.categories.utils.CategoryTransformUtils
-
public final class CategoryTransformUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description CategoryTransformUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.CompletableFuture<java.util.List<io.sphere.sdk.categories.CategoryDraft>>
toCategoryDrafts(io.sphere.sdk.client.SphereClient client, ReferenceIdToKeyCache referenceIdToKeyCache, java.util.List<io.sphere.sdk.categories.Category> categories)
Transforms categories by resolving the references and map them to CategoryDrafts.
-
-
-
Method Detail
-
toCategoryDrafts
@Nonnull public static java.util.concurrent.CompletableFuture<java.util.List<io.sphere.sdk.categories.CategoryDraft>> toCategoryDrafts(@Nonnull io.sphere.sdk.client.SphereClient client, @Nonnull ReferenceIdToKeyCache referenceIdToKeyCache, @Nonnull java.util.List<io.sphere.sdk.categories.Category> categories)
Transforms categories by resolving the references and map them to CategoryDrafts.This method replaces the ids on unexpanded references of the category
Category
by using cache.If the reference ids are already cached, key values are pulled from the cache, otherwise it executes the query to fetch the key value for the reference id's and store the idToKey value pair in the cache for reuse.
Then maps the Category to CategoryDraft by performing reference resolution considering idToKey value from the cache.
- Parameters:
client
- commercetools client.referenceIdToKeyCache
- the instance that manages cache.categories
- the categories to replace the references id's with keys.- Returns:
- a new list which contains categoryDrafts which have all their references resolved and
already replaced with keys.
TODO: Move the implementation from service class to this util class.
-
-