org.datanucleus.store.rdbms
Class SchemaTool

java.lang.Object
  extended by org.datanucleus.PersistenceConfiguration
      extended by org.datanucleus.store.rdbms.SchemaTool

public class SchemaTool
extends org.datanucleus.PersistenceConfiguration

SchemaTool providing an interface for the maintenance of schemas. These utilities include:-


Field Summary
static org.datanucleus.util.NucleusLogger LOGGER
           
static int SCHEMATOOL_CREATE_MODE
          create mode
static int SCHEMATOOL_DATABASE_INFO_MODE
          database info mode
static int SCHEMATOOL_DELETE_MODE
          delete mode
static java.lang.String SCHEMATOOL_OPTION_COMPLETEDDL
          create complete DDL, not only for missing elements
static java.lang.String SCHEMATOOL_OPTION_DDLFILE
          Property specifying the name of a DDL file
static java.lang.String SCHEMATOOL_OPTION_HELP
          output help for schema tool
static java.lang.String SCHEMATOOL_OPTION_MODE
          schema tool mode
static java.lang.String SCHEMATOOL_OPTION_PROPERTIES_FILE
          properties file for schema tool
static java.lang.String SCHEMATOOL_OPTION_VERBOSE
          schema tool in verbose
static int SCHEMATOOL_SCHEMA_INFO_MODE
          schema info mode
static int SCHEMATOOL_VALIDATE_MODE
          validate mode
 
Fields inherited from class org.datanucleus.PersistenceConfiguration
configurable
 
Constructor Summary
SchemaTool()
          Constructor
 
Method Summary
 void createSchema(javax.jdo.PersistenceManagerFactory pmf, java.util.List inputClassNames)
          Method to handle the creation of the schema for a set of classes.
 void deleteSchema(javax.jdo.PersistenceManagerFactory pmf, java.util.List inputClassNames)
          Method to handle the deletion of a schema's tables.
 java.lang.String getApi()
          Acessor for the API (JDO, JPA)
 boolean getCompleteDdl()
           
 java.lang.String getDdlFile()
          Accessor for the DDL filename
 java.lang.String[] getDefaultArgs()
           
protected static org.datanucleus.metadata.FileMetaData[] getFileMetaDataForInput(org.datanucleus.metadata.MetaDataManager metaDataMgr, org.datanucleus.ClassLoaderResolver clr, boolean verbose, java.lang.String persistenceUnitName, java.lang.String[] inputFiles)
          Method to take the input for SchemaTool and returns the FileMetaData that it implies.
 java.lang.String getModeName()
           
 java.lang.String getPersistenceUnitName()
          Acessor for the persistence unit name
protected static javax.jdo.PersistenceManagerFactory getPMFForMode(int mode, java.lang.String api, java.util.Map userProps, java.lang.String persistenceUnitName, java.lang.String ddlFile, boolean verbose)
          Method to create a PersistenceManagerFactory for the specified mode of SchemaTool
 java.lang.String getPropsFileName()
          Acessor for the properties file name (optional).
 boolean isHelp()
           
 boolean isVerbose()
           
static void main(java.lang.String[] args)
          Entry method when invoked from the command line.
 SchemaTool setApi(java.lang.String api)
          Mutator for the API (JDO, JPA)
 void setCommandLineArgs(java.lang.String[] args)
          Initialize the command line arguments
 SchemaTool setCompleteDdl(boolean completeDdl)
          Mutator for the flag to output complete DDL (when using DDL file)
 SchemaTool setDdlFile(java.lang.String file)
          Mutator for the DDL file
 void setHelp(boolean help)
           
 SchemaTool setModeName(java.lang.String mode)
           
 SchemaTool setPersistenceUnitName(java.lang.String unit)
          Mutator for the persistence-unit name.
 SchemaTool setVerbose(boolean verbose)
           
 void validateSchema(javax.jdo.PersistenceManagerFactory pmf, java.util.List inputClassNames)
          Method to handle the validation of a schema's tables.
 
