This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit b9591b30b96a804674125dfd5e5b7efaadcd20ab Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Thu Sep 9 16:34:54 2021 +0200 Specialize the resource type of SQL store to `FeatureSet`. --- .../java/org/apache/sis/internal/sql/feature/Database.java | 3 +-- .../src/main/java/org/apache/sis/storage/sql/SQLStore.java | 8 ++++---- .../src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java | 10 +++++----- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Database.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Database.java index c029516..b3313be 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Database.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/internal/sql/feature/Database.java @@ -43,7 +43,6 @@ import org.apache.sis.internal.system.Modules; import org.apache.sis.internal.util.UnmodifiableArrayList; import org.apache.sis.internal.sql.postgis.Postgres; import org.apache.sis.storage.sql.SQLStore; -import org.apache.sis.storage.Resource; import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.FeatureNaming; import org.apache.sis.storage.DataStoreException; @@ -419,7 +418,7 @@ public class Database<G> extends Syntax { * * @return all tables in an unmodifiable list. */ - public final List<Resource> tables() { + public final List<FeatureSet> tables() { return UnmodifiableArrayList.wrap(tables); } diff --git a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java index dabf372..911bd59 100644 --- a/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java +++ b/storage/sis-sqlstore/src/main/java/org/apache/sis/storage/sql/SQLStore.java @@ -25,8 +25,8 @@ import org.opengis.util.GenericName; import org.opengis.metadata.Metadata; import org.opengis.parameter.ParameterValueGroup; import org.opengis.metadata.spatial.SpatialRepresentationType; -import org.apache.sis.storage.Resource; import org.apache.sis.storage.Aggregate; +import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.IllegalNameException; @@ -249,14 +249,14 @@ public class SQLStore extends DataStore implements Aggregate { } /** - * Returns the resources (features or coverages) in this SQL store. + * Returns the tables (feature sets) in this SQL store. * The list contains only the tables explicitly named at construction time. * * @return children resources that are components of this SQL store. * @throws DataStoreException if an error occurred while fetching the components. */ @Override - public Collection<Resource> components() throws DataStoreException { + public Collection<FeatureSet> components() throws DataStoreException { return model().tables(); } @@ -272,7 +272,7 @@ public class SQLStore extends DataStore implements Aggregate { * @throws DataStoreException if another kind of error occurred while searching resources. */ @Override - public Resource findResource(final String identifier) throws DataStoreException { + public FeatureSet findResource(final String identifier) throws DataStoreException { return model().findTable(this, identifier); } diff --git a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java index 2f4c2a9..3364635 100644 --- a/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java +++ b/storage/sis-sqlstore/src/test/java/org/apache/sis/storage/sql/SQLStoreTest.java @@ -158,7 +158,7 @@ public final strictfp class SQLStoreTest extends TestCase { try (SQLStore store = new SQLStore(new SQLStoreProvider(), new StorageConnector(tmp.source), SQLStoreProvider.createTableName(null, inMemory ? null : SCHEMA, "Cities"))) { - final FeatureSet cities = (FeatureSet) store.findResource("Cities"); + final FeatureSet cities = store.findResource("Cities"); /* * Feature properties should be in same order than columns in the database table, except for * the generated identifier. Note that the country is an association to another feature. @@ -167,11 +167,11 @@ public final strictfp class SQLStoreTest extends TestCase { new String[] {"sis:identifier", "pk:country", "country", "native_name", "english_name", "population", "parks"}, new Object[] {null, String.class, "Countries", String.class, String.class, Integer.class, "Parks"}); - verifyFeatureType(((FeatureSet) store.findResource("Countries")).getType(), + verifyFeatureType(store.findResource("Countries").getType(), new String[] {"sis:identifier", "code", "native_name"}, new Object[] {null, String.class, String.class}); - verifyFeatureType(((FeatureSet) store.findResource("Parks")).getType(), + verifyFeatureType(store.findResource("Parks").getType(), new String[] {"sis:identifier", "pk:country", "FK_City", "city", "native_name", "english_name"}, new Object[] {null, String.class, "Cities", String.class, String.class, String.class}); @@ -309,7 +309,7 @@ public final strictfp class SQLStoreTest extends TestCase { /* * Build the query and get a new set of features. */ - final FeatureSet parks = (FeatureSet) dataset.findResource("Parks"); + final FeatureSet parks = dataset.findResource("Parks"); final FeatureQuery query = new FeatureQuery(); query.setProjection(new FeatureQuery.NamedExpression(FF.property(desiredProperty))); query.setSortBy(FF.sort(FF.property("country"), SortOrder.DESCENDING), @@ -349,7 +349,7 @@ public final strictfp class SQLStoreTest extends TestCase { * so we use `assertSetEquals(…)` for making the test insensitive to feature order. An alternative would be * to add a `query.setSortBy(…)` call, but we avoid that for making this test only about the `WHERE` clause. */ - final FeatureSet cities = (FeatureSet) dataset.findResource("Cities"); + final FeatureSet cities = dataset.findResource("Cities"); final FeatureQuery query = new FeatureQuery(); query.setSelection(FF.equal(FF.property("country"), FF.literal("CAN"))); final Object[] names;