Class DefaultBolCartFacade
- java.lang.Object
-
- de.hybris.platform.sap.sapordermgmtservices.bolfacade.impl.DefaultBolCartFacade
-
- All Implemented Interfaces:
BolCartFacade
- Direct Known Subclasses:
CPQDefaultBolCartFacade
public class DefaultBolCartFacade extends java.lang.Object implements BolCartFacade
Facade for accessing the cart entity via the BOL
-
-
Constructor Summary
Constructors Constructor Description DefaultBolCartFacade()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.List<Item>addEntriesToCart(java.util.List<Item> items)Adds a list of items to the cart, keeping their handlesvoidaddItemsToCart(java.util.List<Item> items)Adds a list of items to the cart, keeping their handlesItemaddToCart(java.lang.String code, long quantity)Adds a product to the cartAddresscreateAddress()Creates a new address instance.BasketcreateCart()Creates a new session cart.protected ItemcreateNewItem(java.lang.String code, long quantity, java.lang.String handle)Creates a new BOL cart item from the attributes provided.protected ItemcreateNewItem(java.lang.String code, long quantity, java.lang.String handle, Basket currentCart)Creates a new BOL cart item from the attributes provided.protected java.lang.StringformatProductIdForBOL(java.lang.String input)Formats product ID taken from hybris catalog and prepares it for sending to LO-API.java.util.Map<java.lang.String,java.lang.String>getAllowedDeliveryTypes()Fetches available delivery types from the cache.BasketgetCart()Return current cart from BOL.BasketBackendgetCartBE()protected MessageListgetCartErrors()Filters the list of messages attached to the cart and just returns the error ones.ItemgetCartItem(int itemNumber)Fetches cart item per item numberprotected ItemgetCartItem(java.lang.String code)Fetches cart item per product idGenericFactorygetGenericFactory()OrdergetOrder()java.lang.BooleanhasCart()Does a session cart exist? This cart is connected to a (non-persisted) order in the SAP back end.booleanisBackendDown()OrderplaceOrderFromCart(Basket cart)Places an order based on a cart, and returns this order.voidreleaseCart()Releases the current session cart.voidsetGenericFactory(GenericFactory genericFactory)voidsetSapPartnerService(SapPartnerService sapPartnerService)voidupdateCart()Updates the session cart and re-reads it from the SAP back end.MessageListvalidateCart()Validates the cart and compiles the list of cart error messages.
-
-
-
Method Detail
-
getGenericFactory
public GenericFactory getGenericFactory()
- Returns:
- the genericFactory
-
setGenericFactory
public void setGenericFactory(GenericFactory genericFactory)
- Parameters:
genericFactory- the genericFactory to set
-
getCart
public Basket getCart()
Description copied from interface:BolCartFacadeReturn current cart from BOL.- Specified by:
getCartin interfaceBolCartFacade- Returns:
- Current cart, might be null if not created yet.
-
hasCart
public java.lang.Boolean hasCart()
Description copied from interface:BolCartFacadeDoes a session cart exist? This cart is connected to a (non-persisted) order in the SAP back end.- Specified by:
hasCartin interfaceBolCartFacade- Returns:
- Does a session cart exist?
-
getAllowedDeliveryTypes
public java.util.Map<java.lang.String,java.lang.String> getAllowedDeliveryTypes()
Description copied from interface:BolCartFacadeFetches available delivery types from the cache. Cache is filled from the SAP back end customizing (ERP customizing table TVSB)- Specified by:
getAllowedDeliveryTypesin interfaceBolCartFacade- Returns:
- Map of delivery types. Key is the shipping condition code, value the language dependent description
-
createAddress
public Address createAddress()
Description copied from interface:BolCartFacadeCreates a new address instance.- Specified by:
createAddressin interfaceBolCartFacade- Returns:
- BOL Address representation
-
createCart
public Basket createCart()
Description copied from interface:BolCartFacadeCreates a new session cart. This call creates a (non-persisted) order in the SAP back end. At this point in time, the sold-to party needs to be known.- Specified by:
createCartin interfaceBolCartFacade- Returns:
- Newly created cart BO instance
-
placeOrderFromCart
public Order placeOrderFromCart(Basket cart)
Description copied from interface:BolCartFacadePlaces an order based on a cart, and returns this order. At this point in time, the order is persisted in the SAP back end.- Specified by:
placeOrderFromCartin interfaceBolCartFacade- Parameters:
cart- SAP representation of a cart- Returns:
- SAP representation of an order which has been submitted
-
getCartItem
public Item getCartItem(int itemNumber)
Description copied from interface:BolCartFacadeFetches cart item per item number- Specified by:
getCartItemin interfaceBolCartFacade- Parameters:
itemNumber- Internal item number- Returns:
- BOL representation of cart item
-
getCartItem
protected Item getCartItem(java.lang.String code)
Fetches cart item per product id- Parameters:
code- Product ID- Returns:
- BOL representation of cart item
-
getOrder
public Order getOrder()
- Returns:
- The BOL representation of the order
-
getCartBE
public BasketBackend getCartBE()
- Returns:
- The cart backend object which establishes the connection to the ERP system
-
getCartErrors
protected MessageList getCartErrors()
Filters the list of messages attached to the cart and just returns the error ones.- Returns:
- Error messages related to the cart
-
updateCart
public void updateCart()
Description copied from interface:BolCartFacadeUpdates the session cart and re-reads it from the SAP back end.- Specified by:
updateCartin interfaceBolCartFacade
-
addToCart
public Item addToCart(java.lang.String code, long quantity)
Description copied from interface:BolCartFacadeAdds a product to the cart- Specified by:
addToCartin interfaceBolCartFacade- Parameters:
code- Product ID to be added to the cartquantity- Quantity to be added to the cart- Returns:
- BOL representation of new item
-
createNewItem
protected Item createNewItem(java.lang.String code, long quantity, java.lang.String handle)
Creates a new BOL cart item from the attributes provided. Creates the cart if this has not happened yet.- Parameters:
code- Product code (SAP material number)quantity- Quantityhandle- Handle to be set into new item. Can be provided as null, in this case a new handle will be created- Returns:
- handle of newly created item
-
createNewItem
protected Item createNewItem(java.lang.String code, long quantity, java.lang.String handle, Basket currentCart)
Creates a new BOL cart item from the attributes provided.- Parameters:
code- Product code (SAP material number)quantity- Quantityhandle- Handle to be set into new item. Can be provided as null, in this case a new handle will be createdcurrentCart- The BOL cart object the items will be attached to- Returns:
- handle of newly created item
-
releaseCart
public void releaseCart()
Description copied from interface:BolCartFacadeReleases the current session cart. A new, initial session cart will be created. An existing session in the SAP back end is released as well, therefore reservations are gone.- Specified by:
releaseCartin interfaceBolCartFacade
-
setSapPartnerService
public void setSapPartnerService(SapPartnerService sapPartnerService)
- Parameters:
sapPartnerService- the sapPartnerService to set
-
validateCart
public MessageList validateCart()
Description copied from interface:BolCartFacadeValidates the cart and compiles the list of cart error messages. Performs a back end call and touches all items to be sure all error situations are handled. Depending on the customizing in the back end, this can be avoided by either redefining this method or the corresponding one inSalesDocument- Specified by:
validateCartin interfaceBolCartFacade- Returns:
- List of cart error messages arising from validation.
-
formatProductIdForBOL
protected java.lang.String formatProductIdForBOL(java.lang.String input)
Formats product ID taken from hybris catalog and prepares it for sending to LO-API. Adds leading zeros.- Parameters:
input-- Returns:
- Formatted product ID
-
addItemsToCart
public void addItemsToCart(java.util.List<Item> items)
Description copied from interface:BolCartFacadeAdds a list of items to the cart, keeping their handles- Specified by:
addItemsToCartin interfaceBolCartFacade- Parameters:
items- BOL items
-
addEntriesToCart
public java.util.List<Item> addEntriesToCart(java.util.List<Item> items)
Description copied from interface:BolCartFacadeAdds a list of items to the cart, keeping their handles- Specified by:
addEntriesToCartin interfaceBolCartFacade- Parameters:
items- BOL items item list- Returns:
- list of items
-
isBackendDown
public boolean isBackendDown()
- Specified by:
isBackendDownin interfaceBolCartFacade- Returns:
- Is back end not available for a planned downtime?
-
-