Methods inherited from class org.datanucleus.PersistenceConfiguration
assertConfigurable, equals, getBooleanObjectProperty, getBooleanProperty, getBooleanProperty, getCalendarForDateTimezone, getIntProperty, getLongProperty, getOptions, getPrimaryClassLoader, getProperty, getStringProperty, getSupportedOptions, hasProperty, isJcaMode, setDefaultProperties, setJCAMode, setOptions, setPrimaryClassLoader, setPropertiesFile, setProperty
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEMATOOL_CREATE_MODE

public static final int SCHEMATOOL_CREATE_MODE
create mode

See Also:
Constant Field Values

SCHEMATOOL_DELETE_MODE

public static final int SCHEMATOOL_DELETE_MODE
delete mode

See Also:
Constant Field Values

SCHEMATOOL_VALIDATE_MODE

public static final int SCHEMATOOL_VALIDATE_MODE
validate mode

See Also:
Constant Field Values

SCHEMATOOL_DATABASE_INFO_MODE

public static final int SCHEMATOOL_DATABASE_INFO_MODE
database info mode

See Also:
Constant Field Values

SCHEMATOOL_SCHEMA_INFO_MODE

public static final int SCHEMATOOL_SCHEMA_INFO_MODE
schema info mode

See Also:
Constant Field Values

SCHEMATOOL_OPTION_MODE

public static final java.lang.String SCHEMATOOL_OPTION_MODE
schema tool mode

See Also:
Constant Field Values

SCHEMATOOL_OPTION_VERBOSE

public static final java.lang.String SCHEMATOOL_OPTION_VERBOSE
schema tool in verbose

See Also:
Constant Field Values

SCHEMATOOL_OPTION_PROPERTIES_FILE

public static final java.lang.String SCHEMATOOL_OPTION_PROPERTIES_FILE
properties file for schema tool

See Also:
Constant Field Values

SCHEMATOOL_OPTION_DDLFILE

public static final java.lang.String SCHEMATOOL_OPTION_DDLFILE
Property specifying the name of a DDL file

See Also:
Constant Field Values

SCHEMATOOL_OPTION_COMPLETEDDL

public static final java.lang.String SCHEMATOOL_OPTION_COMPLETEDDL
create complete DDL, not only for missing elements

See Also:
Constant Field Values

SCHEMATOOL_OPTION_HELP

public static final java.lang.String SCHEMATOOL_OPTION_HELP
output help for schema tool

See Also:
Constant Field Values

LOGGER

public static org.datanucleus.util.NucleusLogger LOGGER
Constructor Detail

SchemaTool

public SchemaTool()
Constructor

Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Entry method when invoked from the command line.

Parameters:
args - List of options for processing by the available methods in this class.
Throws:
java.lang.Exception

getPMFForMode

protected static javax.jdo.PersistenceManagerFactory getPMFForMode(int mode,
                                                                   java.lang.String api,
                                                                   java.util.Map userProps,
                                                                   java.lang.String persistenceUnitName,
                                                                   java.lang.String ddlFile,
                                                                   boolean verbose)
Method to create a PersistenceManagerFactory for the specified mode of SchemaTool

Parameters:
mode - Mode of operation of SchemaTool
api - Persistence API
userProps - Map containing user provided properties (usually input via a file)
persistenceUnitName - Name of the persistence-unit (if any)
ddlFile - Name of a file to output DDL to
verbose - Verbose mode
Returns:
The PersistenceManagerFactory to use
Throws:
org.datanucleus.exceptions.NucleusException - Thrown if an error occurs in creating the required PMF

getFileMetaDataForInput

protected static org.datanucleus.metadata.FileMetaData[] getFileMetaDataForInput(org.datanucleus.metadata.MetaDataManager metaDataMgr,
                                                                                 org.datanucleus.ClassLoaderResolver clr,
                                                                                 boolean verbose,
                                                                                 java.lang.String persistenceUnitName,
                                                                                 java.lang.String[] inputFiles)
