org.jpox
Class SchemaTool

java.lang.Object
  extended byorg.jpox.PMFConfiguration
      extended byorg.jpox.SchemaTool

public class SchemaTool
extends PMFConfiguration

Provides user-domain utilities for the maintenace of schemas. These utilities cover the creation of a set of tables representing classes specified in input JDO meta-data files. Additionally the tables representing these classes can be deleted.

Version:
$Revision: 1.39 $

Nested Class Summary
 
Nested classes inherited from class org.jpox.PMFConfiguration
PMFConfiguration.ObjectPropertySetter, PMFConfiguration.StringPropertySetter
 
Field Summary
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_DUMPDDL
          dump dll to 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.jpox.PMFConfiguration
ADD_UNIQUE_CONSTRAINT_MAP_INVERSE_PROPERTY, AUTO_CREATE_COLUMNS_PROPERTY, AUTO_CREATE_CONSTRAINTS_PROPERTY, AUTO_CREATE_SCHEMA_PROPERTY, AUTO_CREATE_TABLES_PROPERTY, AUTO_CREATE_WARN_ON_ERROR_PROPERTY, AUTO_START_CLASS_NAMES_PROPERTY, AUTO_START_MECHANISM_MODE_PROPERTY, AUTO_START_MECHANISM_PROPERTY, AUTO_START_MECHANISM_XML_FILE_PROPERTY, CACHE_COLLECTIONS_LAZY_PROPERTY, CACHE_COLLECTIONS_PROPERTY, CACHE_LEVEL_1_TYPE_PROPERTY, CACHE_LEVEL_2_CACHE_NAME_PROPERTY, CACHE_LEVEL_2_CONFIGURATION_FILE_PROPERTY, CACHE_LEVEL_2_PROPERTY, CACHE_LEVEL_2_TYPE_PROPERTY, CHECK_EXIST_TABLES_VIEWS_PROPERTY, CLASS_LOADER_RESOLVER_NAME_PROPERTY, configurable, CONNECTION_POOLING_CONFIGURATION_FILE_PROPERTY, CONNECTION_POOLING_TYPE_PROPERTY, DATASTORE_ADAPTER_CLASSNAME_PROPERTY, DATASTORE_CLASS_ADDITION_MAX_RETRIES_PROPERTY, DATASTORE_DELAY_OPERATIONS_UNTIL_COMMIT_PROPERTY, DATE_TIMEZONE_PROPERTY, DEFAULT_INHERITANCE_STRATEGY_PROPERTY, DETACH_ON_CLOSE_PROPERTY, FIXED_SCHEMA_PROPERTY, FOREIGN_KEY_AUTO_MODE, FOREIGN_KEY_CREATE_MODE_PROPERTY, FOREIGN_KEY_STRICT_MODE, GENERATOR_ID_CLASS_PROPERTY, IMPLEMENTATION_CREATOR_NAME_PROPERTY, INITILIAZE_PRIMARY_KEY_COLUMN_INFO, JDO_CONNECTION_FACTORY_NAME_PROPERTY, JDO_CONNECTION_FACTORY_PROPERTY, JDO_CONNECTION_FACTORY2_NAME_PROPERTY, JDO_CONNECTION_FACTORY2_PROPERTY, JDO_DATASTORE_DRIVERNAME_PROPERTY, JDO_DATASTORE_PASSWORD_PROPERTY, JDO_DATASTORE_URL_PROPERTY, JDO_DATASTORE_USERNAME_PROPERTY, JDO_DETACHALLONCOMMIT_PROPERTY, JDO_IGNORECACHE_PROPERTY, JDO_MAPPING_CATALOG_PROPERTY, JDO_MAPPING_PROPERTY, JDO_MAPPING_SCHEMA_PROPERTY, JDO_MULTITHREADED_PROPERTY, JDO_NONTRANSACTIONAL_READ_PROPERTY, JDO_NONTRANSACTIONAL_WRITE_PROPERTY, JDO_OPTIMISTIC_PROPERTY, JDO_RESTOREVALUES_PROPERTY, JDO_RETAINVALUES_PROPERTY, MAX_FETCH_DEPTH_PROPERTY, METADATA_JDO_FILE_EXTENSION_PROPERTY, METADATA_JDOQUERY_FILE_EXTENSION_PROPERTY, METADATA_ORM_FILE_EXTENSION_PROPERTY, METADATA_VALIDATE_PROPERTY, PERSISTENCE_BY_REACHABILITY_AT_COMMIT, POID_TRANSACTION_ATTRIBUTE_PROPERTY, POID_TRANSACTION_ISOLATION_PROPERTY, PROPERTIES_FILE, QUERY_ALLOW_ALL_SQL_STATEMENTS, QUERY_FETCH_DIRECTION_PROPERTY, QUERY_FETCH_SIZE_PROPERTY, QUERY_RESULT_SET_CONCURRENCY_PROPERTY, QUERY_RESULT_SET_TYPE_PROPERTY, QUERY_TIMEOUT_PROPERTY, QUERY_USE_FETCH_PLAN_PROPERTY, QUERY_USE_INNER_JOINS_ONLY_PROPERTY, READ_ONLY_SCHEMA_PROPERTY, STRING_DEFAULT_LENGTH_PROPERTY, TRANSACTION_ISOLATION_PROPERTY, USE_UPDATE_LOCK_PROPERTY, VALIDATE_COLUMNS_PROPERTY, VALIDATE_CONSTRAINTS_PROPERTY, VALIDATE_TABLES_PROPERTY
 
