Class JpaCustomizedOfferCodeRepository<D extends JpaOfferCode>

java.lang.Object
com.broadleafcommerce.promotion.offer.provider.jpa.repository.JpaCustomizedOfferCodeRepository<D>
All Implemented Interfaces:
CustomizedOfferCodeRepository<D>, org.springframework.beans.factory.InitializingBean

public class JpaCustomizedOfferCodeRepository<D extends JpaOfferCode> extends Object implements CustomizedOfferCodeRepository<D>, org.springframework.beans.factory.InitializingBean
  • Constructor Details

    • JpaCustomizedOfferCodeRepository

      public JpaCustomizedOfferCodeRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder, List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> rsqlQueryTransformers, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor rsqlVisitor)
  • Method Details

    • setRepository

      @Autowired @Lazy public void setRepository(OfferCodeRepository<D> repository)
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • findAllByCodes

      public List<D> findAllByCodes(Set<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedOfferCodeRepository
      Specified by:
      findAllByCodes in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      codes - The set of codes to match
      context - Request context information around sandbox and multitenant state
      Returns:
      all OfferCodes by OfferCode.getCode().
    • findAllCodesForFullCache

      public List<String> findAllCodesForFullCache(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedOfferCodeRepository
      Retrieve all the codes in the system based on full cache configuration. See OfferCacheProperties.getFullCodeCacheType() for more information on how the configuration will influence the results of this method.
      Specified by:
      findAllCodesForFullCache in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      context - Request context information around sandbox and multitenant state
      Returns:
      All the codes in the system limited by the cache type configuration.
    • findAllByCodesIncludingInactive

      public Stream<D> findAllByCodesIncludingInactive(List<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Specified by:
      findAllByCodesIncludingInactive in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
    • findAllDuplicatesForCodesInCampaign

      public List<D> findAllDuplicatesForCodesInCampaign(@NonNull @NonNull String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedOfferCodeRepository
      Finds all duplicates OfferCodes by OfferCode.getId(). Typically, this will be used to check for duplicate offer codes of campaign.
      Specified by:
      findAllDuplicatesForCodesInCampaign in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      campaignId - the campaign id
      context - Request context information around sandbox and multitenant state
      Returns:
      all duplicates OfferCodes by OfferCode.getId()
    • findExistingByCodesIncludeExpiredForCampaignId

      public List<D> findExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedOfferCodeRepository
      Search all non-expired offer codes or expired but belonging to the specified campaignId. This is useful to validate that the offer codes can be added or updated. NOTE: This method is used during import of OfferCode and because different DBs has a different limitation on how many entries can be in "in" statement please make sure that the property "broadleaf.dataimport.processor.batch-size" not exited this limitation.
      Specified by:
      findExistingByCodesIncludeExpiredForCampaignId in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      codes - The set of codes to match
      campaignId - the campaign id
      context - Request context information around sandbox and multitenant state
      Returns:
      all OfferCodes by OfferCode.getCode() that are also active or belonging to the specified campaignId
      See Also:
      • com.broadleafcommerce.promotion.offer.dataimport.CampaignCodeImportBatchHandler
    • findExistingByCodesIncludeExpiredForOfferId

      public List<D> findExistingByCodesIncludeExpiredForOfferId(Set<String> codes, String offerId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Description copied from interface: CustomizedOfferCodeRepository
      Search all non-expired offer codes or expired but belonging to the specified offerId. This is useful to validate that the offer codes can be added or updated. NOTE: This method is used during import of OfferCode and because different DBs has a different limitation on how many entries can be in "in" statement please make sure that the property "broadleaf.dataimport.processor.batch-size" not exited this limitation.
      Specified by:
      findExistingByCodesIncludeExpiredForOfferId in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      codes - The set of codes to match
      offerId - the offer id
      context - Request context information around sandbox and multitenant state
      Returns:
      all OfferCodes by OfferCode.getCode() that are also active or belonging to the specified offerId
      See Also:
      • com.broadleafcommerce.promotion.offer.dataimport.CampaignCodeImportBatchHandler
    • readAllByCampaignId

      @Policy(operationTypes=READ) public Stream<D> readAllByCampaignId(String campaignId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedOfferCodeRepository
      Reads the offer codes for the specified campaign id matching the given filters.
      Specified by:
      readAllByCampaignId in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      campaignId - the campaign id
      filters - additional filters to apply in the query
      contextInfo - Request context information around sandbox and multitenant state
      Returns:
      the offer codes for the specified campaign id matching the given filters
    • readAllByCampaignId

      @Policy(operationTypes=READ) public Stream<D> readAllByCampaignId(String campaignId, int pageSize, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedOfferCodeRepository
      Reads the offer codes for the specified campaign id matching the given page size and filters.
      Specified by:
      readAllByCampaignId in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      campaignId - the campaign id
      pageSize - the page size to use when querying for records within the stream
      filters - additional filters to apply in the query
      Returns:
      the offer codes for the specified campaign id matching the given filters and page size
    • getFilterFunction

      @NotNull protected @NotNull BiFunction<String,Integer,List<D>> getFilterFunction(String campaignId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • readAllByOfferId

      @Policy(operationTypes=READ) public Stream<D> readAllByOfferId(String offerId, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedOfferCodeRepository
      Reads the offer codes for the specified offer id matching the given filters.
      Specified by:
      readAllByOfferId in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Parameters:
      offerId - the offer id
      filters - additional filters to apply in the query
      contextInfo - Request context information around sandbox and multitenant state
      Returns:
      the offer codes for the specified offer id matching the given filters
    • updateMaxUsageStatus

      public int updateMaxUsageStatus(String offerCodeId, String status, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: CustomizedOfferCodeRepository
      Update the status (see MaxUsageStatusType) for an offercode, and respond if the status was actually changed.
      Specified by:
      updateMaxUsageStatus in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      status - The status to set (see MaxUsageStatusType)
      contextInfo - Context containing tenant related information (specifically tenantId and applicationId) to use to further discriminate the change
      Returns:
      The number of records updated, if any. It is expected this method is called under load, so the response is a useful measure to detect when the value is actually updated. This is in contrast to other possible duplicate and ineffectual attempts.
    • findAllTenants

      public Set<String> findAllTenants()
      Description copied from interface: CustomizedOfferCodeRepository
      Read a list of distinct tenants for all offer codes
      Specified by:
      findAllTenants in interface CustomizedOfferCodeRepository<D extends JpaOfferCode>
      Returns:
      List of distinct tenants
    • getManagedType

      protected Class<D> getManagedType()
      Helper method to get the underlying Class<D extends JpaOfferCode> for the managed entity. The result is usually determined by RepositoryEntityTypeManager.getManagedType(Class, Class, EntityManager).
      Returns:
      the Class<D extends JpaOfferCode> for the managed entity.
    • getBehaviorUtil

      protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil getBehaviorUtil()
    • getRepositoryEntityTypeManager

      protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager getRepositoryEntityTypeManager()
    • getCriteriaBuilder

      protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder getCriteriaBuilder()
    • getNarrowingHelper

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

      protected jakarta.persistence.EntityManager getEntityManager()
    • getRepository

      protected OfferCodeRepository<D> getRepository()
    • getRsqlQueryTransformers

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

      protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor()
    • getCacheProperties

      @Nullable protected OfferCacheProperties getCacheProperties()
    • setCacheProperties

      @Autowired(required=false) public void setCacheProperties(OfferCacheProperties cacheProperties)
    • getJpaPromotionQueryHelper

      protected JpaPromotionQueryHelper getJpaPromotionQueryHelper()
    • setJpaPromotionQueryHelper

      @Autowired public void setJpaPromotionQueryHelper(JpaPromotionQueryHelper jpaPromotionQueryHelper)