net.sourceforge.addam.impexp
Class ImportDataTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.apache.tools.ant.taskdefs.JDBCTask
              extended by net.sourceforge.addam.impexp.ImportDataTask

public class ImportDataTask
extends org.apache.tools.ant.taskdefs.JDBCTask


Field Summary
private  int batchSize
           
private  boolean deleteFirst
           
protected  File dir
           
private  List<Tables> excludes
           
private  List<Tables> includes
           
private  Script post
           
private  Script pre
           
private  boolean truncateFirst
           
 
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
ImportDataTask()
           
 
Method Summary
 void addPost(Script script)
          used for setting a script to execute after importing data
 void addPre(Script script)
          used for setting a script to execute before importing data
private  void emptyTable(String tableName)
           
 void execute()
          Imports all data from the listed files into the named tables.
private  void executeScript(Script script)
           
protected  List<String> getTableNames()
          returns all Tables included by not excluded
 void importTable(String tableName, Connection connection)
          Imports all data from the file into the named table.
 void setBatchSize(int batchSize)
           
 void setDeleteFirst(boolean deleteFirst)
           
 void setDir(File tableDir)
           
 void setExcludeFile(File tableFile)
          this is a shortcut for having a subelement by simply providing a filename as an attribute to this task
 void setExcludes(String names)
           
 void setExcludesPattern(String pattern)
           
 void setIncludeFile(File tableFile)
          this is a shortcut for having an subelement by simply providing a filename as an attribute to this task
 void setIncludes(String names)
           
 void setIncludesPattern(String pattern)
           
 void setTruncateFirst(boolean truncateFirst)
           
 
Methods inherited from class org.apache.tools.ant.taskdefs.JDBCTask
createClasspath, getClasspath, getConnection, getLoader, getLoaderMap, getPassword, getRdbms, getUrl, getUserId, getVersion, isAutocommit, isCaching, isValidRdbms, setAutocommit, setCaching, setClasspath, setClasspathRef, setDriver, setPassword, setRdbms, setUrl, setUserid, setVersion
 
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

deleteFirst

private boolean deleteFirst

truncateFirst

private boolean truncateFirst

pre

private Script pre

post

private Script post

batchSize

private int batchSize

includes

private final List<Tables> includes

excludes

private final List<Tables> excludes

dir

protected File dir
Constructor Detail

ImportDataTask

public ImportDataTask()
Method Detail

setDir

public void setDir(File tableDir)
Parameters:
tableDir - the directory to write the files into

setTruncateFirst

public void setTruncateFirst(boolean truncateFirst)
Parameters:
truncateFirst - if true, 'truncateFirst table ' will be executed before importing new data from a file. the default value is false.

setDeleteFirst

public void setDeleteFirst(boolean deleteFirst)
Parameters:
deleteFirst - if true, 'delete from
' will be executed before importing new data from a file. the default value is false.

addPre

public void addPre(Script script)
used for setting a script to execute before importing data


addPost

public void addPost(Script script)
used for setting a script to execute after importing data


setBatchSize

public void setBatchSize(int batchSize)

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Imports all data from the listed files into the named tables.

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if anything goes wrong

executeScript

private void executeScript(Script script)

emptyTable

private void emptyTable(String tableName)

importTable

public void importTable(String tableName,
                        Connection connection)
                 throws org.apache.tools.ant.BuildException
Imports all data from the file into the named table.

Throws:
org.apache.tools.ant.BuildException - if anything goes wrong

setIncludeFile

public void setIncludeFile(File tableFile)
this is a shortcut for having an subelement by simply providing a filename as an attribute to this task

Parameters:
tableFile - a file containing an ordered list of tables

setExcludeFile

public void setExcludeFile(File tableFile)
this is a shortcut for having a subelement by simply providing a filename as an attribute to this task

Parameters:
tableFile - a file containing an ordered list of tables

setIncludesPattern

public void setIncludesPattern(String pattern)
Parameters:
pattern - a regexp pattern to compare table names to

setExcludesPattern

public void setExcludesPattern(String pattern)
Parameters:
pattern - a regexp pattern to compare table names to

setIncludes

public void setIncludes(String names)
Parameters:
names - a comma separated list of table names

setExcludes

public void setExcludes(String names)
Parameters:
names - a comma separated list of table names

getTableNames

protected List<String> getTableNames()
returns all Tables included by not excluded

Returns:
List of Strings each naming a table


Copyright © 2005-2006 ADDAM Project Team. All Rights Reserved.