This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-3.1 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 24e0c1b0b0e52814a4acae14fcf4008d3c4b43e8 Merge: f58c7f7d56 e5ffa1ff25 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Jan 22 15:40:48 2024 +0100 Merge branch 'geoapi-4.0' into geoapi-3.1: post-merge reorganization of imports. .../main/org/apache/sis/filter/Capabilities.java | 1 - .../main/org/apache/sis/filter/internal/CopyVisitor.java | 1 - .../main/org/apache/sis/filter/internal/EditVisitor.java | 1 - .../main/org/apache/sis/filter/sqlmm/FunctionDescription.java | 1 - .../test/org/apache/sis/filter/CapabilitiesTest.java | 3 ++- .../test/org/apache/sis/filter/internal/CopyVisitorTest.java | 3 ++- .../test/org/apache/sis/filter/internal/FilterFactoryMock.java | 1 - .../test/org/apache/sis/filter/internal/FunctionMock.java | 1 - .../test/org/apache/sis/filter/internal/ValueReferenceMock.java | 1 - .../main/org/apache/sis/metadata/iso/OnlineResourceAdapter.java | 1 - .../main/org/apache/sis/metadata/iso/URIStringAdapter.java | 1 - .../org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java | 1 - .../org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java | 1 - .../org/apache/sis/metadata/iso/maintenance/LegacyFeatureType.java | 1 - .../main/org/apache/sis/xml/bind/metadata/MD_AssociatedResource.java | 1 - .../org/apache/sis/xml/bind/metadata/code/DQM_ValueStructure.java | 1 - .../org/apache/sis/xml/bind/metadata/code/SV_ParameterDirection.java | 1 - .../test/org/apache/sis/metadata/xml/SchemaComplianceTest.java | 3 ++- .../test/org/apache/sis/xml/RenameListGenerator.java | 1 - .../test/org/apache/sis/xml/test/PackageVerifier.java | 3 ++- .../test/org/apache/sis/xml/test/SchemaCompliance.java | 1 - .../main/org/apache/sis/referencing/crs/DefaultGeodeticCRS.java | 4 +--- .../sis/referencing/operation/transform/ConcatenatedTransform.java | 2 +- .../test/org/apache/sis/io/wkt/WKTParserTest.java | 3 ++- .../org/apache/sis/referencing/factory/GeodeticObjectFactoryTest.java | 3 ++- .../test/org/apache/sis/referencing/geoapi/AuthorityFactoryTest.java | 3 ++- .../org/apache/sis/referencing/geoapi/ParameterizedTransformTest.java | 3 ++- .../referencing/operation/provider/ParameterNameTableGenerator.java | 3 ++- .../org/apache/sis/referencing/report/CoordinateReferenceSystems.java | 3 ++- .../test/org/apache/sis/storage/netcdf/base/FeatureSetTest.java | 3 ++- .../test/org/apache/sis/storage/netcdf/classic/FeatureSetTest.java | 3 ++- .../main/org/apache/sis/pending/temporal/Primitive.java | 1 - incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/CQL.java | 1 - .../main/org/apache/sis/cql/FilterToCQLVisitor.java | 1 - incubator/src/org.apache.sis.cql/main/org/apache/sis/cql/Query.java | 1 - .../org.apache.sis.cql/main/org/apache/sis/cql/internal/AntlrCQL.java | 1 - .../src/org.apache.sis.cql/test/org/apache/sis/cql/CQLTestCase.java | 1 - .../test/org/apache/sis/cql/ExpressionReadingTest.java | 3 ++- .../test/org/apache/sis/cql/ExpressionWritingTest.java | 3 ++- .../org.apache.sis.cql/test/org/apache/sis/cql/FilterReadingTest.java | 3 ++- .../org.apache.sis.cql/test/org/apache/sis/cql/FilterWritingTest.java | 3 ++- .../org.apache.sis.cql/test/org/apache/sis/cql/QueryReadingTest.java | 3 ++- .../org.apache.sis.cql/test/org/apache/sis/cql/QueryWritingTest.java | 3 ++- .../test/org/apache/sis/map/MapLayersTest.java | 2 ++ .../test/org/apache/sis/map/SEPortrayerTest.java | 2 ++ 45 files changed, 42 insertions(+), 45 deletions(-) diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/OnlineResourceAdapter.java index b7bab6f312,0000000000..a66af47713 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/OnlineResourceAdapter.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/OnlineResourceAdapter.java @@@ -1,65 -1,0 +1,64 @@@ +/* + * 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.metadata.iso; + - // Specific to the main and geoapi-3.1 branches: +import java.net.URI; +import java.net.URISyntaxException; +import jakarta.xml.bind.annotation.adapters.XmlAdapter; +import org.opengis.metadata.citation.OnlineResource; +import org.apache.sis.xml.bind.metadata.CI_OnlineResource; +import org.apache.sis.metadata.iso.citation.DefaultOnlineResource; + + +/** + * Converts an URI to a {@code <cit:OnlineResource>} element for ISO 19115-3:2016 compliance. + * We need this additional adapter because some property type changed from {@code URI} to + * {@code OnlineResource} in the upgrade from ISO 19115:2003 to ISO 19115-1:2014. + * + * @author Martin Desruisseaux (Geomatys) + */ +final class OnlineResourceAdapter extends XmlAdapter<CI_OnlineResource, URI> { + /** + * The adapter performing the actual work. + */ + private static final CI_OnlineResource ADAPTER = new CI_OnlineResource.Since2014(); + + /** + * Wraps the given URI in a {@code <cit:OnlineResource>} element. + */ + @Override + public CI_OnlineResource marshal(final URI value) { + if (value != null) { + return ADAPTER.marshal(new DefaultOnlineResource(value)); + } + return null; + } + + /** + * Returns a URI from the given {@code <cit:OnlineResource>} element. + */ + @Override + public URI unmarshal(final CI_OnlineResource value) throws URISyntaxException { + if (value != null) { + final OnlineResource res = ADAPTER.unmarshal(value); + if (res != null) { + return res.getLinkage(); + } + } + return null; + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/URIStringAdapter.java index 6515aead5f,0000000000..8e8dbe312e mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/URIStringAdapter.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/URIStringAdapter.java @@@ -1,66 -1,0 +1,65 @@@ +/* + * 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.metadata.iso; + - // Specific to the main and geoapi-3.1 branches: +import java.net.URI; +import java.net.URISyntaxException; +import jakarta.xml.bind.annotation.adapters.XmlAdapter; +import org.apache.sis.xml.bind.Context; +import org.apache.sis.xml.bind.gco.CharSequenceAdapter; +import org.apache.sis.xml.bind.gco.GO_CharacterString; + + +/** + * Converts an URI to a {@code <gco:CharacterSequence>} element for ISO 19115-3:2016 compliance. + * We need this additional adapter because some property type changed from {@code URI} + * to {@code CharacterSequence} in the upgrade from ISO 19115:2003 to ISO 19115-1:2014. + * + * @author Martin Desruisseaux (Geomatys) + */ +final class URIStringAdapter extends XmlAdapter<GO_CharacterString, URI> { + /** + * The adapter performing the actual work. + */ + private static final CharSequenceAdapter ADAPTER = new CharSequenceAdapter.Since2014(); + + /** + * Wraps the given URI in a {@code <cit:OnlineResource>} element. + */ + @Override + public GO_CharacterString marshal(final URI value) { + if (value != null) { + return ADAPTER.marshal(value.toString()); + } + return null; + } + + /** + * Returns a URI from the given {@code <cit:OnlineResource>} element. + */ + @Override + public URI unmarshal(final GO_CharacterString value) throws URISyntaxException { + if (value != null) { + final CharSequence uri = ADAPTER.unmarshal(value); + if (uri != null) { + final Context context = Context.current(); + return Context.converter(context).toURI(context, uri.toString()); + } + } + return null; + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java index 2f9b46911c,0000000000..d24789d6b4 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/AttributeTypeAdapter.java @@@ -1,50 -1,0 +1,49 @@@ +/* + * 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.metadata.iso.maintenance; + - // Specific to the main and geoapi-3.1 branches: +import jakarta.xml.bind.annotation.adapters.XmlAdapter; +import org.opengis.feature.type.AttributeType; +import org.apache.sis.xml.bind.gco.GO_CharacterString; + + +/** + * For (un)marshalling deprecated {@link AttributeType} as a character string, + * as expected by ISO 19115-3:2016. This is a temporary bridge to be removed + * after the GeoAPI interfaces has been upgraded to ISO 19115-1:2014 model. + * + * @author Martin Desruisseaux (Geomatys) + */ +final class AttributeTypeAdapter extends XmlAdapter<GO_CharacterString, AttributeType> { + /** + * Wrap the given value from {@link DefaultScopeDescription} to the elements + * defined by ISO 19115-3:2016 schema. + */ + @Override + public AttributeType unmarshal(GO_CharacterString value) { + return new LegacyFeatureType(LegacyFeatureType.ADAPTER.unmarshal(value)); + } + + /** + * Unwrap the elements defined by ISO 19115-3:2016 schema to the value used by + * {@link DefaultScopeDescription}. + */ + @Override + public GO_CharacterString marshal(AttributeType value) { + return LegacyFeatureType.ADAPTER.marshal(LegacyFeatureType.wrap(value)); + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java index c63e48bda8,0000000000..2bf7d32b47 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/FeatureTypeAdapter.java @@@ -1,50 -1,0 +1,49 @@@ +/* + * 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.metadata.iso.maintenance; + - // Specific to the main and geoapi-3.1 branches: +import jakarta.xml.bind.annotation.adapters.XmlAdapter; +import org.opengis.feature.type.FeatureType; +import org.apache.sis.xml.bind.gco.GO_CharacterString; + + +/** + * For (un)marshalling deprecated {@link FeatureType} as a character string, + * as expected by ISO 19115-3:2016. This is a temporary bridge to be removed + * after the GeoAPI interfaces has been upgraded to ISO 19115-1:2014 model. + * + * @author Martin Desruisseaux (Geomatys) + */ +final class FeatureTypeAdapter extends XmlAdapter<GO_CharacterString, FeatureType> { + /** + * Wrap the given value from {@link DefaultScopeDescription} to the elements + * defined by ISO 19115-3:2016 schema. + */ + @Override + public FeatureType unmarshal(GO_CharacterString value) { + return new LegacyFeatureType(LegacyFeatureType.ADAPTER.unmarshal(value)); + } + + /** + * Unwrap the elements defined by ISO 19115-3:2016 schema to the value used by + * {@link DefaultScopeDescription}. + */ + @Override + public GO_CharacterString marshal(FeatureType value) { + return LegacyFeatureType.ADAPTER.marshal(LegacyFeatureType.wrap(value)); + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/LegacyFeatureType.java index e9cab4e109,0000000000..1735a1aa68 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/LegacyFeatureType.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/LegacyFeatureType.java @@@ -1,98 -1,0 +1,97 @@@ +/* + * 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.metadata.iso.maintenance; + - // Specific to the main and geoapi-3.1 branches: +import java.util.Set; +import java.util.LinkedHashSet; +import org.opengis.feature.type.FeatureType; +import org.opengis.feature.type.AttributeType; +import org.apache.sis.xml.bind.gco.CharSequenceAdapter; +import org.apache.sis.util.ArgumentChecks; + + +/** + * Bridges between deprecated {@link FeatureType} / {@link AttributeType} and {@link CharSequence}. + * {@code FeatureType} and {@code AttributeType} were used in ISO 19115:2003, but have been replaced + * by {@link CharSequence} in ISO 19115:2014. The corresponding GeoAPI 3.0 interfaces are empty since + * they were placeholder for future work. We use this {@code LegacyFeatureType} as a temporary bridge, + * to be removed with GeoAPI 4.0. + * + * @author Martin Desruisseaux (Geomatys) + * @version 1.0 + * @since 1.0 + * + * @deprecated To be removed after migration to GeoAPI 4.0. + */ +@Deprecated +public final class LegacyFeatureType implements FeatureType, AttributeType, CharSequence { + /** + * The adapter doing most of the actual work of converting {@code FeatureType} or {@code AttributeType} + * to {@code <gco:CharacterSequence>} elements. + */ + static final CharSequenceAdapter ADAPTER = new CharSequenceAdapter(); + + /** + * The value to wrap as a {@code FeatureType} or {@code AttributeType}. + */ + private final CharSequence value; + + /** + * Creates a new type for the given value, which must be non-null. + * + * @param value the text to wrap in a legacy feature type. + */ + public LegacyFeatureType(final CharSequence value) { + ArgumentChecks.ensureNonNull("value", value); + this.value = value; + } + + /** + * Wraps the given {@code FeatureType} or {@code AttributeType} as a {@code CharSequence}. + */ + static CharSequence wrap(final Object value) { + return (value == null || value instanceof CharSequence) + ? (CharSequence) value : new LegacyFeatureType(value.toString()); + } + + /** + * Returns a list with all content of the given collection wrapped as {@link LegacyFeatureType}. + */ + static Set<LegacyFeatureType> wrapAll(final Iterable<? extends CharSequence> values) { + if (values == null) { + return null; + } + final Set<LegacyFeatureType> wrapped = new LinkedHashSet<>(); + for (final CharSequence value : values) { + wrapped.add((value == null || value instanceof LegacyFeatureType) + ? (LegacyFeatureType) value : new LegacyFeatureType(value)); + } + return wrapped; + } + + /** + * Delegates to the value given at construction time. + */ + @Override public int length() {return value.length();} + @Override public char charAt(int index) {return value.charAt(index);} + @Override public CharSequence subSequence(int start, int end) {return value.subSequence(start, end);} + @Override public String toString() {return value.toString();} + @Override public int hashCode() {return value.hashCode() ^ 439703003;} + @Override public boolean equals(final Object obj) { + return (obj instanceof LegacyFeatureType) && value.equals(((LegacyFeatureType) obj).value); + } +}