Class JpaCustomizedVariantRepository<D extends JpaVariant>
java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.product.JpaCustomizedVariantRepository<D>
- All Implemented Interfaces:
CustomizedVariantRepository<D>
,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedVariantRepository<D extends JpaVariant>
extends Object
implements CustomizedVariantRepository<D>, org.springframework.beans.factory.InitializingBean
- Author:
- Samarth Dhruva (samarthd)
-
Constructor Summary
ConstructorDescriptionJpaCustomizedVariantRepository
(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder filterRulesCriteriaBuilder, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager) -
Method Summary
Modifier and TypeMethodDescriptionvoid
protected void
applyProductSubqueryActiveFilters
(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Subquery<String> subquery, jakarta.persistence.criteria.Root<JpaProduct> products, Map<String, Object> params, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected void
applyVariantOrProductContextIdPredicates
(@NonNull Iterable<String> variantContextIds, @NonNull Iterable<String> productContextIds, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<D> criteria, jakarta.persistence.criteria.Root<D> variants, List<jakarta.persistence.criteria.Predicate> predicates, Map<String, Object> params) protected jakarta.persistence.criteria.Predicate
buildContextIdInFilter
(Collection<String> contextIds, jakarta.persistence.criteria.Root<D> variantEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildProductContextIdInFilter
(Collection<String> productContextIds, jakarta.persistence.criteria.Root<D> variantEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String, Object> parameterValues) protected jakarta.persistence.criteria.Predicate
buildSkuInFilter
(Collection<String> skus, jakarta.persistence.criteria.Root<D> variantEntity, 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.findAllByContextIdIn
(Collection<String> contextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves all variants whose context IDs match any of the given IDs.findAllByProductContextIdIn
(Collection<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the variants which are associated with any of the givenproductContextIds
.findAllByProductContextIdInAndSkuIn
(Collection<String> productContextIds, Collection<String> skus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all variants which are associated with any of the givenproductContextIds
andskus
.findAllByVariantOrProductContextId
(@NonNull Iterable<String> variantContextIds, @NonNull Iterable<String> productContextIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) protected JpaCatalogQueryHelper
protected jakarta.persistence.EntityManager
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
void
setCatalogQueryHelper
(JpaCatalogQueryHelper catalogQueryHelper) void
setRepository
(VariantRepository<D> repository) protected boolean
shouldFilterProductOnActiveFlagAndDates
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This checks whether or not to apply active flag & dates filtering.
-
Constructor Details
-
JpaCustomizedVariantRepository
public JpaCustomizedVariantRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, 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
-
findAllByContextIdIn
public Stream<D> findAllByContextIdIn(Collection<String> contextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedVariantRepository
Retrieves all variants whose context IDs match any of the given IDs.- Specified by:
findAllByContextIdIn
in interfaceCustomizedVariantRepository<D extends JpaVariant>
- Parameters:
contextIds
- the context IDs to query forcontextInfo
- context information around sandbox and multitenant state- Returns:
- all variants whose context IDs match any of the given IDs
-
findAllByProductContextIdIn
public Stream<D> findAllByProductContextIdIn(Collection<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedVariantRepository
Reads all of the variants which are associated with any of the givenproductContextIds
.- Specified by:
findAllByProductContextIdIn
in interfaceCustomizedVariantRepository<D extends JpaVariant>
- 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 variants which are associated with any of the given
productContextIds
-
findAllByProductContextIdInAndSkuIn
public Stream<D> findAllByProductContextIdInAndSkuIn(Collection<String> productContextIds, Collection<String> skus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedVariantRepository
Reads all variants which are associated with any of the givenproductContextIds
andskus
.- Specified by:
findAllByProductContextIdInAndSkuIn
in interfaceCustomizedVariantRepository<D extends JpaVariant>
- Parameters:
productContextIds
- a collection of product context IDs which the results must be associated withskus
- a collection of skus which the results must be associated withcontextInfo
- context information surrounding sandboxing and multitenant state- Returns:
- all variants which are associated with any of the given
productContextIds
andskus
-
findAllByVariantOrProductContextId
public List<D> findAllByVariantOrProductContextId(@NonNull @NonNull Iterable<String> variantContextIds, @NonNull @NonNull Iterable<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedVariantRepository
- Specified by:
findAllByVariantOrProductContextId
in interfaceCustomizedVariantRepository<D extends JpaVariant>
- Parameters:
variantContextIds
- Variant IDs to match againstproductContextIds
- IDs of parent Products to match againstcontext
- Request context information around sandbox and multitenant state- Returns:
- A stream of all the
Variants
that match eithervariantContextIds
orproductContextIds
.
-
applyVariantOrProductContextIdPredicates
protected void applyVariantOrProductContextIdPredicates(@NonNull @NonNull Iterable<String> variantContextIds, @NonNull @NonNull Iterable<String> productContextIds, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<D> criteria, jakarta.persistence.criteria.Root<D> variants, List<jakarta.persistence.criteria.Predicate> predicates, Map<String, Object> params) -
applyProductSubqueryActiveFilters
protected void applyProductSubqueryActiveFilters(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.Subquery<String> subquery, jakarta.persistence.criteria.Root<JpaProduct> products, Map<String, Object> params, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) -
countNonProductionRecordsByProductIdsInTenant
public long countNonProductionRecordsByProductIdsInTenant(@NonNull @NonNull Iterable<String> productContextIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedVariantRepository
Returns the count of non-production records that match the givenproductContextIds
and the given tenant context.- Specified by:
countNonProductionRecordsByProductIdsInTenant
in interfaceCustomizedVariantRepository<D extends JpaVariant>
- 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
-
buildContextIdInFilter
-
buildProductContextIdInFilter
-
buildSkuInFilter
-
shouldFilterProductOnActiveFlagAndDates
protected boolean shouldFilterProductOnActiveFlagAndDates(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This checks whether or not to apply active flag & dates filtering. Active filtering is normally applied to queries during theJpaNarrowExecutor
narrowing logic when in a standard user or preview flow. However in some cases, like the subquery for products in this class, we also would like to check if custom active filters should apply. This method uses the same checks as the active flag & date context info customizers to determine when to enable/disable active filtering.- Parameters:
contextInfo
- context information surrounding sandboxing/multitenant state- Returns:
- true, if filters for active flag & dates should be applied to the product
- See Also:
-
ActiveDateFilteringEnabledContextInfoCustomizer
ActiveFlagFilteringEnabledContextInfoCustomizer
-
getNarrowingHelper
protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper() -
getEntityManager
protected jakarta.persistence.EntityManager getEntityManager() -
getCatalogQueryHelper
-
setCatalogQueryHelper
-