org.fosstrak.llrp.client.repository.sql.roaccess
Class AbstractSQLROAccessReportsRepository

java.lang.Object
  extended by org.fosstrak.llrp.client.repository.sql.roaccess.AbstractSQLROAccessReportsRepository
All Implemented Interfaces:
MessageHandler, ROAccessReportsRepository
Direct Known Subclasses:
DerbyROAccessReportsRepository

public abstract class AbstractSQLROAccessReportsRepository
extends java.lang.Object
implements ROAccessReportsRepository

Gives access to the database holding logged RO_ACCESS_REPORTS. There are several constants helping you to simplify your SQL code. If your database does not support the datatypes used in DerbyROAccessReportsRepository you should subclass from this class and invoke the respective class from your repository implementation Repository.

Author:
sawielan

Field Summary
static int CINDEX_AccessSpecID
          column index of the access spec ID.
static int CINDEX_ADAPTER
          column index of the adapter name.
static int CINDEX_AntennaID
          column index of the antenna ID.
static int CINDEX_C1G2_CRC
          column index of the c1g2 crc.
static int CINDEX_C1G2_PC
          column index of the c1g2 pc.
static int CINDEX_ChannelIndex
          column index of the channel index.
static int CINDEX_EPC
          column index of the EPC value.
static int CINDEX_FirstSeenTimestampUptime
          column index of the first seen time stamp since uptime.
static int CINDEX_FirstSeenTimestampUTC
          column index of the first seen time stamp in UTC.
static int CINDEX_InventoryParameterSpecID
          column index of the inventory parameter spec ID.
static int CINDEX_LastSeenTimestampUptime
          column index of the last seen time stamp since uptime.
static int CINDEX_LastSeenTimestampUTC
          column index of the last seen time stamp in UTC.
static int CINDEX_LOGTIME
          column index of the log time.
static int CINDEX_PeakRSSI
          column index of the peak RSSI.
static int CINDEX_READER
          column index of the reader name.
static int CINDEX_ROSpecID
          column index of the RO spec ID.
static int CINDEX_SpecIndex
          column index of the spec index.
static int CINDEX_TagSeenCount
          column index of the tag seen count.
protected  boolean initialized
          flag, whether this repository is initialized or not.
static int NUM_COLUMNS
          the number of columns in the table.
protected  Repository repository
          the repository "owning" this item.
static java.lang.String TABLE_RO_ACCESS_REPORTS
          the name of the RO_ACCESS_REPORTS table.
protected  boolean wipe
          whether to wipe the database at startup or not.
 
Constructor Summary
AbstractSQLROAccessReportsRepository()
          creates a new handle to the RO_ACCESS_REPORTS repository.
 
Method Summary
protected  boolean checkIfTableOk()
          checks whether the required tables exist or not.
 void clear()
          drop all the messages in the repository.
protected  boolean createTable()
          create a new log table.
protected  boolean dropTable()
          drop the log table.
static java.sql.Timestamp extractTimestamp(org.llrp.ltk.types.UnsignedLong ulong)
          Creates a TimeStamp object from a UnsignedLong object.
 java.util.List<ROAccessItem> getAll()
          retrieves all the RO_ACCESS_REPORTS elements in the database.
 void handle(java.lang.String adapterName, java.lang.String readerName, org.llrp.ltk.types.LLRPMessage message)
          This method is invoked from the adapter management whenever a new LLRP message arrives on an attached reader.
protected  void handleROAccessReport(java.lang.String adapterName, java.lang.String readerName, org.llrp.ltk.generated.messages.RO_ACCESS_REPORT message)
          write an RO_ACCESS_REPORT into the database.
 void initialize(Repository repository)
          Initializer for the RO_ACCESS_REPORTS repository.
 boolean isTableOK()
           
 void setRepository(Repository repository)
          set the repository that "owns" this RO_ACCESS_REPORTS repository.
protected abstract  java.lang.String sqlCreateTable()
           
protected abstract  java.lang.String sqlDropTable()
           
protected abstract  java.lang.String sqlInsert()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TABLE_RO_ACCESS_REPORTS

public static final java.lang.String TABLE_RO_ACCESS_REPORTS
the name of the RO_ACCESS_REPORTS table.

See Also:
Constant Field Values

CINDEX_LOGTIME

public static final int CINDEX_LOGTIME
column index of the log time.

See Also:
Constant Field Values

CINDEX_ADAPTER

public static final int CINDEX_ADAPTER
column index of the adapter name.

See Also:
Constant Field Values

CINDEX_READER

public static final int CINDEX_READER
column index of the reader name.

See Also:
Constant Field Values

CINDEX_EPC

public static final int CINDEX_EPC
column index of the EPC value.

See Also:
Constant Field Values

CINDEX_ROSpecID

public static final int CINDEX_ROSpecID
column index of the RO spec ID.

See Also:
Constant Field Values

CINDEX_SpecIndex

public static final int CINDEX_SpecIndex
column index of the spec index.

See Also:
Constant Field Values

CINDEX_InventoryParameterSpecID

public static final int CINDEX_InventoryParameterSpecID
column index of the inventory parameter spec ID.

See Also:
Constant Field Values

CINDEX_AntennaID

public static final int CINDEX_AntennaID
column index of the antenna ID.

See Also:
Constant Field Values

CINDEX_PeakRSSI

public static final int CINDEX_PeakRSSI
column index of the peak RSSI.

