org.n52.wps.server.database
Class AbstractDatabase

java.lang.Object
  extended by org.n52.wps.server.database.AbstractDatabase
All Implemented Interfaces:
IDatabase
Direct Known Subclasses:
DerbyDatabase, HSQLDatabase

public abstract class AbstractDatabase
extends java.lang.Object
implements IDatabase

An anstract-layer to the databases.

Author:
Janne Kovanen

Field Summary
static java.lang.String creationString
          SQL to create a response in the DB
protected static int INSERT_COLUMN_MIME_TYPE
           
protected static int INSERT_COLUMN_REQUEST_DATE
          The column of "request_data" in the insert statement.
protected static int INSERT_COLUMN_REQUEST_ID
          The column of "request_id" in the insert statement.
protected static int INSERT_COLUMN_RESPONSE
          The column of "response" in the insert statement.
protected static int INSERT_COLUMN_RESPONSE_TYPE
          The column of "response_type" in the insert statement.
static java.lang.String insertionString
          SQL to insert a response into the database
protected static java.sql.PreparedStatement insertSQL
           
static java.lang.String PROPERTY_NAME_DATABASE
          Property of the path to the location of the database - name of database type: DERBY, HSQL, ...
static java.lang.String PROPERTY_NAME_DATABASE_NAME
          Property of the path to the location of the database - Actual name of the database.
static java.lang.String PROPERTY_NAME_DATABASE_PATH
          Property of the path to the location of the database
protected static int SELECT_COLUMN_RESPONSE
          The column of "response" in the select statement.
static java.lang.String selectionString
          SQL to retrieve a response from the database
protected static java.sql.PreparedStatement selectSQL
           
protected static int UPDATE_COLUMN_REQUEST_ID
          The column of "request_id" in the update statement.
protected static int UPDATE_COLUMN_RESPONSE
          The column of "response" in the update statement.
protected static java.sql.PreparedStatement updateSQL
           
static java.lang.String updateString
          SQL to update a response, that was already stored in the database
 
Constructor Summary
AbstractDatabase()
           
 
Method Summary
 boolean deleteStoredResponse(java.lang.String id)
           
 java.lang.String generateRetrieveResultURL(java.lang.String id)
          The URL referencing the location from which the ExecuteResponse can be retrieved.
abstract  java.sql.Connection getConnection()
           
abstract  java.lang.String getConnectionURL()
           
 java.lang.String getDatabaseName()
          Returns the name of the database.
protected static java.lang.String getDatabasePath()
          Returns the path to the database.
static IDatabase getInstance()
          Get an instance of the Database object.
 java.lang.String getMimeTypeForStoreResponse(java.lang.String id)
           
 java.lang.String insertResponse(Response response)
          Insert a new Response into the Database.
protected  java.lang.String insertResultEntity(LargeBufferStream baos, java.lang.String id, java.lang.String type, java.lang.String mimeType)
          Inserts any result, which has to be stored in the DB.
 java.io.InputStream lookupResponse(java.lang.String request_id)
          Retrieve the Response on a previous Request, based on an unique identifier, which was already given to the client for reference.
 java.io.File lookupResponseAsFile(java.lang.String id)
           
 void shutdown()
           
 java.lang.String storeComplexValue(java.lang.String id, LargeBufferStream stream, java.lang.String type, java.lang.String mimeType)
           
 java.lang.String storeResponse(Response response)
          Store the Response of a deferred Request.
 void updateResponse(Response response)
          Update the Response in the Database, based on the Identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_NAME_DATABASE_PATH

public static final java.lang.String PROPERTY_NAME_DATABASE_PATH
Property of the path to the location of the database

See Also:
Constant Field Values

PROPERTY_NAME_DATABASE_NAME

public static final java.lang.String PROPERTY_NAME_DATABASE_NAME
Property of the path to the location of the database - Actual name of the database.

See Also:
Constant Field Values

PROPERTY_NAME_DATABASE

public static final java.lang.String PROPERTY_NAME_DATABASE
Property of the path to the location of the database - name of database type: DERBY, HSQL, ...

See Also:
Constant Field Values

creationString

public static final java.lang.String creationString
SQL to create a response in the DB

See Also:
Constant Field Values

insertionString

public static final java.lang.String insertionString
SQL to insert a response into the database

See Also:
Constant Field Values

updateString

public static final java.lang.String updateString
SQL to update a response, that was already stored in the database

See Also:
Constant Field Values

selectionString

public static final java.lang.String selectionString
SQL to retrieve a response from the database

See Also:
Constant Field Values

SELECT_COLUMN_RESPONSE

protected static final int SELECT_COLUMN_RESPONSE
The column of "response" in the select statement.

See Also:
Constant Field Values

INSERT_COLUMN_REQUEST_ID

protected static final int INSERT_COLUMN_REQUEST_ID
The column of "request_id" in the insert statement.

See Also:
Constant Field Values

INSERT_COLUMN_REQUEST_DATE

protected static final int INSERT_COLUMN_REQUEST_DATE
The column of "request_data" in the insert statement.

