sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Update for GeoAPI change: Medium.name property type changed from MediumName to Citation. https://issues.apache.org/jira/browse/SIS-389
Date Sat, 04 May 2019 23:33:29 GMT
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 6640cc33b23b59781359f91e826f62a47c4bfbfb
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu May 2 11:00:32 2019 +0200

    Update for GeoAPI change: Medium.name property type changed from MediumName to Citation.
    https://issues.apache.org/jira/browse/SIS-389
---
 .../org/apache/sis/internal/book/GEOAPI.lst        |   1 -
 .../resources/org/apache/sis/internal/book/OGC.lst |   1 -
 .../sis/internal/jaxb/code/MD_MediumNameCode.java  |   4 +-
 .../sis/internal/metadata/legacy/MediumName.java   | 207 +++++++++++++++++++++
 .../sis/internal/metadata/legacy/package-info.java |  26 +++
 .../metadata/iso/distribution/DefaultMedium.java   |  50 +++--
 .../metadata/iso/distribution/package-info.java    |   2 -
 .../apache/sis/metadata/iso/AllMetadataTest.java   |   2 +-
 8 files changed, 275 insertions(+), 18 deletions(-)

diff --git a/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
b/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
index 1959531..fa371b7 100644
--- a/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
+++ b/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/GEOAPI.lst
@@ -123,7 +123,6 @@ MathTransform
 MathTransform2D
 Medium
 MediumFormat
-MediumName
 Metadata
 MetadataExtensionInformation
 MetadataScope
diff --git a/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
b/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
index 9aec1eb..771ccac 100644
--- a/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
+++ b/core/sis-build-helper/src/main/resources/org/apache/sis/internal/book/OGC.lst
@@ -151,7 +151,6 @@ MD_MaintenanceFrequencyCode
 MD_MaintenanceInformation
 MD_Medium
 MD_MediumFormatCode
-MD_MediumNameCode
 MD_Metadata
 MD_MetadataExtensionInformation
 MD_MetadataScope
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_MediumNameCode.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_MediumNameCode.java
index 0f372e0..b2f18be 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_MediumNameCode.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/MD_MediumNameCode.java
@@ -17,14 +17,14 @@
 package org.apache.sis.internal.jaxb.code;
 
 import javax.xml.bind.annotation.XmlElement;
-import org.opengis.metadata.distribution.MediumName;
 import org.apache.sis.internal.jaxb.cat.CodeListAdapter;
 import org.apache.sis.internal.jaxb.cat.CodeListUID;
 import org.apache.sis.internal.xml.LegacyNamespaces;
