Class PricingEntityContributor

java.lang.Object
com.broadleafcommerce.datafeed.service.collector.product.PricingEntityContributor
All Implemented Interfaces:
CollectedEntityContributor, org.springframework.core.Ordered

public class PricingEntityContributor extends Object implements CollectedEntityContributor
Contributes dynamic/advanced Pricing data to the Products that are collected for a Data Feed.
Author:
Kelly Tisdell (ktisdell)
  • Field Details

    • INCLUDED_PRODUCT_PRICING_TARGET_TYPE

      public static final String 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 this CollectedEntityContributor can handle the given batch of collected entities.
      Specified by:
      canHandle in interface CollectedEntityContributor
      Parameters:
      entityType - the class that represents the batch of items to receive contributions
      request - the original request
      contextInfo - 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 interface CollectedEntityContributor
      Parameters:
      entities - the List of entities that may require contributions
      request - the original request
      processState - A Map of shared context for storing details of the collection process - expected to be thread-safe
      contextInfo - 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 a PriceContext using the Application associated with the DataFeedProcessExecution.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 customer UserTargetRef 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

      protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<T> getPriceInfoForPriceableEntity(Priceable entity, List<T> candidatePriceInfos, @Nullable com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext)
    • 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

      protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo> Optional<T> hasPriceInfoFromPriceList(List<T> candidatePriceInfos)
    • isBasePrice

      protected boolean isBasePrice(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
    • isBaseSalePrice

      protected boolean isBaseSalePrice(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
    • filterPriceInfosForCurrency

      protected <T extends com.broadleafcommerce.pricing.client.domain.PriceInfo> List<T> filterPriceInfosForCurrency(List<T> priceInfos, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext)
    • 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

      protected PricingProvider 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

      protected List<ProductPriceableTargetsBuilder> getProductPriceableTargetsBuilders()
    • getCollectedProductJsonAccessorUtils

      protected CollectedProductJsonAccessorUtils getCollectedProductJsonAccessorUtils()