com.softslate.commerce.businessobjects.core
Class BaseBusinessProcessor

java.lang.Object
  extended by com.softslate.commerce.businessobjects.core.BaseBusinessObject
      extended by com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
All Implemented Interfaces:
BusinessObject, BusinessProcessor
Direct Known Subclasses:
AbstractNotificationProcessor, BasePaymentProcessor, BaseShippingProcessor, BaseTaxProcessor, BasicAdministratorProcessor, BasicAdminPaymentProcessor, BasicAttributeProcessor, BasicCartDiscountProcessor, BasicCartProcessor, BasicCategoryProcessor, BasicCategorySettingProcessor, BasicCountryProcessor, BasicCustomerAddressProcessor, BasicCustomerProcessor, BasicDiscountProcessor, BasicDiscountRangeProcessor, BasicImportExportProcessor, BasicInventoryProcessor, BasicLuceneProcessor, BasicManufacturerProcessor, BasicOptionProcessor, BasicOrderDeliveryProcessor, BasicOrderDiscountProcessor, BasicOrderItemAttributeProcessor, BasicOrderItemProcessor, BasicOrderProcessor, BasicProductProcessor, BasicProductSettingProcessor, BasicRoleProcessor, BasicShippingMethodProcessor, BasicShippingRateProcessor, BasicShippingRuleProcessor, BasicShippingRuleRangeProcessor, BasicSKUProcessor, BasicStateProcessor, BasicTaxRateProcessor, GoogleCheckoutProcessor, InstallerProcessor, MerchantCalculationCallbackProcessorImpl, SettingBean, SettingsBean, UpgradesProcessor

public abstract class BaseBusinessProcessor
extends BaseBusinessObject
implements BusinessProcessor

Abstract superclass for all processing objects in the business layer. (Classes that handle business processing are all named with the suffix "Processor".)

