O
- as OrderI
- as OrderItem
public 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
ChangeListener s 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)
Order s 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)
Order s 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
OrderService
save
in interface OrderService<O extends Order<I>,I extends OrderItem>
order
- as Order
causeSource
- 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
OrderService
update
in interface OrderService<O extends Order<I>,I extends OrderItem>
item
- as OrderItem
causeSource
- 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)
OrderService
save
in interface OrderService<O extends Order<I>,I extends OrderItem>
deliveryDetails
- as DeliveryDetails
causeSource
- 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
OrderService
Order
s maintain referential integrity over Products that are used by them. OrderItem
s in the Order
lockProductsForOrder
in interface OrderService<O extends Order<I>,I extends OrderItem>
order
- as Order
causeSource
- as String @nullable true will cause no subsequent event firingPartialTransactionException
OrderPlacementException
@Transactional(readOnly=false) public void adjustInventory(I item, Number updateCnt, String causeSource)
OrderService
OrderService.adjustInventory(OrderItem, Number, String)
for an Order
ensure they are called within one Transaction.
RuntimeException
s 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 OrderItem
updateCnt
- 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
OrderService
Order
s maintain referential integrity over Products that are used by them. OrderItem
s in the Order
unlockProductsForOrder
in interface OrderService<O extends Order<I>,I extends OrderItem>
order
- as Order
causeSource
- @nullable true will cause no subsequent event firingOrderPlacementException
public 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
- PartialTransactionException
public boolean isExists(Long orderId)
OrderService
public 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)
ChangeGenerator
ChangeListener
s about a changeaddChangeListener
in interface ChangeGenerator<Object>
public void notifyAllListeners(Object object)
ChangeGenerator
notifyAllListeners
in interface ChangeGenerator<Object>
public List getListeners()
ChangeGenerator
getListeners
in interface ChangeGenerator<Object>
public void setListeners(List listeners)
ChangeGenerator
setListeners
in interface ChangeGenerator<Object>
public OrderDao<O> getDao()
OrderService
Copyright © 2018. All rights reserved.