org.enableit.db.darrt
Class DataHandler

java.lang.Object
  |
  +--org.enableit.db.darrt.AbstractFileHandler
        |
        +--org.enableit.db.darrt.AbstractSchemaHandler
              |
              +--org.enableit.db.darrt.DataHandler
All Implemented Interfaces:
FileProcessor

public class DataHandler
extends AbstractSchemaHandler
implements FileProcessor

Data manipulation routines required by Darrt library.

Provides the mechanism for importing and exporting data in several formats.

Author:
Tim Stephenson

Field Summary
static java.lang.String ABOUT
          CVS info ABOUT this class and its current version
static java.lang.String AT_TABLE
          Attribute name holding table name.
 
Constructor Summary
DataHandler()
          Default Constructor.
 
Method Summary
 java.util.Map export()
          Export data from the data source and table patterns configured.
 org.enableit.db.beans.RowSet getRowSetFromCSV(java.io.InputStream is, org.enableit.db.beans.Table table)
          Deprecated. The introduction of the DataParserFactory makes this obsolete.
 org.enableit.db.beans.RowSet getRowSetFromXML(java.io.InputStream is, org.enableit.db.beans.Table table)
          Deprecated. The introduction of the DataParserFactory makes this obsolete.
 org.enableit.db.beans.RowSet importData(org.enableit.db.beans.Provider target, org.enableit.db.beans.RowSet rows)
          Import the data in the row set into the specified database.
 void process(java.io.File file, java.lang.String fileType)
          Process the specified file by importing its data into the database specified by the Provider property.
 void setProvider(org.enableit.db.beans.Provider provider)
          Specify database connection details.
 
Methods inherited from class org.enableit.db.darrt.AbstractSchemaHandler
addListener, addListeners, diffSchemas, getDatabase, getDebug, getListeners, getOnlineRefSchema, getOnlineTargetSchema, getRefDatabase, getRefSchemaName, getRefSchemaUrl, getTablePattern, getTargetDatabase, getTargetSchemaUrl, setDebug, setOnlineRefSchema, setOnlineTargetSchema, setRefDatabase, setRefSchemaName, setRefSchemaUrl, setTablePattern, setTargetDatabase, setTargetSchemaUrl
 
Methods inherited from class org.enableit.db.darrt.AbstractFileHandler
getOperDir, setOperDir
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AT_TABLE

public static final java.lang.String AT_TABLE
Attribute name holding table name.

See Also:
Constant Field Values

ABOUT

public static final java.lang.String ABOUT
CVS info ABOUT this class and its current version

See Also:
Constant Field Values
Constructor Detail

DataHandler

public DataHandler()
Default Constructor.

Method Detail

export

public java.util.Map export()
                     throws SchemaHandlingException
Export data from the data source and table patterns configured.

Returns:
java.util.Map of org.w3c.dom.Documents, each holding data of one table.
Throws:
SchemaHandlingException - If unable to export data for any reason.

importData

public org.enableit.db.beans.RowSet importData(org.enableit.db.beans.Provider target,
                                               org.enableit.db.beans.RowSet rows)
                                        throws DBException
Import the data in the row set into the specified database.

Parameters:
target - Database to install data in.
rows - Data to insert.
Returns:
RowSet containing rows that could not be imported.
Throws:
DBException - If there is a problem importing the data.

process

public void process(java.io.File file,
                    java.lang.String fileType)
             throws ConfigurationException,
                    DBException
Process the specified file by importing its data into the database specified by the Provider property.

Specified by:
process in interface FileProcessor
Parameters:
file - The file to upload. File may be in CSV, Excel or XML format, see class description for details. Other formats can be supported by subclassing this data handler and providing a method with the signature:
getRowSetFrom<file extension in upper case>( :java.io.InputStream, :org.enableit.db.beans.Table) : org.enableit.db.beans.RowSet
fileType - The name of the table to insert into.
Throws:
ConfigurationException - If the fileType specifies an unknown table or the file does not have a supported extension (e.g. .csv or .xml).
DBException - If the handling of the file goes wrong in some recoverable way.

setProvider

public void setProvider(org.enableit.db.beans.Provider provider)
                 throws DBException
Specify database connection details.

Specified by:
setProvider in interface FileProcessor
Parameters:
provider - Provider to be used by the FileProcessor.
Throws:
DBException - If the handling of the file goes wrong in some recoverable way.

getRowSetFromXML

public org.enableit.db.beans.RowSet getRowSetFromXML(java.io.InputStream is,
                                                     org.enableit.db.beans.Table table)
                                              throws java.io.IOException,
                                                     DBException
Deprecated. The introduction of the DataParserFactory makes this obsolete.

Convert an input stream of XML data for the specified table into a structured format of a RowSet.

Parameters:
is - Any Reader wrapper to input stream.
table - The name of the target Table for the RowSet.
Returns:
A RowSet instance holding the data from the InputStream.
Throws:
java.io.IOException
DBException

getRowSetFromCSV

public org.enableit.db.beans.RowSet getRowSetFromCSV(java.io.InputStream is,
                                                     org.enableit.db.beans.Table table)
                                              throws java.io.IOException,
                                                     DBException
Deprecated. The introduction of the DataParserFactory makes this obsolete.

Convert an input stream of CSV data for the specified table into a structured format of a RowSet.

Parameters:
is - Any Reader wrapper to input stream.
table - The name of the target Table for the RowSet.
Returns:
A RowSet instance holding the data from the InputStream.
Throws:
java.io.IOException
DBException


Copyright © 1999-2004 enableIT.org. All Rights Reserved.