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 ofOrder
- 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 ofOrderService
-
-
Constructor Summary
Constructors Constructor Description DefaultOrderService(OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> orderRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable>
getOrderRepository()
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>
getParser()
Iterable<P>
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.List<String>
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.Optional<P>
readByCartId(String cartId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
Read an order by its cart ID.P
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.Optional<P>
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.void
setParser(com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser)
-
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
-
-
-
-
Constructor Detail
-
DefaultOrderService
public DefaultOrderService(OrderRepository<com.broadleafcommerce.data.tracking.core.Trackable> orderRepository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper)
-
-
Method Detail
-
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
-
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)
-
-