Constructor Summary
SchemaTool()
          Constructor
 
Method Summary
static int createSchemaTables(java.net.URL[] jdoFileURLs, java.io.File propsFile, boolean verbose)
          Method to handle the creation of a schema's tables.
static int deleteSchemaTables(java.net.URL[] jdoFileURLs, java.io.File propsFile, boolean verbose)
          Method to handle the deletion of a schema's tables.
 java.lang.String[] getDefaultArgs()
           
 java.lang.String getDumpDdl()
           
 java.lang.String getMode()
           
 PMFContext getPmfContext()
           
static java.util.Properties getPropertiesForDatastore(boolean verbose)
          Utility to set up the properties defining the datastore.
static java.util.Properties getPropertiesFromFile(java.io.File propsFile)
          Utility to generate a Properties object from the specified properties file.
protected  java.util.Map initPropertySetters()
          Initialize the PROPERTY_SETTERS Map.
 boolean isHelp()
           
 boolean isVerbose()
           
static void main(java.lang.String[] args)
          Entry method when invoked from the command line.
static int outputDBInfo(java.io.File propsFile, boolean verbose)
          Method to output the database information.
static int outputSchemaInfo(java.io.File propsFile, boolean verbose)
          Method to output the schema information.
 void setCommandLineArgs(java.lang.String[] args)
          Initialize the command line arguments
 void setDumpDdl(java.lang.String dumpDdl)
           
 void setHelp(boolean help)
           
 void setMode(java.lang.String mode)
           
 void setVerbose(boolean verbose)
           
static int validateSchemaTables(java.net.URL[] jdoFileURLs, java.io.File propsFile, boolean verbose)
          Method to handle the validation of a schema's tables.
 
