com.softslate.commerce.businessobjects.order
Class BasicInventoryProcessor

java.lang.Object
  extended by com.softslate.commerce.businessobjects.core.BaseBusinessObject
      extended by com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
          extended by com.softslate.commerce.businessobjects.order.BasicInventoryProcessor
All Implemented Interfaces:
BusinessObject, BusinessProcessor, InventoryProcessor

public class BasicInventoryProcessor
extends BaseBusinessProcessor
implements InventoryProcessor

Processes business logic having to do with SKUs and inventory levels. BasicInventoryProcessor is the default implementation of the InventoryProcessor interface for the application.

Author:
David Tobey
See Also:
InventoryProcessor

Field Summary
(package private) static org.apache.commons.logging.Log log
           
 java.lang.String[] productSettingsKeys
          The settings keys dealing with inventory.
 
Constructor Summary
BasicInventoryProcessor()
           
 
Method Summary
 java.util.Map loadProductSettings(java.util.Collection orderItems, java.util.Collection productIDs)
          Loads inventory settings for each of the products corresponding to a given Collection of OrderItems.
 java.util.Map processAddItems(java.util.Collection orderItems)
          Processes inventory as new OrderItems are added to a user's cart.
 java.util.Map processInventory(java.util.Collection orderItems, java.util.Map productSettings, java.util.Collection matchingSkus, java.lang.String behavior)
          Generically processes inventory, returning a Map with information about items and skus.
 java.util.Map processOnCheckout(java.util.Map parameters)
          Checks inventory for a user's cart during checkout.
 java.util.Map processOrderComplete(java.util.Map parameters)
          Processes inventory for a user's cart as an order is completed.
 
Methods inherited from class com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
formatDateTime, formatPrice, getAppComponents, getAppSettings, getAttributeIDs, getBusinessObjectFactory, getDaoFactory, getProductIDs, getSettings, getUser, initialize, loadMatchingSkus, parseDateTime, parseResponseData, prepareRequestData, sendHTTPPost, setAppComponents, setAppSettings, setBusinessObjectFactory, setDaoFactory, setSettings, setUser, utils
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

static org.apache.commons.logging.Log log

productSettingsKeys

public java.lang.String[] productSettingsKeys
The settings keys dealing with inventory. These keys correspond both to global settings stored in the sscSetting database table, and product-specific settings defined in the sscProductSetting table.

Constructor Detail

BasicInventoryProcessor

public BasicInventoryProcessor()
Method Detail

processAddItems

public java.util.Map processAddItems(java.util.Collection orderItems)
                              throws java.lang.Exception
Description copied from interface: InventoryProcessor
Processes inventory as new OrderItems are added to a user's cart. Decrements inventory levels (in the memory objects) if products are set to be decremented upon being added to a cart. (Objects are updated in the database by BasicCartProcessor.processAddItems(Collection), which is what calls this method.)

The default implementation of this method does the following:

  1. Loads the inventory settings in effect for each of the products corresponding to the OrderItems being added.
  2. Calls BaseBusinessProcessor.loadMatchingSkus(Collection, Collection, Collection) to load the skus corresponding to the OrderItems.
  3. Calls InventoryProcessor.processInventory(Collection, Map, Collection, String) to process the inventory.
  4. Removes any order items that were rejected because one of their corresponding SKUs are out of stock.
  5. Adjusts the quantities of any order items whose quantities exceed the quantity in stock.
  6. Calls CartProcessor.processQuantities(Collection) to update the cart with the new quantities.

Specified by:
processAddItems in interface InventoryProcessor
Parameters:
orderItems - The Collection of OrderItem objects being added to the cart.
Returns:
A Map containing results of the processing. In the default implementation, the Map is the same as the one returned by InventoryProcessor.processInventory(Collection, Map, Collection, String) (which this method calls).
Throws:
java.lang.Exception
See Also:
BasicCartProcessor.processAddItems(Collection)

processOnCheckout

public java.util.Map processOnCheckout(java.util.Map parameters)
                                throws java.lang.Exception
Description copied from interface: InventoryProcessor
Checks inventory for a user's cart during checkout. This step takes places as the user passes through checkout, but before submitting payment information. Makes sure that if products are to be decremented on checkout, no skus are out of stock. Inventory does not get decremented with this method.

The default implementation of this method largely follows the same steps as InventoryProcessor.processAddItems(Collection).

Specified by:
processOnCheckout in interface InventoryProcessor
Parameters:
parameters - The most recent parameters submitted by the user.
Returns:
A Map containing results of the processing. In the default implementation, the Map is the same as the one returned by InventoryProcessor.processInventory(Collection, Map, Collection, String) (which this method calls).
Throws:
java.lang.Exception
See Also:
CheckoutAction.processInventoryDiscountCheck(BaseForm)

processOrderComplete

public java.util.Map processOrderComplete(java.util.Map parameters)
                                   throws java.lang.Exception
Description copied from interface: InventoryProcessor
Processes inventory for a user's cart as an order is completed. This step takes place after a successful payment processing. Inventory is decremented at this point for products set to be decremented on checkout.

Specified by:
processOrderComplete in interface InventoryProcessor
Parameters:
parameters - The most recent parameters submitted by the user.
Returns:
A Map containing results of the processing. In the default implementation, the Map is the same as the one returned by InventoryProcessor.processInventory(Collection, Map, Collection, String) (which this method calls).
Throws:
java.lang.Exception

loadProductSettings

public java.util.Map loadProductSettings(java.util.Collection orderItems,
                                         java.util.Collection productIDs)
                                  throws java.lang.Exception
Loads inventory settings for each of the products corresponding to a given Collection of OrderItems. Inventory settings are defined globally in the sscSetting database table. They can be overridden product-by-product by settings defined in the sscProductSettings table. This method resolves which products are set to override the global settings, and the resulting Map reflects the overridden settings.

Parameters:
orderItems - A Collection of OrderItem objects being processed.
productIDs -
Returns:
A Map containing the settings. The keys of the Map are the string in the productSettingsKeys array.
Throws:
java.lang.Exception

processInventory

public java.util.Map processInventory(java.util.Collection orderItems,
                                      java.util.Map productSettings,
                                      java.util.Collection matchingSkus,
                                      java.lang.String behavior)
                               throws java.lang.Exception
Description copied from interface: InventoryProcessor
Generically processes inventory, returning a Map with information about items and skus. Does not change the order items being checked.

Specified by:
processInventory in interface InventoryProcessor
Parameters:
orderItems - A Collection of OrderItem objects being processed.
productSettings - A Map of Collections representing the inventory settings in effect for the products in the OrderItems.
matchingSkus - A Collection of Maps representing all the SKUs associated with the OrderItems.
behavior - A String representing when inventory is to be decremented. Either "onAddingToCart" or "onOrderCompletion".
Returns:
A Map containing results of the processing. In the default implementation, the keys of the Map include:
  • skusToDecrement: A Collection of Maps, each representing a SKU that is to be decremented as result of the processing.
  • decrementedSKUs: A Map whose keys are OrderItem objects and whose values are comma-separated Strings representing the ids of the SKU objects corresponding to the OrderItem that are to be decremented. (Used to populate the OrderItem's descrementedSKUs property.)
  • rejectedOrderItems: A Collection of OrderItem objects that have been removed from the user's cart due to their being out of stock.
  • adjustedQuantities: A Map whose keys are OrderItem objects and whose values are Strings representing the OrderItems new quantity, after being adjusted because not enough inventory is available.
  • newOOSSKUs: A Collection of Maps, each representing a SKU that has just reached its out of stock level as result of the processing.
  • productsToDeactivate: A Collection of Strings, each representing the id of a Product object that should now be deactivated because a SKU associated with it has just gone out of stock.
  • lowStockEmails: A Collection of Maps, each representing a SKU that has reached its 'low stock' level, and should trigger a low stock email as a result.
Throws:
java.lang.Exception


Copyright ? SoftSlate, LLC 2003?2005