+import org.apache.sis.internal.metadata.legacy.MediumName;
 
 
 /**
- * JAXB adapter for {@link MediumName}
+ * JAXB adapter for legacy {@link MediumName}
  * in order to wrap the value in an XML element as specified by ISO 19115-3 standard.
  * See package documentation for more information about the handling of {@code CodeList}
in ISO 19115-3.
  *
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/MediumName.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/MediumName.java
new file mode 100644
index 0000000..09a7904
--- /dev/null
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/MediumName.java
@@ -0,0 +1,207 @@
+/*
+ * 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.internal.metadata.legacy;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import org.opengis.annotation.UML;
+import org.opengis.metadata.Identifier;
+import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.citation.CitationDate;
+import org.opengis.metadata.citation.OnlineResource;
+import org.opengis.metadata.citation.PresentationForm;
+import org.opengis.metadata.citation.Responsibility;
+import org.opengis.metadata.citation.Series;
+import org.opengis.metadata.identification.BrowseGraphic;
+import org.opengis.util.CodeList;
+import org.opengis.util.InternationalString;
+import org.apache.sis.internal.util.CodeLists;
+import org.apache.sis.util.iso.Types;
+
+import static org.opengis.annotation.Obligation.*;
+import static org.opengis.annotation.Specification.*;
+
+
+/**
+ * Name of the medium as defined in legacy ISO 19115:2003.
+ * In more recent specification, this code list has been replaced by a citation.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 2.0
+ *
+ * @see <a href="https://issues.apache.org/jira/browse/SIS-389">SIS-389</a>
+ * @see <a href="https://github.com/opengeospatial/geoapi/issues/14">GeoAPI issue #14</a>
+ *
+ * @since 2.0
+ * @module
+ */
+@UML(identifier="MD_MediumNameCode", specification=ISO_19115, version=2003)
+public final class MediumName extends CodeList<MediumName> implements Citation {
+    /** Serial number for compatibility with different versions. */
+    private static final long serialVersionUID = 7157038832444373933L;
+
+    /** List of all enumerations of this type. */
+    private static final List<MediumName> VALUES = new ArrayList<>(18);
+
+    /** Read-only optical disk. */
+    @UML(identifier="cdRom", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CD_ROM = new MediumName("CD_ROM");
+
+    /** Digital versatile disk. */
+    @UML(identifier="dvd", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName DVD = new MediumName("DVD");
+
+    /** Digital versatile disk digital versatile disk, read only. */
+    @UML(identifier="dvdRom", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName DVD_ROM = new MediumName("DVD_ROM");
+
+    /** 3½ inch magnetic disk. */
+    @UML(identifier="3halfInchFloppy", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName FLOPPY_3_HALF_INCH = new MediumName("FLOPPY_3_HALF_INCH");
+
+    /** 5¼ inch magnetic disk. */
+    @UML(identifier="5quarterInchFloppy", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName FLOPPY_5_QUARTER_INCH = new MediumName("FLOPPY_5_QUARTER_INCH");
+
+    /** 7 track magnetic tape. */
+    @UML(identifier="7trackTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName TAPE_7_TRACK = new MediumName("TAPE_7_TRACK");
+
+    /** 9 track magnetic tape. */
+    @UML(identifier="9trackTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName TAPE_9_TRACK = new MediumName("TAPE_9_TRACK");
+
+    /** 3480 cartridge tape drive. */
+    @UML(identifier="3480Cartridge", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_3480 = new MediumName("CARTRIDGE_3480");
+
+    /** 3490 cartridge tape drive. */
+    @UML(identifier="3490Cartridge", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_3490 = new MediumName("CARTRIDGE_3490");
+
+    /** 3580 cartridge tape drive. */
+    @UML(identifier="3580Cartridge", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_3580 = new MediumName("CARTRIDGE_3580");
+
+    /** 4 millimetre magnetic tape. */
+    @UML(identifier="4mmCartridgeTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_TAPE_4mm = new MediumName("CARTRIDGE_TAPE_4mm");
+
+    /** 8 millimetre magnetic tape. */
+    @UML(identifier="8mmCartridgeTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_TAPE_8mm = new MediumName("CARTRIDGE_TAPE_8mm");
+
+    /** ¼ inch magnetic tape. */
+    @UML(identifier="1quarterInchCartridgeTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName CARTRIDGE_TAPE_1_QUARTER_INCH = new MediumName("CARTRIDGE_TAPE_1_QUARTER_INCH");
+
+    /** Half inch cartridge streaming tape drive. */
+    @UML(identifier="digitalLinearTape", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName DIGITAL_LINEAR_TAPE = new MediumName("DIGITAL_LINEAR_TAPE");
+
+    /** Direct computer linkage. */
+    @UML(identifier="onLine", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName ON_LINE = new MediumName("ON_LINE");
+
+    /** Linkage through a satellite communication system. */
+    @UML(identifier="satellite", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName SATELLITE = new MediumName("SATELLITE");
+
+    /** Communication through a telephone network. */
+    @UML(identifier="telephoneLink", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName TELEPHONE_LINK = new MediumName("TELEPHONE_LINK");
+
+    /** Pamphlet or leaflet giving descriptive information. */
+    @UML(identifier="hardcopy", obligation=CONDITIONAL, specification=ISO_19115)
+    public static final MediumName HARDCOPY = new MediumName("HARDCOPY");
+
+    /** Constructs an element of the given name. */
+    private MediumName(final String name) {
+        super(name, VALUES);
+    }
+
+    /**
+     * Returns the list of {@code MediumName}s.
+     *
+     * @return the list of codes declared in the current JVM.
+     */
+    public static MediumName[] values() {
+        synchronized (VALUES) {
+            return VALUES.toArray(new MediumName[VALUES.size()]);
+        }
+    }
+
+    /**
+     * Returns the list of codes of the same kind than this code list element.
+     *
+     * @return all code {@linkplain #values() values} for this code list.
+     */
+    @Override
+    public MediumName[] family() {
+        return values();
+    }
+
+    /**
+     * Returns the medium name that matches the given string, or {@code null} if none match
it.
+     * Contrarily to non-deprecated code list, this method does not create a new code if
none match the given name.
+     *
+     * @param  code  the name of the code to fetch or to create.
+     * @return a code matching the given name, or {@code null}.
+     */
+    public static MediumName valueOf(final String code) {
+        return CodeLists.forName(MediumName.class, code, false);
+    }
+
+    /**
+     * Returns the given citation as a medium name code, or {@code null} if none.
+     *
+     * @param  citation  the medium name to return as a citation, or {@code null}.
+     * @return the code as a citation, or {@code null}.
+     */
+    public static MediumName castOrWrap(final Citation citation) {
+        if (citation instanceof MediumName) {
+            return (MediumName) citation;
+        }
+        if (citation != null) {
+            final InternationalString title = citation.getTitle();
+            if (title != null) {
+                return valueOf(title.toString());
+            }
+        }
+        return null;
+    }
+
+    /** {@link Citation} methods provided for transition from legacy code list to new citation
type. */
+    @Override public InternationalString             getTitle()                   {return
Types.toInternationalString(name());}
+    @Override public Collection<InternationalString> getAlternateTitles()         {return
Collections.emptySet();}
+    @Override public Collection<CitationDate>        getDates()                   {return
Collections.emptySet();}
+    @Override public InternationalString             getEdition()                 {return
null;}
+    @Override public Date                            getEditionDate()             {return
null;}
+    @Override public Collection<Identifier>          getIdentifiers()             {return
Collections.emptySet();}
+    @Override public Collection<Responsibility>      getCitedResponsibleParties() {return
Collections.emptySet();}
+    @Override public Collection<PresentationForm>    getPresentationForms()       {return
Collections.emptySet();}
+    @Override public Series                          getSeries()                  {return
null;}
+    @Override public Collection<InternationalString> getOtherCitationDetails()    {return
Collections.emptySet();}
+    @Override @Deprecated public InternationalString getCollectiveTitle()         {return
null;}
+    @Override public String                          getISBN()                    {return
null;}
+    @Override public String                          getISSN()                    {return
null;}
+    @Override public Collection<OnlineResource>      getOnlineResources()         {return
Collections.emptySet();}
+    @Override public Collection<BrowseGraphic>       getGraphics()                {return
Collections.emptySet();}
+}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/package-info.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/package-info.java
new file mode 100644
index 0000000..355c2de
--- /dev/null
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/legacy/package-info.java
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+
+/**
+ * Metadata objects from legacy standards.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.0
+ * @since   1.0
+ * @module
+ */
+package org.apache.sis.internal.metadata.legacy;
diff --git 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
index b301b20..fdcbfc4 100644
--- 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,16 +26,17 @@ import javax.xml.bind.annotation.XmlRootElement;
 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.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;
 
@@ -67,10 +68,10 @@ import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
  * @since   0.3
  * @module
  */
-@TitleProperty(name = "name")
 @XmlType(name = "MD_Medium_Type", propOrder = {
     "identifier",           // New in ISO 19115-3
     "name",
+    "legacyName",           // From ISO 19115:2003
     "density",
     "densities",
     "densityUnits",
@@ -83,12 +84,12 @@ public class DefaultMedium extends ISOMetadata implements Medium {
     /**
      * Serial number for inter-operability with different versions.
      */
-    private static final long serialVersionUID = 2657393801067168091L;
+    private static final long serialVersionUID = -460355952171320089L;
 
     /**
      * Name of the medium on which the resource can be received.
      */
-    private MediumName name;
+    private Citation name;
 
     /**
      * Density at which the data is recorded.
@@ -180,13 +181,11 @@ public class DefaultMedium extends ISOMetadata implements Medium {
      * Returns the name of the medium on which the resource can be received.
      *
      * @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")
-    public MediumName getName() {
+    @XmlJavaTypeAdapter(CI_Citation.Since2014.class)
+    public Citation getName() {
         return name;
     }
 
@@ -195,7 +194,7 @@ public class DefaultMedium extends ISOMetadata implements Medium {
      *
      * @param  newValue  the new name.
      */
-    public void setName(final MediumName newValue) {
+    public void setName(final Citation newValue) {
         checkWritePermission(name);
         name = newValue;
     }
@@ -389,4 +388,33 @@ public class DefaultMedium extends ISOMetadata implements Medium {
     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;
+    }
+
+    /**
+     * Sets the name of the medium on which the resource can be received.
+     */
+    private void setLegacyName(final MediumName newValue) {
+        name = newValue;
+    }
 }
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
index ac49f5d..5a1f02c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java
@@ -38,7 +38,6 @@
  * {@code  ├─} {@linkplain org.apache.sis.metadata.iso.distribution.DefaultDigitalTransferOptions
Digital transfer options}<br>
  * {@code  └─} {@linkplain org.apache.sis.metadata.iso.distribution.DefaultDataFile
              Data file}<br>
  * {@linkplain org.opengis.util.CodeList Code list}<br>
- * {@code  ├─} {@linkplain org.opengis.metadata.distribution.MediumName   Medium name}<br>
  * {@code  └─} {@linkplain org.opengis.metadata.distribution.MediumFormat Medium format}<br>
  * </td><td class="sep" style="width: 50%; white-space: nowrap">
  *                     {@linkplain org.apache.sis.metadata.iso.distribution.DefaultDistribution
          Distribution}<br>
@@ -47,7 +46,6 @@
  * {@code  │   └─}     {@linkplain org.apache.sis.metadata.iso.distribution.DefaultStandardOrderProcess
  Standard order process}<br>
  * {@code  └─}         {@linkplain org.apache.sis.metadata.iso.distribution.DefaultDigitalTransferOptions
Digital transfer options}<br>
  * {@code      └─}     {@linkplain org.apache.sis.metadata.iso.distribution.DefaultMedium
                Medium}<br>
- * {@code          ├─} {@linkplain org.opengis.metadata.distribution.MediumName
                          Medium name} «code list»<br>
  * {@code          └─} {@linkplain org.opengis.metadata.distribution.MediumFormat
                        Medium format} «code list»<br>
  *                     {@linkplain org.apache.sis.metadata.iso.distribution.DefaultDataFile
              Data file}<br>
  * </td></tr></table>
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
index 743974b..b8ea6f0 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/AllMetadataTest.java
@@ -118,7 +118,7 @@ public final strictfp class AllMetadataTest extends PropertyConsistencyCheck
{
             org.opengis.metadata.distribution.Format.class,
             org.opengis.metadata.distribution.Medium.class,
             org.opengis.metadata.distribution.MediumFormat.class,
-            org.opengis.metadata.distribution.MediumName.class,
+            org.apache.sis.internal.metadata.legacy.MediumName.class,
             org.opengis.metadata.distribution.StandardOrderProcess.class,
             org.opengis.metadata.extent.BoundingPolygon.class,
             org.opengis.metadata.extent.Extent.class,


Mime
View raw message