org.openstreetmap.osmosis.core.apidb.v0_6.impl
Class EntityDao<T extends Entity>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.apidb.v0_6.impl.EntityDao<T>
Type Parameters:
T - The entity type to be supported.
Direct Known Subclasses:
NodeDao, RelationDao, WayDao

public abstract class EntityDao<T extends Entity>
extends java.lang.Object

Provides functionality common to all top level entity daos.


Constructor Summary
protected EntityDao(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, java.lang.String entityName)
          Creates a new instance.
 
Method Summary
protected abstract  EntityContainerFactory<T> getContainerFactory()
          Gets the entity container factory for the entity type.
 ReleasableIterator<EntityContainer> getCurrent()
          Retrieves all current data in the database.
protected abstract  RowMapperListener<CommonEntityData> getEntityRowMapper(RowMapperListener<T> entityListener)
          Creates a row mapper that receives common entity data objects and produces full entity objects.
protected abstract  java.util.List<FeatureHistoryPopulator<T,?,?>> getFeatureHistoryPopulators(java.lang.String selectedEntityStatement, org.springframework.jdbc.core.namedparam.MapSqlParameterSource parameterSource)
          Gets the history feature populators for the entity type.
 ReleasableIterator<ChangeContainer> getHistory()
          Retrieves all changes in the database.
 ReleasableIterator<ChangeContainer> getHistory(java.util.Date intervalBegin, java.util.Date intervalEnd)
          Retrieves the changes that have were made between two points in time.
 ReleasableIterator<ChangeContainer> getHistory(ReplicationQueryPredicates predicates)
          Retrieves the changes that have were made by a set of transactions.
protected  org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate getNamedParamJdbcTemplate()
          Provides access to the named parameter jdbc template.
protected abstract  java.lang.String[] getTypeSpecificFieldNames()
          Produces an array of additional column names specific to this entity type to be returned by entity queries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EntityDao

protected EntityDao(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                    java.lang.String entityName)
Creates a new instance.

Parameters:
jdbcTemplate - Used to access the database.
entityName - The name of the entity. Used for building dynamic sql queries.
Method Detail

getNamedParamJdbcTemplate

protected org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate getNamedParamJdbcTemplate()
Provides access to the named parameter jdbc template.

Returns:
The jdbc template.

getTypeSpecificFieldNames

protected abstract java.lang.String[] getTypeSpecificFieldNames()
Produces an array of additional column names specific to this entity type to be returned by entity queries.

Returns:
The column names.

getEntityRowMapper

protected abstract RowMapperListener<CommonEntityData> getEntityRowMapper(RowMapperListener<T> entityListener)
Creates a row mapper that receives common entity data objects and produces full entity objects.

Parameters:
entityListener - The full entity object listener.
Returns:
The full entity row mapper.

getContainerFactory

protected abstract EntityContainerFactory<T> getContainerFactory()
Gets the entity container factory for the entity type.

Returns:
The factory.

getFeatureHistoryPopulators

protected abstract java.util.List<FeatureHistoryPopulator<T,?,?>> getFeatureHistoryPopulators(java.lang.String selectedEntityStatement,
                                                                                              org.springframework.jdbc.core.namedparam.MapSqlParameterSource parameterSource)
Gets the history feature populators for the entity type.

Parameters:
selectedEntityStatement - The statement for obtaining the id and version pairs of entity records selected.
parameterSource - The parameters required to execute the selected entity statement.
Returns:
The history feature populators.

getHistory

public ReleasableIterator<ChangeContainer> getHistory(ReplicationQueryPredicates predicates)
Retrieves the changes that have were made by a set of transactions.

Parameters:
predicates - Contains the predicates defining the transactions to be queried.
Returns:
An iterator pointing at the identified records.

getHistory

public ReleasableIterator<ChangeContainer> getHistory(java.util.Date intervalBegin,
                                                      java.util.Date intervalEnd)
Retrieves the changes that have were made between two points in time.

Parameters:
intervalBegin - Marks the beginning (inclusive) of the time interval to be checked.
intervalEnd - Marks the end (exclusive) of the time interval to be checked.
Returns:
An iterator pointing at the identified records.

getHistory

public ReleasableIterator<ChangeContainer> getHistory()
Retrieves all changes in the database.

Returns:
An iterator pointing at the identified records.

getCurrent

public ReleasableIterator<EntityContainer> getCurrent()
Retrieves all current data in the database.

Returns:
An iterator pointing at the current records.