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

java.lang.Object
com.broadleafcommerce.cartoperation.service.DefaultItemListItemManagementService<I>
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 Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final String
    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.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DefaultItemListItemManagementService(ItemListProvider<com.broadleafcommerce.cart.client.domain.ItemList> itemListProvider, ItemListItemProvider<I> itemProvider, ItemListSecurityService<com.broadleafcommerce.cart.client.domain.ItemListAccessRule> securityService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, ItemListItemMergingService<I> mergingService)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    createItemListItems(@NonNull String listId, @NonNull Collection<I> createRequests, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Creates item list items.
    void
    deleteItemListItems(@NonNull String listId, @NonNull Collection<String> itemIds, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Deletes item list items from a list.
    org.springframework.data.domain.Page<I>
    getItemListItemPage(@NonNull String listId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, org.springframework.data.domain.Pageable pageable, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Gets a page of item list items.
    getItemListItems(@NonNull String listId, @NonNull Collection<String> itemIds, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Gets specific item list items by their IDs.
    protected ItemListProvider<com.broadleafcommerce.cart.client.domain.ItemList>
     
     
     
    protected ItemListSecurityService<com.broadleafcommerce.cart.client.domain.ItemListAccessRule>
     
    protected com.broadleafcommerce.common.extension.TypeFactory
     
    protected List<I>
    handleAddMerge(@NonNull String itemListId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, @NonNull List<I> addedItems, @NonNull List<MergeItemPair<I>> mergePairs, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Handles adding and merging items into an itemlist.
    protected List<I>
    handleZeroQuantityItems(@NonNull Stream<I> items, @NonNull String listId, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, 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.
    protected boolean
    Tells if the given item has a zero quantity.
    replaceItemListItems(@NonNull String listId, @NonNull Collection<I> updateRequests, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Replaces item list items.
    updateItemListItems(@NonNull String listId, @NonNull Collection<I> updateRequests, @NonNull com.broadleafcommerce.order.common.domain.CustomerRef customerRef, com.broadleafcommerce.data.tracking.core.context.ContextInfo context)
    Updates item list items.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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:
  • Constructor Details

  • Method Details

    • 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()
    • getItemProvider

      protected ItemListItemProvider<I> getItemProvider()
    • getSecurityService

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

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

      protected ItemListItemMergingService<I> getMergingService()