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
ConstructorDescriptionJpaCustomizedOfferCodeRepository
(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 TypeMethodDescriptionvoid
findAllByCodes
(Set<String> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Finds allOfferCodes
byOfferCode.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 duplicatesOfferCodes
byOfferCode.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.TrackableBehaviorUtil
protected OfferCacheProperties
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder
protected jakarta.persistence.EntityManager
protected @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 JpaPromotionQueryHelper
Helper method to get the underlyingClass<D extends JpaOfferCode>
for the managed entity.protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelper
protected OfferCodeRepository<D>
protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager
protected List<com.broadleafcommerce.data.tracking.core.service.RsqlQueryTransformer>
protected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaCriteriaBuilderRsqlVisitor
readAllByCampaignId
(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.void
setCacheProperties
(OfferCacheProperties cacheProperties) void
setJpaPromotionQueryHelper
(JpaPromotionQueryHelper jpaPromotionQueryHelper) void
setRepository
(OfferCodeRepository<D> repository) int
updateMaxUsageStatus
(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, wait
Methods 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:
afterPropertiesSet
in 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:CustomizedOfferCodeRepository
Finds allOfferCodes
byOfferCode.getCode()
.- Specified by:
findAllByCodes
in interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>
- Parameters:
codes
- The set of codes to matchcontext
- Request context information around sandbox and multitenant state- Returns:
- all
OfferCodes
byOfferCode.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. SeeOfferCacheProperties.getFullCodeCacheType()
for more information on how the configuration will influence the results of this method.- Specified by:
findAllCodesForFullCache
in 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:
findAllByCodesIncludingInactive
in 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:CustomizedOfferCodeRepository
Finds all duplicatesOfferCodes
byOfferCode.getId()
. Typically, this will be used to check for duplicate offer codes of campaign.- Specified by:
findAllDuplicatesForCodesInCampaign
in interfaceCustomizedOfferCodeRepository<D extends JpaOfferCode>
- Parameters:
campaignId
- the campaign idcontext
- Request context information around sandbox and multitenant state- Returns:
- all duplicates
OfferCodes
byOfferCode.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 ofOfferCode
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 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
OfferCodes
byOfferCode.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 ofOfferCode
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 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
OfferCodes
byOfferCode.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 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:CustomizedOfferCodeRepository
Reads the offer codes for the specified campaign id matching the given page size and filters.- Specified by:
readAllByCampaignId
in 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:CustomizedOfferCodeRepository
Reads the offer codes for the specified offer id matching the given filters.- Specified by:
readAllByOfferId
in 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:CustomizedOfferCodeRepository
Update the status (seeMaxUsageStatusType
) for an offercode, and respond if the status was actually changed.- Specified by:
updateMaxUsageStatus
in 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:CustomizedOfferCodeRepository
Read a list of distinct tenants for all offer codes- Specified by:
findAllTenants
in 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
-