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 Propertiesprivate Propertiesprivate BusinessObjectFactoryprivate DAOFactoryprivate com.google.common.eventbus.EventBusprivate com.google.inject.Injector(package private) static org.apache.commons.logging.Logprivate Settingsprivate Userprivate 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 theBusinessObjectFactorypreviously set for this business object.Retrieves theDAOFactorypreviously set for this business object.com.google.common.eventbus.EventBusRetrieves theEventBuspreviously set for this factory.com.google.inject.InjectorRetrieves theInjectorpreviously set.getProductIDs(Collection orderItems) Constructs a Collection of Integers composed of the productIDs of a given Collection of OrderItem objects.Retrieves theSettingsinstance previously set for this business object.getUser()Retrieves theUserpreviously set for this business object.voidinitialize(Map transferMap) Initializes this business object by copying incoming parameters into its properties.booleanisProcessorClassActive(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.voidsetAppComponents(Properties appComponents) Sets this object's application components.voidsetAppSettings(Properties appSettings) Sets this object's application settings.voidsetBusinessObjectFactory(BusinessObjectFactory businessObjectFactory) Sets this business object'sBusinessObjectFactory.voidsetDaoFactory(DAOFactory daoFactory) Sets this business object'sDAOFactory.voidsetEventBus(com.google.common.eventbus.EventBus eventBus) Sets this factory'sEventBus.voidsetInjector(com.google.inject.Injector injector) Sets this object'sInjectorthat can be used to create other objects and inject them with dependencies.voidsetSettings(Settings settings) Sets this business object'sSettingsinstance.voidSets this business object'sUser.voidvoidupdateOrderTotals(boolean subtractGiftCerts) voidupdateOrderTotals(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:BusinessProcessorRetrieves theSettingsinstance previously set for this business object. TheSettingsobject holds general settings stored in thesscSettingdatabase table.- Specified by:
getSettingsin interfaceBusinessProcessor- Returns:
- A
Settingsobject that represents various settings for the system.
-
setSettings
Description copied from interface:BusinessProcessorSets this business object'sSettingsinstance. Used by the application'sBusinessObjectFactory(throughinitialize(Map parameters)), to provide the system'sSettingsto this business object.- Specified by:
setSettingsin interfaceBusinessProcessor- Parameters:
settings- The currentSettingsfor the system, containing various settings to be used by this business object.
-
getAppSettings
Description copied from interface:BusinessProcessorRetrieves 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 theSettingsinterface, which stores settings drawn from the database. They are stored in the/WEB-INF/classes/appSettings.propertiesfile under each installation.- Specified by:
getAppSettingsin interfaceBusinessProcessor- Returns:
- A
Propertiesobject that represents various settings for the application.
-
setAppSettings
Description copied from interface:BusinessProcessorSets 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 theSettingsinterface, which stores settings drawn from the database.- Specified by:
setAppSettingsin interfaceBusinessProcessor- Parameters:
appSettings- The current application settings in effect for the system.
-
getAppComponents
Description copied from interface:BusinessProcessorRetrieves 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.propertiesfile under each installation.- Specified by:
getAppComponentsin interfaceBusinessProcessor- Returns:
- A
Propertiesobject that represents component settings for the application.
-
setAppComponents
Description copied from interface:BusinessProcessorSets this object's application components. The components identify which Java classes implement the various interfaces used by the system.- Specified by:
setAppComponentsin interfaceBusinessProcessor- Parameters:
appComponents- The current application components in effect for the system.
-
getUser
Description copied from interface:BusinessProcessorRetrieves theUserpreviously set for this business object. In the struts layer, this property corresponds to the "user" attribute of each session.- Specified by:
getUserin interfaceBusinessProcessor- Returns:
- A
Userobject that represents the user currently accessing the system.
-
setUser
Description copied from interface:BusinessProcessorSets this business object'sUser. Used by the application'sBusinessObjectFactory(throughinitialize(Map parameters)), to provide the currentUseraccessing the system to this business object. In the struts layer, this property corresponds to the "user" attribute of each session.- Specified by:
setUserin interfaceBusinessProcessor- Parameters:
user- The currentUseraccessing the system, for which business processing is to be performed by this business object.
-
getDaoFactory
Description copied from interface:BusinessProcessorRetrieves theDAOFactorypreviously set for this business object.- Specified by:
getDaoFactoryin interfaceBusinessProcessor- Returns:
- A
DAOFactoryobject that can be used to create data access objects.
-
setDaoFactory
Description copied from interface:BusinessProcessorSets this business object'sDAOFactory. Used by the application'sBusinessObjectFactory(throughinitialize(Map parameters)), to provide the currentDAOFactoryfor the system to this business object.- Specified by:
setDaoFactoryin interfaceBusinessProcessor- Parameters:
daoFactory- The currentDAOFactoryfor the system, which will allow this business object to create data access objects.
-
initialize
Description copied from interface:BusinessObjectInitializes this business object by copying incoming parameters into its properties. This method is used byBusinessObjectFactoryimmediately after object creation.- Specified by:
initializein interfaceBusinessObject- Overrides:
initializein classBaseBusinessObject- Parameters:
transferMap- AMapcontaining objects such as the application'sDAOFactory,Settings,User, andBusinessObjectFactory.- Throws:
Exception
-
getBusinessObjectFactory
Description copied from interface:BusinessProcessorRetrieves theBusinessObjectFactorypreviously set for this business object.- Specified by:
getBusinessObjectFactoryin interfaceBusinessProcessor- Returns:
- A
BusinessObjectFactoryobject that can be used to create other business objects.
-
setBusinessObjectFactory
Description copied from interface:BusinessProcessorSets 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:
setBusinessObjectFactoryin interfaceBusinessProcessor- Parameters:
businessObjectFactory- The currentBusinessObjectFactoryfor the system, allowing this business object to create other business objects.
-
utils
Description copied from interface:BusinessProcessorRetrieves a utility object that provides useful methods for business objects.- Specified by:
utilsin interfaceBusinessProcessor- Returns:
- An implementation of
BusinessObjectUtils.
-
getInjector
public com.google.inject.Injector getInjector()Description copied from interface:BusinessProcessorRetrieves theInjectorpreviously set.- Specified by:
getInjectorin interfaceBusinessProcessor- Returns:
- A
Injectorobject 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:BusinessProcessorSets this object'sInjectorthat can be used to create other objects and inject them with dependencies.- Specified by:
setInjectorin interfaceBusinessProcessor- Parameters:
injector- The currentInjectorfor 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:BusinessProcessorRetrieves theEventBuspreviously set for this factory.- Specified by:
getEventBusin interfaceBusinessProcessor- Returns:
- A
EventBusobject 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:BusinessProcessorSets this factory'sEventBus. This factory will pass theEventBusto every business object it creates.- Specified by:
setEventBusin interfaceBusinessProcessor- Parameters:
eventBus- The currentEventBusfor 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'sOrderand that order's firstOrderDeliveryare updated with new price totals and subtotals.- Throws:
Exception
-
isProcessorClassActive
-