O - as OrderI - as OrderItempublic class DefaultOrderService<O extends Order<I>,I extends OrderItem> extends Object implements OrderService<O,I>
Order service
Order)
ChangeGenerator; it will also generate Events of TypeDeliveryDetails - new Object[]{DeliveryDetails, String causeOfSource}| Constructor and Description |
|---|
DefaultOrderService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ChangeListener changeListener)
Allow Notify all
ChangeListeners about a change |
void |
adjustInventory(I item,
Number updateCnt,
String causeSource)
Using a + or a - value for countUpdate we can change the Stock position from its current position.
|
void |
checkItemProductsStillLocked(O order)
For some operations like sending invoice etc it may be necessary for the order to have a lock on all its products;
Warn by throwing
PartialTransactionException.getFailed() of all Products that are not locked. |
OrderDao<O> |
getDao()
The Actions on the service layer can trigger events.
Useful if we want to easily create intermediate save points without having to worry about triggering events. |
List |
getListeners()
Get list directly.
|
OrderDao<O> |
getOrderDao() |
PostOrderProcessStrategy<O,I> |
getPostOrderStrategy() |
PreOrderProcessStrategy<O,I> |
getPreOrderStrategy() |
boolean |
isExists(Long orderId)
Check to see if an Order exists or not
|
O |
load(Long orderId)
Load an existing Order
|
void |
lockProductsForOrder(O order,
String causeSource)
Orders maintain referential integrity over Products that are used by them. |
void |
notifyAllListeners(Object object)
Whenever a node is selected/updated, it also notifies its listeners.
|
<D extends DeliveryDetails> |
save(D deliveryDetails,
String causeSource)
Explicitly update the Delivery Details only
|
<T extends O> |
save(T order,
String causeSource,
Object... context)
|
void |
setListeners(List listeners)
Set list directly.
|
void |
setOrderDao(OrderDao<O> orderDao) |
void |
setPostOrderStrategy(PostOrderProcessStrategy<O,I> postOrderStrategy) |
void |
setPreOrderStrategy(PreOrderProcessStrategy<O,I> preOrderStrategy) |
void |
unlockProductsForOrder(O order,
String causeSource)
Orders maintain referential integrity over Products that are used by them. |
I |
update(I item,
String causeSource)
|
@Transactional(readOnly=false) public <T extends O> T save(T order, String causeSource, Object... context) throws OrderPlacementException
OrderServicesave in interface OrderService<O extends Order<I>,I extends OrderItem>order - as OrdercauseSource - as Source of Change @nullable true will cause no subsequent event firingcontext - as Object varags; typically sent to the ChangeGenerator.getListeners()Order objectOrderPlacementException@Transactional(readOnly=true) public O load(Long orderId)
OrderService@Transactional(readOnly=false) public I update(I item, String causeSource) throws OrderPlacementException
OrderServiceupdate in interface OrderService<O extends Order<I>,I extends OrderItem>item - as OrderItemcauseSource - as Source of Change @nullable true will cause no subsequent event firingOrderItem objectOrderPlacementException@Transactional(readOnly=false) public <D extends DeliveryDetails> D save(D deliveryDetails, String causeSource)
OrderServicesave in interface OrderService<O extends Order<I>,I extends OrderItem>deliveryDetails - as DeliveryDetailscauseSource - as Source of Change @nullable true will cause no subsequent event firing@Transactional(readOnly=false,
noRollbackFor=PartialTransactionException.class)
public void lockProductsForOrder(O order,
String causeSource)
throws PartialTransactionException,
OrderPlacementException
OrderServiceOrders maintain referential integrity over Products that are used by them. OrderItems in the OrderlockProductsForOrder in interface OrderService<O extends Order<I>,I extends OrderItem>order - as OrdercauseSource - as String @nullable true will cause no subsequent event firingPartialTransactionExceptionOrderPlacementException@Transactional(readOnly=false) public void adjustInventory(I item, Number updateCnt, String causeSource)
OrderServiceOrderService.adjustInventory(OrderItem, Number, String) for an Order ensure they are called within one Transaction.
RuntimeExceptions if Products don't exist, difficulty in modifying count on underlying DB etc; so any calling API Post Order placement should ideally account
for RuntimeException use casesadjustInventory in interface OrderService<O extends Order<I>,I extends OrderItem>item - as OrderItemupdateCnt - as Number (Integer) that will be adjusted from the current stock position. A position # will ADD to current position, Negative will deduct from current position.
Note: The update count is not an absolute position; this is to ensure in high volume cases the Adjustments dont overwrite each other and each transaction is responsible for its own adjustment.causeSource - as String @nullable true will cause no subsequent event firing@Transactional(readOnly=false) public void unlockProductsForOrder(O order, String causeSource) throws OrderPlacementException
OrderServiceOrders maintain referential integrity over Products that are used by them. OrderItems in the OrderunlockProductsForOrder in interface OrderService<O extends Order<I>,I extends OrderItem>order - as OrdercauseSource - @nullable true will cause no subsequent event firingOrderPlacementExceptionpublic void checkItemProductsStillLocked(O order) throws PartialTransactionException
PartialTransactionException.getFailed() of all Products that are not locked.checkItemProductsStillLocked in interface OrderService<O extends Order<I>,I extends OrderItem>order - PartialTransactionExceptionpublic boolean isExists(Long orderId)
OrderServicepublic PreOrderProcessStrategy<O,I> getPreOrderStrategy()
public void setPreOrderStrategy(PreOrderProcessStrategy<O,I> preOrderStrategy)
public PostOrderProcessStrategy<O,I> getPostOrderStrategy()
public void setPostOrderStrategy(PostOrderProcessStrategy<O,I> postOrderStrategy)
public void addChangeListener(ChangeListener changeListener)
ChangeGeneratorChangeListeners about a changeaddChangeListener in interface ChangeGenerator<Object>public void notifyAllListeners(Object object)
ChangeGeneratornotifyAllListeners in interface ChangeGenerator<Object>public List getListeners()
ChangeGeneratorgetListeners in interface ChangeGenerator<Object>public void setListeners(List listeners)
ChangeGeneratorsetListeners in interface ChangeGenerator<Object>public OrderDao<O> getDao()
OrderServiceCopyright © 2018. All rights reserved.