Search in sources :

Example 6 with ReleasableContainer

use of org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer in project osmosis by openstreetmap.

the class EntityDao method getEntityHistory.

private ReleasableIterator<EntityHistory<T>> getEntityHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
    ReleasableContainer releasableContainer;
    releasableContainer = new ReleasableContainer();
    try {
        ReleasableIterator<EntityHistory<T>> entityIterator;
        ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> tagIterator;
        List<FeatureHistoryPopulator<T, ?, ?>> featurePopulators;
        EntityHistoryReader<T> entityHistoryReader;
        entityIterator = releasableContainer.add(getFeaturelessEntityHistory(selectedEntityStatement, parameterSource));
        tagIterator = releasableContainer.add(getTagHistory(selectedEntityStatement, parameterSource));
        featurePopulators = getFeatureHistoryPopulators(selectedEntityStatement, parameterSource);
        for (FeatureHistoryPopulator<T, ?, ?> featurePopulator : featurePopulators) {
            releasableContainer.add(featurePopulator);
        }
        entityHistoryReader = new EntityHistoryReader<T>(entityIterator, tagIterator, featurePopulators);
        // The sources are now all attached to the history reader so we don't want to release
        // them in the finally block.
        releasableContainer.clear();
        return entityHistoryReader;
    } finally {
        releasableContainer.close();
    }
}
Also used : ReleasableContainer(org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) Tag(org.openstreetmap.osmosis.core.domain.v0_6.Tag)

Aggregations

ReleasableContainer (org.openstreetmap.osmosis.core.lifecycle.ReleasableContainer)6 ReleasableIterator (org.openstreetmap.osmosis.core.lifecycle.ReleasableIterator)4 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)3 EntityContainer (org.openstreetmap.osmosis.core.container.v0_6.EntityContainer)1 DbFeatureHistory (org.openstreetmap.osmosis.core.database.DbFeatureHistory)1 FeaturePopulator (org.openstreetmap.osmosis.core.database.FeaturePopulator)1 Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)1