org.compass.gps.device.jdbc
Class ResultSetJdbcGpsDevice

java.lang.Object
  extended by org.compass.gps.device.AbstractGpsDevice
      extended by org.compass.gps.device.jdbc.AbstractJdbcGpsDevice
          extended by org.compass.gps.device.jdbc.AbstractJdbcActiveMirrorGpsDevice
              extended by org.compass.gps.device.jdbc.ResultSetJdbcGpsDevice
All Implemented Interfaces:
ActiveMirrorGpsDevice, CompassGpsDevice, JdbcActiveMirrorGpsDevice, JdbcGpsDevice, MirrorDataChangesGpsDevice

public class ResultSetJdbcGpsDevice
extends AbstractJdbcActiveMirrorGpsDevice

A gps device that index a jdbc ResultSet to a set of Compass Resources. Each Resource maps to a ResultSet row. The device can handle multiple ResultSets.

The device holds a list of ResultSetToResourceMappings (or derived classes like TableToResourceMapping). Each one has all the required mappings setting to map the ResultSet with all it's rows to the set of corresponding Resources.

The device can perform active data base mirroring. The mirror operation is enabled only if the mirror flag is enabled, and will execute against each mapping that ResultSetToResourceMapping.supportsVersioning().

The autoDetectVersionColumnSqlType setting (which defauls to true) will automatically set the version column jdbc type for mappings that support versioning.

Author:
kimchy
See Also:
ResultSetToResourceMapping, TableToResourceMapping

Nested Class Summary
 
Nested classes/interfaces inherited from class org.compass.gps.device.jdbc.AbstractJdbcGpsDevice
AbstractJdbcGpsDevice.IndexExecution
 
Field Summary
protected  List mappings
           
 
Fields inherited from class org.compass.gps.device.jdbc.AbstractJdbcGpsDevice
dataSource, dialect, log
 
Fields inherited from class org.compass.gps.device.AbstractGpsDevice
compassGps
 
Constructor Summary
ResultSetJdbcGpsDevice()
           
 
Method Summary
 void addMapping(ResultSetToResourceMapping mapping)
          Adds a mapping to be indexed and mirrored.
protected  AbstractJdbcGpsDevice.IndexExecution[] doGetIndexExecutions(Connection connection)
          Returns the array of index execution with a size of the number of mappings.
protected  void doIndex(CompassSession session, IndexPlan indexPlan)
          Derived devices must implement the method to perform the actual indexing operation.
protected  void doStart()
          performs operations on startup, such as auto generation of mappings for mappings that implement the AutoGenerateMapping, auto detection of version column jdbc type, and JdbcSnapshot loading (using the JdbcSnapshotPersister).
protected  void doStop()
          Saves the JdbcSnapshot.
 boolean isAutoDetectVersionColumnSqlType()
          Should the device auto detect the version columns jdbc type.
 void performMirroring()
          Performs the data change mirroring operation.
protected  Object processRowValue(Object description, ResultSet rs, CompassSession session)
          Index the given ResultSet row into a Compass Resource.
 void setAutoDetectVersionColumnSqlType(boolean autoDetectVersionColumnSqlType)
          Sets if the device auto detect the version columns jdbc type.
 void setMappings(ResultSetToResourceMapping[] mappingsArr)
          Adds an array of mappings to be indexed and mirrored.
 
Methods inherited from class org.compass.gps.device.jdbc.AbstractJdbcActiveMirrorGpsDevice
getSnapshotEventListener, getSnapshotPersister, isMirrorDataChanges, isSaveSnapshotAfterMirror, setMirrorDataChanges, setSaveSnapshotAfterMirror, setSnapshotEventListener, setSnapshotPersister
 
Methods inherited from class org.compass.gps.device.jdbc.AbstractJdbcGpsDevice
doIndex, getDataSource, getDialect, getFetchSize, processResultSet, processRow, setDataSource, setDialect, setFetchSize
 
Methods inherited from class org.compass.gps.device.AbstractGpsDevice
buildMessage, getGps, getName, index, injectGps, isFilteredForIndex, isPerformingIndexOperation, isRunning, refresh, setFilteredEntitiesForIndex, setName, shouldMirrorDataChanges, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.compass.gps.device.jdbc.JdbcGpsDevice
getDataSource, getDialect, getFetchSize, setDataSource, setDialect, setFetchSize
 

Field Detail

mappings

protected List mappings
Constructor Detail

ResultSetJdbcGpsDevice

public ResultSetJdbcGpsDevice()
Method Detail

doStart

protected void doStart()
                throws CompassGpsException
performs operations on startup, such as auto generation of mappings for mappings that implement the AutoGenerateMapping, auto detection of version column jdbc type, and JdbcSnapshot loading (using the JdbcSnapshotPersister).

Overrides:
doStart in class AbstractJdbcGpsDevice
Throws:
CompassGpsException

doStop

protected void doStop()
               throws CompassGpsException
Saves the JdbcSnapshot.

Overrides:
doStop in class AbstractGpsDevice
Throws:
CompassGpsException

doIndex

protected void doIndex(CompassSession session,
                       IndexPlan indexPlan)
                throws CompassGpsException
Description copied from class: AbstractGpsDevice
Derived devices must implement the method to perform the actual indexing operation.

Specified by:
doIndex in class AbstractGpsDevice
Throws:
CompassGpsException

doGetIndexExecutions

protected AbstractJdbcGpsDevice.IndexExecution[] doGetIndexExecutions(Connection connection)
                                                               throws SQLException,
                                                                      JdbcGpsDeviceException
Returns the array of index execution with a size of the number of mappings.

Specified by:
doGetIndexExecutions in class AbstractJdbcGpsDevice
Throws:
SQLException
JdbcGpsDeviceException

processRowValue

protected Object processRowValue(Object description,
                                 ResultSet rs,
                                 CompassSession session)
                          throws SQLException,
                                 CompassException
Index the given ResultSet row into a Compass Resource.

Overrides:
processRowValue in class AbstractJdbcGpsDevice
Throws:
SQLException
CompassException

performMirroring

public void performMirroring()
                      throws JdbcGpsDeviceException
Performs the data change mirroring operation.

Throws:
JdbcGpsDeviceException

addMapping

public void addMapping(ResultSetToResourceMapping mapping)
Adds a mapping to be indexed and mirrored.


setMappings

public void setMappings(ResultSetToResourceMapping[] mappingsArr)
Adds an array of mappings to be indexed and mirrored.


isAutoDetectVersionColumnSqlType

public boolean isAutoDetectVersionColumnSqlType()
Should the device auto detect the version columns jdbc type.


setAutoDetectVersionColumnSqlType

public void setAutoDetectVersionColumnSqlType(boolean autoDetectVersionColumnSqlType)
Sets if the device auto detect the version columns jdbc type.



Copyright (c) 2004-2008 The Compass Project.