org.apache.torque.mojo
Class AbstractSQLExecutorMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.apache.torque.mojo.BaseMojo
          extended by org.apache.torque.mojo.AbstractSQLExecutorMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
AbstractDBACommandMojo, ImportMojo

public abstract class AbstractSQLExecutorMojo
extends BaseMojo

Abstract mojo for making use of SQLExecutor


Field Summary
static String DRIVER_INFO_PROPERTIES_PASSWORD
           
static String DRIVER_INFO_PROPERTIES_USER
           
static String FILE_SORTING_ASC
          Call #setOrder(String) with this value to sort in ascendant order the sql files.
static String FILE_SORTING_DSC
          Call #setOrder(String) with this value to sort in descendant order the sql files.
 
Fields inherited from class org.apache.torque.mojo.BaseMojo
FS, SKIP_PACKAGING_TYPE
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractSQLExecutorMojo()
           
 
Method Summary
 void addText(String sql)
          Set an inline SQL command to execute.
protected  void configureTransactions()
           
protected  String convertNullToEmpty(String s)
           
 void executeMojo()
          Validate our configuration and execute SQL as appropriate
 Connection getConn()
           
protected  Connection getConnection()
          Creates a new Connection as using the driver, url, userid and password specified.
protected  Properties getContextProperties()
           
 org.kuali.db.Credentials getCredentials()
           
 String getDelimiter()
           
 String getDelimiterType()
           
protected  String getDisplayPassword(String password)
           
 String getDriver()
           
protected  Properties getDriverProperties()
          parse driverProperties into Properties set
 org.apache.maven.shared.filtering.MavenFileFilter getFileFilter()
           
protected  org.kuali.db.ConnectionHandler getNewConnectionHandler()
           
protected  org.kuali.db.Credentials getNewCredentials()
           
 String getOnError()
           
 String getPassword()
           
protected  org.apache.maven.settings.Server getServerFromSettingsKey()
           
 String getSettingsKey()
           
 String getSqlCommand()
           
protected  org.kuali.db.SQLExecutor getSqlExecutor()
           
 File[] getSrcFiles()
           
 int getSuccessfulStatements()
          Number of SQL statements executed so far that caused errors.
 String getTargetDatabase()
           
 int getTotalStatements()
          Number of SQL statements executed so far, including the ones that caused errors.
 Vector<org.kuali.db.Transaction> getTransactions()
           
protected  String getUpdatedPassword(org.apache.maven.settings.Server server, String password)
           
protected  String getUpdatedUsername(org.apache.maven.settings.Server server, String username)
           
 String getUrl()
           
 String getUsername()
           
 boolean isAppend()
           
 boolean isAutocommit()
           
 boolean isEnableAnonymousPassword()
           
 boolean isEscapeProcessing()
           
 boolean isKeepFormat()
           
protected  boolean isNullOrEmpty(Collection<?> c)
           
 boolean isShowheaders()
           
 boolean isShowPassword()
           
 boolean isSkipOnConnectionError()
           
 void setAppend(boolean append)
          whether output should be appended to or overwrite an existing file.
 void setAutocommit(boolean autocommit)
           
 void setConn(Connection conn)
           
 void setCredentials(org.kuali.db.Credentials credentials)
           
 void setDelimiter(String delimiter)
          Set the delimiter that separates SQL statements.
 void setDelimiterType(String delimiterType)
          Set the delimiter type: "normal" or "row" (default "normal").
 void setDriver(String driver)
           
 void setDriverProperties(String driverProperties)
           
 void setEnableAnonymousPassword(boolean enableAnonymousPassword)
           
 void setEscapeProcessing(boolean enable)
          Set escape processing for statements.
 void setFileFilter(org.apache.maven.shared.filtering.MavenFileFilter filter)
           
 void setKeepFormat(boolean keepformat)
          whether or not format should be preserved.
 void setOnError(String action)
           
 void setPassword(String password)
           
 void setSettingsKey(String key)
           
 void setShowheaders(boolean showheaders)
          Print headers for result sets from the statements; optional, default true.
 void setShowPassword(boolean showPassword)
           
 void setSkipOnConnectionError(boolean skipOnConnectionError)
           
 void setSqlCommand(String sqlCommand)
           
 void setSrcFiles(File[] files)
           
 void setSuccessfulStatements(int successfulStatements)
           
 void setTargetDatabase(String targetDatabase)
           
 void setTotalStatements(int totalStatements)
           
 void setTransactions(Vector<org.kuali.db.Transaction> transactions)
           
 void setUrl(String url)
           
 void setUsername(String username)
           
