Class DefaultCartApprovalService

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected cz.jirutka.rsql.parser.ast.Node buildAccountCartFilters​(String requestedAccountId, @NonNull String status, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters)
      Builds Node filters based on the requested account id, status, and the account details of the currently authenticated CustomerRef used to retrieve carts.
      protected org.springframework.data.domain.Pageable buildAccountCartPageable​(org.springframework.data.domain.Pageable pageable)
      Builds a new Pageable with default sort of Cart.getApprovalRequestedDate() applied.
      protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAudit​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull com.broadleafcommerce.cart.client.domain.enums.DefaultCartActionTypes actionType, @NonNull String oldCartStatus, @NonNull CartActionAuditUserType userType, String comment, Map<String,​Object> data)
      Builds a CartActionAudit based on the given fields.
      protected CartApprovalProcessResponse buildCartApprovalProcessResponse​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart)
      Given the cart and CartApprovalValidationException failures, creates and returns a response.
      protected UpdateCartRequest buildUpdateCartRequest​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit)
      Builds an UpdateCartRequest based on the given cart and cart action audit.
      protected CartApprovalValidationService getCartApprovalValidationService()  
      protected CartProvider getCartProvider()  
      protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate()  
      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()  
      CartApprovalProcessResponse rejectCart​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Action performed by an account approver to reject a Cart.
      org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartsRequiringApproval​(String requestedAccountId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Retrieve a page of Carts that require approval in the current authenticated user's account context and requested account id if applicable.
      protected void sendCartRejectionMessage​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sends a CartRejectionEvent to notify the cart owner.
      CartApprovalProcessResponse submitForApproval​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Action performed by an account member to submit for approval of a Cart.
      protected com.broadleafcommerce.cart.client.domain.Cart updateCartForRejection​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest)
      Updates the name and status of Cart to reflect that it has been rejected.
      protected com.broadleafcommerce.cart.client.domain.Cart updateCartForSubmitForApproval​(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull CartApprovalProcessRequest cartApprovalProcessRequest)
      Updates the name and status of Cart to reflect that it has been submitted for approval.
    • Constructor Detail

      • DefaultCartApprovalService

        public DefaultCartApprovalService​(CartApprovalValidationService cartApprovalValidationService,
                                          CartProvider cartProvider,
                                          com.broadleafcommerce.common.extension.TypeFactory typeFactory,
                                          org.springframework.retry.support.RetryTemplate messageRetryTemplate)
    • Method Detail

      • retrieveCartsRequiringApproval

        public org.springframework.data.domain.Page<com.broadleafcommerce.cart.client.domain.Cart> retrieveCartsRequiringApproval​(@Nullable
                                                                                                                                  String requestedAccountId,
                                                                                                                                  @NonNull
                                                                                                                                  @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                                                                                                                  @NonNull
                                                                                                                                  @NonNull cz.jirutka.rsql.parser.ast.Node filters,
                                                                                                                                  @Nullable
                                                                                                                                  org.springframework.data.domain.Pageable pageable,
                                                                                                                                  @Nullable
                                                                                                                                  com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CartApprovalService
        Retrieve a page of Carts that require approval in the current authenticated user's account context and requested account id if applicable.
        Specified by:
        retrieveCartsRequiringApproval in interface CartApprovalService
        Parameters:
        requestedAccountId - optional parameter to retrieve carts from a specific account, if not specified, carts in the current account and its sub-accounts context will be retrieved
        customerRef - the currently authenticated CustomerRef containing user's account details
        filters - exising filters to build on top of
        pageable - the requested page of results
        contextInfo - context information related to multitenancy
        Returns:
        a page of Carts that require approval in the current authenticated user's account context and requested account id if applicable.
      • submitForApproval

        public CartApprovalProcessResponse submitForApproval​(@NonNull
                                                             @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                             @NonNull
                                                             @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                             @NonNull
                                                             @NonNull CartApprovalProcessRequest cartApprovalProcessRequest,
                                                             @Nullable
                                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CartApprovalService
        Action performed by an account member to submit for approval of a Cart. Produces a CartActionAudit.
        Specified by:
        submitForApproval in interface CartApprovalService
        Parameters:
        cart - The cart that was submitted for approval
        customer - The customer who submitted the cart for approval
        cartApprovalProcessRequest - the request with which CartApprovalEndpoint is hit
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        a CartApprovalProcessResponse that contains the updated cart, any validation errors encountered, status of the request, and additionalAttributes
      • rejectCart

        public CartApprovalProcessResponse rejectCart​(@NonNull
                                                      @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                      @NonNull
                                                      @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                      @NonNull
                                                      @NonNull CartApprovalProcessRequest cartApprovalProcessRequest,
                                                      @Nullable
                                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Description copied from interface: CartApprovalService
        Action performed by an account approver to reject a Cart. Produces a CartActionAudit . Produces a CartRejectionEvent
        Specified by:
        rejectCart in interface CartApprovalService
        Parameters:
        cart - The cart that was rejected
        customer - The customer who rejected the cart
        cartApprovalProcessRequest - the request with which CartApprovalEndpoint is hit
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        The rejected cart
      • updateCartForSubmitForApproval

        protected com.broadleafcommerce.cart.client.domain.Cart updateCartForSubmitForApproval​(@NonNull
                                                                                               @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                               @NonNull
                                                                                               @NonNull CartApprovalProcessRequest cartApprovalProcessRequest)
        Updates the name and status of Cart to reflect that it has been submitted for approval.
      • buildCartActionAudit

        protected com.broadleafcommerce.cart.client.domain.CartActionAudit buildCartActionAudit​(@NonNull
                                                                                                @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                                @NonNull
                                                                                                @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customer,
                                                                                                @NonNull
                                                                                                @NonNull com.broadleafcommerce.cart.client.domain.enums.DefaultCartActionTypes actionType,
                                                                                                @NonNull
                                                                                                @NonNull String oldCartStatus,
                                                                                                @NonNull
                                                                                                @NonNull CartActionAuditUserType userType,
                                                                                                @Nullable
                                                                                                String comment,
                                                                                                @Nullable
                                                                                                Map<String,​Object> data)
        Builds a CartActionAudit based on the given fields.
      • buildUpdateCartRequest

        protected UpdateCartRequest buildUpdateCartRequest​(@NonNull
                                                           @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                           @NonNull
                                                           @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit cartActionAudit)
        Builds an UpdateCartRequest based on the given cart and cart action audit.
        Parameters:
        cart - the Cart to update
        cartActionAudit - the original CartActionAudit to create
        Returns:
        an UpdateCartRequest based on the given cart and cart action audit
      • updateCartForRejection

        protected com.broadleafcommerce.cart.client.domain.Cart updateCartForRejection​(@NonNull
                                                                                       @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                                                       @NonNull
                                                                                       @NonNull CartApprovalProcessRequest cartApprovalProcessRequest)
        Updates the name and status of Cart to reflect that it has been rejected.
      • sendCartRejectionMessage

        protected void sendCartRejectionMessage​(@NonNull
                                                @NonNull com.broadleafcommerce.cart.client.domain.Cart cart,
                                                @NonNull
                                                @NonNull com.broadleafcommerce.cart.client.domain.CartActionAudit audit,
                                                @Nullable
                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Sends a CartRejectionEvent to notify the cart owner.
      • buildAccountCartFilters

        protected cz.jirutka.rsql.parser.ast.Node buildAccountCartFilters​(@Nullable
                                                                          String requestedAccountId,
                                                                          @NonNull
                                                                          @NonNull String status,
                                                                          @NonNull
                                                                          @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                                                          @NonNull
                                                                          @NonNull cz.jirutka.rsql.parser.ast.Node existingFilters)
        Builds Node filters based on the requested account id, status, and the account details of the currently authenticated CustomerRef used to retrieve carts.

        By default, if the requested account id is present, the filters will look for only requested account's carts, not those of sub-accounts. Otherwise, filters to retrieve sub-account carts will automatically be applied.

        Note that the usage of root account id is to avoid a table scan when querying against cart's account hierarchy.

        Parameters:
        requestedAccountId - optional parameter to build filters to retrieve carts of a specific account
        status - the status to filter by
        customerRef - the currently authenticated CustomerRef containing user's account details
        existingFilters - exising filters to build on top of
        Returns:
        the Node filters based on the requested account id, status, and the account details of the currently authenticated CustomerRef used to retrieve carts
      • buildAccountCartPageable

        protected org.springframework.data.domain.Pageable buildAccountCartPageable​(@Nullable
                                                                                    org.springframework.data.domain.Pageable pageable)
        Builds a new Pageable with default sort of Cart.getApprovalRequestedDate() applied.
        Parameters:
        pageable - requested Pageable to build on top of
        Returns:
        a new Pageable with default sort of Cart.getApprovalRequestedDate() applied
      • getCartProvider

        protected CartProvider getCartProvider()
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
      • getMessageRetryTemplate

        protected org.springframework.retry.support.RetryTemplate getMessageRetryTemplate()