Class JpaCustomizedPriceDataRepository<D extends JpaPriceData>

java.lang.Object
com.broadleafcommerce.pricing.provider.jpa.repository.JpaCustomizedPriceDataRepository<D>
All Implemented Interfaces:
CustomizedPriceDataRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedPriceDataRepository<D extends JpaPriceData> extends Object implements CustomizedPriceDataRepository<D>, org.springframework.beans.factory.InitializingBean
Repository fragment for JpaPriceDataRepository that includes custom JPA query methods.
Author:
Nick Crum ncrum
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    JpaCustomizedPriceDataRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addPriceListIdPredicate(String priceListId, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root)
     
    protected void
    addTargetTypePredicate(String targetType, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root)
     
    void
     
    protected void
    applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.CriteriaQuery<?> nativeQuery, Map<String,Object> nativeQueryParams, List<jakarta.persistence.criteria.Predicate> nativePredicates, Class<?> type)
     
    org.springframework.data.domain.Page<D>
    findByPriceListIdAndTarget(String priceListId, String targetType, Collection<String> targetIds, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    org.springframework.data.domain.Page<D>
    findByPriceListIdAndTarget(String priceListId, String targetType, Collection<String> targetIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Deprecated, for removal: This API element is subject to removal in a future version.
    findByTargetAndPriceListId(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, String priceListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    findByTargetInAndPriceListIdsIn(Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, Collection<String> priceListIds, boolean filterByVendor, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds a list of price data by the given PriceableTargetRefs and price list ids.
    protected List<String>
    findIdsByPriceListId(AtomicReference<String> startingIdField, String priceListId, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds a list of JpaPriceData.get_id() from the given starting id, pricelist id, filters, and paging details.
    protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
     
    protected final Class<D>
     
    protected List<D>
    getPriceDataFromIds(List<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
     
    protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager
     
    protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor
     
    protected jakarta.persistence.criteria.Predicate
    getVendorRefPredicate(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef targetRef, String vendorRefFieldName, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, Map<String,Object> params)
     
    readAllByPriceListId(String priceListId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Reads all JpaPriceData by the given price list id.
    void
     

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.broadleafcommerce.pricing.repository.CustomizedPriceDataRepository

    findByTargetInAndPriceListIdsIn
  • Constructor Details

    • JpaCustomizedPriceDataRepository

      public JpaCustomizedPriceDataRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • setRepository

      @Autowired @Lazy public void setRepository(PriceDataRepository<D> repository)
    • findByPriceListIdAndTarget

      @NonNull @Deprecated(since="1.7.2", forRemoval=true) public org.springframework.data.domain.Page<D> findByPriceListIdAndTarget(@Nullable String priceListId, @Nullable String targetType, Collection<String> targetIds, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      findByPriceListIdAndTarget in interface CustomizedPriceDataRepository<D extends JpaPriceData>
    • findByPriceListIdAndTarget

      @NonNull public org.springframework.data.domain.Page<D> findByPriceListIdAndTarget(@Nullable String priceListId, @Nullable String targetType, Collection<String> targetIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      findByPriceListIdAndTarget in interface CustomizedPriceDataRepository<D extends JpaPriceData>
    • findByTargetInAndPriceListIdsIn

      @NonNull public List<D> findByTargetInAndPriceListIdsIn(@NonNull Collection<com.broadleafcommerce.pricing.client.domain.PriceableTargetRef> targets, @NonNull Collection<String> priceListIds, boolean filterByVendor, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedPriceDataRepository
      Finds a list of price data by the given PriceableTargetRefs and price list ids.
      Specified by:
      findByTargetInAndPriceListIdsIn in interface CustomizedPriceDataRepository<D extends JpaPriceData>
      Parameters:
      targets - a list of PriceableTargetRefs to match
      priceListIds - a list of price list ids to look for
      filterByVendor - whether to also filter the price data based on the {@link {@link PriceableTargetRef#getVendorRef()}
      contextInfo - the current context
      Returns:
      a list of price data by the given PriceableTargetRefs and price list ids
    • getVendorRefPredicate

      protected jakarta.persistence.criteria.Predicate getVendorRefPredicate(com.broadleafcommerce.pricing.client.domain.PriceableTargetRef targetRef, String vendorRefFieldName, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, Map<String,Object> params)
    • findByTargetAndPriceListId

      @NonNull public Optional<D> findByTargetAndPriceListId(@NonNull com.broadleafcommerce.pricing.client.domain.PriceableTargetRef target, @NonNull String priceListId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Specified by:
      findByTargetAndPriceListId in interface CustomizedPriceDataRepository<D extends JpaPriceData>
    • readAllByPriceListId

      public Stream<D> readAllByPriceListId(String priceListId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedPriceDataRepository
      Reads all JpaPriceData by the given price list id.

      This method explicitly fetches the ids and then fetches the entities by the ids to avoid using the SQL offset for the sake of performance, which is used under the hood in JpaNarrowExecutor when the query is a page query.

      Specified by:
      readAllByPriceListId in interface CustomizedPriceDataRepository<D extends JpaPriceData>
    • findIdsByPriceListId

      protected List<String> findIdsByPriceListId(AtomicReference<String> startingIdField, String priceListId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds a list of JpaPriceData.get_id() from the given starting id, pricelist id, filters, and paging details.

      The query uses the starting id condition and order by price list id and price data id for the sake of performance.

    • getPriceDataFromIds

      protected List<D> getPriceDataFromIds(List<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • applyRsqlCriteria

      protected void applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.CriteriaQuery<?> nativeQuery, Map<String,Object> nativeQueryParams, List<jakarta.persistence.criteria.Predicate> nativePredicates, Class<?> type)
    • addPriceListIdPredicate

      protected void addPriceListIdPredicate(String priceListId, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root)
    • addTargetTypePredicate

      protected void addTargetTypePredicate(String targetType, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root)
    • getManagedType

      protected final Class<D> getManagedType()
    • getJpaNarrowingHelper

      protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getJpaNarrowingHelper()
    • getBehaviorUtil

      protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil getBehaviorUtil()
    • getCriteriaBuilder

      protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder getCriteriaBuilder()
    • getRepositoryEntityTypeManager

      protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager getRepositoryEntityTypeManager()
    • getRsqlQueryTransformers

      protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> getRsqlQueryTransformers()
    • getRsqlVisitor

      protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor()