Search in sources :

Example 1 with DbOrderedFeature

use of org.openstreetmap.osmosis.core.database.DbOrderedFeature 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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 2 with DbOrderedFeature

use of org.openstreetmap.osmosis.core.database.DbOrderedFeature 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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) DbFeatureHistory(org.openstreetmap.osmosis.core.database.DbFeatureHistory) WayNode(org.openstreetmap.osmosis.core.domain.v0_6.WayNode) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Example 3 with DbOrderedFeature

use of org.openstreetmap.osmosis.core.database.DbOrderedFeature in project osmosis by openstreetmap.

the class RelationDao method getRelationMembers.

private ReleasableIterator<DbOrderedFeature<RelationMember>> getRelationMembers(String tablePrefix) {
    FileBasedSort<DbOrderedFeature<RelationMember>> sortingStore = new FileBasedSort<DbOrderedFeature<RelationMember>>(new SingleClassObjectSerializationFactory(DbOrderedFeature.class), new DbOrderedFeatureComparator<RelationMember>(), true);
    try {
        String sql;
        SortingStoreRowMapperListener<DbOrderedFeature<RelationMember>> storeListener;
        RowMapperRowCallbackListener<DbOrderedFeature<RelationMember>> rowCallbackListener;
        ReleasableIterator<DbOrderedFeature<RelationMember>> resultIterator;
        sql = relationMemberMapper.getSqlSelect(tablePrefix, false, false);
        // Sends all received data into the object store.
        storeListener = new SortingStoreRowMapperListener<DbOrderedFeature<RelationMember>>(sortingStore);
        // Converts result set rows into objects and passes them into the store.
        rowCallbackListener = new RowMapperRowCallbackListener<DbOrderedFeature<RelationMember>>(relationMemberMapper.getRowMapper(), storeListener);
        // Perform the query passing the row mapper chain to process rows in a streamy fashion.
        jdbcTemplate.query(sql, rowCallbackListener);
        // Open a iterator on the store that will release the store upon completion.
        resultIterator = new StoreReleasingIterator<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();
        }
    }
}
Also used : SingleClassObjectSerializationFactory(org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory) RelationMember(org.openstreetmap.osmosis.core.domain.v0_6.RelationMember) DbOrderedFeature(org.openstreetmap.osmosis.core.database.DbOrderedFeature) FileBasedSort(org.openstreetmap.osmosis.core.sort.common.FileBasedSort)

Aggregations

DbOrderedFeature (org.openstreetmap.osmosis.core.database.DbOrderedFeature)3 FileBasedSort (org.openstreetmap.osmosis.core.sort.common.FileBasedSort)3 SingleClassObjectSerializationFactory (org.openstreetmap.osmosis.core.store.SingleClassObjectSerializationFactory)3 DbFeatureHistory (org.openstreetmap.osmosis.core.database.DbFeatureHistory)2 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)2 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)1