|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.dbmaintainer.util.BaseDatabaseAccessor
org.unitils.dbmaintainer.clean.impl.DefaultDBCleaner
public class DefaultDBCleaner
Implementation of DBCleaner. This implementation will delete all data from a database, except for the tables
that are configured as tables to preserve. This includes the tables that are listed in the property
PROPKEY_PRESERVE_TABLES, PROPKEY_PRESERVE_DATA_TABLES. and the table that is configured as
version table using the property PROPKEY_VERSION_TABLE_NAME.
| Field Summary | |
|---|---|
static String |
PROPKEY_PRESERVE_DATA_SCHEMAS
Property key for schemas in which none of the tables should be cleaned |
static String |
PROPKEY_PRESERVE_DATA_TABLES
Property key for the tables that should not be cleaned |
static String |
PROPKEY_PRESERVE_TABLES
Property that specifies which tables should not be dropped (should also not be cleaned) |
static String |
PROPKEY_VERSION_TABLE_NAME
The key of the property that specifies the name of the datase table in which the DB version is stored. |
protected Set<String> |
schemasToPreserve
Names of schemas that should left untouched. |
protected Set<String> |
tablesToPreserve
The tables that should not be cleaned |
| Fields inherited from class org.unitils.dbmaintainer.util.BaseDatabaseAccessor |
|---|
configuration, dbSupports, defaultDbSupport, sqlHandler |
| Constructor Summary | |
|---|---|
DefaultDBCleaner()
|
|
| Method Summary | |
|---|---|
void |
cleanSchemas()
Deletes all data from the database, except for the tables that have been configured as tablesToPreserve , and the table in which the database version is stored |
protected void |
cleanTable(String tableName,
DbSupport dbSupport)
Deletes the data in the table with the given name. |
protected void |
doInit(Properties configuration)
Configures this object. |
protected Set<String> |
getItemsToPreserve(String propertyName,
boolean prefixDefaultSchema)
Gets the list of items to preserve. |
protected boolean |
isItemToPreserve(String item,
Set<String> itemsToPreserve)
Checks whether the given item is one of the items to preserve. |
| Methods inherited from class org.unitils.dbmaintainer.util.BaseDatabaseAccessor |
|---|
getDbSupport, init |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.unitils.dbmaintainer.util.DatabaseAccessing |
|---|
init |
| Field Detail |
|---|
public static final String PROPKEY_PRESERVE_DATA_SCHEMAS
public static final String PROPKEY_PRESERVE_DATA_TABLES
public static final String PROPKEY_PRESERVE_TABLES
public static final String PROPKEY_VERSION_TABLE_NAME
protected Set<String> schemasToPreserve
protected Set<String> tablesToPreserve
| Constructor Detail |
|---|
public DefaultDBCleaner()
| Method Detail |
|---|
protected void doInit(Properties configuration)
doInit in class BaseDatabaseAccessorconfiguration - The configuration, not nullpublic void cleanSchemas()
cleanSchemas in interface DBCleaner
protected void cleanTable(String tableName,
DbSupport dbSupport)
tableName - The name of the table that need to be cleared, not nulldbSupport - The database support, not null
protected boolean isItemToPreserve(String item,
Set<String> itemsToPreserve)
item - The item, not nullitemsToPreserve - The items to preserve, not null
protected Set<String> getItemsToPreserve(String propertyName,
boolean prefixDefaultSchema)
propertyName - The name of the property that defines the items, not nullprefixDefaultSchema - True to prefix item with default schema when needed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||