Class ProductDataFeedCollector<E extends CollectedProduct>
java.lang.Object
com.broadleafcommerce.datafeed.service.collector.AbstractJsonArrayDataFeedCollector<String,E>
com.broadleafcommerce.datafeed.service.collector.product.ProductDataFeedCollector<E>
- All Implemented Interfaces:
DataFeedCollector
public class ProductDataFeedCollector<E extends CollectedProduct>
extends AbstractJsonArrayDataFeedCollector<String,E>
Handles gathering and storing a Product data feed to be transformed and published.
- Author:
- Kelly Tisdell
-
Constructor Summary
ConstructorDescriptionProductDataFeedCollector
(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper, IncrementalDataFeedEntityUpdateRecordService<IncrementalDataFeedEntityUpdateRecord> incrementalDataFeedEntityUpdateRecordService, List<CollectedEntityContributor> collectedEntityContributors, ProductDataFeedCollectorProperties productDataFeedCollectorProperties, CatalogProvider externalCatalogProvider) -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(DataFeedCollectionRequest request) Indicates if thisDataFeedCollector
can handle this type ofDataFeedProcessExecution
, presumably because of an entity type or other feed type indicator.protected CatalogProvider
protected ProductDataFeedCollectorProperties
postProcess
(@NonNull DataFeedCollectionRequest request, @NonNull List<E> products, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Hook point to allow implementors to modify the Product list prior to returning to be written to a file.readDataFeedRecords
(@NonNull DataFeedCollectionRequest request, @NonNull List<String> idBatch, @NonNull Map<String, Object> collectorProcessState, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) readIdBatchForFullFeed
(@NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> collectorProcessState, int batchSize, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Returns aList
that provides a batch of IDs, sorted in ascending order.readIdBatchForPartialFeed
(DataFeedCollectionRequest collectionRequest, @NonNull List<IncrementalDataFeedEntityUpdateRecord> updateRecords, @NonNull Map<String, Object> sharedProcessState, com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Given a list ofIncrementalDataFeedEntityUpdateRecords
, we need to determine the Product IDs.Methods inherited from class com.broadleafcommerce.datafeed.service.collector.AbstractJsonArrayDataFeedCollector
buildContextInfo, createEmptyLocalCollectedDataFile, executeContributors, getBatchSize, getCollectedEntityContributors, getIdBatchSize, getIncrementalDataFeedEntityUpdateRecordService, getObjectMapper, getRsqlParser, getTypeFactory, getWorkerThreads, handle, isIdDuplicateIncrementalId, readIncrementalUpdateRecords
-
Constructor Details
-
ProductDataFeedCollector
public ProductDataFeedCollector(com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper, IncrementalDataFeedEntityUpdateRecordService<IncrementalDataFeedEntityUpdateRecord> incrementalDataFeedEntityUpdateRecordService, List<CollectedEntityContributor> collectedEntityContributors, ProductDataFeedCollectorProperties productDataFeedCollectorProperties, CatalogProvider externalCatalogProvider)
-
-
Method Details
-
canHandle
Description copied from interface:DataFeedCollector
Indicates if thisDataFeedCollector
can handle this type ofDataFeedProcessExecution
, presumably because of an entity type or other feed type indicator.- Returns:
-
readDataFeedRecords
protected List<E> readDataFeedRecords(@NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull List<String> idBatch, @NonNull @NonNull Map<String, Object> collectorProcessState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) - Specified by:
readDataFeedRecords
in classAbstractJsonArrayDataFeedCollector<String,
E extends CollectedProduct> - Parameters:
request
- the original request to collect dataidBatch
- a batch of unique IDscollectorProcessState
- Map to optionally hold additional state across multiple method invocations - this is thread safe and guaranteed to be the same Map instance on each invocationreadContextInfo
- ContextInfo to read data from the DB or from an API- Returns:
-
postProcess
protected List<E> postProcess(@NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull List<E> products, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Hook point to allow implementors to modify the Product list prior to returning to be written to a file. By default, this does nothing but returns the original product list.- Parameters:
request
-products
-readContextInfo
-- Returns:
-
readIdBatchForFullFeed
protected List<String> readIdBatchForFullFeed(@NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> collectorProcessState, int batchSize, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Description copied from class:AbstractJsonArrayDataFeedCollector
Returns aList
that provides a batch of IDs, sorted in ascending order. Implementations must keep track of their own cursor (stating point) using the collectorProcessState, which is guaranteed to be the same Map instance between invocations.- Specified by:
readIdBatchForFullFeed
in classAbstractJsonArrayDataFeedCollector<String,
E extends CollectedProduct> - Parameters:
request
- the original request to collect datacollectorProcessState
- Map to optionally hold additional state across multiple method invocations - this is thread safe and guaranteed to be the same Map instance on each invocationbatchSize
- the size of the id batch to fetch, usually larger than the normal batch size.readContextInfo
- ContextInfo to read data from the DB or from an API- Returns:
-
readIdBatchForPartialFeed
protected List<String> readIdBatchForPartialFeed(DataFeedCollectionRequest collectionRequest, @NonNull @NonNull List<IncrementalDataFeedEntityUpdateRecord> updateRecords, @NonNull @NonNull Map<String, Object> sharedProcessState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo readContextInfo) Given a list ofIncrementalDataFeedEntityUpdateRecords
, we need to determine the Product IDs. TheIncrementalDataFeedEntityUpdateRecord
contains aIncrementalDataFeedEntityUpdateRecord.getAffectedProductReferenceType()
and aIncrementalDataFeedEntityUpdateRecord.getAffectedProductReferenceValue()
. The types can be one ofDefaultIncrementalEventProductReferenceTypes
. For all references, we need to call the CatalogService and find the IDs, which will be queued up to fetch the products. Note that evenDefaultIncrementalEventProductReferenceTypes.ID
references need to be sent to CatalogServices, as those records need to pass the same RSQL filters to actually be considered for inclusion.- Specified by:
readIdBatchForPartialFeed
in classAbstractJsonArrayDataFeedCollector<String,
E extends CollectedProduct> - Parameters:
collectionRequest
-updateRecords
-sharedProcessState
-readContextInfo
-- Returns:
-
getProductDataFeedCollectorProperties
-
getExternalCatalogProvider
-