Class DefaultPriceListFilterService

java.lang.Object
com.broadleafcommerce.pricing.service.DefaultPriceListFilterService
All Implemented Interfaces:
PriceListFilterService

public class DefaultPriceListFilterService extends Object implements PriceListFilterService
Author:
Chad Harchar (charchar)
  • Constructor Details

    • DefaultPriceListFilterService

      public DefaultPriceListFilterService(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CurrencyUtils currencyUtils, UserTargetFilterService userTargetFilterService, CurrencyConversionService currencyConversionService)
  • Method Details

    • getFilteredPriceLists

      public <P extends PriceList> List<P> getFilteredPriceLists(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, PriceListService<P> priceListService)
      Description copied from interface: PriceListFilterService
      Filters all price lists by type and combines the results into single list
      Specified by:
      getFilteredPriceLists in interface PriceListFilterService
      Type Parameters:
      P -
      Parameters:
      priceContext - The price context with which to filter matching price lists
      contextInfo - The context info with which to determine price lists that may apply
      priceListService -
      Returns:
    • getUserTargetingPriceLists

      protected <P extends PriceList> List<P> getUserTargetingPriceLists(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, PriceListService<P> priceListService, List<javax.money.CurrencyUnit> currencies)
    • getCurrencyTargetingPriceLists

      protected <P extends PriceList> List<P> getCurrencyTargetingPriceLists(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, PriceListService<P> priceListService, List<javax.money.CurrencyUnit> currencies)
    • buildCurrenciesInfoForRequest

      protected CurrencyInfo buildCurrenciesInfoForRequest(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Returns the requested and fallback currencies based on the request and on the system defaults. Requested will always be the first item in the list. Fallback if different than requested will be the second item in the list.
      Parameters:
      priceContext -
      contextInfo -
      Returns:
    • filterPriceListsUsingCurrencyInfo

      public void filterPriceListsUsingCurrencyInfo(List<? extends PriceList> initialList, CurrencyInfo currencyInfo)
      Filter price lists based on currency. The incoming pricelists may be represented by one or two currencies as the prior retrieval logic matches pricelists based on the requested currency and the If only one currency, then the list is unmodified. This is the most typical use case. If the list contains two currencies and currencyConversion from the baseTo the requested is possible then the list is unmodified. Otherwise, the items in the fallback currency are removed. For implementations supporting multiple currencies without a converter (which is typical), they must provide a full suite of prices in each currency. For implementations using currency converters, it is possible to have sparse price lists in the non-base currency (e.g. just sales or one off prices) and allow currency conversion to handle the rest.
      Parameters:
      initialList - The initial price lists to filter
      currencyInfo - Currency information (requested, fallback) for the request
    • filterPriceListsUsingContextRules

      public void filterPriceListsUsingContextRules(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, List<? extends PriceList> initialList)
      Filter price lists by their criteria fields (PriceList.getPriceContextCriteria()) then by hierarchical relationship. Only 1 member of each hierarchy will be returned (the lowest) since descendants with price data or modifiers will trump their ancestors, but, if not, we can also get the reference to the next level up in the hierarchy as needed when actually pricing a target.
      Parameters:
      priceContext - The context to filter price lists against
      initialList - The initial price lists to filter
    • prioritizePriceLists

      public <P extends PriceList> List<P> prioritizePriceLists(List<P> priceLists)
      Description copied from interface: PriceListFilterService
      Sorts the price lists by priority in ascending order, then returns all those with the highest priority.
      Specified by:
      prioritizePriceLists in interface PriceListFilterService
      Parameters:
      priceLists - The price lists to sort
      Returns:
      The sorted price lists
    • getRelevantUserTargets

      protected Set<UserTarget> getRelevantUserTargets(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo ctx)
      Convert user target refs on PriceContext to user targets.

      Then, filter targets for those that are used by PriceLists.

      Parameters:
      priceContext - The context which holds UserTargetRef to convert
      Returns:
      The list of UserTarget that have been converted
    • getRuleEvaluationService

      protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService getRuleEvaluationService()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getCurrencyUtils

      protected CurrencyUtils getCurrencyUtils()
    • getUserTargetFilterService

      public UserTargetFilterService getUserTargetFilterService()
    • getCurrencyConversionService

      protected CurrencyConversionService getCurrencyConversionService()