use of org.openstreetmap.osmosis.core.database.DbFeatureHistory in project osmosis by openstreetmap.
the class RelationDao method getRelationMemberHistory.
private ReleasableIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>> getRelationMemberHistory(String selectedEntityStatement, SqlParameterSource parameterSource) {
FileBasedSort<DbFeatureHistory<DbOrderedFeature<RelationMember>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbOrderedFeatureHistoryComparator<RelationMember>(), true);
try {
String sql;
SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<RelationMember>>> storeListener;
DbFeatureHistoryRowMapper<DbOrderedFeature<RelationMember>> dbFeatureHistoryRowMapper;
DbFeatureRowMapper<RelationMember> dbFeatureRowMapper;
DbOrderedFeatureRowMapper<RelationMember> dbOrderedFeatureRowMapper;
RelationMemberRowMapper relationNodeRowMapper;
ReleasableIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>> resultIterator;
sql = "SELECT rm.relation_id AS id, rm.member_id, rm.member_role, rm.member_type, rm.version, rm.sequence_id" + " FROM " + "relation_members rm" + " INNER JOIN " + selectedEntityStatement + " t ON rm.relation_id = t.relation_id AND rm.version = t.version";
LOG.log(Level.FINER, "Relation member history query: " + sql);
// Sends all received data into the object store.
storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(sortingStore);
// Retrieves the version information associated with the feature.
dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbOrderedFeature<RelationMember>>(storeListener);
// Retrieves the sequence number associated with the feature.
dbOrderedFeatureRowMapper = new DbOrderedFeatureRowMapper<RelationMember>(dbFeatureHistoryRowMapper);
// Retrieves the entity information associated with the feature.
dbFeatureRowMapper = new DbFeatureRowMapper<RelationMember>(dbOrderedFeatureRowMapper);
// Retrieves the basic feature information.
relationNodeRowMapper = new RelationMemberRowMapper(dbFeatureRowMapper);
// Perform the query passing the row mapper chain to process rows in a streamy fashion.
getNamedParamJdbcTemplate().query(sql, parameterSource, relationNodeRowMapper);
// Open a iterator on the store that will release the store upon completion.
resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbOrderedFeature<RelationMember>>>(sortingStore.iterate(), sortingStore);
// The store itself shouldn't be released now that it has been attached to the iterator.
sortingStore = null;
return resultIterator;
} finally {
if (sortingStore != null) {
sortingStore.close();
}
}
}
use of org.openstreetmap.osmosis.core.database.DbFeatureHistory in project osmosis by openstreetmap.
the class WayDao method getWayNodeHistory.
private ReleasableIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>> getWayNodeHistory(String selectedEntityStatement, SqlParameterSource parameterSource) {
FileBasedSort<DbFeatureHistory<DbOrderedFeature<WayNode>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbOrderedFeature<WayNode>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbOrderedFeatureHistoryComparator<WayNode>(), true);
try {
String sql;
SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<WayNode>>> storeListener;
DbFeatureHistoryRowMapper<DbOrderedFeature<WayNode>> dbFeatureHistoryRowMapper;
DbFeatureRowMapper<WayNode> dbFeatureRowMapper;
DbOrderedFeatureRowMapper<WayNode> dbOrderedFeatureRowMapper;
WayNodeRowMapper wayNodeRowMapper;
ReleasableIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>> resultIterator;
sql = "SELECT wn.way_id AS id, wn.node_id, wn.version, wn.sequence_id" + " FROM " + "way_nodes wn" + " INNER JOIN " + selectedEntityStatement + " t ON wn.way_id = t.way_id AND wn.version = t.version";
LOG.log(Level.FINER, "Way node history query: " + sql);
// Sends all received data into the object store.
storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbOrderedFeature<WayNode>>>(sortingStore);
// Retrieves the version information associated with the feature.
dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbOrderedFeature<WayNode>>(storeListener);
// Retrieves the sequence number associated with the feature.
dbOrderedFeatureRowMapper = new DbOrderedFeatureRowMapper<WayNode>(dbFeatureHistoryRowMapper);
// Retrieves the entity information associated with the feature.
dbFeatureRowMapper = new DbFeatureRowMapper<WayNode>(dbOrderedFeatureRowMapper);
// Retrieves the basic feature information.
wayNodeRowMapper = new WayNodeRowMapper(dbFeatureRowMapper);
// Perform the query passing the row mapper chain to process rows in a streamy fashion.
getNamedParamJdbcTemplate().query(sql, parameterSource, wayNodeRowMapper);
// Open a iterator on the store that will release the store upon completion.
resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbOrderedFeature<WayNode>>>(sortingStore.iterate(), sortingStore);
// The store itself shouldn't be released now that it has been attached to the iterator.
sortingStore = null;
return resultIterator;
} finally {
if (sortingStore != null) {
sortingStore.close();
}
}
}
use of org.openstreetmap.osmosis.core.database.DbFeatureHistory 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();
}
}
use of org.openstreetmap.osmosis.core.database.DbFeatureHistory in project osmosis by openstreetmap.
the class EntityDao method getTagHistory.
private ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> getTagHistory(String selectedEntityStatement, MapSqlParameterSource parameterSource) {
FileBasedSort<DbFeatureHistory<DbFeature<Tag>>> sortingStore = new FileBasedSort<DbFeatureHistory<DbFeature<Tag>>>(new SingleClassObjectSerializationFactory(DbFeatureHistory.class), new DbFeatureHistoryComparator<Tag>(), true);
try {
String sql;
SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>> storeListener;
DbFeatureHistoryRowMapper<DbFeature<Tag>> dbFeatureHistoryRowMapper;
DbFeatureRowMapper<Tag> dbFeatureRowMapper;
TagRowMapper tagRowMapper;
ReleasableIterator<DbFeatureHistory<DbFeature<Tag>>> resultIterator;
sql = "SELECT et." + entityName + "_id AS id, et.k, et.v, et.version" + " FROM " + entityName + "_tags et" + " INNER JOIN " + selectedEntityStatement + " t ON et." + entityName + "_id = t." + entityName + "_id AND et.version = t.version";
LOG.log(Level.FINER, "Tag history query: " + sql);
// Sends all received data into the object store.
storeListener = new SortingStoreRowMapperListener<DbFeatureHistory<DbFeature<Tag>>>(sortingStore);
// Retrieves the version information associated with the tag.
dbFeatureHistoryRowMapper = new DbFeatureHistoryRowMapper<DbFeature<Tag>>(storeListener);
// Retrieves the entity information associated with the tag.
dbFeatureRowMapper = new DbFeatureRowMapper<Tag>(dbFeatureHistoryRowMapper);
// Retrieves the basic tag information.
tagRowMapper = new TagRowMapper(dbFeatureRowMapper);
// Perform the query passing the row mapper chain to process rows in a streamy fashion.
namedParamJdbcTemplate.query(sql, parameterSource, tagRowMapper);
// Open a iterator on the store that will release the store upon completion.
resultIterator = new StoreReleasingIterator<DbFeatureHistory<DbFeature<Tag>>>(sortingStore.iterate(), sortingStore);
// The store itself shouldn't be released now that it has been attached to the iterator.
sortingStore = null;
return resultIterator;
} finally {
if (sortingStore != null) {
sortingStore.close();
}
}
}
Aggregations