protected  void updateConfiguration()
          Attempt to automatically detect the correct JDBC driver and database type (oracle, mysql, h2, derby, etc) given a JDBC url
protected  void updateCredentials(org.kuali.db.Credentials credentials)
          Load username/password from settings.xml if user has not set them in JVM properties
protected  void validateConfiguration()
          Validate that some essential configuration items are present
protected  void validateCredentials(org.kuali.db.Credentials credentials)
           
protected  void validateCredentials(org.kuali.db.Credentials credentials, boolean anonymousAccessAllowed, String validationFailureMessage)
           
 
Methods inherited from class org.apache.torque.mojo.BaseMojo
afterExecution, beforeExecution, execute, getEncoding, getMavenSession, getProject, getSettings, isForceMojoExecution, isSkip, isStartMavenLogger, setEncoding, setForceMojoExecution, setMavenSession, setProject, setSettings, setSkip, setStartMavenLogger, skipMojo
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DRIVER_INFO_PROPERTIES_USER

public static final String DRIVER_INFO_PROPERTIES_USER
See Also:
Constant Field Values

DRIVER_INFO_PROPERTIES_PASSWORD

public static final String DRIVER_INFO_PROPERTIES_PASSWORD
See Also:
Constant Field Values

FILE_SORTING_ASC

public static final String FILE_SORTING_ASC
Call #setOrder(String) with this value to sort in ascendant order the sql files.

See Also:
Constant Field Values

FILE_SORTING_DSC

public static final String FILE_SORTING_DSC
Call #setOrder(String) with this value to sort in descendant order the sql files.

See Also:
Constant Field Values
Constructor Detail

AbstractSQLExecutorMojo

public AbstractSQLExecutorMojo()
Method Detail

configureTransactions

protected void configureTransactions()
                              throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

getContextProperties

protected Properties getContextProperties()

getNewCredentials

protected org.kuali.db.Credentials getNewCredentials()

getNewConnectionHandler

protected org.kuali.db.ConnectionHandler getNewConnectionHandler()
                                                          throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

executeMojo

public void executeMojo()
                 throws org.apache.maven.plugin.MojoExecutionException
Validate our configuration and execute SQL as appropriate

Specified by:
executeMojo in class BaseMojo
Throws:
org.apache.maven.plugin.MojoExecutionException

addText

public void addText(String sql)
Set an inline SQL command to execute.

Parameters:
sql - the sql statement to add

setDelimiter

public void setDelimiter(String delimiter)
Set the delimiter that separates SQL statements. Defaults to ";";

Parameters:
delimiter - the new delimiter

setDelimiterType

public void setDelimiterType(String delimiterType)
Set the delimiter type: "normal" or "row" (default "normal").

Parameters:
delimiterType - the new delimiterType

setShowheaders

public void setShowheaders(boolean showheaders)
Print headers for result sets from the statements; optional, default true.

Parameters:
showheaders - true to show the headers, otherwise false

setAppend

public void setAppend(boolean append)
whether output should be appended to or overwrite an existing file. Defaults to false.

Parameters:
append - true to append, otherwise false to overwrite

setKeepFormat

public void setKeepFormat(boolean keepformat)
whether or not format should be preserved. Defaults to false.

Parameters:
keepformat - The keepformat to set

setEscapeProcessing

public void setEscapeProcessing(boolean enable)
Set escape processing for statements.

Parameters:
enable - true to escape, otherwiser false

getSqlExecutor

protected org.kuali.db.SQLExecutor getSqlExecutor()
                                           throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

updateConfiguration

protected void updateConfiguration()
                            throws org.apache.maven.plugin.MojoExecutionException
Attempt to automatically detect the correct JDBC driver and database type (oracle, mysql, h2, derby, etc) given a JDBC url

Throws:
org.apache.maven.plugin.MojoExecutionException

validateConfiguration

protected void validateConfiguration()
                              throws org.apache.maven.plugin.MojoExecutionException
Validate that some essential configuration items are present

Throws:
org.apache.maven.plugin.MojoExecutionException

validateCredentials

protected void validateCredentials(org.kuali.db.Credentials credentials,
                                   boolean anonymousAccessAllowed,
                                   String validationFailureMessage)
                            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

