Class DefaultSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
java.lang.Object
com.broadleafcommerce.orderoperation.service.generate.subscription.DefaultSubscriptionGenerationService<O,F,SWI>
- All Implemented Interfaces:
SubscriptionGenerationService<O,F, SWI>
public class DefaultSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment,SWI extends SubscriptionWithItems>
extends Object
implements SubscriptionGenerationService<O,F,SWI>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSubscriptionGenerationService(SubscriptionOpsProvider<SWI> subscriptionOpsProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected CreateSubscriptionFromOrderRequestbuildRequest(O order, @NonNull Collection<F> fulfillments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) createNewSubscriptions(O order, @NonNull Collection<F> fulfillments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given the providedOrderand its items, creates aSubscription, if one is required.createToken(String subscriptionId, String tokenIdentifier) protected SubscriptionOpsProvider<SWI>protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanisSubscriptionItem(@NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem) lockSubscription(String subscriptionId, List<String> reservations) protected booleanorderItemRepresentsActionToExistingSubscription(O order, @NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem) protected booleanshouldCreateAnyNewSubscriptions(O order, @NonNull Collection<F> fulfillments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to determine whether a givenOrderhas any items representing aSubscriptionthat should be created.unlockToken(String subscriptionId, String token, boolean propagate)
-
Constructor Details
-
DefaultSubscriptionGenerationService
public DefaultSubscriptionGenerationService(SubscriptionOpsProvider<SWI> subscriptionOpsProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
createNewSubscriptions
public List<SWI> createNewSubscriptions(@NonNull O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionGenerationServiceGiven the providedOrderand its items, creates aSubscription, if one is required. Returns already existedSubscriptionif any.- Specified by:
createNewSubscriptionsin interfaceSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment, SWI extends SubscriptionWithItems> - Parameters:
order- a completed orderfulfillments- the order's collection of fulfillmentscontextInfo- context information around the multi-tenant state- Returns:
- the list of the Subscriptions & SubscriptionItems that were created
-
lockSubscription
- Specified by:
lockSubscriptionin interfaceSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment, SWI extends SubscriptionWithItems>
-
clearLock
- Specified by:
clearLockin interfaceSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment, SWI extends SubscriptionWithItems>
-
unlockToken
- Specified by:
unlockTokenin interfaceSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment, SWI extends SubscriptionWithItems>
-
createToken
- Specified by:
createTokenin interfaceSubscriptionGenerationService<O extends com.broadleafcommerce.order.client.domain.Order,F extends com.broadleafcommerce.order.client.domain.OrderFulfillment, SWI extends SubscriptionWithItems>
-
buildRequest
protected CreateSubscriptionFromOrderRequest buildRequest(@NonNull O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldCreateAnyNewSubscriptions
protected boolean shouldCreateAnyNewSubscriptions(O order, @NonNull @NonNull Collection<F> fulfillments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Hook point to determine whether a givenOrderhas any items representing aSubscriptionthat should be created. By default, a subscription is only created for items that need to be billed recurringly. This method checks whetherOrderItem.getRecurringPrice()is not null to determine that for each item. IMPORTANT: By default, this method assumes that if any of the dependentOrderItemsare subscriptions, then their parent (i.e., the root items on theOrder) are also subscriptions.- Parameters:
order- TheOrderwithOrderItemsrepresentingSubscriptionsto createfulfillments- TheOrderFulfillmentscreated forordercontextInfo- Additional sandbox and multitenant info- Returns:
- whether a subscription should be created for the given orderItem
-
isSubscriptionItem
protected boolean isSubscriptionItem(@NonNull @NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
orderItemRepresentsActionToExistingSubscription
protected boolean orderItemRepresentsActionToExistingSubscription(@NonNull O order, @NonNull @NonNull com.broadleafcommerce.order.client.domain.OrderItem orderItem) -
getSubscriptionOpsProvider
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-