public class DefaultScriptSource extends BaseConfigurable implements ScriptSource
ScriptSource that reads script files from the filesystem. Script
files should be located in the directory configured by 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.| Modifier and Type | Field and Description |
|---|---|
protected List<Script> |
allPostProcessingScripts |
protected List<Script> |
allUpdateScripts |
static String |
PROPKEY_EXCLUDE_QUALIFIERS |
static String |
PROPKEY_INCLUDE_QUALIFIERS |
static String |
PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME
Property key for the directory in which the code script files are located
|
static String |
PROPKEY_QUALIFIERS |
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 |
configuration| Constructor and Description |
|---|
DefaultScriptSource() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
boolean |
checkIfScriptContainsCorrectDatabaseName(String nameFile,
String databaseName,
boolean defaultDatabase)
This method checks if a scriptfile is a file that should be used by every schema or if the scriptfile is a file for a specific schema.
|
protected boolean |
checkIfThereAreNoQualifiers(String fileName) |
boolean |
containsOneOfQualifiers(String fileName)
Checks if the name of the script contains one of the qualifiers.
|
protected boolean |
containsQualifier(String fileName,
List<String> qualifiers) |
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(String dialect,
String databaseName,
boolean defaultDatabase)
Gets a list of all available update scripts.
|
protected List<Script> |
getIncrementalScripts(String dialect,
String databaseName,
boolean defaultDatabase) |
List<Script> |
getNewScripts(Version currentVersion,
Set<ExecutedScript> alreadyExecutedScripts,
String dialect,
String databaseName,
boolean defaultDatabase)
Returns a list of scripts with a higher version or whose contents were changed.
|
List<Script> |
getPostProcessingScripts(String dialect,
String databaseName,
boolean defaultDatabase)
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,
String databaseName,
boolean defaultDatabase)
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,
String dialect,
String databaseName,
boolean defaultDatabase)
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(String dialect,
String databaseName,
boolean defaultDatabase) |
protected void |
loadAndOrganizeAllScripts(String dialect,
String databaseName,
boolean defaultDatabase)
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() |
initclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitinitpublic 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
public static final String PROPKEY_EXCLUDE_QUALIFIERS
public static final String PROPKEY_INCLUDE_QUALIFIERS
public static final String PROPKEY_QUALIFIERS
public List<Script> getAllUpdateScripts(String dialect, String databaseName, boolean defaultDatabase)
getAllUpdateScripts in interface ScriptSourceprotected List<Script> getIncrementalScripts(String dialect, String databaseName, boolean defaultDatabase)
protected void assertNoDuplicateIndexes(List<Script> scripts)
scripts - The list of scripts, must be sorted by versionpublic List<Script> getNewScripts(Version currentVersion, Set<ExecutedScript> alreadyExecutedScripts, String dialect, String databaseName, boolean defaultDatabase)
getNewScripts in interface ScriptSourcecurrentVersion - The start version, not nullalreadyExecutedScripts - The scripts which were already executed on the databasepublic boolean isExistingIndexedScriptModified(Version currentVersion, Set<ExecutedScript> alreadyExecutedScripts, String dialect, String databaseName, boolean defaultDatabase)
isExistingIndexedScriptModified in interface ScriptSourcecurrentVersion - The current database version, not nullprotected boolean useScriptFileLastModificationDates()
public List<Script> getPostProcessingScripts(String dialect, String databaseName, boolean defaultDatabase)
getPostProcessingScripts in interface ScriptSourceprotected void loadAndOrganizeAllScripts(String dialect, String databaseName, boolean defaultDatabase)
protected List<Script> loadAllScripts(String dialect, String databaseName, boolean defaultDatabase)
protected void getScriptsAt(List<Script> scripts, String scriptRoot, String relativeLocation, String databaseName, boolean defaultDatabase)
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 addedpublic boolean checkIfScriptContainsCorrectDatabaseName(String nameFile, String databaseName, boolean defaultDatabase)
public boolean containsOneOfQualifiers(String fileName)
fileName - Booleanprotected boolean checkIfThereAreNoQualifiers(String fileName)
protected boolean isPostProcessingScript(Script script)
script - A database script, not nullprotected boolean isScriptFile(File file)
file - The file, not nullprotected Script createScript(File scriptFile, String relativePath)
scriptFile - The script file, not nullprotected List<String> getScriptExtensions()
protected Map<String,Script> convertToScriptNameScriptMap(Set<ExecutedScript> executedScripts)
Copyright © 2017. All rights reserved.