Class DefaultOrderService<P extends com.broadleafcommerce.order.client.domain.Order>

java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.order.service.DefaultOrderService<P>
Type Parameters:
P - A subtype of Order
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>, OrderService<P>

public class DefaultOrderService<P extends com.broadleafcommerce.order.client.domain.Order> extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P> implements OrderService<P>
Default implementation of OrderService
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
     
    protected static final String
     
    protected static final String
     
    protected static final String
     
    protected static final String
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultOrderService(OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> orderRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected cz.jirutka.rsql.parser.ast.Node
    Builds the filter to read the Orders for the specified customerEmail excluding the orders with non-null customerId.
    protected cz.jirutka.rsql.parser.ast.Node
    Builds the filter to read the Orders for the request.
    protected cz.jirutka.rsql.parser.ast.Node
    Builds the filter to read the Orders for the specified ReadCustomerOrdersRequest.getCustomerId() and ReadCustomerOrdersRequest.getAccountId().
     
    protected OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable>
     
    protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>
     
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    protected P
    populateOrderUpdates(P order, UpdateOrderRequest updateRequest)
     
    readAllByContextIdAndMatchingTenant(Iterable<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Retrieves the orders matching the provided IDs and the tenant from ContextInfo if present.
    org.springframework.data.domain.Page<P>
    readAllByOrderNumber(String orderNumber, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Retrieves the orders matching the provided order number from ContextInfo if present.
    readAllUniqueIds(int page, cz.jirutka.rsql.parser.ast.Node filters)
    Retrieves a list of unique order context IDs no larger than page.
    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 orders where the account hierarchy contains the given account id.
    readByCartId(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read an order by its cart ID.
    readByContextIdAndMatchingTenant(String id, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Retrieves the order matching the provided ID and the tenant from ContextInfo if present.
    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 orders for the given customer id and account id.
    readByOrderNumber(String orderNumber, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Read an order by its order number.
    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 orders for the given root account id.
    org.springframework.data.domain.Page<CustomerOrderInfo>
    readCustomerOrderInfo(ReadCustomerOrdersRequest request, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Reads the Orders and additional related data for the ReadCustomerOrdersRequest.
    void
     
    void
    setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
     
    void
    setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
     
    com.broadleafcommerce.order.client.domain.Order
    updateOrder(UpdateOrderRequest updateRequest, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    Updates the Order based on the provided reqest.
    protected void
     

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService

    getRsqlHelper, readAll, readAll, readAll, readAll

    Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService

    convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, delete, getHelper, getRepository, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSort

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    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

    Methods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService

    readAll, readAll, readAll, readAll
  • Field Details

  • Constructor Details

    • DefaultOrderService

      public DefaultOrderService(OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> orderRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
  • Method Details

    • readByCartId

      public Optional<P> readByCartId(String cartId, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Read an order by its cart ID.
      Specified by:
      readByCartId in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      cartId - The order's cart ID
      contextInfo - The current context.
      Returns:
      The order with the cart ID if found
    • readByOrderNumber

      public Optional<P> readByOrderNumber(String orderNumber, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Read an order by its order number.
      Specified by:
      readByOrderNumber in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      orderNumber - The order's order number
      contextInfo - The current context.
      Returns:
      The order with the order number if found
    • readAllUniqueIds

      @NonNull public List<String> readAllUniqueIds(int page, @NonNull cz.jirutka.rsql.parser.ast.Node filters)
      Description copied from interface: OrderService
      Retrieves a list of unique order context IDs no larger than page. It is expected that any appropriate offset is achieved through criteria designated in filters.
      Specified by:
      readAllUniqueIds in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      page - the requested page of results from the database. -1 indicates no limit.
      filters - An RSQL filter used to narrow query results. May be EmptyNode if no filters should be applied.
      Returns:
      unique order IDs
    • readByContextIdAndMatchingTenant

      public P readByContextIdAndMatchingTenant(String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Retrieves the order matching the provided ID and the tenant from ContextInfo if present.

      Differs from the standard narrowing behavior of TrackableRepository.findByContextId(String, ContextInfo), which only returns tenant-level (non-application-associated) records when fetching from a tenant context. This implementation finds all records within the tenant regardless of whether they're associated to an application.

      Specified by:
      readByContextIdAndMatchingTenant in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      id - the id of the order fulfillment to find
      contextInfo - context information surrounding multitenant state.
      Returns:
      the requested order if found within the tenant
    • readAllByContextIdAndMatchingTenant

      public Iterable<P> readAllByContextIdAndMatchingTenant(Iterable<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Retrieves the orders matching the provided IDs and the tenant from ContextInfo if present.

      Differs from the standard narrowing behavior of TrackableRepository.findByContextId(String, ContextInfo), which only returns tenant-level (non-application-associated) records when fetching from a tenant context. This implementation finds all records within the tenant regardless of whether they're associated to an application.

      Specified by:
      readAllByContextIdAndMatchingTenant in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      ids - the ids of the orders to find
      contextInfo - context information surrounding multitenant state.
      Returns:
      The list of narrowed orders
    • readAllByOrderNumber

      public org.springframework.data.domain.Page<P> readAllByOrderNumber(@Nullable String orderNumber, cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Retrieves the orders matching the provided order number from ContextInfo if present.
      Specified by:
      readAllByOrderNumber in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      orderNumber - the order number to query on
      filters - An RSQL filter used to narrow query results. May be EmptyNode if no filters should be applied.
      page - the requested page of results from the database. -1 indicates no limit.
      contextInfo - context information surrounding multitenant state.
      Returns:
      The page of narrowed orders
    • readByCustomerIdAndAccountId

      public org.springframework.data.domain.Page<P> readByCustomerIdAndAccountId(String customerId, String accountId, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Find all orders for the given customer id and account id.

      This is typically used for B2B account orders.

      Specified by:
      readByCustomerIdAndAccountId in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      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 orders for the given customer id and account id
    • readByRootAccountId

      public 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)
      Description copied from interface: OrderService
      Find all orders for the given root account id.

      This is useful to query all the orders 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 orders that belong to the root account and its sub-accounts.

      Specified by:
      readByRootAccountId in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      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 orders for the given root account id
    • readByAccountHierarchyContaining

      public 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)
      Description copied from interface: OrderService
      Find all orders where the account hierarchy contains the given account id.

      This is useful to query all the orders 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 orders that belong to the subAcct and its sub-accounts (subSubAcct in this case).

      Specified by:
      readByAccountHierarchyContaining in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      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 orders where the account hierarchy contains the given account id
    • updateOrder

      public com.broadleafcommerce.order.client.domain.Order updateOrder(UpdateOrderRequest updateRequest, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Updates the Order based on the provided reqest.
      Specified by:
      updateOrder in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      updateRequest - the request payload used to update the Order
      contextInfo - Context information related to multitenancy
      Returns:
      the updated order
    • readCustomerOrderInfo

      public org.springframework.data.domain.Page<CustomerOrderInfo> readCustomerOrderInfo(ReadCustomerOrdersRequest request, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: OrderService
      Reads the Orders and additional related data for the ReadCustomerOrdersRequest.
      Specified by:
      readCustomerOrderInfo in interface OrderService<P extends com.broadleafcommerce.order.client.domain.Order>
      Parameters:
      request - the request to read the Orders and the related data
      page - the requested page of results from the database
      contextInfo - context information related to multitenancy
      Returns:
      the page of the CustomerOrderInfo with the additional requested data if any
    • populateOrderUpdates

      protected P populateOrderUpdates(P order, UpdateOrderRequest updateRequest)
    • validateReadCustomerOrdersRequest

      protected void validateReadCustomerOrdersRequest(@NonNull @NonNull ReadCustomerOrdersRequest request)
    • buildReadCustomerOrdersByRequestFilters

      protected cz.jirutka.rsql.parser.ast.Node buildReadCustomerOrdersByRequestFilters(@NonNull @NonNull ReadCustomerOrdersRequest request)
      Builds the filter to read the Orders for the request.
      Parameters:
      request - the request to read the Orders and the related data
      Returns:
      the filter based on the request
    • buildReadAnonymousOrdersByCustomerEmailFilter

      protected cz.jirutka.rsql.parser.ast.Node buildReadAnonymousOrdersByCustomerEmailFilter(@NonNull @NonNull String customerEmail)
      Builds the filter to read the Orders for the specified customerEmail excluding the orders with non-null customerId.
      Parameters:
      customerEmail - the customer email
      Returns:
      the filter based on the request
    • buildReadOrdersByCustomerIdFilter

      protected cz.jirutka.rsql.parser.ast.Node buildReadOrdersByCustomerIdFilter(@NonNull @NonNull ReadCustomerOrdersRequest request)
      Builds the filter to read the Orders for the specified ReadCustomerOrdersRequest.getCustomerId() and ReadCustomerOrdersRequest.getAccountId().
      Parameters:
      request - the request to read the Orders and the related data
      Returns:
      the filter based on the request
    • getOrderRepository

      protected OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> getOrderRepository()
    • getParser

      protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getParser()
    • setParser

      @Autowired public void setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
    • getTypeFactory

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

      @Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
    • getCustomerOrderInfoHydrationService

      protected CustomerOrderInfoHydrationService getCustomerOrderInfoHydrationService()
    • setCustomerOrderInfoHydrationService

      @Autowired public void setCustomerOrderInfoHydrationService(CustomerOrderInfoHydrationService customerOrderInfoHydrationService)