Class JpaCustomizedProductRepository<D extends JpaProduct>

java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.product.JpaCustomizedProductRepository<D>
All Implemented Interfaces:
CustomizedProductRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedProductRepository<D extends JpaProduct> extends Object implements CustomizedProductRepository<D>, org.springframework.beans.factory.InitializingBean
  • Constructor Summary

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

    Modifier and Type
    Method
    Description
    void
     
    applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.CriteriaQuery<?> nativeQuery, Map<String,Object> nativeQueryParams, List<javax.persistence.criteria.Predicate> nativePredicates)
    Processes the given filters to build and apply the necessary Predicate for RSQL.
    protected javax.persistence.criteria.Predicate
    buildContextIdInFilter(Collection<String> contextIds, javax.persistence.criteria.Root<D> productEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
     
    protected javax.persistence.criteria.Predicate
    buildContextIdNotInFilter(Collection<String> contextIds, javax.persistence.criteria.Root<D> productEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
     
    org.springframework.data.domain.Page<D>
    findAllByCategoryContextId(String categoryContextId, Boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Finds all products in a given category.
    findAllByContextIdIn(@NonNull Iterable<String> contextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds all of the products with matching contextIds.
    findAllByContextIdNotIn(@NonNull Collection<String> exclusions, @NonNull cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds all of the products matching the given filters, excluding any products whose IDs match a value in exclusions.
    findAllByUriIn(@NonNull Iterable<String> uris, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Finds all of the products with matching uris.
    findAllDistinctContextId(int pageSize, @NonNull cz.jirutka.rsql.parser.ast.Node filters)
    Retrieves a list of unique product context IDs no larger than page.
    findAllDistinctContextIdPerContext(int pageSize, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Retrieves a narrowed list of unique product context IDs narrowed on a ContextInfo and no larger than page.
    protected javax.persistence.EntityManager
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
     
    protected cz.jirutka.rsql.parser.RSQLParser
     
    protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor
     
    protected cz.jirutka.rsql.parser.ast.Node
    ignoreArchived(cz.jirutka.rsql.parser.ast.Node filters)
     
    void
     
    void
    setRsqlParser(cz.jirutka.rsql.parser.RSQLParser rsqlParser)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JpaCustomizedProductRepository

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

    • afterPropertiesSet

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

      @Autowired @Lazy public void setRepository(ProductRepository<D> repository)
    • findAllDistinctContextId

      public List<String> findAllDistinctContextId(int pageSize, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters)
      Description copied from interface: CustomizedProductRepository
      Retrieves a list of unique product context IDs no larger than page. It is expected that any appropriate offset is achieved through criteria designated in filters.
      Specified by:
      findAllDistinctContextId in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      pageSize - the requested amount of results from the database. -1 indicates no limit.
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      Returns:
      unique product IDs
    • ignoreArchived

      protected cz.jirutka.rsql.parser.ast.Node ignoreArchived(cz.jirutka.rsql.parser.ast.Node filters)
    • findAllDistinctContextIdPerContext

      public List<String> findAllDistinctContextIdPerContext(int pageSize, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedProductRepository
      Retrieves a narrowed list of unique product context IDs narrowed on a ContextInfo and no larger than page. It is expected that any appropriate offset is achieved through criteria designated in filters.
      Specified by:
      findAllDistinctContextIdPerContext in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      pageSize - the requested amount of results from the database. -1 indicates no limit.
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      context - The context used to help narrowing. For example, narrowing results to a particular catalog.
      Returns:
      The narrowed list of unique product context IDs
    • findAllByContextIdNotIn

      @Policy(operationTypes=READ) public Stream<D> findAllByContextIdNotIn(@NonNull @NonNull Collection<String> exclusions, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedProductRepository
      Finds all of the products matching the given filters, excluding any products whose IDs match a value in exclusions.
      Specified by:
      findAllByContextIdNotIn in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      exclusions - a list of context IDs of products which should be excluded from the results
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      contextInfo - context information around sandboxing and multitenant state
      Returns:
      all of the products matching the given filters, excluding any products whose IDs match a value in exclusions
    • findAllByContextIdIn

      public List<D> findAllByContextIdIn(@NonNull @NonNull Iterable<String> contextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedProductRepository
      Finds all of the products with matching contextIds.
      Specified by:
      findAllByContextIdIn in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      contextIds - The contextIds to match
      contextInfo - Request context information around sandbox and multitenant state
      Returns:
      All of the products with matching contextIds.
    • findAllByUriIn

      public List<D> findAllByUriIn(@NonNull @NonNull Iterable<String> uris, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedProductRepository
      Finds all of the products with matching uris.
      Specified by:
      findAllByUriIn in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      uris - The URIs to match
      contextInfo - Request context information around sandbox and multitenant state
      Returns:
      All of the products with matching uris.
    • findAllByCategoryContextId

      @NonNull public org.springframework.data.domain.Page<D> findAllByCategoryContextId(@NonNull String categoryContextId, @Nullable Boolean isSorted, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedProductRepository
      Finds all products in a given category.
      Specified by:
      findAllByCategoryContextId in interface CustomizedProductRepository<D extends JpaProduct>
      Parameters:
      categoryContextId - the context id of the category.
      isSorted - – Whether to return CategoryProducts where CategoryProduct.sorted is true, else false.
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      page - the requested amount of results from the database. -1 indicates no limit.
      context - Request context information around sandbox and multitenant state
      Returns:
      All the products in the given category
    • applyRsqlCriteria

      protected LinkedRSQLQueryDetails applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.CriteriaQuery<?> nativeQuery, Map<String,Object> nativeQueryParams, List<javax.persistence.criteria.Predicate> nativePredicates)
      Processes the given filters to build and apply the necessary Predicate for RSQL.
      Parameters:
      filters - RSQL filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      criteriaBuilder - the criteria builder used to generate parameters/predicates. Only used as an argument to populate the CriteriaContext in CriteriaContext.withBuilder(CriteriaBuilder).
      nativeQuery - the native query for the original request. Only used as an argument to populate the CriteriaContext in CriteriaContext.withCriteriaQuery(AbstractQuery).
      nativeQueryParams - the parameter values for the nativeQuery. Only used as an argument to populate the CriteriaContext in CriteriaContext.withNarrowingParams(Map).
      nativePredicates - the list of predicates that will be applied on nativeQuery. If the filters are not for linked fields, then the Predicate will be added to this list.
      Returns:
      the CriteriaContext.getLinkedQuery() and CriteriaContext.getLinkedNarrowingParams() that were produced during processing. While the wrapper object will not be null, any/all of its fields can be (for example, if the filters were not on linked fields). These values are useful for ultimately being supplied to JpaNarrowingHelper.JpaCriterias.
    • buildContextIdInFilter

      protected javax.persistence.criteria.Predicate buildContextIdInFilter(Collection<String> contextIds, javax.persistence.criteria.Root<D> productEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • buildContextIdNotInFilter

      protected javax.persistence.criteria.Predicate buildContextIdNotInFilter(Collection<String> contextIds, javax.persistence.criteria.Root<D> productEntity, javax.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • getRsqlQueryTransformers

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

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

      protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper()
    • getEntityManager

      protected javax.persistence.EntityManager getEntityManager()
    • getRsqlParser

      protected cz.jirutka.rsql.parser.RSQLParser getRsqlParser()
    • setRsqlParser

      public void setRsqlParser(cz.jirutka.rsql.parser.RSQLParser rsqlParser)