edu.isi.pegasus.planner.ranking

## Class GetDAX

- java.lang.Object
- - edu.isi.pegasus.planner.ranking.GetDAX

    public class GetDAX
    extends java.lang.Object

This class is responsible for the fetching the DAX'es on the basis of the request ID's from the Windward Provenance Tracking Catalog. If there are more than one way's to get the DAX's then it should be an interface.

Version:
  $Revision$
Author:
  Karan Vahi

### Field Summary

Fields
`static java.lang.String` `c_prefix` Prefix for the property subset to use with this catalog.
`static java.lang.String` `DB_PREFIX` The DB Driver properties prefix.
`private java.sql.Connection` `mConnection` Maintains the connection to the database over the lifetime of this instance.
`private static java.lang.String[]` `mCStatements` The statement to prepare to slurp attributes.
`private LogManager` `mLogger` The instance to the Logging manager.
`private java.util.Properties` `mProps` The properties passed to the client.
`private java.sql.PreparedStatement[]` `mStatements` Maintains an essential set of prepared statement, ready to use.

### Constructor Summary

Constructors
Constructor and Description
`GetDAX()` The default constructor.

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`void` `close()` Explicitely free resources before the garbage collection hits.
`boolean` `connect(PegasusProperties properties)` A convenience method to connect on the basis of PegasusProperties.
`boolean` `connect(java.util.Properties props)` Establishes a connection to the database from the properties.
`java.util.Collection<java.lang.String>` `get(java.lang.String id, java.lang.String dir)` Given a request ID it fetches the DAX's from the DB and writes out to the directory passed.
`protected java.lang.String` `getJDBCURL(java.lang.String driver, java.util.Properties properties)` Constructs the jdbc url on the basis fo the driver and db properties.
`protected java.sql.PreparedStatement` `getStatement(int i)` Singleton manager for prepared statements.
`boolean` `isClosed()` Predicate to check, if the connection with the catalog's implementation is still active.
`static void` `main(java.lang.String[] args)` For Testing purposes only.
`protected static void` `sanityCheck(java.io.File dir)` Checks the destination location for existence, if it can be created, if it is writable etc.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### c_prefix

    public static final java.lang.String c_prefix

Prefix for the property subset to use with this catalog.

See Also:
  Constant Field Values

#### DB_PREFIX

    public static final java.lang.String DB_PREFIX

The DB Driver properties prefix.

See Also:
  Constant Field Values

#### mCStatements

    private static final java.lang.String[] mCStatements

The statement to prepare to slurp attributes.

#### mConnection

    private java.sql.Connection mConnection

Maintains the connection to the database over the lifetime of this instance.

#### mStatements

    private java.sql.PreparedStatement[] mStatements

Maintains an essential set of prepared statement, ready to use.

#### mProps

    private java.util.Properties mProps

The properties passed to the client.

#### mLogger

    private LogManager mLogger

The instance to the Logging manager.

### Constructor Detail

#### GetDAX

    public GetDAX()

The default constructor.

### Method Detail

#### connect

    public boolean connect(PegasusProperties properties)

A convenience method to connect on the basis of PegasusProperties. Eventually this logic should go in the invoking code or factory.

Parameters:
  `properties` - PegasusProperties
Returns:
  boolean

#### connect

    public boolean connect(java.util.Properties props)

Establishes a connection to the database from the properties. You can specify a `driver` property to contain the class name of the JDBC driver for your database. This property will be removed before attempting to connect. You must speficy a `url` property to describe the connection. It will be removed before attempting to connect.

Parameters:
  `props` - is the property table with sufficient settings to establish a link with the database. The minimum key required key is "url", and possibly "driver". Any other keys depend on the database driver.
Returns:
  true if connected, false if failed to connect.
See Also:
  `DriverManager.getConnection( String, Properties )`

#### getJDBCURL

    protected java.lang.String getJDBCURL(java.lang.String driver,
                                          java.util.Properties properties)

Constructs the jdbc url on the basis fo the driver and db properties.

Parameters:
  `driver` - the driver being used.
  `properties` - the db properites
Returns:
  the jdbc url, else null if unable to construct

#### get

    public java.util.Collection<java.lang.String> get(java.lang.String id,
                                                      java.lang.String dir)

Given a request ID it fetches the DAX's from the DB and writes out to the directory passed.

Parameters:
  `id` - the request id.
  `dir` - the directory where the DAX'es need to be placed.
Returns:
  a Collection of basenames fo the DAX'es placed in the directory.

#### isClosed

    public boolean isClosed()

Predicate to check, if the connection with the catalog's implementation is still active. This helps determining, if it makes sense to call `close()`.

Returns:
  true, if the implementation is disassociated, false otherwise.
See Also:
  `close()`

#### close

    public void close()

Explicitely free resources before the garbage collection hits.

#### getStatement

    protected java.sql.PreparedStatement getStatement(int i)
                                               throws java.sql.SQLException

Singleton manager for prepared statements. This instruction checks that a prepared statement is ready to use, and will create an instance of the prepared statement, if it was unused previously.

Parameters:
  `i` - is the index which prepared statement to check.
Returns:
  a handle to the prepared statement.
Throws:
  `java.sql.SQLException` - in case of unable to delete entry.

#### sanityCheck

    protected static void sanityCheck(java.io.File dir)
                               throws java.io.IOException

Checks the destination location for existence, if it can be created, if it is writable etc.

Parameters:
  `dir` - is the new base directory to optionally create.
Throws:
  `java.io.IOException` - in case of error while writing out files.

#### main

    public static void main(java.lang.String[] args)

For Testing purposes only.

Parameters:
  `args` - the arguments passed.