deegree 2.3 (2010/04/09 10:10 build-4-official)

org.deegree.tools.datastore
Class DDLGenerator

java.lang.Object
  extended by org.deegree.tools.datastore.DDLGenerator
Direct Known Subclasses:
OracleDDLGenerator, PostGISDDLGenerator

public abstract class DDLGenerator
extends Object

Abstract base class for DDL generation from annotated GML schema files.

This abstract base class only implements the functionality needed to retrieve the necessary tables and columns used in an annotated GML schema. Some DDL generation may be dependent on the specific SQL backend to be used, so this is implemented in concrete extensions of this class.

Version:
$Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
Author:
Markus Schneider, last edited by: $Author: mschneider $

Nested Class Summary
(package private)  class DDLGenerator.ColumnDefinition
           
(package private)  class DDLGenerator.TableDefinition
           
 
Field Summary
protected static int FEATURE_TYPE_TABLE
           
protected static String FT_PREFIX
           
protected static int JOIN_TABLE
           
protected static int MULTI_PROPERTY_TABLE
           
protected  MappedGMLSchema schema
           
protected  Set<String> sequences
           
protected  Map<String,DDLGenerator.TableDefinition> tables
           
 
Constructor Summary
protected DDLGenerator(URL schemaURL)
          Creates a new instance of DDLGenerator from the given parameters.
 
