Class ExternalCatalogProvider
java.lang.Object
com.broadleafcommerce.datafeed.service.collector.provider.ExternalCatalogProvider
- All Implemented Interfaces:
CatalogProvider
Default implementation of
CatalogProvider.- Author:
- Kelly Tisdell (ktisdell)
-
Constructor Summary
ConstructorsConstructorDescriptionExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, CatalogProviderProperties catalogProviderProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ProviderUtil providerUtil) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringbuildReadBatchOfProductIdsUriForFullFeed(String startId, int batchSize, String rsql) protected StringbuildReadBatchOfProductsUri(@NonNull List<String> ids) Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.protected <T> reactor.core.publisher.Mono<T>customizeReadIdBatchForFullFeedMono(reactor.core.publisher.Mono<T> mono) protected <T> reactor.core.publisher.Mono<T>customizeReadIdBatchForPartialFeedMono(reactor.core.publisher.Mono<T> mono) protected <T> reactor.core.publisher.Mono<T>customizeReadProductsMono(reactor.core.publisher.Mono<T> mono) protected List<CollectedProduct>deserializeBatchOfProductsResponse(List<com.fasterxml.jackson.databind.node.ObjectNode> productJsonObjects) protected CollectedProductdeserializeProduct(com.fasterxml.jackson.databind.node.ObjectNode productJson) Deserializes anObjectNodeintoCollectedProduct.protected CatalogProviderPropertiesprotected com.fasterxml.jackson.databind.ObjectMapperprotected ProviderUtilprotected com.broadleafcommerce.common.extension.TypeFactoryprotected org.springframework.web.reactive.function.client.WebClientreadIdBatchForFullFeed(String cursor, int batchSize, String filterString, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads a batch of Product IDs, in ascending order, starting at the cursor.readIdBatchForPartialFeed(@NonNull List<IncrementalDataFeedEntityUpdateRecord> updateRecords, String filterString, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Given a batch ofIncrementalDataFeedEntityUpdateRecords, fetch Product IDs that correspond.readProducts(@NonNull List<String> idBatch, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Reads a batch ofCollectedProductsfrom the batch of provided IDs.
-
Constructor Details
-
ExternalCatalogProvider
public ExternalCatalogProvider(org.springframework.web.reactive.function.client.WebClient webClient, CatalogProviderProperties catalogProviderProperties, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ProviderUtil providerUtil)
-
-
Method Details
-
readIdBatchForPartialFeed
public List<String> readIdBatchForPartialFeed(@NonNull @NonNull List<IncrementalDataFeedEntityUpdateRecord> updateRecords, @Nullable String filterString, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Description copied from interface:CatalogProviderGiven a batch ofIncrementalDataFeedEntityUpdateRecords, fetch Product IDs that correspond.- Specified by:
readIdBatchForPartialFeedin interfaceCatalogProvider- Parameters:
updateRecords- a list of records with references to products and their IDsfilterString- a RSQL filter string, or nullreadContextInfo- theContextInfofor reading the IDs- Returns:
-
customizeReadIdBatchForPartialFeedMono
protected <T> reactor.core.publisher.Mono<T> customizeReadIdBatchForPartialFeedMono(reactor.core.publisher.Mono<T> mono) -
readIdBatchForFullFeed
public List<String> readIdBatchForFullFeed(@Nullable String cursor, int batchSize, @Nullable String filterString, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CatalogProviderReads a batch of Product IDs, in ascending order, starting at the cursor.- Specified by:
readIdBatchForFullFeedin interfaceCatalogProvider- Parameters:
cursor- the last ID fetched, or nullbatchSize- the number of IDs to fetch in a batchfilterString- a RSQL filter string, or nullcontextInfo- theContextInfofor reading the IDs- Returns:
-
customizeReadIdBatchForFullFeedMono
protected <T> reactor.core.publisher.Mono<T> customizeReadIdBatchForFullFeedMono(reactor.core.publisher.Mono<T> mono) -
readProducts
public List<CollectedProduct> readProducts(@NonNull @NonNull List<String> idBatch, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Description copied from interface:CatalogProviderReads a batch ofCollectedProductsfrom the batch of provided IDs.- Specified by:
readProductsin interfaceCatalogProvider- Parameters:
idBatch- batch of IDs for which to fetch productsreadContextInfo- contextInfo theContextInfofor reading the IDs- Returns:
-
customizeReadProductsMono
protected <T> reactor.core.publisher.Mono<T> customizeReadProductsMono(reactor.core.publisher.Mono<T> mono) -
buildReadBatchOfProductIdsUriForFullFeed
-
buildReadBatchOfProductsUri
Builds a catalog fetch URI with a filter containing a range of IDs of products to retrieve from catalog.- Parameters:
ids- The list of ids- Returns:
- A URI for retrieving a list of products from catalog.
-
deserializeBatchOfProductsResponse
protected List<CollectedProduct> deserializeBatchOfProductsResponse(@Nullable List<com.fasterxml.jackson.databind.node.ObjectNode> productJsonObjects) -
deserializeProduct
protected CollectedProduct deserializeProduct(com.fasterxml.jackson.databind.node.ObjectNode productJson) Deserializes anObjectNodeintoCollectedProduct.This manual process is necessary, as at the time of writing, concepts like
JsonAnySetterandJsonAnyGetterdo not fully supportObjectNode. Thus, we first read JSON asObjectNodedirectly, then manually parse out specific properties we want to promote as first-class fields.- Parameters:
productJson- theObjectNoderepresenting the product JSON- Returns:
- a
CollectedProductrepresentation of the input
-
getWebClient
protected org.springframework.web.reactive.function.client.WebClient getWebClient() -
getCatalogProviderProperties
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getProviderUtil
-