public final class PriceReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.products.PriceDraft,io.sphere.sdk.products.PriceDraftBuilder,ProductSyncOptions>
TYPE_DOES_NOT_EXIST
BLANK_ID_VALUE_ON_REFERENCE, BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER, options
Constructor and Description |
---|
PriceReferenceResolver(ProductSyncOptions options,
TypeService typeService,
ChannelService channelService,
CustomerGroupService customerGroupService)
Takes a
ProductSyncOptions instance, TypeService , a ChannelService and
a CustomerGroupService to instantiate a PriceReferenceResolver instance that
could be used to resolve the prices of variant drafts in the CTP project specified in the
injected ProductSyncOptions instance. |
Modifier and Type | Method and Description |
---|---|
protected java.util.concurrent.CompletionStage<io.sphere.sdk.products.PriceDraftBuilder> |
resolveCustomTypeReference(io.sphere.sdk.products.PriceDraftBuilder draftBuilder)
Given a draft of
D (e.g. |
java.util.concurrent.CompletionStage<io.sphere.sdk.products.PriceDraft> |
resolveReferences(io.sphere.sdk.products.PriceDraft priceDraft)
Given a
PriceDraft this method attempts to resolve the custom type and channel
references to return a CompletionStage which contains a new instance of the draft with
the resolved references. |
resolveCustomTypeReference
getIdFromReference, getKeyFromResourceIdentifier
public PriceReferenceResolver(@Nonnull ProductSyncOptions options, @Nonnull TypeService typeService, @Nonnull ChannelService channelService, @Nonnull CustomerGroupService customerGroupService)
ProductSyncOptions
instance, TypeService
, a ChannelService
and
a CustomerGroupService
to instantiate a PriceReferenceResolver
instance that
could be used to resolve the prices of variant drafts in the CTP project specified in the
injected ProductSyncOptions
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.channelService
- the service to fetch the channels for reference resolution.customerGroupService
- the service to fetch the customer groups for reference resolution.public java.util.concurrent.CompletionStage<io.sphere.sdk.products.PriceDraft> resolveReferences(@Nonnull io.sphere.sdk.products.PriceDraft priceDraft)
PriceDraft
this method attempts to resolve the custom type and channel
references to return a CompletionStage
which contains a new instance of the draft with
the resolved references.
The method then tries to fetch the key of the customer group, optimistically from a cache.
If the id is not found in cache nor the CTP project the ReferenceResolutionException
will be thrown.
resolveReferences
in class BaseReferenceResolver<io.sphere.sdk.products.PriceDraft,ProductSyncOptions>
priceDraft
- the priceDraft to resolve it's references.CompletionStage
that contains as a result a new inventoryEntryDraft instance
with resolved references or, in case an error occurs during reference resolution a ReferenceResolutionException
.@Nonnull protected java.util.concurrent.CompletionStage<io.sphere.sdk.products.PriceDraftBuilder> resolveCustomTypeReference(@Nonnull io.sphere.sdk.products.PriceDraftBuilder draftBuilder)
CustomReferenceResolver
D
(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.products.PriceDraft,io.sphere.sdk.products.PriceDraftBuilder,ProductSyncOptions>
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
.