Class DefaultCartService
- java.lang.Object
-
- de.hybris.platform.sap.sapordermgmtservices.cart.impl.DefaultCartCheckoutBaseService
-
- de.hybris.platform.sap.sapordermgmtservices.cart.impl.DefaultCartService
-
- All Implemented Interfaces:
CartCheckoutBaseService,CartService
- Direct Known Subclasses:
CPQDefaultCartService
public class DefaultCartService extends DefaultCartCheckoutBaseService implements CartService
Basic cart functions for SAP synchronous order management. In this case, the cart will be created in the back end session, it does not touch the hybris persistence.
The class synchronizes accesses to the BOL object representing the cart, as this is not thread safe. Multi-threaded accesses can happen although we use request sequencing, since also filters might call cart facades.
-
-
Constructor Summary
Constructors Constructor Description DefaultCartService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<CartModificationData>addEntriesToCart(java.util.List<OrderEntryData> orderEntries)Adds quick order entries to the cart.voidaddItemsToCart(java.util.List<Item> items)Adds an item to the cart.CartModificationDataaddToCart(java.lang.String code, long quantity)Adds an entry to the cart.protected voidcheckForDeletion(java.math.BigDecimal quantity, Item itemToUpdate)Checks if cart item is meant to be deleted, which is indicated by a quantity zero.protected java.math.BigDecimalconvertQuantity(long quantity)Converts a quantity into a BigDecimal so that BOL can consume it.protected intconvertToPositiveInt(long entryNumber)protected java.util.List<Item>createItemsFromOrderEntries(java.util.List<OrderEntryData> cartEntries)Converter<Item,OrderEntryData>getCartItemConverter()ItemFactorygetItemFactory()Converter<Message,CartModificationData>getMessageConverter()SalesAreaServicegetSalesAreaService()SessionServicegetSessionService()booleanisItemAvailable(java.lang.String itemKey)Does an item exist with a given key?voidsetCartItemConverter(Converter<Item,OrderEntryData> cartItemConverter)voidsetItemFactory(ItemFactory itemFactory)voidsetMessageConverter(Converter<Message,CartModificationData> messageConverter)voidsetSalesAreaService(SalesAreaService salesAreaService)voidsetSessionService(SessionService sessionService)Sets standard session service via spring injectionCartModificationDataupdateCartEntry(long entryNumber, long quantityAsLong)Updates a cart entryjava.util.List<CartModificationData>validateCartData()Validates cart-
Methods inherited from class de.hybris.platform.sap.sapordermgmtservices.cart.impl.DefaultCartCheckoutBaseService
compileSessionCart, createEmptyCart, getBolCartFacade, getCartConverter, getI18nService, getMessageSource, getSessionCart, getSessionCart, hasSessionCart, removeSessionCart, reverseCartSorting, reverseCartSorting, setBolCartFacade, setCartConverter, setI18nService, setMessageSource
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface de.hybris.platform.sap.sapordermgmtservices.cart.CartCheckoutBaseService
getSessionCart, getSessionCart, hasSessionCart, removeSessionCart
-
-
-
-
Method Detail
-
addToCart
public CartModificationData addToCart(java.lang.String code, long quantity)
Description copied from interface:CartServiceAdds an entry to the cart. The result contains error messages if those have occurred.- Specified by:
addToCartin interfaceCartService- Parameters:
code- Product IDquantity- Quantity to be added- Returns:
- Cart modification data
-
updateCartEntry
public CartModificationData updateCartEntry(long entryNumber, long quantityAsLong)
Description copied from interface:CartServiceUpdates a cart entry- Specified by:
updateCartEntryin interfaceCartService- Parameters:
entryNumber- Item numberquantityAsLong- New quantity of item- Returns:
- Cart modifications
-
convertToPositiveInt
protected int convertToPositiveInt(long entryNumber)
- Parameters:
entryNumber-- Returns:
- Input converted into positive int
-
checkForDeletion
protected void checkForDeletion(java.math.BigDecimal quantity, Item itemToUpdate)Checks if cart item is meant to be deleted, which is indicated by a quantity zero. In this case, the BOL item will be marked to be deleted- Parameters:
quantity- New item quantity, if zero: Item will be deleteditemToUpdate- BOL item to be updated
-
convertQuantity
protected java.math.BigDecimal convertQuantity(long quantity)
Converts a quantity into a BigDecimal so that BOL can consume it.- Parameters:
quantity-- Returns:
- Quantity as result from the input, if input is positive. Zero otherwise
-
validateCartData
public java.util.List<CartModificationData> validateCartData()
Description copied from interface:CartServiceValidates cart- Specified by:
validateCartDatain interfaceCartService- Returns:
- Modification status as result of the validation
-
getSessionService
public SessionService getSessionService()
- Returns:
- Standard session service (needed to access session cart and references to product configuration runtime objects attached to cart entries)
-
setSessionService
public void setSessionService(SessionService sessionService)
Sets standard session service via spring injection- Parameters:
sessionService-
-
getCartItemConverter
public Converter<Item,OrderEntryData> getCartItemConverter()
- Returns:
- the cartItemConverter
-
setCartItemConverter
public void setCartItemConverter(Converter<Item,OrderEntryData> cartItemConverter)
- Parameters:
cartItemConverter- the cartItemConverter to set
-
getMessageConverter
public Converter<Message,CartModificationData> getMessageConverter()
- Returns:
- the messageConverter
-
setMessageConverter
public void setMessageConverter(Converter<Message,CartModificationData> messageConverter)
- Parameters:
messageConverter- the messageConverter to set
-
getSalesAreaService
public SalesAreaService getSalesAreaService()
- Returns:
- the salesAreaService
-
setSalesAreaService
public void setSalesAreaService(SalesAreaService salesAreaService)
- Parameters:
salesAreaService- the salesAreaService to set
-
isItemAvailable
public boolean isItemAvailable(java.lang.String itemKey)
Description copied from interface:CartServiceDoes an item exist with a given key?- Specified by:
isItemAvailablein interfaceCartService- Parameters:
itemKey- key for the item.- Returns:
- Does item exist for the item key?
-
addItemsToCart
public void addItemsToCart(java.util.List<Item> items)
Description copied from interface:CartServiceAdds an item to the cart.- Specified by:
addItemsToCartin interfaceCartService- Parameters:
items- list of items
-
addEntriesToCart
public java.util.List<CartModificationData> addEntriesToCart(java.util.List<OrderEntryData> orderEntries)
Description copied from interface:CartServiceAdds quick order entries to the cart.- Specified by:
addEntriesToCartin interfaceCartService- Returns:
-
createItemsFromOrderEntries
protected java.util.List<Item> createItemsFromOrderEntries(java.util.List<OrderEntryData> cartEntries)
-
getItemFactory
public ItemFactory getItemFactory()
- Returns:
- the itemFactory
-
setItemFactory
public void setItemFactory(ItemFactory itemFactory)
- Parameters:
itemFactory- the itemFactory to set
-
-