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 Summary
ConstructorsConstructorDescriptionJpaCustomizedOfferCodeRepository(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 Summary
Modifier and TypeMethodDescriptionvoidfindAllByCodes(Set<String> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds allOfferCodesbyOfferCode.getCode().findAllByCodesIncludingInactive(List<String> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) findAllCodesForFullCache(com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Retrieve all the codes in the system based on full cache configuration.findAllDuplicatesForCodesInCampaign(@NonNull String campaignId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds all duplicatesOfferCodesbyOfferCode.getId().Read a list of distinct tenants for all offer codesfindExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Search all non-expired offer codes or expired but belonging to the specified campaignId.findExistingByCodesIncludeExpiredForOfferId(Set<String> codes, String offerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Search all non-expired offer codes or expired but belonging to the specified offerId.protected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtilprotected OfferCachePropertiesprotected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilderprotected jakarta.persistence.EntityManagerprotected @NotNull BiFunction<String,Integer, List<D>> getFilterFunction(String campaignId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected JpaPromotionQueryHelperHelper method to get the underlyingClass<D extends JpaOfferCode>for the managed entity.protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelperprotected OfferCodeRepository<D>protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManagerprotected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitorreadAllByCampaignId(String campaignId, int pageSize, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the offer codes for the specified campaign id matching the given page size and filters.readAllByCampaignId(String campaignId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the offer codes for the specified campaign id matching the given filters.readAllByOfferId(String offerId, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads the offer codes for the specified offer id matching the given filters.voidsetCacheProperties(OfferCacheProperties cacheProperties) voidsetJpaPromotionQueryHelper(JpaPromotionQueryHelper jpaPromotionQueryHelper) voidsetRepository(OfferCodeRepository<D> repository) intupdateMaxUsageStatus(String offerCodeId, String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Update the status (seeMaxUsageStatusType) for an offercode, and respond if the status was actually changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.promotion.offer.repository.CustomizedOfferCodeRepository
findAllByCode
-
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
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.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:CustomizedOfferCodeRepositoryFinds allOfferCodesbyOfferCode.getCode().- Specified by:
findAllByCodesin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
codes- The set of codes to matchcontext- Request context information around sandbox and multitenant state- Returns:
- all
OfferCodesbyOfferCode.getCode().
-
findAllCodesForFullCache
public List<String> findAllCodesForFullCache(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedOfferCodeRepositoryRetrieve all the codes in the system based on full cache configuration. SeeOfferCacheProperties.getFullCodeCacheType()for more information on how the configuration will influence the results of this method.- Specified by:
findAllCodesForFullCachein interfaceCustomizedOfferCodeRepository<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:
findAllByCodesIncludingInactivein interfaceCustomizedOfferCodeRepository<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:CustomizedOfferCodeRepositoryFinds all duplicatesOfferCodesbyOfferCode.getId(). Typically, this will be used to check for duplicate offer codes of campaign.- Specified by:
findAllDuplicatesForCodesInCampaignin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
campaignId- the campaign idcontext- Request context information around sandbox and multitenant state- Returns:
- all duplicates
OfferCodesbyOfferCode.getId()
-
findExistingByCodesIncludeExpiredForCampaignId
public List<D> findExistingByCodesIncludeExpiredForCampaignId(Set<String> codes, String campaignId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:CustomizedOfferCodeRepositorySearch 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 ofOfferCodeand 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:
findExistingByCodesIncludeExpiredForCampaignIdin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
codes- The set of codes to matchcampaignId- the campaign idcontext- Request context information around sandbox and multitenant state- Returns:
- all
OfferCodesbyOfferCode.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:CustomizedOfferCodeRepositorySearch 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 ofOfferCodeand 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:
findExistingByCodesIncludeExpiredForOfferIdin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
codes- The set of codes to matchofferId- the offer idcontext- Request context information around sandbox and multitenant state- Returns:
- all
OfferCodesbyOfferCode.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:CustomizedOfferCodeRepositoryReads the offer codes for the specified campaign id matching the given filters.- Specified by:
readAllByCampaignIdin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
campaignId- the campaign idfilters- additional filters to apply in the querycontextInfo- 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:CustomizedOfferCodeRepositoryReads the offer codes for the specified campaign id matching the given page size and filters.- Specified by:
readAllByCampaignIdin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
campaignId- the campaign idpageSize- the page size to use when querying for records within the streamfilters- additional filters to apply in the query- Returns:
- the offer codes for the specified campaign id matching the given filters and page size
-
getFilterFunction
-
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:CustomizedOfferCodeRepositoryReads the offer codes for the specified offer id matching the given filters.- Specified by:
readAllByOfferIdin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Parameters:
offerId- the offer idfilters- additional filters to apply in the querycontextInfo- 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:CustomizedOfferCodeRepositoryUpdate the status (seeMaxUsageStatusType) for an offercode, and respond if the status was actually changed.- Specified by:
updateMaxUsageStatusin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>status- The status to set (seeMaxUsageStatusType)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
Description copied from interface:CustomizedOfferCodeRepositoryRead a list of distinct tenants for all offer codes- Specified by:
findAllTenantsin interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>- Returns:
- List of distinct tenants
-
getManagedType
Helper method to get the underlyingClass<D extends JpaOfferCode>for the managed entity. The result is usually determined byRepositoryEntityTypeManager.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
-
getRsqlQueryTransformers
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer> getRsqlQueryTransformers() -
getRsqlVisitor
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor getRsqlVisitor() -
getCacheProperties
-
setCacheProperties
-
getJpaPromotionQueryHelper
-
setJpaPromotionQueryHelper
-