Method Summary
protected abstract  StringBuffer generateCreateIndexStmts(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the creation of standard indexes for the given table definition.
protected  StringBuffer generateCreateSchemaStmts(String dbSchemaName)
          Generates the DDL statements necessary for the creation of the given schema.
 void generateCreateScript(String outputFile)
           
 void generateCreateScript(String outputFile, String dbSchema)
          Generates the DDL statements to create a relational schema that backs the GML schema.
protected  StringBuffer generateCreateSequenceStmt(String sequenceName)
          Generates the DDL statements necessary for the creation of the given sequence.
protected abstract  StringBuffer generateCreateTableStmt(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the creation of the given table definition.
protected  StringBuffer generateDropIndexStmts(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the dropping of standard indexes for the given table definition.
protected  StringBuffer generateDropSchemaStmt(String dbSchemaName)
          Generates the DDL statements necessary for the removal of the given schema.
 void generateDropScript(String outputFile, String dbSchema)
          Generates the DDL statements that can be used to remove the relational schema again.
protected  StringBuffer generateDropSequenceStmt(String sequenceName)
          Generates the DDL statements necessary for the removal of the given sequence.
protected  StringBuffer generateDropTableStmt(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the removal of the given table definition.
protected abstract  StringBuffer generateSetSchemaStmt(String dbSchemaName)
          Generates the SQL statements necessary for setting the schema search path.
protected  DDLGenerator.TableDefinition[] getTables(int type)
          Returns all table definitions of the given type.
static void main(String[] args)
           
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FT_PREFIX

protected static final String FT_PREFIX
See Also:
Constant Field Values

FEATURE_TYPE_TABLE

protected static final int FEATURE_TYPE_TABLE
See Also:
Constant Field Values

JOIN_TABLE

protected static final int JOIN_TABLE
See Also:
Constant Field Values

MULTI_PROPERTY_TABLE

protected static final int MULTI_PROPERTY_TABLE
See Also:
Constant Field Values

schema

protected MappedGMLSchema schema

tables

protected Map<String,DDLGenerator.TableDefinition> tables

sequences

protected Set<String> sequences
Constructor Detail

DDLGenerator

protected DDLGenerator(URL schemaURL)
                throws MalformedURLException,
                       IOException,
                       SAXException,
                       XMLParsingException,
                       XMLSchemaException,
                       UnknownCRSException
Creates a new instance of DDLGenerator from the given parameters.

Parameters:
schemaURL -
Throws:
MalformedURLException
IOException
SAXException
XMLParsingException
XMLSchemaException
UnknownCRSException
Method Detail

generateSetSchemaStmt

protected abstract StringBuffer generateSetSchemaStmt(String dbSchemaName)
Generates the SQL statements necessary for setting the schema search path. Must be overwritten by the concrete implementation.

Parameters:
dbSchemaName -
Returns:
the SQL statements necessary for setting the schema search path accordingly

generateCreateSchemaStmts

protected StringBuffer generateCreateSchemaStmts(String dbSchemaName)
Generates the DDL statements necessary for the creation of the given schema. May be overwritten by a concrete implementation.

Parameters:
dbSchemaName -
Returns:
the DDL statements necessary for the creation of the given db schema

generateCreateTableStmt

protected abstract StringBuffer generateCreateTableStmt(DDLGenerator.TableDefinition table)
Generates the DDL statements necessary for the creation of the given table definition. Must be overwritten by the concrete implementation.

Parameters:
table -
Returns:
the DDL statements necessary for the creation of the given table definition

generateCreateIndexStmts

protected abstract StringBuffer generateCreateIndexStmts(DDLGenerator.TableDefinition table)
Generates the DDL statements necessary for the creation of standard indexes for the given table definition. Must be overwritten by the concrete implementation.

Parameters:
table -
Returns:
the DDL statements necessary for the creation of standard indexes for the given table definition

generateCreateSequenceStmt

protected StringBuffer generateCreateSequenceStmt(String sequenceName)
Generates the DDL statements necessary for the creation of the given sequence. May be overwritten by a concrete implementation.

Parameters:
sequenceName -
Returns:
the DDL statements necessary for the creation of the given sequence definition

generateDropSchemaStmt

protected StringBuffer generateDropSchemaStmt(String dbSchemaName)
Generates the DDL statements necessary for the removal of the given schema. May be overwritten by a concrete implementation.

Parameters:
dbSchemaName -
Returns:
the DDL statements necessary for the removal of the given db schema

generateDropTableStmt

protected StringBuffer generateDropTableStmt(DDLGenerator.TableDefinition table)
Generates the DDL statements necessary for the removal of the given table definition. May be overwritten by a concrete implementation.

Parameters:
table -
Returns:
the DDL statements necessary for the removal of the given table definition

generateDropIndexStmts

protected StringBuffer generateDropIndexStmts(DDLGenerator.TableDefinition table)
Generates the DDL statements necessary for the dropping of standard indexes for the given table definition. May be overwritten by a concrete implementation.

Parameters:
table -
Returns:
the DDL statements necessary for the dropping of standard indexes for the given table definition

generateDropSequenceStmt

protected StringBuffer generateDropSequenceStmt(String sequenceName)
Generates the DDL statements necessary for the removal of the given sequence. May be overwritten by a concrete implementation.

Parameters:
sequenceName -
Returns:
the DDL statements necessary for the removal of the given sequence definition

getTables

protected DDLGenerator.TableDefinition[] getTables(int type)
Returns all table definitions of the given type.

Parameters:
type - FEATURE_TYPE_TABLE, JOIN_TABLE or MULTI_PROPERTY_TABLE
Returns:
all table definitions of the given type.

generateCreateScript

public void generateCreateScript(String outputFile)
                          throws IOException
Parameters:
outputFile -
Throws:
IOException

generateCreateScript

public void generateCreateScript(String outputFile,
                                 String dbSchema)
                          throws IOException
Generates the DDL statements to create a relational schema that backs the GML schema.

Parameters:
outputFile -
dbSchema - (may be null)
Throws:
IOException

generateDropScript

public void generateDropScript(String outputFile,
                               String dbSchema)
                        throws IOException
Generates the DDL statements that can be used to remove the relational schema again.

Parameters:
outputFile -
dbSchema - (may be null)
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException,
                        SAXException,
                        XMLParsingException,
                        XMLSchemaException,
                        UnknownCRSException
Parameters:
args -
Throws:
IOException
SAXException
XMLParsingException
XMLSchemaException
UnknownCRSException

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class Object
Returns:
a string representation of the object.

deegree 2.3 (2010/04/09 10:10 build-4-official)

an open source project founded by lat/lon, Bonn, Germany.
For more information visit: http://www.deegree.org