sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1820526 - in /sis/branches/ISO-19115-3/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/ ...
Date Mon, 08 Jan 2018 04:12:36 GMT
Author: desruisseaux
Date: Mon Jan  8 04:12:36 2018
New Revision: 1820526

URL: http://svn.apache.org/viewvc?rev=1820526&view=rev
Log:
Skip commit e212fa862cd16c969cb2cd3c726a81ed8fef725d (XSLT experiment)
Adaptation of commit 3d3bb1b0e47fcd6b4985943a4f33e307dcc59ab6 from Image Matter
(got the first ISO 19115-3 round trip test working).
We omit the ISOTestUtils class - instead we define the expected XML directly in the test.

The project at this revision can be built but is known to have test failures.
Tests will pass only after we completed the port of all ISO 19115-3 work.

Modified:
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/CI_PresentationFormCode.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation
(legacy).xml
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation.xml
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/CI_PresentationFormCode.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/CI_PresentationFormCode.java?rev=1820526&r1=1820525&r2=1820526&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/CI_PresentationFormCode.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/CI_PresentationFormCode.java
[UTF-8] Mon Jan  8 04:12:36 2018
@@ -16,10 +16,12 @@
  */
 package org.apache.sis.internal.jaxb.code;
 
+import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import org.opengis.metadata.citation.PresentationForm;
 import org.apache.sis.internal.jaxb.gmd.CodeListAdapter;
 import org.apache.sis.internal.jaxb.gmd.CodeListUID;
+import org.apache.sis.xml.Namespaces;
 
 
 /**
@@ -33,6 +35,7 @@ import org.apache.sis.internal.jaxb.gmd.
  * @since   0.3
  * @module
  */
+@XmlType(namespace = Namespaces.CIT)
 public final class CI_PresentationFormCode extends CodeListAdapter<CI_PresentationFormCode,
