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 0018ef82310b7413dfc88ccfca67ed262ae2a8dc Merge: dc69af0 50b074f Author: Martin Desruisseaux <[email protected]> AuthorDate: Sun May 5 23:56:44 2019 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1. .../apache/sis/internal/jaxb/cat/CodeListUID.java | 3 +- .../internal/jaxb/code/MD_CharacterSetLegacy.java | 84 ----- .../sis/internal/jaxb/lan/LocaleAdapter.java | 62 ++++ .../sis/internal/jaxb/lan/LocaleAndCharset.java | 400 +++++++++++++++++++++ .../apache/sis/internal/jaxb/lan/OtherLocales.java | 150 ++++++++ .../apache/sis/internal/jaxb/lan/PT_Locale.java | 216 ++++++++--- .../internal/metadata/LegacyPropertyAdapter.java | 37 +- .../org/apache/sis/internal/metadata/Merger.java | 83 ++++- .../sis/internal/metadata/MetadataUtilities.java | 42 +++ .../apache/sis/internal/metadata/OtherLocales.java | 189 ---------- .../apache/sis/internal/simple/SimpleMetadata.java | 21 +- .../apache/sis/metadata/ModifiableMetadata.java | 170 +++++++-- .../org/apache/sis/metadata/PropertyAccessor.java | 48 ++- .../java/org/apache/sis/metadata/SpecialCases.java | 30 +- .../java/org/apache/sis/metadata/TreeNode.java | 61 +++- .../org/apache/sis/metadata/TreeNodeChildren.java | 51 +-- .../iso/DefaultExtendedElementInformation.java | 7 +- .../apache/sis/metadata/iso/DefaultMetadata.java | 265 ++++++++------ .../sis/metadata/iso/citation/DefaultContact.java | 7 +- .../iso/content/DefaultCoverageDescription.java | 9 +- .../DefaultFeatureCatalogueDescription.java | 76 ++-- .../sis/metadata/iso/content/package-info.java | 4 +- .../DefaultDigitalTransferOptions.java | 2 +- .../metadata/iso/distribution/DefaultFormat.java | 3 +- .../metadata/iso/distribution/DefaultMedium.java | 5 +- .../identification/DefaultDataIdentification.java | 126 ++++--- .../metadata/iso/identification/package-info.java | 7 +- .../maintenance/DefaultMaintenanceInformation.java | 5 +- .../org/apache/sis/metadata/iso/package-info.java | 8 +- .../sis/metadata/iso/quality/DefaultScope.java | 3 +- .../main/java/org/apache/sis/util/iso/Types.java | 6 +- .../java/org/apache/sis/xml/ValueConverter.java | 2 +- .../org/apache/sis/xml/RenameOnExport.lst | 2 +- .../org/apache/sis/xml/RenameOnImport.lst | 2 +- .../sis/internal/jaxb/lan/LanguageCodeTest.java | 6 +- .../sis/internal/jaxb/lan/OtherLocalesTest.java | 112 ++++++ .../sis/internal/jaxb/lan/PT_LocaleTest.java | 12 +- .../apache/sis/internal/metadata/MergerTest.java | 13 +- .../internal/metadata/MetadataUtilitiesTest.java | 32 +- .../sis/internal/metadata/OtherLocalesTest.java | 129 ------- .../apache/sis/metadata/PropertyAccessorTest.java | 8 +- .../sis/metadata/PropertyConsistencyCheck.java | 23 +- .../sis/metadata/iso/CustomMetadataTest.java | 2 + .../sis/metadata/iso/DefaultMetadataTest.java | 20 +- .../DefaultDataIdentificationTest.java | 44 ++- .../org/apache/sis/test/mock/MetadataMock.java | 15 +- .../apache/sis/test/suite/MetadataTestSuite.java | 2 +- .../sis/test/xml/AnnotationConsistencyCheck.java | 17 +- .../apache/sis/test/integration/MetadataTest.java | 18 +- .../apache/sis/internal/util/CollectionsExt.java | 21 ++ .../sis/internal/util/TreeFormatCustomization.java | 8 + .../sis/util/collection/TreeTableFormat.java | 32 +- .../earthobservation/LandsatReaderTest.java | 2 +- .../apache/sis/internal/storage/xml/StoreTest.java | 6 +- 54 files changed, 1831 insertions(+), 877 deletions(-) diff --cc core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java index bada66b,5454a81..68ca3de --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/simple/SimpleMetadata.java @@@ -135,11 -146,11 +146,11 @@@ public class SimpleMetadata implements } /** - * The character coding standard used for the metadata set. - * Also the character coding standard(s) used for the dataset. + * @deprecated As of SIS 1.0, replaced by {@link #getLocalesAndCharsets()}. */ @Override + @Deprecated - public Collection<Charset> getCharacterSets() { + public final Collection getCharacterSets() { return Collections.emptySet(); // We use 'Set' because we handle 'Charset' like a CodeList. } diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java index d4470ce,a6e3c3a..aab0ae8 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java @@@ -557,7 -557,8 +558,7 @@@ public class DefaultExtendedElementInfo * @since 0.5 */ public void setRationale(final InternationalString newValue) { - rationales = writeCollection(LegacyPropertyAdapter.asCollection(newValue), rationales, InternationalString.class); - checkWritePermission(rationale); - rationale = newValue; ++ rationales = writeCollection(CollectionsExt.singletonOrEmpty(newValue), rationales, InternationalString.class); } /** diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java index a28bfaf,d67d579..f1f2012 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java @@@ -189,17 -197,12 +197,12 @@@ public class DefaultMetadata extends IS /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = 7337533776231004504L; - - /** - * Language(s) used for documenting metadata. - */ - private Collection<Locale> languages; - private static final long serialVersionUID = -1128741312274891545L; ++ private static final long serialVersionUID = -76483485174667242L; /** - * Full name of the character coding standard used for the metadata set. + * Language(s) and character set(s) used within the dataset. */ - private Collection<Charset> characterSets; + private Map<Locale,Charset> locales; /** * Identification of the parent metadata record. @@@ -345,10 -348,9 +348,9 @@@ if (object != null) { identifiers = singleton(object.getMetadataIdentifier(), Identifier.class); parentMetadata = object.getParentMetadata(); - languages = copyCollection(object.getLanguages(), Locale.class); - characterSets = copyCollection(object.getCharacterSets(), Charset.class); + locales = copyMap (object.getLocalesAndCharsets(), Locale.class); metadataScopes = copyCollection(object.getMetadataScopes(), MetadataScope.class); - contacts = copyCollection(object.getContacts(), Responsibility.class); + contacts = copyCollection(object.getContacts(), ResponsibleParty.class); dateInfo = copyCollection(object.getDateInfo(), CitationDate.class); metadataStandards = copyCollection(object.getMetadataStandards(), Citation.class); metadataProfiles = copyCollection(object.getMetadataProfiles(), Citation.class); @@@ -630,25 -678,23 +678,11 @@@ */ @Override @Deprecated - @Dependencies("getCharacterSets") - @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) + @Dependencies("getLocalesAndCharsets") + // @XmlElement at the end of this class. public CharacterSet getCharacterSet() { - if (FilterByVersion.LEGACY_METADATA.accept()) { - final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(), - Charset.class, null, DefaultMetadata.class, "getCharacterSet"); - if (cs != null) { - final String name = cs.name(); - for (final CharacterSet candidate : CharacterSet.values()) { - for (final String n : candidate.names()) { - if (name.equals(n)) { - return candidate; - } - final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(), - Charset.class, null, DefaultMetadata.class, "getCharacterSet"); - if (cs != null) { - final String name = cs.name(); - for (final CharacterSet candidate : CharacterSet.values()) { - for (final String n : candidate.names()) { - if (name.equals(n)) { - return candidate; -- } -- } - return CharacterSet.valueOf(name); -- } - return CharacterSet.valueOf(name); -- } -- return null; ++ return CharacterSet.fromCharset(LegacyPropertyAdapter.getSingleton(getCharacterSets(), ++ Charset.class, null, DefaultMetadata.class, "getCharacterSet")); } /** diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java index d3abded,c262b5c..8d8166c --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java @@@ -37,10 -35,11 +37,11 @@@ import org.apache.sis.internal.jaxb.gco import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.jaxb.metadata.CI_Citation; import org.apache.sis.internal.jaxb.metadata.MD_Identifier; - import org.apache.sis.internal.xml.LegacyNamespaces; -import org.apache.sis.internal.metadata.legacy.MediumName; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; + import org.apache.sis.internal.xml.LegacyNamespaces; + import org.apache.sis.internal.util.CollectionsExt; +import org.apache.sis.internal.util.CodeLists; import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive; diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java index 53e9d92,f7bb052..4dedc6c --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java @@@ -16,23 -16,24 +16,26 @@@ */ package org.apache.sis.metadata.iso.identification; + import java.util.Map; import java.util.Collection; + import java.util.Collections; import java.util.Locale; import java.nio.charset.Charset; ++import java.util.stream.Collectors; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; - import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.metadata.citation.Citation; +import org.opengis.metadata.identification.CharacterSet; import org.opengis.metadata.identification.TopicCategory; import org.opengis.metadata.identification.DataIdentification; - import org.apache.sis.internal.metadata.OtherLocales; - import org.apache.sis.internal.jaxb.lan.LocaleAdapter; + import org.apache.sis.internal.jaxb.lan.LocaleAndCharset; + import org.apache.sis.internal.jaxb.lan.OtherLocales; + import org.apache.sis.internal.jaxb.lan.PT_Locale; import org.apache.sis.internal.xml.LegacyNamespaces; import org.apache.sis.internal.jaxb.FilterByVersion; - import org.apache.sis.internal.util.CollectionsExt; + import org.apache.sis.internal.metadata.Dependencies; /** @@@ -72,8 -73,8 +75,8 @@@ * @module */ @XmlType(name = "MD_DataIdentification_Type", propOrder = { - "language", // Legacy ISO 19115:2003 - "characterSets", // Legacy ISO 19115:2003 + "languages", // Legacy ISO 19115:2003 - "characterSets", // Legacy ISO 19115:2003 ++ "characterSet", // Legacy ISO 19115:2003 "defaultLocale", // New in ISO 19115:2014 "otherLocales", // New in ISO 19115:2014 "environmentDescription", @@@ -214,29 -245,29 +247,41 @@@ public class DefaultDataIdentification /** * Returns the character coding standard used for the dataset. * + * <div class="warning"><b>Upcoming API change — JDK integration</b><br> + * The element type may change to the {@link Charset} class in GeoAPI 4.0. + * </div> + * * @return character coding standard(s) used. + * + * @deprecated Replaced by {@code getLocalesAndCharsets().values()}. */ @Override - @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) + @Deprecated + @Dependencies("getLocalesAndCharsets") - @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) - public Collection<Charset> getCharacterSets() { - return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getCharacterSets(getLocalesAndCharsets()) : null; ++ // @XmlElement at the end of this class. + public Collection<CharacterSet> getCharacterSets() { - return characterSets = nonNullCollection(characterSets, CharacterSet.class); ++ return getLocalesAndCharsets().values().stream().map(CharacterSet::fromCharset).collect(Collectors.toSet()); } /** * Sets the character coding standard used for the dataset. * + * <div class="warning"><b>Upcoming API change — JDK integration</b><br> + * The element type may change to the {@link Charset} class in GeoAPI 4.0. + * </div> + * * @param newValues the new character sets. + * + * @deprecated Replaced by putting values in {@link #getLocalesAndCharsets()} map. */ + @Deprecated - public void setCharacterSets(final Collection<? extends Charset> newValues) { + public void setCharacterSets(final Collection<? extends CharacterSet> newValues) { - characterSets = writeCollection(newValues, characterSets, CharacterSet.class); + // TODO: delete after SIS 1.0 release (method not needed by JAXB). - setLocalesAndCharsets(LocaleAndCharset.setCharacterSets(getLocalesAndCharsets(), newValues)); ++ Collection<Charset> c = null; ++ if (newValues != null) { ++ c = newValues.stream().map(CharacterSet::toCharset).collect(Collectors.toSet()); ++ } ++ setLocalesAndCharsets(LocaleAndCharset.setCharacterSets(getLocalesAndCharsets(), c)); } /** @@@ -316,17 -347,7 +361,18 @@@ * Gets the other locales for this record (used in ISO 19115-3 format). */ @XmlElement(name = "otherLocale") - private Collection<Locale> getOtherLocales() { - return FilterByVersion.CURRENT_METADATA.accept() ? OtherLocales.filter(getLanguages()) : null; + private Collection<PT_Locale> getOtherLocales() { + return FilterByVersion.CURRENT_METADATA.accept() ? OtherLocales.filter(getLocalesAndCharsets()) : null; } + + /** - * Returns the locale to marshal if the XML document is to be written - * according the legacy ISO 19115:2003 model. ++ * Returns the character coding for the metadata set (used in legacy ISO 19157 format). ++ * ++ * @see #getCharacterSets() + */ - @XmlElement(name = "language", namespace = LegacyNamespaces.GMD) - @XmlJavaTypeAdapter(LocaleAdapter.class) - private Collection<Locale> getLanguage() { - return FilterByVersion.LEGACY_METADATA.accept() ? getLanguages() : null; ++ @Dependencies("getLocalesAndCharsets") ++ @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) ++ private Collection<Charset> getCharacterSet() { ++ return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getCharacterSets(getLocalesAndCharsets()) : null; + } } diff --cc core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java index 4ce4f45,5dc44ac..5a41a2b --- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java +++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/CustomMetadataTest.java @@@ -20,6 -20,6 +20,7 @@@ import java.util.Map import java.util.HashMap; import java.util.Collection; import java.util.Locale; ++import java.nio.charset.Charset; import java.lang.reflect.Proxy; import java.lang.reflect.Method; import java.lang.reflect.InvocationHandler;
