org.fosstrak.epcis.repository.capture
Class CaptureOperationsBackendSQL

java.lang.Object
  extended by org.fosstrak.epcis.repository.capture.CaptureOperationsBackendSQL
All Implemented Interfaces:
CaptureOperationsBackend

public class CaptureOperationsBackendSQL
extends Object
implements CaptureOperationsBackend

The CaptureOperationsBackendSQL uses basic SQL statements (actually PreparedStatements) to implement the CaptureOperationsBackend interface.

Author:
Alain Remund, Marco Steybe, Sean Wellington

Constructor Summary
CaptureOperationsBackendSQL()
           
 
Method Summary
 void dbReset(Connection dbconnection, String dbResetScript)
          Runs the dbreset SQL script.
 Long getVocabularyElement(CaptureOperationsSession session, String vocabularyType, String vocabularyElement)
          Retrieves the ID (primary key) of the vocabulary with the given type that matches the given URI string.
 Long insertAggregationEvent(CaptureOperationsSession session, Timestamp eventTime, Timestamp recordTime, String eventTimeZoneOffset, Long bizStepId, Long dispositionId, Long readPointId, Long bizLocationId, String action, String parentId)
          Inserts a new EPCIS aggregation event into the database.
 Long insertBusinessTransaction(CaptureOperationsSession session, String bizTrans, String bizTransType)
          Inserts the BusinessTransactionType and the BusinessTransactionID into the BusinessTransaction-Table if necessary.
 void insertBusinessTransactionsForEvent(CaptureOperationsSession session, long eventId, String eventType, List<BusinessTransactionType> btts)
          
 void insertEpcsForEvent(CaptureOperationsSession session, long eventId, String eventType, List<String> epcs)
          Inserts the given EPCs into the database and associates them with the EPCIS event with the given type and ID (primary key).
 void insertExtensionFieldsForEvent(CaptureOperationsSession session, long eventId, String eventType, List<EventFieldExtension> exts)
          
 Long insertObjectEvent(CaptureOperationsSession session, Timestamp eventTime, Timestamp recordTime, String eventTimeZoneOffset, Long bizStepId, Long dispositionId, Long readPointId, Long bizLocationId, String action)
          Inserts a new EPCIS object event into the database.
 Long insertQuantityEvent(CaptureOperationsSession session, Timestamp eventTime, Timestamp recordTime, String eventTimeZoneOffset, Long bizStepId, Long dispositionId, Long readPointId, Long bizLocationId, Long epcClassId, Long quantity)
          Inserts a new EPCIS quantity event into the database.
 Long insertTransactionEvent(CaptureOperationsSession session, Timestamp eventTime, Timestamp recordTime, String eventTimeZoneOffset, Long bizStepId, Long dispositionId, Long readPointId, Long bizLocationId, String action, String parentId)
          Inserts a new EPCIS transaction event into the database.
 Long insertVocabularyElement(CaptureOperationsSession session, String vocabularyType, String vocabularyElement)
          Inserts the vocabulary of the given type and the given vocabulary element URI into the database.
 CaptureOperationsSession openSession(DataSource dataSource)
          Opens a new session for the database transaction.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CaptureOperationsBackendSQL

public CaptureOperationsBackendSQL()
Method Detail

dbReset

public void dbReset(Connection dbconnection,
                    String dbResetScript)
             throws SQLException,
                    IOException
Runs the dbreset SQL script.

Specified by:
dbReset in interface CaptureOperationsBackend
Parameters:
dbconnection - The JDBC Connection object.
dbResetScript - The filename of the SQL script to execute.
Throws:
SQLException - If an error with the database occurred.
IOException - If an exception reading from the SQL script occurred.

openSession

public CaptureOperationsSession openSession(DataSource dataSource)
                                     throws SQLException
Opens a new session for the database transaction.

Specified by:
openSession in interface CaptureOperationsBackend
Parameters:
dataSource - The DataSource object to retrieve the database connection from.
Returns:
A CaptureOperationsSession instantiated with the database connection retrieved from the given DataSource.
Throws:
SQLException - If an SQL error occurred.

