org.compass.gps.device.jdbc.mapping
Class ResultSetToResourceMapping

java.lang.Object
  extended by org.compass.gps.device.jdbc.mapping.ResultSetToResourceMapping
Direct Known Subclasses:
TableToResourceMapping

public class ResultSetToResourceMapping
extends Object

Maps a Jdbc ResultSet to a Compass Resource.

The required mappings are the alias of the Resource, the select query that generates the ResultSet, and at least one id mapping that maps the ResultSet identifiers columns (IdColumnToPropertyMapping).

Mapping data columns (DataColumnToPropertyMapping) is optional, but provides the meta data (Resource Proeprty) for searching. You can also enable (which is disabled by default) for indexing all the un mapped columns of the ResultSet using the setIndexUnMappedColumns(boolean).

For real time mirroring, the version query and at least one version column mapping (VersionColumnMapping) is required.

Author:
kimchy

Constructor Summary
ResultSetToResourceMapping()
          Creates a new ResultSet to Resource mapping.
ResultSetToResourceMapping(String alias, String selectQuery)
          Creates a new ResultSet to Resource mapping using the supplied alias and select query.
ResultSetToResourceMapping(String alias, String selectQuery, ColumnToPropertyMapping idMapping)
          Creates a new ResultSet to Resource mapping using the supplied alias and select query and one id column mapping.
 
Method Summary
 void addDataMapping(ColumnToPropertyMapping dataMapping)
          Adds data column mapping.
 void addIdMapping(ColumnToPropertyMapping idMapping)
          Adds id column mapping.
 void addVersionMapping(VersionColumnMapping versionColumnMapping)
          Adds version column mapping for real time mirror data changes.
 Iterator dataMappingsIt()
          Returns an iterator over the data mappings.
 int dataMappingsSize()
          Returns the size of the data mappings.
 String getAlias()
          Returns the alias of the mapped Resource.
 List getMappingsForColumn(int columnIndex)
          Returns a list of all the ColumnMappings that are mapped to the column index.
 List getMappingsForColumn(String columnName)
          Returns a list of all the ColumnMappings that are mapped to the column name.
 String getSelectQuery()
          Returns the select query that generates the ResultSet.
 String getVersionQuery()
          Returns the version query that is used for real time mirror data changes.
 Iterator idMappingsIt()
          Returns an iterator over the id mappings.
 int idMappingsSize()
          Returns the size of the id mappings.
 boolean isIndexUnMappedColumns()
          Should the mapping index unmapped columns as data columns.
 Iterator mappingsIt()
           
 void setAlias(String alias)
          Sets the alias of the mapped Resource.
 void setDataMappings(ColumnToPropertyMapping[] dataMappingsArr)
          Adds of array of ColumnToPropertyMappings which acts as the data column mappings.
 void setIdMappings(ColumnToPropertyMapping[] idMappingsArr)
          Adds the array of ColumnToPropertyMappings which acts as the id column mappings.
 void setIndexUnMappedColumns(boolean indexUnMappedColumns)
          Returns if the mapping should set to index unmapped columns as data columns.
 void setSelectQuery(String selectQuery)
          Sets the select query that generates the ResultSet.
 void setVersionMappings(VersionColumnMapping[] versionColumnMappingsArr)
          Adds an array of ColumnToPropertyMappings which acts as the version column mappings.
 void setVersionQuery(String snapshotQuery)
          Sets the version query that is used for real time mirror data changes.
 boolean supportsVersioning()
          Is the mapping support versioning.
 String toString()
           
 Iterator versionMappingsIt()
          Returns an iterator of the version mappings.
 int versionMappingsSize()
          Returns the size of the version mappings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResultSetToResourceMapping

public ResultSetToResourceMapping()
Creates a new ResultSet to Resource mapping. Must set at least the alias, the select query, and at lease one id mapping.

Indexing of unmapped columns is diasabled by default.


ResultSetToResourceMapping

public ResultSetToResourceMapping(String alias,
                                  String selectQuery)
Creates a new ResultSet to Resource mapping using the supplied alias and select query. At least one id mapping is required to be configured as well.

Indexing of unmapped columns is diasabled by default.

Parameters:
alias - The alias of the mapped Resource.
selectQuery - The select query that generates teh ResultSet.

ResultSetToResourceMapping

public ResultSetToResourceMapping(String alias,
                                  String selectQuery,
                                  ColumnToPropertyMapping idMapping)
Creates a new ResultSet to Resource mapping using the supplied alias and select query and one id column mapping.

If additional id column mappings are required, use addIdMapping(ColumnToPropertyMapping) to add them.

Indexing of unmapped columns is diasabled by default.

Parameters:
alias - The alias of the mapped Resource.
selectQuery - The select query that generates teh ResultSet.
idMapping - Id mapping used to map an id column.
Method Detail

getAlias

public String getAlias()
Returns the alias of the mapped Resource.


setAlias

public void setAlias(String alias)
Sets the alias of the mapped Resource.


getSelectQuery

public String getSelectQuery()
Returns the select query that generates the ResultSet.


setSelectQuery

public void setSelectQuery(String selectQuery)
Sets the select query that generates the ResultSet.


getVersionQuery

public String getVersionQuery()
Returns the version query that is used for real time mirror data changes.


setVersionQuery

public void setVersionQuery(String snapshotQuery)
Sets the version query that is used for real time mirror data changes.


addIdMapping

public void addIdMapping(ColumnToPropertyMapping idMapping)
Adds id column mapping.


addDataMapping

public void addDataMapping(ColumnToPropertyMapping dataMapping)
Adds data column mapping.


addVersionMapping

public void addVersionMapping(VersionColumnMapping versionColumnMapping)
Adds version column mapping for real time mirror data changes.


getMappingsForColumn

public List getMappingsForColumn(String columnName)
Returns a list of all the ColumnMappings that are mapped to the column name.

Parameters:
columnName - The column name for the mapped columns.
Returns:
A list of all the ColumnMappings.

getMappingsForColumn

public List getMappingsForColumn(int columnIndex)
Returns a list of all the ColumnMappings that are mapped to the column index.

Parameters:
columnIndex - The column index for the mapped columns.
Returns:
A list of all the ColumnMappings.

setIdMappings

public void setIdMappings(ColumnToPropertyMapping[] idMappingsArr)
Adds the array of ColumnToPropertyMappings which acts as the id column mappings.

Parameters:
idMappingsArr - An array of ColumnToPropertyMappings to add.

setDataMappings

public void setDataMappings(ColumnToPropertyMapping[] dataMappingsArr)
Adds of array of ColumnToPropertyMappings which acts as the data column mappings.

Parameters:
dataMappingsArr - An array of ColumnToPropertyMappings to add.

setVersionMappings

public void setVersionMappings(VersionColumnMapping[] versionColumnMappingsArr)
Adds an array of ColumnToPropertyMappings which acts as the version column mappings.

Parameters:
versionColumnMappingsArr - An array of ColumnToPropertyMappings to add.

idMappingsIt

public Iterator idMappingsIt()
Returns an iterator over the id mappings.


idMappingsSize

public int idMappingsSize()
Returns the size of the id mappings.


dataMappingsIt

public Iterator dataMappingsIt()
Returns an iterator over the data mappings.


dataMappingsSize

public int dataMappingsSize()
Returns the size of the data mappings.


versionMappingsIt

public Iterator versionMappingsIt()
Returns an iterator of the version mappings.


versionMappingsSize

public int versionMappingsSize()
Returns the size of the version mappings.


mappingsIt

public Iterator mappingsIt()

isIndexUnMappedColumns

public boolean isIndexUnMappedColumns()
Should the mapping index unmapped columns as data columns.


setIndexUnMappedColumns

public void setIndexUnMappedColumns(boolean indexUnMappedColumns)
Returns if the mapping should set to index unmapped columns as data columns.


supportsVersioning

public boolean supportsVersioning()
Is the mapping support versioning. It is a derived property, returning false if no version column mapping are set.


toString

public String toString()
Overrides:
toString in class Object


Copyright (c) 2004-2009 The Compass Project.