Class JpaCustomizedProductAssetRepository<D extends JpaProductAsset>

java.lang.Object
com.broadleafcommerce.catalog.provider.jpa.repository.asset.JpaCustomizedProductAssetRepository<D>
All Implemented Interfaces:
CustomizedProductAssetRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedProductAssetRepository<D extends JpaProductAsset> extends Object implements CustomizedProductAssetRepository<D>, org.springframework.beans.factory.InitializingBean
Author:
Samarth Dhruva (samarthd)
  • Constructor Details

    • JpaCustomizedProductAssetRepository

      public JpaCustomizedProductAssetRepository(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 catalogFilterRuleCriteriaBuilder, 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(ProductAssetRepository<D> repository)
    • searchAllWithProductContextId

      @NonNull @Policy(operationTypes=READ) public org.springframework.data.domain.Page<D> searchAllWithProductContextId(@NonNull String productContextId, @Nullable Boolean isSorted, @Nullable String searchString, @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedProductAssetRepository
      Finds all ProductAssets for the given product context ID, optionally filtering by additional search/filter arguments.

      If searchString is provided, then this method will search for assets whose EntityAsset.url, EntityAsset.title, EntityAsset.altText, or EntityAsset.tags contain it.

      If no searchString is provided, then this method will simply return all assets for the given product.

      This method also supports RSQL filtration via filters.

      Specified by:
      searchAllWithProductContextId in interface CustomizedProductAssetRepository<D extends JpaProductAsset>
      Parameters:
      productContextId - the value which the product context ID should match against
      isSorted - (optional) if not-null, will restrict results to only include ProductAssets where ProductAsset.sorted has the given value
      searchString - (optional) a string which should be found in EntityAsset.url, EntityAsset.title, EntityAsset.altText, or EntityAsset.tags
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      page - the requested page of results from the database
      contextInfo - the context to query within
      Returns:
      the assets in the database with the given product context ID, optionally filtered by the given search/filter arguments (if provided)
    • buildProductContextIdFilter

      protected jakarta.persistence.criteria.Predicate buildProductContextIdFilter(jakarta.persistence.criteria.Root<D> productAssetEntity, String productContextId, jakarta.persistence.criteria.CriteriaBuilder criteriaBuilder, Map<String,Object> parameterValues)
    • 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 given filters to build and apply the necessary Predicate for RSQL.
      Parameters:
      filters - RSQL filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      criteriaBuilder - the criteria builder used to generate parameters/predicates. Only used as an argument to populate the CriteriaContext in CriteriaContext.withBuilder(CriteriaBuilder).
      nativeQuery - the native query for the original request. Only used as an argument to populate the CriteriaContext in CriteriaContext.withCriteriaQuery(AbstractQuery).
      nativeQueryParams - the parameter values for the nativeQuery. Only used as an argument to populate the CriteriaContext in CriteriaContext.withNarrowingParams(Map).
      nativePredicates - the list of predicates that will be applied on nativeQuery. If the filters are not for linked fields, then the Predicate will be added to this list.
      Returns:
      the CriteriaContext.getLinkedQuery() and CriteriaContext.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 to JpaNarrowingHelper.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: CustomizedProductAssetRepository
      Reads all of the product assets which are associated with any of the given productContextIds.
      Specified by:
      findAllByProductContextIdIn in interface CustomizedProductAssetRepository<D extends JpaProductAsset>
      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 product assets which are associated with any of the given productContextIds
    • findAllByProductContextIdIn

      @Policy(operationTypes=READ) public Stream<D> findAllByProductContextIdIn(Collection<String> productContextIds, @NonNull @NonNull cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedProductAssetRepository
      Reads all of the product assets which are associated with any of the given productContextIds.
      Specified by:
      findAllByProductContextIdIn in interface CustomizedProductAssetRepository<D extends JpaProductAsset>
      Parameters:
      productContextIds - a collection of product context IDs which the results must be associated with
      filters - additional filters to apply in the query. Should be EmptyNode if no additional filters should be applied.
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      all of the product assets 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: CustomizedProductAssetRepository
      Returns the count of non-production records that match the given productContextIds and the given tenant context.
      Specified by:
      countNonProductionRecordsByProductIdsInTenant in interface CustomizedProductAssetRepository<D extends JpaProductAsset>
      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
    • buildProductContextIdInFilter

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

      protected ProductAssetRepository<D> getRepository()
    • getNarrowingHelper

      protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper getNarrowingHelper()
    • getRsqlQueryTransformers

      @NonNull protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> getRsqlQueryTransformers()
    • getRsqlVisitor

      @NonNull protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor()
    • getEntityManager

      protected jakarta.persistence.EntityManager getEntityManager()
    • getCatalogQueryHelper

      protected JpaCatalogQueryHelper getCatalogQueryHelper()
    • setCatalogQueryHelper

      @Autowired public void setCatalogQueryHelper(JpaCatalogQueryHelper catalogQueryHelper)