|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.unitils.core.util.BaseConfigurable
org.unitils.dbmaintainer.script.impl.DefaultScriptSource
public class DefaultScriptSource
Implementation of ScriptSource that reads script files from the filesystem.
PROPKEY_SCRIPT_LOCATIONS.
Valid script files start with a version number followed by an underscore, and end with the
extension configured by PROPKEY_SCRIPT_EXTENSIONS.
| Field Summary | |
|---|---|
protected java.util.List<Script> |
allPostProcessingScripts
|
protected java.util.List<Script> |
allUpdateScripts
|
static java.lang.String |
PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME
Property key for the directory in which the code script files are located |
static java.lang.String |
PROPKEY_SCRIPT_EXTENSIONS
Property key for the extension of the script files |
static java.lang.String |
PROPKEY_SCRIPT_LOCATIONS
Property key for the directory in which the script files are located |
static java.lang.String |
PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES
|
| Fields inherited from class org.unitils.core.util.BaseConfigurable |
|---|
configuration |
| Constructor Summary | |
|---|---|
DefaultScriptSource()
|
|
| Method Summary | |
|---|---|
protected void |
assertNoDuplicateIndexes(java.util.List<Script> scripts)
Asserts that, in the given list of database update scripts, there are no two indexed scripts with the same version. |
protected java.util.Map<java.lang.String,Script> |
convertToScriptNameScriptMap(java.util.Set<ExecutedScript> executedScripts)
|
protected Script |
createScript(java.io.File scriptFile,
java.lang.String relativePath)
Creates a script object for the given script file |
java.util.List<Script> |
getAllUpdateScripts()
Gets a list of all available update scripts. |
protected java.util.List<Script> |
getIncrementalScripts()
|
java.util.List<Script> |
getNewScripts(Version currentVersion,
java.util.Set<ExecutedScript> alreadyExecutedScripts)
Returns a list of scripts with a higher version or whose contents were changed. |
java.util.List<Script> |
getPostProcessingScripts()
Gets the configured post-processing script files and verfies that they on the file system. |
protected java.util.List<java.lang.String> |
getScriptExtensions()
Gets the configured extensions for the script files. |
protected void |
getScriptsAt(java.util.List<Script> scripts,
java.lang.String scriptRoot,
java.lang.String relativeLocation)
Adds all scripts available in the given directory or one of its subdirectories to the given List of files |
boolean |
isExistingIndexedScriptModified(Version currentVersion,
java.util.Set<ExecutedScript> alreadyExecutedScripts)
Returns true if one or more scripts that have a version index equal to or lower than the index specified by the given version object has been modified since the timestamp specfied by the given version. |
protected boolean |
isPostProcessingScript(Script script)
|
protected boolean |
isScriptFile(java.io.File file)
Indicates if the given file is a database update script file |
protected java.util.List<Script> |
loadAllScripts()
|
protected void |
loadAndOrganizeAllScripts()
Loads all scripts and organizes them: Splits them into update and postprocessing scripts, sorts them in their execution order, and makes sure there are no 2 update or postprocessing scripts with the same index. |
protected boolean |
useScriptFileLastModificationDates()
|
| Methods inherited from class org.unitils.core.util.BaseConfigurable |
|---|
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.core.util.Configurable |
|---|
init |
| Field Detail |
|---|
public static final java.lang.String PROPKEY_SCRIPT_LOCATIONS
public static final java.lang.String PROPKEY_SCRIPT_EXTENSIONS
public static final java.lang.String PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME
public static final java.lang.String PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES
protected java.util.List<Script> allUpdateScripts
protected java.util.List<Script> allPostProcessingScripts
| Constructor Detail |
|---|
public DefaultScriptSource()
| Method Detail |
|---|
public java.util.List<Script> getAllUpdateScripts()
getAllUpdateScripts in interface ScriptSourceprotected java.util.List<Script> getIncrementalScripts()
protected void assertNoDuplicateIndexes(java.util.List<Script> scripts)
scripts - The list of scripts, must be sorted by version
public java.util.List<Script> getNewScripts(Version currentVersion,
java.util.Set<ExecutedScript> alreadyExecutedScripts)
getNewScripts in interface ScriptSourcecurrentVersion - The start version, not nullalreadyExecutedScripts - The scripts which were already executed on the database
public boolean isExistingIndexedScriptModified(Version currentVersion,
java.util.Set<ExecutedScript> alreadyExecutedScripts)
isExistingIndexedScriptModified in interface ScriptSourcecurrentVersion - The current database version, not null
protected boolean useScriptFileLastModificationDates()
public java.util.List<Script> getPostProcessingScripts()
getPostProcessingScripts in interface ScriptSourceprotected void loadAndOrganizeAllScripts()
protected java.util.List<Script> loadAllScripts()
protected void getScriptsAt(java.util.List<Script> scripts,
java.lang.String scriptRoot,
java.lang.String relativeLocation)
scriptLocation - The current script location, not nullcurrentParentIndexes - The indexes of the current parent folders, not nullscriptFiles - The list to which the available script have to be addedprotected boolean isPostProcessingScript(Script script)
script - A database script, not null
protected boolean isScriptFile(java.io.File file)
file - The file, not null
protected Script createScript(java.io.File scriptFile,
java.lang.String relativePath)
scriptFile - The script file, not null
protected java.util.List<java.lang.String> getScriptExtensions()
protected java.util.Map<java.lang.String,Script> convertToScriptNameScriptMap(java.util.Set<ExecutedScript> executedScripts)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||