deegree 2.5 (2011/06/29 09:44 build-8-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 java.lang.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 java.lang.String FT_PREFIX
           
protected static int JOIN_TABLE
           
protected static int MULTI_PROPERTY_TABLE
           
protected  MappedGMLSchema schema
           
protected  java.util.Set<java.lang.String> sequences
           
protected  java.util.Map<java.lang.String,DDLGenerator.TableDefinition> tables
           
 
Constructor Summary
protected DDLGenerator(java.net.URL schemaURL)
          Creates a new instance of DDLGenerator from the given parameters.
 
Method Summary
protected abstract  java.lang.StringBuffer generateCreateIndexStmts(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the creation of standard indexes for the given table definition.
protected  java.lang.StringBuffer generateCreateSchemaStmts(java.lang.String dbSchemaName)
          Generates the DDL statements necessary for the creation of the given schema.
 void generateCreateScript(java.lang.String outputFile)
           
 void generateCreateScript(java.lang.String outputFile, java.lang.String dbSchema)
          Generates the DDL statements to create a relational schema that backs the GML schema.
protected  java.lang.StringBuffer generateCreateSequenceStmt(java.lang.String sequenceName)
          Generates the DDL statements necessary for the creation of the given sequence.
protected abstract  java.lang.StringBuffer generateCreateTableStmt(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the creation of the given table definition.
protected  java.lang.StringBuffer generateDropIndexStmts(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the dropping of standard indexes for the given table definition.
protected  java.lang.StringBuffer generateDropSchemaStmt(java.lang.String dbSchemaName)
          Generates the DDL statements necessary for the removal of the given schema.
 void generateDropScript(java.lang.String outputFile, java.lang.String dbSchema)
          Generates the DDL statements that can be used to remove the relational schema again.
protected  java.lang.StringBuffer generateDropSequenceStmt(java.lang.String sequenceName)
          Generates the DDL statements necessary for the removal of the given sequence.
protected  java.lang.StringBuffer generateDropTableStmt(DDLGenerator.TableDefinition table)
          Generates the DDL statements necessary for the removal of the given table definition.
protected abstract  java.lang.StringBuffer generateSetSchemaStmt(java.lang.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(java.lang.String[] args)
           
 java.lang.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 java.lang.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 java.util.Map<java.lang.String,DDLGenerator.TableDefinition> tables

sequences

protected java.util.Set<java.lang.String> sequences
Constructor Detail

DDLGenerator

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

Parameters:
schemaURL -
Throws:
java.net.MalformedURLException
java.io.IOException
org.xml.sax.SAXException
XMLParsingException
XMLSchemaException
UnknownCRSException
Method Detail

generateSetSchemaStmt

protected abstract java.lang.StringBuffer generateSetSchemaStmt(java.lang.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 java.lang.StringBuffer generateCreateSchemaStmts(java.lang.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 java.lang.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 java.lang.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 java.lang.StringBuffer generateCreateSequenceStmt(java.lang.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 java.lang.StringBuffer generateDropSchemaStmt(java.lang.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 java.lang.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 java.lang.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 java.lang.StringBuffer generateDropSequenceStmt(java.lang.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(java.lang.String outputFile)
                          throws java.io.IOException
Parameters:
outputFile -
Throws:
java.io.IOException

generateCreateScript

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

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

generateDropScript

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

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

main

public static void main(java.lang.String[] args)
                 throws java.io.IOException,
                        org.xml.sax.SAXException,
                        XMLParsingException,
                        XMLSchemaException,
                        UnknownCRSException
Parameters:
args -
Throws:
java.io.IOException
org.xml.sax.SAXException
XMLParsingException
XMLSchemaException
UnknownCRSException

toString

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

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

deegree 2.5 (2011/06/29 09:44 build-8-official)

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