The methods provided here allow subclasses to communicate with other elements of the application. In particular, retrieve general settings from the database (using getSettings()), retrive application settings from the /WEB-INF/classes/appSettings.properties file (using getAppSettings(), retrive application components from the /WEB-INF/classes/appComponents.properties file (using getAppComponents(), retrieve user information (using getUser()), create data access objects (using getDaoFactory()) and create other business objects (using getBusinessObjectFactory()).

Author:
David Tobey

Field Summary
private  java.util.Properties appComponents
           
private  java.util.Properties appSettings
           
private  BusinessObjectFactory businessObjectFactory
           
private  DAOFactory daoFactory
           
(package private) static org.apache.commons.logging.Log log
           
private  Settings settings
           
private  User user
           
private  BusinessObjectUtils utils
           
 
Constructor Summary
BaseBusinessProcessor()
           
 
Method Summary
 java.lang.String formatDateTime(java.util.Date dateTime)
          Formats a Date object into a string suitable for storage in the database.
 java.lang.String formatPrice(double rawPrice, java.lang.String currencyCode, java.util.Locale locale)
          Formats a double into a string suitable for displaying the double as a price.
 java.util.Properties getAppComponents()
          Retrieves this object's application components.
 java.util.Properties getAppSettings()
          Retrieves the application settings previously set for this object.
 java.util.Collection getAttributeIDs(java.util.Collection orderItems)
          Constructs a Collection of Integers composed of the attributeIDs of the OrderItemAttriubtes associated with a given Collection of OrderItem objects.
 BusinessObjectFactory getBusinessObjectFactory()
          Retrieves the BusinessObjectFactory previously set for this business object.
 DAOFactory getDaoFactory()
          Retrieves the DAOFactory previously set for this business object.
 java.util.Collection getProductIDs(java.util.Collection orderItems)
          Constructs a Collection of Integers composed of the productIDs of a given Collection of OrderItem objects.
 Settings getSettings()
          Retrieves the Settings instance previously set for this business object.
 User getUser()
          Retrieves the User previously set for this business object.
 void initialize(java.util.Map transferMap)
          Initializes this business object by copying incoming parameters into its properties.
 java.util.Collection loadMatchingSkus(java.util.Collection orderItems, java.util.Collection productIDs, java.util.Collection attributeIDs)
          Given a Collection of productIDs and OrderItem objects, construct a Collection of Maps composed of all of the SKUs that match the order items.
 java.util.Date parseDateTime(java.lang.String dateTime)
          Parses a string into a Date object.
 java.util.Map parseResponseData(java.lang.String response)
          Parses a query string of name value pairs into a Map.
 java.lang.String prepareRequestData(java.util.Map params, boolean urlEncode)
          Prepares a url-encoded string for use with an HTTP request, given a map of the request's parameters.
 java.lang.String sendHTTPPost(java.lang.String urlString, java.lang.String postData, boolean followRedirect)
          Sends an HTTP request using the POST method to a given URL.
 void setAppComponents(java.util.Properties appComponents)
          Sets this object's application components.
 void setAppSettings(java.util.Properties appSettings)
          Sets this object's application settings.
 void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory)
          Sets this business object's BusinessObjectFactory.
 void setDaoFactory(DAOFactory daoFactory)
          Sets this business object's DAOFactory.
 void setSettings(Settings settings)
          Sets this business object's Settings instance.
 void setUser(User user)
          Sets this business object's User.
 BusinessObjectUtils utils()
          Retrieves a utility object that provides useful methods for business objects.
 
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

settings

private Settings settings

appSettings

private java.util.Properties appSettings

appComponents

private java.util.Properties appComponents

user

private User user

daoFactory

private DAOFactory daoFactory

businessObjectFactory

private BusinessObjectFactory businessObjectFactory

utils

private BusinessObjectUtils utils
Constructor Detail

BaseBusinessProcessor

public BaseBusinessProcessor()
Method Detail

getSettings

public Settings getSettings()
Description copied from interface: BusinessProcessor
Retrieves the Settings instance previously set for this business object. The Settings object holds general settings stored in the sscSetting database table.

Specified by:
getSettings in interface BusinessProcessor
Returns:
A Settings object that represents various settings for the system.

setSettings

public void setSettings(Settings settings)
Description copied from interface: BusinessProcessor
Sets this business object's Settings instance. Used by the application's BusinessObjectFactory (through initialize(Map parameters)), to provide the system's Settings to this business object.

Specified by:
setSettings in interface BusinessProcessor
Parameters:
settings - The current Settings for the system, containing various settings to be used by this business object.

getAppSettings

public java.util.Properties getAppSettings()
Description copied from interface: BusinessProcessor
Retrieves the application settings previously set for this object. The application settings are settings for information unique to a given installation, such as the location of files on the server, as opposed to the Settings interface, which stores settings drawn from the database. They are stored in the /WEB-INF/classes/appSettings.properties file under each installation.

Specified by:
getAppSettings in interface BusinessProcessor
Returns:
A Properties object that represents various settings for the application.

setAppSettings

public void setAppSettings(java.util.Properties appSettings)
Description copied from interface: BusinessProcessor
Sets this object's application settings. The application settings are settings for information unique to a given installation, such as the location of files on the server, as opposed to the Settings interface, which stores settings drawn from the database.

Specified by:
setAppSettings in interface BusinessProcessor
Parameters:
appSettings - The current application settings in effect for the system.

getAppComponents

public java.util.Properties getAppComponents()
Description copied from interface: BusinessProcessor
Retrieves this object's application components. The components identify which Java classes implement the various interfaces used by the system. They are stored in the /WEB-INF/classes/appComponents.properties file under each installation.

Specified by:
getAppComponents in interface BusinessProcessor
Returns:
A Properties object that represents component settings for the application.

setAppComponents

public void setAppComponents(java.util.Properties appComponents)
Description copied from interface: BusinessProcessor
Sets this object's application components. The components identify which Java classes implement the various interfaces used by the system.

Specified by:
setAppComponents in interface BusinessProcessor
Parameters:
appComponents - The current application components in effect for the system.

getUser

public User getUser()
Description copied from interface: BusinessProcessor
Retrieves the User previously set for this business object. In the struts layer, this property corresponds to the "user" attribute of each session.

Specified by:
getUser in interface BusinessProcessor
Returns:
A User object that represents the user currently accessing the system.

setUser

public void setUser(User user)
Description copied from interface: BusinessProcessor
Sets this business object's User. Used by the application's BusinessObjectFactory (through initialize(Map parameters)), to provide the current User accessing the system to this business object. In the struts layer, this property corresponds to the "user" attribute of each session.

Specified by:
setUser in interface BusinessProcessor
Parameters:
user - The current User accessing the system, for which business processing is to be performed by this business object.

getDaoFactory

public DAOFactory getDaoFactory()
Description copied from interface: BusinessProcessor
Retrieves the DAOFactory previously set for this business object.

Specified by:
getDaoFactory in interface BusinessProcessor
Returns:
A DAOFactory object that can be used to create data access objects.

setDaoFactory

public void setDaoFactory(DAOFactory daoFactory)
Description copied from interface: BusinessProcessor
Sets this business object's DAOFactory. Used by the application's BusinessObjectFactory (through initialize(Map parameters)), to provide the current DAOFactory for the system to this business object.

Specified by:
setDaoFactory in interface BusinessProcessor
Parameters:
daoFactory - The current DAOFactory for the system, which will allow this business object to create data access objects.

initialize

public void initialize(java.util.Map transferMap)
                throws java.lang.Exception
Description copied from interface: BusinessObject
Initializes this business object by copying incoming parameters into its properties. This method is used by BusinessObjectFactory immediately after object creation.

Specified by:
initialize in interface BusinessObject
Overrides:
initialize in class BaseBusinessObject
Parameters:
transferMap - A Map containing objects such as the application's DAOFactory, Settings,User, and BusinessObjectFactory.
Throws:
java.lang.Exception

getBusinessObjectFactory

public BusinessObjectFactory getBusinessObjectFactory()
Description copied from interface: BusinessProcessor
Retrieves the BusinessObjectFactory previously set for this business object.

Specified by:
getBusinessObjectFactory in interface BusinessProcessor
Returns:
A BusinessObjectFactory object that can be used to create other business objects.

setBusinessObjectFactory

public void setBusinessObjectFactory(BusinessObjectFactory businessObjectFactory)
Description copied from interface: BusinessProcessor
Sets this business object's BusinessObjectFactory. Used by the application's BusinessObjectFactory (through initialize(Map parameters)), to provide itself to this business object, so that it can create other business objects in turn.

Specified by:
setBusinessObjectFactory in interface BusinessProcessor
Parameters:
businessObjectFactory - The current BusinessObjectFactory for the system, allowing this business object to create other business objects.

utils

public BusinessObjectUtils utils()
Description copied from interface: BusinessProcessor
Retrieves a utility object that provides useful methods for business objects.

Specified by:
utils in interface BusinessProcessor
Returns:
An implementation of BusinessObjectUtils.

formatDateTime

public java.lang.String formatDateTime(java.util.Date dateTime)
Formats a Date object into a string suitable for storage in the database.

Parameters:
dateTime -
Returns:
a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.

parseDateTime

public java.util.Date parseDateTime(java.lang.String dateTime)
Parses a string into a Date object.

Parameters:
dateTime - a String in the form of "yyyy-MM-dd HH:mm:ss:SSS" suitable for storage in the database.
Returns:
a Date object.

formatPrice

public java.lang.String formatPrice(double rawPrice,
                                    java.lang.String currencyCode,
                                    java.util.Locale locale)
Formats a double into a string suitable for displaying the double as a price.

Parameters:
rawPrice -
currencyCode -
locale -
Returns:
a String suitable for displaying the double as a price.

prepareRequestData

public java.lang.String prepareRequestData(java.util.Map params,
                                           boolean urlEncode)
                                    throws java.lang.Exception
Prepares a url-encoded string for use with an HTTP request, given a map of the request's parameters.

Parameters:
params - A Map of key-value String pairs representing the parameters of the request.
Returns:
A String representing a valid URL-encoded query string.
Throws:
java.lang.Exception

parseResponseData

public java.util.Map parseResponseData(java.lang.String response)
                                throws java.lang.Exception
Parses a query string of name value pairs into a Map.

Parameters:
response - A String key-value pairs in the form of a URL query string
Returns:
A Map representing the query string.
Throws:
java.lang.Exception

sendHTTPPost

public java.lang.String sendHTTPPost(java.lang.String urlString,
                                     java.lang.String postData,
                                     boolean followRedirect)
                              throws java.lang.Exception
Sends an HTTP request using the POST method to a given URL.

Parameters:
urlString - The URL to send the request to.
postData - A String representing a valid URL-encoded query string.
followRedirect - A boolean indicating whether redirects should be followed.
Returns:
A String representing the server's response, or the Location header if redirects are not to be followed.
Throws:
java.lang.Exception

getProductIDs

public java.util.Collection getProductIDs(java.util.Collection orderItems)
                                   throws java.lang.Exception
Constructs a Collection of Integers composed of the productIDs of a given Collection of OrderItem objects.

Parameters:
orderItems -
Returns:
A Collection of Integers representing the productIDs of the order items.
Throws:
java.lang.Exception

getAttributeIDs

public java.util.Collection getAttributeIDs(java.util.Collection orderItems)
                                     throws java.lang.Exception
Constructs a Collection of Integers composed of the attributeIDs of the OrderItemAttriubtes associated with a given Collection of OrderItem objects.

Parameters:
orderItems -
Returns:
A Collection of Integers representing the attributeIDs of the order items.
Throws:
java.lang.Exception

loadMatchingSkus

public java.util.Collection loadMatchingSkus(java.util.Collection orderItems,
                                             java.util.Collection productIDs,
                                             java.util.Collection attributeIDs)
                                      throws java.lang.Exception
Given a Collection of productIDs and OrderItem objects, construct a Collection of Maps composed of all of the SKUs that match the order items. Used by inventory and discount processing to handle inventory and discounts particular to given SKUs.

Parameters:
orderItems -
productIDs -
Returns:
A Collection of Maps, each representing a SKU that matches one of the order items.
Throws:
java.lang.Exception


Copyright ? SoftSlate, LLC 2003?2005