com.softslate.commerce.businessobjects.order
Class BasicCartProcessor

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.BasicCartProcessor
All Implemented Interfaces:
BusinessObject, BusinessProcessor, CartProcessor

public class BasicCartProcessor
extends BaseBusinessProcessor
implements CartProcessor

Processes business logic having to do with a user's cart. BasicCartProcessor is the default implementation of the CartProcessor interface for the application.

Author:
David Tobey
See Also:
CartProcessor

Field Summary
static java.lang.String addItemStatus
           
static java.lang.String addressAddedStatus
           
static java.lang.String corruptedStatus
           
static java.lang.String initializedStatus
           
(package private) static org.apache.commons.logging.Log log
           
static java.lang.String pendingStatus
           
static java.lang.String receivedStatus
           
 boolean skipDiscountsAndShipping
           
 
Constructor Summary
BasicCartProcessor()
           
 
Method Summary
 java.lang.String getOrderAttribute(java.util.Map parameters, java.lang.String productCode, java.lang.String attributeCode, int index)
          Retrieves the value submitted for an attribute of a given product, as part of a request to add or edit an item in the user's cart.
 int getOrderItemQuantity(java.util.Map parameters, int index)
          Looks up the submitted quantity of a given product contained in a request to add or edit a user's cart item.
 void initializeCart()
          Initializes a user's cart.
 void initializeCart(java.util.Map parameters)
           
 java.util.Map markOrderComplete(java.util.Map parameters)
          Marks an order as complete at the very end of the checkout process, after payments have been processed.
 java.util.Map postProcessAddItems(java.util.Collection newOrderItems)
           
 java.util.Map processAddItems(java.util.Collection newOrderItems)
          Given a Collection of initialized OrderItem objects, adds the items to the user's cart.
 java.util.Map processAddItems(java.util.Map parameters)
          Processes a request to add items to a user's cart.
 java.util.Map processCheckoutAddresses(java.util.Map parameters)
          Processes a request to add address information to a user's cart.
 java.util.Map processEditItem(java.util.Map parameters)
          Processes a request to edit a given item in a user's cart.
 void processItemAttribute(OrderItem orderItem, Attribute attribute, Option option, java.lang.String attributeValue)
          Adds an attribute to a given OrderItem.
 void processItemAttributes(java.util.Map parameters, Product product, java.util.Collection missingAttributes, java.util.Collection newOrderItems, OrderItem orderItem, int index)
          Finds the attributes identified in the incoming parameters and creates OrderItemAttributes to be added to the OrderItem.
 java.util.Map processOrderComplete(java.util.Map parameters)
          Handles processing at the end of the checkout process, after payments have been processed.
 void processQuantities(java.util.Collection newOrderItems)
          Given a Collection of OrderItems in the user's cart whose quantities have been set, updates the totals and weights of each OrderItem based on the (new) quantity.
 java.util.Map processRemoveItem(OrderItem orderItem)
          Removes a given OrderItem from the user's cart, updating the cart totals in the process.
 void processTotalsAndFormatting(java.util.Collection orderItems)
          Given a Collection of OrderItems in the user's cart whose totals have been set, updates the totals and weights of each OrderDelivery and Order they are under, and applies formatting to the totals.
 void updateOrderAndDeliveryTotals(OrderDelivery orderDelivery, OrderItem orderItem)
          Given an OrderItem, updates the totals of the user's Order and the OrderDelivery the OrderItem is under.
 
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, updateOrderTotals, updateOrderTotals, utils
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.softslate.commerce.businessobjects.core.BusinessObject
initialize
 

Field Detail

log

static org.apache.commons.logging.Log log

addItemStatus

public static java.lang.String addItemStatus

initializedStatus

public static java.lang.String initializedStatus

addressAddedStatus

public static java.lang.String addressAddedStatus

pendingStatus

public static java.lang.String pendingStatus

receivedStatus

public static java.lang.String receivedStatus

corruptedStatus

public static java.lang.String corruptedStatus

skipDiscountsAndShipping

public boolean skipDiscountsAndShipping
Constructor Detail

BasicCartProcessor

public BasicCartProcessor()
Method Detail

processAddItems

public java.util.Map processAddItems(java.util.Map parameters)
                              throws java.lang.Exception
