Class JpaCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.JpaCustomizedCategoryProductRepository<D>
- All Implemented Interfaces:
CustomizedCategoryProductRepository<D>
,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
extends Object
implements CustomizedCategoryProductRepository<D>, org.springframework.beans.factory.InitializingBean
- Author:
- Nathan Moore (nathandmoore)
-
Constructor Summary
ConstructorDescriptionJpaCustomizedCategoryProductRepository
(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 TypeMethodDescriptionvoid
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.protected jakarta.persistence.criteria.Predicate
buildCategoryContextIdFilter
(jakarta.persistence.criteria.Root<D> categoryProductEntity, String categoryContextId, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildProductContextIdInFilter
(Collection<String> productContextIds, jakarta.persistence.criteria.Root<D> categoryProductEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) long
countNonProductionRecordsByProductIdsInTenant
(@NonNull Iterable<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.org.springframework.data.domain.Page<D>
findAllByCategoryIdAndIsSorted
(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) protected org.springframework.data.domain.Page<D>
findAllByCategoryIdAndOptions
(String categoryContextId, List<String> productIds, Boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) org.springframework.data.domain.Page<D>
findAllByCategoryIdAndProductIds
(String categoryContextId, List<String> productIds, 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>
findAllByCategoryIdAndProductIdsAndIsSorted
(String categoryContextId, List<String> productIds, boolean isSorted, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Returns allCategoryProducts
for the givenCategory.id
andProduct's ID
whereSortable.getSorted()
is true.findAllByProductContextIdIn
(Collection<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the category products which are associated with any of the givenproductContextIds
.protected JpaCatalogQueryHelper
void
setCatalogQueryHelper
(JpaCatalogQueryHelper catalogQueryHelper) void
setRepository
(CategoryProductRepository<D> repository)
-
Constructor Details
-
JpaCustomizedCategoryProductRepository
public JpaCustomizedCategoryProductRepository(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
-
setRepository
-
findAllByCategoryIdAndIsSorted
@NonNull public org.springframework.data.domain.Page<D> findAllByCategoryIdAndIsSorted(@NonNull String categoryContextId, 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:CustomizedCategoryProductRepository
- Specified by:
findAllByCategoryIdAndIsSorted
in interfaceCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
- Parameters:
categoryContextId
- aCategory's ID
for which to find all sortedCategoryProducts
.isSorted
- Whether to returnCategoryProducts
whereCategoryProduct.sorted
is true else where false.filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontext
- context surrounding sandboxing and multitenant state- Returns:
- all
CategoryProducts
for the givenCategory.id
whereSortable.getSorted()
is true.
-
findAllByCategoryIdAndProductIdsAndIsSorted
@NonNull public org.springframework.data.domain.Page<D> findAllByCategoryIdAndProductIdsAndIsSorted(@NonNull String categoryContextId, @Nullable List<String> productIds, 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:CustomizedCategoryProductRepository
Returns allCategoryProducts
for the givenCategory.id
andProduct's ID
whereSortable.getSorted()
is true.- Specified by:
findAllByCategoryIdAndProductIdsAndIsSorted
in interfaceCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
- Parameters:
categoryContextId
- aCategory's ID
for which to find all sortedCategoryProducts
.productIds
- the list ofProduct's ID
to retrieveisSorted
- Whether to returnCategoryProducts
whereCategoryProduct.sorted
is true else where false.filters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontext
- context surrounding sandboxing and multitenant state- Returns:
- all
CategoryProducts
for the givenCategory.id
whereSortable.getSorted()
is true.
-
findAllByCategoryIdAndProductIds
@NonNull public org.springframework.data.domain.Page<D> findAllByCategoryIdAndProductIds(@NonNull String categoryContextId, @Nullable List<String> productIds, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @NonNull org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCategoryProductRepository
- Specified by:
findAllByCategoryIdAndProductIds
in interfaceCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
- Parameters:
categoryContextId
- aCategory's ID
for which to find all sortedCategoryProducts
.productIds
- the list ofProduct's ID
to retrievefilters
- additional filters to apply in the query. Should beEmptyNode
if no additional filters should be applied.page
- the requested page of results from the databasecontextInfo
- context surrounding sandboxing and multitenant state- Returns:
- all
CategoryProducts
for the givenCategory.id
whereSortable.getSorted()
is true.
-
findAllByCategoryIdAndOptions
protected org.springframework.data.domain.Page<D> findAllByCategoryIdAndOptions(@NonNull String categoryContextId, @Nullable List<String> productIds, @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) -
buildCategoryContextIdFilter
-
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
.
-
findAllByProductContextIdIn
@Policy(operationTypes=READ) public Stream<D> findAllByProductContextIdIn(Collection<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedCategoryProductRepository
Reads all of the category products which are associated with any of the givenproductContextIds
.- Specified by:
findAllByProductContextIdIn
in interfaceCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
- Parameters:
productContextIds
- a collection of product context IDs which the results must be associated withcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- all of the category products which are associated with any of the given
productContextIds
-
countNonProductionRecordsByProductIdsInTenant
public long countNonProductionRecordsByProductIdsInTenant(@NonNull @NonNull Iterable<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedCategoryProductRepository
Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.- Specified by:
countNonProductionRecordsByProductIdsInTenant
in interfaceCustomizedCategoryProductRepository<D extends JpaCategoryProduct>
- Parameters:
productContextIds
- IDs of parent Products to match againstcontext
- Request context information around sandbox and multitenant state- Returns:
- the count of non-production records that match the given
productContextIds
and the given tenant context
-
buildProductContextIdInFilter
-
getCatalogQueryHelper
-
setCatalogQueryHelper
-