PresentationForm> {
     /**
      * Empty constructor for JAXB only.

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java?rev=1820526&r1=1820525&r2=1820526&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/CodeListMarshallingTest.java
[UTF-8] Mon Jan  8 04:12:36 2018
@@ -32,6 +32,7 @@ import org.apache.sis.internal.jaxb.Sche
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
+import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
@@ -53,11 +54,12 @@ import static org.apache.sis.test.Assert
 public final strictfp class CodeListMarshallingTest extends XMLTestCase {
     /**
      * Returns a XML string to use for testing purpose.
+     * Note that responsible party exists only in legacy ISO 19115:2003 model.
      *
      * @param baseURL  the base URL of XML schemas.
      */
     private static String getResponsiblePartyXML(final String baseURL) {
-        return "<gmd:CI_ResponsibleParty xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
+        return "<gmd:CI_ResponsibleParty xmlns:gmd=\"" + LegacyNamespaces.GMD + "\">\n"
+
                "  <gmd:role>\n" +
                "    <gmd:CI_RoleCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH_LEGACY
+ "#CI_RoleCode\"" +
                     " codeListValue=\"principalInvestigator\">" + "Principal investigator</gmd:CI_RoleCode>\n"
+
@@ -68,15 +70,31 @@ public final strictfp class CodeListMars
     /**
      * Returns a XML string to use for testing purpose.
      *
-     * @param baseURL  the base URL of XML schemas.
-     */
-    private static String getCitationXML(final String baseURL, final String language, final
String value) {
-        return "<gmd:CI_Date xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
-               "  <gmd:dateType>\n" +
-               "    <gmd:CI_DateTypeCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH_LEGACY
+ "#CI_DateTypeCode\"" +
-                    " codeListValue=\"creation\" codeSpace=\"" + language + "\">" + value
+ "</gmd:CI_DateTypeCode>\n" +
-               "  </gmd:dateType>\n" +
-               "</gmd:CI_Date>";
+     * @param  language  three-letter ISO code.
+     * @param  dateType  date type code list in the language identified by {@code language}.
+     * @param  legacy    {@code true} for ISO 19139:2007 format, {@code false} for ISO 19115-3
format.
+     */
+    private static String getCitationXML(final String language, final String dateType, final
boolean legacy) {
+        final Object[] args = new Object[] {
+            "cit",                          // Prefix
+            Namespaces.CIT,                 // Namespace
+            Schemas.METADATA_ROOT,          // Base URL of code list path
+            Schemas.CODELISTS_PATH,         // Relative code list path in base URL
+            language, dateType
+        };
+        if (legacy) {
+            args[0] = "gmd";                              // Prefix
+            args[1] = LegacyNamespaces.GMD;               // Namespace
+            args[2] = Schemas.METADATA_ROOT_LEGACY;       // Base URL of code list path
+            args[3] = Schemas.CODELISTS_PATH_LEGACY;      // Relative code list path in base
URL
+        }
+        return String.format(
+                "<%1$s:CI_Date xmlns:%1$s=\"%2$s\">\n" +
+                "  <%1$s:dateType>\n" +
+                "    <%1$s:CI_DateTypeCode codeList=\"%3$s%4$s#CI_DateTypeCode\"" +
+                     " codeListValue=\"creation\" codeSpace=\"%5$s\">%6$s</%1$s:CI_DateTypeCode>\n"
+
+                "  </%1$s:dateType>\n" +
+                "</%1$s:CI_Date>", args);
     }
 
     /**
@@ -125,14 +143,36 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testLocalization() throws JAXBException {
+        testLocalization(false);
+    }
+
+    /**
+     * Tests a code list localization in ISO 19139:2007.
+     *
+     * @throws JAXBException if an error occurred while marshaling the XML.
+     *
+     * @since 1.0
+     */
+    @Test
+    @DependsOnMethod("testLocalization")
+    public void testLocalizationLegacyXML() throws JAXBException {
+        testLocalization(true);
+    }
+
+    /**
+     * Implementation of {@link #testLocalization()} and {@link #testLocalizationLegacyXML()}.
+     */
+    private void testLocalization(final boolean legacy) throws JAXBException {
         final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
-        marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
+        if (legacy) {
+            marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
+        }
         /*
          * First, test using the French locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.FRENCH);
-        String expected = getCitationXML(Schemas.METADATA_ROOT_LEGACY, "fra", "Création");
+        String expected = getCitationXML("fra", "Création", legacy);
         CitationDate ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         String actual = marshal(marshaller, ci);
@@ -141,7 +181,7 @@ public final strictfp class CodeListMars
          * Tests again using the English locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.ENGLISH);
-        expected = getCitationXML(Schemas.METADATA_ROOT_LEGACY, "eng", "Creation");
+        expected = getCitationXML("eng", "Creation", legacy);
         ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         actual = marshal(marshaller, ci);
@@ -159,21 +199,22 @@ public final strictfp class CodeListMars
     public void testExtraCodes() throws JAXBException {
         final DefaultCitation id = new DefaultCitation();
         id.setPresentationForms(Arrays.asList(
-                PresentationForm.valueOf("IMAGE_DIGITAL"), // Existing code with UML id="imageDigital"
-                PresentationForm.valueOf("test")));        // New code
-
-        final String xml = marshal(id, LegacyNamespaces.ISO_19139);
+                PresentationForm.valueOf("IMAGE_DIGITAL"),      // Existing code with UML
id="imageDigital"
+                PresentationForm.valueOf("test")));             // New code
 
-        // "IMAGE_DIGITAL" is marshalled as "imageDigital" because is contains a UML id,
which is lower-case.
+        final String xml = marshal(id);
+        /*
+         * "IMAGE_DIGITAL" is marshalled as "imageDigital" because is contains a UML id,
which is lower-case.
+         */
         assertXmlEquals(
-                "<gmd:CI_Citation xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
-                "  <gmd:presentationForm>\n" +
-                "    <gmd:CI_PresentationFormCode codeListValue=\"imageDigital\">Image
digital</gmd:CI_PresentationFormCode>\n" +
-                "  </gmd:presentationForm>\n" +
-                "  <gmd:presentationForm>\n" +
-                "    <gmd:CI_PresentationFormCode codeListValue=\"test\">Test</gmd:CI_PresentationFormCode>\n"
+
-                "  </gmd:presentationForm>\n" +
-                "</gmd:CI_Citation>\n",
+                "<cit:CI_Citation xmlns:cit=\"" + Namespaces.CIT + "\">\n" +
+                "  <cit:presentationForm>\n" +
+                "    <cit:CI_PresentationFormCode codeListValue=\"imageDigital\">Image
digital</cit:CI_PresentationFormCode>\n" +
+                "  </cit:presentationForm>\n" +
+                "  <cit:presentationForm>\n" +
+                "    <cit:CI_PresentationFormCode codeListValue=\"test\">Test</cit:CI_PresentationFormCode>\n"
+
+                "  </cit:presentationForm>\n" +
+                "</cit:CI_Citation>\n",
                 xml, "xmlns:*", "codeList", "codeSpace");
     }
 }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation
(legacy).xml
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation%20%28legacy%29.xml?rev=1820526&r1=1820525&r2=1820526&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation
(legacy).xml (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation
(legacy).xml Mon Jan  8 04:12:36 2018
@@ -70,4 +70,8 @@
       </gmd:role>
     </gmd:CI_ResponsibleParty>
   </gmd:citedResponsibleParty>
+  <gmd:presentationForm>
+    <gmd:CI_PresentationFormCode codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_PresentationFormCode"
+                                 codeListValue="physicalObject">Physical Object</gmd:CI_PresentationFormCode>
+  </gmd:presentationForm>
 </gmd:CI_Citation>

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation.xml
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation.xml?rev=1820526&r1=1820525&r2=1820526&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation.xml
(original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/citation/Citation.xml
Mon Jan  8 04:12:36 2018
@@ -79,4 +79,8 @@
       </cit:party>
     </cit:CI_Responsibility>
   </cit:citedResponsibleParty>
+  <cit:presentationForm>
+    <cit:CI_PresentationFormCode codeList="http://standards.iso.org/iso/19115/resources/Codelist/cat/codelists.xml#CI_PresentationFormCode"
+                                 codeListValue="physicalObject">Physical Object</cit:CI_PresentationFormCode>
+  </cit:presentationForm>
 </cit:CI_Citation>

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java?rev=1820526&r1=1820525&r2=1820526&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Schemas.java
[UTF-8] Mon Jan  8 04:12:36 2018
@@ -55,7 +55,6 @@ public final class Schemas {
     /**
      * The XSD definition for 193139 metadata objects.
      */
-    @Deprecated
     public static final String METADATA_XSD_LEGACY = "http://schemas.opengis.net/iso/19139/20070417/gmd/gmd.xsd";
 
     /**
@@ -78,7 +77,6 @@ public final class Schemas {
      * The root directory of OGC metadata schemas.
      * This is the schema used by default in Apache SIS.
      */
-    @Deprecated
     public static final String METADATA_ROOT_LEGACY = "http://schemas.opengis.net/iso/19139/20070417/";
 
     /**
@@ -91,7 +89,6 @@ public final class Schemas {
      * The root directory of ISO 19115-3 metadata schemas.
      * This is sometime used as an alternative to {@link #METADATA_ROOT_LEGACY}.
      */
-    @Deprecated
     public static final String ISO_19139_ROOT = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/";
 
     /**
@@ -103,7 +100,6 @@ public final class Schemas {
      *
      * @see <a href="https://issues.apache.org/jira/browse/SIS-154">SIS-154</a>
      */
-    @Deprecated
     public static final String CODELISTS_PATH_LEGACY = "resources/Codelist/gmxCodelists.xml";
 
     /**



Mime
View raw message