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 dc69af044f679a4a8cda3a85ddcb4687c18b45c5 Merge: 8164ff4 6640cc3 Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu May 2 11:45:25 2019 +0200 Merge branch 'geoapi-4.0' into geoapi-3.1 but without changing the Medium.name property type for compatibility reason. .../sis/internal/jaxb/code/MD_MediumNameCode.java | 2 +- .../sis/internal/metadata/legacy/package-info.java | 26 ++++++++++ .../metadata/iso/distribution/DefaultMedium.java | 56 ++++++++++++++++++++-- 3 files changed, 78 insertions(+), 6 deletions(-) diff --cc core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java index b301b20,fdcbfc4..d3abded --- 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 @@@ -26,18 -26,19 +26,21 @@@ import javax.xml.bind.annotation.XmlRoo import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.metadata.Identifier; + import org.opengis.metadata.citation.Citation; import org.opengis.metadata.distribution.Medium; +import org.opengis.metadata.distribution.MediumName; import org.opengis.metadata.distribution.MediumFormat; import org.apache.sis.measure.ValueRange; - import org.apache.sis.metadata.TitleProperty; import org.apache.sis.metadata.iso.ISOMetadata; ++import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.internal.jaxb.gco.GO_Real; import org.apache.sis.internal.jaxb.FilterByVersion; - import org.apache.sis.internal.xml.LegacyNamespaces; + import org.apache.sis.internal.jaxb.metadata.CI_Citation; import org.apache.sis.internal.jaxb.metadata.MD_Identifier; -import org.apache.sis.internal.metadata.legacy.MediumName; + import org.apache.sis.internal.xml.LegacyNamespaces; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; ++import org.apache.sis.internal.util.CodeLists; import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive; @@@ -70,7 -71,7 +73,7 @@@ @XmlType(name = "MD_Medium_Type", propOrder = { "identifier", // New in ISO 19115-3 "name", - "legacyName", // From ISO 19115:2003 ++ "newName", // From ISO 19115:2014 "density", "densities", "densityUnits", @@@ -179,23 -180,21 +182,31 @@@ public class DefaultMedium extends ISOM /** * Returns the name of the medium on which the resource can be received. * ++ * <div class="warning"><b>Upcoming API change</b><br> ++ * {@link MediumName} may be replaced by {@link Citation} in GeoAPI 4.0. ++ * </div> ++ * * @return name of the medium, or {@code null}. + * + * @see <a href="https://issues.apache.org/jira/browse/SIS-389">SIS-389</a> + * */ @Override -- @XmlElement(name = "name") - @XmlJavaTypeAdapter(CI_Citation.Since2014.class) - public Citation getName() { - return name; ++ @XmlElement(name = "name", namespace = LegacyNamespaces.GMD) + public MediumName getName() { - return name; ++ return FilterByVersion.LEGACY_METADATA.accept() ? name : null; } /** * Sets the name of the medium on which the resource can be received. * ++ * <div class="warning"><b>Upcoming API change</b><br> ++ * {@link MediumName} may be replaced by {@link Citation} in GeoAPI 4.0. ++ * </div> ++ * * @param newValue the new name. */ - public void setName(final Citation newValue) { + public void setName(final MediumName newValue) { checkWritePermission(name); name = newValue; } @@@ -389,4 -388,33 +400,39 @@@ public void setIdentifier(final Identifier newValue) { super.setIdentifier(newValue); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * Returns the medium name as a code list. + */ - @XmlElement(name = "name", namespace = LegacyNamespaces.GMD) - private MediumName getLegacyName() { - return FilterByVersion.LEGACY_METADATA.accept() ? MediumName.castOrWrap(name) : null; ++ @XmlElement(name = "name") ++ @XmlJavaTypeAdapter(CI_Citation.Since2014.class) ++ private Citation getNewName() { ++ return (name != null) ? new DefaultCitation(name.name()) : null; + } + + /** + * Sets the name of the medium on which the resource can be received. + */ - private void setLegacyName(final MediumName newValue) { - name = newValue; ++ private void setNewName(final Citation newValue) { ++ if (newValue != null) { ++ final InternationalString title = newValue.getTitle(); ++ if (title != null) { ++ name = CodeLists.forName(MediumName.class, title.toString(), false); ++ } ++ } + } }
