uk.org.ogsadai.client.databrowser.sql
Class DBJoin

java.lang.Object
  |
  +--uk.org.ogsadai.client.databrowser.sql.DBJoin

public class DBJoin
extends java.lang.Object

Handles a "Join" across databases.

Version:
$Revision: 1.13 $
Author:
Paul J Graham, EPCC

Field Summary
private static java.lang.String COPYRIGHT_NOTICE
          Copyright statement
private static DataTransportMode MODE
          The mode of the data transfer, here we use BLOCK
private static TimeoutProperty TEN_MINUTE_TIMEOUT
          timeout property for a 10 minute timeout
private static int TEN_MINUTES
          timeout of the request
 
Constructor Summary
DBJoin()
           
 
Method Summary
private  void createTable(DataService service, DBUpdate createTable)
           
private  void destroyTable(DataService service, DBUpdate dropTable)
          Destroy a table
private  java.lang.String getTableName(DBUpdate update)
          Gets the intermediate table name (assumes the SQL statement ends with the table name, e.g.
 java.sql.ResultSet join(DBProgressModel pm, DBJoinParameter params)
          Performs a join.
private  DTOutputStream launchOutputActivity(SQLQuery query, WebRowSet webrowset, DataService service, Session session)
          Launches an output activity which sends the results of a query to an output stream for use in another activity.
private  void performBulkLoad(DTOutputStream outputStream, java.lang.String tableNameTo, DataService serviceFrom, DataService serviceTo)
          Delivers data from a source data service resource and bulk loads this data into a table at the sink data service resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT_NOTICE

private static final java.lang.String COPYRIGHT_NOTICE
Copyright statement

See Also:
Constant Field Values

MODE

private static final DataTransportMode MODE
The mode of the data transfer, here we use BLOCK


TEN_MINUTES

private static final int TEN_MINUTES
timeout of the request

See Also:
Constant Field Values

TEN_MINUTE_TIMEOUT

private static final TimeoutProperty TEN_MINUTE_TIMEOUT
timeout property for a 10 minute timeout

Constructor Detail

DBJoin

public DBJoin()
Method Detail

join

public java.sql.ResultSet join(DBProgressModel pm,
                               DBJoinParameter params)
                        throws java.lang.Exception
Performs a join. Runs a join across three databases. First two temporary tables are created in database C. Then databases A and B are queried and the results delivered (via BulkLoad) to the temporary tables. Then the join query is run across the temp tables, the result of this join returned and the temporary tables destroyed. If an error occurs during execution of any of the above steps an attempt will be made to drop the temporary tables.

Parameters:
pm - The progress monitor
params - The join parameters
Returns:
The result of the join
Throws:
java.lang.Exception - if anything goes wrong while executing actions on the services.

getTableName

private java.lang.String getTableName(DBUpdate update)
Gets the intermediate table name (assumes the SQL statement ends with the table name, e.g. 'DROP TABLE tablename')

Parameters:
update - The 'DROP TABLE' SQL
Returns:
The name of the temporary table

destroyTable

private void destroyTable(DataService service,
                          DBUpdate dropTable)
                   throws java.lang.Exception
Destroy a table

Parameters:
service - The service which will run the SQL
dropTable - The SQL to run 'DROP TABLE ...'
Throws:
java.lang.Exception - if anything goes wrong while executing the action on the service.

createTable

private void createTable(DataService service,
                         DBUpdate createTable)
                  throws java.lang.Exception
Parameters:
service - The data service which will run the SQL
createTable - The SQL to run 'CREATE TABLE ...'
Throws:
java.lang.Exception - if anything goes wrong while executing the action on the service.

launchOutputActivity

private DTOutputStream launchOutputActivity(SQLQuery query,
                                            WebRowSet webrowset,
                                            DataService service,
                                            Session session)
                                     throws java.lang.Exception
Launches an output activity which sends the results of a query to an output stream for use in another activity.

Parameters:
query - The SQL query activity
webrowset - The webrowset result convertor activity which contains the output
service - The data service to run the query
Returns:
The name of the output stream (required for input to another activity
Throws:
java.lang.Exception - if anything goes wrong while executing the action on the service.

performBulkLoad

private void performBulkLoad(DTOutputStream outputStream,
                             java.lang.String tableNameTo,
                             DataService serviceFrom,
                             DataService serviceTo)
                      throws java.lang.Exception
Delivers data from a source data service resource and bulk loads this data into a table at the sink data service resource.

Parameters:
outputStream - The name of the output activity
tableNameTo - The name of the table where the results will be loaded
serviceFrom - The source data service providing data via an output stream
serviceTo - The sink data service performing the loading activity
Throws:
java.lang.Exception - if anything goes wrong while executing the action on the service.