org.apache.ddlutils.task
Class WriteSchemaSqlToFileCommand

java.lang.Object
  extended by org.apache.ddlutils.task.Command
      extended by org.apache.ddlutils.task.DatabaseCommand
          extended by org.apache.ddlutils.task.DatabaseCommandWithCreationParameters
              extended by org.apache.ddlutils.task.WriteSchemaSqlToFileCommand

public class WriteSchemaSqlToFileCommand
extends DatabaseCommandWithCreationParameters

Parses the schema XML files specified in the enclosing task, and writes the SQL statements necessary to create this schema in the database, to a file. Note that this SQL is database specific and hence this subtask requires that for the enclosing task, either a data source is specified (via the database sub element) or the databaseType attribute is used to specify the database type.

Version:
$Revision: 289996 $

Field Summary
 
Fields inherited from class org.apache.ddlutils.task.Command
_log
 
Constructor Summary
WriteSchemaSqlToFileCommand()
           
 
Method Summary
 void execute(DatabaseTaskBase task, Database model)
          Executes this command.
protected  boolean isAlterDatabase()
          Determines whether to alter the database if it already exists, or re-set it.
protected  boolean isDoDrops()
          Determines whether SQL is generated to drop tables and the associated constraints if necessary.
 void setAlterDatabase(boolean alterTheDb)
          Specifies whether DdlUtils shall generate SQL to alter an existing database rather than SQL for clearing it and creating it new.
 void setDoDrops(boolean doDrops)
          Specifies whether SQL for dropping tables, external constraints, etc.
 void setOutputFile(File outputFile)
          Specifies the name of the file to write the SQL commands to.
 
Methods inherited from class org.apache.ddlutils.task.DatabaseCommandWithCreationParameters
addConfiguredParameter, getFilteredParameters
 
Methods inherited from class org.apache.ddlutils.task.DatabaseCommand
getCatalogPattern, getDatabaseType, getDataSource, getPlatform, getSchemaPattern, isRequiringModel, setPlatformConfiguration
 
Methods inherited from class org.apache.ddlutils.task.Command
handleException, isFailOnError, setFailOnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WriteSchemaSqlToFileCommand

public WriteSchemaSqlToFileCommand()
Method Detail

setOutputFile

public void setOutputFile(File outputFile)
Specifies the name of the file to write the SQL commands to.

Parameters:
outputFile - The output file

isAlterDatabase

protected boolean isAlterDatabase()
Determines whether to alter the database if it already exists, or re-set it.

Returns:
true if to alter the database

setAlterDatabase

public void setAlterDatabase(boolean alterTheDb)
Specifies whether DdlUtils shall generate SQL to alter an existing database rather than SQL for clearing it and creating it new.

Parameters:
alterTheDb - true if SQL to alter the database shall be created

isDoDrops

protected boolean isDoDrops()
Determines whether SQL is generated to drop tables and the associated constraints if necessary.

Returns:
true if drops SQL shall be generated if necessary

setDoDrops

public void setDoDrops(boolean doDrops)
Specifies whether SQL for dropping tables, external constraints, etc. is created if necessary. Note that this is only relevant when alterDatabase is false.

Parameters:
doDrops - true if drops shall be performed if necessary

execute

public void execute(DatabaseTaskBase task,
                    Database model)
             throws org.apache.tools.ant.BuildException
Executes this command.

Specified by:
execute in class Command
Parameters:
task - The executing task
model - The database model
Throws:
org.apache.tools.ant.BuildException


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.