de.dfki.mycbr.io
Class DataBaseImporter

java.lang.Object
  extended by de.dfki.mycbr.io.DataBaseImporter

public class DataBaseImporter
extends java.lang.Object

class to import a casebase from a postgres database

Author:
myCBR Team, Pascal Reuss

Nested Class Summary
static class DataBaseImporter.DataBaseImporterError
           
 
Constructor Summary
DataBaseImporter(int id, Project project, Concept concept, java.lang.String dbmapping)
          Constructor for DataBaseImporter
 
Method Summary
 void addMissingValues()
          method to add values from the table to an attributes allowed values Only for used
 void checkData()
          method to check if the read data is valid
 boolean connectToDatabase(int id)
          Establish a connection to a given postgreSQL Database
 void doImport()
          maps the read data to cases
 int getCurrentNumberOfCases()
           
 java.lang.String getSeperatorMultiple()
           
 java.lang.String getTableName()
          Returns the TableName which should be used for import
 int getTotalNumberOfCases()
           
 boolean isImporting()
           
 boolean readData(java.lang.String table, java.lang.String[] filtercolumns, java.lang.String[] filtervalues)
          Reads the Data from the table of a given database
 void readMetaDataFromDatabase(java.lang.String table)
          Method to get the columnNames of the table from which the data is read
 void readMetaDataFromXML()
          Method to get the mapping for columns and attributes from an xml file
 void setSeperatorMultiple(java.lang.String seperator)
           
 void setTableName(java.lang.String tablename)
          Sets the tablename which should be used for import
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataBaseImporter

public DataBaseImporter(int id,
                        Project project,
                        Concept concept,
                        java.lang.String dbmapping)
Constructor for DataBaseImporter

Parameters:
id - of the database to use for the CaseBase
project - used for the CaseBase
concept - used for the CaseBase
Method Detail

connectToDatabase

public boolean connectToDatabase(int id)
Establish a connection to a given postgreSQL Database

Returns:
true if successful, false if connection cannot be established

readData

public boolean readData(java.lang.String table,
                        java.lang.String[] filtercolumns,
                        java.lang.String[] filtervalues)
Reads the Data from the table of a given database

Parameters:
table - the name of the table to read the data from
filtercolumns - an array with the names of the columns for a where clause
filtervalues - an array with the values of the columns for a where clause
Returns:
true if data can be imported, false if not

readMetaDataFromDatabase

public void readMetaDataFromDatabase(java.lang.String table)
Method to get the columnNames of the table from which the data is read


readMetaDataFromXML

public void readMetaDataFromXML()
Method to get the mapping for columns and attributes from an xml file


addMissingValues

public void addMissingValues()
method to add values from the table to an attributes allowed values Only for used


checkData

public void checkData()
method to check if the read data is valid


doImport

public void doImport()
maps the read data to cases


getTableName

public java.lang.String getTableName()
Returns the TableName which should be used for import

Returns:
TableName

setTableName

public void setTableName(java.lang.String tablename)
Sets the tablename which should be used for import

Parameters:
tablename -

getTotalNumberOfCases

public int getTotalNumberOfCases()

getCurrentNumberOfCases

public int getCurrentNumberOfCases()

getSeperatorMultiple

public java.lang.String getSeperatorMultiple()

setSeperatorMultiple

public void setSeperatorMultiple(java.lang.String seperator)

isImporting

public boolean isImporting()
Returns:
true when still importing, false otherwisec