Class PricingEntityContributor
java.lang.Object
com.broadleafcommerce.datafeed.service.collector.product.PricingEntityContributor
- All Implemented Interfaces:
CollectedEntityContributor
,org.springframework.core.Ordered
Contributes dynamic/advanced Pricing data to the Products that are collected for a Data Feed.
- Author:
- Kelly Tisdell (ktisdell)
-
Field Summary
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
-
Constructor Summary
ConstructorDescriptionPricingEntityContributor
(PricingProvider externalPricingProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.tenant.service.CommonApplicationService<com.broadleafcommerce.data.tracking.core.tenant.domain.Application> applicationService, List<ProductPriceableTargetsBuilder> productPriceableTargetsBuilders, CollectedProductJsonAccessorUtils collectedProductJsonAccessorUtils) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
assignDefaultProductPriceInfos
(@NonNull List<CollectedProduct> products, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
assignPriceInfosToProducts
(@NonNull List<CollectedProduct> products, @NonNull Map<Object, Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> targetsMap, @NonNull List<com.broadleafcommerce.pricing.client.domain.PriceInfo> priceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) boolean
canHandle
(@NonNull Class<?> entityType, @NonNull DataFeedCollectionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Indicates if thisCollectedEntityContributor
can handle the given batch of collected entities.protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
Optional<T>checkForPriceInfoForVariantFromPriceList
(List<T> candidatePriceInfos, VariantSummary variant) protected com.broadleafcommerce.pricing.client.domain.context.PriceContext
constructPriceContext
(@NonNull List<CollectedProduct> products, @NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Constructs aPriceContext
using theApplication
associated with theDataFeedProcessExecution.getApplicationId()
.protected com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext
constructPriceInfoContext
(@NonNull List<CollectedProduct> products, @NonNull Map<Object, Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> targetsMap, @NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
contribute
(@NonNull List<? extends CollectedEntity<?>> entities, @NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to allow the augmentation or decoration of a batch of entities that have been fetched, but that may need additional data from other sources.createTargetsMap
(@NonNull List<CollectedProduct> products, @NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
List<T>filterPriceInfosForCurrency
(List<T> priceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
voidfixStandardPriceIfNeeded
(T variantPriceInfo, List<T> candidatePriceInfos) protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonApplicationService<com.broadleafcommerce.data.tracking.core.tenant.domain.Application>
protected CollectedProductJsonAccessorUtils
protected PricingProvider
protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
Optional<T>getPriceInfoForPriceableEntity
(Priceable entity, List<T> candidatePriceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) protected List<ProductPriceableTargetsBuilder>
protected com.broadleafcommerce.common.extension.TypeFactory
protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo>
Optional<T>hasPriceInfoFromPriceList
(List<T> candidatePriceInfos) protected boolean
isBasePrice
(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) protected boolean
isBaseSalePrice
(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) protected boolean
isDirectVariantPrice
(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, VariantSummary variant) protected boolean
isTargetingVariantSku
(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, VariantSummary variant) protected com.broadleafcommerce.data.tracking.core.tenant.domain.Application
readApplication
(@NonNull DataFeedCollectionRequest request, @NonNull Map<String, Object> processState, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.datafeed.service.collector.CollectedEntityContributor
getOrder
-
Field Details
-
INCLUDED_PRODUCT_PRICING_TARGET_TYPE
- See Also:
-
-
Constructor Details
-
PricingEntityContributor
public PricingEntityContributor(PricingProvider externalPricingProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.broadleafcommerce.data.tracking.core.tenant.service.CommonApplicationService<com.broadleafcommerce.data.tracking.core.tenant.domain.Application> applicationService, List<ProductPriceableTargetsBuilder> productPriceableTargetsBuilders, CollectedProductJsonAccessorUtils collectedProductJsonAccessorUtils)
-
-
Method Details
-
canHandle
public boolean canHandle(@NonNull @NonNull Class<?> entityType, @NonNull @NonNull DataFeedCollectionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CollectedEntityContributor
Indicates if thisCollectedEntityContributor
can handle the given batch of collected entities.- Specified by:
canHandle
in interfaceCollectedEntityContributor
- Parameters:
entityType
- the class that represents the batch of items to receive contributionsrequest
- the original requestcontextInfo
- the context info associated with this process- Returns:
-
contribute
public void contribute(@NonNull @NonNull List<? extends CollectedEntity<?>> entities, @NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CollectedEntityContributor
Hook point to allow the augmentation or decoration of a batch of entities that have been fetched, but that may need additional data from other sources.- Specified by:
contribute
in interfaceCollectedEntityContributor
- Parameters:
entities
- the List of entities that may require contributionsrequest
- the original requestprocessState
- A Map of shared context for storing details of the collection process - expected to be thread-safecontextInfo
- the context info associated with this process
-
constructPriceContext
protected com.broadleafcommerce.pricing.client.domain.context.PriceContext constructPriceContext(@NonNull @NonNull List<CollectedProduct> products, @NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Constructs aPriceContext
using theApplication
associated with theDataFeedProcessExecution.getApplicationId()
. The Application instance is fetched from the DB and provides the default locale and currency to the PriceContext. By default, the constructed PriceContext also has an anonymous customerUserTargetRef
assigned to it.- Parameters:
products
-request
-processState
-contextInfo
-- Returns:
-
constructPriceInfoContext
protected com.broadleafcommerce.pricing.client.domain.context.PriceInfoContext constructPriceInfoContext(@NonNull @NonNull List<CollectedProduct> products, @NonNull @NonNull Map<Object, Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> targetsMap, @NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createTargetsMap
protected Map<Object,Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> createTargetsMap(@NonNull @NonNull List<CollectedProduct> products, @NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
assignDefaultProductPriceInfos
protected void assignDefaultProductPriceInfos(@NonNull @NonNull List<CollectedProduct> products, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
assignPriceInfosToProducts
protected void assignPriceInfosToProducts(@NonNull @NonNull List<CollectedProduct> products, @NonNull @NonNull Map<Object, Set<com.broadleafcommerce.pricing.client.domain.PriceableTarget>> targetsMap, @NonNull @NonNull List<com.broadleafcommerce.pricing.client.domain.PriceInfo> priceInfos, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getPriceInfoForPriceableEntity
-
checkForPriceInfoForVariantFromPriceList
protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<T> checkForPriceInfoForVariantFromPriceList(List<T> candidatePriceInfos, VariantSummary variant) -
isDirectVariantPrice
protected boolean isDirectVariantPrice(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, VariantSummary variant) -
isTargetingVariantSku
protected boolean isTargetingVariantSku(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo, VariantSummary variant) -
fixStandardPriceIfNeeded
protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo> void fixStandardPriceIfNeeded(T variantPriceInfo, List<T> candidatePriceInfos) -
hasPriceInfoFromPriceList
-
isBasePrice
protected boolean isBasePrice(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) -
isBaseSalePrice
protected boolean isBaseSalePrice(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo) -
filterPriceInfosForCurrency
-
readApplication
protected com.broadleafcommerce.data.tracking.core.tenant.domain.Application readApplication(@NonNull @NonNull DataFeedCollectionRequest request, @NonNull @NonNull Map<String, Object> processState, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getExternalPricingProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getApplicationService
protected com.broadleafcommerce.data.tracking.core.tenant.service.CommonApplicationService<com.broadleafcommerce.data.tracking.core.tenant.domain.Application> getApplicationService() -
getProductPriceableTargetsBuilders
-
getCollectedProductJsonAccessorUtils
-