|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.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 | |
---|---|
static java.lang.String |
DATASOURCE_CLASS
|
static java.lang.String |
DATASOURCE_DATABASENAME
|
static java.lang.String |
DATASOURCE_DRIVER
|
static java.lang.String |
DATASOURCE_PASSWORD
|
static java.lang.String |
DATASOURCE_URL
|
static java.lang.String |
DATASOURCE_USERNAME
|
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(javax.sql.DataSource dataSource)
Create a database connection (platform instance) from a data source |
protected org.apache.ddlutils.Platform |
connectToDatabase(java.lang.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(java.lang.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(java.lang.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. |
javax.sql.DataSource |
getDataSource()
|
protected org.apache.ddlutils.model.Database |
getModel()
Returns the database model. |
org.apache.ddlutils.Platform |
getPlatform()
|
protected java.lang.Object |
getPropertyValue(org.apache.commons.beanutils.DynaBean bean,
java.lang.String propName)
Determines the value of the bean's property that has the given name. |
java.util.List |
getRows(java.lang.String tableName)
|
java.lang.String |
getSelectQueryForAllString(org.apache.ddlutils.model.Table table)
|
void |
init(java.util.Map parameters)
Initializes the datasource and the connection (platform) |
protected org.apache.ddlutils.model.Database |
insertData(org.apache.ddlutils.model.Database model,
java.lang.String dataXml)
Inserts data into the database. |
protected org.apache.ddlutils.model.Database |
insertData(java.lang.String dataXml)
Inserts data into the database. |
boolean |
isDatabaseSupported(java.lang.String driverName,
java.lang.String jdbcConnectionUrl)
Tries to determine whether a the jdbc driver and connection url re supported. |
org.apache.ddlutils.model.Database |
readModelFromDatabase(java.lang.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(java.lang.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 java.lang.String DATASOURCE_DATABASENAME
public static final java.lang.String DATASOURCE_CLASS
public static final java.lang.String DATASOURCE_DRIVER
public static final java.lang.String DATASOURCE_URL
public static final java.lang.String DATASOURCE_USERNAME
public static final java.lang.String DATASOURCE_PASSWORD
Constructor Detail |
---|
public JetspeedDDLUtil()
Method Detail |
---|
public void startUp()
public void tearDown()
public boolean isDatabaseSupported(java.lang.String driverName, java.lang.String jdbcConnectionUrl)
driverName
- The fully qualified name of the JDBC driverjdbcConnectionUrl
- The connection url
public void writeDatabaseSchematoFile(java.lang.String fileName)
fileName
- protected org.apache.ddlutils.model.Database createDatabaseSchemaFromXML(java.lang.String fileName)
dbDef
- The database XML definition
protected org.apache.ddlutils.model.Database createDatabaseSchemaFromString(java.lang.String dbDef)
dbDef
- The database XML definition
protected org.apache.ddlutils.Platform connectToDatabase(javax.sql.DataSource dataSource)
Create a database connection (platform instance) from a data source
dataSource
- protected org.apache.ddlutils.Platform connectToDatabase(java.lang.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 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
SerializerException
public void alterDatabase(org.apache.ddlutils.model.Database model) throws SerializerException
model
- The new database model
SerializerException
public void createDatabase(org.apache.ddlutils.model.Database model) throws SerializerException
model
- The new database model
SerializerException
protected org.apache.ddlutils.model.Database insertData(org.apache.ddlutils.model.Database model, java.lang.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(java.lang.String databaseName)
platform
- The physical database connectiondatabaseName
- The name of the resulting database
public void init(java.util.Map parameters)
protected org.apache.ddlutils.model.Database getModel()
protected org.apache.ddlutils.model.Database insertData(java.lang.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 java.lang.Object getPropertyValue(org.apache.commons.beanutils.DynaBean bean, java.lang.String propName)
bean
- The beanpropName
- The name of the property
public javax.sql.DataSource getDataSource()
public org.apache.ddlutils.Platform getPlatform()
public java.util.List getRows(java.lang.String tableName)
public java.lang.String getSelectQueryForAllString(org.apache.ddlutils.model.Table table)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |