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
FieldsModifier and TypeFieldDescriptionprotected static final StringAttribute 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
ConstructorsConstructorDescriptionDefaultItemListItemManagementService(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 TypeMethodDescriptioncreateItemListItems(@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.voiddeleteItemListItems(@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 ItemListItemProvider<I>protected ItemListItemMergingService<I>protected ItemListSecurityService<com.broadleafcommerce.cart.client.domain.ItemListAccessRule>protected com.broadleafcommerce.common.extension.TypeFactoryhandleAddMerge(@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.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 booleanhasZeroQuantity(I item) 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.
-
Field Details
-
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
-
DefaultItemListItemManagementService
public 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 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:ItemListItemManagementServiceGets a page of item list items.- Specified by:
getItemListItemPagein interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the item list to fetch items fromcustomerRef- Information about the owning customerpageable- the page informationcontext- 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:ItemListItemManagementServiceGets specific item list items by their IDs.- Specified by:
getItemListItemsin interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the item list to fetch items fromitemIds- the IDs of the items to findcustomerRef- Information about the owning customercontext- 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:ItemListItemManagementServiceCreates item list items.- Specified by:
createItemListItemsin interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the item list to create the items forcreateRequests- the item creation requestscustomerRef- Information about the owning customercontext- 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:ItemListItemManagementServiceReplaces item list items.- Specified by:
replaceItemListItemsin interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the item list to replace items inupdateRequests- the item update requestscustomerRef- Information about the owning customercontext- 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:ItemListItemManagementServiceUpdates item list items.- Specified by:
updateItemListItemsin interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the item list to update items inupdateRequests- the item update requestscontext- 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:ItemListItemManagementServiceDeletes item list items from a list.- Specified by:
deleteItemListItemsin interfaceItemListItemManagementService<I extends com.broadleafcommerce.cart.client.domain.ItemListItem>- Parameters:
listId- the ID of the list to delete fromitemIds- the IDs of the items to deletecustomerRef- Information about the owning customercontext- 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 tocustomerRef- the reference to the customer performing the update operationcontext- the context of the request- Returns:
- a list of non-zero quantity items
-
hasZeroQuantity
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 tocustomerRef- the customerRef the itemlist belongs toaddedItems- the items to add to the itemlistmergePairs- the items to merge into the itemlistcontext- the context of the request- Returns:
- the list of all added and merged itemlistitems
-
getItemListProvider
-
getItemProvider
-
getSecurityService
protected ItemListSecurityService<com.broadleafcommerce.cart.client.domain.ItemListAccessRule> getSecurityService() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getMergingService
-