public interface ProductTypeService
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> |
cacheKeysToIds(java.util.Set<java.lang.String> keys)
Filters out the keys which are already cached and fetches only the not-cached product type keys from the CTP
project defined in an injected
SphereClient and stores a mapping for every productType to id in
the cached map of keys -> ids and returns this cached map. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.producttypes.ProductType>> |
createProductType(io.sphere.sdk.producttypes.ProductTypeDraft productTypeDraft)
Given a resource draft of type
ProductTypeDraft, this method attempts to create a resource
ProductType based on it in the CTP project defined by the sync options. |
java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,AttributeMetaData>>> |
fetchCachedProductAttributeMetaDataMap(java.lang.String productTypeId)
TODO FIX JAVADOC AND TEST METHOD
Given a
productType, this method first checks if a cached map of ProductType ids -> map of
AttributeMetaData is not empty. |
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> |
fetchCachedProductTypeId(java.lang.String key)
Given a
key, this method first checks if a cached map of ProductType keys -> ids contains the key. |
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.producttypes.ProductType>> |
fetchMatchingProductTypesByKeys(java.util.Set<java.lang.String> keys)
Given a
Set of ProductType keys, this method fetches a set of all the ProductTypes, matching this given
set of keys in the CTP project, defined in an injected SphereClient. |
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.producttypes.ProductType>> |
fetchProductType(java.lang.String key)
Given a productType key, this method fetches a productType that matches this given key in the CTP project defined
in an injected
SphereClient. |
java.util.concurrent.CompletionStage<io.sphere.sdk.producttypes.ProductType> |
updateProductType(io.sphere.sdk.producttypes.ProductType productType,
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.producttypes.ProductType>> updateActions)
Updates existing product type with
updateActions. |
@Nonnull
java.util.concurrent.CompletionStage<java.util.Map<java.lang.String,java.lang.String>> cacheKeysToIds(@Nonnull
java.util.Set<java.lang.String> keys)
SphereClient and stores a mapping for every productType to id in
the cached map of keys -> ids and returns this cached map.
Note: If all the supplied keys are already cached, the cached map is returned right away with no request to CTP.
keys - the productType keys to fetch and cache the ids for.CompletionStage<Map> in which the result of it's completion contains a map of all
productType keys -> ids@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<java.lang.String>> fetchCachedProductTypeId(@Nonnull
java.lang.String key)
key, this method first checks if a cached map of ProductType keys -> ids contains the key.
If not, it returns a completed future that contains an Optional that contains what this key maps to in
the cache. If the cache doesn't contain the key; this method attempts to fetch the id of the key from the CTP
project, caches it and returns a CompletionStage<Optional<String>>
in which the result of it's completion could contain an
Optional with the id inside of it or an empty Optional if no ProductType was
found in the CTP project with this key.key - the key by which a ProductType id should be fetched from the CTP project.CompletionStage<Optional<String>> in which the result of its
completion could contain an Optional with the id inside of it or an empty Optional if no
ProductType was found in the CTP project with this key.@Nonnull java.util.concurrent.CompletionStage<java.util.Optional<java.util.Map<java.lang.String,AttributeMetaData>>> fetchCachedProductAttributeMetaDataMap(@Nonnull java.lang.String productTypeId)
productType, this method first checks if a cached map of ProductType ids -> map of
AttributeMetaData is not empty. If not, it returns a completed future that contains an optional that
contains what this productType id maps to in the cache. If the cache is empty,
the method populates the cache with the mapping of all ProductType ids to maps of each product type's attributes'
AttributeMetaData in the CTP project, by querying the CTP project for all ProductTypes.
After that, the method returns a CompletionStage<Optional<String>>
in which the result of it's completion could contain an
Optional with a map of the attributes names -> AttributeMetaData inside of it or an empty
Optional if no ProductType was found in the CTP project with this id.
productTypeId - the id by which a a map of the attributes names -> AttributeMetaData
corresponding to the product type should be fetched from the CTP project.CompletionStage<Optional<String>> in which the result of its
completion could contain an Optional with the id inside of it or an empty Optional if no
ProductType was found in the CTP project with this key.@Nonnull
java.util.concurrent.CompletionStage<java.util.Set<io.sphere.sdk.producttypes.ProductType>> fetchMatchingProductTypesByKeys(@Nonnull
java.util.Set<java.lang.String> keys)
Set of ProductType keys, this method fetches a set of all the ProductTypes, matching this given
set of keys in the CTP project, defined in an injected SphereClient. A
mapping of the key to the id of the fetched ProductType is persisted in an in-memory map.keys - set of ProductType keys to fetch matching ProductTypes by.CompletionStage<Map> in which the result of it's completion contains a Set
of all matching ProductType.@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.producttypes.ProductType>> createProductType(@Nonnull
io.sphere.sdk.producttypes.ProductTypeDraft productTypeDraft)
ProductTypeDraft, this method attempts to create a resource
ProductType based on it in the CTP project defined by the sync options.
A completion stage containing an empty optional and the error callback will be triggered in those cases:
On the other hand, if the resource gets created successfully on CTP, then the created resource's id and
key are cached and the method returns a CompletionStage in which the result of it's completion
contains an instance Optional of the resource which was created.
productTypeDraft - the resource draft to create a resource based off of.CompletionStage containing an optional with the created resource if successful otherwise an
empty optional.@Nonnull
java.util.concurrent.CompletionStage<io.sphere.sdk.producttypes.ProductType> updateProductType(@Nonnull
io.sphere.sdk.producttypes.ProductType productType,
@Nonnull
java.util.List<io.sphere.sdk.commands.UpdateAction<io.sphere.sdk.producttypes.ProductType>> updateActions)
updateActions.productType - product type that should be updatedupdateActions - List of actions that should be applied to productTypeCompletionStage with updated ProductType.@Nonnull
java.util.concurrent.CompletionStage<java.util.Optional<io.sphere.sdk.producttypes.ProductType>> fetchProductType(@Nullable
java.lang.String key)
SphereClient. If there is no matching productType an empty Optional
will be returned in the returned future.key - the key of the product type to fetch.CompletionStage<Optional> in which the result of it's completion contains an
Optional that contains the matching ProductType if exists, otherwise empty.