atg.droplet.sql
Class SQLTableManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.droplet.EmptyFormHandler
              extended by atg.droplet.GenericFormHandler
                  extended by atg.droplet.sql.SQLTableManager
All Implemented Interfaces:
DropletFormHandler, NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class SQLTableManager
extends GenericFormHandler

A form handler/bean that provides functionality for creating, dropping, and providing information about the state of a set of tables. Two alternate methods of connecting to the database are used, dependent upon the property UseDataSource. If UseDataSource is set to true, the DataSource and TransactionManager must be configured and will be used for acquiring database connections. If UseDataSource is false or not explicitly set, the ConnectionURL will be used for acquiring database connections.


Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.droplet.GenericFormHandler
PARAM_DEFER_FORWARD_OR_REDIRECT, PARAM_USE_FORWARDS
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
SQLTableManager()
           
 
Method Summary
 void createTables()
          Creates the tables.
 void dropTables()
          Drops all of the tables
 boolean getAllTablesExist()
          Returns true if all specified tables exist
 java.lang.String getConnectionURL()
           
 java.lang.String getCreateSQL()
          Returns the SQL that will be used to implement the create tables operation
 java.lang.String getDatabaseName(java.sql.Connection conn)
          Returns the canonical name for the database that we're using
 javax.sql.DataSource getDataSource()
           
 java.lang.String getDBErrorURL()
           
 java.lang.String getDropSQL()
          Returns the SQL that will be used to implement the dropTables operation
 boolean getNoTablesExist()
          Returns true if none of the specified tables exist
 SQLTableConfig[] getTables()
           
 boolean getTableStatus(boolean pAllTablesExist)
          Go through the list of tables names that we were supplied with.
 javax.transaction.TransactionManager getTransactionManager()
           
 boolean getUseDataSource()
           
 boolean handleCreateTables(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Creates the tables specified by executing the SQL specified
 boolean handleDropTables(DynamoHttpServletRequest pRequest, DynamoHttpServletResponse pResponse)
          Drops each of the tables specified by the TableNames property
 void setConnectionURL(java.lang.String pConnectionURL)
          Sets the property ConnectionURL.
 void setDataSource(javax.sql.DataSource pDataSource)
          Sets the DataSource
 void setDBErrorURL(java.lang.String pDBErrorURL)
          Sets the property DBErrorURL.
 void setTables(SQLTableConfig[] pTables)
          Sets the property Tables.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Sets the TransactionManager
 void setUseDataSource(boolean pUseDataSource)
          Sets the property UseDataSource
 
Methods inherited from class atg.droplet.GenericFormHandler
addFormException, addUncheckedFormException, afterSet, beforeSet, checkFormRedirect, createFormSubmissionMessage, getCancelURL, getCheckForValidSession, getFormError, getFormExceptions, getFormName, getMessagePort, getMessageSource, getMessageType, getPropertyExceptions, getSendMessages, getUncheckedFormExceptions, handleCancel, handleFormException, handleUncheckedFormException, hasUncheckedFormExceptions, isDeferForwardsAndRedirects, isRestorableForm, isUseForwards, isValidSession, redirectOrForward, resetFormExceptions, setCancelURL, setCheckForValidSession, setDeferForwardsAndRedirects, setFormName, setMessagePort, setMessageSource, setMessageType, setRestorableForm, setSendMessages, setUseForwards
 
Methods inherited from class atg.droplet.EmptyFormHandler
afterGet, beforeGet
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStartService, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Class version string

Constructor Detail

SQLTableManager

public SQLTableManager()
Method Detail

setTables

public void setTables(SQLTableConfig[] pTables)
Sets the property Tables. This must be in an order such that any table that references another table must be after it in the list. Tables are created in the order that they are specified in the list, and dropped in the reverse order.


getTables

public SQLTableConfig[] getTables()
Returns:
The value of the property Tables.

setConnectionURL

public void setConnectionURL(java.lang.String pConnectionURL)
Sets the property ConnectionURL.


getConnectionURL

public java.lang.String getConnectionURL()
Returns:
The value of the property ConnectionURL.

setDBErrorURL

public void setDBErrorURL(java.lang.String pDBErrorURL)
Sets the property DBErrorURL.


getDBErrorURL

public java.lang.String getDBErrorURL()
Returns:
The value of the property DBErrorURL.

setUseDataSource

public void setUseDataSource(boolean pUseDataSource)
Sets the property UseDataSource


getUseDataSource

public boolean getUseDataSource()
Returns:
The value of the property UseDataSource.

setDataSource

public void setDataSource(javax.sql.DataSource pDataSource)
Sets the DataSource


getDataSource

public javax.sql.DataSource getDataSource()
Returns:
The value of the property DataSource.

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Sets the TransactionManager


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Returns:
The value of the property TransactionManager.

getTableStatus

public boolean getTableStatus(boolean pAllTablesExist)
Go through the list of tables names that we were supplied with. If we don't find one of them, we return false.


getAllTablesExist

public boolean getAllTablesExist()
Returns true if all specified tables exist


getNoTablesExist

public boolean getNoTablesExist()
Returns true if none of the specified tables exist


dropTables

public void dropTables()
                throws java.sql.SQLException
Drops all of the tables

Throws:
java.sql.SQLException

getDropSQL

public java.lang.String getDropSQL()
Returns the SQL that will be used to implement the dropTables operation


getCreateSQL

public java.lang.String getCreateSQL()
Returns the SQL that will be used to implement the create tables operation


getDatabaseName

public java.lang.String getDatabaseName(java.sql.Connection conn)
Returns the canonical name for the database that we're using


createTables

public void createTables()
                  throws java.sql.SQLException
Creates the tables.

Throws:
java.sql.SQLException

handleCreateTables

public boolean handleCreateTables(DynamoHttpServletRequest pRequest,
                                  DynamoHttpServletResponse pResponse)
                           throws java.io.IOException,
                                  javax.servlet.ServletException
Creates the tables specified by executing the SQL specified

Throws:
java.io.IOException
javax.servlet.ServletException

handleDropTables

public boolean handleDropTables(DynamoHttpServletRequest pRequest,
                                DynamoHttpServletResponse pResponse)
                         throws java.io.IOException,
                                javax.servlet.ServletException
Drops each of the tables specified by the TableNames property

Throws:
java.io.IOException
javax.servlet.ServletException