Description copied from interface: CartProcessor
Processes a request to add items to a user's cart. If the user's cart has not been initialized, this method initializes it first by calling CartProcessor.initializeCart() to create a new instance of Order in the User instance for the user. It then adds an OrderDelivery instance under the Order and OrderItem instances under the OrderDelivery.

This method manages the parsing of incoming parameters that identify the products, quantities, and attribute values of the items to be added. It populates OrderItem objects with the incoming information and then hands off the processing to the CartProcessor.processAddItems(Collection) method.

The incoming Map must have the following keys:

Specified by:
processAddItems in interface CartProcessor
Parameters:
parameters - A Map representing the items and attributes being added to the user's cart.
Returns:
A Map representing the results of the processing. The Map may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs".
Throws:
java.lang.Exception
See Also:
CartAddAction

processAddItems

public java.util.Map processAddItems(java.util.Collection newOrderItems)
                              throws java.lang.Exception
Description copied from interface: CartProcessor
Given a Collection of initialized OrderItem objects, adds the items to the user's cart. Manages the processing of inventory and discounting, updates the user's cart totals, and manages synchronizing the objects with the database.

Specified by:
processAddItems in interface CartProcessor
Parameters:
newOrderItems - The Collection containing the OrderItem objects to be added to the user's cart.
Returns:
A Map containing information on the results of the processing. The Map may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs".
Throws:
java.lang.Exception

initializeCart

public void initializeCart()
                    throws java.lang.Exception
Description copied from interface: CartProcessor
Initializes a user's cart. Creates new instances of Order and OrderDelivery representing a user's cart. Sets the current User object's order property with the newly created Order. Synchronizes the new cart with the database.

Specified by:
initializeCart in interface CartProcessor
Throws:
java.lang.Exception

initializeCart

public void initializeCart(java.util.Map parameters)
                    throws java.lang.Exception
Throws:
java.lang.Exception

processQuantities

public void processQuantities(java.util.Collection newOrderItems)
                       throws java.lang.Exception
Description copied from interface: CartProcessor
Given a Collection of OrderItems in the user's cart whose quantities have been set, updates the totals and weights of each OrderItem based on the (new) quantity.

Specified by:
processQuantities in interface CartProcessor
Parameters:
newOrderItems - The Collection containing the OrderItem objects whose quantities and totals are to be set.
Throws:
java.lang.Exception

processTotalsAndFormatting

public void processTotalsAndFormatting(java.util.Collection orderItems)
                                throws java.lang.Exception
Description copied from interface: CartProcessor
Given a Collection of OrderItems in the user's cart whose totals have been set, updates the totals and weights of each OrderDelivery and Order they are under, and applies formatting to the totals.

Specified by:
processTotalsAndFormatting in interface CartProcessor
Parameters:
orderItems - The OrderItems whose totals must be added to the order and order delivery.
Throws:
java.lang.Exception

updateOrderAndDeliveryTotals

public void updateOrderAndDeliveryTotals(OrderDelivery orderDelivery,
                                         OrderItem orderItem)
Given an OrderItem, updates the totals of the user's Order and the OrderDelivery the OrderItem is under. Calculates new totals for the quantity, price total, and weight total.

Parameters:
orderDelivery - The order delivery that contains the new OrderItem.
orderItem - The newly-added order item whose price must be added to the order's total and the delivery's total.

getOrderAttribute

public java.lang.String getOrderAttribute(java.util.Map parameters,
                                          java.lang.String productCode,
                                          java.lang.String attributeCode,
                                          int index)
                                   throws java.lang.Exception
Retrieves the value submitted for an attribute of a given product, as part of a request to add or edit an item in the user's cart. Uses the orderAttributes property (which is a HashMap) of the incoming Map to look up the attribute's value. The key for the attribute is formed like so: productCode|attributeCode.

Parameters:
parameters - A Map representing the items and properties submitted to add or edit items in the user's cart.
productCode - The code of the product corresponding to the attribute.
attributeCode - The code of the attribute whose value is being looked up.
index - The index of the submitted array of product codes corresponding to the item being added.
Returns:
The submitted value of the attribute corresponding to the attibuteCode, or null, if the attribute is not found.
Throws:
java.lang.Exception

processItemAttributes

public void processItemAttributes(java.util.Map parameters,
                                  Product product,
                                  java.util.Collection missingAttributes,
                                  java.util.Collection newOrderItems,
                                  OrderItem orderItem,
                                  int index)
                           throws java.lang.Exception
