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
ConstructorDescriptionExternalCatalogProvider
(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 String
buildReadBatchOfProductIdsUriForFullFeed
(String startId, int batchSize, String rsql) protected String
buildReadBatchOfProductsUri
(@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 CollectedProduct
deserializeProduct
(com.fasterxml.jackson.databind.node.ObjectNode productJson) Deserializes anObjectNode
intoCollectedProduct
.protected CatalogProviderProperties
protected com.fasterxml.jackson.databind.ObjectMapper
protected ProviderUtil
protected com.broadleafcommerce.common.extension.TypeFactory
protected org.springframework.web.reactive.function.client.WebClient
readIdBatchForFullFeed
(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 ofCollectedProducts
from 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:CatalogProvider
Given a batch ofIncrementalDataFeedEntityUpdateRecords
, fetch Product IDs that correspond.- Specified by:
readIdBatchForPartialFeed
in interfaceCatalogProvider
- Parameters:
updateRecords
- a list of records with references to products and their IDsfilterString
- a RSQL filter string, or nullreadContextInfo
- theContextInfo
for 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:CatalogProvider
Reads a batch of Product IDs, in ascending order, starting at the cursor.- Specified by:
readIdBatchForFullFeed
in interfaceCatalogProvider
- Parameters:
cursor
- the last ID fetched, or nullbatchSize
- the number of IDs to fetch in a batchfilterString
- a RSQL filter string, or nullcontextInfo
- theContextInfo
for 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:CatalogProvider
Reads a batch ofCollectedProducts
from the batch of provided IDs.- Specified by:
readProducts
in interfaceCatalogProvider
- Parameters:
idBatch
- batch of IDs for which to fetch productsreadContextInfo
- contextInfo theContextInfo
for 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 anObjectNode
intoCollectedProduct
.This manual process is necessary, as at the time of writing, concepts like
JsonAnySetter
andJsonAnyGetter
do not fully supportObjectNode
. Thus, we first read JSON asObjectNode
directly, then manually parse out specific properties we want to promote as first-class fields.- Parameters:
productJson
- theObjectNode
representing the product JSON- Returns:
- a
CollectedProduct
representation 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
-