@Service @Transactional class PersistentOrderManager<T extends Order> extends Object implements OrderManager<T>
| Constructor and Description |
|---|
PersistentOrderManager(Inventory<InventoryItem> inventory,
Accountancy<AccountancyEntry> accountancy,
BusinessTime businessTime,
OrderRepository<T> orderRepository,
org.springframework.transaction.PlatformTransactionManager txManager)
Creates a new
PersistentOrderManager using the given Inventory, Accountancy
BusinessTime, OrderRepository and PlatformTransactionManager. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancelOrder(Order order)
Cancels an
Order, it can only be cancelled is OrderStatus is OPEN. |
OrderCompletionResult |
completeOrder(T order)
Tries to complete this order, the
OrderStatus has to be PAID. |
boolean |
contains(OrderIdentifier orderIdentifier)
Checks if this
OrderManager contains an order. |
Iterable<T> |
find(LocalDateTime from,
LocalDateTime to)
|
Iterable<T> |
find(OrderStatus orderStatus)
|
Iterable<T> |
find(UserAccount userAccount)
Returns all
Orders of the given UserAccount. |
Iterable<T> |
find(UserAccount userAccount,
LocalDateTime from,
LocalDateTime to)
Returns all
Orders from the given UserAccount in between the dates from and to,
including from and to. |
Optional<T> |
get(OrderIdentifier orderIdentifier)
Returns the order identified by an
OrderIdentifier |
boolean |
payOrder(Order order)
|
T |
save(T order)
Saves the given
Order or persists changes to it. |
@Autowired public PersistentOrderManager(Inventory<InventoryItem> inventory, Accountancy<AccountancyEntry> accountancy, BusinessTime businessTime, OrderRepository<T> orderRepository, org.springframework.transaction.PlatformTransactionManager txManager)
PersistentOrderManager using the given Inventory, Accountancy
BusinessTime, OrderRepository and PlatformTransactionManager.inventory - must not be null.accountancy - must not be null.businessTime - must not be null.orderRepository - must not be null.txManager - must not be null.public T save(T order)
OrderManagerOrder or persists changes to it.save in interface OrderManager<T extends Order>order - the order to be saved, must not be null.public final Optional<T> get(OrderIdentifier orderIdentifier)
OrderManagerOrderIdentifierget in interface OrderManager<T extends Order>orderIdentifier - identifier of the Order to be returned, must not be null.Optional.empty().public final boolean contains(OrderIdentifier orderIdentifier)
OrderManagerOrderManager contains an order.contains in interface OrderManager<T extends Order>orderIdentifier - the OrderIdentifier of the Order, must not be null.public final Iterable<T> find(LocalDateTime from, LocalDateTime to)
OrderManagerOrders in between the dates from and to, including from and to. So every entry
with an time stamp <= to and >= from is returned. If no Orders within the specified time span exist, an
empty Iterable is returned.find in interface OrderManager<T extends Order>from - time stamp denoting the start of the requested time period, must not be null.to - time stamp denoting the end of the requested time period, must not be null.Iterable containing all Orders between from and to.public final Iterable<T> find(OrderStatus orderStatus)
OrderManagerOrders having the OrderStatus status. If no orders with the specified status
exist, an empty Iterable is returned.find in interface OrderManager<T extends Order>orderStatus - Denoting the OrderStatus on which the Orders will be requested.Orders with the specified OrderStatuspublic final Iterable<T> find(UserAccount userAccount)
OrderManagerOrders of the given UserAccount. If this user has no orders, an empty Iterable
is returned.find in interface OrderManager<T extends Order>userAccount - Denoting the UserAccount on which the orders will be requested, must not be
null.Iterable containing all orders of the specified user.public final Iterable<T> find(UserAccount userAccount, LocalDateTime from, LocalDateTime to)
OrderManagerOrders from the given UserAccount in between the dates from and to,
including from and to. If this user has no Orders in this period, an empty Iterable is returned.find in interface OrderManager<T extends Order>userAccount - the UserAccount whose Orders shall be returned, must not be null.from - time stamp denoting the start of the requested time period,must not be null.to - time stamp denoting the end of the requested time period, must not be null.Iterable containing all orders from the specified user in the specified period.public OrderCompletionResult completeOrder(T order)
OrderManagerOrderStatus has to be PAID.completeOrder in interface OrderManager<T extends Order>order - the order to complete, must not be null.OrderCompletionResultpublic boolean payOrder(Order order)
OrderManagerpayOrder in interface OrderManager<T extends Order>order - the order to be payed, must not be null.public boolean cancelOrder(Order order)
OrderManagerOrder, it can only be cancelled is OrderStatus is OPEN.cancelOrder in interface OrderManager<T extends Order>order - the order to be canceled, must not be null.Copyright © 2014 Pivotal Software, Inc.. All rights reserved.