Finds the attributes identified in the incoming parameters and creates OrderItemAttributes to be added to the OrderItem.

Parameters:
parameters -
product -
missingAttributes -
newOrderItems -
orderItem -
index -
Throws:
java.lang.Exception

processItemAttribute

public void processItemAttribute(OrderItem orderItem,
                                 Attribute attribute,
                                 Option option,
                                 java.lang.String attributeValue)
                          throws java.lang.Exception
Adds an attribute to a given OrderItem. Adds the attribute's total and weight to the order item's.

Parameters:
orderItem - The OrderItem that is having an attribute added to it.
attribute - The Attribute being added to the order item
option - The Option of the above attribute that is being added to the order item. If no option is relevant, this parameter may be null.
attributeValue - The value of the attribute being added to the OrderItem. Corresponds to the option's code, or a free form value if no option is relevant.
Throws:
java.lang.Exception

getOrderItemQuantity

public int getOrderItemQuantity(java.util.Map parameters,
                                int index)
                         throws java.lang.Exception
Looks up the submitted quantity of a given product contained in a request to add or edit a user's cart item. Uses the orderProductQuantities property (which is a String[]) of the incoming Map to look up the value.

Parameters:
parameters - A Map representing the items and properties being added or edited.
index - The index of the submitted array of product quantities corresponding to the item being added.
Returns:
An int representing the submitted quantity of the user's cart item
Throws:
java.lang.Exception

processEditItem

public java.util.Map processEditItem(java.util.Map parameters)
                              throws java.lang.Exception
Description copied from interface: CartProcessor
Processes a request to edit a given item in a user's cart. The incoming Map must have the same keys required by CartProcessor.processAddItems(Map), plus a key named orderItem, which identifies the order item being edited.

Specified by:
processEditItem in interface CartProcessor
Parameters:
parameters - A Map identifying the item being edited and specifying the item's new properties.
Returns:
A Map containing information on the results of the processing. The Map may have one or more of the following keys related to inventory processing: "lowStockEmails", "missingAttributes", "rejectedOrderItems", "adjustedOrderItems", and "newOOSSKUs".
Throws:
java.lang.Exception
See Also:
CartItemEditAction

processRemoveItem

public java.util.Map processRemoveItem(OrderItem orderItem)
                                throws java.lang.Exception
Description copied from interface: CartProcessor
Removes a given OrderItem from the user's cart, updating the cart totals in the process.

Specified by:
processRemoveItem in interface CartProcessor
Parameters:
orderItem - The OrderItem being removed.
Throws:
java.lang.Exception

processCheckoutAddresses

public java.util.Map processCheckoutAddresses(java.util.Map parameters)
                                       throws java.lang.Exception
Description copied from interface: CartProcessor
Processes a request to add address information to a user's cart. Originates from the checkout process in the Struts layer.

Specified by:
processCheckoutAddresses in interface CartProcessor
Parameters:
parameters - A Map representing the address information of the current user.
Throws:
java.lang.Exception
See Also:
CheckoutAction.processCheckoutAddresses(BaseForm)

processOrderComplete

public java.util.Map processOrderComplete(java.util.Map parameters)
                                   throws java.lang.Exception
Description copied from interface: CartProcessor
Handles processing at the end of the checkout process, after payments have been processed. Decrements inventory, marks discounts as having been used and updates the order totals.

Specified by:
processOrderComplete in interface CartProcessor
Returns:
A Map representing the results of the processing.
Throws:
java.lang.Exception
See Also:
CheckoutAction.processOrderComplete(BaseForm)

markOrderComplete

public java.util.Map markOrderComplete(java.util.Map parameters)
                                throws java.lang.Exception
Description copied from interface: CartProcessor
Marks an order as complete at the very end of the checkout process, after payments have been processed. Sets the order's completed field with the current time. Sets the user's order with a status of "Received" and assigns an order number to the order. The "Received" status is given to all orders that have been successfully completed by the user. In other words, orders whose payments succeeded.

The order number is an integer given to each completed order, starting at the "orderNumberFloor" database setting (whose default is 1,000).

Specified by:
markOrderComplete in interface CartProcessor
Returns:
A Map representing the results of the processing.
Throws:
java.lang.Exception
See Also:
CheckoutAction.processOrderComplete(BaseForm)

postProcessAddItems

public java.util.Map postProcessAddItems(java.util.Collection newOrderItems)
                                  throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © SoftSlate, LLC 2003–2005