Class 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 Detail

      • DefaultCartService

        public DefaultCartService()
    • Method Detail

      • addToCart

        public CartModificationData addToCart​(java.lang.String code,
                                              long quantity)
        Description copied from interface: CartService
        Adds an entry to the cart. The result contains error messages if those have occurred.
        Specified by:
        addToCart in interface CartService
        Parameters:
        code - Product ID
        quantity - Quantity to be added
        Returns:
        Cart modification data
      • updateCartEntry

        public CartModificationData updateCartEntry​(long entryNumber,
                                                    long quantityAsLong)
        Description copied from interface: CartService
        Updates a cart entry
        Specified by:
        updateCartEntry in interface CartService
        Parameters:
        entryNumber - Item number
        quantityAsLong - 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 deleted
        itemToUpdate - 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
      • getSessionService

        public de.hybris.platform.servicelayer.session.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​(de.hybris.platform.servicelayer.session.SessionService sessionService)
        Sets standard session service via spring injection
        Parameters:
        sessionService -
      • getCartItemConverter

        public de.hybris.platform.servicelayer.dto.converter.Converter<Item,​OrderEntryData> getCartItemConverter()
        Returns:
        the cartItemConverter
      • setCartItemConverter

        public void setCartItemConverter​(de.hybris.platform.servicelayer.dto.converter.Converter<Item,​OrderEntryData> cartItemConverter)
        Parameters:
        cartItemConverter - the cartItemConverter to set
      • getMessageConverter

        public de.hybris.platform.servicelayer.dto.converter.Converter<Message,​CartModificationData> getMessageConverter()
        Returns:
        the messageConverter
      • setMessageConverter

        public void setMessageConverter​(de.hybris.platform.servicelayer.dto.converter.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: CartService
        Does an item exist with a given key?
        Specified by:
        isItemAvailable in interface CartService
        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: CartService
        Adds an item to the cart.
        Specified by:
        addItemsToCart in interface CartService
        Parameters:
        items - list of items
      • addEntriesToCart

        public java.util.List<CartModificationData> addEntriesToCart​(java.util.List<OrderEntryData> orderEntries)
        Description copied from interface: CartService
        Adds quick order entries to the cart.
        Specified by:
        addEntriesToCart in interface CartService
        Parameters:
        orderEntries - order entries list
        Returns:
        list of CartModificationData objects
      • 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