rjw.dc.db
Class Database

java.lang.Object
  |
  +--rjw.dc.db.Database

public class Database
extends java.lang.Object

Holder of the Database connection and information. Starts the QueryQueue and handles update, insert and select statements.

On the first start, the Database will be created (if the database is empty; the tables do not exist). If this fails, a message is shown to the user.

For new records, the unique ID is created by this class. This has not been perfected at this moment.

Since:
1.3
Version:
DC0.50
Author:
Robert-Jan van der Waals

Constructor Summary
Database()
          Initializes the Database, creates a new one if necessary
 
Method Summary
static void close()
           
 void deleteCollection(DataCrowCollection collection, RequestorCollection requestors)
           
 void deleteValues(DataCrowObject o, RequestorCollection requestors)
          Deletes values from the database.
 void init()
          Starts the query queue and initializes the database connection
 void insertCollection(DataCrowCollection collection, RequestorCollection requestors)
           
 void insertValues(DataCrowObject o, RequestorCollection requestors)
          Inserts new values.
 void runQuery(java.lang.String sQuery, RequestorCollection requestors)
          Runs a predefined query
 java.lang.Object runQueryDirect(DataCrowObject o)
          Runs a query directly, bypassing the query queue
 java.lang.Object runQueryDirect(Query query)
          Does not put the query in a queue but executes it immediately.
 java.lang.Object runQueryDirect(java.lang.String sQuery)
          Does not put the query in a queue but executes it immediately.
 void searchValues(DataCrowObject o, QueryOptions options, RequestorCollection requestors)
          Searches for values.
 boolean uniqueValues(DataCrowObject o, boolean bUpdateQuery)
          Checks whether the values are unique (do not exist as yet in the database).
 void updateCollection(DataCrowCollection collection, RequestorCollection requestors)
           
 void updateValues(DataCrowObject o, RequestorCollection requestors)
          Updates values.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Database

public Database()
Initializes the Database, creates a new one if necessary

Method Detail

close

public static void close()

init

public void init()
Starts the query queue and initializes the database connection

See Also:
DatabaseConnection, QueryQueue

insertCollection

public void insertCollection(DataCrowCollection collection,
                             RequestorCollection requestors)

updateCollection

public void updateCollection(DataCrowCollection collection,
                             RequestorCollection requestors)

deleteCollection

public void deleteCollection(DataCrowCollection collection,
                             RequestorCollection requestors)

runQuery

public void runQuery(java.lang.String sQuery,
                     RequestorCollection requestors)
Runs a predefined query

Parameters:
sQuery - query statement
requestors - requests to the UI

runQueryDirect

public java.lang.Object runQueryDirect(java.lang.String sQuery)
Does not put the query in a queue but executes it immediately. Errors are returned to the caller (not thrown)

Parameters:
sQuery - query statement

runQueryDirect

public java.lang.Object runQueryDirect(DataCrowObject o)
Runs a query directly, bypassing the query queue


runQueryDirect

public java.lang.Object runQueryDirect(Query query)
Does not put the query in a queue but executes it immediately. Errors are returned to the caller (not thrown)


searchValues

public void searchValues(DataCrowObject o,
                         QueryOptions options,
                         RequestorCollection requestors)
Searches for values. The query is put in the query queue. The results are past to the caller by using the RequestorCollection

Parameters:
o - the object which is used as the condition
options - query options
requestors - requestors for the result of the query (UI)

updateValues

public void updateValues(DataCrowObject o,
                         RequestorCollection requestors)
Updates values. The query is put in the query queue. Actions are past to the caller by using the RequestorCollection

Parameters:
o - the object to be updated
requestors - requestors which depend on the outcome of the query

insertValues

public void insertValues(DataCrowObject o,
                         RequestorCollection requestors)
Inserts new values. The query is put in the query queue. Actions are past to the caller by using the RequestorCollection

Parameters:
o - the object to be inserted
requestors - requestors which depend on the outcome of the query

deleteValues

public void deleteValues(DataCrowObject o,
                         RequestorCollection requestors)
Deletes values from the database. The query is put in the query queue. Actions are past to the caller by using the RequestorCollection

Parameters:
o - the object to be deleted
requestors - requestors which depend on the outcome of the query

uniqueValues

public boolean uniqueValues(DataCrowObject o,
                            boolean bUpdateQuery)
Checks whether the values are unique (do not exist as yet in the database). Updates and inserts are checked differently

Parameters:
o - object to be checked
bUpdateQuery - specifies whether this is an update or an insert