Class DefaultOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Type Parameters:
P
- A subtype ofOrder
- All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>
,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
,OrderService<P>
OrderService
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultOrderService
(OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> orderRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper) -
Method Summary
Modifier and TypeMethodDescriptionprotected cz.jirutka.rsql.parser.ast.Node
buildReadAnonymousOrdersByCustomerEmailFilter
(@NonNull String customerEmail) Builds the filter to read the Orders for the specifiedcustomerEmail
excluding the orders with non-nullcustomerId
.protected cz.jirutka.rsql.parser.ast.Node
buildReadCustomerOrdersByRequestFilters
(@NonNull ReadCustomerOrdersRequest request) Builds the filter to read the Orders for the request.protected cz.jirutka.rsql.parser.ast.Node
buildReadOrdersByCustomerIdFilter
(@NonNull ReadCustomerOrdersRequest request) Builds the filter to read the Orders for the specifiedReadCustomerOrdersRequest.getCustomerId()
andReadCustomerOrdersRequest.getAccountId()
.protected CustomerOrderInfoHydrationService
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 fromContextInfo
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 fromContextInfo
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 fromContextInfo
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 theReadCustomerOrdersRequest
.void
setCustomerOrderInfoHydrationService
(CustomerOrderInfoHydrationService customerOrderInfoHydrationService) 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 theOrder
based on the provided reqest.protected void
validateReadCustomerOrdersRequest
(@NonNull ReadCustomerOrdersRequest request) 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
-
CUSTOMER_ID
- See Also:
-
ACCOUNT_ID
- See Also:
-
EMAIL_ADDRESS
- See Also:
-
SUBMIT_DATE
- See Also:
-
ORDER_ID
- See Also:
-
-
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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
cartId
- The order's cart IDcontextInfo
- 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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
orderNumber
- The order's order numbercontextInfo
- 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 infilters
.- Specified by:
readAllUniqueIds
in interfaceOrderService<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 beEmptyNode
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 fromContextInfo
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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
id
- the id of the order fulfillment to findcontextInfo
- 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 fromContextInfo
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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
ids
- the ids of the orders to findcontextInfo
- 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 fromContextInfo
if present.- Specified by:
readAllByOrderNumber
in interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
orderNumber
- the order number to query onfilters
- An RSQL filter used to narrow query results. May beEmptyNode
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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
customerId
- the id of the customer who owns the cartaccountId
- the id of the account that the cart belongs topage
- the requested page of results from the databasecontextInfo
- 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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
rootAccountId
- the root account id of the cartpage
- the requested page of results from the databasecontextInfo
- 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 interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
accountId
- the account id to filter the account hierarchy bypage
- the requested page of results from the databasecontextInfo
- 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 theOrder
based on the provided reqest.- Specified by:
updateOrder
in interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
updateRequest
- the request payload used to update the OrdercontextInfo
- 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 theReadCustomerOrdersRequest
.- Specified by:
readCustomerOrderInfo
in interfaceOrderService<P extends com.broadleafcommerce.order.client.domain.Order>
- Parameters:
request
- the request to read the Orders and the related datapage
- the requested page of results from the databasecontextInfo
- context information related to multitenancy- Returns:
- the page of the
CustomerOrderInfo
with the additional requested data if any
-
populateOrderUpdates
-
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 specifiedcustomerEmail
excluding the orders with non-nullcustomerId
.- 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 specifiedReadCustomerOrdersRequest.getCustomerId()
andReadCustomerOrdersRequest.getAccountId()
.- Parameters:
request
- the request to read the Orders and the related data- Returns:
- the filter based on the request
-
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
-
setCustomerOrderInfoHydrationService
@Autowired public void setCustomerOrderInfoHydrationService(CustomerOrderInfoHydrationService customerOrderInfoHydrationService)
-