Interface CartService<P extends com.broadleafcommerce.cart.client.domain.Cart>

  • All Superinterfaces:
    com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
    All Known Implementing Classes:
    DefaultCartService

    public interface CartService<P extends com.broadleafcommerce.cart.client.domain.Cart>
    extends com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
    Service API for Carts. Supported by CartRepository.
    Author:
    Chad Harchar (charchar)
    • Method Summary

      All Methods Instance Methods Abstract Methods Deprecated Methods 
      Modifier and Type Method Description
      int purgeAbandonedAnonymousCarts​(Duration abandonedCartTimeout, Collection<String> statuses, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Delete anonymous carts that have not been updated for the specified amount of time.
      org.springframework.data.domain.Page<P> readAll​(cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Read a page of narrowed Carts based on the given filters
      org.springframework.data.domain.Page<P> readAllByStatusesAndCustomerIdAndAccountId​(Set<String> statuses, String customerId, String accountId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts for the given customer id, account id, and statuses.
      List<P> readAllMatchingTenantByIds​(List<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds a list of the carts with the given ids and matching the tenant from the given ContextInfo.
      Optional<P> readAnonymousCustomerHistoricalOrder​(String emailAddress, String orderNumber, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Reads an anonymous or not authenticated customer's historical cart using the orderNumber and emailAddress.
      org.springframework.data.domain.Page<P> readByAccountHierarchyContaining​(String accountId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts where the account hierarchy contains the given account id.
      org.springframework.data.domain.Page<P> readByAccountHierarchyContainingAndStatusIn​(String accountId, Iterable<String> statuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts where the account hierarchy contains the given account id and has the matching status.
      org.springframework.data.domain.Page<P> readByCustomerId​(String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo, org.springframework.data.domain.Pageable page)
      Find all carts for the given customer id.
      org.springframework.data.domain.Page<P> readByCustomerIdAndAccountId​(String customerId, String accountId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts for the given customer id and account id.
      org.springframework.data.domain.Page<P> readByCustomerIdAndAccountId​(String customerId, String accountId, org.springframework.data.domain.Pageable page, cz.jirutka.rsql.parser.ast.Node filters, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts for the given customer id and account id.
      Optional<P> readByCustomerIdAndOrderNumber​(String customerId, String orderNumber, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Find the cart (if it exists) for the provided customer id and order number.
      Optional<P> readByNameAndCustomerId​(String cartName, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find the cart for the given name and customer id.
      Optional<P> readByNameAndCustomerRefCustomerId​(String cartName, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      org.springframework.data.domain.Page<P> readByRootAccountId​(String rootAccountId, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts for the given root account id.
      org.springframework.data.domain.Page<P> readByRootAccountIdAndStatusIn​(String rootAccountId, Iterable<String> statuses, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find all carts for the given root account id and statuses.
      List<P> readByStatus​(String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Reads all of the carts with the given status.
      Optional<P> readByStatusAndCustomerId​(String status, String customerId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find a cart with the given status (if it exists) for the provided customer id.
      Optional<P> readByStatusAndCustomerIdAndAccountId​(String status, String customerId, String accountId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find a cart with the given status (if it exists) for the provided customer id and account id.
      Optional<P> readByStatusAndCustomerIdAndAccountIdAndName​(String status, String customerId, String accountId, String name, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Find a cart with the given status (if it exists) for the provided customer id and account id.
      org.springframework.data.domain.Page<P> readHistoricalCartsByCustomer​(String customerId, Date startDate, Date endDate, com.broadleafcommerce.data.tracking.core.context.ContextInfo context, org.springframework.data.domain.Pageable page)
      Find all carts that are DefaultCartStatuses.SUBMITTED or DefaultCartStatuses.CANCELLED for the provided customer and dates.
      org.springframework.data.domain.Page<P> readPageMatchingTenantByStatus​(String status, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Finds a page of the carts with the given status and matching the tenant from the given ContextInfo.
      P replaceCartItem​(P cart, String cartItemId, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Replaces the cart item in the cart and saves.
      P replaceWithCartAudit​(String id, UpdateCartRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Replaces the cart state and its related CartActionAudit.
      P updateCartItem​(P cart, String cartItemId, com.broadleafcommerce.cart.client.domain.CartItem cartItem, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
      Patches (updates only present fields) of the cart item in the cart and saves.
      List<P> updateCartsMatchingTenantStatus​(List<String> cartIds, String status, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Updates the Cart.getStatus() for the given cart ids and status and matching the tenant from the given ContextInfo.
      P updateWithCartAudit​(String id, @NonNull UpdateCartRequest request, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Updates the cart state and its related CartActionAudit.
      • Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService

        create, createAll, createAllAllowingPartialSuccess, delete, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSort
    • Method Detail

      • readAll

        org.springframework.data.domain.Page<P> readAll​(cz.jirutka.rsql.parser.ast.Node filters,
                                                        @Nullable
                                                        org.springframework.data.domain.Pageable pageable,
                                                        @Nullable
                                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Read a page of narrowed Carts based on the given filters
        Parameters:
        filters - the RSQL Node used to restrict result, must not be null
        pageable - the current page
        contextInfo - Request context information around sandbox and multitenant state
        Returns:
        a page of narrowed Carts based on the given filters
      • readByCustomerId

        org.springframework.data.domain.Page<P> readByCustomerId​(String customerId,
                                                                 @Nullable
                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo,
                                                                 @Nullable
                                                                 org.springframework.data.domain.Pageable page)
        Find all carts for the given customer id.
        Parameters:
        customerId - the id of the customer who owns the cart
        contextInfo - Context information used to discriminate the carts by applicationId
        page - the requested page of results from the database
        Returns:
        all carts for the given customer id
      • readByCustomerIdAndAccountId

        org.springframework.data.domain.Page<P> readByCustomerIdAndAccountId​(String customerId,
                                                                             @Nullable
                                                                             String accountId,
                                                                             @Nullable
                                                                             org.springframework.data.domain.Pageable page,
                                                                             @Nullable
                                                                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given customer id and account id. Account id can be null to find customer's personal non-account carts.
        Parameters:
        customerId - the id of the customer who owns the cart
        accountId - the id of the account that the cart belongs to,
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given customer id and account id
      • readByCustomerIdAndAccountId

        org.springframework.data.domain.Page<P> readByCustomerIdAndAccountId​(String customerId,
                                                                             @Nullable
                                                                             String accountId,
                                                                             @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 carts for the given customer id and account id. Account id can be null to find customer's personal non-account carts.
        Parameters:
        customerId - the id of the customer who owns the cart
        accountId - the id of the account that the cart belongs to,
        page - the requested page of results from the database
        filters - RSQL filters
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given customer id and account id
      • readAllByStatusesAndCustomerIdAndAccountId

        org.springframework.data.domain.Page<P> readAllByStatusesAndCustomerIdAndAccountId​(Set<String> statuses,
                                                                                           String customerId,
                                                                                           @Nullable
                                                                                           String accountId,
                                                                                           @Nullable
                                                                                           org.springframework.data.domain.Pageable page,
                                                                                           @Nullable
                                                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given customer id, account id, and statuses. Account id can be null to find customer's personal non-account carts.
        Parameters:
        statuses - the statuses to match
        customerId - the id of the customer who owns the cart
        accountId - the id of the account that the cart belongs to
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given customer id and account id and statuses
      • readByRootAccountId

        org.springframework.data.domain.Page<P> readByRootAccountId​(String rootAccountId,
                                                                    @Nullable
                                                                    org.springframework.data.domain.Pageable page,
                                                                    @Nullable
                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given root account id.

        This is useful to query all the carts that belongs to the same root account.

        For example, if we have this account setup, rootAcct -> subAcct (child of rootAcct) -> subSubAcct (child of subAcct), this query is useful to query all the carts that belong to the root account and its sub-accounts.

        Parameters:
        rootAccountId - the root account id of the cart
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given root account id
      • readByRootAccountIdAndStatusIn

        org.springframework.data.domain.Page<P> readByRootAccountIdAndStatusIn​(String rootAccountId,
                                                                               Iterable<String> statuses,
                                                                               @Nullable
                                                                               org.springframework.data.domain.Pageable page,
                                                                               @Nullable
                                                                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given root account id and statuses.
        Parameters:
        rootAccountId - the root account id of the cart
        statuses - the statuses to match
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given root account id
      • readByAccountHierarchyContaining

        org.springframework.data.domain.Page<P> readByAccountHierarchyContaining​(String accountId,
                                                                                 @Nullable
                                                                                 org.springframework.data.domain.Pageable page,
                                                                                 @Nullable
                                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts where the account hierarchy contains the given account id.

        This is useful to query all the carts that belongs to the same non-root account and its sub-accounts.

        For example, if we have this account setup, rootAcct -> subAcct (child of rootAcct) -> subSubAcct (child of subAcct), this query is useful to query all the carts that belong to the subAcct and its sub-accounts (subSubAcct in this case).

        Parameters:
        accountId - the account id to filter the account hierarchy by
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts where the account hierarchy contains the given account id
      • readByAccountHierarchyContainingAndStatusIn

        org.springframework.data.domain.Page<P> readByAccountHierarchyContainingAndStatusIn​(String accountId,
                                                                                            Iterable<String> statuses,
                                                                                            @Nullable
                                                                                            org.springframework.data.domain.Pageable page,
                                                                                            @Nullable
                                                                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts where the account hierarchy contains the given account id and has the matching status.

        This is useful to query all the carts that belongs to the same non-root account and its sub-accounts based on the status

        For example, if we have this account setup, rootAcct -> subAcct (child of rootAcct) -> subSubAcct (child of subAcct), this query is useful to query all the carts that belong to the subAcct and its sub-accounts (subSubAcct in this case) and has the DefaultCartStatuses.REQUIRES_APPROVAL.

        Parameters:
        accountId - the account id to filter the account hierarchy by
        statuses - the statuses to match
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts where the account hierarchy contains the given account id
      • readByNameAndCustomerId

        Optional<P> readByNameAndCustomerId​(String cartName,
                                            String customerId,
                                            @Nullable
                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find the cart for the given name and customer id. There should only be one result, as cart names are unique per customer.
        Parameters:
        cartName - the name of the cart to retrieve
        customerId - the id of the customer who owns the cart
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        an optional cart with the name and customer provided
      • readByNameAndCustomerRefCustomerId

        @Deprecated
        Optional<P> readByNameAndCustomerRefCustomerId​(String cartName,
                                                       String customerId,
                                                       @Nullable
                                                       com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find the cart for the given name and customer id. There should only be one result, as cart names are unique per customer.
        Parameters:
        cartName - the name of the cart to retrieve
        customerId - the id of the customer who owns the cart
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        an optional cart with the name and customer provided
      • readByStatusAndCustomerId

        Optional<P> readByStatusAndCustomerId​(String status,
                                              String customerId,
                                              @Nullable
                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find a cart with the given status (if it exists) for the provided customer id.
        Parameters:
        status - the status of carts to consider
        customerId - the id of the customer who owns the cart
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        a cart with the given status (if it exists) for the provided customer id.
      • readByStatusAndCustomerIdAndAccountId

        Optional<P> readByStatusAndCustomerIdAndAccountId​(String status,
                                                          String customerId,
                                                          @Nullable
                                                          String accountId,
                                                          @Nullable
                                                          com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find a cart with the given status (if it exists) for the provided customer id and account id. Account id can be null to find customer's personal non-account carts.
        Parameters:
        status - the status of carts to consider
        customerId - the id of the customer who owns the cart
        accountId - the id of the account that the cart belongs to
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        a cart with the given status (if it exists) for the provided customer id and account id.
      • readByStatusAndCustomerIdAndAccountIdAndName

        Optional<P> readByStatusAndCustomerIdAndAccountIdAndName​(String status,
                                                                 String customerId,
                                                                 @Nullable
                                                                 String accountId,
                                                                 @Nullable
                                                                 String name,
                                                                 @Nullable
                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find a cart with the given status (if it exists) for the provided customer id and account id. Account id can be null to find customer's personal non-account carts.
        Parameters:
        status - the status of carts to consider
        customerId - the id of the customer who owns the cart
        accountId - the id of the account that the cart belongs to
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        a cart with the given status (if it exists) for the provided customer id and account id.
      • readHistoricalCartsByCustomer

        org.springframework.data.domain.Page<P> readHistoricalCartsByCustomer​(String customerId,
                                                                              @Nullable
                                                                              Date startDate,
                                                                              @Nullable
                                                                              Date endDate,
                                                                              @Nullable
                                                                              com.broadleafcommerce.data.tracking.core.context.ContextInfo context,
                                                                              @Nullable
                                                                              org.springframework.data.domain.Pageable page)
        Find all carts that are DefaultCartStatuses.SUBMITTED or DefaultCartStatuses.CANCELLED for the provided customer and dates.
        Parameters:
        customerId - the id of the customer who owns the carts
        startDate - the starting date to filter carts by
        endDate - the ending date to filter carts by
        context - Context information used to discriminate the carts by applicationId
        page - the requested page of results from the database
        Returns:
        all carts that are DefaultCartStatuses.SUBMITTED or DefaultCartStatuses.CANCELLED for the provided customer and dates.
      • readByCustomerIdAndOrderNumber

        Optional<P> readByCustomerIdAndOrderNumber​(String customerId,
                                                   String orderNumber,
                                                   @Nullable
                                                   com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Find the cart (if it exists) for the provided customer id and order number.
        Parameters:
        customerId - the id of the customer who owns the cart
        orderNumber - the order number for the cart
        context - Context information used to discriminate the carts by applicationId
        Returns:
        a cart (if it exists) with the given order number that belongs to the provided customer.
      • updateCartsMatchingTenantStatus

        List<P> updateCartsMatchingTenantStatus​(List<String> cartIds,
                                                String status,
                                                @Nullable
                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Updates the Cart.getStatus() for the given cart ids and status and matching the tenant from the given ContextInfo.
        Parameters:
        cartIds - the ids of the carts to update the status for
        status - the status to update the carts to
        contextInfo - Context information used to discriminate the carts by applicationId
        Returns:
        the updated carts
      • updateWithCartAudit

        P updateWithCartAudit​(String id,
                              @NonNull
                              @NonNull UpdateCartRequest request,
                              @Nullable
                              com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Updates the cart state and its related CartActionAudit. Will also send relevant notifications based on changes to the cart's status.
        Parameters:
        id - Id of the cart to update
        request - The request with the new cart state and audit
        contextInfo - Additional sandbox and multitenant info
        Returns:
        The updated cart state.
      • replaceWithCartAudit

        P replaceWithCartAudit​(String id,
                               UpdateCartRequest request,
                               @Nullable
                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Replaces the cart state and its related CartActionAudit. Will also send relevant notifications based on changes to the cart's status.
        Parameters:
        id - Id of the cart to replace
        request - The request with the new cart state and audit
        contextInfo - Additional sandbox and multitenant info
        Returns:
        The updated cart state.
      • replaceCartItem

        P replaceCartItem​(P cart,
                          String cartItemId,
                          com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                          com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Replaces the cart item in the cart and saves.
        Parameters:
        cart - the cart to replace an item of
        cartItemId - the ID of the cart item to replace
        cartItem - the cart item to replace with (ID will be overwritten with cartItemId)
        context - Context information used to discriminate the carts by applicationId
        Returns:
        the updated cart
      • updateCartItem

        P updateCartItem​(P cart,
                         String cartItemId,
                         com.broadleafcommerce.cart.client.domain.CartItem cartItem,
                         com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Patches (updates only present fields) of the cart item in the cart and saves.
        Parameters:
        cart - the cart to replace an item of
        cartItemId - the ID of the cart item to replace
        cartItem - the cart item to replace with (ID will be overwritten with cartItemId)
        context - Context information used to discriminate the carts by applicationId
        Returns:
        the updated cart
      • readAnonymousCustomerHistoricalOrder

        Optional<P> readAnonymousCustomerHistoricalOrder​(String emailAddress,
                                                         String orderNumber,
                                                         @Nullable
                                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Reads an anonymous or not authenticated customer's historical cart using the orderNumber and emailAddress.
        Parameters:
        emailAddress - The email address associated with the cart
        orderNumber - The historical cart's order number
        context - Context information around sandbox and multitenant state.
        Returns:
        The historical cart for an anonymous customer
      • purgeAbandonedAnonymousCarts

        int purgeAbandonedAnonymousCarts​(Duration abandonedCartTimeout,
                                         Collection<String> statuses,
                                         @Nullable
                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Delete anonymous carts that have not been updated for the specified amount of time.
        Parameters:
        abandonedCartTimeout - The length of time a cart can be inactive before being purged.
        statuses - The statuses to consider for purging.
        contextInfo - context information related to multitenancy
        Returns:
        The number of carts purged.
      • readByStatus

        List<P> readByStatus​(String status,
                             @Nullable
                             com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Reads all of the carts with the given status.
        Parameters:
        status - The CartStatus to filter by
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        All of the carts with the given status.
      • readPageMatchingTenantByStatus

        org.springframework.data.domain.Page<P> readPageMatchingTenantByStatus​(String status,
                                                                               @Nullable
                                                                               org.springframework.data.domain.Pageable pageable,
                                                                               @Nullable
                                                                               com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Finds a page of the carts with the given status and matching the tenant from the given ContextInfo.
        Parameters:
        status - the status of the cart
        pageable - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        A page of the carts with the given status and matching the tenant from the given ContextInfo.
      • readAllMatchingTenantByIds

        List<P> readAllMatchingTenantByIds​(List<String> ids,
                                           @Nullable
                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Finds a list of the carts with the given ids and matching the tenant from the given ContextInfo.
        Parameters:
        ids - the ids of the cart
        contextInfo - context information related to multitenancy
        Returns:
        Finds a list of the carts with the given ids and matching the tenant from the given ContextInfo.