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

java.lang.Object
  extended by org.compass.gps.device.jdbc.mapping.AbstractColumnMapping
      extended by org.compass.gps.device.jdbc.mapping.AbstractColumnToPropertyMapping
          extended by org.compass.gps.device.jdbc.mapping.AbstractConstantColumnToPropertyMapping
              extended by org.compass.gps.device.jdbc.mapping.IdColumnToPropertyMapping
All Implemented Interfaces:
ColumnMapping, ColumnToPropertyMapping

public class IdColumnToPropertyMapping
extends AbstractConstantColumnToPropertyMapping

Maps an id column to Resource Property. The id column is the column that identifies or is part of columns that identifies the ResultSet. In a table, it is the table primary keys.

The PropertyIndex is Property.Index.UN_TOKENIZED. the PropertyStore is Property.Store.YES, the PropertyTermVector is Property.TermVector.NO and the Boost is 1.0f.

The id mapping also holds an additional mapping, the columnNameForVersion mapping. When performing the mirror operation (if enabled), it is the id column name that is added to the select query in order to filter by the specified ids. For example, if the select query is (for a PARENT and CHILD table relationship): select p.id as parent_id, p.first_name as parent_first_name, p.last_name as parent_last_name, p.version as parent_version, COALESCE(c.id, 0) as child_id, c.first_name as child_first_name, c.last_name child_last_name, COALESCE(c.version, 0) as child_version from parent p left join child c on p.id = c.parent_id than when performing the query to get the values for certain values of ids (the parent and child ids), the column names that will be used are: p.id and COALESCE(c.id, 0). And the actual where clause will be: where p.id = ? and COALESCE(c.id, 0) = ?.

Note, that the id column name is parent_id, and child_id. They are used for reading the id values, not constructing queries.

Author:
kimchy

Constructor Summary
IdColumnToPropertyMapping()
          Creates an empty id column to property mapping.
IdColumnToPropertyMapping(int columnIndex, String propertyName)
          Creates a new Id Column to property mapping given the column index and the property name.
IdColumnToPropertyMapping(int columnIndex, String propertyName, String columnNameForVersion)
          Creates a new Id Column to property mapping given the column index, the property name, and the column name for the versioning (the mirror operation).
IdColumnToPropertyMapping(String columnName, String propertyName)
          Creates a new Id column to propery mapping given the column name and the property name.
IdColumnToPropertyMapping(String columnName, String propertyName, String columnNameForVersion)
          Creates a new Id column to property mapping given the column name, the property name, and the column name for the versioning (the mirror operation).
 
Method Summary
 String getColumnNameForVersion()
          Returns the id column name that will be used in the dynamically created where clause with the original select query.
 void setColumnNameForVersion(String columnNameForVersion)
          Sets the id column name that will be used in the dynamically created where clause with the original select query.
 
Methods inherited from class org.compass.gps.device.jdbc.mapping.AbstractConstantColumnToPropertyMapping
getBoost, getPropertyIndex, getPropertyStore, getPropertyTermVector
 
Methods inherited from class org.compass.gps.device.jdbc.mapping.AbstractColumnToPropertyMapping
getAnalyzer, getConverter, getExcludeFromAll, getPropertyName, setAnalyzer, setConverter, setExcludeFromAll, setPropertyName, toString
 
Methods inherited from class org.compass.gps.device.jdbc.mapping.AbstractColumnMapping
getColumnIndex, getColumnName, isUsingColumnIndex, setColumnIndex, setColumnName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.compass.gps.device.jdbc.mapping.ColumnMapping
getColumnIndex, getColumnName, isUsingColumnIndex
 

Constructor Detail

IdColumnToPropertyMapping

public IdColumnToPropertyMapping()
Creates an empty id column to property mapping. Must set at least the colum index or colum name, and the property name. If using mirroring, must set the column name for version as well.


IdColumnToPropertyMapping

public IdColumnToPropertyMapping(String columnName,
                                 String propertyName)
Creates a new Id column to propery mapping given the column name and the property name. The column name will also be used as the columnNameForVersion value.

Parameters:
columnName - The id column name that will be used to look up the id value (also acts as the columnNameForVersion).
propertyName - The Compass Resource Property name.

IdColumnToPropertyMapping

public IdColumnToPropertyMapping(String columnName,
                                 String propertyName,
                                 String columnNameForVersion)
Creates a new Id column to property mapping given the column name, the property name, and the column name for the versioning (the mirror operation).

Parameters:
columnName - The id column name that will be used to look up the id value.
propertyName - The Compass Resource Property name.
columnNameForVersion - The id column name that will be used in the dynamically created where clause with the original select query.

IdColumnToPropertyMapping

public IdColumnToPropertyMapping(int columnIndex,
                                 String propertyName)
Creates a new Id Column to property mapping given the column index and the property name. Note that the column name for versioning will be null, so if mirroring will be enabled, it must be set.

Parameters:
columnIndex - The id column index that will be used to look up the id value.
propertyName - The Compass Resource Property name.

IdColumnToPropertyMapping

public IdColumnToPropertyMapping(int columnIndex,
                                 String propertyName,
                                 String columnNameForVersion)
Creates a new Id Column to property mapping given the column index, the property name, and the column name for the versioning (the mirror operation).

Parameters:
columnIndex - The id column index that will be used to look up the id value.
propertyName - The Compass Resource Property name.
columnNameForVersion - The id column name that will be used in the dynamically created where clause with the original select query.
Method Detail

getColumnNameForVersion

public String getColumnNameForVersion()
Returns the id column name that will be used in the dynamically created where clause with the original select query.


setColumnNameForVersion

public void setColumnNameForVersion(String columnNameForVersion)
Sets the id column name that will be used in the dynamically created where clause with the original select query.

Parameters:
columnNameForVersion - The id column name that will be used in the dynamically created where clause with the original select query.


Copyright (c) 2004-2008 The Compass Project.