org.opentox.database
Class ModelsTable

java.lang.Object
  extended by org.opentox.database.ModelsTable
All Implemented Interfaces:
IDataBaseAccess, ITable

public class ModelsTable
extends java.lang.Object
implements IDataBaseAccess, ITable

Version:
1.3.3 (Last update: Dec 28, 2009)
Author:
OpenTox - http://www.opentox.org/, Sopasakis Pantelis, Sarimveis Harry

Nested Class Summary
private  class ModelsTable.JteratorImpl
          A private implementation of Jterator.
 
Nested classes/interfaces inherited from interface org.opentox.interfaces.IDataBaseAccess
IDataBaseAccess.CreateTable, IDataBaseAccess.Registration, IDataBaseAccess.Removal
 
Field Summary
static java.lang.String COL_ALGORITHM_ID
           
static java.lang.String COL_MODEL_ID
           
static java.lang.String COL_MODEL_URI
           
static ModelsTable INSTANCE
           
private static ModelsTable instanceOfThis
           
static java.lang.String MODEL_INFO_TABLE
           
 
Fields inherited from interface org.opentox.interfaces.IDataBaseAccess
DATABASENAME, DB_URL, DRIVER
 
Constructor Summary
private ModelsTable()
           
 
Method Summary
 void create()
          Generates the table that contains information about models.
 AlgorithmEnum getAlgorithm(java.lang.String ID)
          Returns an AlgorithmEnum characterization of a given model.
private static ModelsTable getInstance()
           
 int getModelsStack()
          TODO: IMPORTANT!!! Rewrite this method!!! Returns the number of models currently in the database.
 void getRidOf()
          Removes completely the table from the database.
private  boolean isModel(java.lang.String ID, java.lang.String Model)
          Checks if a model was built with a given algorithm.
 Jterator<java.lang.String> iterator(java.lang.String ColumnName)
          Provides an iterator for all elements in a specified column of the database.
static void main(java.lang.String[] args)
           
 int register(java.lang.String AlgID)
          Registers a new trained model in database
 void remove(java.lang.String ID)
          This method is used to delete a model registered in the database.
 Jterator<java.lang.String> search(java.lang.String IterableCoumn, java.lang.String SearchColumn, java.lang.String keyword)
          Performs a search in the table.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COL_MODEL_ID

public static final java.lang.String COL_MODEL_ID
See Also:
Constant Field Values

COL_MODEL_URI

public static final java.lang.String COL_MODEL_URI
See Also:
Constant Field Values

COL_ALGORITHM_ID

public static final java.lang.String COL_ALGORITHM_ID
See Also:
Constant Field Values

MODEL_INFO_TABLE

public static final java.lang.String MODEL_INFO_TABLE
See Also:
Constant Field Values

instanceOfThis

private static ModelsTable instanceOfThis

INSTANCE

public static final ModelsTable INSTANCE
Constructor Detail

ModelsTable

private ModelsTable()
Method Detail

getInstance

private static ModelsTable getInstance()

create

public void create()
Generates the table that contains information about models. The structure of this table is:

 |                     MODEL_INFO                         |
 |========================================================|
 | MODEL_ID (INT) | MODEL_URI (TXT) | ALGORITHM_URI (TXT) |
 |----------------|-----------------|---------------------|
 |        *       |        *        |          *          |
 |        *       |        *        |          *          |

 

Specified by:
create in interface ITable
See Also:
create(), isModel(java.lang.String, java.lang.String), register(java.lang.String), remove(java.lang.String)

getModelsStack

public int getModelsStack()
TODO: IMPORTANT!!! Rewrite this method!!! Returns the number of models currently in the database.

Returns:
the first available model id.

register

public int register(java.lang.String AlgID)
Registers a new trained model in database

Parameters:
AlgID - URI of the algorithm used to train the model
Returns:
New model's ID
See Also:
remove(java.lang.String)

remove

public void remove(java.lang.String ID)
This method is used to delete a model registered in the database.

Parameters:
ID - The ID of the model to be deleted
See Also:
register(java.lang.String)

iterator

public Jterator<java.lang.String> iterator(java.lang.String ColumnName)
Description copied from interface: ITable
Provides an iterator for all elements in a specified column of the database.

Specified by:
iterator in interface ITable
Parameters:
ColumnName - The name of the column.
Returns:
An instance of Jterator<String>

search

public Jterator<java.lang.String> search(java.lang.String IterableCoumn,
                                         java.lang.String SearchColumn,
                                         java.lang.String keyword)
Description copied from interface: ITable
Performs a search in the table. Searches the entries of the column defined by SearchColumn to check if its entries resemble a given keyword and returns an iterator over the corresponding entries of the column specified by the argument IterableColumn. The search is performed by a database SQL-type query containing 'LIKE %...%'.

Specified by:
search in interface ITable
Parameters:
IterableCoumn - The column of the table on whose entries the iterator takes values.
SearchColumn - The column of the table which should be searched.
keyword - A keyword
Returns:
An instance of a Jterator (in fact this is an Iterator) which can be used to iterate over the search results.

getRidOf

public void getRidOf()
Description copied from interface: ITable
Removes completely the table from the database. After this operation all data stored in the table will get lost, so make sure that you either really don't need these data or that you have kept backup of your database which is in general highly recommended.

Specified by:
getRidOf in interface ITable

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isModel

private boolean isModel(java.lang.String ID,
                        java.lang.String Model)
Checks if a model was built with a given algorithm. e.g. isModel(10,"svm") returns true if the model with ID = 10 is an SVM model.

Parameters:
ID - the id of the model.
Model -
Returns:
The logical value of the answer to the submitted query.
See Also:
register(java.lang.String), remove(java.lang.String), getAlgorithm(java.lang.String)

getAlgorithm

public AlgorithmEnum getAlgorithm(java.lang.String ID)
Returns an AlgorithmEnum characterization of a given model.

Parameters:
ID - identity number of a model (as a String).
Returns:
Algorithm Enumeration instance for the given ID.
See Also:
isModel(java.lang.String, java.lang.String)

main

public static void main(java.lang.String[] args)
                 throws java.sql.SQLException
Throws:
java.sql.SQLException