Package org.datanucleus.store.schema
Class SchemaTool
- java.lang.Object
-
- org.datanucleus.store.schema.SchemaTool
-
public class SchemaTool extends Object
SchemaTool 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 class
SchemaTool.Mode
-
Field Summary
Fields Modifier and Type Field Description static NucleusLogger
LOGGER
static String
OPTION_API
static String
OPTION_CATALOG_NAME
static String
OPTION_COMPLETE_DDL
static String
OPTION_CREATE_DATABASE
static String
OPTION_CREATE_TABLES_FOR_CLASSES
static String
OPTION_DBINFO
static String
OPTION_DDL_FILE
static String
OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
static String
OPTION_DELETE_DATABASE
static String
OPTION_DELETE_TABLES_FOR_CLASSES
static String
OPTION_INCLUDE_AUTO_START
static String
OPTION_SCHEMA_NAME
static String
OPTION_SCHEMAINFO
static String
OPTION_VALIDATE_TABLES_FOR_CLASSES
-
Constructor Summary
Constructors Constructor Description SchemaTool()
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
createDatabase(SchemaAwareStoreManager storeMgr, String catalogName, String schemaName)
void
createSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
void
deleteDatabase(SchemaAwareStoreManager storeMgr, String catalogName, String schemaName)
void
deleteSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
String
getApi()
Accessor for the metadata API (JDO, JPA) in use (metadata definition)String
getCatalogName()
boolean
getCompleteDdl()
String
getDdlFile()
boolean
getIncludeAutoStart()
static PersistenceNucleusContext
getNucleusContextForMode(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose)
Method to create a NucleusContext for the specified mode of SchemaToolstatic PersistenceNucleusContext
getNucleusContextForMode(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, String ddlFile, boolean verbose, boolean ignoreMetaDataForMissingClasses)
Method to create a NucleusContext for the specified mode of SchemaToolProperties
getPropertiesForSchemaTool()
Method to generate the properties to be used by SchemaTool.String
getSchemaName()
boolean
isVerbose()
static void
main(String[] args)
Entry method when invoked from the command line.SchemaTool
setApi(String api)
Mutator for the metadata API (JDO, JPA)SchemaTool
setCatalogName(String catalogName)
SchemaTool
setCompleteDdl(boolean completeDdl)
SchemaTool
setDdlFile(String file)
SchemaTool
setIncludeAutoStart(boolean include)
SchemaTool
setSchemaName(String schemaName)
SchemaTool
setVerbose(boolean verbose)
void
validateSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
-
-
-
Field Detail
-
LOGGER
public static final NucleusLogger LOGGER
-
OPTION_CREATE_DATABASE
public static final String OPTION_CREATE_DATABASE
- See Also:
- Constant Field Values
-
OPTION_DELETE_DATABASE
public static final String OPTION_DELETE_DATABASE
- See Also:
- Constant Field Values
-
OPTION_CREATE_TABLES_FOR_CLASSES
public static final String OPTION_CREATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DELETE_TABLES_FOR_CLASSES
public static final String OPTION_DELETE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
public static final String OPTION_DELETE_CREATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_VALIDATE_TABLES_FOR_CLASSES
public static final String OPTION_VALIDATE_TABLES_FOR_CLASSES
- See Also:
- Constant Field Values
-
OPTION_DBINFO
public static final String OPTION_DBINFO
- See Also:
- Constant Field Values
-
OPTION_SCHEMAINFO
public static final String OPTION_SCHEMAINFO
- See Also:
- Constant Field Values
-
OPTION_DDL_FILE
public static final String OPTION_DDL_FILE
- See Also:
- Constant Field Values
-
OPTION_COMPLETE_DDL
public static final String OPTION_COMPLETE_DDL
- See Also:
- Constant Field Values
-
OPTION_INCLUDE_AUTO_START
public static final String OPTION_INCLUDE_AUTO_START
- See Also:
- Constant Field Values
-
OPTION_API
public static final String OPTION_API
- See Also:
- Constant Field Values
-
OPTION_CATALOG_NAME
public static final String OPTION_CATALOG_NAME
- See Also:
- Constant Field Values
-
OPTION_SCHEMA_NAME
public static final String OPTION_SCHEMA_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Entry method when invoked from the command line.- Parameters:
args
- List of options for processing by the available methods in this class.- Throws:
Exception
- If an error occurs in operation
-
getPropertiesForSchemaTool
public 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, String catalogName, String schemaName)
-
deleteDatabase
public void deleteDatabase(SchemaAwareStoreManager storeMgr, String catalogName, String schemaName)
-
createSchemaForClasses
public void createSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
-
deleteSchemaForClasses
public void deleteSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
-
validateSchemaForClasses
public void validateSchemaForClasses(SchemaAwareStoreManager storeMgr, Set<String> classNames)
-
getNucleusContextForMode
public static PersistenceNucleusContext getNucleusContextForMode(SchemaTool.Mode mode, String api, Map userProps, String persistenceUnitName, 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, String api, Map userProps, String persistenceUnitName, 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 String getApi()
Accessor for the metadata API (JDO, JPA) in use (metadata definition)- Returns:
- the API
-
setApi
public SchemaTool setApi(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 String getSchemaName()
-
setSchemaName
public SchemaTool setSchemaName(String schemaName)
-
getCatalogName
public String getCatalogName()
-
setCatalogName
public SchemaTool setCatalogName(String catalogName)
-
getDdlFile
public String getDdlFile()
-
setDdlFile
public SchemaTool setDdlFile(String file)
-
setCompleteDdl
public SchemaTool setCompleteDdl(boolean completeDdl)
-
getCompleteDdl
public boolean getCompleteDdl()
-
setIncludeAutoStart
public SchemaTool setIncludeAutoStart(boolean include)
-
getIncludeAutoStart
public boolean getIncludeAutoStart()
-
-