Interface SubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
- All Superinterfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<S>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<S>
- All Known Implementing Classes:
DefaultSubscriptionService
public interface SubscriptionService<S extends Subscription,SWI extends SubscriptionWithItems>
extends com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<S>
-
Method Summary
Modifier and TypeMethodDescriptionaddPriceDataChange(Set<String> subscriptionIds, PriceDataChange change, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds aPriceDataChangeto the subscription.default ScallToCancelSubscription(S subscription, String reason) Deprecated.voidcancelActiveSubscription(String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) default voidcancelAllPriorSubscriptions(List<String> subscriptionsIds) Deprecated.UsecancelAllPriorSubscriptions(List, ContextInfo)insteadvoidcancelAllPriorSubscriptions(List<String> subscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels all prior subscriptions bySubscription.getNextSubscription()in the given subscriptionIds listdefault ScancelSubscription(String subscriptionId, String reason) Deprecated.UsecancelSubscription(String, String, ContextInfo)insteadcancelSubscription(String subscriptionId, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscriptionwith the provided subscriptionIddefault ScancelSubscription(S subscription, String reason) Deprecated.cancelSubscription(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscriptiondefault ScancelSubscriptionForFailureBilling(S subscription) Deprecated.cancelSubscriptionForFailureBilling(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Set the subscriptionStatus toSubscriptionStatusEnum.CANCELLEDand create a respectiveSubscriptionStatusAuditdefault ScancelSubscriptionImmediately(S subscription, String reason) Deprecated.cancelSubscriptionImmediately(S subscription, String reason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels theSubscriptionimmediately instead of factoring in the grace period logicdefault voidcancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason) Deprecated.voidcancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidApply any uncommitted changes to the subscription to the production state.default LongcountAllBySubscriptionStatus(String subscriptionStatus) Deprecated.countAllBySubscriptionStatus(String subscriptionStatus, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Count all subscription entities given the subscription statusdefault ScreateSubscription(S subscriptionRequest) Deprecated.UseCrudEntityService.create(Object, ContextInfo)insteaddefault SWIcreateSubscriptionWithItems(SWI subscriptionRequest) Deprecated.createSubscriptionWithItems(SWI subscriptionWithItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) findAllByIds(List<String> ids) Deprecated.UseCrudEntityService.readAllByContextId(Iterable, ContextInfo)insteadfindAllByUserRefAndItemRefs(String userRef, Collection<String> itemRefs) Deprecated.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.findAllSubscriptionsByUserRef(String userRef, boolean includeInactive) Deprecated.findAllSubscriptionsByUserRefAndStatuses(String userRef, String[] statuses) Deprecated.findAllSubscriptionWithItemsById(List<String> subscriptionsIds) Deprecated.UsefindAllWithItemsById(List, ContextInfo)insteadfindAllWithItemsById(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.Deprecated.UseCrudEntityService.readByContextId(String, ContextInfo)insteadfindByMatchingSource(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find aSubscriptionwith the source matching theSubscriptiongiven.findBySubscriptionSourceRef(String subscriptionSourceRef) Deprecated.UsefindBySubscriptionSourceRef(String, ContextInfo)insteadfindBySubscriptionSourceRef(String subscriptionSourceRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find theSubscriptionby subscriptionSourceRefdefault SearchResult<String>findIdsBySubscriptionStatus(String subscriptionStatus, int page, int pageSize) Deprecated.org.springframework.data.domain.Page<String>findIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) default SWIfindWithItemsById(String subscriptionId) Deprecated.UsefindWithItemsById(String, ContextInfo)insteadfindWithItemsById(String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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(String subscriptionId, String userRefType, String userRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a user-owned subscription with items for a given idreplaceSubscription(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces aSubscription.replaceSubscriptionWithItems(SWI subscriptionWithItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidRevert any uncommitted changes to the subscription.default voidupdateNextSubscriptionForActiveStatus(String subscriptionId) Deprecated.UsecancelActiveSubscription(String, ContextInfo)insteaddefault SupdateSubscription(S subscriptionRequest) Deprecated.UseCrudEntityService.update(String, Object, ContextInfo)insteaddefault SupdateSubscriptionFromJob(S subscription) Deprecated.updateSubscriptionFromJob(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the subscription.default SupgradeSubscription(S subscription, List<String> priorSubscriptionIds) Deprecated.upgradeSubscription(S subscription, List<String> priorSubscriptionIds, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create the upgradedSubscriptionand cancel prior subscriptions in its favordefault SWIupgradeSubscriptionByItemRefs(SWI subscription, Set<String> upgradableItemRefs) Deprecated.upgradeSubscriptionByItemRefs(SWI subscription, Set<String> upgradableItemRefs, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Upgrade subscriptions matching the subscription's userRef and given subscriptionItem referencesMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, 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, readAll
-
Method Details
-
findById
Deprecated.UseCrudEntityService.readByContextId(String, ContextInfo)instead -
findWithItemsById
Deprecated.UsefindWithItemsById(String, ContextInfo)instead -
findWithItemsById
-
findAllByIds
Deprecated.UseCrudEntityService.readAllByContextId(Iterable, ContextInfo)insteadFind all theSubscriptionby their ids -
findBySubscriptionSourceRef
@Deprecated(since="1.0.0") default Optional<S> findBySubscriptionSourceRef(String subscriptionSourceRef) Deprecated.UsefindBySubscriptionSourceRef(String, ContextInfo)insteadFind theSubscriptionby subscriptionSourceRef -
findBySubscriptionSourceRef
Optional<S> findBySubscriptionSourceRef(String subscriptionSourceRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find theSubscriptionby subscriptionSourceRef -
findAllSubscriptionsByUserRef
@Deprecated(since="1.0.0") default List<SWI> findAllSubscriptionsByUserRef(String userRef, boolean includeInactive) Deprecated.Find allsubscriptionsby userRef. Optionally include inactive records. -
findAllByUserRefTypeAndUserRef
List<SWI> findAllByUserRefTypeAndUserRef(String userRefType, String userRef, boolean includeInactive, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef. Optionally include inactive records. -
findAllByUserRefTypeAndUserRef
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) Find allsubscriptionsby userRef. Optionally include inactive records. -
findAllSubscriptionOwnerInfosByPriceData
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) Find allsubscription infosrelated to subscriptions by priceDataId.- 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
SWI readByContextIdAndUserRefTypeAndUserRef(String subscriptionId, String userRefType, String userRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves a user-owned subscription with items for a given id- 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
-
findAllSubscriptionsByUserRefAndStatuses
@Deprecated(since="1.0.0") @Nullable default List<SWI> findAllSubscriptionsByUserRefAndStatuses(String userRef, String[] statuses) Deprecated.Find allsubscriptionsby userRef and statuses. -
findAllWithItemsByUserRefTypeAndUserRefAndStatuses
@Nullable List<SWI> findAllWithItemsByUserRefTypeAndUserRefAndStatuses(String userRefType, String userRef, List<String> statuses, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find allsubscriptionsby userRef and statuses. -
findByMatchingSource
Optional<S> findByMatchingSource(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Find aSubscriptionwith the source matching theSubscriptiongiven. By default, this is based onSubscription.getSubscriptionSource(),Subscription.getSubscriptionSourceRef(),Subscription.getSecondarySourceType(), andSubscription.getSecondarySourceRef().- Parameters:
subscription- ASubscriptionfor which to find a matching source.
-
createSubscription
Deprecated.UseCrudEntityService.create(Object, ContextInfo)instead -
createSubscriptionWithItems
Deprecated.Create theSubscriptionand relateditems -
createSubscriptionWithItems
SWI createSubscriptionWithItems(SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Parameters:
subscriptionWithItems- Request containing theSubscriptionto make.contextInfo- Additional sandbox and multitenant info- Returns:
- The created
Subscriptionand related entities.
-
replaceSubscriptionWithItems
SWI replaceSubscriptionWithItems(SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Parameters:
subscriptionWithItems- Request containing updates to make.contextInfo- Additional sandbox and multitenant info- Returns:
- The updated
Subscriptionand related entities.
-
updateSubscription
Deprecated.UseCrudEntityService.update(String, Object, ContextInfo)instead -
cancelSubscription
Deprecated.UsecancelSubscription(String, String, ContextInfo)instead -
cancelSubscription
S cancelSubscription(String subscriptionId, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscriptionwith the provided subscriptionId- Parameters:
subscriptionId- id for the subscription to be cancelledreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
cancelSubscription
Deprecated. -
cancelSubscription
S cancelSubscription(S subscription, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancel aSubscription- Parameters:
subscription- the subscription to be cancelledreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
replaceSubscription
S replaceSubscription(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Replaces aSubscription.- Parameters:
subscription- the subscription to replacecontextInfo- context information around multi-tenant state- Returns:
- the updated subscription
-
cancelSubscriptionImmediately
Deprecated.Cancels theSubscriptionimmediately instead of factoring in the grace period logic -
cancelSubscriptionImmediately
S cancelSubscriptionImmediately(S subscription, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels theSubscriptionimmediately instead of factoring in the grace period logic- Parameters:
subscription- the subscription to be cancelled immediatelyreason- reason for the cancellationcontextInfo- context information around multi-tenant state- Returns:
- the cancelled subscription
-
upgradeSubscription
@Deprecated(since="1.0.0") default S upgradeSubscription(S subscription, List<String> priorSubscriptionIds) Deprecated. -
upgradeSubscription
S upgradeSubscription(S subscription, List<String> priorSubscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Create the upgradedSubscriptionand cancel prior subscriptions in its favor- Parameters:
subscription- upgraded subscription to createpriorSubscriptionIds- prior subscription ids to be cancelledcontextInfo- context information around multi-tenant state- Returns:
- the upgraded subscription
-
upgradeSubscriptionByItemRefs
@Deprecated(since="1.0.0") default SWI upgradeSubscriptionByItemRefs(SWI subscription, Set<String> upgradableItemRefs) Deprecated.Upgrade subscriptions with given item refs to the given subscription -
upgradeSubscriptionByItemRefs
SWI upgradeSubscriptionByItemRefs(SWI subscription, Set<String> upgradableItemRefs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Upgrade subscriptions matching the subscription's userRef and given subscriptionItem references- Parameters:
subscription- the upgraded subscriptionupgradableItemRefs- the items refs for prior subscriptions to be upgradecontextInfo- context information around multi-tenant state- Returns:
- the upgraded subscription
-
findAllByUserRefAndItemRefs
@Deprecated(since="1.0.0") default List<S> findAllByUserRefAndItemRefs(String userRef, Collection<String> itemRefs) Deprecated. -
findAllByUserRefTypeAndUserRefAndItemRefs
-
callToCancelSubscription
Deprecated. -
findAllSubscriptionWithItemsById
@Deprecated(since="1.0.0") default List<SWI> findAllSubscriptionWithItemsById(List<String> subscriptionsIds) Deprecated.UsefindAllWithItemsById(List, ContextInfo)instead -
findAllWithItemsById
-
updateNextSubscriptionForActiveStatus
@Deprecated(since="1.0.0") default void updateNextSubscriptionForActiveStatus(String subscriptionId) Deprecated.UsecancelActiveSubscription(String, ContextInfo)instead -
cancelActiveSubscription
void cancelActiveSubscription(String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
cancelAllPriorSubscriptions
Deprecated.UsecancelAllPriorSubscriptions(List, ContextInfo)insteadFind all the prior Subscriptions bySubscription.getNextSubscription()and updateSubscriptionstatus to CANCELLED -
cancelAllPriorSubscriptions
void cancelAllPriorSubscriptions(List<String> subscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Cancels all prior subscriptions bySubscription.getNextSubscription()in the given subscriptionIds list- Parameters:
subscriptionIds- ids of nextSubscriptions for which to cancel prior subscriptionscontextInfo- context information around multi-tenant state
-
findIdsBySubscriptionStatus
@Deprecated(since="1.0.0") default SearchResult<String> findIdsBySubscriptionStatus(String subscriptionStatus, int page, int pageSize) Deprecated. -
findIdsBySubscriptionStatus
-
countAllBySubscriptionStatus
Deprecated. -
countAllBySubscriptionStatus
Long countAllBySubscriptionStatus(String subscriptionStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Count all subscription entities given the subscription status -
cancelSubscriptionForFailureBilling
Deprecated. -
cancelSubscriptionForFailureBilling
S cancelSubscriptionForFailureBilling(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Set the subscriptionStatus toSubscriptionStatusEnum.CANCELLEDand create a respectiveSubscriptionStatusAudit- Parameters:
subscription- subscription to cancelcontextInfo- context information around multi-tenant state- Returns:
- cancelled subscription
-
updateSubscriptionFromJob
Deprecated.This would read the record from the DB and do validate the DB Version property to check for any StaleObject and throw custom OptimisticLockException -
updateSubscriptionFromJob
S updateSubscriptionFromJob(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the subscription. Ensures the given subscription has an updatedSubscription.getVersion()value before proceeding- Parameters:
subscription- subscription to be updatedcontextInfo- context information around multi-tenant state- Returns:
- updated subscription
- Throws:
CustomOptimisticLockException- if the given subscription's version is out of date
-
cancelSubscriptionImmediatelyWithRetries
@Deprecated(since="1.0.0") default void cancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason) Deprecated.Performs an immediate cancellation of the subscription and will retry the cancellation if the subscription is optimistically locked.SubscriptionConfigurationProperties.getOptimisticLockTryCount()is used to declare the number of times that the update can be attempted forObjectOptimisticLockingFailureExceptions -
cancelSubscriptionImmediatelyWithRetries
void cancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) CallscancelSubscriptionImmediately(Subscription, String, ContextInfo). Retries the operation in case of concurrency problems -
commit
void commit(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Apply 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.
- Parameters:
subscriptionId- the subscription to commitcontextInfo- context information around multi-tenant state- See Also:
-
#revert(String, ContextInfo)
-
revert
void revert(S subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Revert 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.- Parameters:
subscriptionId- the subscription to revertcontextInfo- context information around multi-tenant state- See Also:
-
#commit(String, ContextInfo)
-
readAllByName
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) Reads a paginated result set of allSubscriptions, applying the provided name, filters, page request, and context info against the results.- 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
List<String> addPriceDataChange(Set<String> subscriptionIds, PriceDataChange change, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds aPriceDataChangeto the subscription. This will be used to set upBillingEvents appropriately for timely charging of the subscription.- 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
-
cancelSubscription(Subscription, String, ContextInfo)instead