|
||||||||||
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 List<Script> |
allPostProcessingScripts
|
protected List<Script> |
allUpdateScripts
|
static String |
PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME
Property key for the directory in which the code script files are located |
static String |
PROPKEY_SCRIPT_EXTENSIONS
Property key for the extension of the script files |
static String |
PROPKEY_SCRIPT_LOCATIONS
Property key for the directory in which the script files are located |
static String |
PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES
|
Fields inherited from class org.unitils.core.util.BaseConfigurable |
---|
configuration |
Constructor Summary | |
---|---|
DefaultScriptSource()
|
Method Summary | |
---|---|
protected void |
assertNoDuplicateIndexes(List<Script> scripts)
Asserts that, in the given list of database update scripts, there are no two indexed scripts with the same version. |
protected Map<String,Script> |
convertToScriptNameScriptMap(Set<ExecutedScript> executedScripts)
|
protected Script |
createScript(File scriptFile,
String relativePath)
Creates a script object for the given script file |
List<Script> |
getAllUpdateScripts()
Gets a list of all available update scripts. |
protected List<Script> |
getIncrementalScripts()
|
List<Script> |
getNewScripts(Version currentVersion,
Set<ExecutedScript> alreadyExecutedScripts)
Returns a list of scripts with a higher version or whose contents were changed. |
List<Script> |
getPostProcessingScripts()
Gets the configured post-processing script files and verfies that they on the file system. |
protected List<String> |
getScriptExtensions()
Gets the configured extensions for the script files. |
protected void |
getScriptsAt(List<Script> scripts,
String scriptRoot,
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,
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(File file)
Indicates if the given file is a database update script file |
protected 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 String PROPKEY_SCRIPT_LOCATIONS
public static final String PROPKEY_SCRIPT_EXTENSIONS
public static final String PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME
public static final String PROPKEY_USESCRIPTFILELASTMODIFICATIONDATES
protected List<Script> allUpdateScripts
protected List<Script> allPostProcessingScripts
Constructor Detail |
---|
public DefaultScriptSource()
Method Detail |
---|
public List<Script> getAllUpdateScripts()
getAllUpdateScripts
in interface ScriptSource
protected List<Script> getIncrementalScripts()
protected void assertNoDuplicateIndexes(List<Script> scripts)
scripts
- The list of scripts, must be sorted by versionpublic List<Script> getNewScripts(Version currentVersion, Set<ExecutedScript> alreadyExecutedScripts)
getNewScripts
in interface ScriptSource
currentVersion
- The start version, not nullalreadyExecutedScripts
- The scripts which were already executed on the database
public boolean isExistingIndexedScriptModified(Version currentVersion, Set<ExecutedScript> alreadyExecutedScripts)
isExistingIndexedScriptModified
in interface ScriptSource
currentVersion
- The current database version, not null
protected boolean useScriptFileLastModificationDates()
public List<Script> getPostProcessingScripts()
getPostProcessingScripts
in interface ScriptSource
protected void loadAndOrganizeAllScripts()
protected List<Script> loadAllScripts()
protected void getScriptsAt(List<Script> scripts, String scriptRoot, 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(File file)
file
- The file, not null
protected Script createScript(File scriptFile, String relativePath)
scriptFile
- The script file, not null
protected List<String> getScriptExtensions()
protected Map<String,Script> convertToScriptNameScriptMap(Set<ExecutedScript> executedScripts)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |