com.ge.grc.acuity.scriptprocessing
Class RelationalDataSource

java.lang.Object
  extended bycom.ge.grc.acuity.scriptprocessing.DataSource
      extended bycom.ge.grc.acuity.scriptprocessing.RelationalDataSource

public class RelationalDataSource
extends DataSource

Class to obtain data from a relational data source. The constructor establishes the connection to the data source. Methods return data as CachedRowSets from SQL queries or as a List of output parameters from a Stored Procedure call.

Version:
$Revision: 1.7 $ Last modified on $Date: 2007/03/01 21:45:57 $
Author:
crapo

Field Summary
 
Fields inherited from class com.ge.grc.acuity.scriptprocessing.DataSource
ac
 
Constructor Summary
RelationalDataSource(AcuityController _ac)
          Constructor for class.
 
Method Summary
 java.lang.Object executeStoredProcedure(com.hp.hpl.jena.ontology.Individual storedProcedureInstance, java.util.List filters)
          Call this method to execute a relational database stored procedure.
 java.lang.Object executeStoredProcedure(java.lang.String callableStmt, java.util.List filters)
           
 void finalize()
           
 sun.jdbc.rowset.CachedRowSet getCachedRowSet(java.lang.String sqlStmt, int maxRows)
          This method is called to retrieve the results of an SQL query against the identified database.
static java.lang.Object getCachedRowSetColumnValue(sun.jdbc.rowset.CachedRowSet crs, int colIdx, int colType)
          Method to get the value of an index-specified (1-based) field from the current row of a CachedRowSet.
 int[] getCachedRowSetRowsFromFilter(com.hp.hpl.jena.ontology.Individual f)
           
protected  java.lang.String[] getRemoteInstancesQueryInfo(com.hp.hpl.jena.rdf.model.RDFNode dbClassInstDesc)
          Method to return the information associated with a remote relational DB instance (instance of DBInstancesDescriptor).
protected  java.lang.String[] getRemoteStatementsQueryInfo(com.hp.hpl.jena.rdf.model.RDFNode dbStmtDesc)
          Method to return the information associated with a remote relational DB statement (instance of DBStatementsDescriptor).
 java.lang.Object processDBInstanceDescriptor(java.util.ArrayList individuals, com.hp.hpl.jena.ontology.Individual inst, com.hp.hpl.jena.rdf.model.RDFNode dbDesc)
           
 java.lang.Object processDBStatementDescriptor(java.util.ArrayList list, com.hp.hpl.jena.ontology.Individual inst, java.lang.String s, java.lang.String p, com.hp.hpl.jena.rdf.model.RDFNode dbDesc)
           
 java.lang.Object processSQLStatement(com.hp.hpl.jena.ontology.Individual script)
          Call this method to process an Individual of type SQLStatement.
 java.lang.Object processSQLStatement(com.hp.hpl.jena.ontology.Individual script, java.util.List filters)
           
 void releaseConnection()
           
static java.util.List[] resultSetToListArray(java.sql.ResultSet rs)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelationalDataSource

public RelationalDataSource(AcuityController _ac)
                     throws AcuityException,
                            java.sql.SQLException
Constructor for class.

Parameters:
_ac -
Throws:
AcuityException
java.sql.SQLException
Method Detail

finalize

public void finalize()

releaseConnection

public void releaseConnection()

processDBInstanceDescriptor

public java.lang.Object processDBInstanceDescriptor(java.util.ArrayList individuals,
                                                    com.hp.hpl.jena.ontology.Individual inst,
                                                    com.hp.hpl.jena.rdf.model.RDFNode dbDesc)
                                             throws AcuityException
Throws:
AcuityException

processDBStatementDescriptor

public java.lang.Object processDBStatementDescriptor(java.util.ArrayList list,
                                                     com.hp.hpl.jena.ontology.Individual inst,
                                                     java.lang.String s,
                                                     java.lang.String p,
                                                     com.hp.hpl.jena.rdf.model.RDFNode dbDesc)
                                              throws AcuityException
Throws:
AcuityException

processSQLStatement

public java.lang.Object processSQLStatement(com.hp.hpl.jena.ontology.Individual script,
                                            java.util.List filters)
                                     throws java.sql.SQLException,
                                            AcuityException
Throws:
java.sql.SQLException
AcuityException

processSQLStatement

public java.lang.Object processSQLStatement(com.hp.hpl.jena.ontology.Individual script)
                                     throws java.sql.SQLException,
                                            AcuityException
Call this method to process an Individual of type SQLStatement.

Parameters:
script -
Returns:
Throws:
java.sql.SQLException
AcuityException

executeStoredProcedure

public java.lang.Object executeStoredProcedure(com.hp.hpl.jena.ontology.Individual storedProcedureInstance,
                                               java.util.List filters)
                                        throws AcuityException,
                                               java.sql.SQLException
Call this method to execute a relational database stored procedure.

Parameters:
storedProcedureInstance - - the Individual in the model representing the stored procedure
filters - - the filters associated with the stored procedure
Returns:
- a List of the outputs of the stored procedure, filtered if appropriate
Throws:
AcuityException
java.sql.SQLException

executeStoredProcedure

public java.lang.Object executeStoredProcedure(java.lang.String callableStmt,
                                               java.util.List filters)
                                        throws AcuityException,
                                               java.sql.SQLException
Throws:
AcuityException
java.sql.SQLException

resultSetToListArray

public static java.util.List[] resultSetToListArray(java.sql.ResultSet rs)
                                             throws AcuityException
Throws:
AcuityException

getCachedRowSet

public sun.jdbc.rowset.CachedRowSet getCachedRowSet(java.lang.String sqlStmt,
                                                    int maxRows)
                                             throws java.sql.SQLException,
                                                    AcuityException
This method is called to retrieve the results of an SQL query against the identified database.

Parameters:
sqlStmt - - the SQL query string used to extract data from the DB
Returns:
- The set of records matching the SQL query statement returned as a CachedRowSet. Note that the CachedRowSet does not require that the database connection remain open.
Throws:
java.sql.SQLException - -
AcuityException - -

getCachedRowSetRowsFromFilter

public int[] getCachedRowSetRowsFromFilter(com.hp.hpl.jena.ontology.Individual f)
                                    throws AcuityException
Parameters:
f -
Returns:
Throws:
AcuityException

getCachedRowSetColumnValue

public static java.lang.Object getCachedRowSetColumnValue(sun.jdbc.rowset.CachedRowSet crs,
                                                          int colIdx,
                                                          int colType)
                                                   throws java.sql.SQLException,
                                                          AcuityException
Method to get the value of an index-specified (1-based) field from the current row of a CachedRowSet.

Parameters:
crs - - the CachedRowSet with the correct current row
colIdx - - the integer (1-based) column for which the value is desired
colType - - the java.sql.Types integer indicating the data type of the column
Returns:
- the value as an Object, e.g., String, Integer, etc.
Throws:
AcuityException
java.sql.SQLException

getRemoteInstancesQueryInfo

protected java.lang.String[] getRemoteInstancesQueryInfo(com.hp.hpl.jena.rdf.model.RDFNode dbClassInstDesc)
                                                  throws AcuityException
Method to return the information associated with a remote relational DB instance (instance of DBInstancesDescriptor).

Parameters:
dbClassInstDesc - - the RDFNode which is the DBInstancesDescriptor serving as a pseudo-instance for remote DB instances
Returns:
- a String array with 5 elements: 1) the remote DB Table name, 2) the remote DB Column name containing the instances, 3) the [Class] name to be matched (in the Column named in next element) for returned instances (optional), 4) the remote DB Column name containing the Class name of the instance (optional), and 5) the remote DB Column name containing the string to be used as the rdfs:label of the instance (optional).
Throws:
AcuityException - -

getRemoteStatementsQueryInfo

protected java.lang.String[] getRemoteStatementsQueryInfo(com.hp.hpl.jena.rdf.model.RDFNode dbStmtDesc)
                                                   throws AcuityException
Method to return the information associated with a remote relational DB statement (instance of DBStatementsDescriptor).

Parameters:
dbStmtDesc - - the RDFNode which is the DBStatementsDescriptor serving as a pseudo-instance for remote DB Statements
Returns:
- a String array with 4 elements: 1) the remote DB Table name, 2) the remote DB Column name containing the subjects of the statements, 3) the remote DB Column named containing the objects of the statements, and 4) the URI of the Property to serve as predicate of the returned statements
Throws:
AcuityException - -