edu.washington.cs.rfid.data.db
Class DeploymentDataConnection

java.lang.Object
  extended by java.lang.Thread
      extended by edu.washington.cs.rfid.data.db.DeploymentDataConnection
All Implemented Interfaces:
java.lang.Runnable

public class DeploymentDataConnection
extends java.lang.Thread

A wrapper for a SimpleDBConnection that provides methods for retrieving deployment metadata (i.e. data on readers, antennas, configuration, etc.) from the RFID database. Also supports a remote connection to the data manager for dynamic updates on deployment metadata which it can forward to listeners.

Author:
Evan

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
DeploymentDataConnection(SimpleDBConnection db)
          Creates a new DeploymentDataConnection using the given SimpleDBConnection.
 
Method Summary
 void addListener(DeploymentDataConnectionListener l)
          Adds a new DeploymentDataConnectionListener to the list of listeners.
 boolean endTransaction()
          Stops a transaction by turning on auto commit mode for this connection.
 java.util.Hashtable<java.lang.Integer,java.util.Vector<java.lang.Integer>> getAdjacentAntennaHashtable()
          Retrieves the adjacent antenna table from the database and returns it in a Hashtable.
 java.util.Hashtable<java.lang.Integer,java.util.Vector<AntMetadata>> getAntennaHashtable(int gatewayID)
          Retrieves the antenna metadata for the antennas of readers connected to the specified gateway and returns it in a Hashtable.
 java.util.Vector<AntMetadata> getAntMetadataVector()
          Retrieves the antenna metadata from the database and returns it in a Vector.
 java.util.Vector<RdrMetadata> getGatewayToRdrConfigVector(int gatewayID)
          Retrieves the gateway to reader configuration information for a specified gateway and returns it in a Vector.
 java.util.Vector<RdrMetadata> getRdrMetadataVector()
          Retrieves the reader metadata from the database and returns it in a Vector.
 java.util.Hashtable<java.lang.Integer,java.util.Hashtable<java.lang.Integer,java.lang.Boolean>> getVisibleAntennaHashtable()
          Retrieves the visible antenna table from the database and returns it in a Hashtable.
 boolean insertAdjacentAnt(int antAID, int antBID)
          Inserts an adjacent antenna pair.
 boolean insertAntMetadata(AntMetadata ant)
          Inserts the antenna metadata for a particular antenna.
 boolean insertRdrMetadata(RdrMetadata rdr)
          Inserts the reader metadata for a particular reader.
 boolean insertVisibleAnt(int antAID, int antBID)
          Inserts a visible antenna pair.
 boolean rollback()
          Rolls back database state to the last committed transaction.
 void run()
          The run method from Thread.
 boolean startTransaction()
          Starts a transaction by turning off auto commit mode for this connection.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DeploymentDataConnection

public DeploymentDataConnection(SimpleDBConnection db)
Creates a new DeploymentDataConnection using the given SimpleDBConnection.

Parameters:
db -
Method Detail

startTransaction

public boolean startTransaction()
Starts a transaction by turning off auto commit mode for this connection.


rollback

public boolean rollback()
Rolls back database state to the last committed transaction.

Returns:

endTransaction

public boolean endTransaction()
Stops a transaction by turning on auto commit mode for this connection.


addListener

public void addListener(DeploymentDataConnectionListener l)
Adds a new DeploymentDataConnectionListener to the list of listeners.

Parameters:
l - The DeploymentDataConnectionListener

getRdrMetadataVector

public java.util.Vector<RdrMetadata> getRdrMetadataVector()
Retrieves the reader metadata from the database and returns it in a Vector.

Returns:
A Vector containing all the reader metadata

getAntMetadataVector

public java.util.Vector<AntMetadata> getAntMetadataVector()
Retrieves the antenna metadata from the database and returns it in a Vector.

Returns:
A Vector containing all the antenna metadata

getAntennaHashtable

public java.util.Hashtable<java.lang.Integer,java.util.Vector<AntMetadata>> getAntennaHashtable(int gatewayID)
Retrieves the antenna metadata for the antennas of readers connected to the specified gateway and returns it in a Hashtable.

Parameters:
gatewayID - The gateway to retrieve the antenna metadata for
Returns:
The antenna metadata contained in a Hashtable\\>

getVisibleAntennaHashtable

public java.util.Hashtable<java.lang.Integer,java.util.Hashtable<java.lang.Integer,java.lang.Boolean>> getVisibleAntennaHashtable()
Retrieves the visible antenna table from the database and returns it in a Hashtable.

Returns:
A Hashtable containing the visible antenna table.

getAdjacentAntennaHashtable

public java.util.Hashtable<java.lang.Integer,java.util.Vector<java.lang.Integer>> getAdjacentAntennaHashtable()
Retrieves the adjacent antenna table from the database and returns it in a Hashtable.

Returns:
A Hashtable containing the adjacent antenna table.

getGatewayToRdrConfigVector

public java.util.Vector<RdrMetadata> getGatewayToRdrConfigVector(int gatewayID)
Retrieves the gateway to reader configuration information for a specified gateway and returns it in a Vector.

Parameters:
gatewayID - The gateway to retrieve the configuration information for.
Returns:
The gateway to reader configuration information for the specified gateway in a Vector.

insertRdrMetadata

public boolean insertRdrMetadata(RdrMetadata rdr)
Inserts the reader metadata for a particular reader.

Parameters:
The - reader metadata
Returns:
True if the metadata is successfully created, false o/w

insertAntMetadata

public boolean insertAntMetadata(AntMetadata ant)
Inserts the antenna metadata for a particular antenna.

Parameters:
The - antenna metadata
Returns:
True if the metadata is successfully created, false o/w

insertVisibleAnt

public boolean insertVisibleAnt(int antAID,
                                int antBID)
Inserts a visible antenna pair.

Parameters:
The - visible antenna pair
Returns:
True if the antenna pair is successfully created, false o/w

insertAdjacentAnt

public boolean insertAdjacentAnt(int antAID,
                                 int antBID)
Inserts an adjacent antenna pair.

Parameters:
The - adjacent antenna pair
Returns:
True if the antenna pair is successfully created, false o/w

run

public void run()
The run method from Thread. Maintains a connection to the data manager over which it receives updates regarding deployment data changes. For each received update, it alerts all the DeploymentDataConnectionListeners.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread