Class DefaultItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>

  • All Implemented Interfaces:
    ItemListItemManagementService<I>

    public class DefaultItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
    extends Object
    implements ItemListItemManagementService<I>
    Default implementation of an item list item management service.
    Author:
    Jacob Mitash
    • Field Detail

      • ATTR_MERGE_UPDATED

        protected static final String ATTR_MERGE_UPDATED
        Attribute key for a boolean value that indicates that an item was updated as a result of a merge instead of the typical addition/create.
        See Also:
        Constant Field Values
    • Constructor Detail

    • Method Detail

      • getItemListItemPage

        public org.springframework.data.domain.Page<I> getItemListItemPage​(@NonNull
                                                                           @NonNull String listId,
                                                                           @NonNull
                                                                           @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                                                           @Nullable
                                                                           org.springframework.data.domain.Pageable pageable,
                                                                           @Nullable
                                                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Gets a page of item list items.
        Specified by:
        getItemListItemPage in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the item list to fetch items from
        customerRef - Information about the owning customer
        pageable - the page information
        context - the context of the request
        Returns:
        a page of items
      • getItemListItems

        public List<I> getItemListItems​(@NonNull
                                        @NonNull String listId,
                                        @NonNull
                                        @NonNull Collection<String> itemIds,
                                        @NonNull
                                        @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                        @Nullable
                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Gets specific item list items by their IDs.
        Specified by:
        getItemListItems in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the item list to fetch items from
        itemIds - the IDs of the items to find
        customerRef - Information about the owning customer
        context - the context of the request
        Returns:
        a list of items
      • createItemListItems

        public List<I> createItemListItems​(@NonNull
                                           @NonNull String listId,
                                           @NonNull
                                           @NonNull Collection<I> createRequests,
                                           @NonNull
                                           @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                           @Nullable
                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Creates item list items.
        Specified by:
        createItemListItems in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the item list to create the items for
        createRequests - the item creation requests
        customerRef - Information about the owning customer
        context - the context of the request
        Returns:
        a list of create item list items
      • replaceItemListItems

        public List<I> replaceItemListItems​(@NonNull
                                            @NonNull String listId,
                                            @NonNull
                                            @NonNull Collection<I> updateRequests,
                                            @NonNull
                                            @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                            @Nullable
                                            com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Replaces item list items.
        Specified by:
        replaceItemListItems in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the item list to replace items in
        updateRequests - the item update requests
        customerRef - Information about the owning customer
        context - the context of the request
        Returns:
        a list of replaced items
      • updateItemListItems

        public List<I> updateItemListItems​(@NonNull
                                           @NonNull String listId,
                                           @NonNull
                                           @NonNull Collection<I> updateRequests,
                                           @NonNull
                                           @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                           @Nullable
                                           com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Updates item list items.
        Specified by:
        updateItemListItems in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the item list to update items in
        updateRequests - the item update requests
        context - the context of the request
        Returns:
        a list of updated items
      • deleteItemListItems

        public void deleteItemListItems​(@NonNull
                                        @NonNull String listId,
                                        @NonNull
                                        @NonNull Collection<String> itemIds,
                                        @NonNull
                                        @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                        @Nullable
                                        com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Description copied from interface: ItemListItemManagementService
        Deletes item list items from a list.
        Specified by:
        deleteItemListItems in interface ItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>
        Parameters:
        listId - the ID of the list to delete from
        itemIds - the IDs of the items to delete
        customerRef - Information about the owning customer
        context - the context of the request
      • handleZeroQuantityItems

        protected List<I> handleZeroQuantityItems​(@NonNull
                                                  @NonNull Stream<I> items,
                                                  @NonNull
                                                  @NonNull String listId,
                                                  @NonNull
                                                  @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                                  @Nullable
                                                  com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Handles item updates with a quantity of zero by deleting the items and filtering them from the results.
        Parameters:
        items - the stream of items to handle (can include items of any quantity)
        listId - the ID of the list the items belong to
        customerRef - the reference to the customer performing the update operation
        context - the context of the request
        Returns:
        a list of non-zero quantity items
      • hasZeroQuantity

        protected boolean hasZeroQuantity​(@NonNull
                                          I item)
        Tells if the given item has a zero quantity.
        Parameters:
        item - the item to test
        Returns:
        true if the quantity of the item is zero, false otherwise
      • handleAddMerge

        protected List<I> handleAddMerge​(@NonNull
                                         @NonNull String itemListId,
                                         @NonNull
                                         @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef,
                                         @NonNull
                                         @NonNull List<I> addedItems,
                                         @NonNull
                                         @NonNull List<MergeItemPair<I>> mergePairs,
                                         @Nullable
                                         com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
        Handles adding and merging items into an itemlist.
        Parameters:
        itemListId - the id of the itemlist to add to
        customerRef - the customerRef the itemlist belongs to
        addedItems - the items to add to the itemlist
        mergePairs - the items to merge into the itemlist
        context - the context of the request
        Returns:
        the list of all added and merged itemlistitems
      • getItemListProvider

        protected ItemListProvider<com.broadleafcommerce.cart.client.domain.ItemList> getItemListProvider()
      • getSecurityService

        protected ItemListSecurityService<com.broadleafcommerce.cart.client.domain.ItemListAccessRule> getSecurityService()
      • getTypeFactory

        protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()