public final class CustomerReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.CustomerDraftBuilder,CustomerSyncOptions>
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CUSTOMER_GROUP_DOES_NOT_EXIST |
static java.lang.String |
FAILED_TO_RESOLVE_CUSTOM_TYPE |
static java.lang.String |
FAILED_TO_RESOLVE_CUSTOMER_GROUP_REFERENCE |
static java.lang.String |
FAILED_TO_RESOLVE_STORE_REFERENCE |
TYPE_DOES_NOT_EXISTBLANK_ID_VALUE_ON_REFERENCE, BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER, options| Constructor and Description |
|---|
CustomerReferenceResolver(CustomerSyncOptions options,
TypeService typeService,
CustomerGroupService customerGroupService)
Takes a
CustomerSyncOptions instance, a TypeService and a CustomerGroupService to instantiate a CustomerReferenceResolver instance that could be
used to resolve the customer drafts in the CTP project specified in the injected CustomerSyncOptions instance. |
| Modifier and Type | Method and Description |
|---|---|
java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> |
populateKeyToIdCachesForReferencedKeys(CustomerBatchValidator.ReferencedKeys referencedKeys)
Calls the
cacheKeysToIds service methods to fetch all the referenced keys (i.e custom
type, customer group) from the commercetools to populate caches for the reference resolution. |
java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> |
resolveCustomerGroupReference(io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)
Given a
CustomerDraftBuilder this method attempts to resolve the customer group to
return a CompletionStage which contains a new instance of the builder with the resolved
customer group reference. |
protected java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> |
resolveCustomTypeReference(io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)
Given a draft of
D (e.g. |
java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraft> |
resolveReferences(io.sphere.sdk.customers.CustomerDraft customerDraft)
Given a
CustomerDraft this method attempts to resolve the stores, customer group and
custom type references to return a CompletionStage which contains a new instance of the
draft with the resolved references or, in case an error occurs during reference resolution, a
ReferenceResolutionException. |
java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> |
resolveStoreReferences(io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)
Given a
CustomerDraftBuilder this method attempts to resolve the stores and return a
CompletionStage which contains a new instance of the builder with the resolved
references. |
resolveCustomTypeReferencegetIdFromReference, getKeyFromResourceIdentifierpublic static final java.lang.String FAILED_TO_RESOLVE_CUSTOMER_GROUP_REFERENCE
public static final java.lang.String FAILED_TO_RESOLVE_STORE_REFERENCE
public static final java.lang.String FAILED_TO_RESOLVE_CUSTOM_TYPE
public static final java.lang.String CUSTOMER_GROUP_DOES_NOT_EXIST
public CustomerReferenceResolver(@Nonnull
CustomerSyncOptions options,
@Nonnull
TypeService typeService,
@Nonnull
CustomerGroupService customerGroupService)
CustomerSyncOptions instance, a TypeService and a CustomerGroupService to instantiate a CustomerReferenceResolver instance that could be
used to resolve the customer drafts in the CTP project specified in the injected CustomerSyncOptions 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.customerGroupService - the service to fetch the customer groups for reference resolution.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraft> resolveReferences(@Nonnull
io.sphere.sdk.customers.CustomerDraft customerDraft)
CustomerDraft this method attempts to resolve the stores, customer group and
custom type references to return a CompletionStage which contains a new instance of the
draft with the resolved references or, in case an error occurs during reference resolution, a
ReferenceResolutionException.resolveReferences in class BaseReferenceResolver<io.sphere.sdk.customers.CustomerDraft,CustomerSyncOptions>customerDraft - the draft to resolve its references.CompletionStage that contains as a result a new CustomerDraft instance with
resolved custom type reference or, in case an error occurs during reference resolution, a
ReferenceResolutionException.protected java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveCustomTypeReference(@Nonnull
io.sphere.sdk.customers.CustomerDraftBuilder 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.customers.CustomerDraft,io.sphere.sdk.customers.CustomerDraftBuilder,CustomerSyncOptions>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.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveCustomerGroupReference(@Nonnull
io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)
CustomerDraftBuilder this method attempts to resolve the customer group to
return a CompletionStage which contains a new instance of the builder with the resolved
customer group reference.draftBuilder - the customerDraft to resolve its customer group reference.CompletionStage that contains as a result a new builder instance with
resolved customer group reference or, in case an error occurs during reference resolution,
a ReferenceResolutionException.@Nonnull
public java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveStoreReferences(@Nonnull
io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)
CustomerDraftBuilder this method attempts to resolve the stores and return a
CompletionStage which contains a new instance of the builder with the resolved
references.draftBuilder - the customer draft to resolve its store references.CompletionStage that contains as a result a new builder instance with
resolved references or, in case an error occurs during reference resolution, a ReferenceResolutionException.@Nonnull
public java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> populateKeyToIdCachesForReferencedKeys(@Nonnull
CustomerBatchValidator.ReferencedKeys referencedKeys)
cacheKeysToIds service methods to fetch all the referenced keys (i.e custom
type, customer group) 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 product 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 customer references.