Class JpaCustomizedOfferRepository<D extends JpaOffer>
- java.lang.Object
-
- com.broadleafcommerce.promotion.offer.provider.jpa.repository.JpaCustomizedOfferRepository<D>
-
- All Implemented Interfaces:
CustomizedOfferRepository<D>,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedOfferRepository<D extends JpaOffer> extends Object implements CustomizedOfferRepository<D>, org.springframework.beans.factory.InitializingBean
- Author:
- Chad Harchar (charchar)
-
-
Constructor Summary
Constructors Constructor Description JpaCustomizedOfferRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()protected javax.persistence.criteria.PredicatebuildAutomaticOrCodeOrCustomerOffersPredicate(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<JpaOffer> topRoot, Map<String,Object> params)protected javax.persistence.criteria.Subquery<String>buildSharedCodesSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder)protected javax.persistence.criteria.Subquery<String>buildTrackingSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder)protected javax.persistence.criteria.Subquery<String>buildUserTargetSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder, int userTargetsSize)Stream<D>findAllCustomerOffers(Iterable<? extends UserTarget> userTargets, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)Read all offers that have no user targets or contain the provided user targets.Stream<D>findAutomaticAndCodeAndCustomerOffers(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Read all offers whereOffer#getAutomaticallyConsideredis true,Offer.getCampaignTrackingIds()intersects with the provided tracking ids,Offer.getSharedCodes()intersects with the provided codes, or offers that contain the provided user targets.List<D>findBySharedCodesCodeIn(Iterable<String> codes, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Reads all offers whereOffer.sharedCodesintersects with the provided codes.Stream<D>findVoucherOffers(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)Read all voucher offers whereOffer#getAutomaticallyConsideredis true,Offer.getCampaignTrackingIds()intersects with the provided tracking ids,Offer.getSharedCodes()intersects with the provided codes, or offers that contain the provided user targets.
-
-
-
Method Detail
-
afterPropertiesSet
public void afterPropertiesSet()
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
findBySharedCodesCodeIn
public List<D> findBySharedCodesCodeIn(Iterable<String> codes, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedOfferRepositoryReads all offers whereOffer.sharedCodesintersects with the provided codes.- Specified by:
findBySharedCodesCodeInin interfaceCustomizedOfferRepository<D extends JpaOffer>- Parameters:
codes- codes the returnedOffer(s) are associated with.context- Context information around sandbox and multitenant state.- Returns:
- all
Offers associated to the provided codes.
-
findAutomaticAndCodeAndCustomerOffers
public Stream<D> findAutomaticAndCodeAndCustomerOffers(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedOfferRepositoryRead all offers whereOffer#getAutomaticallyConsideredis true,Offer.getCampaignTrackingIds()intersects with the provided tracking ids,Offer.getSharedCodes()intersects with the provided codes, or offers that contain the provided user targets. Intended to be used with the Campaign module andcom.broadleafcommerce.promotion.campaign.domain.Campaign#id.- Specified by:
findAutomaticAndCodeAndCustomerOffersin interfaceCustomizedOfferRepository<D extends JpaOffer>- Parameters:
userTargets- The targets to match offers againstcodes- codes the returnedOffer(s) are associated with.trackingIds- tracking ids the returnedOffer(s) are associated with.context- Context information around sandbox and multitenant state.- Returns:
- all offers where
Offer#getAutomaticallyConsideredis true, or the offer is associated with the provided codes, tracking ids, or user targets.
-
findVoucherOffers
public Stream<D> findVoucherOffers(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
Description copied from interface:CustomizedOfferRepositoryRead all voucher offers whereOffer#getAutomaticallyConsideredis true,Offer.getCampaignTrackingIds()intersects with the provided tracking ids,Offer.getSharedCodes()intersects with the provided codes, or offers that contain the provided user targets. Skips active date narrowing to fetch voucher offers for validation against submitted orders.- Specified by:
findVoucherOffersin interfaceCustomizedOfferRepository<D extends JpaOffer>- Parameters:
userTargets- The targets to match offers againstcodes- codes the returnedOffer(s) are associated with.trackingIds- tracking ids the returnedOffer(s) are associated with.context- Context information around sandbox and multitenant state.- Returns:
- all voucher offers where
Offer#getAutomaticallyConsideredis true, or the offer is associated with the provided codes, tracking ids, or user targets.
-
findAllCustomerOffers
public Stream<D> findAllCustomerOffers(Iterable<? extends UserTarget> userTargets, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Description copied from interface:CustomizedOfferRepositoryRead all offers that have no user targets or contain the provided user targets.- Specified by:
findAllCustomerOffersin interfaceCustomizedOfferRepository<D extends JpaOffer>- Parameters:
userTargets- The targets to match offers againstcontextInfo- Context information around sandbox and multitenant state.- Returns:
- all offers that have no user targets or contain the provided user targets.
-
buildUserTargetSubquery
protected javax.persistence.criteria.Subquery<String> buildUserTargetSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder, int userTargetsSize)
-
buildSharedCodesSubquery
protected javax.persistence.criteria.Subquery<String> buildSharedCodesSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder)
-
buildTrackingSubquery
protected javax.persistence.criteria.Subquery<String> buildTrackingSubquery(javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder)
-
buildAutomaticOrCodeOrCustomerOffersPredicate
protected javax.persistence.criteria.Predicate buildAutomaticOrCodeOrCustomerOffersPredicate(Iterable<? extends UserTarget> userTargets, Iterable<String> codes, Iterable<String> trackingIds, javax.persistence.criteria.CriteriaQuery<JpaOffer> criteria, javax.persistence.criteria.CriteriaBuilder builder, javax.persistence.criteria.Root<JpaOffer> topRoot, Map<String,Object> params)
-
-