|
||||||||||
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.version.impl.DefaultExecutedScriptInfoSource
public class DefaultExecutedScriptInfoSource
Implementation of VersionSource
that stores the version in the database. The version is stored in the
table whose name is defined by the property PROPERTY_EXECUTED_SCRIPTS_TABLE_NAME
. The version index column name is
defined by PROPERTY_FILE_NAME_COLUMN_NAME
, the version timestamp colmumn name is defined by
PROPERTY_SCRIPT_VERSION_COLUMN_NAME
. The last updated succeeded column name is defined by
PROPERTY_EXECUTED_AT_COLUMN_NAME
.
Field Summary | |
---|---|
protected boolean |
autoCreateExecutedScriptsTable
True if the scripts table should be created automatically if it does not exist yet |
protected String |
checksumColumnName
The name of the database column in which the checksum calculated on the script content is stored |
protected int |
checksumColumnSize
|
protected String |
executedAtColumnName
The name of the database column in which the script execution timestamp is stored |
protected int |
executedAtColumnSize
|
protected Set<ExecutedScript> |
executedScripts
|
protected String |
executedScriptsTableName
The name of the database table in which the executed script info is stored |
protected String |
fileLastModifiedAtColumnName
The name of the database column in which the file last modification timestamp is stored |
protected String |
fileNameColumnName
The name of the database column in which the script name is stored |
protected int |
fileNameColumnSize
|
static String |
PROPERTY_AUTO_CREATE_EXECUTED_SCRIPTS_TABLE
|
static String |
PROPERTY_CHECKSUM_COLUMN_NAME
|
static String |
PROPERTY_CHECKSUM_COLUMN_SIZE
|
static String |
PROPERTY_EXECUTED_AT_COLUMN_NAME
|
static String |
PROPERTY_EXECUTED_AT_COLUMN_SIZE
|
static String |
PROPERTY_EXECUTED_SCRIPTS_TABLE_NAME
|
static String |
PROPERTY_FILE_LAST_MODIFIED_AT_COLUMN_NAME
|
static String |
PROPERTY_FILE_NAME_COLUMN_NAME
|
static String |
PROPERTY_FILE_NAME_COLUMN_SIZE
|
static String |
PROPERTY_SCRIPT_VERSION_COLUMN_NAME
|
static String |
PROPERTY_SCRIPT_VERSION_COLUMN_SIZE
|
static String |
PROPERTY_SUCCEEDED_COLUMN_NAME
|
static String |
PROPERTY_TIMESTAMP_FORMAT
|
protected String |
succeededColumnName
The name of the database column in which the script name is stored |
protected DateFormat |
timestampFormat
Format of the contents of the executed_at column |
protected String |
versionColumnName
The name of the database column in which the script version is stored |
protected int |
versionColumnSize
|
Fields inherited from class org.unitils.dbmaintainer.util.BaseDatabaseAccessor |
---|
configuration, dbSupports, defaultDbSupport, sqlHandler |
Constructor Summary | |
---|---|
DefaultExecutedScriptInfoSource()
|
Method Summary | |
---|---|
protected boolean |
checkExecutedScriptsTable()
Checks if the version table and columns are available and if a record exists in which the version info is stored. |
void |
clearAllExecutedScripts()
Clears all script executions that have been registered. |
protected void |
createExecutedScriptsTable()
Creates the version table and inserts a version record. |
protected void |
doClearAllExecutedScripts()
|
protected Set<ExecutedScript> |
doGetExecutedScripts()
Precondition: The table dbmaintain_scripts must exist |
protected void |
doInit(Properties configuration)
Initializes the name of the version table and its columns using the given configuration. |
protected void |
doRegisterExecutedScript(ExecutedScript executedScript)
Registers the fact that the given script has been executed on the database Precondition: The table dbmaintain_scripts must exist |
protected void |
doSaveExecutedScript(ExecutedScript executedScript)
Saves the given registered script Precondition: The table dbmaintain_scripts must exist |
protected void |
doUpdateExecutedScript(ExecutedScript executedScript)
Updates the given registered script Precondition: The table dbmaintain_scripts must exist |
protected String |
getCreateExecutedScriptsTableStatement()
|
Set<ExecutedScript> |
getExecutedScripts()
|
protected boolean |
isExecutedScriptsTableValid()
Checks if the version table and columns are available and if a record exists in which the version info is stored. |
boolean |
isFromScratchUpdateRecommended()
This method returns whether a from scratch update is recommended: It will return true if the database is in it's initial state (i.e. the dbmaintain_scripts table doesn't exist yet or is invalid) and the autoCreateExecutedScriptsTable property is set to true. |
void |
registerExecutedScript(ExecutedScript executedScript)
Registers the fact that the given script has been executed on the database |
void |
updateExecutedScript(ExecutedScript executedScript)
Updates the given registered script |
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 PROPERTY_EXECUTED_SCRIPTS_TABLE_NAME
public static final String PROPERTY_FILE_NAME_COLUMN_NAME
public static final String PROPERTY_FILE_NAME_COLUMN_SIZE
public static final String PROPERTY_SCRIPT_VERSION_COLUMN_NAME
public static final String PROPERTY_SCRIPT_VERSION_COLUMN_SIZE
public static final String PROPERTY_FILE_LAST_MODIFIED_AT_COLUMN_NAME
public static final String PROPERTY_CHECKSUM_COLUMN_NAME
public static final String PROPERTY_CHECKSUM_COLUMN_SIZE
public static final String PROPERTY_EXECUTED_AT_COLUMN_NAME
public static final String PROPERTY_EXECUTED_AT_COLUMN_SIZE
public static final String PROPERTY_SUCCEEDED_COLUMN_NAME
public static final String PROPERTY_AUTO_CREATE_EXECUTED_SCRIPTS_TABLE
public static final String PROPERTY_TIMESTAMP_FORMAT
protected Set<ExecutedScript> executedScripts
protected String executedScriptsTableName
protected String fileNameColumnName
protected int fileNameColumnSize
protected String versionColumnName
protected int versionColumnSize
protected String fileLastModifiedAtColumnName
protected String checksumColumnName
protected int checksumColumnSize
protected String executedAtColumnName
protected int executedAtColumnSize
protected String succeededColumnName
protected boolean autoCreateExecutedScriptsTable
protected DateFormat timestampFormat
Constructor Detail |
---|
public DefaultExecutedScriptInfoSource()
Method Detail |
---|
protected void doInit(Properties configuration)
doInit
in class BaseDatabaseAccessor
configuration
- the configuration, not nullpublic boolean isFromScratchUpdateRecommended()
isFromScratchUpdateRecommended
in interface ExecutedScriptInfoSource
public Set<ExecutedScript> getExecutedScripts()
getExecutedScripts
in interface ExecutedScriptInfoSource
protected Set<ExecutedScript> doGetExecutedScripts()
public void registerExecutedScript(ExecutedScript executedScript)
registerExecutedScript
in interface ExecutedScriptInfoSource
executedScript
- The script that was executed on the databaseprotected void doRegisterExecutedScript(ExecutedScript executedScript)
executedScript
- The script that was executed on the databasepublic void updateExecutedScript(ExecutedScript executedScript)
updateExecutedScript
in interface ExecutedScriptInfoSource
executedScript
- The script, not nullprotected void doSaveExecutedScript(ExecutedScript executedScript)
executedScript
- The script, not nullprotected void doUpdateExecutedScript(ExecutedScript executedScript)
executedScript
- The script, not nullpublic void clearAllExecutedScripts()
getExecutedScripts()
will return an empty set.
clearAllExecutedScripts
in interface ExecutedScriptInfoSource
protected void doClearAllExecutedScripts()
protected boolean checkExecutedScriptsTable()
protected boolean isExecutedScriptsTableValid()
protected void createExecutedScriptsTable()
protected String getCreateExecutedScriptsTableStatement()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |