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 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 interface org.springframework.beans.factory.InitializingBean
    • setRepository

      @Autowired @Lazy public void setRepository(VariantRepository<D> repository)
    • 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 interface CustomizedVariantRepository<D extends JpaVariant>
      Parameters:
      contextIds - the context IDs to query for
      contextInfo - 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 given productContextIds.
      Specified by:
      findAllByProductContextIdIn in interface CustomizedVariantRepository<D extends JpaVariant>
      Parameters:
      productContextIds - a collection of product context IDs which the results must be associated with
      contextInfo - 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 given productContextIds and skus.
      Specified by:
      findAllByProductContextIdInAndSkuIn in interface CustomizedVariantRepository<D extends JpaVariant>
      Parameters:
      productContextIds - a collection of product context IDs which the results must be associated with
      skus - a collection of skus which the results must be associated with
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all variants which are associated with any of the given productContextIds and skus
    • 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
      Returns a stream of all the Variants that match either variantContextIds or productContextIds.
      Specified by:
      findAllByVariantOrProductContextId in interface CustomizedVariantRepository<D extends JpaVariant>
      Parameters:
      variantContextIds - Variant IDs to match against
      productContextIds - IDs of parent Products to match against
      context - Request context information around sandbox and multitenant state
      Returns:
      A stream of all the Variants that match either variantContextIds or productContextIds.
    • 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 given productContextIds and the given tenant context.
      Specified by:
      countNonProductionRecordsByProductIdsInTenant in interface CustomizedVariantRepository<D extends JpaVariant>
      Parameters:
      productContextIds - IDs of parent Products to match against
      context - 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

      protected jakarta.persistence.criteria.Predicate buildContextIdInFilter(Collection<String> contextIds, jakarta.persistence.criteria.Root<D> variantEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • buildProductContextIdInFilter

      protected jakarta.persistence.criteria.Predicate buildProductContextIdInFilter(Collection<String> productContextIds, jakarta.persistence.criteria.Root<D> variantEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • buildSkuInFilter

      protected jakarta.persistence.criteria.Predicate buildSkuInFilter(Collection<String> skus, jakarta.persistence.criteria.Root<D> variantEntity, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • 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 the JpaNarrowExecutor 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

      protected JpaCatalogQueryHelper getCatalogQueryHelper()
    • setCatalogQueryHelper

      @Autowired public void setCatalogQueryHelper(JpaCatalogQueryHelper catalogQueryHelper)