See Also:
Constant Field Values

INSERT_COLUMN_RESPONSE_TYPE

protected static final int INSERT_COLUMN_RESPONSE_TYPE
The column of "response_type" in the insert statement.

See Also:
Constant Field Values

INSERT_COLUMN_RESPONSE

protected static final int INSERT_COLUMN_RESPONSE
The column of "response" in the insert statement.

See Also:
Constant Field Values

UPDATE_COLUMN_RESPONSE

protected static final int UPDATE_COLUMN_RESPONSE
The column of "response" in the update statement.

See Also:
Constant Field Values

UPDATE_COLUMN_REQUEST_ID

protected static final int UPDATE_COLUMN_REQUEST_ID
The column of "request_id" in the update statement.

See Also:
Constant Field Values

INSERT_COLUMN_MIME_TYPE

protected static final int INSERT_COLUMN_MIME_TYPE
See Also:
Constant Field Values

insertSQL

protected static java.sql.PreparedStatement insertSQL

updateSQL

protected static java.sql.PreparedStatement updateSQL

selectSQL

protected static java.sql.PreparedStatement selectSQL
Constructor Detail

AbstractDatabase

public AbstractDatabase()
Method Detail

getInstance

public static IDatabase getInstance()
Get an instance of the Database object. Only one instance is required. If it not already exists, it will be created. The first call of this method can take some time. Preferable call this method once on application startup, to serve additional calls in less time. When the Database-application is started, it first tries to connect to an existing database. If it is not found, this method tries to create a new one. Implementations can have additional properties, such as username/password.

Returns:
A static instance of Database.

insertResponse

public java.lang.String insertResponse(Response response)
Insert a new Response into the Database.

Specified by:
insertResponse in interface IDatabase
Parameters:
response - The Response to insert.
See Also:
storeResponse(Response)

insertResultEntity

protected java.lang.String insertResultEntity(LargeBufferStream baos,
                                              java.lang.String id,
                                              java.lang.String type,
                                              java.lang.String mimeType)
Inserts any result, which has to be stored in the DB.

Parameters:
baos -
id -
type -

updateResponse

public void updateResponse(Response response)
Update the Response in the Database, based on the Identifier.

Specified by:
updateResponse in interface IDatabase
Parameters:
response - The Response to update
See Also:
storeResponse(Response)

storeResponse

public java.lang.String storeResponse(Response response)
Store the Response of a deferred Request. It either gets inserted into the databse, or it updates a previous Response, based on the identifier.

Specified by:
storeResponse in interface IDatabase
Parameters:
response - The Response to store.

lookupResponse

public java.io.InputStream lookupResponse(java.lang.String request_id)
Retrieve the Response on a previous Request, based on an unique identifier, which was already given to the client for reference.

Specified by:
lookupResponse in interface IDatabase
Parameters:
request_id - The identifier of the Request
Returns:
null, if an SQLException occurred, else an InputStream with the Response

storeComplexValue

public java.lang.String storeComplexValue(java.lang.String id,
                                          LargeBufferStream stream,
                                          java.lang.String type,
                                          java.lang.String mimeType)
Specified by:
storeComplexValue in interface IDatabase

generateRetrieveResultURL

public java.lang.String generateRetrieveResultURL(java.lang.String id)
The URL referencing the location from which the ExecuteResponse can be retrieved. If "status" is "true" in the Execute request, the ExecuteResponse should also be found here as soon as the process returns the initial response to the client. It should persist at this location as long as the outputs are accessible from the server. The outputs may be stored for as long as the implementer of the server decides. If the process takes a long time, this URL can be repopulated on an ongoing basis in order to keep the client updated on progress. Before the process has succeeded, the ExecuteResponse contains information about the status of the process, including whether or not processing has started, and the percentage completed. It may also optionally contain the inputs and any ProcessStartedType interim results. When the process has succeeded, the ExecuteResponse found at this URL shall contain the output values or references to them.

Specified by:
generateRetrieveResultURL in interface IDatabase
Returns:

getConnection

public abstract java.sql.Connection getConnection()

getConnectionURL

public abstract java.lang.String getConnectionURL()

getDatabaseName

public java.lang.String getDatabaseName()
Returns the name of the database.

Specified by:
getDatabaseName in interface IDatabase

getDatabasePath

protected static java.lang.String getDatabasePath()
Returns the path to the database.


shutdown

public void shutdown()
Specified by:
shutdown in interface IDatabase
Throws:
java.lang.Exception

getMimeTypeForStoreResponse

public java.lang.String getMimeTypeForStoreResponse(java.lang.String id)
Specified by:
getMimeTypeForStoreResponse in interface IDatabase

deleteStoredResponse

public boolean deleteStoredResponse(java.lang.String id)
Specified by:
deleteStoredResponse in interface IDatabase

lookupResponseAsFile

public java.io.File lookupResponseAsFile(java.lang.String id)
Specified by:
lookupResponseAsFile in interface IDatabase


Copyright © 2007-2011 52north.org. All Rights Reserved.