ca.sqlpower.architect.ddl
Class SQLServerDDLGenerator

java.lang.Object
  extended by ca.sqlpower.architect.ddl.GenericDDLGenerator
      extended by ca.sqlpower.architect.ddl.SQLServerDDLGenerator
All Implemented Interfaces:
DDLGenerator
Direct Known Subclasses:
SQLServer2000DDLGenerator, SQLServer2005DDLGenerator

public abstract class SQLServerDDLGenerator
extends GenericDDLGenerator

The base class for version-specific SQL Server DDL generators. This class is marked abstract because it is not appropriate to use it directly on any version of SQL Server.


Field Summary
static java.lang.String GENERATOR_VERSION
           
 
Fields inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
allowConnection, con, EOL, profileFunctionMap, targetCatalog, targetSchema, topLevelNames, typeMap, warnings
 
Constructor Summary
SQLServerDDLGenerator()
           
 
Method Summary
 void addColumn(SQLColumn c)
          Appends the DDL statement for adding the given column to its parent table in this DDL Generator's target schema/catalog.
 void addIndex(SQLIndex index)
          Adds a DDL statement to this generator that will create the given index.
 java.lang.String columnType(SQLColumn c)
          Adds support for the SQL Server identity feature.
protected  void createTypeMap()
          Creates and populates typeMap using DatabaseMetaData.
 java.lang.String getCatalogTerm()
          Returns the string "Database".
 java.lang.String getDeferrabilityClause(SQLRelationship r)
          Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform.
 java.lang.String getName()
          Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.
 java.lang.String getSchemaTerm()
          Returns the string "Owner".
 java.lang.String getStatementTerminator()
          Returns an empty string because SS2k doesn't need DDL statement terminators.
 boolean isReservedWord(java.lang.String word)
          Check to see if the word word is on the list of reserved words for this database
 java.lang.String makeDropForeignKeySQL(java.lang.String fkTable, java.lang.String fkName)
          Generates a command for dropping a foreign key which works on some platforms.
 boolean supportsDeferrabilityPolicy(SQLRelationship r)
          Returns true if the platform supports the deferrability policy of the given relationship, false otherwise.
 java.lang.String toIdentifier(java.lang.String name)
          Converts space to underscore in name and returns the possibly-modified string.
 void writeDDLTransactionBegin()
          Does nothing.
 void writeDDLTransactionEnd()
          Prints "GO" on its own line.
 void writeHeader()
           
 
Methods inherited from class ca.sqlpower.architect.ddl.GenericDDLGenerator
addPrimaryKey, addPrimaryKeysToCreateTable, addRelationship, addTable, columnDefinition, columnNullability, createPhysicalName, createSeqPhysicalName, dropColumn, dropPrimaryKey, dropRelationship, dropTable, endStatement, failsafeGetTypeDescriptor, generateDDLScript, generateDDLStatements, getAllowConnection, getColumnDataTypeName, getCon, getDdlStatements, getDefaultType, getDeleteActionClause, getProfileFunctionMap, getTargetCatalog, getTargetSchema, getTypeMap, getUpdateActionClause, getWarnings, makeDropTableSQL, modifyColumn, print, println, setAllowConnection, setCon, setProfileFunctionMap, setTargetCatalog, setTargetSchema, setTypeMap, supportsDeleteAction, supportsRollback, supportsUpdateAction, toQualifiedName, toQualifiedName, toQualifiedName, writeCreateDB, writeExportedRelationships, writePrimaryKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GENERATOR_VERSION

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

SQLServerDDLGenerator

public SQLServerDDLGenerator()
                      throws java.sql.SQLException
Throws:
java.sql.SQLException
Method Detail

getName

