Class ProductTransformServiceImpl
- java.lang.Object
-
- com.commercetools.sync.services.impl.BaseTransformServiceImpl
-
- com.commercetools.sync.products.service.impl.ProductTransformServiceImpl
-
- All Implemented Interfaces:
ProductTransformService
public class ProductTransformServiceImpl extends BaseTransformServiceImpl implements ProductTransformService
-
-
Field Summary
-
Fields inherited from class com.commercetools.sync.services.impl.BaseTransformServiceImpl
CHUNK_SIZE, KEY_IS_NOT_SET_PLACE_HOLDER, referenceIdToKeyCache
-
-
Constructor Summary
Constructors Constructor Description ProductTransformServiceImpl(io.sphere.sdk.client.SphereClient ctpClient, ReferenceIdToKeyCache referenceIdToKeyCache)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletionStage<java.util.List<io.sphere.sdk.products.ProductProjection>>
replaceAttributeReferenceIdsWithKeys(java.util.List<io.sphere.sdk.products.ProductProjection> products)
Replaces the ids on attribute references with keys.java.util.concurrent.CompletableFuture<java.util.List<io.sphere.sdk.products.ProductDraft>>
toProductDrafts(java.util.List<io.sphere.sdk.products.ProductProjection> products)
Transforms products by resolving the references and map them to ProductDrafts.-
Methods inherited from class com.commercetools.sync.services.impl.BaseTransformServiceImpl
cacheResourceReferenceKeys, cacheResourceReferenceKeys, createResourceIdsGraphQlRequests, fetchAndFillReferenceIdToKeyCache, getCtpClient, getNonCachedReferenceIds
-
-
-
-
Constructor Detail
-
ProductTransformServiceImpl
public ProductTransformServiceImpl(@Nonnull io.sphere.sdk.client.SphereClient ctpClient, @Nonnull ReferenceIdToKeyCache referenceIdToKeyCache)
-
-
Method Detail
-
toProductDrafts
@Nonnull public java.util.concurrent.CompletableFuture<java.util.List<io.sphere.sdk.products.ProductDraft>> toProductDrafts(@Nonnull java.util.List<io.sphere.sdk.products.ProductProjection> products)
Description copied from interface:ProductTransformService
Transforms products by resolving the references and map them to ProductDrafts.This method replaces the ids on attribute references with keys and resolves(fetch key values for the reference id's) non null and unexpanded references of the product
Product
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 Product to ProductDraft by performing reference resolution considering idToKey value from the cache.
- Specified by:
toProductDrafts
in interfaceProductTransformService
- Parameters:
products
- the products to replace the references and attributes id's with keys.- Returns:
- a new list which contains productDrafts which have all their references and attributes references resolved and already replaced with keys.
-
replaceAttributeReferenceIdsWithKeys
@Nonnull public java.util.concurrent.CompletionStage<java.util.List<io.sphere.sdk.products.ProductProjection>> replaceAttributeReferenceIdsWithKeys(@Nonnull java.util.List<io.sphere.sdk.products.ProductProjection> products)
Replaces the ids on attribute references with keys.Note: this method mutates the products passed by changing the reference keys with ids.
- Parameters:
products
- the products to replace the reference attributes ids with keys on.- Returns:
- products with all their attributes references resolvable and already replaced with keys.
-
-