Class QuoteDraftingStatusHandler

All Implemented Interfaces:
CartStatusHandler

public class QuoteDraftingStatusHandler extends AbstractQuoteCartStatusHandler
Handles a Cart in or changing to the DefaultQuoteStatuses.DRAFTING status.
  • Field Details

    • SECURE_RANDOM

      protected static final SecureRandom SECURE_RANDOM
  • Constructor Details

    • QuoteDraftingStatusHandler

      public QuoteDraftingStatusHandler(com.broadleafcommerce.resource.security.utils.service.AuthenticationUtils authenticationUtils, com.broadleafcommerce.common.extension.TypeFactory typeFactory, QuoteAuthUtils quoteAuthUtils, com.broadleafcommerce.cart.client.properties.QuoteProperties properties, CartProvider cartProvider, CartOperationService cartOperationService, CartActionAuditOperationService<com.broadleafcommerce.cart.client.domain.CartActionAudit> cartActionAuditOperationService)
  • Method Details

    • getStatusToHandle

      protected String getStatusToHandle()
      Description copied from class: AbstractCartStatusChangeHandler
      Gets the status to handle by this handler
      Specified by:
      getStatusToHandle in class AbstractCartStatusChangeHandler
      Returns:
      the status to handle by this handler
    • getValidOriginatingStatuses

      protected Set<String> getValidOriginatingStatuses(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Only an DefaultCartStatuses.IN_PROCESS DefaultCartTypes.STANDARD cart can be converted into a DefaultCartTypes.QUOTE cart with DefaultQuoteStatuses.DRAFTING status.

      Moving an DefaultQuoteStatuses.EXPIRED quote to this status would effectively clone the quote and shift the cloned quote into DefaultQuoteStatuses.DRAFTING status while leaving the original DefaultQuoteStatuses.EXPIRED quote untouched.

      Specified by:
      getValidOriginatingStatuses in class AbstractCartStatusChangeHandler
      Parameters:
      contextInfo - the contextInfo for the request
      Returns:
      a set of valid originating statuses that can transition to the AbstractCartStatusChangeHandler.getStatusToHandle()
    • getCartActionType

      protected String getCartActionType(ChangeCartStatusRequest cartStatusRequest)
      Description copied from class: AbstractCartStatusChangeHandler
      Hook point to determine the cart action type.

      Returns DefaultQuoteActionTypes.UNKNOWN by default unless overridden.

      Overrides:
      getCartActionType in class AbstractCartStatusChangeHandler
      Parameters:
      cartStatusRequest - the change cart status request
      Returns:
      DefaultQuoteActionTypes.UNKNOWN by default unless overridden.
    • processStatusChange

      protected ChangeCartStatusRequest processStatusChange(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from class: AbstractCartStatusChangeHandler
      Perform the status change of the Cart.

      By default, this updates the status and creates a corresponding CartActionAudit. This serves as a hook point for additional steps for the status change.

      Overrides:
      processStatusChange in class AbstractCartStatusChangeHandler
      Parameters:
      changeStatusRequest - the ChangeCartStatusRequest to facilitate the cart status change
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the ChangeCartStatusRequest with the updated cart
    • populateQuoteName

      protected void populateQuoteName(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Populates the name of the quote if not already set.

      By default, the quote name would be "MM/dd/yyyy HH:mm - CUSTOMER_NAME" in an account context, and "MM/dd/yyyy HH:mm - {Fist Item's Name}" in a non-account context.

      Parameters:
      changeStatusRequest - the ChangeCartStatusRequest containing the quote
      contextInfo - the contextInfo for the request
    • getFirstItemName

      protected Optional<String> getFirstItemName(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Returns the name of the first cart item.
      Parameters:
      changeStatusRequest - the ChangeCartStatusRequest containing the quote
      contextInfo - the contextInfo for the request
      Returns:
      am optional of first item name if exists, otherwise Optional.empty()
    • getCustomerName

      protected String getCustomerName(@NonNull @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef)
      Returns a customer name or username (if name is not available).
    • cloneQuote

      protected com.broadleafcommerce.cart.client.domain.Cart cloneQuote(@NonNull @NonNull ChangeCartStatusRequest changeStatusRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • cloneCartActionAudits

      protected void cloneCartActionAudits(@NonNull @NonNull ChangeCartStatusRequest changeCartStatusRequest, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart expiredQuote, @NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart clonedQuote, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getCartProvider

      protected CartProvider getCartProvider()
    • getCartOperationService

      protected CartOperationService getCartOperationService()
    • getCartActionAuditOperationService

      protected CartActionAuditOperationService<com.broadleafcommerce.cart.client.domain.CartActionAudit> getCartActionAuditOperationService()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
      Overrides:
      getTypeFactory in class AbstractCartStatusChangeHandler