insertObjectEvent

public Long insertObjectEvent(CaptureOperationsSession session,
                              Timestamp eventTime,
                              Timestamp recordTime,
                              String eventTimeZoneOffset,
                              Long bizStepId,
                              Long dispositionId,
                              Long readPointId,
                              Long bizLocationId,
                              String action)
                       throws SQLException
Inserts a new EPCIS object event into the database.

Specified by:
insertObjectEvent in interface CaptureOperationsBackend
Parameters:
session - The database session.
eventTime - The event's 'eventTime' parameter.
recordTime - The event's 'recordTime' parameter.
eventTimeZoneOffset - The event's 'eventTimeZoneOffset' parameter.
bizStepId - The event's 'BusinessStepID' parameter.
dispositionId - The event's 'DispositionID' parameter.
readPointId - The event's 'ReadPointID' parameter.
bizLocationId - The event's 'BusinessLocationID' parameter.
action - The event's 'action' parameter.
Returns:
The database primary key of the inserted EPCIS object event.
Throws:
SQLException - If an SQL exception occurred.

insertTransactionEvent

public Long insertTransactionEvent(CaptureOperationsSession session,
                                   Timestamp eventTime,
                                   Timestamp recordTime,
                                   String eventTimeZoneOffset,
                                   Long bizStepId,
                                   Long dispositionId,
                                   Long readPointId,
                                   Long bizLocationId,
                                   String action,
                                   String parentId)
                            throws SQLException
Inserts a new EPCIS transaction event into the database.

Specified by:
insertTransactionEvent in interface CaptureOperationsBackend
Parameters:
session - The database session.
eventTime - The event's 'eventTime' parameter.
recordTime - The event's 'recordTime' parameter.
eventTimeZoneOffset - The event's 'eventTimeZoneOffset' parameter.
bizStepId - The event's 'BusinessStepID' parameter.
dispositionId - The event's 'DispositionID' parameter.
readPointId - The event's 'ReadPointID' parameter.
bizLocationId - The event's 'BusinessLocationID' parameter.
action - The event's 'action' parameter.
parentId - The event's 'ParentID' parameter.
Returns:
The database primary key of the inserted EPCIS transaction event.
Throws:
SQLException - If an SQL exception occurred.

insertAggregationEvent

public Long insertAggregationEvent(CaptureOperationsSession session,
                                   Timestamp eventTime,
                                   Timestamp recordTime,
                                   String eventTimeZoneOffset,
                                   Long bizStepId,
                                   Long dispositionId,
                                   Long readPointId,
                                   Long bizLocationId,
                                   String action,
                                   String parentId)
                            throws SQLException
Inserts a new EPCIS aggregation event into the database.

Specified by:
insertAggregationEvent in interface CaptureOperationsBackend
Parameters:
session - The database session.
eventTime - The event's 'eventTime' parameter.
recordTime - The event's 'recordTime' parameter.
eventTimeZoneOffset - The event's 'eventTimeZoneOffset' parameter.
bizStepId - The event's 'BusinessStepID' parameter.
dispositionId - The event's 'DispositionID' parameter.
readPointId - The event's 'ReadPointID' parameter.
bizLocationId - The event's 'BusinessLocationID' parameter.
action - The event's 'action' parameter.
parentId - The event's 'ParentID' parameter.
Returns:
The database primary key of the inserted EPCIS aggregation event.
Throws:
SQLException - If an SQL exception occurred.

insertQuantityEvent

public Long insertQuantityEvent(CaptureOperationsSession session,
                                Timestamp eventTime,
                                Timestamp recordTime,
                                String eventTimeZoneOffset,
                                Long bizStepId,
                                Long dispositionId,
                                Long readPointId,
                                Long bizLocationId,
                                Long epcClassId,
                                Long quantity)
                         throws SQLException
Inserts a new EPCIS quantity event into the database.

Specified by:
insertQuantityEvent in interface CaptureOperationsBackend
Parameters:
session - The database session.
eventTime - The event's 'eventTime' parameter.
recordTime - The event's 'recordTime' parameter.
eventTimeZoneOffset - The event's 'eventTimeZoneOffset' parameter.
bizStepId - The event's 'BusinessStepID' parameter.
dispositionId - The event's 'DispositionID' parameter.
readPointId - The event's 'ReadPointID' parameter.
bizLocationId - The event's 'BusinessLocationID' parameter.
epcClassId - The event's 'EpcClassID' parameter.
quantity - The event's 'quantity' parameter.
Returns:
The database primary key of the inserted EPCIS quantity event.
Throws:
SQLException - If an SQL exception occurred.

insertEpcsForEvent

public void insertEpcsForEvent(CaptureOperationsSession session,
                               long eventId,
                               String eventType,
                               List<String> epcs)
                        throws SQLException
Inserts the given EPCs into the database and associates them with the EPCIS event with the given type and ID (primary key).

Specified by:
insertEpcsForEvent in interface CaptureOperationsBackend
Parameters:
session - The database session.
eventId - The ID (primary key) of the EPCIS event for which the EPCs should be inserted.
eventType - The type of the EPCIS event for which the EPCs should be inserted.
epcs - The List of EPCs to insert.
Throws:
SQLException - If an SQL error occurred.

getVocabularyElement

public Long getVocabularyElement(CaptureOperationsSession session,
                                 String vocabularyType,
                                 String vocabularyElement)
                          throws SQLException
Retrieves the ID (primary key) of the vocabulary with the given type that matches the given URI string. If no vocabulary element with the given URI exists, null will be returned.

Specified by:
getVocabularyElement in interface CaptureOperationsBackend
Parameters:
session - The database session.
vocabularyType - The type of the vocabulary to retrieve. The type determines from which database table name the primary key will be retrieved.
vocabularyElement - The URI string of the vocabulary element to retrieve.
Returns:
The ID (primary key) of the matching vocabulary element, or null if none was found.
Throws:
SQLException - If an SQL error occurred.

insertVocabularyElement

public Long insertVocabularyElement(CaptureOperationsSession session,
                                    String vocabularyType,
                                    String vocabularyElement)
                             throws SQLException
Inserts the vocabulary of the given type and the given vocabulary element URI into the database.

Specified by:
insertVocabularyElement in interface CaptureOperationsBackend
Parameters:
session - The database session.
vocabularyType - The type of the vocabulary to insert. The type determines to which database table name the vocabulary will be inserted.
vocabularyElement - The URI string of the vocabulary element to insert.
Returns:
The ID (primary key) of the inserted vocabulary element.
Throws:
SQLException - If an SQL error occurred.

insertBusinessTransaction

public Long insertBusinessTransaction(CaptureOperationsSession session,
                                      String bizTrans,
                                      String bizTransType)
                               throws SQLException
Inserts the BusinessTransactionType and the BusinessTransactionID into the BusinessTransaction-Table if necessary.

Specified by:
insertBusinessTransaction in interface CaptureOperationsBackend
Parameters:
session - The database session.
bizTrans - The BusinessTransaction to be inserted.
bizTransType - The type of the business transaction to insert.
Returns:
The ID from the BusinessTransaction-table.
Throws:
SQLException - If an SQL problem with the database occurred.

insertBusinessTransactionsForEvent

public void insertBusinessTransactionsForEvent(CaptureOperationsSession session,
                                               long eventId,
                                               String eventType,
                                               List<BusinessTransactionType> btts)
                                        throws SQLException

Specified by:
insertBusinessTransactionsForEvent in interface CaptureOperationsBackend
Throws:
SQLException

insertExtensionFieldsForEvent

public void insertExtensionFieldsForEvent(CaptureOperationsSession session,
                                          long eventId,
                                          String eventType,
                                          List<EventFieldExtension> exts)
                                   throws SQLException

Specified by:
insertExtensionFieldsForEvent in interface CaptureOperationsBackend
Throws:
SQLException


Copyright © 2010. All Rights Reserved.