org.melati.poem.csv
Class CSVFilesProcessor

Package class diagram package CSVFilesProcessor
java.lang.Object
  extended by org.melati.poem.csv.CSVFilesProcessor

public class CSVFilesProcessor
extends Object

A class to define a sequence of CSVTables and process them by parsing the files and writing the data to the database.

Author:
MylesC@paneris.org

Field Summary
protected  Vector tables
           
 
Constructor Summary
CSVFilesProcessor(Database db)
          Constructor.
 
Method Summary
 CSVTable addTable(String tablename, File file)
          Convenience method.
 CSVTable addTable(Table tab, File file)
          Add a table to this processor.
 void process(boolean writeOnFly, boolean emptyTables, boolean recordDetails, boolean fieldDetails, Writer output)
          Load all the data from the files, empty the tables if necessary and then write the new data into the tables.
 void process(boolean emptyTables, boolean recordDetails, boolean fieldDetails, Writer output)
          With write on the fly false.
protected  void writeData(Writer o)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tables

protected Vector tables
Constructor Detail

CSVFilesProcessor

public CSVFilesProcessor(Database db)
Constructor.

Parameters:
db - the target database
Method Detail

addTable

public CSVTable addTable(String tablename,
                         File file)
Convenience method.

Parameters:
tablename - the name of a POEM table
file - a CSV file, with first line containing field names
Returns:
a new CSVTable

addTable

public CSVTable addTable(Table tab,
                         File file)
Add a table to this processor.

Parameters:
tab - a POEM table
file - a CSV file, with first line containing field names
Returns:
a new CSVTable

process

public void process(boolean writeOnFly,
                    boolean emptyTables,
                    boolean recordDetails,
                    boolean fieldDetails,
                    Writer output)
             throws IOException,
                    CSVParseException,
                    NoPrimaryKeyInCSVTableException,
                    CSVWriteDownException
Load all the data from the files, empty the tables if necessary and then write the new data into the tables.

Write a report of the progress to the Writer.

Parameters:
writeOnFly - flag whether to write down to db when all files read in if set then it is the programmers responsibility to ensure that there are no references to yet to be created fields
emptyTables - flag whether to remove remains from last run
recordDetails - flag passed in to table.report
fieldDetails - flag passed in to table.report
output - to write report to
Throws:
IOException - if file stuff goes wrong
CSVParseException - if csv file has an error
NoPrimaryKeyInCSVTableException - not thrown
CSVWriteDownException - thrown when a persistent cannot be created

process

public void process(boolean emptyTables,
                    boolean recordDetails,
                    boolean fieldDetails,
                    Writer output)
             throws IOException,
                    CSVParseException,
                    NoPrimaryKeyInCSVTableException,
                    CSVWriteDownException
With write on the fly false.

Load all the data from the files, empty the tables if necessary and then write the new data into the tables.

Write a report of the progress to the Writer.

Parameters:
emptyTables - flag whether to remove remains from last run
recordDetails - flag passed in to table.report
fieldDetails - flag passed in to table.report
output - to write report to
Throws:
IOException - if file stuff goes wrong
CSVParseException - if csv file has an error
NoPrimaryKeyInCSVTableException - not thrown
CSVWriteDownException - thrown when a persistent cannot be created

writeData

protected void writeData(Writer o)
                  throws NoPrimaryKeyInCSVTableException,
                         CSVWriteDownException
Parameters:
o - output log to write to
Throws:
NoPrimaryKeyInCSVTableException
CSVWriteDownException


Copyright © 2000-2010 PanEris. All Rights Reserved.