See Also:
Constant Field Values

CINDEX_ChannelIndex

public static final int CINDEX_ChannelIndex
column index of the channel index.

See Also:
Constant Field Values

CINDEX_FirstSeenTimestampUTC

public static final int CINDEX_FirstSeenTimestampUTC
column index of the first seen time stamp in UTC.

See Also:
Constant Field Values

CINDEX_FirstSeenTimestampUptime

public static final int CINDEX_FirstSeenTimestampUptime
column index of the first seen time stamp since uptime.

See Also:
Constant Field Values

CINDEX_LastSeenTimestampUTC

public static final int CINDEX_LastSeenTimestampUTC
column index of the last seen time stamp in UTC.

See Also:
Constant Field Values

CINDEX_LastSeenTimestampUptime

public static final int CINDEX_LastSeenTimestampUptime
column index of the last seen time stamp since uptime.

See Also:
Constant Field Values

CINDEX_TagSeenCount

public static final int CINDEX_TagSeenCount
column index of the tag seen count.

See Also:
Constant Field Values

CINDEX_C1G2_CRC

public static final int CINDEX_C1G2_CRC
column index of the c1g2 crc.

See Also:
Constant Field Values

CINDEX_C1G2_PC

public static final int CINDEX_C1G2_PC
column index of the c1g2 pc.

See Also:
Constant Field Values

CINDEX_AccessSpecID

public static final int CINDEX_AccessSpecID
column index of the access spec ID.

See Also:
Constant Field Values

NUM_COLUMNS

public static final int NUM_COLUMNS
the number of columns in the table.

See Also:
Constant Field Values

repository

protected Repository repository
the repository "owning" this item.


wipe

protected boolean wipe
whether to wipe the database at startup or not.


initialized

protected boolean initialized
flag, whether this repository is initialized or not.

Constructor Detail

AbstractSQLROAccessReportsRepository

public AbstractSQLROAccessReportsRepository()
creates a new handle to the RO_ACCESS_REPORTS repository. The default constructor uses the connection from the DerbyRepository.

Method Detail

setRepository

public void setRepository(Repository repository)
Description copied from interface: ROAccessReportsRepository
set the repository that "owns" this RO_ACCESS_REPORTS repository.

Specified by:
setRepository in interface ROAccessReportsRepository
Parameters:
repository - the repository that "owns" this RO_ACCESS_REPORTS repository.

sqlCreateTable

protected abstract java.lang.String sqlCreateTable()
Returns:
a SQL creating the necessary table.

sqlDropTable

protected abstract java.lang.String sqlDropTable()
Returns:
a SQL dropping the table.

sqlInsert

protected abstract java.lang.String sqlInsert()
Returns:
a SQL allowing to insert a new log item.

initialize

public void initialize(Repository repository)
                throws LLRPRuntimeException
Description copied from interface: ROAccessReportsRepository
Initializer for the RO_ACCESS_REPORTS repository. NOTICE: if you create an instance of a subclass of this interface, you MUST call this method directly after instantiation.

Specified by:
initialize in interface ROAccessReportsRepository
Parameters:
repository - the repository belonging to this RO_ACCESS_REPORTS DB.
Throws:
LLRPRuntimeException

dropTable

protected boolean dropTable()
drop the log table.


createTable

protected boolean createTable()
create a new log table.


checkIfTableOk

protected boolean checkIfTableOk()
checks whether the required tables exist or not.

Returns:
true if everything is OK, false otherwise.

isTableOK

public boolean isTableOK()
Returns:
true if the table is up and OK, false otherwise.

handle

public void handle(java.lang.String adapterName,
                   java.lang.String readerName,
                   org.llrp.ltk.types.LLRPMessage message)
Description copied from interface: MessageHandler
This method is invoked from the adapter management whenever a new LLRP message arrives on an attached reader.

Specified by:
handle in interface MessageHandler
Parameters:
adapterName - the name of the adapter where the reader belongs to.
readerName - the name of the receiving reader.
message - the LLRP message.

handleROAccessReport

protected void handleROAccessReport(java.lang.String adapterName,
                                    java.lang.String readerName,
                                    org.llrp.ltk.generated.messages.RO_ACCESS_REPORT message)
write an RO_ACCESS_REPORT into the database.

Parameters:
adapterName - name of the adapter.
readerName - name of the reader.
message - the LLRP RO_ACCESS_REPORT to be logged.

getAll

public java.util.List<ROAccessItem> getAll()
                                    throws java.lang.Exception
Description copied from interface: ROAccessReportsRepository
retrieves all the RO_ACCESS_REPORTS elements in the database.

Specified by:
getAll in interface ROAccessReportsRepository
Returns:
a list of all the entries in the database stored into ROAccessItem.
Throws:
java.lang.Exception - when there is an error of any kind.

clear

public void clear()
           throws java.lang.Exception
Description copied from interface: ROAccessReportsRepository
drop all the messages in the repository.

Specified by:
clear in interface ROAccessReportsRepository
Throws:
java.lang.Exception - when there is an error of any kind.

extractTimestamp

public static java.sql.Timestamp extractTimestamp(org.llrp.ltk.types.UnsignedLong ulong)
Creates a TimeStamp object from a UnsignedLong object.

Parameters:
ulong - the unsigned long TimeStamp object.
Returns:
a SQL Timestamp object.


Copyright © 2009. All Rights Reserved.