public java.lang.String getName()
Description copied from interface: DDLGenerator
Returns the name of this DDL Generator, which should be a human-readable string with the vendor and/or product name (and version if the generator doesn't work with all versions) of the database platform this generator targets.

Specified by:
getName in interface DDLGenerator
Overrides:
getName in class GenericDDLGenerator

isReservedWord

public boolean isReservedWord(java.lang.String word)
Description copied from class: GenericDDLGenerator
Check to see if the word word is on the list of reserved words for this database

Specified by:
isReservedWord in interface DDLGenerator
Overrides:
isReservedWord in class GenericDDLGenerator
Returns:

writeHeader

public void writeHeader()
Overrides:
writeHeader in class GenericDDLGenerator

writeDDLTransactionBegin

public void writeDDLTransactionBegin()
Description copied from class: GenericDDLGenerator
Does nothing. If your target system supports transactional DDL, override this method and print the appropriate statement.

Overrides:
writeDDLTransactionBegin in class GenericDDLGenerator

writeDDLTransactionEnd

public void writeDDLTransactionEnd()
Prints "GO" on its own line.

Overrides:
writeDDLTransactionEnd in class GenericDDLGenerator

getStatementTerminator

public java.lang.String getStatementTerminator()
Returns an empty string because SS2k doesn't need DDL statement terminators.

Specified by:
getStatementTerminator in interface DDLGenerator
Overrides:
getStatementTerminator in class GenericDDLGenerator

createTypeMap

protected void createTypeMap()
                      throws java.sql.SQLException
Description copied from class: GenericDDLGenerator
Creates and populates typeMap using DatabaseMetaData. Subclasses for specific DB platforms will be able to override this implementation with one that uses a static, pre-defined type map.

Overrides:
createTypeMap in class GenericDDLGenerator
Throws:
java.sql.SQLException

getCatalogTerm

public java.lang.String getCatalogTerm()
Returns the string "Database".

Specified by:
getCatalogTerm in interface DDLGenerator
Overrides:
getCatalogTerm in class GenericDDLGenerator

getSchemaTerm

public java.lang.String getSchemaTerm()
Returns the string "Owner".

Specified by:
getSchemaTerm in interface DDLGenerator
Overrides:
getSchemaTerm in class GenericDDLGenerator

toIdentifier

public java.lang.String toIdentifier(java.lang.String name)
Description copied from class: GenericDDLGenerator
Converts space to underscore in name and returns the possibly-modified string. This will not be completely sufficient because it leaves ".", "%", and lots of other non-alphanumeric characters alone. Subclasses might choose to quote and leave everything alone, or whatever.

Specified by:
toIdentifier in interface DDLGenerator
Overrides:
toIdentifier in class GenericDDLGenerator

columnType

public java.lang.String columnType(SQLColumn c)
Adds support for the SQL Server identity feature.

Specified by:
columnType in interface DDLGenerator
Overrides:
columnType in class GenericDDLGenerator
Returns:

addColumn

public void addColumn(SQLColumn c)
Description copied from interface: DDLGenerator
Appends the DDL statement for adding the given column to its parent table in this DDL Generator's target schema/catalog.

Specified by:
addColumn in interface DDLGenerator
Overrides:
addColumn in class GenericDDLGenerator
Parameters:
c - The column to create a ADD statement for.

addIndex

public void addIndex(SQLIndex index)
              throws ArchitectException
Description copied from class: GenericDDLGenerator
Adds a DDL statement to this generator that will create the given index.

Specified by:
addIndex in interface DDLGenerator
Overrides:
addIndex in class GenericDDLGenerator
Parameters:
index - The specification of the index to create. Note, if the index type is STATISTIC, no DDL will be generated because STATISTIC indices are just artificial JDBC constructs to describe table statistics (you can't create or drop them).
Throws:
ArchitectException

getDeferrabilityClause

public java.lang.String getDeferrabilityClause(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns the correct syntax for setting the deferrability of a foreign key relationship on this DDL Generator's target platform. Throws an UnsupportedOperationException if the platform does not support the given relationship's deferrability policy.

Overrides:
getDeferrabilityClause in class GenericDDLGenerator
Parameters:
r - The relationship the deferrability clause is for
Returns:
The SQL clause for declaring the deferrability policy in r.

supportsDeferrabilityPolicy

public boolean supportsDeferrabilityPolicy(SQLRelationship r)
Description copied from class: GenericDDLGenerator
Returns true if the platform supports the deferrability policy of the given relationship, false otherwise. This generic method assumes support for all deferrability policies.

Overrides:
supportsDeferrabilityPolicy in class GenericDDLGenerator
Returns:
Whether the chosen platform supports the deferrability.

makeDropForeignKeySQL

public java.lang.String makeDropForeignKeySQL(java.lang.String fkTable,
                                              java.lang.String fkName)
Description copied from class: GenericDDLGenerator
Generates a command for dropping a foreign key which works on some platforms. The statement looks like ALTER TABLE $fktable DROP FOREIGN KEY $fkname.

Specified by:
makeDropForeignKeySQL in interface DDLGenerator
Overrides:
makeDropForeignKeySQL in class GenericDDLGenerator
Parameters:
fkTable - The name of the FK table whose relationship should be dropped.
fkName - The name of the key to drop.
Returns:
a SQL statement which will drop the key.


Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca