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
ConstructorDescriptionJpaCustomizedProductRepository
(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 TypeMethodDescriptionvoid
protected LinkedRSQLQueryDetails
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) Processes the givenfilters
to build and apply the necessaryPredicate
for RSQL.protected jakarta.persistence.criteria.Predicate
buildContextIdInFilter
(Collection<String> contextIds, jakarta.persistence.criteria.Root<D> productEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildContextIdNotInFilter
(Collection<String> contextIds, jakarta.persistence.criteria.Root<D> productEntity, jakarta.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 matchingcontextIds
.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 givenfilters
, excluding any products whose IDs match a value inexclusions
.findAllByUriIn
(@NonNull Iterable<String> uris, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Finds all of the products with matchinguris
.findAllDistinctContextId
(int pageSize, @NonNull cz.jirutka.rsql.parser.ast.Node filters) Retrieves a list of unique product context IDs no larger thanpage
.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 aContextInfo
and no larger thanpage
.findAllDistinctContextIdPerContextWithOptionalStipulations
(@NonNull cz.jirutka.rsql.parser.ast.Node filters, ProductStipulations stipulations, int pageSize, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieves a list of unique product context IDs narrowed on aContextInfo
and no larger thanpage
.protected jakarta.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
setRepository
(ProductRepository<D> repository) void
setRsqlParser
(cz.jirutka.rsql.parser.RSQLParser rsqlParser)
-
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 interfaceorg.springframework.beans.factory.InitializingBean
-
setRepository
-
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 thanpage
. It is expected that any appropriate offset is achieved through criteria designated infilters
.- Specified by:
findAllDistinctContextId
in interfaceCustomizedProductRepository<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 beEmptyNode
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 aContextInfo
and no larger thanpage
. It is expected that any appropriate offset is achieved through criteria designated infilters
.- Specified by:
findAllDistinctContextIdPerContext
in interfaceCustomizedProductRepository<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 beEmptyNode
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
-
findAllDistinctContextIdPerContextWithOptionalStipulations
@Policy(operationTypes=READ) public List<String> findAllDistinctContextIdPerContextWithOptionalStipulations(@NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable ProductStipulations stipulations, int pageSize, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedProductRepository
Retrieves a list of unique product context IDs narrowed on aContextInfo
and no larger thanpage
. It is expected that any appropriate offset is achieved through criteria designated infilters
.- Specified by:
findAllDistinctContextIdPerContextWithOptionalStipulations
in interfaceCustomizedProductRepository<D extends JpaProduct>
- Parameters:
filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.stipulations
- Additional filtering context to be applied during product fetch. Stipulations are applied as a set of OR conditions, and any match of any of the stipulations designates a match for this set of conditions. Optional.pageSize
- the requested amount of results from the database. -1 indicates no limit.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 givenfilters
, excluding any products whose IDs match a value inexclusions
.- Specified by:
findAllByContextIdNotIn
in interfaceCustomizedProductRepository<D extends JpaProduct>
- Parameters:
exclusions
- a list of context IDs of products which should be excluded from the resultsfilters
- additional filters to apply in the query. Should beEmptyNode
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 inexclusions
-
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 matchingcontextIds
.- Specified by:
findAllByContextIdIn
in interfaceCustomizedProductRepository<D extends JpaProduct>
- Parameters:
contextIds
- The contextIds to matchcontextInfo
- 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 matchinguris
.- Specified by:
findAllByUriIn
in interfaceCustomizedProductRepository<D extends JpaProduct>
- Parameters:
uris
- The URIs to matchcontextInfo
- 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 interfaceCustomizedProductRepository<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, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, jakarta.persistence.criteria.CriteriaQuery<?> 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
.
-
buildContextIdInFilter
-
buildContextIdNotInFilter
-
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 jakarta.persistence.EntityManager getEntityManager() -
getRsqlParser
protected cz.jirutka.rsql.parser.RSQLParser getRsqlParser() -
setRsqlParser
public void setRsqlParser(cz.jirutka.rsql.parser.RSQLParser rsqlParser)
-