Class DefaultSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<S>
com.broadleafcommerce.subscription.service.impl.DefaultSubscriptionService<S,SWI>
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<S>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<S>,SubscriptionService<S,SWI>
public class DefaultSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<S>
implements SubscriptionService<S,SWI>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected BillingEventPaymentService<BillingEventPayment,BillingEventPaymentWithEvent, BillingEventDTO, BillingEventPaymentWithTransaction> static final intprotected EntitlementProvider<Entitlement>static final Stringprotected SubscriptionNextBillDateServiceprotected final SubscriptionRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected SubscriptionConfigurationPropertiesprotected SubscriptionItemService<SubscriptionItem>protected com.broadleafcommerce.data.tracking.core.messaging.TransitionListenerprotected com.broadleafcommerce.common.extension.TypeFactory -
Constructor Summary
ConstructorsConstructorDescriptionDefaultSubscriptionService(SubscriptionRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionaddPriceDataChange(Set<String> subscriptionIds, PriceDataChange change, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds aPriceDataChangeto the subscription.protected voidaddPriceDataChange(S subscription, PriceDataChange change, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds aPriceDataChangeto theSubscriptionand updates the subscription.protected Map<String,Set<SubscriptionItem>> buildSubscriptionItemsBySubscriptionIdMap(@NonNull List<S> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a map ofSubscriptionItemsbySubscriptionbuildSubscriptionsWithItems(List<S> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor each of the providedSubscriptions.protected SWIbuildSubscriptionWithItems(Subscription subscription, List<SubscriptionItem> subscriptionItems) protected SWIbuildSubscriptionWithItems(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor the providedSubscription.voidcancelActiveSubscription(String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidcancelAllPriorSubscriptions(List<String> subscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels all prior subscriptions bySubscription.getNextSubscription()in the given subscriptionIds listprotected voidcancelNextSubscription(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) cancelSubscription(String subscriptionId, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscriptionwith the provided subscriptionIdcancelSubscription(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscriptioncancelSubscriptionForFailureBilling(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Set the subscriptionStatus toSubscriptionStatusEnum.CANCELLEDand create a respectiveSubscriptionStatusAuditcancelSubscriptionImmediately(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels theSubscriptionimmediately instead of factoring in the grace period logicvoidcancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcancelSubscriptionRelations(S subscription, String reason, Date cancelDate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidApply any uncommitted changes to the subscription to the production state.countAllBySubscriptionStatus(String subscriptionStatus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Count all subscription entities given the subscription statuscreate(S subscriptionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) createAll(List<S> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SubscriptionPeriodcreatePrepaidDueNowPeriod(S subscriptionRequest) protected voidcreateSubscriptionBillingAudit(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcreateSubscriptionCancelStatusAudit(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidcreateSubscriptionStatusAudit(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) createSubscriptionWithItems(SWI subscriptionRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findAllByUserRefTypeAndUserRef(String userRefType, String userRef, boolean includeInactive, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef.org.springframework.data.domain.Page<SWI>findAllByUserRefTypeAndUserRef(String userRefType, String userRef, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef.findAllByUserRefTypeAndUserRefAndItemRefs(String userRefType, String userRef, Collection<String> itemRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.data.domain.Page<SubscriptionOwnerInfo>findAllSubscriptionOwnerInfosByPriceData(String priceDataId, Set<String> statuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscription infosrelated to subscriptions by priceDataId.findAllWithItemsById(List<String> subscriptionsIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findAllWithItemsByUserRefTypeAndUserRefAndStatuses(String userRefType, String userRef, List<String> statuses, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef and statuses.protected SfindByContextId(String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findByMatchingSource(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find aSubscriptionwith the source matching theSubscriptiongiven.findBySubscriptionSourceRef(String subscriptionSourceRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find theSubscriptionby subscriptionSourceReforg.springframework.data.domain.Page<String>findIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findWithItemsById(String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected DategetCancelDate(S subscription) Get the date on which theSubscriptionstatus should be changed toSubscriptionStatusEnum.CANCELLED.protected intReturns the default page sizeprotected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>protected DategetPriorBillDate(S subscriptionRequest) Gets the prior bill date for the givenSubscriptionin its creation.protected StringhandleSubscriptionCancelGracePeriod(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanhasValidRemainingTryCount(int remainingTryCount) protected <T extends SubscriptionItem>
voidhydrateItemAdjustments(Collection<T> items, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates the given subscription itemsadjustments.protected voidhydrateSubscriptionAdjustments(Collection<S> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates the given subscriptionsadjustments.protected booleanisOptimisticLockException(Exception exception) protected BooleanisSubscriptionCancelled(S subscription) protected BooleanisSubscriptionToBeCancelled(S subscription, Date cancelDate) org.springframework.data.domain.Page<S>readAllByName(String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Reads a paginated result set of allSubscriptions, applying the provided name, filters, page request, and context info against the results.readByContextIdAndUserRefTypeAndUserRef(@NonNull String subscriptionId, @NonNull String userRefType, @NonNull String userRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a user-owned subscription with items for a given idprotected voidrefundSubscriptionInGracePeriod(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) replaceSubscription(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces aSubscription.protected List<SubscriptionAdjustment>replaceSubscriptionAdjustments(S existing, S changed, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscription.getSubscriptionAdjustments()using thechangedSubscription.protected List<SubscriptionItemAdjustment>replaceSubscriptionItemAdjustments(SWI existing, SWI changed, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscriptionItem.getSubscriptionItemAdjustments()using thechangedSubscriptionItem.protected List<SubscriptionItem>replaceSubscriptionItems(SWI existing, SWI changed, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscriptionWithItems.getSubscriptionItems()using thechangedSubscriptionWithItems.replaceSubscriptionWithItems(SWI subscriptionWithItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected org.springframework.data.domain.Page<SWI>retrievePageWithItems(org.springframework.data.domain.Page<S> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor each of the providedSubscriptions.voidRevert any uncommitted changes to the subscription.protected List<SubscriptionAdjustment>saveAdjustments(@NonNull List<SubscriptionAdjustment> adjustments, S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetBillingEventPaymentService(BillingEventPaymentService<BillingEventPayment, BillingEventPaymentWithEvent, BillingEventDTO, BillingEventPaymentWithTransaction> billingEventPaymentService) voidsetEntitlementProvider(EntitlementProvider<Entitlement> entitlementProvider) voidsetNextBillDateService(SubscriptionNextBillDateService nextBillDateService) voidsetParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser) voidsetSubscriptionAdjustmentService(SubscriptionAdjustmentService<SubscriptionAdjustment> subscriptionAdjustmentService) voidsetSubscriptionBillingAuditService(SubscriptionBillingAuditService<SubscriptionBillingAudit> subscriptionBillingAuditService) voidsetSubscriptionConfigurationProperties(SubscriptionConfigurationProperties subscriptionConfigurationProperties) voidsetSubscriptionItemAdjustmentService(SubscriptionItemAdjustmentService<SubscriptionItemAdjustment> subscriptionItemAdjustmentService) voidsetSubscriptionItemService(SubscriptionItemService<SubscriptionItem> subscriptionItemService) voidsetSubscriptionStatusAuditService(SubscriptionStatusAuditService<SubscriptionStatusAudit> subscriptionStatusAuditService) voidsetTransitionListener(com.broadleafcommerce.data.tracking.core.messaging.TransitionListener transitionListener) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected voidupdatePriorSubscriptionsWithNextSubscriptionIdAndCancel(String subscriptionId, List<String> priorSubscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SupdateSubscriptionForFutureCancel(S subscription, String reason, Date cancelDate, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SupdateSubscriptionForImmediateCancel(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) updateSubscriptionFromJob(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the subscription.upgradeSubscription(S subscription, List<String> priorSubscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create the upgradedSubscriptionand cancel prior subscriptions in its favorupgradeSubscriptionByItemRefs(SWI subscriptionWithItems, Set<String> upgradableItemRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Upgrade subscriptions matching the subscription's userRef and given subscriptionItem referencesupgradeSubscriptionWithItems(SWI subscription, List<String> priorSubscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidvalidateNotCancelled(S subscription, Date cancelDate) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAllMethods inherited from interface com.broadleafcommerce.subscription.service.SubscriptionService
callToCancelSubscription, cancelAllPriorSubscriptions, cancelSubscription, cancelSubscription, cancelSubscriptionForFailureBilling, cancelSubscriptionImmediately, cancelSubscriptionImmediatelyWithRetries, countAllBySubscriptionStatus, createSubscription, createSubscriptionWithItems, findAllByIds, findAllByUserRefAndItemRefs, findAllSubscriptionsByUserRef, findAllSubscriptionsByUserRefAndStatuses, findAllSubscriptionWithItemsById, findById, findBySubscriptionSourceRef, findIdsBySubscriptionStatus, findWithItemsById, updateNextSubscriptionForActiveStatus, updateSubscription, updateSubscriptionFromJob, upgradeSubscription, upgradeSubscriptionByItemRefs
-
Field Details
-
IN_GRACE_PERIOD_REASON_SUFFIX
- See Also:
-
BILLING_FAILED
- See Also:
-
DEFAULT_PAGE_SIZE
public static final int DEFAULT_PAGE_SIZE- See Also:
-
repo
-
subscriptionBillingAuditService
-
subscriptionStatusAuditService
-
billingEventPaymentService
protected BillingEventPaymentService<BillingEventPayment,BillingEventPaymentWithEvent, billingEventPaymentServiceBillingEventDTO, BillingEventPaymentWithTransaction> -
entitlementProvider
-
subscriptionItemService
-
subscriptionAdjustmentService
-
subscriptionItemAdjustmentService
protected SubscriptionItemAdjustmentService<SubscriptionItemAdjustment> subscriptionItemAdjustmentService -
nextBillDateService
-
subscriptionConfigurationProperties
-
typeFactory
protected com.broadleafcommerce.common.extension.TypeFactory typeFactory -
transitionListener
protected com.broadleafcommerce.data.tracking.core.messaging.TransitionListener transitionListener
-
-
Constructor Details
-
DefaultSubscriptionService
public DefaultSubscriptionService(SubscriptionRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
-
Method Details
-
findWithItemsById
public SWI findWithItemsById(String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
findWithItemsByIdin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
findAllByUserRefTypeAndUserRef
public List<SWI> findAllByUserRefTypeAndUserRef(String userRefType, String userRef, boolean includeInactive, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind allsubscriptionsby userRef. Optionally include inactive records.- Specified by:
findAllByUserRefTypeAndUserRefin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
findAllByUserRefTypeAndUserRef
public org.springframework.data.domain.Page<SWI> findAllByUserRefTypeAndUserRef(String userRefType, String userRef, @Nullable org.springframework.data.domain.Pageable page, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind allsubscriptionsby userRef. Optionally include inactive records.- Specified by:
findAllByUserRefTypeAndUserRefin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
findAllSubscriptionOwnerInfosByPriceData
public org.springframework.data.domain.Page<SubscriptionOwnerInfo> findAllSubscriptionOwnerInfosByPriceData(String priceDataId, Set<String> statuses, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind allsubscription infosrelated to subscriptions by priceDataId.- Specified by:
findAllSubscriptionOwnerInfosByPriceDatain interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
priceDataId- The id of the priceData belonging to one or more of the containedSubscriptionIteminstances in associatedSubscriptioninstances.statuses- Set of statuses to filter by.page- The page informationcontextInfo- Additional sandbox and multitenant info
-
readByContextIdAndUserRefTypeAndUserRef
public SWI readByContextIdAndUserRefTypeAndUserRef(@NonNull @NonNull String subscriptionId, @NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceRetrieves a user-owned subscription with items for a given id- Specified by:
readByContextIdAndUserRefTypeAndUserRefin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionId- The id of the subscriptionuserRefType- type of the owning useruserRef- id of the owning usercontextInfo- context information around multi-tenant state- Returns:
- a user-owned subscription with items for a given id
-
findAllWithItemsByUserRefTypeAndUserRefAndStatuses
public List<SWI> findAllWithItemsByUserRefTypeAndUserRefAndStatuses(String userRefType, String userRef, List<String> statuses, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind allsubscriptionsby userRef and statuses.- Specified by:
findAllWithItemsByUserRefTypeAndUserRefAndStatusesin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
findAllByUserRefTypeAndUserRefAndItemRefs
public List<S> findAllByUserRefTypeAndUserRefAndItemRefs(String userRefType, String userRef, Collection<String> itemRefs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
findAllByUserRefTypeAndUserRefAndItemRefsin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
findByMatchingSource
public Optional<S> findByMatchingSource(@NonNull S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind aSubscriptionwith the source matching theSubscriptiongiven. By default, this is based onSubscription.getSubscriptionSource(),Subscription.getSubscriptionSourceRef(),Subscription.getSecondarySourceType(), andSubscription.getSecondarySourceRef().- Specified by:
findByMatchingSourcein interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- ASubscriptionfor which to find a matching source.
-
create
@Transactional public S create(S subscriptionRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
createin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<S extends Subscription>- Overrides:
createin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<S extends Subscription>
-
createPrepaidDueNowPeriod
-
createAll
@Transactional public List<S> createAll(List<S> subscriptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
createAllin interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<S extends Subscription>- Overrides:
createAllin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<S extends Subscription>
-
saveAdjustments
protected List<SubscriptionAdjustment> saveAdjustments(@NonNull @NonNull List<SubscriptionAdjustment> adjustments, S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createSubscriptionWithItems
@Transactional public SWI createSubscriptionWithItems(@NonNull SWI subscriptionRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionService- Specified by:
createSubscriptionWithItemsin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionRequest- Request containing theSubscriptionto make.contextInfo- Additional sandbox and multitenant info- Returns:
- The created
Subscriptionand related entities.
-
replaceSubscriptionWithItems
@Transactional public SWI replaceSubscriptionWithItems(@NonNull SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionService- Specified by:
replaceSubscriptionWithItemsin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionWithItems- Request containing updates to make.contextInfo- Additional sandbox and multitenant info- Returns:
- The updated
Subscriptionand related entities.
-
getPriorBillDate
Gets the prior bill date for the givenSubscriptionin its creation. For prepaid, there was a DueNow checkout transaction, so the prior bill date is the created date. But if the subscription is postpaid or is in a free trial, the prior bill date is null since there was not a DueNow checkout transaction. -
createSubscriptionStatusAudit
protected void createSubscriptionStatusAudit(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createSubscriptionBillingAudit
protected void createSubscriptionBillingAudit(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
findBySubscriptionSourceRef
public Optional<S> findBySubscriptionSourceRef(String subscriptionSourceRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceFind theSubscriptionby subscriptionSourceRef- Specified by:
findBySubscriptionSourceRefin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
cancelSubscription
@Transactional public S cancelSubscription(String subscriptionId, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCancel aSubscriptionwith the provided subscriptionId- Specified by:
cancelSubscriptionin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionId- id for the subscription to be cancelledreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
cancelSubscription
@Transactional public S cancelSubscription(S subscription, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCancel aSubscription- Specified by:
cancelSubscriptionin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- the subscription to be cancelledreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
replaceSubscription
@Transactional public S replaceSubscription(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceReplaces aSubscription.- Specified by:
replaceSubscriptionin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- the subscription to replacecontextInfo- context information around multi-tenant state- Returns:
- the updated subscription
-
validateNotCancelled
-
isSubscriptionCancelled
-
isSubscriptionToBeCancelled
-
updateSubscriptionForFutureCancel
-
getCancelDate
Get the date on which theSubscriptionstatus should be changed toSubscriptionStatusEnum.CANCELLED. By default, this is the next bill date, but left open for extension. -
cancelSubscriptionRelations
-
cancelNextSubscription
-
cancelSubscriptionImmediately
@Transactional public S cancelSubscriptionImmediately(S subscription, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCancels theSubscriptionimmediately instead of factoring in the grace period logic- Specified by:
cancelSubscriptionImmediatelyin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- the subscription to be cancelled immediatelyreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
updateSubscriptionForImmediateCancel
-
createSubscriptionCancelStatusAudit
-
upgradeSubscription
@Transactional public S upgradeSubscription(@NonNull S subscription, List<String> priorSubscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCreate the upgradedSubscriptionand cancel prior subscriptions in its favor- Specified by:
upgradeSubscriptionin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- upgraded subscription to createpriorSubscriptionIds- prior subscription ids to be cancelledcontextInfo- context information around multi-tenant state- Returns:
- the upgraded subscription
-
updatePriorSubscriptionsWithNextSubscriptionIdAndCancel
-
upgradeSubscriptionWithItems
-
upgradeSubscriptionByItemRefs
@Transactional public SWI upgradeSubscriptionByItemRefs(@NonNull SWI subscriptionWithItems, Set<String> upgradableItemRefs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceUpgrade subscriptions matching the subscription's userRef and given subscriptionItem references- Specified by:
upgradeSubscriptionByItemRefsin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionWithItems- the upgraded subscriptionupgradableItemRefs- the items refs for prior subscriptions to be upgradecontextInfo- context information around multi-tenant state- Returns:
- the upgraded subscription
-
handleSubscriptionCancelGracePeriod
-
refundSubscriptionInGracePeriod
-
findAllWithItemsById
public List<SWI> findAllWithItemsById(List<String> subscriptionsIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
findAllWithItemsByIdin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
cancelActiveSubscription
public void cancelActiveSubscription(String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
cancelActiveSubscriptionin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
cancelAllPriorSubscriptions
@Transactional public void cancelAllPriorSubscriptions(List<String> subscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCancels all prior subscriptions bySubscription.getNextSubscription()in the given subscriptionIds list- Specified by:
cancelAllPriorSubscriptionsin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionIds- ids of nextSubscriptions for which to cancel prior subscriptionscontextInfo- context information around multi-tenant state
-
findIdsBySubscriptionStatus
@Transactional public org.springframework.data.domain.Page<String> findIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
findIdsBySubscriptionStatusin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
countAllBySubscriptionStatus
@Transactional public Long countAllBySubscriptionStatus(String subscriptionStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCount all subscription entities given the subscription status- Specified by:
countAllBySubscriptionStatusin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
updateSubscriptionFromJob
@Transactional public S updateSubscriptionFromJob(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceUpdates the subscription. Ensures the given subscription has an updatedSubscription.getVersion()value before proceeding- Specified by:
updateSubscriptionFromJobin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- subscription to be updatedcontextInfo- context information around multi-tenant state- Returns:
- updated subscription
-
cancelSubscriptionForFailureBilling
public S cancelSubscriptionForFailureBilling(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceSet the subscriptionStatus toSubscriptionStatusEnum.CANCELLEDand create a respectiveSubscriptionStatusAudit- Specified by:
cancelSubscriptionForFailureBillingin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscription- subscription to cancelcontextInfo- context information around multi-tenant state- Returns:
- cancelled subscription
-
cancelSubscriptionImmediatelyWithRetries
@Transactional public void cancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceCallsSubscriptionService.cancelSubscriptionImmediately(Subscription, String, ContextInfo). Retries the operation in case of concurrency problems- Specified by:
cancelSubscriptionImmediatelyWithRetriesin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
-
commit
public void commit(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceApply any uncommitted changes to the subscription to the production state. Subscriptions are not only locked during a modification flow, but changes are also stored in a temporary modification state. When the modification flow is complete, this method is called to finalize the changes.Special note, during the modification flow, any retrieval of the subscription will return the modified state. However, the billing view of the subscription will continue to see the unmodified state until this method is called and the changes are finalized.
- Specified by:
commitin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> contextInfo- context information around multi-tenant state- See Also:
-
#revert(String, ContextInfo)
-
revert
public void revert(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceRevert any uncommitted changes to the subscription. This will remove any changes that have been made to the subscription during the modification flow and leave the production state untouched.- Specified by:
revertin interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> contextInfo- context information around multi-tenant state- See Also:
-
#commit(String, ContextInfo)
-
readAllByName
public org.springframework.data.domain.Page<S> readAllByName(@Nullable String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) Description copied from interface:SubscriptionServiceReads a paginated result set of allSubscriptions, applying the provided name, filters, page request, and context info against the results.- Specified by:
readAllByNamein interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
name- A full or partial name to filter the results byfilters- Additional RSQL filters to applypage- The page informationcontext- Additional sandbox and multitenant info- Returns:
- A paginated result set of all
Subscriptions.
-
addPriceDataChange
public List<String> addPriceDataChange(Set<String> subscriptionIds, PriceDataChange change, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionServiceAdds aPriceDataChangeto the subscription. This will be used to set upBillingEvents appropriately for timely charging of the subscription.- Specified by:
addPriceDataChangein interfaceSubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems> - Parameters:
subscriptionIds- The id list of the subscriptions to add the change tochange- The pricing change informationcontextInfo- Additional sandbox and multitenant info- Returns:
- The list of ids for updated subscriptions
-
addPriceDataChange
protected void addPriceDataChange(S subscription, PriceDataChange change, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds aPriceDataChangeto theSubscriptionand updates the subscription.- Parameters:
subscription- TheSubscriptionto add thePriceDataChangechange- ThePriceDataChangeto addcontextInfo- Additional sandbox and multitenant info
-
replaceSubscriptionItems
protected List<SubscriptionItem> replaceSubscriptionItems(@NonNull SWI existing, @NonNull SWI changed, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscriptionWithItems.getSubscriptionItems()using thechangedSubscriptionWithItems. Any items with matching ids will be replaced, any inexistingnot inchangedwill be removed, and any inchangednot inexistingwill be created.- Parameters:
existing- The existing, unchangedSubscriptionchanged- TheSubscriptionwith changescontextInfo- Additional sandbox and multitenant info- Returns:
- The new list of
SubscriptionWithItemssafter all the replaces, removes, and creates.
-
replaceSubscriptionAdjustments
protected List<SubscriptionAdjustment> replaceSubscriptionAdjustments(@NonNull S existing, @NonNull S changed, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscription.getSubscriptionAdjustments()using thechangedSubscription. Any adjustments with matching ids will be replaced, any inexistingnot inchangedwill be removed, and any inchangednot inexistingwill be created.- Parameters:
existing- The existing, unchangedSubscriptionchanged- TheSubscriptionwith changescontextInfo- Additional sandbox and multitenant info- Returns:
- The new list of
SubscriptionAdjustmentsafter all the replaces, removes, and creates.
-
replaceSubscriptionItemAdjustments
protected List<SubscriptionItemAdjustment> replaceSubscriptionItemAdjustments(@NonNull SWI existing, @NonNull SWI changed, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles replacing all of theexistingSubscriptionItem.getSubscriptionItemAdjustments()using thechangedSubscriptionItem. Any adjustments with matching ids will be replaced, any inexistingnot inchangedwill be removed, and any inchangednot inexistingwill be created.- Parameters:
existing- The existing, unchangedDefaultSubscriptionServicechanged- TheDefaultSubscriptionServicewith changescontextInfo- Additional sandbox and multitenant info- Returns:
- The new list of
SubscriptionItemAdjustments after all the replaces, removes, and creates.
-
findByContextId
-
buildSubscriptionWithItems
protected SWI buildSubscriptionWithItems(Subscription subscription, List<SubscriptionItem> subscriptionItems) -
retrievePageWithItems
protected org.springframework.data.domain.Page<SWI> retrievePageWithItems(org.springframework.data.domain.Page<S> subscriptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor each of the providedSubscriptions. This reads and hydrates all of theSubscriptionAdjustmentsonto theSubscriptionsas well as reading all of theirSubscriptionItems.This does not hydrate the
SubscriptionItemAdjustments.- Parameters:
subscriptions-Subscriptionsfor which to buildSubscriptionWithItemscontextInfo- Additional sandbox and multitenant info- Returns:
- A
SubscriptionWithItemsfor each of the providedSubscriptions.
-
buildSubscriptionsWithItems
protected List<SWI> buildSubscriptionsWithItems(List<S> subscriptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor each of the providedSubscriptions. This reads and hydrates all of theSubscriptionAdjustmentsonto theSubscriptionsas well as reading all of theirSubscriptionItems.This does not hydrate the
SubscriptionItemAdjustments.- Parameters:
subscriptions-Subscriptionsfor which to buildSubscriptionWithItemscontextInfo- Additional sandbox and multitenant info- Returns:
- A
SubscriptionWithItemsfor each of the providedSubscriptions.
-
buildSubscriptionItemsBySubscriptionIdMap
protected Map<String,Set<SubscriptionItem>> buildSubscriptionItemsBySubscriptionIdMap(@NonNull @NonNull List<S> subscriptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a map ofSubscriptionItemsbySubscription- Parameters:
subscriptions- The list of subscriptions for which the subscriptionItems are to be fetched.contextInfo- The context info- Returns:
- A map of
SubscriptionItemsbySubscription
-
getDefaultPageSize
protected int getDefaultPageSize()Returns the default page size- Returns:
- the default page size
-
hydrateSubscriptionAdjustments
protected void hydrateSubscriptionAdjustments(Collection<S> subscriptions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates the given subscriptionsadjustments.- Parameters:
subscriptions-Subscriptionsto hydratecontextInfo- Additional sandbox and multitenant info
-
hydrateItemAdjustments
protected <T extends SubscriptionItem> void hydrateItemAdjustments(Collection<T> items, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hydrates the given subscription itemsadjustments.- Parameters:
items-SubscriptionItemsto hydratecontextInfo- Additional sandbox and multitenant info
-
buildSubscriptionWithItems
protected SWI buildSubscriptionWithItems(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds aSubscriptionWithItemsfor the providedSubscription. This reads and hydrates all of theSubscriptionAdjustmentsonto theSubscriptionas well as reading all of theirSubscriptionItems. This also hydrates theSubscriptionItemAdjustments.- Parameters:
subscription- ASubscriptionfor which to buildSubscriptionWithItemscontextInfo- Additional sandbox and multitenant info- Returns:
- A
SubscriptionWithItemsfor the providedSubscriptions.
-
isOptimisticLockException
-
hasValidRemainingTryCount
protected boolean hasValidRemainingTryCount(int remainingTryCount) -
setSubscriptionBillingAuditService
@Autowired public void setSubscriptionBillingAuditService(SubscriptionBillingAuditService<SubscriptionBillingAudit> subscriptionBillingAuditService) -
setSubscriptionStatusAuditService
@Autowired public void setSubscriptionStatusAuditService(SubscriptionStatusAuditService<SubscriptionStatusAudit> subscriptionStatusAuditService) -
setBillingEventPaymentService
@Autowired public void setBillingEventPaymentService(BillingEventPaymentService<BillingEventPayment, BillingEventPaymentWithEvent, BillingEventDTO, BillingEventPaymentWithTransaction> billingEventPaymentService) -
setEntitlementProvider
-
setSubscriptionItemService
@Autowired public void setSubscriptionItemService(SubscriptionItemService<SubscriptionItem> subscriptionItemService) -
setSubscriptionAdjustmentService
@Autowired public void setSubscriptionAdjustmentService(SubscriptionAdjustmentService<SubscriptionAdjustment> subscriptionAdjustmentService) -
setSubscriptionItemAdjustmentService
@Autowired public void setSubscriptionItemAdjustmentService(SubscriptionItemAdjustmentService<SubscriptionItemAdjustment> subscriptionItemAdjustmentService) -
setNextBillDateService
-
setSubscriptionConfigurationProperties
@Autowired public void setSubscriptionConfigurationProperties(SubscriptionConfigurationProperties subscriptionConfigurationProperties) -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
setTransitionListener
@Autowired(required=false) public void setTransitionListener(com.broadleafcommerce.data.tracking.core.messaging.TransitionListener transitionListener) -
getParser
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getParser() -
setParser
@Autowired(required=false) public void setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
-