org.openstreetmap.osmosis.core.pgsql.v0_6.impl
Class PostgresSqlEntityManager<T extends Entity>

java.lang.Object
  extended by org.openstreetmap.osmosis.core.pgsql.v0_6.impl.PostgresSqlEntityManager<T>
Type Parameters:
T - The entity type to be supported.
All Implemented Interfaces:
EntityManager<T>

public class PostgresSqlEntityManager<T extends Entity>
extends java.lang.Object
implements EntityManager<T>

Provides postgres entity manager support allowing entities to be manipulated via a common dataset interface.

Author:
Brett Henderson

Constructor Summary
PostgresSqlEntityManager(EntityDao<T> entityDao, UserDao userDao)
          Creates a new instance.
 
Method Summary
 void addEntity(T entity)
          Adds the specified entity to the database.
 boolean exists(long id)
          Indicates if the specified entity exists in the database.
 T getEntity(long id)
          Retrieves an entity by its identifier.
 ReleasableIterator<T> iterate()
          Returns an iterator providing access to all entities in the database.
 void modifyEntity(T entity)
          Updates the specified entity details in the database.
 void removeEntity(long entityId)
          Removes the specified entity from the database.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PostgresSqlEntityManager

public PostgresSqlEntityManager(EntityDao<T> entityDao,
                                UserDao userDao)
Creates a new instance.

Parameters:
entityDao - The dao allowing manipulation of a specific entity type.
userDao - The user dao allowing user entries to be updated or created.
Method Detail

addEntity

public void addEntity(T entity)
Adds the specified entity to the database.

Specified by:
addEntity in interface EntityManager<T extends Entity>
Parameters:
entity - The entity to add.

exists

public boolean exists(long id)
Indicates if the specified entity exists in the database.

Specified by:
exists in interface EntityManager<T extends Entity>
Parameters:
id - The id of the entity.
Returns:
True if the entity exists, false otherwise.

getEntity

public T getEntity(long id)
Retrieves an entity by its identifier.

Specified by:
getEntity in interface EntityManager<T extends Entity>
Parameters:
id - The id of the entity.
Returns:
The entity.

iterate

public ReleasableIterator<T> iterate()
Returns an iterator providing access to all entities in the database.

Specified by:
iterate in interface EntityManager<T extends Entity>
Returns:
The entity iterator.

modifyEntity

public void modifyEntity(T entity)
Updates the specified entity details in the database.

Specified by:
modifyEntity in interface EntityManager<T extends Entity>
Parameters:
entity - The entity to update.

removeEntity

public void removeEntity(long entityId)
Removes the specified entity from the database.

Specified by:
removeEntity in interface EntityManager<T extends Entity>
Parameters:
entityId - The id of the entity to remove.