org.dbmaintain.script
Class ScriptFactory

java.lang.Object
  extended by org.dbmaintain.script.ScriptFactory

public class ScriptFactory
extends Object

Author:
Tim Ducheyne, Filip Neven

Field Summary
protected  ScriptIndexes baseLineRevision
           
 
Constructor Summary
ScriptFactory(String scriptIndexRegexp, String targetDatabaseRegexp, String qualifierRegexp, Set<Qualifier> registeredQualifiers, Set<Qualifier> patchQualifiers, String postProcessingScriptDirName, ScriptIndexes baseLineRevision)
           
 
Method Summary
 Script createScriptWithContent(String fileName, Long fileLastModifiedAt, ScriptContentHandle scriptContentHandle)
           
 Script createScriptWithoutContent(String fileName, Long fileLastModifiedAt, String checkSum)
           
protected  String[] getPathParts(String fileName)
           
protected  Set<Qualifier> getQualifiers(String[] pathParts)
           
protected  ScriptIndexes getScriptIndexes(String[] pathParts)
          Creates a version by extracting the indexes from the the given script file name.
protected  String getTargetDatabaseName(String[] pathParts)
          Resolves the target database name from the given list of tokens

E.g. 01_@databaseA_myscript.sql

If the file name consists out of multiple path-parts, the last found target database is used

E.g. 01_@database1/01_@database2_myscript.sql

will return database2

protected  List<String> getTokens(String[] pathParts, Pattern pattern, boolean addNullIfNoMatch)
           
protected  boolean isIgnored(ScriptIndexes scriptIndexes)
           
 boolean isPatchScript(Set<Qualifier> qualifiers)
           
protected  boolean isPostProcessingScript(String fileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

baseLineRevision

protected ScriptIndexes baseLineRevision
Constructor Detail

ScriptFactory

public ScriptFactory(String scriptIndexRegexp,
                     String targetDatabaseRegexp,
                     String qualifierRegexp,
                     Set<Qualifier> registeredQualifiers,
                     Set<Qualifier> patchQualifiers,
                     String postProcessingScriptDirName,
                     ScriptIndexes baseLineRevision)
Method Detail

createScriptWithContent

public Script createScriptWithContent(String fileName,
                                      Long fileLastModifiedAt,
                                      ScriptContentHandle scriptContentHandle)

createScriptWithoutContent

public Script createScriptWithoutContent(String fileName,
                                         Long fileLastModifiedAt,
                                         String checkSum)

isPostProcessingScript

protected boolean isPostProcessingScript(String fileName)
Parameters:
fileName - The script file name, not null
Returns:
True if the given script name is a post processing script

getTargetDatabaseName

protected String getTargetDatabaseName(String[] pathParts)
Resolves the target database name from the given list of tokens

E.g. 01_@databaseA_myscript.sql

If the file name consists out of multiple path-parts, the last found target database is used

E.g. 01_@database1/01_@database2_myscript.sql

will return database2

Parameters:
pathParts - The file path split up in tokens, not null
Returns:
The target database name, null if none found

getQualifiers

protected Set<Qualifier> getQualifiers(String[] pathParts)

getScriptIndexes

protected ScriptIndexes getScriptIndexes(String[] pathParts)
Creates a version by extracting the indexes from the the given script file name.

Parameters:
pathParts - The file path split up in tokens, not null
Returns:
The version of the script file, not null

getTokens

protected List<String> getTokens(String[] pathParts,
                                 Pattern pattern,
                                 boolean addNullIfNoMatch)

getPathParts

protected String[] getPathParts(String fileName)

isIgnored

protected boolean isIgnored(ScriptIndexes scriptIndexes)
Parameters:
scriptIndexes - The revision of the script, not null
Returns:
True if a baseline revision was set and the revision of the script was below the baseline

isPatchScript

public boolean isPatchScript(Set<Qualifier> qualifiers)
Parameters:
qualifiers - a set of script qualifiers, not null
Returns:
True if there is a patch qualifier


Copyright © 2011. All Rights Reserved.