eu.bootstrep.Utilities
Class DbMethods

java.lang.Object
  extended by eu.bootstrep.Utilities.DbMethods

public class DbMethods
extends java.lang.Object

This Class contains various methods used to access the BioLexicon database.


Field Summary
(package private)  Logger Logger
          An instance of Logger Class
private static java.lang.String MESSTABLE
          Table in database in which messages are recorded
private static java.lang.String mSelect
          Select instruction
private static java.lang.String mWhere
          Where part of selecting messages
 
Constructor Summary
DbMethods()
          Creates a new instance of DbMethods
 
Method Summary
 java.sql.Connection connect2DB(java.lang.String[] dbParam, PropertyBean PB, MainBean MB, MessageBean mesBn)
          This method connects to database.
Input dbParam parameter contains the following information: 0, db -> database name 1, host -> database server ipaddress/hostname 2, port -> database server port, usually 3306 3, user -> database user name 4, password -> database user password 5, driver -> used driver to connect to the database via ODBC 6, odbc -> the odbc name
 java.util.ArrayList execSingleQuery(MainBean MB, java.lang.String doQry, java.lang.Integer numCols)
          This method executes the query in input.
 java.util.ArrayList extractSynonyms(MainBean MB, java.lang.String doQryRel, java.lang.String doQryCls, java.lang.String doQrySyn)
          This method extracts synonyms from the BioLexicon database.
This method uses three different queries: doQryRel creates the identifier of relation: namely:SR_isSynomymOf doQryCls selects distinct cluster identifier from STG_USER_SYNCLUSTER doQrySyn selects synomyms from staging tables: USER_CLS_LM, relation between cluster and lemmas; USER_LE_LM, relation between lexical entries and lemmas; STG_SENSE, senses Query to executed in the following order: doQryCls, to extract clusters doQryRel to create the identifier doQryRel to combune previous results
 void genericQuery(PropertyBean PB, MessageBean mesBn, MainBean MB, java.lang.String doQry)
          This method executes the query in input.
private  java.lang.String getMessageText(PropertyBean PB, MainBean MB, java.lang.Integer messId, java.lang.String LANG)
          This method retrieves text for a given message.
 MessageBean setMessages(PropertyBean PB, MainBean MB, MessageBean mesBn)
          This method retrieves all messages from database and set the MessageBean values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MESSTABLE

private static final java.lang.String MESSTABLE
Table in database in which messages are recorded

See Also:
Constant Field Values

mSelect

private static final java.lang.String mSelect
Select instruction

See Also:
Constant Field Values

mWhere

private static final java.lang.String mWhere
Where part of selecting messages

See Also:
Constant Field Values

Logger

Logger Logger
An instance of Logger Class

Constructor Detail

DbMethods

public DbMethods()
Creates a new instance of DbMethods

Method Detail

connect2DB

public java.sql.Connection connect2DB(java.lang.String[] dbParam,
                                      PropertyBean PB,
                                      MainBean MB,
                                      MessageBean mesBn)
                               throws java.sql.SQLException
This method connects to database.
Input dbParam parameter contains the following information:

Parameters:
dbParam - an array with db Parameters
PB - The PropertyBean
MB - The MainBean
mesBn - The MessageBean
Returns:
True if connection is OK, false otherwise
Throws:
java.sql.SQLException - SQL Exception

setMessages

public MessageBean setMessages(PropertyBean PB,
                               MainBean MB,
                               MessageBean mesBn)
This method retrieves all messages from database and set the MessageBean values.

Parameters:
PB - The PropertyBean
MB - The MainBean
mesBn - MessageBean as default
Returns:
The updated MessageBean

getMessageText

private java.lang.String getMessageText(PropertyBean PB,
                                        MainBean MB,
                                        java.lang.Integer messId,
                                        java.lang.String LANG)
This method retrieves text for a given message. The message is identified bt its identifier.

Parameters:
PB - The propertyBean
MB - The MainBean
messId - The message identifier
LANG - The language. By default EN
Returns:
The message text

genericQuery

public void genericQuery(PropertyBean PB,
                         MessageBean mesBn,
                         MainBean MB,
                         java.lang.String doQry)
This method executes the query in input. It is called by the Process method. Mainly, this method executes LOAD SQL instructions.

Parameters:
PB - The PropertyBean
mesBn - The MessageBean
MB - The MainBean
doQry - The query to be executed

execSingleQuery

public java.util.ArrayList execSingleQuery(MainBean MB,
                                           java.lang.String doQry,
                                           java.lang.Integer numCols)
This method executes the query in input. It is called by the Process method.
This method executes the query and formats the returned resultset accordingly with the number of columns input parameter. The output is formatted in a comma separated value format and added to a List.

Parameters:
MB - The MainBean
doQry - The input query
numCols - The number of columns of the table selected in the doQry
Returns:
A list containing values formatted in comma separated values and " as delimiter

extractSynonyms

public java.util.ArrayList extractSynonyms(MainBean MB,
                                           java.lang.String doQryRel,
                                           java.lang.String doQryCls,
                                           java.lang.String doQrySyn)
This method extracts synonyms from the BioLexicon database.
This method uses three different queries: Query to executed in the following order:
  1. doQryCls, to extract clusters
  2. doQryRel to create the identifier
  3. doQryRel to combune previous results

Parameters:
MB - The MainBean
doQryRel - Query to create the identifier of relation
doQryCls - Query to selects distinct cluster identifier
doQrySyn - Query to selects synomyms from staging tables
Returns:
A list containing values formatted in comma separated values and " as delimiter