Class BaseBusinessProcessor
java.lang.Object
com.softslate.commerce.businessobjects.core.BaseBusinessObject
com.softslate.commerce.businessobjects.core.BaseBusinessProcessor
- All Implemented Interfaces:
BusinessObject
,BusinessProcessor
- Direct Known Subclasses:
AbstractJob
,AvaTaxSubscriberImpl
,BaseLuceneProcessor
,BasePaymentProcessor
,BaseShippingProcessor
,BaseTaxProcessor
,BaseTrigger
,BasicAdministratorProcessor
,BasicAdminPaymentProcessor
,BasicAttributeProcessor
,BasicCartDiscountProcessor
,BasicCartProcessor
,BasicCategoryProcessor
,BasicCategorySettingProcessor
,BasicCountryProcessor
,BasicCustomerAddressProcessor
,BasicCustomerProcessor
,BasicCustomerWishListProcessor
,BasicDiscountProcessor
,BasicDiscountRangeProcessor
,com.softslate.emailer.businessobjects.core.BasicEmailerProcessor
,BasicEmailOptOutProcessor
,BasicEmailProcessor
,BasicImportExportProcessor
,BasicInventoryProcessor
,BasicJsonExclusionStrategy
,BasicManufacturerProcessor
,BasicOptionProcessor
,BasicOrderDeliveryProcessor
,BasicOrderDiscountProcessor
,BasicOrderItemAttributeProcessor
,BasicOrderItemProcessor
,BasicOrderProcessor
,BasicOrderSettingProcessor
,BasicOrderShippingRuleProcessor
,BasicProductProcessor
,BasicProductReviewProcessor
,BasicProductSettingProcessor
,BasicRecaptchaProcessor
,BasicRequestLogProcessor
,BasicRoleProcessor
,BasicSalesReportProcessor
,BasicShippingMethodProcessor
,BasicShippingRateProcessor
,BasicShippingRuleProcessor
,BasicShippingRuleRangeProcessor
,BasicSKUProcessor
,BasicStateProcessor
,BasicTaxRateProcessor
,BasicTemplateProcessor
,CapturePaymentSubscriberImpl
,EmailSenderImpl
,EventBusRegistrarImpl
,FedExAddressValidationProcessor
,InstallerProcessor
,InventoryNotificationSubscriberImpl
,LocalFileStorageProcessor
,OrderStatusEmailNotificationSubscriberImpl
,PaypointCallbackProcessor
,QboConnectionProcessorImpl
,QboOrderProcessorImpl
,QboOrderSubscriberImpl
,QboQueryProcessorImpl
,RequestLogBean
,SettingBean
,SettingsBean
,TemplateParserImpl
,UpgradesProcessor
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
FieldsModifier and TypeFieldDescriptionprivate Properties
private Properties
private BusinessObjectFactory
private DAOFactory
private com.google.common.eventbus.EventBus
private com.google.inject.Injector
(package private) static org.apache.commons.logging.Log
private Settings
private User
private BusinessObjectUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionformatDateTime
(Date dateTime) Formats a Date object into a string suitable for storage in the database.formatPrice
(double rawPrice, String currencyCode, Locale locale) Formats a double into a string suitable for displaying the double as a price.Retrieves this object's application components.Retrieves the application settings previously set for this object.getAttributeIDs
(Collection orderItems) Constructs a Collection of Integers composed of the attributeIDs of the OrderItemAttriubtes associated with a given Collection of OrderItem objects.Retrieves theBusinessObjectFactory
previously set for this business object.Retrieves theDAOFactory
previously set for this business object.com.google.common.eventbus.EventBus
Retrieves theEventBus
previously set for this factory.com.google.inject.Injector
Retrieves theInjector
previously set.getProductIDs
(Collection orderItems) Constructs a Collection of Integers composed of the productIDs of a given Collection of OrderItem objects.Retrieves theSettings
instance previously set for this business object.getUser()
Retrieves theUser
previously set for this business object.void
initialize
(Map transferMap) Initializes this business object by copying incoming parameters into its properties.boolean
isProcessorClassActive
(String componentsKey) loadMatchingSkus
(Collection orderItems, Collection productIDs, 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.parseDateTime
(String dateTime) Parses a string into a Date object.parseResponseData
(String response) Parses a query string of name value pairs into a Map.prepareRequestData
(Map params, boolean urlEncode) Prepares a url-encoded string for use with an HTTP request, given a map of the request's parameters.sendHTTPGet
(String urlString, String postData, boolean followRedirect) sendHTTPPost
(String urlString, String postData, boolean followRedirect) Sends an HTTP request using the POST method to a given URL.sendHTTPPost
(String urlString, String postData, boolean followRedirect, Map requestProperties, String inputCharSet, Integer timeoutInSeconds) Sends an HTTP request using the POST method to a given URL.void
setAppComponents
(Properties appComponents) Sets this object's application components.void
setAppSettings
(Properties appSettings) Sets this object's application settings.void
setBusinessObjectFactory
(BusinessObjectFactory businessObjectFactory) Sets this business object'sBusinessObjectFactory
.void
setDaoFactory
(DAOFactory daoFactory) Sets this business object'sDAOFactory
.void
setEventBus
(com.google.common.eventbus.EventBus eventBus) Sets this factory'sEventBus
.void
setInjector
(com.google.inject.Injector injector) Sets this object'sInjector
that can be used to create other objects and inject them with dependencies.void
setSettings
(Settings settings) Sets this business object'sSettings
instance.void
Sets this business object'sUser
.void
void
updateOrderTotals
(boolean subtractGiftCerts) void
updateOrderTotals
(Order order, boolean subtractGiftCerts) Updates the totals of a user's order taking into account taxes and shipping.utils()
Retrieves a utility object that provides useful methods for business objects.
-
Field Details
-
log
static org.apache.commons.logging.Log log -
settings
-
appSettings
-
appComponents
-
user
-
daoFactory
-
businessObjectFactory
-
utils
-
injector
private com.google.inject.Injector injector -
eventBus
private com.google.common.eventbus.EventBus eventBus
-
-
Constructor Details
-
BaseBusinessProcessor
public BaseBusinessProcessor()
-
-
Method Details
-
getSettings
Description copied from interface:BusinessProcessor
Retrieves theSettings
instance previously set for this business object. TheSettings
object holds general settings stored in thesscSetting
database table.- Specified by:
getSettings
in interfaceBusinessProcessor
- Returns:
- A
Settings
object that represents various settings for the system.
-
setSettings
Description copied from interface:BusinessProcessor
Sets this business object'sSettings
instance. Used by the application'sBusinessObjectFactory
(throughinitialize(Map parameters)
), to provide the system'sSettings
to this business object.- Specified by:
setSettings
in interfaceBusinessProcessor
- Parameters:
settings
- The currentSettings
for the system, containing various settings to be used by this business object.
-
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 theSettings
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 interfaceBusinessProcessor
- Returns:
- A
Properties
object that represents various settings for the application.
-
setAppSettings
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 theSettings
interface, which stores settings drawn from the database.- Specified by:
setAppSettings
in interfaceBusinessProcessor
- Parameters:
appSettings
- The current application settings in effect for the system.
-
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 interfaceBusinessProcessor
- Returns:
- A
Properties
object that represents component settings for the application.
-
setAppComponents
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 interfaceBusinessProcessor
- Parameters:
appComponents
- The current application components in effect for the system.
-
getUser
Description copied from interface:BusinessProcessor
Retrieves theUser
previously set for this business object. In the struts layer, this property corresponds to the "user" attribute of each session.- Specified by:
getUser
in interfaceBusinessProcessor
- Returns:
- A
User
object that represents the user currently accessing the system.
-
setUser
Description copied from interface:BusinessProcessor
Sets this business object'sUser
. Used by the application'sBusinessObjectFactory
(throughinitialize(Map parameters)
), to provide the currentUser
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 interfaceBusinessProcessor
- Parameters:
user
- The currentUser
accessing the system, for which business processing is to be performed by this business object.
-
getDaoFactory
Description copied from interface:BusinessProcessor
Retrieves theDAOFactory
previously set for this business object.- Specified by:
getDaoFactory
in interfaceBusinessProcessor
- Returns:
- A
DAOFactory
object that can be used to create data access objects.
-
setDaoFactory
Description copied from interface:BusinessProcessor
Sets this business object'sDAOFactory
. Used by the application'sBusinessObjectFactory
(throughinitialize(Map parameters)
), to provide the currentDAOFactory
for the system to this business object.- Specified by:
setDaoFactory
in interfaceBusinessProcessor
- Parameters:
daoFactory
- The currentDAOFactory
for the system, which will allow this business object to create data access objects.
-
initialize
Description copied from interface:BusinessObject
Initializes this business object by copying incoming parameters into its properties. This method is used byBusinessObjectFactory
immediately after object creation.- Specified by:
initialize
in interfaceBusinessObject
- Overrides:
initialize
in classBaseBusinessObject
- Parameters:
transferMap
- AMap
containing objects such as the application'sDAOFactory
,Settings
,User
, andBusinessObjectFactory
.- Throws:
Exception
-
getBusinessObjectFactory
Description copied from interface:BusinessProcessor
Retrieves theBusinessObjectFactory
previously set for this business object.- Specified by:
getBusinessObjectFactory
in interfaceBusinessProcessor
- Returns:
- A
BusinessObjectFactory
object that can be used to create other business objects.
-
setBusinessObjectFactory
Description copied from interface:BusinessProcessor
Sets this business object'sBusinessObjectFactory
. Used by the application'sBusinessObjectFactory
(throughinitialize(Map parameters)
), to provide itself to this business object, so that it can create other business objects in turn.- Specified by:
setBusinessObjectFactory
in interfaceBusinessProcessor
- Parameters:
businessObjectFactory
- The currentBusinessObjectFactory
for the system, allowing this business object to create other business objects.
-
utils
Description copied from interface:BusinessProcessor
Retrieves a utility object that provides useful methods for business objects.- Specified by:
utils
in interfaceBusinessProcessor
- Returns:
- An implementation of
BusinessObjectUtils
.
-
getInjector
public com.google.inject.Injector getInjector()Description copied from interface:BusinessProcessor
Retrieves theInjector
previously set.- Specified by:
getInjector
in interfaceBusinessProcessor
- Returns:
- A
Injector
object that can be used to create other objects and inject them with dependencies.
-
setInjector
@Inject public void setInjector(com.google.inject.Injector injector) Description copied from interface:BusinessProcessor
Sets this object'sInjector
that can be used to create other objects and inject them with dependencies.- Specified by:
setInjector
in interfaceBusinessProcessor
- Parameters:
injector
- The currentInjector
for the system, which can be used to create other objects and inject them with dependencies.
-
getEventBus
public com.google.common.eventbus.EventBus getEventBus()Description copied from interface:BusinessProcessor
Retrieves theEventBus
previously set for this factory.- Specified by:
getEventBus
in interfaceBusinessProcessor
- Returns:
- A
EventBus
object that can be used to post events and trigger subscribers to run their code.
-
setEventBus
@Inject public void setEventBus(com.google.common.eventbus.EventBus eventBus) Description copied from interface:BusinessProcessor
Sets this factory'sEventBus
. This factory will pass theEventBus
to every business object it creates.- Specified by:
setEventBus
in interfaceBusinessProcessor
- Parameters:
eventBus
- The currentEventBus
for the system, which can be used to post events to subscribers
-
formatDateTime
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
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
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
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:
Exception
-
parseResponseData
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:
Exception
-
sendHTTPPost
public String sendHTTPPost(String urlString, String postData, boolean followRedirect, Map requestProperties, String inputCharSet, Integer timeoutInSeconds) throws 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.requestProperties
- Map that holds request properties to be sent in connection.inputCharSet
- Character set of the response data- Returns:
- A String representing the server's response, or the Location header if redirects are not to be followed.
- Throws:
Exception
-
sendHTTPPost
public String sendHTTPPost(String urlString, String postData, boolean followRedirect) throws 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:
Exception
-
sendHTTPGet
public String sendHTTPGet(String urlString, String postData, boolean followRedirect) throws Exception - Throws:
Exception
-
getProductIDs
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:
Exception
-
getAttributeIDs
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:
Exception
-
loadMatchingSkus
public Collection loadMatchingSkus(Collection orderItems, Collection productIDs, Collection attributeIDs) throws 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:
Exception
-
updateOrderTotals
- Throws:
Exception
-
updateOrderTotals
- Throws:
Exception
-
updateOrderTotals
Updates the totals of a user's order taking into account taxes and shipping. The user'sOrder
and that order's firstOrderDelivery
are updated with new price totals and subtotals.- Throws:
Exception
-
isProcessorClassActive
-