Interface CartRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>

  • All Superinterfaces:
    CustomizedCartRepository<D>, com.broadleafcommerce.common.extension.DomainTypeAware, com.broadleafcommerce.common.messaging.notification.NotificationStateRepository, org.springframework.data.repository.Repository<D,​String>, com.broadleafcommerce.data.tracking.core.TrackableRepository<D>, com.broadleafcommerce.data.tracking.core.TrackableRsqlFilterExecutor<D>
    All Known Subinterfaces:
    JpaCartRepository<D>

    @NoRepositoryBean
    public interface CartRepository<D extends com.broadleafcommerce.data.tracking.core.Trackable>
    extends com.broadleafcommerce.data.tracking.core.TrackableRepository<D>, CustomizedCartRepository<D>, com.broadleafcommerce.data.tracking.core.TrackableRsqlFilterExecutor<D>
    Repository for persistent counter-parts of Cart.
    Author:
    Chad Harchar (charchar)
    • Method Detail

      • findByCustomerId

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByCustomerId​(String customerId,
                                                                 @Nullable
                                                                 org.springframework.data.domain.Pageable page,
                                                                 @Nullable
                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given customer id.
        Parameters:
        customerId - the id of the customer who owns the cart
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given customer id
      • findByCustomerIdAndAccountId

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByCustomerIdAndAccountId​(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
      • findByCustomerIdAndAccountId

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByCustomerIdAndAccountId​(String customerId,
                                                                             @Nullable
                                                                             String accountId,
                                                                             org.springframework.data.domain.Pageable page,
                                                                             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
      • findByRootAccountId

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByRootAccountId​(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
      • findByRootAccountIdAndStatusIn

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByRootAccountIdAndStatusIn​(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
      • findByAccountHierarchyContaining

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByAccountHierarchyContaining​(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
      • findByAccountHierarchyContainingAndStatusIn

        @Policy(operationTypes=READ)
        org.springframework.data.domain.Page<D> findByAccountHierarchyContainingAndStatusIn​(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
      • findByCustomerRefCustomerId

        @Deprecated
        @Policy(operationTypes=READ)
        default org.springframework.data.domain.Page<D> findByCustomerRefCustomerId​(String customerId,
                                                                                    @Nullable
                                                                                    org.springframework.data.domain.Pageable page,
                                                                                    @Nullable
                                                                                    com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Find all carts for the given customer id.
        Parameters:
        customerId - the id of the customer who owns the cart
        page - the requested page of results from the database
        contextInfo - context information related to multitenancy
        Returns:
        all carts for the given customer id
      • findByNameAndCustomerId

        @Policy(operationTypes=READ)
        Optional<D> findByNameAndCustomerId​(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 related to multitenancy
        Returns:
        an optional cart with the name and customer provided
      • findByNameAndCustomerRefCustomerId

        @Deprecated
        @Policy(operationTypes=READ)
        default Optional<D> findByNameAndCustomerRefCustomerId​(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 related to multitenancy
        Returns:
        an optional cart with the name and customer provided
      • findByCustomerIdAndOrderNumber

        @Policy(operationTypes=READ)
        Optional<D> findByCustomerIdAndOrderNumber​(String customerId,
                                                   String orderNumber,
                                                   @Nullable
                                                   com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        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
        contextInfo - context information related to multitenancy
        Returns:
        a cart (if it exists) with the given order number that belongs to the provided customer.
      • findByCustomerRefCustomerIdAndOrderNumber

        @Deprecated
        @Policy(operationTypes=READ)
        default Optional<D> findByCustomerRefCustomerIdAndOrderNumber​(String customerId,
                                                                      String orderNumber,
                                                                      @Nullable
                                                                      com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        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
        contextInfo - context information related to multitenancy
        Returns:
        a cart (if it exists) with the given order number that belongs to the provided customer.
      • findByEmailAddressAndOrderNumberAndStatusNotIn

        @Policy(operationTypes=READ)
        Optional<D> findByEmailAddressAndOrderNumberAndStatusNotIn​(String emailAddress,
                                                                   String orderNumber,
                                                                   Iterable<String> statuses,
                                                                   @Nullable
                                                                   com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Finds a cart (if it exists) by emailAddress and orderNumber that is not in list of given statuses.
        Parameters:
        emailAddress - The email address associated with the cart
        orderNumber - The cart's order number
        statuses - The statuses to not match
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        A cart (if it exists) matching the emailAddress and orderNumber and not matching the list of given statuses
      • findByEmailAddressAndOrderNumberAndStatusIn

        @Policy(operationTypes=READ)
        Optional<D> findByEmailAddressAndOrderNumberAndStatusIn​(String emailAddress,
                                                                String orderNumber,
                                                                Iterable<String> statuses,
                                                                @Nullable
                                                                com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Finds a cart (if it exists) by emailAddress and orderNumber that is in list of given statuses. This is usually used to find historical carts for an anonymous or not authenticated customer.
        Parameters:
        emailAddress - The email address associated with the cart
        orderNumber - The cart's order number
        statuses - The statuses to not match
        contextInfo - Context information around sandbox and multitenant state.
        Returns:
        A cart (if it exists) matching the emailAddress and orderNumber and matching the list of given statuses
      • findByStatus

        @Policy(operationTypes=READ)
        List<D> findByStatus​(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.
      • findByStatusAndCustomerIdAndAccountIdAndName

        @Policy(operationTypes=READ)
        Optional<D> findByStatusAndCustomerIdAndAccountIdAndName​(String status,
                                                                 String customerId,
                                                                 @Nullable
                                                                 String accountId,
                                                                 @Nullable
                                                                 String name,
                                                                 @Nullable
                                                                 com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
        Finds a cart with the given status for the customer ID, account ID, and name provided. By default, if multiple are found, this selects the cart with the latest createDate.
        Parameters:
        status - the status to find carts of
        customerId - the customer ID to find carts with
        accountId - the account ID to find carts with
        name - The name of the cart, or, if null, then a cart with no name
        contextInfo - the context to use for filtering the results
        Returns:
        the cart with requested details, or empty if none was found.