Class JpaCustomizedSubscriptionRepository<D extends JpaSubscription>
java.lang.Object
com.broadleafcommerce.subscription.provider.jpa.repository.JpaCustomizedSubscriptionRepository<D>
- All Implemented Interfaces:
CustomizedSubscriptionRepository<D>,org.springframework.beans.factory.InitializingBean
public class JpaCustomizedSubscriptionRepository<D extends JpaSubscription>
extends Object
implements CustomizedSubscriptionRepository<D>, org.springframework.beans.factory.InitializingBean
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
ConstructorsConstructorDescriptionJpaCustomizedSubscriptionRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddPredicatesForSubscriptionStatusAndNexBillDateBeforeNow(List<jakarta.persistence.criteria.Predicate> predicates, Map<String, Object> params, jakarta.persistence.criteria.Root<D> subscription, jakarta.persistence.criteria.CriteriaBuilder builder, String subscriptionStatus) voidcountAllBySubscriptionStatus(String subscriptionStatus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Countsubscriptionsmatching the subscriptionStatus.protected <D extends JpaSubscription>
voidexplicitSimpleNarrowing(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> subscription, Map<String, Object> params) filterSubscriptionsByItemRefs(List<D> unfiltered, Collection<String> itemRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.data.domain.Page<D>findAllByPriceData(String priceDataId, Set<String> statuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby priceDataId.org.springframework.data.domain.Page<D>findAllBySubscriptionStatusInAndNextBillDateBeforeOrNextStatusChangeDateBeforeOrEndOfTermDateBefore(List<String> subscriptionStatuses, Date dateToFilter, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find subscriptions within the following criteria: subscriptionStatus in the given list billing frequency isDefaultSubscriptionBillingFrequencyEnum.NON_RENEWINGOR theSubscription.getNextBillDate()is before or equal the given date OR theSubscription.getNextStatusChangeDate()is before or equal the given date OR theSubscription.getEndOfTermDate()is before or equal the given date lastBillingOperationStatus is null OR is eitherPaymentStatusEnum.SUCCESSorPaymentStatusEnum.ABORTEDNote that the last condition prevents subscriptions that are being processed by another subscription job to be picked up again.org.springframework.data.domain.Page<D>findAllBySubscriptionStatusInAndNextBillDateBeforeOrNullAndNextStatusChangeDateBefore(List<String> subscriptionStatuses, Date dateToFilter, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find subscriptions within the following criteria: subscriptionStatus in the given list billing frequency isDefaultSubscriptionBillingFrequencyEnum.NON_RENEWINGOR the nextBillDate before or equal the given date OR nextBillDate is null and the nextStatusChangeDate is before or equal the given date lastBillingOperationStatus is null OR is eitherPaymentStatusEnum.SUCCESSorPaymentStatusEnum.ABORTEDNote that the last condition prevents subscriptions that are being processed by another subscription job to be picked up again.findAllByUserRefTypeAndUserRefAndActive(String userRefType, String userRef, boolean includeInactive, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userId.findAllByUserRefTypeAndUserRefAndSubscriptionItemsItemRefIn(String userRefType, String userRef, Collection<String> itemRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findByMatchingSubscriptionSource(@NonNull Subscription subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find aSubscriptionwith the source matching theSubscriptiongiven.org.springframework.data.domain.Page<String>findContextIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieve contextIds ofsubscriptionsmatching the subscriptionStatusprotected com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtilprotected com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilderprotected jakarta.persistence.EntityManagerprotected SubscriptionItemRepository<JpaSubscriptionItem>protected <T extends JpaSubscriptionItem>
Class<T>Helper method to get the underlyingClass<D extends JpaSubscription>for the managed entity.protected com.broadleafcommerce.data.tracking.jpa.filtering.narrow.JpaNarrowingHelperprotected SubscriptionRepository<D>protected com.broadleafcommerce.common.jpa.RepositoryEntityTypeManagergetSubscriptionsByUserRefTypeAndUserRef(String userRefType, String userRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetItemRepository(SubscriptionItemRepository<JpaSubscriptionItem> itemRepository) voidsetRepository(SubscriptionRepository<D> repository) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.subscription.repository.CustomizedSubscriptionRepository
countAllBySubscriptionStatus, findAllBySubscriptionStatus, findAllBySubscriptionStatusAndBillingOperationStatus, findAllByUserRefAndSubscriptionItemsItemRefIn, listSubscriptions
-
Field Details
-
SUBSCRIPTION_STATUS
- See Also:
-
NEXT_BILL_DATE
- See Also:
-
NEXT_STATUS_CHANGE_DATE
- See Also:
-
END_OF_TERM_DATE
- See Also:
-
LAST_BILLING_OPERATION_STATUS
- See Also:
-
BILLING_FREQUENCY
- See Also:
-
SUBSCRIPTION_SOURCE
- See Also:
-
SUBSCRIPTION_SOURCE_REF
- See Also:
-
SECONDARY_SOURCE_TYPE
- See Also:
-
SECONDARY_SOURCE_REF
- See Also:
-
PRICE_DATA_ID
- See Also:
-
-
Constructor Details
-
JpaCustomizedSubscriptionRepository
public JpaCustomizedSubscriptionRepository(com.broadleafcommerce.data.tracking.core.TrackableBehaviorUtil behaviorUtil, com.broadleafcommerce.common.jpa.RepositoryEntityTypeManager repositoryEntityTypeManager, com.broadleafcommerce.data.tracking.jpa.filtering.fetch.rsql.JpaFiltersCriteriaBuilder criteriaBuilder)
-
-
Method Details
-
setRepository
-
setItemRepository
@Autowired @Lazy public void setItemRepository(SubscriptionItemRepository<JpaSubscriptionItem> itemRepository) -
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean
-
findAllByUserRefTypeAndUserRefAndActive
public List<D> findAllByUserRefTypeAndUserRefAndActive(String userRefType, String userRef, boolean includeInactive, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryFind allsubscriptionsby userId. Optionally include inactive subscriptions.- Specified by:
findAllByUserRefTypeAndUserRefAndActivein interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
findContextIdsBySubscriptionStatus
public org.springframework.data.domain.Page<String> findContextIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryRetrieve contextIds ofsubscriptionsmatching the subscriptionStatus- Specified by:
findContextIdsBySubscriptionStatusin interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
findAllByPriceData
public org.springframework.data.domain.Page<D> findAllByPriceData(String priceDataId, Set<String> statuses, org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryFind allsubscriptionsby priceDataId.- Specified by:
findAllByPriceDatain interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>- Parameters:
priceDataId- The id of the priceData belonging to one or more of the containedSubscriptionIteminstances.statuses- Set of statuses to filter by.page- The page informationcontextInfo- Additional sandbox and multitenant info
-
findAllByUserRefTypeAndUserRefAndSubscriptionItemsItemRefIn
public List<D> findAllByUserRefTypeAndUserRefAndSubscriptionItemsItemRefIn(String userRefType, String userRef, Collection<String> itemRefs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
findAllByUserRefTypeAndUserRefAndSubscriptionItemsItemRefInin interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
countAllBySubscriptionStatus
public Long countAllBySubscriptionStatus(String subscriptionStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryCountsubscriptionsmatching the subscriptionStatus.- Specified by:
countAllBySubscriptionStatusin interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
findAllBySubscriptionStatusInAndNextBillDateBeforeOrNullAndNextStatusChangeDateBefore
@Transactional public org.springframework.data.domain.Page<D> findAllBySubscriptionStatusInAndNextBillDateBeforeOrNullAndNextStatusChangeDateBefore(List<String> subscriptionStatuses, Date dateToFilter, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryFind subscriptions within the following criteria:- subscriptionStatus in the given list
- billing frequency is
DefaultSubscriptionBillingFrequencyEnum.NON_RENEWINGOR the nextBillDate before or equal the given date OR nextBillDate is null and the nextStatusChangeDate is before or equal the given date - lastBillingOperationStatus is null OR is either
PaymentStatusEnum.SUCCESSorPaymentStatusEnum.ABORTEDNote that the last condition prevents subscriptions that are being processed by another subscription job to be picked up again.
- Specified by:
findAllBySubscriptionStatusInAndNextBillDateBeforeOrNullAndNextStatusChangeDateBeforein interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
findAllBySubscriptionStatusInAndNextBillDateBeforeOrNextStatusChangeDateBeforeOrEndOfTermDateBefore
@Transactional public org.springframework.data.domain.Page<D> findAllBySubscriptionStatusInAndNextBillDateBeforeOrNextStatusChangeDateBeforeOrEndOfTermDateBefore(List<String> subscriptionStatuses, Date dateToFilter, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryFind subscriptions within the following criteria:- subscriptionStatus in the given list
- billing frequency is
DefaultSubscriptionBillingFrequencyEnum.NON_RENEWINGOR theSubscription.getNextBillDate()is before or equal the given date OR theSubscription.getNextStatusChangeDate()is before or equal the given date OR theSubscription.getEndOfTermDate()is before or equal the given date - lastBillingOperationStatus is null OR is either
PaymentStatusEnum.SUCCESSorPaymentStatusEnum.ABORTEDNote that the last condition prevents subscriptions that are being processed by another subscription job to be picked up again.
- Specified by:
findAllBySubscriptionStatusInAndNextBillDateBeforeOrNextStatusChangeDateBeforeOrEndOfTermDateBeforein interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>
-
findByMatchingSubscriptionSource
public Optional<D> findByMatchingSubscriptionSource(@NonNull @NonNull Subscription subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CustomizedSubscriptionRepositoryFind aSubscriptionwith the source matching theSubscriptiongiven. By default, this is based onSubscription.getSubscriptionSource(),Subscription.getSubscriptionSourceRef(),Subscription.getSecondarySourceType(), andSubscription.getSecondarySourceRef().- Specified by:
findByMatchingSubscriptionSourcein interfaceCustomizedSubscriptionRepository<D extends JpaSubscription>- Parameters:
subscription- ASubscriptionfor which to find a matching source.
-
addPredicatesForSubscriptionStatusAndNexBillDateBeforeNow
-
getManagedType
Helper method to get the underlyingClass<D extends JpaSubscription>for the managed entity. The result is usually determined byRepositoryEntityTypeManager.getManagedType(Class, Class, EntityManager).- Returns:
- the
Class<D extends JpaSubscription>for the managed entity.
-
getManagedItemType
-
explicitSimpleNarrowing
protected <D extends JpaSubscription> void explicitSimpleNarrowing(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, List<jakarta.persistence.criteria.Predicate> predicates, jakarta.persistence.criteria.CriteriaBuilder builder, jakarta.persistence.criteria.Root<D> subscription, Map<String, Object> params) -
getSubscriptionsByUserRefTypeAndUserRef
-
filterSubscriptionsByItemRefs
-
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
-
getItemRepository
-