validateCredentials

protected void validateCredentials(org.kuali.db.Credentials credentials)
                            throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException

isNullOrEmpty

protected boolean isNullOrEmpty(Collection<?> c)

convertNullToEmpty

protected String convertNullToEmpty(String s)

updateCredentials

protected void updateCredentials(org.kuali.db.Credentials credentials)
Load username/password from settings.xml if user has not set them in JVM properties

Throws:
org.apache.maven.plugin.MojoExecutionException

getServerFromSettingsKey

protected org.apache.maven.settings.Server getServerFromSettingsKey()

getUpdatedPassword

protected String getUpdatedPassword(org.apache.maven.settings.Server server,
                                    String password)

getDisplayPassword

protected String getDisplayPassword(String password)

getUpdatedUsername

protected String getUpdatedUsername(org.apache.maven.settings.Server server,
                                    String username)

getConnection

protected Connection getConnection()
                            throws org.apache.maven.plugin.MojoExecutionException
Creates a new Connection as using the driver, url, userid and password specified. The calling method is responsible for closing the connection.

Returns:
Connection the newly created connection.
Throws:
org.apache.maven.plugin.MojoExecutionException - if the UserId/Password/Url is not set or there is no suitable driver or the driver fails to load.
SQLException - if there is problem getting connection with valid url

getDriverProperties

protected Properties getDriverProperties()
                                  throws org.apache.maven.plugin.MojoExecutionException
parse driverProperties into Properties set

Returns:
the driver properties
Throws:
org.apache.maven.plugin.MojoExecutionException

getUsername

public String getUsername()

setUsername

public void setUsername(String username)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

getUrl

public String getUrl()

setUrl

public void setUrl(String url)

getDriver

public String getDriver()

setDriver

public void setDriver(String driver)

setAutocommit

public void setAutocommit(boolean autocommit)

getSrcFiles

public File[] getSrcFiles()

setSrcFiles

public void setSrcFiles(File[] files)

getSuccessfulStatements

public int getSuccessfulStatements()
Number of SQL statements executed so far that caused errors.

Returns:
the number

getTotalStatements

public int getTotalStatements()
Number of SQL statements executed so far, including the ones that caused errors.

Returns:
the number

getOnError

public String getOnError()

setOnError

public void setOnError(String action)

setSettingsKey

public void setSettingsKey(String key)

setDriverProperties

public void setDriverProperties(String driverProperties)

getSqlCommand

public String getSqlCommand()

setSqlCommand

public void setSqlCommand(String sqlCommand)

getTransactions

public Vector<org.kuali.db.Transaction> getTransactions()

setTransactions

public void setTransactions(Vector<org.kuali.db.Transaction> transactions)

setFileFilter

public void setFileFilter(org.apache.maven.shared.filtering.MavenFileFilter filter)

getTargetDatabase

public String getTargetDatabase()

setTargetDatabase

public void setTargetDatabase(String targetDatabase)

getConn

public Connection getConn()

setConn

public void setConn(Connection conn)

getDelimiter

public String getDelimiter()

getDelimiterType

public String getDelimiterType()

isKeepFormat

public boolean isKeepFormat()

isShowheaders

public boolean isShowheaders()

isAppend

public boolean isAppend()

isEscapeProcessing

public boolean isEscapeProcessing()

isSkipOnConnectionError

public boolean isSkipOnConnectionError()

setSkipOnConnectionError

public void setSkipOnConnectionError(boolean skipOnConnectionError)

getFileFilter

public org.apache.maven.shared.filtering.MavenFileFilter getFileFilter()

isShowPassword

public boolean isShowPassword()

setShowPassword

public void setShowPassword(boolean showPassword)

isEnableAnonymousPassword

public boolean isEnableAnonymousPassword()

setEnableAnonymousPassword

public void setEnableAnonymousPassword(boolean enableAnonymousPassword)

getSettingsKey

public String getSettingsKey()

isAutocommit

public boolean isAutocommit()

setSuccessfulStatements

public void setSuccessfulStatements(int successfulStatements)

setTotalStatements

public void setTotalStatements(int totalStatements)

setCredentials

public void setCredentials(org.kuali.db.Credentials credentials)

getCredentials

public org.kuali.db.Credentials getCredentials()


Copyright © 2004-2013 The Kuali Foundation. All Rights Reserved.