Methods inherited from class org.jpox.PMFConfiguration
assertConfigurable, equals, getAutoCreateColumns, getAutoCreateConstraints, getAutoCreateTables, getAutoCreateWarnOnError, getAutoStartClassNames, getAutoStartMechanism, getAutoStartMechanismMode, getAutoStartMechanismXmlFile, getCalendarForDateTimezone, getCatalog, getCheckExistTablesOrViews, getClassLoaderResolverName, getConnectionDriverName, getConnectionFactory, getConnectionFactory2, getConnectionFactory2Name, getConnectionFactoryName, getConnectionPassword, getConnectionPoolingConfigurationFile, getConnectionPoolingType, getConnectionURL, getConnectionUserName, getDatastoreAdapterClassName, getDatastoreClassAdditionMaxRetries, getDatastoreDelayOperationsEnabled, getDateTimezone, getDefaultInheritanceStrategy, getDetachAllOnCommit, getDetachOnClose, getDictionary, getFixedSchema, getForeignKeyCreateMode, getIdentifierCase, getIdentifierNamingStrategy, getIdentifierTablePrefix, getIdentifierTableSuffix, getIdentifierWordSeparator, getIgnoreCache, getImplementationCreatorName, getInitializePrimaryKeyColumnInfo, getJdoCacheCollections, getJdoCacheCollectionsLazy, getJdoCacheLevel1Type, getJdoCacheLevel2, getJdoCacheLevel2CacheName, getJdoCacheLevel2ConfigurationFile, getJdoCacheLevel2Type, getJdoMetaDataFileExtension, getJdoqueryMetaDataFileExtension, getMapping, getMaxFetchDepth, getMetaDataValidate, getMultithreaded, getNontransactionalRead, getNontransactionalWrite, getOptimistic, getOptions, getOrmMetaDataFileExtension, getPersistenceByReachabilityAtCommit, getPersistentIdGenerator, getPoidTransactionAttribute, getPoidTransactionIsolationLevel, getPropertiesFile, getQueryFetchDirection, getQueryFetchSize, getQueryResultSetConcurrency, getQueryResultSetType, getQueryTimeout, getQueryUseFetchPlan, getQueryUseInnerJoinsOnly, getReadOnlySchema, getRestoreValues, getRetainValues, getSchema, getStringDefaultLength, getTransactionIsolation, getUniqueConstraintsMapInverse, getUseUpdateLock, getValidateColumns, getValidateConstraints, getValidateTables, isQueryAllowAllSQLStatements, setAutoCreateColumns, setAutoCreateConstraints, setAutoCreateSchema, setAutoCreateTables, setAutoCreateWarnOnError, setAutoStartClassNames, setAutoStartMechanism, setAutoStartMechanismMode, setAutoStartMechanismXmlFile, setCatalog, setCheckExistTablesOrViews, setClassLoaderResolverName, setConnectionDriverName, setConnectionFactory, setConnectionFactory2, setConnectionFactory2Name, setConnectionFactoryName, setConnectionPassword, setConnectionPoolingConfigurationFile, setConnectionPoolingType, setConnectionURL, setConnectionUserName, setDatastoreAdapterClassName, setDatastoreClassAdditionMaxRetries, setDatastoreDelayOperationsEnabled, setDateTimezone, setDefaultInheritanceStrategy, setDetachAllOnCommit, setDetachOnClose, setFixedSchema, setForeignKeyCreateMode, setIdentifierCase, setIdentifierNamingStrategy, setIdentifierTablePrefix, setIdentifierTableSuffix, setIdentifierWordSeparator, setIgnoreCache, setImplementationCreatorName, setInitializePrimaryKeyColumnInfo, setJdoCacheCollections, setJdoCacheCollectionsLazy, setJdoCacheLevel1Type, setJdoCacheLevel2, setJdoCacheLevel2CacheName, setJdoCacheLevel2ConfigurationFile, setJdoCacheLevel2Type, setJdoMetaDataFileExtension, setJdoqueryMetaDataFileExtension, setMapping, setMaxFetchDepth, setMetaDataValidate, setMultithreaded, setNontransactionalRead, setNontransactionalWrite, setOptimistic, setOptions, setOptions, setOrmMetaDataFileExtension, setPersistenceByReachabilityAtCommit, setPersistentIdGenerator, setPoidTransactionAttribute, setPoidTransactionIsolation, setPoidTransactionIsolation, setPropertiesFile, setQueryAllowAllSQLStatements, setQueryFetchDirection, setQueryFetchSize, setQueryResultSetConcurrency, setQueryResultSetType, setQueryTimeout, setQueryUseFetchPlan, setQueryUseInnerJoinsOnly, setReadOnlySchema, setRestoreValues, setRetainValues, setSchema, setStringDefaultLength, setTransactionIsolation, setTransactionIsolation, setUniqueConstraintsMapInverse, setUseUpdateLock, setValidateColumns, setValidateConstraints, setValidateTables
 
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_DUMPDDL

