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 Details

    • findById

      @Deprecated(since="1.0.0") default Optional<S> findById(String subscriptionId)
      Deprecated.
      Use CrudEntityService.readByContextId(String, ContextInfo) instead
    • findWithItemsById

      @Deprecated(since="1.0.0") default SWI findWithItemsById(String subscriptionId)
    • findWithItemsById

      SWI findWithItemsById(String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • findAllByIds

      @Deprecated(since="1.0.0") default List<S> findAllByIds(List<String> ids)
      Deprecated.
      Use CrudEntityService.readAllByContextId(Iterable, ContextInfo) instead
      Find all the Subscription by their ids
    • findBySubscriptionSourceRef

      @Deprecated(since="1.0.0") default Optional<S> findBySubscriptionSourceRef(String subscriptionSourceRef)
      Find the Subscription by subscriptionSourceRef
    • findBySubscriptionSourceRef

      Optional<S> findBySubscriptionSourceRef(String subscriptionSourceRef, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find the Subscription by subscriptionSourceRef
    • findAllSubscriptionsByUserRef

      @Deprecated(since="1.0.0") default List<SWI> findAllSubscriptionsByUserRef(String userRef, boolean includeInactive)
      Find all subscriptions by 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 all subscriptions by 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 all subscriptions by 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 all subscription infos related to subscriptions by priceDataId.
      Parameters:
      priceDataId - The id of the priceData belonging to one or more of the contained SubscriptionItem instances in associated Subscription instances.
      statuses - Set of statuses to filter by.
      page - The page information
      contextInfo - 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 subscription
      userRefType - type of the owning user
      userRef - id of the owning user
      contextInfo - 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)
      Find all subscriptions by 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 all subscriptions by userRef and statuses.
    • findByMatchingSource

      Optional<S> findByMatchingSource(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Parameters:
      subscription - A Subscription for which to find a matching source.
    • createSubscription

      @Deprecated(since="1.0.0") default S createSubscription(S subscriptionRequest)
      Deprecated.
      Use CrudEntityService.create(Object, ContextInfo) instead
    • createSubscriptionWithItems

      @Deprecated(since="1.0.0") default SWI createSubscriptionWithItems(SWI subscriptionRequest)
      Create the Subscription and related items
    • createSubscriptionWithItems

      SWI createSubscriptionWithItems(SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Parameters:
      subscriptionWithItems - Request containing the Subscription to make.
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The created Subscription and related entities.
    • replaceSubscriptionWithItems

      SWI replaceSubscriptionWithItems(SWI subscriptionWithItems, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Replaces the Subscription provided along with its SubscriptionAdjustments and SubscriptionItems.
      Parameters:
      subscriptionWithItems - Request containing updates to make.
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The updated Subscription and related entities.
    • updateSubscription

      @Deprecated(since="1.0.0") default S updateSubscription(S subscriptionRequest)
      Deprecated.
      Use CrudEntityService.update(String, Object, ContextInfo) instead
    • cancelSubscription

      @Deprecated(since="1.0.0") default S cancelSubscription(String subscriptionId, String reason)
    • cancelSubscription

      S cancelSubscription(String subscriptionId, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Cancel a Subscription with the provided subscriptionId
      Parameters:
      subscriptionId - id for the subscription to be cancelled
      reason - reason for the cancellation
      contextInfo - context information around multi-tenant state
      Returns:
      the cancelled subscription
    • cancelSubscription

      @Deprecated(since="1.0.0") default S cancelSubscription(S subscription, String reason)
    • cancelSubscription

      S cancelSubscription(S subscription, String reason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Cancel a Subscription
      Parameters:
      subscription - the subscription to be cancelled
      reason - reason for the cancellation
      contextInfo - 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 a Subscription.
      Parameters:
      subscription - the subscription to replace
      contextInfo - context information around multi-tenant state
      Returns:
      the updated subscription
    • cancelSubscriptionImmediately

      @Deprecated(since="1.0.0") default S cancelSubscriptionImmediately(S subscription, String reason)
      Cancels the Subscription immediately 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 the Subscription immediately instead of factoring in the grace period logic
      Parameters:
      subscription - the subscription to be cancelled immediately
      reason - reason for the cancellation
      contextInfo - context information around multi-tenant state
      Returns:
      the cancelled subscription
    • upgradeSubscription

      @Deprecated(since="1.0.0") default S upgradeSubscription(S subscription, List<String> priorSubscriptionIds)
    • upgradeSubscription

      S upgradeSubscription(S subscription, List<String> priorSubscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Create the upgraded Subscription and cancel prior subscriptions in its favor
      Parameters:
      subscription - upgraded subscription to create
      priorSubscriptionIds - prior subscription ids to be cancelled
      contextInfo - context information around multi-tenant state
      Returns:
      the upgraded subscription
    • upgradeSubscriptionByItemRefs

      @Deprecated(since="1.0.0") default SWI upgradeSubscriptionByItemRefs(SWI subscription, Set<String> upgradableItemRefs)
      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 subscription
      upgradableItemRefs - the items refs for prior subscriptions to be upgrade
      contextInfo - 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)
    • findAllByUserRefTypeAndUserRefAndItemRefs

      List<S> findAllByUserRefTypeAndUserRefAndItemRefs(String userRefType, String userRef, Collection<String> itemRefs, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • callToCancelSubscription

      @Deprecated(since="1.0.0") default S callToCancelSubscription(S subscription, String reason)
    • findAllSubscriptionWithItemsById

      @Deprecated(since="1.0.0") default List<SWI> findAllSubscriptionWithItemsById(List<String> subscriptionsIds)
    • findAllWithItemsById

      List<SWI> findAllWithItemsById(List<String> subscriptionsIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • updateNextSubscriptionForActiveStatus

      @Deprecated(since="1.0.0") default void updateNextSubscriptionForActiveStatus(String subscriptionId)
    • cancelActiveSubscription

      void cancelActiveSubscription(String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • cancelAllPriorSubscriptions

      @Deprecated(since="1.0.0") default void cancelAllPriorSubscriptions(List<String> subscriptionsIds)
      Find all the prior Subscriptions by Subscription.getNextSubscription() and update Subscription status to CANCELLED
    • cancelAllPriorSubscriptions

      void cancelAllPriorSubscriptions(List<String> subscriptionIds, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Cancels all prior subscriptions by Subscription.getNextSubscription() in the given subscriptionIds list
      Parameters:
      subscriptionIds - ids of nextSubscriptions for which to cancel prior subscriptions
      contextInfo - context information around multi-tenant state
    • findIdsBySubscriptionStatus

      @Deprecated(since="1.0.0") default SearchResult<String> findIdsBySubscriptionStatus(String subscriptionStatus, int page, int pageSize)
    • findIdsBySubscriptionStatus

      org.springframework.data.domain.Page<String> findIdsBySubscriptionStatus(String subscriptionStatus, org.springframework.data.domain.Pageable pageable, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • countAllBySubscriptionStatus

      @Deprecated(since="1.0.0") default Long countAllBySubscriptionStatus(String subscriptionStatus)
    • countAllBySubscriptionStatus

      Long countAllBySubscriptionStatus(String subscriptionStatus, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Count all subscription entities given the subscription status
    • cancelSubscriptionForFailureBilling

      @Deprecated(since="1.0.0") default S cancelSubscriptionForFailureBilling(S subscription)
    • cancelSubscriptionForFailureBilling

      S cancelSubscriptionForFailureBilling(S subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Set the subscriptionStatus to SubscriptionStatusEnum.CANCELLED and create a respective SubscriptionStatusAudit
      Parameters:
      subscription - subscription to cancel
      contextInfo - context information around multi-tenant state
      Returns:
      cancelled subscription
    • updateSubscriptionFromJob

      @Deprecated(since="1.0.0") default S updateSubscriptionFromJob(S subscription)
      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 updated Subscription.getVersion() value before proceeding
      Parameters:
      subscription - subscription to be updated
      contextInfo - 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)
      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 for ObjectOptimisticLockingFailureExceptions
    • cancelSubscriptionImmediatelyWithRetries

      void cancelSubscriptionImmediatelyWithRetries(String subscriptionId, String cancelReason, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Calls cancelSubscriptionImmediately(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 commit
      contextInfo - 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 revert
      contextInfo - 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 all Subscriptions, applying the provided name, filters, page request, and context info against the results.
      Parameters:
      name - A full or partial name to filter the results by
      filters - Additional RSQL filters to apply
      page - The page information
      context - 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 a PriceDataChange to the subscription. This will be used to set up BillingEvents appropriately for timely charging of the subscription.
      Parameters:
      subscriptionIds - The id list of the subscriptions to add the change to
      change - The pricing change information
      contextInfo - Additional sandbox and multitenant info
      Returns:
      The list of ids for updated subscriptions