Class DefaultPriceListService<P extends PriceList>
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>,PriceListService<P>
- Author:
- Chad Harchar (charchar)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPriceListService(PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PriceListFilterService priceListFilterService, CurrencyUtils currencyUtils, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) -
Method Summary
Modifier and TypeMethodDescriptionconvertPriceListRefToIdList(Collection<com.broadleafcommerce.pricing.client.domain.PriceListRef> priceListRefs) com.broadleafcommerce.pricing.client.domain.PriceListRefconvertPriceListToPriceListRef(PriceList priceList) Create a lightweight PriceListRef from a PriceList object.protected CurrencyUtilsprotected PriceListFilterServiceprotected PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.TypeFactoryprotected voidmodifyPriceContext(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extend this if you want to modify the provided price context, for example removing certain attributes for security reasons.readAllByCurrencyIn(List<javax.money.CurrencyUnit> currencies, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all price lists targeting the given currency.org.springframework.data.domain.Page<P>readAllByIds(Iterable<String> ids, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<P>readAllByName(String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) readAllByPriceRefs(Collection<com.broadleafcommerce.pricing.client.domain.PriceListRef> priceListRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns list of PriceLists for the provided priceListRefs.org.springframework.data.domain.Page<P>readAllByType(String type, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<P>readAllByTypeAndName(String type, String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) readAllByUserTargetsIn(Iterable<UserTarget> userTargets, List<javax.money.CurrencyUnit> currencies, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads all price lists wherePriceList.getUserTargets()intersects with the providedUserTargets.Returns the fields that the PriceModifier components can use for calculations.List<com.broadleafcommerce.pricing.client.domain.PriceListRef>retrievePriceListRefsForPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Retrieves allPriceListRefsthat apply to a givenPriceContext.retrievePriceListsForPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Retrieves allPriceListRefsthat apply to a givenPriceContext.protected voidsetCurrencyForContext(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Ensures thatPriceContext.getCurrency()is set and is valid for theContextInfo.Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Field Details
-
CACHE_BY_PRICE_LIST
- See Also:
-
CACHE_BY_CURRENCY
- See Also:
-
CACHE_BY_USER
- See Also:
-
-
Constructor Details
-
DefaultPriceListService
public DefaultPriceListService(PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.common.extension.TypeFactory typeFactory, PriceListFilterService priceListFilterService, CurrencyUtils currencyUtils, com.broadleafcommerce.common.extension.cache.CacheStateManager cacheStateManager, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
-
-
Method Details
-
retrievePriceListRefsForPriceContext
@NonNull public List<com.broadleafcommerce.pricing.client.domain.PriceListRef> retrievePriceListRefsForPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Description copied from interface:PriceListServiceRetrieves all
PriceListRefsthat apply to a givenPriceContext.This method will look first for any customer- or account-specific
PriceListssince these will trump any others (seePriceList.getUserTargets(). Then, it will filter byPriceList.getCurrency(). If none, then it will filter first on currency then onPriceList.getPriceContextCriteria(). In all cases, if applicable, it will filter and sort on priority.- Specified by:
retrievePriceListRefsForPriceContextin interfacePriceListService<P extends PriceList>
-
retrievePriceListsForPriceContext
@NonNull public List<P> retrievePriceListsForPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext) Description copied from interface:PriceListServiceRetrieves all
PriceListRefsthat apply to a givenPriceContext.This method will look first for any customer- or account-specific
PriceListssince these will trump any others (seePriceList.getUserTargets(). Then, it will filter byPriceList.getCurrency(). If none, then it will filter first on currency then onPriceList.getPriceContextCriteria(). In all cases, if applicable, it will filter and sort on priority.- Specified by:
retrievePriceListsForPriceContextin interfacePriceListService<P extends PriceList>
-
convertPriceListToPriceListRef
public com.broadleafcommerce.pricing.client.domain.PriceListRef convertPriceListToPriceListRef(PriceList priceList) Description copied from interface:PriceListServiceCreate a lightweight PriceListRef from a PriceList object.- Specified by:
convertPriceListToPriceListRefin interfacePriceListService<P extends PriceList>- Returns:
-
readAllByPriceRefs
@NonNull public List<P> readAllByPriceRefs(Collection<com.broadleafcommerce.pricing.client.domain.PriceListRef> priceListRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:PriceListServiceReturns list of PriceLists for the provided priceListRefs.- Specified by:
readAllByPriceRefsin interfacePriceListService<P extends PriceList>- Returns:
-
convertPriceListRefToIdList
protected List<String> convertPriceListRefToIdList(Collection<com.broadleafcommerce.pricing.client.domain.PriceListRef> priceListRefs) -
readAllByUserTargetsIn
@NonNull public List<P> readAllByUserTargetsIn(@NonNull Iterable<UserTarget> userTargets, @NonNull List<javax.money.CurrencyUnit> currencies, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:PriceListServiceReads all price lists wherePriceList.getUserTargets()intersects with the providedUserTargets.- Specified by:
readAllByUserTargetsInin interfacePriceListService<P extends PriceList>- Parameters:
userTargets- users the returnedPriceListshould targetcurrencies- the list ofCurrencyUnits by which to filtercontext- Context information regarding the current API request- Returns:
- all
PriceLists targeting the providedUserTargets.
-
readAllByCurrencyIn
@NonNull public List<P> readAllByCurrencyIn(@NonNull List<javax.money.CurrencyUnit> currencies, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:PriceListServiceReads all price lists targeting the given currency.- Specified by:
readAllByCurrencyInin interfacePriceListService<P extends PriceList>- Parameters:
currencies- the list ofCurrencyUnits by which to filtercontext- Context information regarding the current API request- Returns:
- all
PriceLists targeting the provided currency
-
readAllByIds
@NonNull public org.springframework.data.domain.Page<P> readAllByIds(@NonNull Iterable<String> ids, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByIdsin interfacePriceListService<P extends PriceList>
-
readAllByType
@NonNull public org.springframework.data.domain.Page<P> readAllByType(@NonNull String type, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByTypein interfacePriceListService<P extends PriceList>
-
readAllByName
@NonNull public org.springframework.data.domain.Page<P> readAllByName(@NonNull String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByNamein interfacePriceListService<P extends PriceList>
-
readAllByTypeAndName
@NonNull public org.springframework.data.domain.Page<P> readAllByTypeAndName(@NonNull String type, @NonNull String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
readAllByTypeAndNamein interfacePriceListService<P extends PriceList>
-
readModifiableFieldsForType
- Specified by:
readModifiableFieldsForTypein interfacePriceListService<P extends PriceList>
-
readAllModifiableFieldsForType
Description copied from interface:PriceListServiceReturns the fields that the PriceModifier components can use for calculations.- Specified by:
readAllModifiableFieldsForTypein interfacePriceListService<P extends PriceList>- Returns:
-
modifyPriceContext
protected void modifyPriceContext(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Extend this if you want to modify the provided price context, for example removing certain attributes for security reasons. Left blank by default.- Parameters:
priceContext- data relevant for determining which pricing entities apply to an API requestcontextInfo- Optional sandbox and multitenant info
-
setCurrencyForContext
protected void setCurrencyForContext(@NonNull @NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Ensures thatPriceContext.getCurrency()is set and is valid for theContextInfo. If it is not set, then this will check the currency related torequest locale, thenApplicationoncontextInfo, then finallySystemCurrencyContextHolder.Moreover, currency may be requested on
priceContext, but, if it is not valid for the current application, it will not be honored and the result ofApplication.computeDefaultCurrency()will be used instead.- Parameters:
priceContext- Data relevant for determining which pricing entities apply to an API request.contextInfo- Additional context for multitenancy and sandbox
-
getRepository
@NonNull protected PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository() -
getCurrencyUtils
-
getPriceListFilterService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-