Class CustomerReferenceResolver
- java.lang.Object
 - 
- com.commercetools.sync.commons.helpers.BaseReferenceResolver<D,S>
 - 
- com.commercetools.sync.commons.helpers.CustomReferenceResolver<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.CustomerDraftBuilder,CustomerSyncOptions>
 - 
- com.commercetools.sync.customers.helpers.CustomerReferenceResolver
 
 
 
 
- 
public final class CustomerReferenceResolver extends CustomReferenceResolver<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.CustomerDraftBuilder,CustomerSyncOptions>
 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.lang.StringCUSTOMER_GROUP_DOES_NOT_EXISTstatic java.lang.StringFAILED_TO_RESOLVE_CUSTOM_TYPEstatic java.lang.StringFAILED_TO_RESOLVE_CUSTOMER_GROUP_REFERENCEstatic java.lang.StringFAILED_TO_RESOLVE_STORE_REFERENCE- 
Fields inherited from class com.commercetools.sync.commons.helpers.CustomReferenceResolver
TYPE_DOES_NOT_EXIST 
- 
Fields inherited from class com.commercetools.sync.commons.helpers.BaseReferenceResolver
BLANK_ID_VALUE_ON_REFERENCE, BLANK_KEY_VALUE_ON_RESOURCE_IDENTIFIER, options 
 - 
 
- 
Constructor Summary
Constructors Constructor Description CustomerReferenceResolver(CustomerSyncOptions options, TypeService typeService, CustomerGroupService customerGroupService)Takes aCustomerSyncOptionsinstance, aTypeServiceand aCustomerGroupServiceto instantiate aCustomerReferenceResolverinstance that could be used to resolve the customer drafts in the CTP project specified in the injectedCustomerSyncOptionsinstance. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>>populateKeyToIdCachesForReferencedKeys(CustomerBatchValidator.ReferencedKeys referencedKeys)Calls thecacheKeysToIdsservice 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 aCustomerDraftBuilderthis method attempts to resolve the customer group to return aCompletionStagewhich 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 ofD(e.g.java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraft>resolveReferences(io.sphere.sdk.customers.CustomerDraft customerDraft)Given aCustomerDraftthis method attempts to resolve the stores, customer group and custom type references to return aCompletionStagewhich contains a new instance of the draft with the resolved references or, in case an error occurs during reference resolution, aReferenceResolutionException.java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder>resolveStoreReferences(io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)Given aCustomerDraftBuilderthis method attempts to resolve the stores and return aCompletionStagewhich contains a new instance of the builder with the resolved references.- 
Methods inherited from class com.commercetools.sync.commons.helpers.CustomReferenceResolver
resolveCustomTypeReference 
- 
Methods inherited from class com.commercetools.sync.commons.helpers.BaseReferenceResolver
getIdFromReference, getKeyFromResourceIdentifier 
 - 
 
 - 
 
- 
- 
Field Detail
- 
FAILED_TO_RESOLVE_CUSTOMER_GROUP_REFERENCE
public static final java.lang.String FAILED_TO_RESOLVE_CUSTOMER_GROUP_REFERENCE
- See Also:
 - Constant Field Values
 
 
- 
FAILED_TO_RESOLVE_STORE_REFERENCE
public static final java.lang.String FAILED_TO_RESOLVE_STORE_REFERENCE
- See Also:
 - Constant Field Values
 
 
- 
FAILED_TO_RESOLVE_CUSTOM_TYPE
public static final java.lang.String FAILED_TO_RESOLVE_CUSTOM_TYPE
- See Also:
 - Constant Field Values
 
 
- 
CUSTOMER_GROUP_DOES_NOT_EXIST
public static final java.lang.String CUSTOMER_GROUP_DOES_NOT_EXIST
- See Also:
 - Constant Field Values
 
 
 - 
 
- 
Constructor Detail
- 
CustomerReferenceResolver
public CustomerReferenceResolver(@Nonnull CustomerSyncOptions options, @Nonnull TypeService typeService, @Nonnull CustomerGroupService customerGroupService)Takes aCustomerSyncOptionsinstance, aTypeServiceand aCustomerGroupServiceto instantiate aCustomerReferenceResolverinstance that could be used to resolve the customer drafts in the CTP project specified in the injectedCustomerSyncOptionsinstance.- Parameters:
 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.
 
 - 
 
- 
Method Detail
- 
resolveReferences
@Nonnull public java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraft> resolveReferences(@Nonnull io.sphere.sdk.customers.CustomerDraft customerDraft)Given aCustomerDraftthis method attempts to resolve the stores, customer group and custom type references to return aCompletionStagewhich contains a new instance of the draft with the resolved references or, in case an error occurs during reference resolution, aReferenceResolutionException.- Specified by:
 resolveReferencesin classBaseReferenceResolver<io.sphere.sdk.customers.CustomerDraft,CustomerSyncOptions>- Parameters:
 customerDraft- the draft to resolve its references.- Returns:
 - a 
CompletionStagethat contains as a result a new CustomerDraft instance with resolved custom type reference or, in case an error occurs during reference resolution, aReferenceResolutionException. 
 
- 
resolveCustomTypeReference
protected java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveCustomTypeReference(@Nonnull io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)Description copied from class:CustomReferenceResolverGiven a draft ofD(e.g.CategoryDraft) this method attempts to resolve it's custom type reference to returnCompletionStagewhich 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).
- Specified by:
 resolveCustomTypeReferencein classCustomReferenceResolver<io.sphere.sdk.customers.CustomerDraft,io.sphere.sdk.customers.CustomerDraftBuilder,CustomerSyncOptions>- Parameters:
 draftBuilder- the draft builder to resolve it's references.- Returns:
 - a 
CompletionStagethat contains as a result a new draft instance with resolved custom type references or, in case an error occurs during reference resolution, aReferenceResolutionException. 
 
- 
resolveCustomerGroupReference
@Nonnull public java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveCustomerGroupReference(@Nonnull io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)Given aCustomerDraftBuilderthis method attempts to resolve the customer group to return aCompletionStagewhich contains a new instance of the builder with the resolved customer group reference.- Parameters:
 draftBuilder- the customerDraft to resolve its customer group reference.- Returns:
 - a 
CompletionStagethat contains as a result a new builder instance with resolved customer group reference or, in case an error occurs during reference resolution, aReferenceResolutionException. 
 
- 
resolveStoreReferences
@Nonnull public java.util.concurrent.CompletionStage<io.sphere.sdk.customers.CustomerDraftBuilder> resolveStoreReferences(@Nonnull io.sphere.sdk.customers.CustomerDraftBuilder draftBuilder)Given aCustomerDraftBuilderthis method attempts to resolve the stores and return aCompletionStagewhich contains a new instance of the builder with the resolved references.- Parameters:
 draftBuilder- the customer draft to resolve its store references.- Returns:
 - a 
CompletionStagethat contains as a result a new builder instance with resolved references or, in case an error occurs during reference resolution, aReferenceResolutionException. 
 
- 
populateKeyToIdCachesForReferencedKeys
@Nonnull public java.util.concurrent.CompletableFuture<java.util.List<java.util.Map<java.lang.String,java.lang.String>>> populateKeyToIdCachesForReferencedKeys(@Nonnull CustomerBatchValidator.ReferencedKeys referencedKeys)Calls thecacheKeysToIdsservice 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.
- Parameters:
 referencedKeys- a wrapper for the product references to fetch and cache the id's for.- Returns:
 CompletionStage<Map<String>String>> in which the results of it's completions contains a map of requested references keys -> ids of customer references.
 
 - 
 
 -