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
FieldsModifier and TypeFieldDescriptionprotected 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
ConstructorsConstructorDescriptionJpaCustomizedContentItemRepository
(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 TypeMethodDescriptionprotected 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 rangeprotected 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 embeddedprotected 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 rangeprotected 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 stringprotected 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 stringvoid
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 givenfilters
to build and apply the necessaryPredicate
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 givenmodel
.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 queryorg.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 allContentItem
s that are currently inactive.findByCombinedModelAndItemUris
(String uri, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Takes the givenuri
and returns the item where the combination ofits URI
and itsContentModel'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
getQuerySearchTokens
(String query) Returns a list of matches from the givenquery
using the givenregex
.protected ContentItemRepository<D>
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
setRepository
(ContentItemRepository<D> repository)
-
Field Details
-
URI
- See Also:
-
ADDRESSABLE_BY_URI
- See Also:
-
NAME
- See Also:
-
TAGS
- See Also:
-
AUTHOR_USERNAME
- See Also:
-
AUTHOR_NAME
- See Also:
-
NOW
- See Also:
-
ACTIVE_START_DATE
- See Also:
-
ACTIVE_END_DATE
- See Also:
-
IS_EMBEDDED
- See Also:
-
TENANT
- See Also:
-
EMPTY_ARRAY
- See Also:
-
-
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 interfaceorg.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 givenmodel
.- Specified by:
findAllActiveByName
in interfaceCustomizedContentItemRepository<D extends JpaContentItem>
- Parameters:
nameQuery
- the name of the content item to search forfilters
- the filters to apply to the querypage
- the page to returncontextInfo
- 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 allContentItem
s that are currently inactive.- Specified by:
findAllInactiveByName
in interfaceCustomizedContentItemRepository<D extends JpaContentItem>
- Parameters:
nameQuery
- the name of the content item to search forfilters
- the filters to apply to the querypage
- the page to returncontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- a list of all
ContentItem
s 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 givenuri
and returns the item where the combination ofits URI
and itsContentModel's URI
matches.- Specified by:
findByCombinedModelAndItemUris
in interfaceCustomizedContentItemRepository<D extends JpaContentItem>
- Parameters:
uri
- The URI to match againstcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- A
ContentItem
if the combination of its and its parent model's URIs matchuri
.
-
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 interfaceCustomizedContentItemRepository<D extends JpaContentItem>
- Parameters:
query
- the name of the content item to search forfilters
- the filters to apply to the querypage
- the page to returncontextInfo
- 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 againstbuilder
- the criteria builderroot
- the criteria rootpredicates
- the list of existing predicates to add toparams
- 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 againstquery
- the name string to query againstbuilder
- the criteria builderroot
- the criteria rootpredicates
- the list of existing predicates to add toparams
- 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 builderroot
- the criteria rootpredicates
- the list of existing predicates to add toparams
- 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 builderroot
- the criteria rootpredicates
- the list of existing predicates to add toparams
- 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 builderroot
- the criteria rootpredicates
- 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 givenfilters
to build and apply the necessaryPredicate
for RSQL.- Parameters:
filters
- RSQL filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.criteriaBuilder
- the criteria builder used to generate parameters/predicates. Only used as an argument to populate theCriteriaContext
inCriteriaContext.withBuilder(CriteriaBuilder)
.nativeQuery
- the native query for the original request. Only used as an argument to populate theCriteriaContext
inCriteriaContext.withCriteriaQuery(AbstractQuery)
.nativeQueryParams
- the parameter values for thenativeQuery
. Only used as an argument to populate theCriteriaContext
inCriteriaContext.withNarrowingParams(Map)
.nativePredicates
- the list of predicates that will be applied onnativeQuery
. If thefilters
are not for linked fields, then thePredicate
will be added to this list.- Returns:
- the
CriteriaContext.getLinkedQuery()
andCriteriaContext.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 toJpaNarrowingHelper.JpaCriterias
.
-
getQuerySearchTokens
Returns a list of matches from the givenquery
using the givenregex
.- Parameters:
query
- the query to match against- Returns:
- a list of matches from the given
query
using the givenregex
-
getManagedType
-
getRepository
-
setRepository
-
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()
-