Class DefaultPriceListService<P extends PriceList>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.pricing.service.DefaultPriceListService<P>
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, PriceListService<P>

public class DefaultPriceListService<P extends PriceList> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements PriceListService<P>
Author:
Chad Harchar (charchar)
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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 Summary

    Modifier and Type
    Method
    Description
    protected List<String>
    convertPriceListRefToIdList(Collection<com.broadleafcommerce.pricing.client.domain.PriceListRef> priceListRefs)
     
    com.broadleafcommerce.pricing.client.domain.PriceListRef
    Create a lightweight PriceListRef from a PriceList object.
    protected CurrencyUtils
     
     
    protected PriceListRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    protected void
    modifyPriceContext(@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 where PriceList.getUserTargets() intersects with the provided UserTargets.
    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 all PriceListRefs that apply to a given PriceContext.
    retrievePriceListsForPriceContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext)
    Retrieves all PriceListRefs that apply to a given PriceContext.
    protected void
    setCurrencyForContext(@NonNull com.broadleafcommerce.pricing.client.domain.context.PriceContext priceContext, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Ensures that PriceContext.getCurrency() is set and is valid for the ContextInfo.

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

    getRsqlHelper, readAll, readAll, readAll, readAll

    Methods 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, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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, updateSort

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll
  • Field Details

  • 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: PriceListService

      Retrieves all PriceListRefs that apply to a given PriceContext.

      This method will look first for any customer- or account-specific PriceLists since these will trump any others (see PriceList.getUserTargets(). Then, it will filter by PriceList.getCurrency(). If none, then it will filter first on currency then on PriceList.getPriceContextCriteria(). In all cases, if applicable, it will filter and sort on priority.

      Specified by:
      retrievePriceListRefsForPriceContext in interface PriceListService<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: PriceListService

      Retrieves all PriceListRefs that apply to a given PriceContext.

      This method will look first for any customer- or account-specific PriceLists since these will trump any others (see PriceList.getUserTargets(). Then, it will filter by PriceList.getCurrency(). If none, then it will filter first on currency then on PriceList.getPriceContextCriteria(). In all cases, if applicable, it will filter and sort on priority.

      Specified by:
      retrievePriceListsForPriceContext in interface PriceListService<P extends PriceList>
    • convertPriceListToPriceListRef

      public com.broadleafcommerce.pricing.client.domain.PriceListRef convertPriceListToPriceListRef(PriceList priceList)
      Description copied from interface: PriceListService
      Create a lightweight PriceListRef from a PriceList object.
      Specified by:
      convertPriceListToPriceListRef in interface PriceListService<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: PriceListService
      Returns list of PriceLists for the provided priceListRefs.
      Specified by:
      readAllByPriceRefs in interface PriceListService<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: PriceListService
      Reads all price lists where PriceList.getUserTargets() intersects with the provided UserTargets.
      Specified by:
      readAllByUserTargetsIn in interface PriceListService<P extends PriceList>
      Parameters:
      userTargets - users the returned PriceList should target
      currencies - the list of CurrencyUnits by which to filter
      context - Context information regarding the current API request
      Returns:
      all PriceLists targeting the provided UserTargets.
    • readAllByCurrencyIn

      @NonNull public List<P> readAllByCurrencyIn(@NonNull List<javax.money.CurrencyUnit> currencies, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: PriceListService
      Reads all price lists targeting the given currency.
      Specified by:
      readAllByCurrencyIn in interface PriceListService<P extends PriceList>
      Parameters:
      currencies - the list of CurrencyUnits by which to filter
      context - 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:
      readAllByIds in interface PriceListService<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:
      readAllByType in interface PriceListService<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:
      readAllByName in interface PriceListService<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:
      readAllByTypeAndName in interface PriceListService<P extends PriceList>
    • readModifiableFieldsForType

      public ModifiableFields readModifiableFieldsForType(String type)
      Specified by:
      readModifiableFieldsForType in interface PriceListService<P extends PriceList>
    • readAllModifiableFieldsForType

      public Set<String> readAllModifiableFieldsForType(String type)
      Description copied from interface: PriceListService
      Returns the fields that the PriceModifier components can use for calculations.
      Specified by:
      readAllModifiableFieldsForType in interface PriceListService<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 request
      contextInfo - 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 that PriceContext.getCurrency() is set and is valid for the ContextInfo. If it is not set, then this will check the currency related to request locale, then Application on contextInfo, then finally SystemCurrencyContextHolder.

      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 of Application.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()
      Overrides:
      getRepository in class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends PriceList>
    • getCurrencyUtils

      protected CurrencyUtils getCurrencyUtils()
    • getPriceListFilterService

      protected PriceListFilterService getPriceListFilterService()
    • getTypeFactory

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