atg.adapter.gsa
Class SQLProcessorEngine

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.adapter.gsa.SQLProcessorEngine
All Implemented Interfaces:
atg.naming.NameContextBindingListener, atg.naming.NameContextElement, atg.naming.NameResolver, atg.nucleus.AdminableService, atg.nucleus.logging.ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, atg.nucleus.naming.ComponentNameResolver, atg.nucleus.Service, atg.nucleus.ServiceListener, java.util.EventListener

public class SQLProcessorEngine
extends atg.nucleus.GenericService

This class is designed to assist with database table manipulation such as adding tables. Parts copied from atg.service.idgen.?? by mgk

Version:
1.0
Author:
mf

Field Summary
static java.lang.String APACHE_DERBY
           
 
Fields inherited from class atg.nucleus.GenericService
CLASS_VERSION, 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
SQLProcessorEngine()
          empty constructor
SQLProcessorEngine(atg.adapter.gsa.GSARepository pRep)
          Construct a generator
 
Method Summary
 boolean createTables(java.util.List<java.lang.String> pStatements, boolean pDrop)
          This method is used to create tables in a database.
 void doStartService()
          method to execute when starting this component
 void dropTablesFromCreateStatements(java.util.List<java.lang.String> pCreateStatements)
          This method is used to iteratively drop tables.
 java.lang.String getCreateTableBeginDelimiter()
           
 java.lang.String getCreateTableEndDelimiter()
           
 java.lang.String getDetermineTableExistsSQL()
           
 java.lang.String getDropTableSQL()
           
 atg.adapter.gsa.GSARepository getRepository()
           
 boolean isDerby()
          Returns true if the current database is Apache Derby.
 void setCreateTableBeginDelimiter(java.lang.String pStr)
           
 void setCreateTableEndDelimiter(java.lang.String pStr)
           
 void setDetermineTableExistsSQL(java.lang.String pStr)
           
 void setDropTableSQL(java.lang.String pStr)
           
 void setRepository(atg.adapter.gsa.GSARepository pRep)
           
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, 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

APACHE_DERBY

public static final java.lang.String APACHE_DERBY
See Also:
Constant Field Values
Constructor Detail

SQLProcessorEngine

public SQLProcessorEngine()
empty constructor


SQLProcessorEngine

public SQLProcessorEngine(atg.adapter.gsa.GSARepository pRep)
Construct a generator

Method Detail

setRepository

public void setRepository(atg.adapter.gsa.GSARepository pRep)

getRepository

public atg.adapter.gsa.GSARepository getRepository()

setDetermineTableExistsSQL

public void setDetermineTableExistsSQL(java.lang.String pStr)

getDetermineTableExistsSQL

public java.lang.String getDetermineTableExistsSQL()

setDropTableSQL

public void setDropTableSQL(java.lang.String pStr)

getDropTableSQL

public java.lang.String getDropTableSQL()

setCreateTableBeginDelimiter

public void setCreateTableBeginDelimiter(java.lang.String pStr)

getCreateTableBeginDelimiter

public java.lang.String getCreateTableBeginDelimiter()

setCreateTableEndDelimiter

public void setCreateTableEndDelimiter(java.lang.String pStr)

getCreateTableEndDelimiter

public java.lang.String getCreateTableEndDelimiter()

doStartService

public void doStartService()
                    throws atg.nucleus.ServiceException
method to execute when starting this component

Overrides:
doStartService in class atg.nucleus.GenericService
Throws:
atg.nucleus.ServiceException

createTables

public boolean createTables(java.util.List<java.lang.String> pStatements,
                            boolean pDrop)
                     throws SQLProcessorException
This method is used to create tables in a database. It takes a String that contains all of the table creation statements and is of the format: CREATE TABLE foo ( ); ... CREATE TABLE bar ( ); Specifically, this is the format output by the GSA when a call is made to generateSQL(); Before making the tables, this large String will be split apart into an array of individual CREATE TABLE statements using the createTableBeginDelimiter and createTableEndDelimiter properties. By default, createTableBeginDelimiter = "CREATE TABLE" and createTableEndDelimiter = ";"

Parameters:
String - pStr - the String containing the CREATE TABLE statements
boolean - pDrop - indicates whether to drop tables and recreate them if the tables already exist in the database
Returns:
boolean true if any tables were created ( or dropped and created )
Throws:
SQLProcessorException - if an error occurs trying to create the tables

isDerby

public boolean isDerby()
                throws SQLProcessorException
Returns true if the current database is Apache Derby. The first invocation to this method will cache its answer.

Throws:
SQLProcessorException

dropTablesFromCreateStatements

public void dropTablesFromCreateStatements(java.util.List<java.lang.String> pCreateStatements)
                                    throws SQLProcessorException
This method is used to iteratively drop tables. The iterative effort is necessary because tables may have references. ASSUMPTION: references only exist for tables that are defined within this repository. If references exist from tables outside this repository, this method will throw a SQLProcessorException

Parameters:
Vector - of CREATE TABLE statements indicating which tables to drop
Throws:
SQLProcessorException - thrown if all tables can not be dropped


Copyright © 2009. All Rights Reserved.