|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.jetspeed.serializer.JetspeedDDLUtil
public class JetspeedDDLUtil
Jetspeed DDLUtil
The Jetspeed DDL Utility is capabale of extracting existing schema information as well as recreating databases.
Field Summary | |
---|---|
private String |
_databaseName
The database name. |
private boolean |
connected
|
private DataSource |
dataSource
The data source to test against. |
static String |
DATASOURCE_CLASS
|
static String |
DATASOURCE_DATABASENAME
|
static String |
DATASOURCE_DRIVER
|
static String |
DATASOURCE_PASSWORD
|
static String |
DATASOURCE_URL
|
static String |
DATASOURCE_USERNAME
|
private static org.apache.commons.logging.Log |
log
Logger |
private org.apache.ddlutils.model.Database |
model
The database model. |
(package private) Map |
parameters
|
private org.apache.ddlutils.Platform |
platform
|
(package private) org.apache.ddlutils.model.JdbcTypeCategoryEnum |
temEnum
|
(package private) org.apache.ddlutils.PlatformUtils |
utils
|
(package private) StringWriter |
writer
|
Constructor Summary | |
---|---|
JetspeedDDLUtil()
|
Method Summary | |
---|---|
void |
alterDatabase(org.apache.ddlutils.model.Database model)
Alter an existing database from the given model. |
protected org.apache.ddlutils.Platform |
connectToDatabase(DataSource dataSource)
Create a database connection (platform instance) from a data source |
protected org.apache.ddlutils.Platform |
connectToDatabase(String databaseType)
Create a database connection (platform instance) from a (case insensitive) database type (like MySQL) |
void |
createDatabase(org.apache.ddlutils.model.Database model)
Creates a new database from the given model. |
protected org.apache.ddlutils.model.Database |
createDatabaseSchemaFromString(String dbDef)
Parses the database defined in the given XML definition String and creates a database schema (model) object |
protected org.apache.ddlutils.model.Database |
createDatabaseSchemaFromXML(String fileName)
Parses the database defined in the given XML file and creates a database schema (model) object |
protected void |
dropDatabase()
Drops the tables defined in the database model. |
protected void |
dropDatabaseTables(org.apache.ddlutils.model.Database model)
Drops the tables defined in the database model on this connection. |
DataSource |
getDataSource()
|
protected org.apache.ddlutils.model.Database |
getModel()
Returns the database model. |
org.apache.ddlutils.Platform |
getPlatform()
|
protected Object |
getPropertyValue(org.apache.commons.beanutils.DynaBean bean,
String propName)
Determines the value of the bean's property that has the given name. |
List |
getRows(String tableName)
|
String |
getSelectQueryForAllString(org.apache.ddlutils.model.Table table)
|
void |
init(Map parameters)
Initializes the datasource and the connection (platform) |
protected org.apache.ddlutils.model.Database |
insertData(org.apache.ddlutils.model.Database model,
String dataXml)
Inserts data into the database. |
protected org.apache.ddlutils.model.Database |
insertData(String dataXml)
Inserts data into the database. |
boolean |
isDatabaseSupported(String driverName,
String jdbcConnectionUrl)
Tries to determine whether a the jdbc driver and connection url re supported. |
private void |
modifyVarBinaryColumn(org.apache.ddlutils.model.Database targetModel,
String tableName,
String columnName)
|
org.apache.ddlutils.model.Database |
readModelFromDatabase(String databaseName)
Reads the database model from a live database. |
void |
startUp()
|
void |
tearDown()
|
protected void |
updateDatabaseSchema(org.apache.ddlutils.model.Database targetModel,
boolean alterDb)
Update a given database schema to match the schema of targetModel If alterDB is true, the routine attempts to modify the existing database shcema while preserving the data (as much as possible). |
void |
writeDatabaseSchematoFile(String fileName)
Parses the database defined in the given XML file and creates a database schema (model) object |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DATASOURCE_DATABASENAME
public static final String DATASOURCE_CLASS
public static final String DATASOURCE_DRIVER
public static final String DATASOURCE_URL
public static final String DATASOURCE_USERNAME
public static final String DATASOURCE_PASSWORD
private static final org.apache.commons.logging.Log log
org.apache.ddlutils.model.JdbcTypeCategoryEnum temEnum
Map parameters
org.apache.ddlutils.PlatformUtils utils
StringWriter writer
private org.apache.ddlutils.Platform platform
private DataSource dataSource
private String _databaseName
private org.apache.ddlutils.model.Database model
private boolean connected
Constructor Detail |
---|
public JetspeedDDLUtil()
Method Detail |
---|
public void startUp()
public void tearDown()
public boolean isDatabaseSupported(String driverName, String jdbcConnectionUrl)
driverName
- The fully qualified name of the JDBC driverjdbcConnectionUrl
- The connection url
public void writeDatabaseSchematoFile(String fileName)
fileName
- protected org.apache.ddlutils.model.Database createDatabaseSchemaFromXML(String fileName)
dbDef
- The database XML definition
protected org.apache.ddlutils.model.Database createDatabaseSchemaFromString(String dbDef)
dbDef
- The database XML definition
protected org.apache.ddlutils.Platform connectToDatabase(DataSource dataSource)
Create a database connection (platform instance) from a data source
dataSource
- protected org.apache.ddlutils.Platform connectToDatabase(String databaseType)
Create a database connection (platform instance) from a (case insensitive) database type (like MySQL)
dataSource
- protected void updateDatabaseSchema(org.apache.ddlutils.model.Database targetModel, boolean alterDb) throws org.apache.jetspeed.serializer.SerializerException
Update a given database schema to match the schema of targetModel If alterDB is true, the routine attempts to modify the existing database shcema while preserving the data (as much as possible). If not, the existing tables are dropped prior to recreate
targetModel
- The new database modelalterDb
- if true, try to use alter database and preserve data
org.apache.jetspeed.serializer.SerializerException
private void modifyVarBinaryColumn(org.apache.ddlutils.model.Database targetModel, String tableName, String columnName)
public void alterDatabase(org.apache.ddlutils.model.Database model) throws org.apache.jetspeed.serializer.SerializerException
model
- The new database model
org.apache.jetspeed.serializer.SerializerException
public void createDatabase(org.apache.ddlutils.model.Database model) throws org.apache.jetspeed.serializer.SerializerException
model
- The new database model
org.apache.jetspeed.serializer.SerializerException
protected org.apache.ddlutils.model.Database insertData(org.apache.ddlutils.model.Database model, String dataXml) throws org.apache.ddlutils.DatabaseOperationException
Inserts data into the database. Data is expected to be in the format
model
- The database modeldataXml
- The data xml
org.apache.ddlutils.DatabaseOperationException
protected void dropDatabaseTables(org.apache.ddlutils.model.Database model) throws org.apache.ddlutils.DatabaseOperationException
model
- The database model
org.apache.ddlutils.DatabaseOperationException
public org.apache.ddlutils.model.Database readModelFromDatabase(String databaseName)
platform
- The physical database connectiondatabaseName
- The name of the resulting database
public void init(Map parameters)
protected org.apache.ddlutils.model.Database getModel()
protected org.apache.ddlutils.model.Database insertData(String dataXml) throws org.apache.ddlutils.DatabaseOperationException
dataXml
- The data xml
org.apache.ddlutils.DatabaseOperationException
protected void dropDatabase() throws org.apache.ddlutils.DatabaseOperationException
org.apache.ddlutils.DatabaseOperationException
protected Object getPropertyValue(org.apache.commons.beanutils.DynaBean bean, String propName)
bean
- The beanpropName
- The name of the property
public DataSource getDataSource()
public org.apache.ddlutils.Platform getPlatform()
public List getRows(String tableName)
public String getSelectQueryForAllString(org.apache.ddlutils.model.Table table)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |