net.sourceforge.jdbcimporter.ant
Class JDBCImporterTask

java.lang.Object
  extended byorg.apache.tools.ant.ProjectComponent
      extended byorg.apache.tools.ant.Task
          extended bynet.sourceforge.jdbcimporter.ant.JDBCImporterTask

public class JDBCImporterTask
extends org.apache.tools.ant.Task

The JDBCImporterTask class is the Ant task that controls the import of data to the database.

Version:
0.6
Author:
Chris Nagy

Field Summary
protected  ConnectionDefElement connectionElement
          The ConnectionDefElement containing the connection definition.
protected  java.lang.String engineClassname
          The class name of the engine used for the import.
protected  java.util.List entityElements
          The list of ElementDefElement.
protected  boolean failOnError
          Flag indicating that the import should stop on the first error (default is false).
protected  ImportDef importDef
          The import definition.
protected static org.apache.commons.logging.Log LOG
          The log for debug information.
protected  java.util.Map plugins
          The mapping between connection definition/delimiter parser types and implementations.
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
JDBCImporterTask()
          Create a JDBCImporter Ant task.
 
Method Summary
 void addConfiguredProperty(PropertyElement element)
          Adds a property to the plugin properties.
static void applyProperty(java.lang.Object obj, java.lang.String name, java.lang.String value)
          Apply the property to the given object.
 ConnectionDefElement createConnection()
          Creates an empty ConnectionDefElement and returns it.
 ImportEntityDefElement createEntity()
          Creates an empty EntityDefElement and returns it.
 void execute()
          Import data into the database by processing each entity definition via the import engine.
 void setBatchCount(int count)
          Sets the number of rows to import before calling execute batch.
 void setCommitCount(int count)
          Sets the number of rows to import before committing.
 void setEngine(java.lang.String className)
          Sets the class name of the engine used for the import.
 void setFailonerror(boolean flag)
          Sets a flag to indicate that the import should stop after the first error.
 void setPostSQLFile(java.io.File file)
          Sets the file containing the sql statements that will be executed after the import.
 void setPreSQLFile(java.io.File file)
          Sets the file containing the sql statements that will be executed before the import.
 void setTrimValues(boolean flag)
          Sets the flag indicating whether values should be trimmed after reading them from the delimiter parser.
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static org.apache.commons.logging.Log LOG
The log for debug information.


engineClassname

protected java.lang.String engineClassname
The class name of the engine used for the import.


importDef

protected ImportDef importDef
The import definition.


connectionElement

protected ConnectionDefElement connectionElement
The ConnectionDefElement containing the connection definition.


entityElements

protected java.util.List entityElements
The list of ElementDefElement.


plugins

protected java.util.Map plugins
The mapping between connection definition/delimiter parser types and implementations.


failOnError

protected boolean failOnError
Flag indicating that the import should stop on the first error (default is false).

Constructor Detail

JDBCImporterTask

public JDBCImporterTask()
Create a JDBCImporter Ant task.

Method Detail

setEngine

public void setEngine(java.lang.String className)
Sets the class name of the engine used for the import.

Parameters:
className - the class name

setBatchCount

public void setBatchCount(int count)
Sets the number of rows to import before calling execute batch.

Parameters:
count - the number of rows

setCommitCount

public void setCommitCount(int count)
Sets the number of rows to import before committing.

Parameters:
count - the number of rows

setPreSQLFile

public void setPreSQLFile(java.io.File file)
Sets the file containing the sql statements that will be executed before the import. The sql statements inside the file should be separated by the semi-colon character.

Parameters:
file - the file

setPostSQLFile

public void setPostSQLFile(java.io.File file)
Sets the file containing the sql statements that will be executed after the import. The sql statements inside the file should be separated by the semi-colon character.

Parameters:
file - the file

setTrimValues

public void setTrimValues(boolean flag)
Sets the flag indicating whether values should be trimmed after reading them from the delimiter parser.

Parameters:
flag - trim values flag.

setFailonerror

public void setFailonerror(boolean flag)
Sets a flag to indicate that the import should stop after the first error.

Parameters:
flag - flag
Since:
0.69

createConnection

public ConnectionDefElement createConnection()
Creates an empty ConnectionDefElement and returns it.

Returns:
connection definition element

createEntity

public ImportEntityDefElement createEntity()
Creates an empty EntityDefElement and returns it.

Returns:
entity definition element

addConfiguredProperty

public void addConfiguredProperty(PropertyElement element)
Adds a property to the plugin properties.

Parameters:
element - the property element

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Import data into the database by processing each entity definition via the import engine.

Throws:
org.apache.tools.ant.BuildException - if there is no connection definition or entity definitions

applyProperty

public static void applyProperty(java.lang.Object obj,
                                 java.lang.String name,
                                 java.lang.String value)
                          throws org.apache.tools.ant.BuildException
Apply the property to the given object.

Parameters:
obj - the object
name - the name of the property
value - the string value of the property
Throws:
org.apache.tools.ant.BuildException