Package org.datanucleus.store.schema
Class SchemaTool
- java.lang.Object
-
- org.datanucleus.store.schema.SchemaTool
-
public class SchemaTool extends java.lang.ObjectSchemaTool providing an interface for the maintenance of schemas. These utilities include:-- creation of a schema/catalog in the datastore
- deletion of a schema/catalog in the datastore
- creation of tables representing classes specified in input data
- deletion of tables representing classes specified in input data
- validation of tables representing classes specified in input data
- details about the datastore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSchemaTool.Mode
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringapiNameName of the persistence API to use.private java.lang.StringcatalogNameName of the schema (for use with createDatabase, deleteDatabase modes).private booleancompleteDdlWhen generating DDL to a file, whether to generate complete DDL, or just for missing components.private java.lang.StringddlFilenameName of a file in which to put the DDL (or null if wanting to execute in the datastore).private booleanincludeAutoStartWhen updating the schema, whether to include any auto-start mechanism.static NucleusLoggerLOGGERstatic java.lang.StringOPTION_APIstatic java.lang.StringOPTION_CATALOG_NAMEstatic java.lang.StringOPTION_COMPLETE_DDLstatic java.lang.StringOPTION_CREATE_DATABASEstatic java.lang.StringOPTION_CREATE_TABLES_FOR_CLASSESstatic java.lang.StringOPTION_DBINFOstatic java.lang.StringOPTION_DDL_FILEstatic java.lang.StringOPTION_DELETE_CREATE_TABLES_FOR_CLASSESstatic java.lang.StringOPTION_DELETE_DATABASEstatic java.lang.StringOPTION_DELETE_TABLES_FOR_CLASSESstatic java.lang.StringOPTION_INCLUDE_AUTO_STARTstatic java.lang.StringOPTION_SCHEMA_NAMEstatic java.lang.StringOPTION_SCHEMAINFOstatic java.lang.StringOPTION_VALIDATE_TABLES_FOR_CLASSESprivate java.lang.StringschemaNameName of the schema (for use with createDatabase, deleteDatabase modes).private booleanverboseWhether to operate in verbose mode.
-
Constructor Summary
Constructors Constructor Description SchemaTool()Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateDatabase(SchemaAwareStoreManager storeMgr, java.lang.String catalogName, java.lang.String schemaName)voidcreateSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)voiddeleteDatabase(SchemaAwareStoreManager storeMgr, java.lang.String catalogName, java.lang.String schemaName)voiddeleteSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)java.lang.StringgetApi()Accessor for the metadata API (JDO, JPA) in use (metadata definition)java.lang.StringgetCatalogName()booleangetCompleteDdl()java.lang.StringgetDdlFile()booleangetIncludeAutoStart()static PersistenceNucleusContextgetNucleusContextForMode(SchemaTool.Mode mode, java.lang.String api, java.util.Map userProps, java.lang.String persistenceUnitName, java.lang.String ddlFile, boolean verbose)Method to create a NucleusContext for the specified mode of SchemaToolstatic PersistenceNucleusContextgetNucleusContextForMode(SchemaTool.Mode mode, java.lang.String api, java.util.Map userProps, java.lang.String persistenceUnitName, java.lang.String ddlFile, boolean verbose, boolean ignoreMetaDataForMissingClasses)Method to create a NucleusContext for the specified mode of SchemaTooljava.util.PropertiesgetPropertiesForSchemaTool()Method to generate the properties to be used by SchemaTool.java.lang.StringgetSchemaName()booleanisVerbose()static voidmain(java.lang.String[] args)Entry method when invoked from the command line.SchemaToolsetApi(java.lang.String api)Mutator for the metadata API (JDO, JPA)SchemaToolsetCatalogName(java.lang.String catalogName)SchemaToolsetCompleteDdl(boolean completeDdl)SchemaToolsetDdlFile(java.lang.String file)SchemaToolsetIncludeAutoStart(boolean include)SchemaToolsetSchemaName(java.lang.String schemaName)SchemaToolsetVerbose(boolean verbose)voidvalidateSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)
-
-
-
Field Detail
-
LOGGER
public static final NucleusLogger LOGGER
-
OPTION_CREATE_DATABASE
public static final java.lang.String OPTION_CREATE_DATABASE
- See Also:
- Constant Field Values
-
OPTION_DELETE_DATABASE
public static final java.lang.String OPTION_DELETE_DATABASE
- See Also:
- Constant Field Values
-
OPTION_CREATE_TABLES_FOR_CLASSES
public static final java.lang.String OPTION_CREATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DELETE_TABLES_FOR_CLASSES
public static final java.lang.String OPTION_DELETE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
public static final java.lang.String OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_VALIDATE_TABLES_FOR_CLASSES
public static final java.lang.String OPTION_VALIDATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DBINFO
public static final java.lang.String OPTION_DBINFO
- See Also:
- Constant Field Values
-
OPTION_SCHEMAINFO
public static final java.lang.String OPTION_SCHEMAINFO
- See Also:
- Constant Field Values
-
OPTION_DDL_FILE
public static final java.lang.String OPTION_DDL_FILE
- See Also:
- Constant Field Values
-
OPTION_COMPLETE_DDL
public static final java.lang.String OPTION_COMPLETE_DDL
- See Also:
- Constant Field Values
-
OPTION_INCLUDE_AUTO_START
public static final java.lang.String OPTION_INCLUDE_AUTO_START
- See Also:
- Constant Field Values
-
OPTION_API
public static final java.lang.String OPTION_API
- See Also:
- Constant Field Values
-
OPTION_CATALOG_NAME
public static final java.lang.String OPTION_CATALOG_NAME
- See Also:
- Constant Field Values
-
OPTION_SCHEMA_NAME
public static final java.lang.String OPTION_SCHEMA_NAME
- See Also:
- Constant Field Values
-
apiName
private java.lang.String apiName
Name of the persistence API to use.
-
schemaName
private java.lang.String schemaName
Name of the schema (for use with createDatabase, deleteDatabase modes).
-
catalogName
private java.lang.String catalogName
Name of the schema (for use with createDatabase, deleteDatabase modes).
-
ddlFilename
private java.lang.String ddlFilename
Name of a file in which to put the DDL (or null if wanting to execute in the datastore).
-
completeDdl
private boolean completeDdl
When generating DDL to a file, whether to generate complete DDL, or just for missing components.
-
includeAutoStart
private boolean includeAutoStart
When updating the schema, whether to include any auto-start mechanism.
-
verbose
private boolean verbose
Whether to operate in verbose mode.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args) throws java.lang.ExceptionEntry 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- If an error occurs in operation
-
getPropertiesForSchemaTool
public java.util.Properties getPropertiesForSchemaTool()
Method to generate the properties to be used by SchemaTool. This includes whether to create DDL to a file, and whether to include any auto-start mechanism- Returns:
- The properties to use with SchemaTool.
-
createDatabase
public void createDatabase(SchemaAwareStoreManager storeMgr, java.lang.String catalogName, java.lang.String schemaName)
-
deleteDatabase
public void deleteDatabase(SchemaAwareStoreManager storeMgr, java.lang.String catalogName, java.lang.String schemaName)
-
createSchemaForClasses
public void createSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)
-
deleteSchemaForClasses
public void deleteSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)
-
validateSchemaForClasses
public void validateSchemaForClasses(SchemaAwareStoreManager storeMgr, java.util.Set<java.lang.String> classNames)
-
getNucleusContextForMode
public static PersistenceNucleusContext getNucleusContextForMode(SchemaTool.Mode mode, java.lang.String api, java.util.Map userProps, java.lang.String persistenceUnitName, java.lang.String ddlFile, boolean verbose)
Method to create a NucleusContext for the specified mode of SchemaTool- Parameters:
mode- Mode of operation of SchemaToolapi- Persistence APIuserProps- 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 toverbose- Verbose mode- Returns:
- The NucleusContext to use
- Throws:
NucleusException- Thrown if an error occurs in creating the required NucleusContext
-
getNucleusContextForMode
public static PersistenceNucleusContext getNucleusContextForMode(SchemaTool.Mode mode, java.lang.String api, java.util.Map userProps, java.lang.String persistenceUnitName, java.lang.String ddlFile, boolean verbose, boolean ignoreMetaDataForMissingClasses)
Method to create a NucleusContext for the specified mode of SchemaTool- Parameters:
mode- Mode of operation of SchemaToolapi- Persistence APIuserProps- 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 toverbose- Verbose modeignoreMetaDataForMissingClasses- Whether to ignore metadata for missing classes- Returns:
- The NucleusContext to use
- Throws:
NucleusException- Thrown if an error occurs in creating the required NucleusContext
-
getApi
public java.lang.String getApi()
Accessor for the metadata API (JDO, JPA) in use (metadata definition)- Returns:
- the API
-
setApi
public SchemaTool setApi(java.lang.String api)
Mutator for the metadata API (JDO, JPA)- Parameters:
api- the API- 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
-
getSchemaName
public java.lang.String getSchemaName()
-
setSchemaName
public SchemaTool setSchemaName(java.lang.String schemaName)
-
getCatalogName
public java.lang.String getCatalogName()
-
setCatalogName
public SchemaTool setCatalogName(java.lang.String catalogName)
-
getDdlFile
public java.lang.String getDdlFile()
-
setDdlFile
public SchemaTool setDdlFile(java.lang.String file)
-
setCompleteDdl
public SchemaTool setCompleteDdl(boolean completeDdl)
-
getCompleteDdl
public boolean getCompleteDdl()
-
setIncludeAutoStart
public SchemaTool setIncludeAutoStart(boolean include)
-
getIncludeAutoStart
public boolean getIncludeAutoStart()
-
-