com.softslate.commerce.daos.core
Class BaseDAO

java.lang.Object
  extended bycom.softslate.commerce.daos.core.BaseDAO
All Implemented Interfaces:
DAOInterface
Direct Known Subclasses:
AdministratorDAOBasic, AttributeDAOBasic, BaseAdminGatewayDAOBasic, BasicTaxRateDAOBasic, CategoryDAOBasic, CategorySettingDAOBasic, CountryDAOBasic, CustomerAddressDAOBasic, CustomerDAOBasic, InstallerDAOBasic, NPODAOBasic, OptionDAOBasic, OrderDAOBasic, OrderDeliveryDAOBasic, OrderItemAttributeDAOBasic, OrderItemDAOBasic, PaymentDAOBasic, ProductDAOBasic, ProductSettingDAOBasic, RoleDAOBasic, SettingsDAOBasic, ShippingMethodDAOBasic, ShippingRateDAOBasic, SKUDAOBasic, StateDAOBasic, UpgradesDAOBasic

public abstract class BaseDAO
extends java.lang.Object
implements DAOInterface

Abstract superclass for all objects in the data access layer.

The methods provided allow implementations to communicate with other elements of the application. In particular, retrieve settings (using getSettingsBean()), retrieve database connections (using getConnection()), retrieve SQL statements (using getSqlMap() and getSQL(java.lang.String, java.lang.String)), and create other data access objects (using getDaoFactory()).

Author:
David Tobey

Field Summary
private  java.sql.Connection connection
           
private  DAOFactory daoFactory
           
private  javax.sql.DataSource dataSource
           
(package private) static org.apache.commons.logging.Log log
           
private  SettingsBean settingsBean
           
private  java.util.Map sqlMap
           
 
Constructor Summary
BaseDAO()
           
 
Method Summary
 java.lang.String formatDateTime(java.util.Date dateTime)
          Formats a Date object into a string suitable for storage in the database.
 java.sql.Connection getConnection()
          Retrieves a Connection to the application's DataSource.
 DAOFactory getDaoFactory()
          Retrieves the application's DAOFactory.
 javax.sql.DataSource getDataSource()
          Retrieves the application's DataSource.
 SettingsBean getSettingsBean()
          Retrieves the SettingsBean previously set for this data access object.
 java.lang.String getSQL(java.lang.String module, java.lang.String key)
          Returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources".
 java.util.Map getSqlMap()
          Retrieves a Map of the SQL statements used by the application.
 void initialize(java.util.Map transferMap)
          Initializes this data access object by copying incoming parameters into its properties.
 java.util.Date parseDateTime(java.lang.String dateTime)
          Formats a Date object into a string suitable for storage in the database.
 void setConnection(java.sql.Connection connection)
           
 void setDaoFactory(DAOFactory daoFactory)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setSettingsBean(SettingsBean settingsBean)
           
 void setSqlMap(java.util.Map sqlMap)
           
 
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

settingsBean

private SettingsBean settingsBean

dataSource

private javax.sql.DataSource dataSource

connection

private java.sql.Connection connection

sqlMap

private java.util.Map sqlMap

daoFactory

private DAOFactory daoFactory
Constructor Detail

BaseDAO

public BaseDAO()
Method Detail

getSettingsBean

public SettingsBean getSettingsBean()
Description copied from interface: DAOInterface
Retrieves the SettingsBean previously set for this data access object.

Specified by:
getSettingsBean in interface DAOInterface
Returns:
A SettingsBean object that represents various settings for the system.

setSettingsBean

public void setSettingsBean(SettingsBean settingsBean)
Specified by:
setSettingsBean in interface DAOInterface

getDataSource

public javax.sql.DataSource getDataSource()
Description copied from interface: DAOInterface
Retrieves the application's DataSource.

Specified by:
getDataSource in interface DAOInterface
Returns:
The application's DataSource.

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Specified by:
setDataSource in interface DAOInterface

getConnection

public java.sql.Connection getConnection()
Description copied from interface: DAOInterface
Retrieves a Connection to the application's DataSource.

Specified by:
getConnection in interface DAOInterface
Returns:
A Connection to the application's DataSource.

setConnection

public void setConnection(java.sql.Connection connection)
Specified by:
setConnection in interface DAOInterface

getSqlMap

public java.util.Map getSqlMap()
Description copied from interface: DAOInterface
Retrieves a Map of the SQL statements used by the application.

Specified by:
getSqlMap in interface DAOInterface
Returns:
A Map of the SQL statements used by the application.

setSqlMap

public void setSqlMap(java.util.Map sqlMap)
Specified by:
setSqlMap in interface DAOInterface

getDaoFactory

public DAOFactory getDaoFactory()
Description copied from interface: DAOInterface
Retrieves the application's DAOFactory.

Specified by:
getDaoFactory in interface DAOInterface
Returns:
The application's DAOFactory.

setDaoFactory

public void setDaoFactory(DAOFactory daoFactory)
Specified by:
setDaoFactory in interface DAOInterface

initialize

public void initialize(java.util.Map transferMap)
                throws java.lang.Exception
Description copied from interface: DAOInterface
Initializes this data access object by copying incoming parameters into its properties. This method is used by DAOFactory after object creation to copy the application's DAOFactory and SettingsBean into the new object. The sqlMap and dataSource properties are also copied from the DAOFactory.

Specified by:
initialize in interface DAOInterface
Parameters:
transferMap - A Map containing objects such as the application's DAOFactory and SettingsBean.
Throws:
java.lang.Exception

getSQL

public java.lang.String getSQL(java.lang.String module,
                               java.lang.String key)
                        throws java.lang.Exception
Returns an SQL statement configured in the .properties files under "/WEB-INF/classes/resources".

Parameters:
module - The application module corresponding to the desired SQL statement, such as "core", "product", "order", or "customer".
key - A string key for the SQL statement corresponding to the keys in the .properties files.
Returns:
An SQL statement, or null if the requested statement could not be found.
Throws:
java.lang.Exception

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)
                             throws java.lang.Exception
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.
Throws:
java.lang.Exception


Copyright © SoftSlate, Inc. 2003–2005