public static final java.lang.String SCHEMATOOL_OPTION_DUMPDDL
dump dll to file

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
Constructor Detail

SchemaTool

public SchemaTool()
Constructor

Method Detail

createSchemaTables

public static int createSchemaTables(java.net.URL[] jdoFileURLs,
                                     java.io.File propsFile,
                                     boolean verbose)
                              throws java.lang.Exception
Method to handle the creation of a schema's tables.

Parameters:
jdoFileURLs - URLs of JDO files defining the classes to be persisted (and hence the tables to be created).
propsFile - File containing properties to use (optional)
verbose - Verbose output
Returns:
Return code
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

deleteSchemaTables

public static int deleteSchemaTables(java.net.URL[] jdoFileURLs,
                                     java.io.File propsFile,
                                     boolean verbose)
                              throws java.lang.Exception
Method to handle the deletion of a schema's tables.

Parameters:
jdoFileURLs - URLs of JDO files defining the classes to be unpersisted (and hence the tables to be deleted).
propsFile - File containing properties to use (optional)
verbose - Verbose output
Returns:
Return code
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

validateSchemaTables

public static int validateSchemaTables(java.net.URL[] jdoFileURLs,
                                       java.io.File propsFile,
                                       boolean verbose)
                                throws java.lang.Exception
Method to handle the validation of a schema's tables.

Parameters:
jdoFileURLs - URLs of JDO files defining the classes to be validated
propsFile - File containing properties to use (optional)
verbose - Verbose output
Returns:
Return code
Throws:
java.lang.Exception - Thrown when either an error occurs parsing the MetaData, or the DB definition is not defined.

outputDBInfo

public static int outputDBInfo(java.io.File propsFile,
                               boolean verbose)
                        throws java.lang.Exception
Method to output the database information.

Parameters:
propsFile - File containing properties to use (optional)
verbose - Verbose output
Returns:
Return code
Throws:
java.lang.Exception - Thrown when the DB definition is not defined.

outputSchemaInfo

public static int outputSchemaInfo(java.io.File propsFile,
                                   boolean verbose)
                            throws java.lang.Exception
Method to output the schema information.

Parameters:
propsFile - File containing properties to use (optional)
verbose - Verbose output
Returns:
Return code
Throws:
java.lang.Exception - Thrown when the DB definition is not defined.

getPropertiesForDatastore

public static java.util.Properties getPropertiesForDatastore(boolean verbose)
                                                      throws java.lang.Exception
Utility to set up the properties defining the datastore. Uses the DatabaseProperties object to obtain them from System.properties.

Parameters:
verbose - Verbose output
Returns:
The properties definition for the datastore.
Throws:
java.lang.Exception - Thrown when the datastore is not fully specified.

getPropertiesFromFile

public static java.util.Properties getPropertiesFromFile(java.io.File propsFile)
Utility to generate a Properties object from the specified properties file.

Parameters:
propsFile - Properties file
Returns:
The Properties to use with the PMF

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

setCommandLineArgs

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

Parameters:
args -

isHelp

public boolean isHelp()
Returns:
the help

setHelp

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

getMode

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

setMode

public void setMode(java.lang.String mode)
Parameters:
mode - the mode to set

isVerbose

public boolean isVerbose()
Returns:
the verbose

setVerbose

public void setVerbose(boolean verbose)
Parameters:
verbose - the verbose to set

getDefaultArgs

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

getPmfContext

public PMFContext getPmfContext()
Returns:
the pmfContext

getDumpDdl

public java.lang.String getDumpDdl()
Returns:
the dumpDdl

setDumpDdl

public void setDumpDdl(java.lang.String dumpDdl)
Parameters:
dumpDdl - the dumpDdl to set

initPropertySetters

protected java.util.Map initPropertySetters()
Initialize the PROPERTY_SETTERS Map.

Overrides:
initPropertySetters in class PMFConfiguration
Returns:
The PROPERTY_SETTERS Map.


Copyright © -2007 . All Rights Reserved.