Method to take the input for SchemaTool and returns the FileMetaData that it implies. The input should either be a persistence-unit name, or a set of input files.

Parameters:
metaDataMgr - Manager for MetaData
clr - ClassLoader resolver
verbose - Whether to put message verbosely
persistenceUnitName - Name of the "persistence-unit"
inputFiles - Input metadata/class files
Returns:
The FileMetaData for the input
Throws:
org.datanucleus.exceptions.NucleusException - Thrown if error(s) occur in processing the input

createSchema

public void createSchema(javax.jdo.PersistenceManagerFactory pmf,
                         java.util.List inputClassNames)
                  throws java.lang.Exception
Method to handle the creation of the schema for a set of classes. If no classes are supplied then assumes that all "known" classes (for this PMF) should be processed.

Parameters:
pmf - PersistenceManagerFactory to use when generating the schema
inputClassNames - names of all classes whose schema is to be created
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

deleteSchema

public void deleteSchema(javax.jdo.PersistenceManagerFactory pmf,
                         java.util.List inputClassNames)
                  throws java.lang.Exception
Method to handle the deletion of a schema's tables. If no classes are supplied then assumes that all "known" classes (for this PMF) should be processed.

Parameters:
pmf - PersistenceManagerFactory to use when generating the schema
inputClassNames - names of all classes whose schema is to be created
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

validateSchema

public void validateSchema(javax.jdo.PersistenceManagerFactory pmf,
                           java.util.List inputClassNames)
                    throws java.lang.Exception
Method to handle the validation of a schema's tables. If no classes are supplied then assumes that all "known" classes (for this PMF) should be processed.

Parameters:
pmf - PersistenceManagerFactory to use when generating the schema
inputClassNames - names of all classes whose schema is to be created
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

setCommandLineArgs

public void setCommandLineArgs(java.lang.String[] args)
Initialize the command line arguments

Parameters:
args - Command line args

isHelp

public boolean isHelp()
Returns:
the help

setHelp

public void setHelp(boolean help)
Parameters:
help - the help to set

setCompleteDdl

public SchemaTool setCompleteDdl(boolean completeDdl)
Mutator for the flag to output complete DDL (when using DDL file)

Parameters:
completeDdl - Whether to return complete DDL
Returns:
The SchemaTool instance

getCompleteDdl

public boolean getCompleteDdl()
Returns:
whether to use generate DDL (or just update DDL)

getModeName

public java.lang.String getModeName()
Returns:
the mode

setModeName

public SchemaTool setModeName(java.lang.String mode)
Parameters:
mode - the mode to set
Returns:
The SchemaTool instance

getApi

public java.lang.String getApi()
Acessor for the API (JDO, JPA)

Returns:
the API

setApi

public SchemaTool setApi(java.lang.String api)
Mutator for the API (JDO, JPA)

Parameters:
api - the API
Returns:
The SchemaTool instance

getPersistenceUnitName

public java.lang.String getPersistenceUnitName()
Acessor for the persistence unit name

Returns:
the unit name

setPersistenceUnitName

public SchemaTool setPersistenceUnitName(java.lang.String unit)
Mutator for the persistence-unit name.

Parameters:
unit - Unit name
Returns:
The SchemaTool instance

isVerbose

public boolean isVerbose()
Returns:
the verbose

setVerbose

public SchemaTool setVerbose(boolean verbose)
Parameters:
verbose - the verbose to set
Returns:
The SchemaTool instance

getDefaultArgs

public java.lang.String[] getDefaultArgs()
Returns:
the defaultArgs

getDdlFile

public java.lang.String getDdlFile()
Accessor for the DDL filename

Returns:
the file to use when outputing the DDL

setDdlFile

public SchemaTool setDdlFile(java.lang.String file)
Mutator for the DDL file

Parameters:
file - the file to use when outputting the DDL
Returns:
The SchemaTool instance

getPropsFileName

public java.lang.String getPropsFileName()
Acessor for the properties file name (optional).

Returns:
the props file name


Copyright © 2009. All Rights Reserved.