Search in sources :

Example 1 with AllEntityDao

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

the class ApidbFileReplicator 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) {
    Replicator replicator;
    ReplicationSource source;
    TransactionManager txnSnapshotLoader;
    SystemTimeLoader systemTimeLoader;
    new SchemaVersionValidator(loginCredentials, preferences).validateVersion(ApidbVersionConstants.SCHEMA_MIGRATIONS);
    source = new AllEntityDao(dbCtx.getJdbcTemplate());
    txnSnapshotLoader = new TransactionDao(dbCtx);
    systemTimeLoader = new TimeDao(dbCtx.getJdbcTemplate());
    replicator = new Replicator(source, changeSink, txnSnapshotLoader, systemTimeLoader, iterations, minInterval, maxInterval);
    replicator.replicate();
}
Also used : AllEntityDao(org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao) TimeDao(org.openstreetmap.osmosis.apidb.v0_6.impl.TimeDao) TransactionManager(org.openstreetmap.osmosis.apidb.v0_6.impl.TransactionManager) TransactionDao(org.openstreetmap.osmosis.apidb.v0_6.impl.TransactionDao) Replicator(org.openstreetmap.osmosis.apidb.v0_6.impl.Replicator) ReplicationSource(org.openstreetmap.osmosis.apidb.v0_6.impl.ReplicationSource) SchemaVersionValidator(org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator) SystemTimeLoader(org.openstreetmap.osmosis.apidb.v0_6.impl.SystemTimeLoader)

Example 2 with AllEntityDao

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

the class ApidbChangeReader 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;
        changeSink.initialize(Collections.<String, Object>emptyMap());
        new SchemaVersionValidator(loginCredentials, preferences).validateVersion(ApidbVersionConstants.SCHEMA_MIGRATIONS);
        entityDao = new AllEntityDao(dbCtx.getJdbcTemplate());
        try (ReleasableIterator<ChangeContainer> reader = entityDao.getHistory(intervalBegin, intervalEnd)) {
            ReleasableIterator<ChangeContainer> i;
            if (fullHistory) {
                i = reader;
            } else {
                i = new DeltaToDiffReader(reader);
            }
            while (i.hasNext()) {
                changeSink.process(i.next());
            }
        }
        changeSink.complete();
    } finally {
        changeSink.close();
    }
}
Also used : AllEntityDao(org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) SchemaVersionValidator(org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator) DeltaToDiffReader(org.openstreetmap.osmosis.apidb.v0_6.impl.DeltaToDiffReader)

Example 3 with AllEntityDao

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

the class ApidbCurrentReader 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 = entityDao.getCurrent()) {
            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) SchemaVersionValidator(org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator)

Example 4 with AllEntityDao

use of org.openstreetmap.osmosis.apidb.v0_6.impl.AllEntityDao 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)4 SchemaVersionValidator (org.openstreetmap.osmosis.apidb.v0_6.impl.SchemaVersionValidator)4 BoundContainer (org.openstreetmap.osmosis.core.container.v0_6.BoundContainer)2 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)2 Bound (org.openstreetmap.osmosis.core.domain.v0_6.Bound)2 DeltaToDiffReader (org.openstreetmap.osmosis.apidb.v0_6.impl.DeltaToDiffReader)1 EntitySnapshotReader (org.openstreetmap.osmosis.apidb.v0_6.impl.EntitySnapshotReader)1 ReplicationSource (org.openstreetmap.osmosis.apidb.v0_6.impl.ReplicationSource)1 Replicator (org.openstreetmap.osmosis.apidb.v0_6.impl.Replicator)1 SystemTimeLoader (org.openstreetmap.osmosis.apidb.v0_6.impl.SystemTimeLoader)1 TimeDao (org.openstreetmap.osmosis.apidb.v0_6.impl.TimeDao)1 TransactionDao (org.openstreetmap.osmosis.apidb.v0_6.impl.TransactionDao)1 TransactionManager (org.openstreetmap.osmosis.apidb.v0_6.impl.TransactionManager)1 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)1