public final class CategoryReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.categories.CategoryDraft,io.sphere.sdk.categories.CategoryDraftBuilder,CategorySyncOptions>
TYPE_DOES_NOT_EXISTBLANK_ID_VALUE_ON_REFERENCE, BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER, options| Constructor and Description |
|---|
CategoryReferenceResolver(CategorySyncOptions options,
TypeService typeService,
CategoryService categoryService)
Takes a
CategorySyncOptions instance, a CategoryService and TypeService
to instantiate a CategoryReferenceResolver instance that could be used to resolve the
category drafts in the CTP project specified in the injected CategorySyncOptions
instance. |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> |
populateKeyToIdCachesForReferencedKeys(CategoryBatchValidator.ReferencedKeys referencedKeys)
Calls the
cacheKeysToIds service methods to fetch all the referenced keys (category and
type) from the commercetools to populate caches for the reference resolution. |
protected java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraftBuilder> |
resolveCustomTypeReference(io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder)
Given a draft of
D (e.g. |
java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraft> |
resolveReferences(io.sphere.sdk.categories.CategoryDraft categoryDraft)
Given a
CategoryDraft this method attempts to resolve the custom type and parent
category references to return a CompletionStage which contains a new instance of the
draft with the resolved references. |
resolveCustomTypeReferencegetIdFromReference, getKeyFromResourceIdentifierpublic CategoryReferenceResolver(@Nonnull
CategorySyncOptions options,
@Nonnull
TypeService typeService,
@Nonnull
CategoryService categoryService)
CategorySyncOptions instance, a CategoryService and TypeService
to instantiate a CategoryReferenceResolver instance that could be used to resolve the
category drafts in the CTP project specified in the injected CategorySyncOptions
instance.options - the container of all the options of the sync process including the CTP project
client and/or configuration and other sync-specific options.typeService - the service to fetch the custom types for reference resolution.categoryService - the service to fetch the categories for reference resolution.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraft> resolveReferences(@Nonnull
io.sphere.sdk.categories.CategoryDraft categoryDraft)
CategoryDraft this method attempts to resolve the custom type and parent
category references to return a CompletionStage which contains a new instance of the
draft with the resolved references.resolveReferences in class BaseReferenceResolver<io.sphere.sdk.categories.CategoryDraft,CategorySyncOptions>categoryDraft - the categoryDraft to resolve its references.CompletionStage that contains as a result a new categoryDraft instance with
resolved category references or, in case an error occurs during reference resolution, a
ReferenceResolutionException.@Nonnull
protected java.util.concurrent.CompletionStage<io.sphere.sdk.categories.CategoryDraftBuilder> resolveCustomTypeReference(@Nonnull
io.sphere.sdk.categories.CategoryDraftBuilder draftBuilder)
CustomReferenceResolverD (e.g. CategoryDraft) this method attempts to resolve it's
custom type reference to return CompletionStage which contains a new instance of the
draft with the resolved custom type reference.
The method then tries to fetch the key of the custom type, optimistically from a cache. If the key is is not found, the resultant draft would remain exactly the same as the passed draft (without a custom type reference resolution).
resolveCustomTypeReference in class CustomReferenceResolver<io.sphere.sdk.categories.CategoryDraft,io.sphere.sdk.categories.CategoryDraftBuilder,CategorySyncOptions>draftBuilder - the draft builder to resolve it's references.CompletionStage that contains as a result a new draft instance with resolved
custom type references or, in case an error occurs during reference resolution, a ReferenceResolutionException.@Nonnull
public java.util.concurrent.CompletableFuture<java.util.Map<java.lang.String,java.lang.String>> populateKeyToIdCachesForReferencedKeys(@Nonnull
CategoryBatchValidator.ReferencedKeys referencedKeys)
cacheKeysToIds service methods to fetch all the referenced keys (category and
type) from the commercetools to populate caches for the reference resolution.
Note: This method is meant be only used internally by the library to improve performance.
referencedKeys - a wrapper for the category references to fetch and cache the id's for.CompletionStage<Map<String>String>> in
which the results of it's completions contains a map of requested references keys -> ids
of parent category references.