public class DefaultCartService extends DefaultAbstractOrderService<CartModel,CartEntryModel> implements CartService
CartServiceAbstractService.SerializableDTO| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
SESSION_CART_PARAMETER_NAME |
modelService, sessionService, txManagertenant| Constructor and Description |
|---|
DefaultCartService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addToCart(CartModel cartModel,
ProductModel productModel,
long quantity,
UnitModel unitModel)
Deprecated.
since 6.2.0
|
void |
appendToCart(CartModel sourceCart,
CartModel targetCart)
Clones all entries of source cart to the target cart.
|
boolean |
calculateCart(CartModel cartModel)
Deprecated.
since 6.2.0
|
void |
changeCurrentCartUser(UserModel user)
Changes the user of the session cart to the given user.
|
void |
changeSessionCartCurrency(CurrencyModel currency)
Changes the currency of the session cart to the given currency.
|
CartModel |
clone(ComposedTypeModel orderType,
ComposedTypeModel entryType,
AbstractOrderModel original,
java.lang.String code)
Creates new order from given original and change its type and type for entry.
|
CartModel |
createCartFromQuote(QuoteModel quote)
Creates a new cart based on the given
QuoteModel. |
protected CreateCartFromQuoteStrategy |
getCreateCartFromQuoteStrategy() |
protected int |
getNextEntryNumber(CartModel cart,
AbstractOrderEntryModel forMe) |
CartModel |
getSessionCart()
Returns the cart attached to the current session.
|
boolean |
hasCart()
Deprecated.
since 6.2.0
|
boolean |
hasSessionCart()
Returns
true if the current session already holds a cart, false otherwise. |
protected CartModel |
internalGetSessionCart() |
protected void |
postProcessClonedEntries(java.util.Collection<CartEntryModel> sourceClones,
int lastEntryNo,
CartModel targetCart)
Rearrange cloned entries numbers according to last entry number from the target.
|
void |
removeSessionCart()
If existing the current session cart is being detached from this session and removed.
|
void |
setAddToCartStrategy(AddToCartStrategy addToCartStrategy) |
void |
setCartFactory(CartFactory cartFactory) |
void |
setCreateCartFromQuoteStrategy(CreateCartFromQuoteStrategy createCartFromQuoteStrategy) |
void |
setOrderCalculation(OrderCalculation orderCalculation) |
void |
setSessionCart(CartModel cart)
Attach the cart to a session.
|
void |
updateQuantities(CartModel cart,
java.util.List<java.lang.Long> quantities)
Deprecated.
since 6.2.0
|
void |
updateQuantities(CartModel cart,
java.util.Map<java.lang.Integer,java.lang.Long> quantities)
Updates multiple cart entry quantities at once.
|
addAllGlobalDiscountValues, addAllTotalTaxValues, addEntryAtPosition, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, getAbstractOrderEntryService, getAbstractOrderEntryTypeService, getCloneAbstractOrderStrategy, getCollidingEntry, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getEntryTypeCode, getGlobalDiscountValue, getOrderDao, getSaveAbstractOrderStrategy, removeGlobalDiscountValue, removeTotalTaxValue, saveOrder, setAbstractOrderEntryService, setAbstractOrderEntryTypeService, setCloneAbstractOrderStrategy, setOrderDao, setSaveAbstractOrderStrategygetModelService, getSessionService, getTxManager, setModelService, setSessionService, setTxManagerafterPropertiesSet, getCurrentTenant, setBeanName, setCurrentTenant, writeReplaceclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddAllGlobalDiscountValues, addAllTotalTaxValues, addGlobalDiscountValue, addNewEntry, addNewEntry, addNewEntry, addTotalTaxValue, getEntriesForNumber, getEntriesForProduct, getEntryForNumber, getGlobalDiscountValue, removeGlobalDiscountValue, removeTotalTaxValue, saveOrderpublic static final java.lang.String SESSION_CART_PARAMETER_NAME
@Deprecated public void addToCart(CartModel cartModel, ProductModel productModel, long quantity, UnitModel unitModel) throws InvalidCartException
CartServiceCartModel the (existing) ProductModel in the given UnitModel and
with the given quantity. If in the cart already an entry with the given product and given unit exists
the given quantity is added to the the quantity of this cart entry. After this the cart is
calculated.addToCart in interface CartServicecartModel - the cart, must existproductModel - the product which is added to the cartquantity - the quantity of the productunitModel - if null ProductService.getOrderableUnit(ProductModel) is used to determine the unitInvalidCartException - if the product is a base product OR the quantity is less 1 or no usable unit was found
(only when given unit is also null)public boolean hasSessionCart()
CartServicetrue if the current session already holds a cart, false otherwise. Please use
this instead of CartService.getSessionCart() if you like to avoid unnecessary auto-creation of the session cart.hasSessionCart in interface CartServiceCartService.getSessionCart()@Deprecated public boolean hasCart()
hasCart in interface CartServicepublic void setSessionCart(CartModel cart)
CartServicesetSessionCart in interface CartServicepublic CartModel getSessionCart()
CartServiceCartFactory. As default a DefaultCartFactory is
being used.getSessionCart in interface CartServiceprotected CartModel internalGetSessionCart()
@Deprecated public boolean calculateCart(CartModel cartModel)
CartServicecartModel and returns true if each entry and after this the
CartModel was calculated. Thereby any invalid entry will be automatically removed.calculateCart in interface CartServicecartModel - the CartModelfalse if the cartModel was already calculated.@Deprecated public void updateQuantities(CartModel cart, java.util.List<java.lang.Long> quantities)
CartServicequantities. If the quantity value is 0 the
cart entry is removed.updateQuantities in interface CartServicecart - the cart where the quantities are updatedquantities - the new quantity list for each cart entrypublic void updateQuantities(CartModel cart, java.util.Map<java.lang.Integer,java.lang.Long> quantities)
CartServiceupdateQuantities in interface CartServicecart - the cart to update cart entry quantities atquantities - the entry specific quantities as map of { entry number -> quantity }public void removeSessionCart()
CartServiceremoveSessionCart in interface CartServiceCartService.getSessionCart(),
CartService.setSessionCart(CartModel)public CartModel clone(ComposedTypeModel orderType, ComposedTypeModel entryType, AbstractOrderModel original, java.lang.String code)
AbstractOrderServiceCloneAbstractOrderStrategy injected strategy. Resulting order remains not persisted.clone in interface AbstractOrderService<CartModel,CartEntryModel>orderType - type of result order (OrderModel will be chosen if null is passed)entryType - type of entry (if null will use service to get proper type)original - original ordercode - code for new orderpublic void appendToCart(CartModel sourceCart, CartModel targetCart)
CartServiceCalculationService. The target cart is also not persisted after this method call.appendToCart in interface CartServicesourceCart - the cart providing the entries to copytargetCart - the target cart to create new entries forpublic void changeCurrentCartUser(UserModel user)
CartServicechangeCurrentCartUser in interface CartServiceuser - new session cart userprotected void postProcessClonedEntries(java.util.Collection<CartEntryModel> sourceClones, int lastEntryNo, CartModel targetCart)
protected int getNextEntryNumber(CartModel cart, AbstractOrderEntryModel forMe)
public void setAddToCartStrategy(AddToCartStrategy addToCartStrategy)
public void setOrderCalculation(OrderCalculation orderCalculation)
public void setCartFactory(CartFactory cartFactory)
public void changeSessionCartCurrency(CurrencyModel currency)
CartServicechangeSessionCartCurrency in interface CartServicecurrency - new session cart currencypublic CartModel createCartFromQuote(QuoteModel quote)
CartServiceQuoteModel. Please note that it is the caller's responsibility to
persist the new cart returned by this method. The quote passed into this method will not be affected by its logic.createCartFromQuote in interface CartServicequote - the quote modelprotected CreateCartFromQuoteStrategy getCreateCartFromQuoteStrategy()
public void setCreateCartFromQuoteStrategy(CreateCartFromQuoteStrategy createCartFromQuoteStrategy)
Copyright © 2018 SAP SE. All Rights Reserved.