Search in sources :

Example 1 with EntitySnapshotReader

use of org.openstreetmap.osmosis.apidb.v0_6.impl.EntitySnapshotReader in project osmosis by openstreetmap.

the class ApidbReader method runImpl.

/**
 * Runs the task implementation. This is called by the run method within a transaction.
 *
 * @param dbCtx
 *            Used to access the database.
 */
protected void runImpl(DatabaseContext2 dbCtx) {
    try {
        AllEntityDao entityDao;
        sink.initialize(Collections.<String, Object>emptyMap());
        new SchemaVersionValidator(loginCredentials, preferences).validateVersion(ApidbVersionConstants.SCHEMA_MIGRATIONS);
        entityDao = new AllEntityDao(dbCtx.getJdbcTemplate());
        sink.process(new BoundContainer(new Bound("Osmosis " + OsmosisConstants.VERSION)));
        try (ReleasableIterator<EntityContainer> reader = new EntitySnapshotReader(entityDao.getHistory(), snapshotInstant)) {
            while (reader.hasNext()) {
                sink.process(reader.next());
            }
        }
        sink.complete();
    } finally {
        sink.close();
    }
}
Also used : AllEntityDao(org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao) BoundContainer(org.openstreetmap.osmosis.core.container.v0_6.BoundContainer) Bound(org.openstreetmap.osmosis.core.domain.v0_6.Bound) EntityContainer(org.openstreetmap.osmosis.core.container.v0_6.EntityContainer) EntitySnapshotReader(org.openstreetmap.osmosis.apidb.v0_6.impl.EntitySnapshotReader) SchemaVersionValidator(org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator)

Aggregations

AllEntityDao (org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao)1 EntitySnapshotReader (org.openstreetmap.osmosis.apidb.v0_6.impl.EntitySnapshotReader)1 SchemaVersionValidator (org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator)1 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)1 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)1 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)1