Class JpaCustomizedContentItemRepository<D extends JpaContentItem>

java.lang.Object
com.broadleafcommerce.content.provider.jpa.repository.JpaCustomizedContentItemRepository<D>
All Implemented Interfaces:
CustomizedContentItemRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedContentItemRepository<D extends JpaContentItem> extends Object implements CustomizedContentItemRepository<D>, org.springframework.beans.factory.InitializingBean
Author:
Nathan Moore (nathandmoore)
  • Field Summary

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

    Constructors
    Constructor
    Description
    JpaCustomizedContentItemRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate,Class<?>> rsqlVisitor, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder catalogFilterRuleCriteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addActiveDateRangePredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
    Adds a predicate to filter for active items by a content item's active date range
    protected void
    addEmbeddedFilterPredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates)
    Adds a predicate to filter out content items marked as embedded
    protected void
    addInactiveDateRangePredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
    Adds a predicate to filter for inactive items by a content item's active date range
    protected void
    addNamePredicate(String nameQuery, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
    Adds a predicate for filtering by a content item's name "like" the passed in string
    protected void
    addPredicateForField(String field, String query, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
    Adds a predicate for filtering by a field on content item "like" the passed in string
    void
     
    applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.CriteriaQuery<D> nativeQuery, Map<String,Object> nativeQueryParams, List<jakarta.persistence.criteria.Predicate> nativePredicates)
    Processes the given filters to build and apply the necessary Predicate for RSQL.
    org.springframework.data.domain.Page<D>
    findAllActiveByName(String nameQuery, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Returns a list of all active content items that are associated with the given model.
    org.springframework.data.domain.Page<D>
    findAllByQuery(String query, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Returns a list of all content items that are associate with the given query
    org.springframework.data.domain.Page<D>
    findAllInactiveByName(String nameQuery, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Returns a list of all ContentItems that are currently inactive.
    findByCombinedModelAndItemUris(String uri, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Takes the given uri and returns the item where the combination of its URI and its ContentModel's URI matches.
    protected org.springframework.data.domain.Page<D>
    getActiveFilteredResults(@NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Class<D> entityType, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.CriteriaQuery<D> criteria, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
     
    protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder
     
    protected jakarta.persistence.EntityManager
     
    protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
     
    protected Class<D>
     
    protected static List<String>
    Returns a list of matches from the given query using the given regex.
     
    protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager
     
    protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
     
    protected cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate,Class<?>>
     
    void
     

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • JpaCustomizedContentItemRepository

      public JpaCustomizedContentItemRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate,Class<?>> rsqlVisitor, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder catalogFilterRuleCriteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager)
  • Method Details

    • afterPropertiesSet

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

      public org.springframework.data.domain.Page<D> findAllActiveByName(String nameQuery, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedContentItemRepository
      Returns a list of all active content items that are associated with the given model.
      Specified by:
      findAllActiveByName in interface CustomizedContentItemRepository<D extends JpaContentItem>
      Parameters:
      nameQuery - the name of the content item to search for
      filters - the filters to apply to the query
      page - the page to return
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      A list of all active content items that are associated with the given model.
    • findAllInactiveByName

      public org.springframework.data.domain.Page<D> findAllInactiveByName(String nameQuery, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedContentItemRepository
      Returns a list of all ContentItems that are currently inactive.
      Specified by:
      findAllInactiveByName in interface CustomizedContentItemRepository<D extends JpaContentItem>
      Parameters:
      nameQuery - the name of the content item to search for
      filters - the filters to apply to the query
      page - the page to return
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a list of all ContentItems that are currently inactive.
    • findByCombinedModelAndItemUris

      public Optional<D> findByCombinedModelAndItemUris(String uri, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedContentItemRepository
      Takes the given uri and returns the item where the combination of its URI and its ContentModel's URI matches.
      Specified by:
      findByCombinedModelAndItemUris in interface CustomizedContentItemRepository<D extends JpaContentItem>
      Parameters:
      uri - The URI to match against
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      A ContentItem if the combination of its and its parent model's URIs match uri.
    • findAllByQuery

      public org.springframework.data.domain.Page<D> findAllByQuery(String query, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedContentItemRepository
      Returns a list of all content items that are associate with the given query
      Specified by:
      findAllByQuery in interface CustomizedContentItemRepository<D extends JpaContentItem>
      Parameters:
      query - the name of the content item to search for
      filters - the filters to apply to the query
      page - the page to return
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      A list of all content items that are associate with the given query
    • addNamePredicate

      protected void addNamePredicate(String nameQuery, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
      Adds a predicate for filtering by a content item's name "like" the passed in string
      Parameters:
      nameQuery - the name string to query against
      builder - the criteria builder
      root - the criteria root
      predicates - the list of existing predicates to add to
      params - the list of existing narrowing params to add to
    • addPredicateForField

      protected void addPredicateForField(String field, String query, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
      Adds a predicate for filtering by a field on content item "like" the passed in string
      Parameters:
      field - the field to query against
      query - the name string to query against
      builder - the criteria builder
      root - the criteria root
      predicates - the list of existing predicates to add to
      params - the list of existing narrowing params to add to
    • addActiveDateRangePredicate

      protected void addActiveDateRangePredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
      Adds a predicate to filter for active items by a content item's active date range
      Parameters:
      builder - the criteria builder
      root - the criteria root
      predicates - the list of existing predicates to add to
      params - the list of existing narrowing params to add to
    • addInactiveDateRangePredicate

      protected void addInactiveDateRangePredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
      Adds a predicate to filter for inactive items by a content item's active date range
      Parameters:
      builder - the criteria builder
      root - the criteria root
      predicates - the list of existing predicates to add to
      params - the list of existing narrowing params to add to
    • addEmbeddedFilterPredicate

      protected void addEmbeddedFilterPredicate(jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> root, List<jakarta.persistence.criteria.Predicate> predicates)
      Adds a predicate to filter out content items marked as embedded
      Parameters:
      builder - the criteria builder
      root - the criteria root
      predicates - the list of existing predicates to add to
    • getActiveFilteredResults

      protected org.springframework.data.domain.Page<D> getActiveFilteredResults(@NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @NonNull @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, Class<D> entityType, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.CriteriaQuery<D> criteria, List<jakarta.persistence.criteria.Predicate> predicates, Map<String,Object> params)
    • applyRsqlCriteria

      protected LinkedRSQLQueryDetails applyRsqlCriteria(cz.jirutka.rsql.parser.ast.Node filters, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.CriteriaQuery<D> nativeQuery, Map<String,Object> nativeQueryParams, List<jakarta.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.
    • getQuerySearchTokens

      protected static List<String> getQuerySearchTokens(String query)
      Returns a list of matches from the given query using the given regex.
      Parameters:
      query - the query to match against
      Returns:
      a list of matches from the given query using the given regex
    • getManagedType

      protected Class<D> getManagedType()
    • getRepository

      protected ContentItemRepository<D> getRepository()
    • setRepository

      @Autowired @Lazy public void setRepository(ContentItemRepository<D> repository)
    • getHelper

      protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getHelper()
    • getRsqlQueryTransformers

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

      protected cz.jirutka.rsql.parser.ast.RSQLVisitor<jakarta.persistence.criteria.Predicate,Class<?>> getRsqlVisitor()
    • 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()
    • getEntityManager

      protected jakarta.persistence.EntityManager getEntityManager()