Class DefaultSubscriptionOperationService<SWI extends SubscriptionWithItems>
java.lang.Object
com.broadleafcommerce.subscriptionoperation.service.DefaultSubscriptionOperationService<SWI>
- All Implemented Interfaces:
SubscriptionOperationService<SWI>
public class DefaultSubscriptionOperationService<SWI extends SubscriptionWithItems>
extends Object
implements SubscriptionOperationService<SWI>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultSubscriptionOperationService(SubscriptionProvider<SWI, Subscription, SubscriptionOwnerInfo> subscriptionProvider, SubscriptionValidationService subscriptionValidationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, List<ModifySubscriptionHandler> modifySubscriptionHandlers, CatalogProvider<Product> catalogProvider, CancellationPolicyProvider<CancellationPolicy> cancellationPolicyProvider, SubscriptionGenerationService<SWI> subscriptionGenerationService, SubscriptionOperationUtils subscriptionOperationUtils, com.broadleafcommerce.orchestration.service.provider.external.WorkflowProvider workflowProvider, SubscriptionOperationServiceProperties subOpsServiceProperties, org.springframework.context.MessageSource messageSource) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAdjustment(@NonNull AddAdjustmentRequest addAdjustmentRequest, String subscriptionId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Adds the requestedadjustmentsonto theSubscriptionthat matches the passed ID.protected voidaddUnavailableAction(SWI swi, @NonNull String actionType, @NonNull String reasonMessagePath) buildAddAdjustmentWorkflowContext(@NonNull String subscriptionId, @NonNull LockStatus lockStatus, @NonNull AddAdjustmentRequest addAdjustmentRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the context for theDefaultWorkflowNameConstants.SUBSCRIPTION_CSR_ADD_ADJUSTMENT_WORKFLOWworkflow.protected SubscriptionActionbuildAvailableAction(SWI subscription, @NonNull String actionType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates aSubscriptionActionfor theactionTypeandSubscriptionWithItemsrepresenting an action that may be taken against thesubscription.protected Map<String,ItemChoice> buildItemChoiceByChoiceKey(@NonNull Product product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a map of choice keys to item choices for all options on the product, including child options.protected SubscriptionbuildSubscription(@NonNull SubscriptionCreationRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<SubscriptionItem>buildSubscriptionItems(@NonNull SubscriptionCreationRequest creationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected SWIbuildSubscriptionWithItems(@NonNull SubscriptionCreationRequest creationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) buildUpdatePriceDataWorkflowContext(@NonNull String priceDataId, @NonNull PriceChangeRequest priceChangeRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the context for theDefaultWorkflowNameConstants.SUBSCRIPTION_BULK_PRICING_UPDATE_WORKFLOWworkflow.Forcefully clear a lock on a subscription.createSubscriptionFromOrder(@NonNull CreateSubscriptionFromOrderRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out aSubscriptionWithItemsfrom order details, and calls a provider to persist them in the resource-tier service.createSubscriptionWithItems(@NonNull SubscriptionCreationRequest creationRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds out aSubscriptionWithItemsand calls a provider to persist them in the resource-tier servicecreateToken(String subscriptionId, String tokenIdentifier) Create a child lock on a subscription.getAddablePostPurchaseOptions(@NonNull Product product, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a set of choice keys for theItemChoices that are allowed to be added post-purchase.Gets all the possible action types that can be performed by the customer (not CSR or system).getCancellationFeeProductIdToFetch(@NonNull CancellationPolicyDetail cancellationPolicyDetail, @NonNull SubscriptionWithItems subscriptionWithItems) Fetches the Id of the extra (cancellation) fee product.protected CancellationPolicyProvider<CancellationPolicy>protected CatalogProvider<Product>protected List<ProductOption>getChildOptions(@NonNull ItemChoice itemChoice, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the child options for the givenItemChoice.protected Set<SubscriptionItem>getCurrentAddons(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the current addons for the givenDefaultSubscriptionOperationService.protected SubscriptionReferencedItemgetCustomRootItemReferencedBySubscription(SWI subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles getting theSubscriptionReferencedItemfor a customSubscription.getRootItemRefType().protected StringgetLockToken(@NonNull LockStatus lockStatus) protected StringgetMessage(@NonNull String messagePath, Object... args) protected org.springframework.context.MessageSourceprotected List<ModifySubscriptionHandler>protected SubscriptionReferencedItemgetRootItemReferencedBySubscription(SWI subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves theSubscriptionReferencedItemreferenced as theSubscription.getRootItemRef().protected SubscriptionOperationServicePropertiesprotected SubscriptionGenerationService<SWI>protected SubscriptionOperationUtilsprotected SubscriptionProvider<SWI,Subscription, SubscriptionOwnerInfo> protected Optional<SubscriptionStatusHandler<SWI>>getSubscriptionStatusHandler(@NonNull UpdateSubscriptionStatusRequest request, SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected List<SubscriptionStatusHandler<SWI>>protected SubscriptionValidationServiceprotected com.broadleafcommerce.common.extension.TypeFactoryprotected com.broadleafcommerce.orchestration.service.provider.external.WorkflowProviderprotected SubscriptionhandleStatusUpdateRequest(@NonNull UpdateSubscriptionStatusRequest request, SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanhasNewAddonsToAdd(@NonNull Set<SubscriptionItem> currentAddons, @NonNull Set<String> addablePostPurchase, @NonNull Map<String, ItemChoice> itemChoiceByChoiceKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether new addons can be added post-purchase given the current addons,protected booleanisAnyCurrentAddonsEditable(@NonNull Set<SubscriptionItem> currentAddons, @NonNull Map<String, ItemChoice> itemChoiceByChoiceKey, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether any of the current addons are editable post-purchase.protected booleanisCurrentDateBeyondDowngradeAvailabilityDuration(SWI subscriptionWithItems) Determines whether the current time is beyond the period start date + restrictDowngradeAfterDays.lockSubscription(String subscriptionId, List<String> reservations) Attempt to create a lock on a subscription.modifySubscription(@NonNull ModifySubscriptionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles modifyingSubscriptionsbased on the allowedactions.protected voidpopulateCancelAction(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.CANCEL.protected voidpopulateCancelActionInfo(@NonNull SubscriptionWithItems subscription, @NonNull SubscriptionAction action, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anDefaultSubscriptionActionType.CANCELaction for the givenSubscriptionWithItems.protected voidpopulateCancellationFeeProducts(@NonNull SubscriptionWithItems subscriptionWithItems, @NonNull CancellationPolicyDetail cancellationPolicyDetail, @NonNull SubscriptionAction action, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the extra (cancellation) fee products including the grace fee cancellation product if applicable on the givenactionfrom the givenCancellationPolicyDetailby fetching them from the Catalog Service.protected voidpopulateChangeAutoRenewalAction(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.CHANGE_AUTO_RENEWAL.protected voidpopulateDowngradeAction(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.DOWNGRADE.protected voidpopulateDowngradeActionInfo(@NonNull SubscriptionReferencedItem rootItem, @NonNull SubscriptionAction action, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anDOWNGRADEaction for the givenSubscriptionWithItems.protected voidpopulateEditAction(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.EDIT.protected voidpopulateSubscriptionActionAvailability(@NonNull String actionType, SWI subscriptionWithItems, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateSubscriptionActions(Iterable<SWI> subscriptions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidpopulateSubscriptionActions(SWI subscription, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidpopulateUpgradeAction(SWI swi, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.UPGRADE.protected voidpopulateUpgradeActionInfo(@NonNull SubscriptionReferencedItem rootItem, @NonNull SubscriptionAction action, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anUPGRADEaction for the givenSubscriptionWithItems.readSubscriptionActions(@NonNull SubscriptionActionRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method reads subscriptions for a given user type and user id, additionally filtered and paginated by given parametersreadSubscriptionById(@NonNull String subscriptionId, boolean isSandboxAware, boolean ignoreDeleteFiltering, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method reads a subscription for the given idorg.springframework.data.domain.Page<SWI>readSubscriptionsForUserRefTypeAndUserRef(@NonNull String userRefType, @NonNull String userRef, boolean getActions, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method reads subscriptions for a given user type and user id, additionally filtered and paginated by given parametersreadUserSubscriptionById(@NonNull String userRefType, @NonNull String userRef, @NonNull String subscriptionId, boolean getActions, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) This method attempts to find aSubscriptionWithItemsby id which is owned by the user/accountreplaceSubscriptionWithItems(SWI subscriptionWithItems, boolean isSandboxAware, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles updating theSubscription'sstatus.voidsetSubscriptionStatusHandlers(List<SubscriptionStatusHandler<SWI>> subscriptionStatusHandlers) unlockToken(String subscriptionId, String token, boolean propagate) Unlock a child lock on a subscription.voidupdatePriceData(String priceDataId, PriceChangeRequest priceChangeRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) updateSubscriptionStatus(@NonNull UpdateSubscriptionStatusRequest request, boolean isSandboxAware, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles updating theSubscription'sstatus.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.subscriptionoperation.service.SubscriptionOperationService
readSubscriptionById, readSubscriptionById
-
Constructor Details
-
DefaultSubscriptionOperationService
public DefaultSubscriptionOperationService(SubscriptionProvider<SWI, Subscription, SubscriptionOwnerInfo> subscriptionProvider, SubscriptionValidationService subscriptionValidationService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, List<ModifySubscriptionHandler> modifySubscriptionHandlers, CatalogProvider<Product> catalogProvider, CancellationPolicyProvider<CancellationPolicy> cancellationPolicyProvider, SubscriptionGenerationService<SWI> subscriptionGenerationService, SubscriptionOperationUtils subscriptionOperationUtils, com.broadleafcommerce.orchestration.service.provider.external.WorkflowProvider workflowProvider, SubscriptionOperationServiceProperties subOpsServiceProperties, org.springframework.context.MessageSource messageSource)
-
-
Method Details
-
populateSubscriptionActions
public void populateSubscriptionActions(@NonNull SWI subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServicePopulatesSubscriptionWithItems.getAvailableActions()andSubscriptionWithItems.getUnavailableReasonsByActionType().- Specified by:
populateSubscriptionActionsin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscription- TheSubscriptionWithItemsto populate.contextInfo- Additional sandbox and multitenant info.
-
readSubscriptionActions
public SubscriptionActionResponse readSubscriptionActions(@NonNull @NonNull SubscriptionActionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceThis method reads subscriptions for a given user type and user id, additionally filtered and paginated by given parameters- Specified by:
readSubscriptionActionsin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
request- theSubscriptionActionRequestcontextInfo- context information around multi-tenant state- Returns:
- Subscriptions with items matching the given criteria
-
readSubscriptionsForUserRefTypeAndUserRef
public org.springframework.data.domain.Page<SWI> readSubscriptionsForUserRefTypeAndUserRef(@NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, boolean getActions, @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:SubscriptionOperationServiceThis method reads subscriptions for a given user type and user id, additionally filtered and paginated by given parameters- Specified by:
readSubscriptionsForUserRefTypeAndUserRefin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
userRefType- user type, seeDefaultUserRefTypesuserRef- id of owning user or accountgetActions- whether to get available actions for the subscriptionspage- information about which page of results to return from the database.filters- additional filters to apply in the query. Should beEmptyNodeif no additional filters should be applied.contextInfo- context information around multi-tenant state- Returns:
- Subscriptions with items matching the given criteria
-
readUserSubscriptionById
public SWI readUserSubscriptionById(@NonNull @NonNull String userRefType, @NonNull @NonNull String userRef, @NonNull @NonNull String subscriptionId, boolean getActions, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceThis method attempts to find aSubscriptionWithItemsby id which is owned by the user/account- Specified by:
readUserSubscriptionByIdin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
userRefType- user type, seeDefaultUserRefTypesuserRef- id of owning user or accountsubscriptionId- The id of theSubscriptionthat is intended to be gatheredgetActions- whether to get available actions for the subscriptioncontextInfo- context information around multi-tenant state- Returns:
- Subscriptions with items matching the given criteria
-
readSubscriptionById
public SWI readSubscriptionById(@NonNull @NonNull String subscriptionId, boolean isSandboxAware, boolean ignoreDeleteFiltering, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceThis method reads a subscription for the given id- Specified by:
readSubscriptionByIdin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionId- The id of theSubscriptionthat is intended to be gatheredisSandboxAware- Whether to look for sandbox recordsignoreDeleteFiltering- Whether to ignore sandbox delete filteringcontextInfo- context information around multi-tenant state- Returns:
- a subscription with items identified by the subscription id
-
createSubscriptionWithItems
public SWI createSubscriptionWithItems(@NonNull @NonNull SubscriptionCreationRequest creationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceBuilds out aSubscriptionWithItemsand calls a provider to persist them in the resource-tier service- Specified by:
createSubscriptionWithItemsin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
creationRequest- request DTO with necessary fields to build a subscriptioncontextInfo- context information around multi-tenant state- Returns:
- a created subscription with its items
-
createSubscriptionFromOrder
public List<SWI> createSubscriptionFromOrder(@NonNull @NonNull CreateSubscriptionFromOrderRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceBuilds out aSubscriptionWithItemsfrom order details, and calls a provider to persist them in the resource-tier service.- Specified by:
createSubscriptionFromOrderin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
request- request DTO with necessary fields to build aSubscription.contextInfo- context information around multi-tenant state- Returns:
- a created subscription with its items
-
updateSubscriptionStatus
public SWI updateSubscriptionStatus(@NonNull @NonNull UpdateSubscriptionStatusRequest request, boolean isSandboxAware, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceHandles updating theSubscription'sstatus.- Specified by:
updateSubscriptionStatusin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
request- The request to modify a subscription's status.isSandboxAware- Whether sandboxing should be enabled for the scope of the operationcontextInfo- context information around multi-tenant state- Returns:
- The updated
SubscriptionWithItems
-
replaceSubscriptionWithItems
public SWI replaceSubscriptionWithItems(@NonNull SWI subscriptionWithItems, boolean isSandboxAware, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceHandles updating theSubscription'sstatus.- Specified by:
replaceSubscriptionWithItemsin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionWithItems- theSubscriptionWithItemsto replaceisSandboxAware- Whether sandboxing should be enabled for the scope of the operationcontextInfo- context information around multi-tenant state- Returns:
- The updated
SubscriptionWithItems
-
modifySubscription
public ModifySubscriptionResponse modifySubscription(@NonNull @NonNull ModifySubscriptionRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceHandles modifyingSubscriptionsbased on the allowedactions. By default, this should defer the actual business logic to the appropriateModifySubscriptionHandler.- Specified by:
modifySubscriptionin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
request- The request to modify a subscription.contextInfo- context information around multi-tenant state- Returns:
- Details about the result of the action.
-
lockSubscription
Description copied from interface:SubscriptionOperationServiceAttempt to create a lock on a subscription. While a subscription is locked, no other changes can be made to the subscription.- Specified by:
lockSubscriptionin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionId- The subscription to lockreservations- The list of reservation identifiers (i.e. child locks) to make on the subscription- Returns:
- The status of the lock request
-
clearLock
Description copied from interface:SubscriptionOperationServiceForcefully clear a lock on a subscription. This will release all child locks as well.- Specified by:
clearLockin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionId- The subscription to unlockisRevert- Whether the unlock operation is the result of a revert operation. Optional. Default is true.- Returns:
- The status of the lock request
-
unlockToken
Description copied from interface:SubscriptionOperationServiceUnlock a child lock on a subscription. If the child lock is the last lock on the subscription, the subscription will be unlocked as well.- Specified by:
unlockTokenin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionId- The subscription to unlocktoken- The token of the child lock to unlockpropagate- Whether to propagate the token unlock to the parent lock (if applicable).- Returns:
- The status of the lock request
-
createToken
Description copied from interface:SubscriptionOperationServiceCreate a child lock on a subscription.- Specified by:
createTokenin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
subscriptionId- The subscription identifiertokenIdentifier- The identifier for the child lock. Optional. Will generate an identifier if null.- Returns:
- The status of the lock request
-
addAdjustment
public void addAdjustment(@NonNull @NonNull AddAdjustmentRequest addAdjustmentRequest, String subscriptionId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:SubscriptionOperationServiceAdds the requestedadjustmentsonto theSubscriptionthat matches the passed ID.- Specified by:
addAdjustmentin interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>- Parameters:
addAdjustmentRequest- the request to add adjustments onto a subscriptionsubscriptionId- theSubscriptionto add the adjustment tocontextInfo- context information around multi-tenant state
-
updatePriceData
public void updatePriceData(String priceDataId, PriceChangeRequest priceChangeRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) - Specified by:
updatePriceDatain interfaceSubscriptionOperationService<SWI extends SubscriptionWithItems>
-
getAllCustomerSubscriptionActionTypes
Gets all the possible action types that can be performed by the customer (not CSR or system). -
buildAddAdjustmentWorkflowContext
protected Map<String,String> buildAddAdjustmentWorkflowContext(@NonNull @NonNull String subscriptionId, @NonNull @NonNull LockStatus lockStatus, @NonNull @NonNull AddAdjustmentRequest addAdjustmentRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the context for theDefaultWorkflowNameConstants.SUBSCRIPTION_CSR_ADD_ADJUSTMENT_WORKFLOWworkflow.- Parameters:
subscriptionId- The ID of the subscription to add the adjustment tolockStatus- TheLockStatusfor the subscriptionaddAdjustmentRequest- The request containing the adjustment to addcontextInfo- Additional multitenant and sandbox info- Returns:
- The context for the workflow
-
getLockToken
-
buildUpdatePriceDataWorkflowContext
protected Map<String,String> buildUpdatePriceDataWorkflowContext(@NonNull @NonNull String priceDataId, @NonNull @NonNull PriceChangeRequest priceChangeRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds the context for theDefaultWorkflowNameConstants.SUBSCRIPTION_BULK_PRICING_UPDATE_WORKFLOWworkflow.- Parameters:
priceDataId- The ID of the price data to updatepriceChangeRequest- The request containing the new price datacontextInfo- Additional multitenant and sandbox info- Returns:
- The context for the workflow
-
getSubscriptionStatusHandler
protected Optional<SubscriptionStatusHandler<SWI>> getSubscriptionStatusHandler(@NonNull @NonNull UpdateSubscriptionStatusRequest request, @NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
handleStatusUpdateRequest
protected Subscription handleStatusUpdateRequest(@NonNull @NonNull UpdateSubscriptionStatusRequest request, @NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
populateSubscriptionActions
-
populateSubscriptionActionAvailability
-
populateEditAction
protected void populateEditAction(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.EDIT. By default, it's always an available action.- Parameters:
swi- TheDefaultSubscriptionOperationServiceto populate the action details forcontextInfo- additional sandbox and multitenant info
-
populateUpgradeAction
protected void populateUpgradeAction(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.UPGRADE.- Parameters:
swi- TheDefaultSubscriptionOperationServiceto populate the action details forcontextInfo- additional sandbox and multitenant info
-
populateDowngradeAction
protected void populateDowngradeAction(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.DOWNGRADE.- Parameters:
swi- TheDefaultSubscriptionOperationServiceto populate the action details forcontextInfo- additional sandbox and multitenant info
-
populateCancelAction
protected void populateCancelAction(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.CANCEL.- Parameters:
swi-SubscriptionWithItemsto be potentially acted against.contextInfo- Additional sandbox and multitenant info
-
populateChangeAutoRenewalAction
protected void populateChangeAutoRenewalAction(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the action details for theDefaultSubscriptionActionType.CHANGE_AUTO_RENEWAL. By default, it's always an available action.- Parameters:
swi- TheDefaultSubscriptionOperationServiceto populate the action details forcontextInfo- additional sandbox and multitenant info
-
getMessage
-
getAddablePostPurchaseOptions
protected Set<String> getAddablePostPurchaseOptions(@NonNull @NonNull Product product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets a set of choice keys for theItemChoices that are allowed to be added post-purchase.- Parameters:
product- the product to evaluatecontextInfo- additional sandbox and multitenant info- Returns:
- a set of choice keys for the
ItemChoices that are allowed to be added
-
getCurrentAddons
protected Set<SubscriptionItem> getCurrentAddons(@NonNull SWI swi, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the current addons for the givenDefaultSubscriptionOperationService.- Parameters:
swi- theDefaultSubscriptionOperationServiceto evaluatecontextInfo- additional sandbox and multitenant info- Returns:
- the current addons for the given
DefaultSubscriptionOperationService
-
hasNewAddonsToAdd
protected boolean hasNewAddonsToAdd(@NonNull @NonNull Set<SubscriptionItem> currentAddons, @NonNull @NonNull Set<String> addablePostPurchase, @NonNull @NonNull Map<String, ItemChoice> itemChoiceByChoiceKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether new addons can be added post-purchase given the current addons,- Parameters:
currentAddons- the current addonsaddablePostPurchase- the choice keys of addons that can be added post-purchaseitemChoiceByChoiceKey- map of choice keys to item choices for all options on the productcontextInfo- additional sandbox and multitenant info- Returns:
- whether new addons can be added post-purchase
-
isAnyCurrentAddonsEditable
protected boolean isAnyCurrentAddonsEditable(@NonNull @NonNull Set<SubscriptionItem> currentAddons, @NonNull @NonNull Map<String, ItemChoice> itemChoiceByChoiceKey, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines whether any of the current addons are editable post-purchase.- Parameters:
currentAddons- the current addonsitemChoiceByChoiceKey- map of choice keys to item choices for all options on the productcontextInfo- additional sandbox and multitenant info- Returns:
- whether any of the current addons are editable post-purchase
-
buildItemChoiceByChoiceKey
protected Map<String,ItemChoice> buildItemChoiceByChoiceKey(@NonNull @NonNull Product product, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds a map of choice keys to item choices for all options on the product, including child options.- Parameters:
product- the product to evaluatecontextInfo- additional sandbox and multitenant info- Returns:
- a map of choice keys to item choices for all options on the product
-
getChildOptions
protected List<ProductOption> getChildOptions(@NonNull @NonNull ItemChoice itemChoice, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Gets the child options for the givenItemChoice.- Parameters:
itemChoice- the item choice to evaluatecontextInfo- additional sandbox and multitenant info- Returns:
- the child options for the given
ItemChoice
-
isCurrentDateBeyondDowngradeAvailabilityDuration
protected boolean isCurrentDateBeyondDowngradeAvailabilityDuration(@NonNull SWI subscriptionWithItems) Determines whether the current time is beyond the period start date + restrictDowngradeAfterDays.- Parameters:
subscriptionWithItems- theSubscriptionWithItemsobject- Returns:
- whether the current time is beyond the period start date + restrictDowngradeAfterDays.
-
buildAvailableAction
protected SubscriptionAction buildAvailableAction(@NonNull SWI subscription, @NonNull @NonNull String actionType, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Creates aSubscriptionActionfor theactionTypeandSubscriptionWithItemsrepresenting an action that may be taken against thesubscription.- Parameters:
subscription- TheSubscriptionWithItemsbeing retrieved that may be acted against.actionType- The type of action that is allowed for thesubscription. SeeDefaultSubscriptionActionType.contextInfo- Additional sandbox and multitenant info- Returns:
- A
SubscriptionActionfor theactionTypeandSubscriptionWithItemsrepresenting an action that may be taken against thesubscription.
-
getRootItemReferencedBySubscription
protected SubscriptionReferencedItem getRootItemReferencedBySubscription(@NonNull SWI subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Retrieves theSubscriptionReferencedItemreferenced as theSubscription.getRootItemRef().- Parameters:
subscription- ASubscriptionWithItemswhose root item to fetch.contextInfo- Additional sandbox and multitenant info- Returns:
- The
SubscriptionReferencedItemreferenced as theSubscription.getRootItemRef(). - See Also:
-
getCustomRootItemReferencedBySubscription
protected SubscriptionReferencedItem getCustomRootItemReferencedBySubscription(@NonNull SWI subscription, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Handles getting theSubscriptionReferencedItemfor a customSubscription.getRootItemRefType().- Parameters:
subscription- ASubscriptionWithItemswhose root item to fetch.contextInfo- Additional sandbox and multitenant info- Returns:
- The
SubscriptionReferencedItemreferenced as theSubscription.getRootItemRef(). - See Also:
-
populateUpgradeActionInfo
protected void populateUpgradeActionInfo(@NonNull @NonNull SubscriptionReferencedItem rootItem, @NonNull @NonNull SubscriptionAction action, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anUPGRADEaction for the givenSubscriptionWithItems.- Parameters:
rootItem- TheSubscriptionReferencedItemthat stores what its upgrade options are.action- TheSubscriptionActionrepresenting the upgrade action.contextInfo- Additional sandbox and multitenant info
-
populateDowngradeActionInfo
protected void populateDowngradeActionInfo(@NonNull @NonNull SubscriptionReferencedItem rootItem, @NonNull @NonNull SubscriptionAction action, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anDOWNGRADEaction for the givenSubscriptionWithItems.- Parameters:
rootItem- TheSubscriptionReferencedItemthat stores what its upgrade options are.action- TheSubscriptionActionrepresenting the downgrade action.contextInfo- Additional sandbox and multitenant info
-
populateCancelActionInfo
protected void populateCancelActionInfo(@NonNull @NonNull SubscriptionWithItems subscription, @NonNull @NonNull SubscriptionAction action, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates theSubscriptionAction.getActionInfo()for the anDefaultSubscriptionActionType.CANCELaction for the givenSubscriptionWithItems.- Parameters:
subscription- TheSubscriptionWithItemsthat stores the subscription with its items.action- TheSubscriptionActionrepresenting the cancel action.contextInfo- Additional sandbox and multitenant info
-
populateCancellationFeeProducts
protected void populateCancellationFeeProducts(@NonNull @NonNull SubscriptionWithItems subscriptionWithItems, @NonNull @NonNull CancellationPolicyDetail cancellationPolicyDetail, @NonNull @NonNull SubscriptionAction action, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Populates the extra (cancellation) fee products including the grace fee cancellation product if applicable on the givenactionfrom the givenCancellationPolicyDetailby fetching them from the Catalog Service.- Parameters:
subscriptionWithItems- TheSubscriptionWithItemsthat stores the subscription with its items.cancellationPolicyDetail- TheCancellationPolicyDetailcontaining more details about the current subscription'sCancellationPolicyaction- TheSubscriptionActionrepresenting the cancel action.contextInfo- Additional sandbox and multitenant info
-
getCancellationFeeProductIdToFetch
protected Optional<String> getCancellationFeeProductIdToFetch(@NonNull @NonNull CancellationPolicyDetail cancellationPolicyDetail, @NonNull @NonNull SubscriptionWithItems subscriptionWithItems) Fetches the Id of the extra (cancellation) fee product. It could be the grace fee cancellation product (if applicable) or the cancellation fee product from the givenCancellationPolicyDetail.- Parameters:
cancellationPolicyDetail- TheCancellationPolicyDetailcontaining more details about the current subscription'sCancellationPolicysubscriptionWithItems- TheSubscriptionWithItemsthat stores the subscription with its items.- Returns:
- Product Id of the cancellation fee product
-
buildSubscriptionWithItems
protected SWI buildSubscriptionWithItems(@NonNull @NonNull SubscriptionCreationRequest creationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildSubscription
protected Subscription buildSubscription(@NonNull @NonNull SubscriptionCreationRequest request, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildSubscriptionItems
protected List<SubscriptionItem> buildSubscriptionItems(@NonNull @NonNull SubscriptionCreationRequest creationRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getSubscriptionProvider
-
getSubscriptionValidationService
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getModifySubscriptionHandlers
-
getCatalogProvider
-
getCancellationPolicyProvider
-
getSubscriptionGenerationService
-
getSubscriptionOperationUtils
-
getWorkflowProvider
protected com.broadleafcommerce.orchestration.service.provider.external.WorkflowProvider getWorkflowProvider() -
getSubOpsServiceProperties
-
getMessageSource
protected org.springframework.context.MessageSource getMessageSource() -
getSubscriptionStatusHandlers
-
setSubscriptionStatusHandlers
@Autowired(required=false) public void setSubscriptionStatusHandlers(List<SubscriptionStatusHandler<SWI>> subscriptionStatusHandlers)
-