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 94597927c0b85f4b2f2e1ae8188a3fbe7e76a691 Author: Martin Desruisseaux <[email protected]> AuthorDate: Sat May 24 21:45:13 2025 +0200 Remove `FeatureCatalogBuilder`, which was not really used. --- .../main/org/apache/sis/storage/gpx/Store.java | 17 ----- .../main/org/apache/sis/storage/gpx/Types.java | 26 ++----- .../sis/storage/base/FeatureCatalogBuilder.java | 81 ---------------------- .../apache/sis/storage/base/MetadataBuilder.java | 3 - .../sis/storage/base/MetadataBuilderTest.java | 4 +- 5 files changed, 9 insertions(+), 122 deletions(-) diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java index 9ca78310e1..ebe8c6ddc9 100644 --- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java +++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Store.java @@ -29,7 +29,6 @@ import org.apache.sis.storage.FeatureSet; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreContentException; -import org.apache.sis.storage.IllegalNameException; import org.apache.sis.storage.base.StoreUtilities; import org.apache.sis.storage.xml.stream.StaxDataStore; import org.apache.sis.util.Version; @@ -186,22 +185,6 @@ public class Store extends StaxDataStore implements FeatureSet { return types.parent; } - /** - * Returns the feature type for the given name. The {@code name} argument should be the result of calling - * {@link org.opengis.util.GenericName#toString()} on the name of one of the feature types in this data store. - * - * @param name the name or alias of the feature type to get. - * @return the feature type of the given name or alias (never {@code null}). - * @throws IllegalNameException if the given name was not found or is ambiguous. - * - * @deprecated We are not sure yet if we will keep this method. Decision is pending acquisition of - * more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}. - */ - @Deprecated(since="0.8") - public FeatureType getFeatureType(final String name) throws IllegalNameException { - return types.names.get(this, name); - } - /** * Returns the stream of features. * This store does not cache the features. Any new iteration over features will re-read from the file. diff --git a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java index 352a74d7b7..99cfd33640 100644 --- a/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java +++ b/endorsed/src/org.apache.sis.storage.xml/main/org/apache/sis/storage/gpx/Types.java @@ -29,7 +29,6 @@ import org.opengis.metadata.citation.OnlineResource; import org.opengis.metadata.content.ContentInformation; import org.opengis.metadata.acquisition.GeometryType; import org.apache.sis.setup.GeometryLibrary; -import org.apache.sis.storage.FeatureNaming; import org.apache.sis.storage.IllegalNameException; import org.apache.sis.storage.gps.Fix; import org.apache.sis.referencing.CommonCRS; @@ -41,7 +40,7 @@ import org.apache.sis.feature.builder.PropertyTypeBuilder; import org.apache.sis.feature.builder.AttributeRole; import org.apache.sis.feature.privy.AttributeConvention; import org.apache.sis.geometry.wrapper.Geometries; -import org.apache.sis.storage.base.FeatureCatalogBuilder; +import org.apache.sis.storage.base.MetadataBuilder; import org.apache.sis.util.iso.DefaultNameFactory; // Specific to the geoapi-3.1 and geoapi-4.0 branches: @@ -88,16 +87,6 @@ final class Types { */ final Collection<ContentInformation> metadata; - /** - * Binding from names to feature type instances. - * Shall not be modified after construction. - * - * @deprecated We are not sure yet if we will keep this field. Decision is pending acquisition of - * more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}. - */ - @Deprecated(since="0.8") - final FeatureNaming<FeatureType> names; - /** * Accessor to the geometry implementation in use (Java2D, ESRI or JTS). */ @@ -128,7 +117,7 @@ final class Types { throws FactoryException, IllegalNameException { geometries = Geometries.factory(library); - final Map<String,InternationalString[]> resources = new HashMap<>(); + final var resources = new HashMap<String, InternationalString[]>(); final Map<String,?> geomInfo = Map.of(AbstractIdentifiedType.NAME_KEY, AttributeConvention.GEOMETRY_PROPERTY); final Map<String,?> envpInfo = Map.of(AbstractIdentifiedType.NAME_KEY, AttributeConvention.ENVELOPE_PROPERTY); /* @@ -143,7 +132,7 @@ final class Types { * │ sis:identifier │ Integer │ [1 … 1] │ SIS-specific property * └────────────────┴─────────┴──────────────┘ */ - final FeatureTypeBuilder builder = new FeatureTypeBuilder(factory, library, locale); + final var builder = new FeatureTypeBuilder(factory, library, locale); builder.setNameSpace(Tags.PREFIX).setName("GPXEntity").setAbstract(true); builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY); parent = builder.build(); @@ -282,12 +271,11 @@ final class Types { builder.addAssociation(trackSegment).setName(Tags.TRACK_SEGMENTS).setMaximumOccurs(Integer.MAX_VALUE); track = create(builder, resources); - final FeatureCatalogBuilder fc = new FeatureCatalogBuilder(null); - fc.define(route); - fc.define(track); - fc.define(wayPoint); + final var fc = new MetadataBuilder(); + fc.addFeatureType(route, -1); + fc.addFeatureType(track, -1); + fc.addFeatureType(wayPoint, -1); metadata = fc.buildAndFreeze().getContentInfo(); - names = fc.features; } /** diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/FeatureCatalogBuilder.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/FeatureCatalogBuilder.java deleted file mode 100644 index 15b6d5050d..0000000000 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/FeatureCatalogBuilder.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.sis.storage.base; - -import org.opengis.util.GenericName; -import org.apache.sis.storage.DataStore; -import org.apache.sis.storage.FeatureNaming; -import org.apache.sis.storage.IllegalNameException; -import org.apache.sis.metadata.iso.DefaultMetadata; - -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.feature.FeatureType; - - -/** - * Helper methods for the feature metadata created by {@code DataStore} implementations. - * This is a convenience class for chaining {@link #addFeatureType(FeatureType, long)} - * method calls with {@link FeatureNaming#add(DataStore, GenericName, Object)}. - * - * @author Martin Desruisseaux (Geomatys) - * - * @see org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription - */ -public final class FeatureCatalogBuilder extends MetadataBuilder { - /** - * The data store for which the metadata will be created, or {@code null} if unknown. - * This is used for producing error message if an exception is thrown. - */ - private final DataStore store; - - /** - * The feature types created by the {@code FeatureCatalogBuilder}. - * {@code DataStore} implementations can keep the reference to this {@code FeatureNaming} - * after the {@link #build()} method has been invoked. - */ - public final FeatureNaming<FeatureType> features; - - /** - * Creates a new builder for the given data store. - * - * @param store the data store for which the metadata will be created, or {@code null} if unknown. - */ - public FeatureCatalogBuilder(final DataStore store) { - this.store = store; - features = new FeatureNaming<>(); - } - - /** - * Adds descriptions for the given feature in both the {@link DefaultMetadata} and {@link FeatureNaming} instances. - * Invoking this method is equivalent to executing the following code (omitting {@code null} checks for brevity): - * - * {@snippet lang="java" : - * features.add(store, add(type, null), type); - * } - * - * @param type the feature type to add, or {@code null}. - * @throws IllegalNameException if a feature of the same name has already been added. - * - * @see #addFeatureType(FeatureType, long) - */ - public final void define(final FeatureType type) throws IllegalNameException { - final GenericName name = addFeatureType(type, -1); - if (name != null) { - features.add(store, name, type); - } - } -} diff --git a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java index 41a6938b8d..657102d957 100644 --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java @@ -1867,14 +1867,11 @@ public class MetadataBuilder { * * This method returns the feature name for more convenient chaining with * {@link org.apache.sis.storage.FeatureNaming#add FeatureNaming.add(…)}. - * Note that the {@link FeatureCatalogBuilder} subclasses can also be used for that chaining. * * @param type the feature type to add, or {@code null} for no-operation. * @param occurrences number of instances of the given feature type, or a negative value if unknown. * Note that ISO-19115 considers 0 as an invalid value. Consequently, if 0, the feature is not added. * @return the name of the added feature (even if not added to the metadata), or {@code null} if none. - * - * @see FeatureCatalogBuilder#define(FeatureType) */ public final GenericName addFeatureType(final FeatureType type, final long occurrences) { if (type == null) { diff --git a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java index ec9e903f8a..9ef0405554 100644 --- a/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java +++ b/endorsed/src/org.apache.sis.storage/test/org/apache/sis/storage/base/MetadataBuilderTest.java @@ -154,8 +154,8 @@ public final class MetadataBuilderTest extends TestCase { assertTrue(metadata.getContentInfo().isEmpty()); } else { final ContentInformation content = getSingleton(metadata.getContentInfo()); - assertInstanceOf(FeatureCatalogueDescription.class, content); - final FeatureTypeInfo info = getSingleton(((FeatureCatalogueDescription) content).getFeatureTypeInfo()); + final var catalog = assertInstanceOf(FeatureCatalogueDescription.class, content); + final FeatureTypeInfo info = getSingleton(catalog.getFeatureTypeInfo()); assertEquals(expected, info.getFeatureInstanceCount(), errorMessage); } }
