Class DefaultPriceListFilterService
java.lang.Object
com.broadleafcommerce.pricing.service.DefaultPriceListFilterService
- All Implemented Interfaces:
PriceListFilterService
- Author:
- Chad Harchar (charchar)
-
Constructor Summary
ConstructorDescriptionDefaultPriceListFilterService
(com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService ruleEvaluationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CurrencyUtils currencyUtils, UserTargetFilterService userTargetFilterService, CurrencyConversionService currencyConversionService) -
Method Summary
Modifier and TypeMethodDescriptionprotected 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.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.void
filterPriceListsUsingCurrencyInfo
(List<? extends PriceList> initialList, CurrencyInfo currencyInfo) Filter price lists based on currency.protected CurrencyConversionService
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) protected CurrencyUtils
getFilteredPriceLists
(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, PriceListService<P> priceListService) Filters all price lists by type and combines the results into single listprotected Set<UserTarget>
getRelevantUserTargets
(com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo ctx) protected com.broadleafcommerce.rulesengine.expression.service.RuleEvaluationService
protected com.broadleafcommerce.common.extension.TypeFactory
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) prioritizePriceLists
(List<P> priceLists) Sorts the price lists by priority in ascending order, then returns all those with the highest priority.
-
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 interfacePriceListFilterService
- Type Parameters:
P
-- Parameters:
priceContext
- The price context with which to filter matching price listscontextInfo
- The context info with which to determine price lists that may applypriceListService
-- 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 filtercurrencyInfo
- 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 againstinitialList
- The initial price lists to filter
-
prioritizePriceLists
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 interfacePriceListFilterService
- 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) Convertuser target refs
onPriceContext
touser targets
.Then, filter targets for those that are used by PriceLists.
- Parameters:
priceContext
- The context which holdsUserTargetRef
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
-
getUserTargetFilterService
-
getCurrencyConversionService
-