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

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 Details

    • log

      static org.apache.commons.logging.Log log
    • settings

      private Settings settings
    • appSettings

      private Properties appSettings
    • appComponents

      private Properties appComponents
    • user

      private User user
    • daoFactory

      private DAOFactory daoFactory
    • businessObjectFactory

      private BusinessObjectFactory businessObjectFactory
    • utils

      private BusinessObjectUtils utils
    • injector

      private com.google.inject.Injector injector
    • eventBus

      private com.google.common.eventbus.EventBus eventBus
  • Constructor Details

    • BaseBusinessProcessor

      public BaseBusinessProcessor()
  • Method Details

    • 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

      @Inject 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 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

      @Inject public void setAppSettings(@Named("appSettings") 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 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

      @Inject public void setAppComponents(@Named("appComponents") 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

      @Inject 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

      @Inject 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(Map transferMap) throws 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:
      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

      @Inject 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.
    • getInjector

      public com.google.inject.Injector getInjector()
      Description copied from interface: BusinessProcessor
      Retrieves the Injector previously set.
      Specified by:
      getInjector in interface BusinessProcessor
      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's Injector that can be used to create other objects and inject them with dependencies.
      Specified by:
      setInjector in interface BusinessProcessor
      Parameters:
      injector - The current Injector 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 the EventBus previously set for this factory.
      Specified by:
      getEventBus in interface BusinessProcessor
      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's EventBus. This factory will pass the EventBus to every business object it creates.
      Specified by:
      setEventBus in interface BusinessProcessor
      Parameters:
      eventBus - The current EventBus for the system, which can be used to post events to subscribers
    • formatDateTime

      public String formatDateTime(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 Date parseDateTime(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 String formatPrice(double rawPrice, String currencyCode, 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 String prepareRequestData(Map params, boolean urlEncode) throws 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:
      Exception
    • parseResponseData

      public Map parseResponseData(String response) throws 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:
      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

      public Collection getProductIDs(Collection orderItems) throws 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:
      Exception
    • getAttributeIDs

      public Collection getAttributeIDs(Collection orderItems) throws 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:
      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

      public void updateOrderTotals() throws Exception
      Throws:
      Exception
    • updateOrderTotals

      public void updateOrderTotals(boolean subtractGiftCerts) throws Exception
      Throws:
      Exception
    • updateOrderTotals

      public void updateOrderTotals(Order order, boolean subtractGiftCerts) throws Exception
      Updates the totals of a user's order taking into account taxes and shipping. The user's Order and that order's first OrderDelivery are updated with new price totals and subtotals.
      Throws:
      Exception
    • isProcessorClassActive

      public boolean isProcessorClassActive(String componentsKey)