This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sis.git
commit 89daa3b3d0e302d42c05ba063d85506d41ee3a45 Merge: 09ba94f 6944f6c Author: Martin Desruisseaux <[email protected]> AuthorDate: Mon May 6 14:46:48 2019 +0200 Merge branch 'geoapi-3.1' Contains fix for https://issues.apache.org/jira/browse/SIS-402 regression. .../apache/sis/internal/jaxb/cat/CodeListUID.java | 3 +- .../internal/jaxb/code/MD_CharacterSetCode.java | 22 ++ .../internal/jaxb/code/MD_CharacterSetLegacy.java | 84 ----- .../sis/internal/jaxb/code/MD_MediumNameCode.java | 2 +- .../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 ---------- .../internal/metadata/legacy/package-info.java} | 34 +- .../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 | 5 +- .../apache/sis/metadata/iso/DefaultMetadata.java | 264 ++++++++------ .../sis/metadata/iso/citation/DefaultContact.java | 7 +- .../iso/content/DefaultCoverageDescription.java | 9 +- .../DefaultFeatureCatalogueDescription.java | 78 ++-- .../sis/metadata/iso/content/package-info.java | 4 +- .../DefaultDigitalTransferOptions.java | 2 +- .../metadata/iso/distribution/DefaultFormat.java | 3 +- .../metadata/iso/distribution/DefaultMedium.java | 59 ++- .../identification/DefaultDataIdentification.java | 135 ++++--- .../metadata/iso/identification/package-info.java | 7 +- .../maintenance/DefaultMaintenanceInformation.java | 5 +- .../sis/metadata/iso/maintenance/DefaultScope.java | 3 +- .../org/apache/sis/metadata/iso/package-info.java | 8 +- .../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/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 | 17 +- .../sis/metadata/iso/DefaultMetadataTest.java | 20 +- .../DefaultDataIdentificationTest.java | 44 ++- .../apache/sis/test/suite/MetadataTestSuite.java | 2 +- .../sis/test/xml/AnnotationConsistencyCheck.java | 17 +- .../apache/sis/metadata/iso/api-changes.properties | 5 +- .../apache/sis/test/integration/MetadataTest.java | 13 +- .../apache/sis/internal/util/CollectionsExt.java | 21 ++ .../sis/internal/util/TreeFormatCustomization.java | 8 + .../sis/util/collection/TreeTableFormat.java | 32 +- pom.xml | 6 +- .../apache/sis/internal/storage/xml/StoreTest.java | 4 +- 54 files changed, 1887 insertions(+), 893 deletions(-) diff --cc core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_CharacterSetCode.java index 6962f03,6962f03..6d35f4e --- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_CharacterSetCode.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_CharacterSetCode.java @@@ -21,6 -21,6 +21,7 @@@ import java.nio.charset.Charset import java.nio.charset.IllegalCharsetNameException; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlAdapter; ++import org.opengis.metadata.identification.CharacterSet; import org.apache.sis.xml.Namespaces; import org.apache.sis.xml.ValueConverter; import org.apache.sis.internal.jaxb.Context; @@@ -105,4 -105,4 +106,25 @@@ public final class MD_CharacterSetCode public void setElement(final CodeListUID value) { identifier = value; } ++ ++ /** ++ * Converts the given Java Character Set to {@code CharacterSet}. ++ * ++ * @param cs the character set, or {@cod null}. ++ * @return a code list for the given character set, or {@code null} if the given {@code cs} was null. ++ */ ++ public static CharacterSet fromCharset(final Charset cs) { ++ if (cs == null) { ++ return 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); ++ } } diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java index 548fe6f,f4f8731..76e1d68 --- 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 @@@ -71,15 -77,12 +76,20 @@@ import org.apache.sis.internal.jaxb.Fil import org.apache.sis.internal.jaxb.Context; 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.util.collection.Containers; + import org.apache.sis.util.ObjectConverter; + import org.apache.sis.internal.converter.SurjectiveConverter; + import org.apache.sis.math.FunctionProperty; +// Branch-specific imports +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; +import static org.opengis.annotation.Obligation.MANDATORY; +import static org.opengis.annotation.Obligation.CONDITIONAL; +import static org.opengis.annotation.Specification.ISO_19115; - import static org.apache.sis.internal.metadata.MetadataUtilities.valueIfDefined; ++import org.apache.sis.internal.jaxb.code.MD_CharacterSetCode; + /** * Root entity which defines metadata about a resource or resources. @@@ -361,36 -368,7 +366,35 @@@ public class DefaultMetadata extends IS applicationSchemaInfo = copyCollection(object.getApplicationSchemaInfo(), ApplicationSchemaInformation.class); metadataMaintenance = object.getMetadataMaintenance(); acquisitionInformation = copyCollection(object.getAcquisitionInformation(), AcquisitionInformation.class); - resourceLineages = copyCollection(object.getResourceLineages(), Lineage.class); + if (object instanceof DefaultMetadata) { + final DefaultMetadata c = (DefaultMetadata) object; + identifiers = singleton(c.getMetadataIdentifier(), Identifier.class); + parentMetadata = c.getParentMetadata(); - languages = copyCollection(c.getLanguages(), Locale.class); - characterSets = copyCollection(c.getCharacterSets(), Charset.class); ++ locales = copyMap (c.getLocalesAndCharsets(), Locale.class); + metadataScopes = copyCollection(c.getMetadataScopes(), DefaultMetadataScope.class); + dateInfo = copyCollection(c.getDateInfo(), CitationDate.class); + metadataStandards = copyCollection(c.getMetadataStandards(), Citation.class); + metadataProfiles = copyCollection(c.getMetadataProfiles(), Citation.class); + alternativeMetadataReferences = copyCollection(c.getAlternativeMetadataReferences(), Citation.class); + metadataLinkages = copyCollection(c.getMetadataLinkages(), OnlineResource.class); + resourceLineages = copyCollection(c.getResourceLineages(), Lineage.class); + } else { + setFileIdentifier (object.getFileIdentifier()); + setParentIdentifier (object.getParentIdentifier()); + setLanguage (object.getLanguage()); + setLocales (object.getLocales()); + setCharacterSet (object.getCharacterSet()); + setHierarchyLevels (object.getHierarchyLevels()); + setHierarchyLevelNames (object.getHierarchyLevelNames()); + setDateStamp (object.getDateStamp()); + setMetadataStandardName (object.getMetadataStandardName()); + setMetadataStandardVersion(object.getMetadataStandardVersion()); + try { + setDataSetUri(object.getDataSetUri()); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } } } @@@ -500,23 -478,65 +504,65 @@@ } /** - * Returns the language(s) used for documenting metadata. - * The first element in iteration order is the default language. - * All other elements, if any, are alternate language(s) used within the resource. + * Returns the language(s) and character set(s) used for documenting metadata. + * The first entry in iteration order is the default language and its character set. + * All other entries, if any, are alternate language(s) and character set(s) used within the resource. * - * <p>Unless an other locale has been specified with the {@link org.apache.sis.xml.XML#LOCALE} property, + * <p>Unless another locale has been specified with the {@link org.apache.sis.xml.XML#LOCALE} property, * this {@code DefaultMetadata} instance and its children will use the first locale returned by this method * for marshalling {@link org.opengis.util.InternationalString} and {@link org.opengis.util.CodeList} instances - * in ISO 19115-2 compliant XML documents. + * in ISO 19115-2 compliant XML documents.</p> * - * @return language(s) used for documenting metadata. + * <p>Each ({@link Locale}, {@link Charset}) entry is equivalent to an instance of ISO 19115 {@code PT_Locale} + * class. The language code and the character set are mandatory elements in ISO standard. Consequently this map + * should not contain null key or null values, but Apache SIS implementations is tolerant for historical reasons. + * The same character set may be associated to many languages.</p> * - * @since 0.5 + * @return language(s) and character set(s) used for documenting metadata. + * + * @since 1.0 */ - @Override // @XmlElement at the end of this class. + @UML(identifier="defaultLocale+otherLocale", obligation=CONDITIONAL, specification=ISO_19115) + public Map<Locale,Charset> getLocalesAndCharsets() { + return locales = nonNullMap(locales, Locale.class); + } + + /** + * Sets the language(s) and character set(s) used within the dataset. + * The first element in iteration order should be the default language. + * All other elements, if any, are alternate language(s) used within the resource. + * + * @param newValues the new language(s) and character set(s) used for documenting metadata. + * + * @see org.apache.sis.xml.XML#LOCALE + * + * @since 1.0 + */ + public void setLocalesAndCharsets(final Map<? extends Locale, ? extends Charset> newValues) { + locales = writeMap(newValues, locales, Locale.class); + /* + * The "magic" applying this language to every children + * is performed by the 'beforeMarshal(Marshaller)' method. + */ + } + + /** + * Returns the language(s) used for documenting metadata. + * The first element in iteration order is the default language. + * All other elements, if any, are alternate language(s) used within the resource. + * + * @return language(s) used for documenting metadata. + * + * @since 0.5 + * + * @deprecated Replaced by <code>{@linkplain #getLocalesAndCharsets()}.keySet()</code>. + */ + @Deprecated + @Dependencies("getLocalesAndCharsets") public Collection<Locale> getLanguages() { - return languages = nonNullCollection(languages, Locale.class); + // TODO: delete after SIS 1.0 release (method not needed by JAXB). + return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getLanguages(getLocalesAndCharsets()) : null; } /** @@@ -591,16 -614,28 +640,40 @@@ } /** + * Sets information about an alternatively used localized character string for a linguistic extension. + * + * @param newValues the new locales. + * - * @deprecated As of SIS 0.5, replaced by {@link #setLanguages(Collection)}. ++ * @deprecated Replaced by putting keys in {@link #getLocalesAndCharsets()}. + */ + @Deprecated + public void setLocales(final Collection<? extends Locale> newValues) { - checkWritePermission(valueIfDefined(languages)); - setOtherLocales(newValues); ++ getLocales().addAll(newValues); ++ } ++ ++ /** + * Converter from {@link PT_Locale} and {@link Locale}. + */ + private static final class ToLocale extends SurjectiveConverter<PT_Locale,Locale> { + static final ToLocale INSTANCE = new ToLocale(); + private ToLocale() {} + @Override public Class<PT_Locale> getSourceClass() {return PT_Locale.class;} + @Override public Class<Locale> getTargetClass() {return Locale.class;} + @Override public Locale apply(PT_Locale p) {return p.getLocale();} + @Override public ObjectConverter<Locale, PT_Locale> inverse() {return FromLocale.INSTANCE;} + } + + /** + * Converter from {@link Locale} and {@link PT_Locale}. + */ + private static final class FromLocale implements ObjectConverter<Locale,PT_Locale> { + static final FromLocale INSTANCE = new FromLocale(); + private FromLocale() {} + @Override public Set<FunctionProperty> properties() {return EnumSet.of(FunctionProperty.INJECTIVE);} + @Override public Class<Locale> getSourceClass() {return Locale.class;} + @Override public Class<PT_Locale> getTargetClass() {return PT_Locale.class;} + @Override public PT_Locale apply(Locale o) {return (o != null) ? new PT_Locale(o) : null;} + @Override public ObjectConverter<PT_Locale, Locale> inverse() {return ToLocale.INSTANCE;} } /** @@@ -654,25 -678,11 +716,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; - } - } - } - return CharacterSet.valueOf(name); - } - } - return null; - return CharacterSet.fromCharset(LegacyPropertyAdapter.getSingleton(getCharacterSets(), ++ return MD_CharacterSetCode.fromCharset(LegacyPropertyAdapter.getSingleton(getCharacterSets(), + Charset.class, null, DefaultMetadata.class, "getCharacterSet")); } /** diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java index e11fe11,4e8d3f3..bb0ff67 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java @@@ -35,15 -36,9 +35,16 @@@ import org.apache.sis.internal.jaxb.Fil import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; +import org.apache.sis.internal.geoapi.evolution.UnsupportedCodeList; + import org.apache.sis.internal.xml.LegacyNamespaces; + import org.apache.sis.internal.util.CollectionsExt; +// Branch-specific imports +import org.opengis.util.CodeList; +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; +import static org.opengis.annotation.Specification.ISO_19115; + /** * Information required to enable contact with the responsible person and/or organization. diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java index e8b0e82,5439958..330fa37 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java @@@ -33,13 -36,8 +35,12 @@@ import org.apache.sis.internal.xml.Lega import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; import org.apache.sis.internal.jaxb.FilterByVersion; - import org.apache.sis.internal.xml.LegacyNamespaces; import org.apache.sis.internal.jaxb.metadata.MD_Identifier; +// Branch-specific imports +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; +import static org.opengis.annotation.Specification.ISO_19115; import static org.apache.sis.internal.metadata.MetadataUtilities.valueIfDefined; @@@ -294,12 -280,14 +295,12 @@@ public class DefaultCoverageDescriptio @Deprecated public void setContentType(final CoverageContentType newValue) { checkWritePermission(valueIfDefined(attributeGroups)); - final Collection<CoverageContentType> newValues = LegacyPropertyAdapter.asCollection(newValue); + final Collection<CoverageContentType> newValues = CollectionsExt.singletonOrEmpty(newValue); - Collection<AttributeGroup> groups = attributeGroups; + Collection<DefaultAttributeGroup> groups = attributeGroups; if (groups != null) { - for (final AttributeGroup group : groups) { - if (group instanceof DefaultAttributeGroup) { - ((DefaultAttributeGroup) group).setContentTypes(newValues); - return; - } + for (final DefaultAttributeGroup group : groups) { + group.setContentTypes(newValues); + return; // Actually stop at the first instance. } } final DefaultAttributeGroup group = new DefaultAttributeGroup(); @@@ -326,11 -314,11 +327,11 @@@ @XmlElement(name = "dimension", namespace = LegacyNamespaces.GMD) public final Collection<RangeDimension> getDimensions() { if (!FilterByVersion.LEGACY_METADATA.accept()) return null; - return new LegacyPropertyAdapter<RangeDimension,AttributeGroup>(getAttributeGroups()) { + return new LegacyPropertyAdapter<RangeDimension,DefaultAttributeGroup>(getAttributeGroups()) { /** Stores a legacy value into the new kind of value. */ - @Override protected AttributeGroup wrap(final RangeDimension value) { + @Override protected DefaultAttributeGroup wrap(final RangeDimension value) { final DefaultAttributeGroup container = new DefaultAttributeGroup(); - container.setAttributes(asCollection(value)); + container.setAttributes(CollectionsExt.singletonOrEmpty(value)); return container; } @@@ -341,9 -329,9 +342,9 @@@ } /** Updates the legacy value in an existing instance of the new kind of value. */ - @Override protected boolean update(final AttributeGroup container, final RangeDimension value) { + @Override protected boolean update(final DefaultAttributeGroup container, final RangeDimension value) { if (container instanceof DefaultAttributeGroup) { - container.setAttributes(asCollection(value)); - ((DefaultAttributeGroup) container).setAttributes(CollectionsExt.singletonOrEmpty(value)); ++ container.setAttributes(CollectionsExt.singletonOrEmpty(value)); return true; } return false; diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java index a8e127e,1f17382..4aecef5 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java @@@ -24,17 -26,14 +26,18 @@@ import javax.xml.bind.annotation.XmlRoo import org.opengis.util.GenericName; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.content.FeatureCatalogueDescription; -import org.opengis.metadata.content.FeatureTypeInfo; import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.xml.LegacyNamespaces; - import org.apache.sis.internal.jaxb.lan.LocaleAdapter; + import org.apache.sis.internal.jaxb.lan.PT_Locale; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; + import org.apache.sis.internal.jaxb.lan.LocaleAndCharset; +// Branch-specific imports +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; ++import static org.opengis.annotation.Obligation.CONDITIONAL; +import static org.opengis.annotation.Specification.ISO_19115; import static org.apache.sis.internal.metadata.MetadataUtilities.valueIfDefined; @@@ -132,13 -131,9 +135,14 @@@ public class DefaultFeatureCatalogueDes if (object != null) { compliant = object.isCompliant(); includedWithDataset = object.isIncludedWithDataset(); - languages = copyCollection(object.getLanguages(), Locale.class); - locales = copyMap(object.getLocalesAndCharsets(), Locale.class); - featureTypes = copyCollection(object.getFeatureTypeInfo(), FeatureTypeInfo.class); featureCatalogueCitations = copyCollection(object.getFeatureCatalogueCitations(), Citation.class); + if (object instanceof DefaultFeatureCatalogueDescription) { ++ locales = copyMap(((DefaultFeatureCatalogueDescription) object).getLocalesAndCharsets(), Locale.class); + featureTypes = copyCollection(((DefaultFeatureCatalogueDescription) object).getFeatureTypeInfo(), DefaultFeatureTypeInfo.class); + } else { ++ setLanguages(copyCollection(object.getLanguages(), Locale.class)); + setFeatureTypes(object.getFeatureTypes()); + } } } @@@ -189,14 -184,42 +193,42 @@@ } /** - * Returns the language(s) used within the catalogue + * Returns the language(s) and character set(s) used within the catalogue. + * + * @return language(s) and character set(s) used within the catalogue. + * + * @since 1.0 + */ - @Override ++ @UML(identifier="locale", obligation=CONDITIONAL, specification=ISO_19115) + // @XmlElement at the end of this class. + public Map<Locale,Charset> getLocalesAndCharsets() { + return locales = nonNullMap(locales, Locale.class); + } + + /** + * Sets the language(s) and character set(s) used within the catalogue. + * + * @param newValues the new language(s) and character set(s) used within the catalogue. + * + * @since 1.0 + */ + public void setLocalesAndCharsets(final Map<? extends Locale, ? extends Charset> newValues) { + locales = writeMap(newValues, locales, Locale.class); + } + + /** + * Returns the language(s) used within the catalogue. * * @return language(s) used within the catalogue. + * + * @deprecated Replaced by {@code getLocalesAndCharsets().keySet()}. */ @Override - // @XmlElement at the end of this class. + @Deprecated + @Dependencies("getLocalesAndCharsets") + @XmlElement(name = "language", namespace = LegacyNamespaces.GMD) public Collection<Locale> getLanguages() { - return languages = nonNullCollection(languages, Locale.class); + return FilterByVersion.LEGACY_METADATA.accept() ? LocaleAndCharset.getLanguages(getLocalesAndCharsets()) : null; } /** diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java index 1cff463,8d8166c..7a71a65 --- 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 @@@ -36,14 -39,11 +37,17 @@@ import org.apache.sis.internal.jaxb.met import org.apache.sis.internal.jaxb.metadata.MD_Identifier; 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; +import static org.apache.sis.internal.metadata.MetadataUtilities.valueIfDefined; + +// Branch-specific imports +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; +import static org.opengis.annotation.Specification.ISO_19115; /** @@@ -232,9 -238,9 +244,9 @@@ public class DefaultMedium extends ISOM * @since 0.5 */ public void setDensity(final Double newValue) { - checkWritePermission(density); + checkWritePermission(valueIfDefined(densities)); if (ensurePositive(DefaultMedium.class, "density", true, newValue)) { - densities = writeCollection(LegacyPropertyAdapter.asCollection(newValue), densities, Double.class); - density = newValue; ++ densities = writeCollection(CollectionsExt.singletonOrEmpty(newValue), densities, Double.class); } } diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java index 53e9d92,8a8ad79..9a37a17 --- 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 @@@ -28,12 -30,13 +30,19 @@@ import org.opengis.metadata.citation.Ci 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; + ++// Branch-specific imports ++import org.opengis.annotation.UML; ++import static org.opengis.annotation.Obligation.CONDITIONAL; ++import static org.opengis.annotation.Specification.ISO_19115; ++import org.apache.sis.internal.jaxb.code.MD_CharacterSetCode; + /** * Information required to identify a dataset. @@@ -152,10 -152,9 +158,13 @@@ public class DefaultDataIdentification public DefaultDataIdentification(final DataIdentification object) { super(object); if (object != null) { - languages = copyCollection(object.getLanguages(), Locale.class); - characterSets = copyCollection(object.getCharacterSets(), CharacterSet.class); - environmentDescription = object.getEnvironmentDescription(); - supplementalInformation = object.getSupplementalInformation(); - locales = copyMap(object.getLocalesAndCharsets(), Locale.class); ++ if (object instanceof DefaultDataIdentification) { ++ locales = copyMap(((DefaultDataIdentification) object).getLocalesAndCharsets(), Locale.class); ++ } else { ++ setLanguages(object.getLanguages()); ++ } + environmentDescription = object.getEnvironmentDescription(); + supplementalInformation = object.getSupplementalInformation(); } } @@@ -185,6 -184,34 +194,34 @@@ } /** + * Returns the language(s) and character set(s) used within the dataset. + * The first element in iteration order is the default language. + * All other elements, if any, are alternate language(s) used within the resource. + * + * @return language(s) and character set(s) used within the dataset. + * + * @since 1.0 + */ - @Override ++ @UML(identifier="defaultLocale+otherLocale", obligation=CONDITIONAL, specification=ISO_19115) + // @XmlElement at the end of this class. + public Map<Locale,Charset> getLocalesAndCharsets() { + return locales = nonNullMap(locales, Locale.class); + } + + /** + * Sets the language(s) and character set(s) used within the dataset. + * The first element in iteration order should be the default language. + * All other elements, if any, are alternate language(s) used within the resource. + * + * @param newValues the new language(s) and character set(s) used within the dataset. + * + * @since 1.0 + */ + public void setLocalesAndCharsets(final Map<? extends Locale, ? extends Charset> newValues) { + locales = writeMap(newValues, locales, Locale.class); + } + + /** * Returns the language(s) used within the resource. * The first element in iteration order shall be the default language. * All other elements, if any, are alternate language(s) used within the resource. @@@ -219,11 -252,15 +262,15 @@@ * </div> * * @return character coding standard(s) used. + * + * @deprecated Replaced by {@code getLocalesAndCharsets().values()}. */ @Override - @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) + @Deprecated + @Dependencies("getLocalesAndCharsets") + // @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()); ++ return getLocalesAndCharsets().values().stream().map(MD_CharacterSetCode::fromCharset).collect(Collectors.toSet()); } /** diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java index e44afd0,f3846a5..570360e --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java @@@ -120,9 -121,9 +120,8 @@@ @XmlJavaTypeAdapter(GO_DateTime.class), @XmlJavaTypeAdapter(GO_GenericName.class), @XmlJavaTypeAdapter(MD_AggregateInformation.class), - @XmlJavaTypeAdapter(MD_AssociatedResource.class), @XmlJavaTypeAdapter(MD_BrowseGraphic.class), @XmlJavaTypeAdapter(MD_CharacterSetCode.class), - @XmlJavaTypeAdapter(MD_CharacterSetLegacy.class), @XmlJavaTypeAdapter(MD_Constraints.class), @XmlJavaTypeAdapter(MD_DataIdentification.class), @XmlJavaTypeAdapter(MD_Format.class), @@@ -137,8 -138,8 +136,7 @@@ @XmlJavaTypeAdapter(MD_StandardOrderProcess.class), @XmlJavaTypeAdapter(MD_TopicCategoryCode.class), @XmlJavaTypeAdapter(MD_Usage.class), - @XmlJavaTypeAdapter(PT_Locale.class), @XmlJavaTypeAdapter(SV_CoupledResource.class), - @XmlJavaTypeAdapter(SV_CouplingType.class), @XmlJavaTypeAdapter(SV_OperationMetadata.class), @XmlJavaTypeAdapter(SV_OperationChainMetadata.class), @XmlJavaTypeAdapter(SV_Parameter.class), diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java index fa7838f,a655627..a136236 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java @@@ -39,11 -39,8 +39,12 @@@ import org.apache.sis.internal.metadata import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.xml.LegacyNamespaces; + import org.apache.sis.internal.util.CollectionsExt; +// Branch-specific imports +import org.opengis.annotation.UML; +import static org.opengis.annotation.Obligation.OPTIONAL; +import static org.opengis.annotation.Specification.ISO_19115; import static org.apache.sis.internal.metadata.MetadataUtilities.valueIfDefined; diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java index b68246e,7aee4f8..ef20f70 --- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java +++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java @@@ -21,11 -21,9 +21,12 @@@ import javax.xml.bind.annotation.XmlTyp import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import org.opengis.metadata.extent.Extent; -import org.opengis.metadata.maintenance.Scope; +import org.opengis.metadata.quality.Scope; import org.opengis.metadata.maintenance.ScopeCode; import org.opengis.metadata.maintenance.ScopeDescription; +import org.apache.sis.internal.metadata.Dependencies; +import org.apache.sis.internal.metadata.LegacyPropertyAdapter; ++import org.apache.sis.internal.util.CollectionsExt; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.xml.Namespaces; @@@ -201,34 -190,6 +202,34 @@@ public class DefaultScope extends ISOMe } /** + * Information about the spatial, vertical and temporal extent of the data specified by the scope. + * This method fetches the value from the {@linkplain #getExtents() extents} collection. + * + * @return Information about the extent of the data, or {@code null}. + * + * @deprecated As of ISO 19115:2014, replaced by {@link #getExtents()}. + */ + @Override + @Deprecated + @Dependencies("getExtents") + public Extent getExtent() { + return LegacyPropertyAdapter.getSingleton(getExtents(), Extent.class, null, DefaultScope.class, "getExtent"); + } + + /** + * Sets information about the spatial, vertical and temporal extent of the data specified by the scope. + * This method stores the value in the {@linkplain #setExtents(Collection) extents} collection. + * + * @param newValue The new extent. + * + * @deprecated As of ISO 19115:2014, replaced by {@link #setExtents(Collection)}. + */ + @Deprecated + public void setExtent(final Extent newValue) { - setExtents(LegacyPropertyAdapter.asCollection(newValue)); ++ setExtents(CollectionsExt.singletonOrEmpty(newValue)); + } + + /** * Returns detailed descriptions about the level of the data specified by the scope. * * @return detailed description about the level of the data. diff --cc core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java index 08ad74a,732cb5b..6fce10a --- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java +++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/PropertyAccessorTest.java @@@ -221,11 -223,10 +224,10 @@@ public final strictfp class PropertyAcc Identification.class, "getDescriptiveKeywords", "descriptiveKeywords", "descriptiveKeywords", "Descriptive keywords", Keywords[].class, Identification.class, "getResourceSpecificUsages", "resourceSpecificUsages", "resourceSpecificUsage", "Resource specific usages", Usage[].class, Identification.class, "getResourceConstraints", "resourceConstraints", "resourceConstraints", "Resource constraints", Constraints[].class, - Identification.class, "getAssociatedResources", "associatedResources", "associatedResource", "Associated resources", AssociatedResource[].class, + AbstractIdentification.class, "getAssociatedResources", "associatedResources", "associatedResource", "Associated resources", DefaultAssociatedResource[].class, - DataIdentification.class, "getLanguages", "languages", "language", "Languages", Locale[].class, - DataIdentification.class, "getCharacterSets", "characterSets", "characterSet", "Character sets", CharacterSet[].class, DataIdentification.class, "getEnvironmentDescription", "environmentDescription", "environmentDescription", "Environment description", InternationalString.class, - DataIdentification.class, "getSupplementalInformation", "supplementalInformation", "supplementalInformation", "Supplemental information", InternationalString.class); + DataIdentification.class, "getSupplementalInformation", "supplementalInformation", "supplementalInformation", "Supplemental information", InternationalString.class, - DataIdentification.class, "getLocalesAndCharsets", "localesAndCharsets", "defaultLocale+otherLocale", "Locales and charsets", Map.class); ++ DefaultDataIdentification.class, "getLocalesAndCharsets", "localesAndCharsets", "defaultLocale+otherLocale", "Locales and charsets", Map.class); } /** diff --cc core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/api-changes.properties index 8efbceb,8476d40..916a754 --- a/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/api-changes.properties +++ b/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/api-changes.properties @@@ -22,35 -22,3 +22,36 @@@ # with the changes in the international standard. The UML identifiers of added methods are "number" # and "numberType" respectively. # +org.opengis.metadata.citation.Citation=-getCollectiveTitle +getGraphics:graphic +getOnlineResources:onlineResource +org.opengis.metadata.citation.Contact=-getAddress +getAddresses:address +getContactType:contactType -getOnlineResource +getOnlineResources:onlineResource -getPhone +getPhones:phone +org.opengis.metadata.citation.OnlineResource=+getProtocolRequest:protocolRequest +org.opengis.metadata.citation.ResponsibleParty=-getContactInfo -getIndividualName -getOrganisationName -getPositionName +org.opengis.metadata.citation.Telephone=-getFacsimiles +getNumber:number +getNumberType:numberType -getVoices +org.opengis.metadata.constraint.Constraints=+getConstraintApplicationScope:constraintApplicationScope +getGraphics:graphic +getReferences:reference +getReleasability:releasability +getResponsibleParties:responsibleParty +org.opengis.metadata.content.Band=+getBoundMax:boundMax +getBoundMin:boundMin +getBoundUnits:boundUnits +org.opengis.metadata.content.CoverageDescription=+getAttributeGroups:attributeGroup -getContentType -getDimensions +getProcessingLevelCode:processingLevelCode - org.opengis.metadata.content.FeatureCatalogueDescription=+getFeatureTypeInfo:featureTypes -getFeatureTypes ++org.opengis.metadata.content.FeatureCatalogueDescription=+getFeatureTypeInfo:featureTypes -getFeatureTypes -getLanguages +getLocalesAndCharsets:locale +org.opengis.metadata.content.RangeDimension=+getDescription:description -getDescriptor +getNames:name +org.opengis.metadata.distribution.DigitalTransferOptions=+getDistributionFormats:distributionFormat -getOffLine +getOffLines:offLine +getTransferFrequency:transferFrequency +org.opengis.metadata.distribution.Distribution=+getDescription:description +org.opengis.metadata.distribution.Format=+getFormatSpecificationCitation:formatSpecificationCitation +getMedia:medium -getName -getSpecification -getVersion +org.opengis.metadata.distribution.Medium=-getDensities +getDensity:density +getIdentifier:identifier +org.opengis.metadata.distribution.StandardOrderProcess=+getOrderOptionsType:orderOptionsType +getOrderOptions:orderOptions +org.opengis.metadata.ExtendedElementInformation=-getDomainCode +getRationale:rationale -getRationales -getShortName +org.opengis.metadata.extent.SpatialTemporalExtent=+getVerticalExtent:verticalExtent +org.opengis.metadata.identification.AggregateInformation=-getAggregateDataSetIdentifier -getAggregateDataSetName +getMetadataReference:metadataReference +getName:name +org.opengis.metadata.identification.BrowseGraphic=+getImageConstraints:imageContraints +getLinkages:linkage ++org.opengis.metadata.identification.DataIdentification=-getCharacterSets -getLanguages +getLocalesAndCharsets:defaultLocale+otherLocale +org.opengis.metadata.identification.Identification=+getAdditionalDocumentations:additionalDocumentation -getAggregationInfo +getAssociatedResources:associatedResource +getExtents:extent +getProcessingLevel:processingLevel +getSpatialRepresentationTypes:spatialRepresentationType +getSpatialResolutions:spatialResolution ~+getTemporalResolutions:temporalResolution +getTopicCategories:topicCategory +org.opengis.metadata.identification.Keywords=+getKeywordClass:keywordClass +org.opengis.metadata.identification.Resolution=+getAngularDistance:angularDistance +getLevelOfDetail:levelOfDetail +getVertical:vertical +org.opengis.metadata.identification.ServiceIdentification=+getAccessProperties:accessProperties +getContainsChain:containsChain +getContainsOperations:containsOperations +getCoupledResources:coupledResource +getCouplingType:couplingType +getOperatedDatasets:operatedDataset +getOperatesOn:operatesOn +getProfiles:profile +getServiceStandards:serviceStandard +getServiceType:serviceType +getServiceTypeVersions:serviceTypeVersion +org.opengis.metadata.identification.Usage=+getAdditionalDocumentation:additionalDocumentation +getIdentifiedIssues:identifiedIssues +getResponses:response +org.opengis.metadata.Identifier=+getCodeSpace:codeSpace +getDescription:description +getVersion:version +org.opengis.metadata.lineage.Lineage=+getAdditionalDocumentation:additionalDocumentation +getScope:scope +org.opengis.metadata.lineage.ProcessStep=-getDate +getReferences:reference +getScope:scope +org.opengis.metadata.lineage.Source=-getScaleDenominator +getScope:scope -getSourceExtents +getSourceMetadata:sourceMetadata +getSourceSpatialResolution:sourceSpatialResolution +org.opengis.metadata.maintenance.MaintenanceInformation=-getDateOfNextUpdate +getMaintenanceDates:maintenanceDate +getMaintenanceScopes:maintenanceScope -getUpdateScopeDescriptions -getUpdateScopes - org.opengis.metadata.Metadata=+getAlternativeMetadataReferences:alternativeMetadataReference -getCharacterSet +getCharacterSets:characterSet -getDataSetUri -getDateStamp +getDateInfo:dateInfo -getFileIdentifier -getHierarchyLevelNames -getHierarchyLevels -getLanguage +getLanguages:defaultLocale+otherLocale -getLocales +getMetadataIdentifier:metadataIdentifier +getMetadataLinkages:metadataLinkage +getMetadataProfiles:metadataProfile +getMetadataScopes:metadataScope -getMetadataStandardNa [...] ++org.opengis.metadata.Metadata=+getAlternativeMetadataReferences:alternativeMetadataReference -getCharacterSet -getCharacterSets -getDataSetUri -getDateStamp +getDateInfo:dateInfo -getFileIdentifier -getHierarchyLevelNames -getHierarchyLevels -getLanguage -getLanguages -getLocales +getLocalesAndCharsets:defaultLocale+otherLocale +getMetadataIdentifier:metadataIdentifier +getMetadataLinkages:metadataLinkage +getMetadataProfiles:metadataProfile +getMetadataScopes:metadataScope -getMetadata [...] +org.opengis.metadata.quality.Scope=-getExtent +getExtents:extent +org.opengis.metadata.spatial.Dimension=+getDimensionDescription:dimensionDescription +getDimensionTitle:dimensionTitle diff --cc core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java index 4071879,dfff391..8ed26a8 --- a/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java +++ b/core/sis-referencing/src/test/java/org/apache/sis/test/integration/MetadataTest.java @@@ -88,9 -88,7 +88,8 @@@ import org.junit.Test import static org.apache.sis.test.Assert.*; import static org.apache.sis.test.TestUtilities.getSingleton; - import static org.apache.sis.metadata.iso.DefaultMetadataTest.REGRESSION; +import org.apache.sis.internal.geoapi.evolution.UnsupportedCodeList; /** * Tests XML (un)marshalling of a metadata object containing various elements @@@ -484,13 -464,10 +478,10 @@@ public strictfp class MetadataTest exte @Test public void testMetadataWithVerticalCRS() throws JAXBException { final Metadata metadata = unmarshalFile(Metadata.class, VERTICAL_CRS_XML); - if (REGRESSION) { - ((DefaultMetadata) metadata).setCharacterSet(CharacterSet.UTF_8); - } - assertEquals("fileIdentifier", "20090901", metadata.getMetadataIdentifier().getCode()); - assertEquals("language", Locale.ENGLISH, getSingleton(metadata.getLocalesAndCharsets().keySet())); - assertEquals("characterSet", StandardCharsets.UTF_8, getSingleton(metadata.getLocalesAndCharsets().values())); - assertEquals("dateStamp", xmlDate("2014-01-04 00:00:00"), getSingleton(metadata.getDateInfo()).getDate()); + assertEquals("fileIdentifier", "20090901", metadata.getFileIdentifier()); + assertEquals("language", Locale.ENGLISH, metadata.getLanguage()); + assertEquals("characterSet", CharacterSet.UTF_8, metadata.getCharacterSet()); + assertEquals("dateStamp", xmlDate("2014-01-04 00:00:00"), metadata.getDateStamp()); /* * <gmd:contact> * <gmd:CI_ResponsibleParty> diff --cc storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java index e23f541,bc72797..ab742f1 --- a/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java +++ b/storage/sis-storage/src/test/java/org/apache/sis/internal/storage/xml/StoreTest.java @@@ -97,15 -96,16 +96,14 @@@ public final strictfp class StoreTest e metadata = store.getMetadata(); assertSame("Expected cached value.", metadata, store.getMetadata()); } - final Responsibility resp = getSingleton(metadata.getContacts()); - final Party party = getSingleton(resp.getParties()); - final Contact contact = getSingleton(party.getContactInfo()); - final OnlineResource resource = getSingleton(contact.getOnlineResources()); + final ResponsibleParty resp = getSingleton(metadata.getContacts()); + final Contact contact = resp.getContactInfo(); + final OnlineResource resource = contact.getOnlineResource(); - assertInstanceOf("party", Organisation.class, party); - assertEquals(Locale.ENGLISH, getSingleton(metadata.getLocalesAndCharsets().keySet())); - assertEquals(StandardCharsets.UTF_8, getSingleton(metadata.getLocalesAndCharsets().values())); + assertEquals(Locale.ENGLISH, metadata.getLanguage()); - if (!REGRESSION) - assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet()); ++ assertEquals(CharacterSet.UTF_8, metadata.getCharacterSet()); assertEquals(Role.PRINCIPAL_INVESTIGATOR, resp.getRole()); - assertEquals("Apache SIS", String.valueOf(party.getName())); + assertEquals("Apache SIS", String.valueOf(resp.getOrganisationName())); assertEquals("http://sis.apache.org", String.valueOf(resource.getLinkage())); assertEquals(OnLineFunction.INFORMATION, resource.getFunction()); }
