sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1819927 - in /sis/branches/ISO-19115-3: core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/code/ core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/ core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/...
Date Wed, 03 Jan 2018 05:35:30 GMT
Author: desruisseaux
Date: Wed Jan  3 05:35:30 2018
New Revision: 1819927

URL: http://svn.apache.org/viewvc?rev=1819927&view=rev
Log:
Skip commit 669c595ef233dafe676da71bc7b184093d463a6b (this commit was setting the default
format to legacy ISO 19139, while we want newer ISO 19115-3).
Instead, fix a few test cases.

Modified:
    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/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt
    sis/branches/ISO-19115-3/ide-project/NetBeans/build.xml

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=1819927&r1=1819926&r2=1819927&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] Wed Jan  3 05:35:30 2018
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Cit
 import org.opengis.metadata.citation.Responsibility;
 import org.opengis.metadata.citation.PresentationForm;
 import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.jaxb.Schemas;
 import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
@@ -42,7 +43,7 @@ import static org.apache.sis.test.Assert
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
- * @version 0.5
+ * @version 1.0
  *
  * @see <a href="http://jira.geotoolkit.org/browse/GEOTK-121">GEOTK-121</a>
  *
@@ -58,7 +59,7 @@ public final strictfp class CodeListMars
     private static String getResponsiblePartyXML(final String baseURL) {
         return "<gmd:CI_ResponsibleParty xmlns:gmd=\"" + Namespaces.GMD + "\">\n" +
                "  <gmd:role>\n" +
-               "    <gmd:CI_RoleCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH +
"#CI_RoleCode\"" +
+               "    <gmd:CI_RoleCode codeList=\"" + baseURL + Schemas.CODELISTS_PATH_LEGACY
+ "#CI_RoleCode\"" +
                     " codeListValue=\"principalInvestigator\">" + "Principal investigator</gmd:CI_RoleCode>\n"
+
                "  </gmd:role>\n" +
                "</gmd:CI_ResponsibleParty>";
@@ -72,7 +73,7 @@ public final strictfp class CodeListMars
     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
+ "#CI_DateTypeCode\"" +
+               "    <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>";
@@ -85,14 +86,14 @@ public final strictfp class CodeListMars
      */
     @Test
     public void testDefaultURL() throws JAXBException {
-        final String expected = getResponsiblePartyXML(Schemas.METADATA_ROOT);
+        final String expected = getResponsiblePartyXML(Schemas.METADATA_ROOT_LEGACY);
         final Responsibility rp = (Responsibility) XML.unmarshal(expected);
         assertEquals(Role.PRINCIPAL_INVESTIGATOR, rp.getRole());
         /*
          * Use the convenience method in order to avoid the effort of creating
          * our own MarshallerPool.
          */
-        final String actual = XML.marshal(rp);
+        final String actual = marshal(rp, LegacyNamespaces.ISO_19139);
         assertXmlEquals(expected, actual, "xmlns:*");
     }
 
@@ -109,6 +110,7 @@ public final strictfp class CodeListMars
 
         final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
+        marshaller.setProperty(XML.METADATA_VERSION, LegacyNamespaces.ISO_19139);
         marshaller.setProperty(XML.SCHEMAS, Collections.singletonMap("gmd",
                 "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas"));
// Intentionally omit trailing '/'.
         final String actual = marshal(marshaller, rp);
@@ -125,11 +127,12 @@ public final strictfp class CodeListMars
     public void testLocalization() throws JAXBException {
         final MarshallerPool pool = getMarshallerPool();
         final Marshaller marshaller = pool.acquireMarshaller();
+        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, "fra", "Création");
+        String expected = getCitationXML(Schemas.METADATA_ROOT_LEGACY, "fra", "Création");
         CitationDate ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         String actual = marshal(marshaller, ci);
@@ -138,7 +141,7 @@ public final strictfp class CodeListMars
          * Tests again using the English locale.
          */
         marshaller.setProperty(XML.LOCALE, Locale.ENGLISH);
-        expected = getCitationXML(Schemas.METADATA_ROOT, "eng", "Creation");
+        expected = getCitationXML(Schemas.METADATA_ROOT_LEGACY, "eng", "Creation");
         ci = (CitationDate) XML.unmarshal(expected);
         assertEquals(DateType.CREATION, ci.getDateType());
         actual = marshal(marshaller, ci);
@@ -159,7 +162,7 @@ public final strictfp class CodeListMars
                 PresentationForm.valueOf("IMAGE_DIGITAL"), // Existing code with UML id="imageDigital"
                 PresentationForm.valueOf("test")));        // New code
 
-        final String xml = marshal(id);
+        final String xml = marshal(id, LegacyNamespaces.ISO_19139);
 
         // "IMAGE_DIGITAL" is marshalled as "imageDigital" because is contains a UML id,
which is lower-case.
         assertXmlEquals(

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java?rev=1819927&r1=1819926&r2=1819927&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/constraint/DefaultLegalConstraintsTest.java
[UTF-8] Wed Jan  3 05:35:30 2018
@@ -24,6 +24,7 @@ import org.apache.sis.xml.XML;
 import org.apache.sis.xml.Namespaces;
 import org.apache.sis.xml.MarshallerPool;
 import org.apache.sis.util.logging.WarningListener;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
@@ -79,7 +80,7 @@ public final strictfp class DefaultLegal
     }
 
     /**
-     * Unmarshalls the given XML fragment.
+     * Unmarshals the given XML fragment.
      */
     private DefaultLegalConstraints unmarshal(final String xml) throws JAXBException {
         final MarshallerPool pool = getMarshallerPool();
@@ -142,7 +143,7 @@ public final strictfp class DefaultLegal
 
         final DefaultLegalConstraints c = new DefaultLegalConstraints();
         c.setUseConstraints(singleton(Restriction.LICENCE));
-        assertXmlEquals(xml, marshal(c), "xmlns:*");
+        assertXmlEquals(xml, marshal(c, LegacyNamespaces.ISO_19139), "xmlns:*");
         /*
          * Unmarshall and ensure that we got back the original LICENCE code, not a new "LICENSE"
code.
          */

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java?rev=1819927&r1=1819926&r2=1819927&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/LegacyNamespaces.java
[UTF-8] Wed Jan  3 05:35:30 2018
@@ -105,26 +105,6 @@ public final class LegacyNamespaces {
     public static final String GTS = "http://www.isotc211.org/2005/gts";
 
     /**
-     * A non-public (un)marshaller property for controlling usage of {@code org.apache.sis.xml.FilteredNamespaces}.
-     * Values can be:
-     *
-     * <ul>
-     *   <li>{@link Boolean#FALSE} for disabling namespace replacements. XML (un)marshalling
will use the namespaces URI
-     *       supported natively by SIS as declared in JAXB annotations. This is sometime
useful for debugging purpose.</li>
-     *   <li>{@link Boolean#TRUE} for forcing namespace replacements at unmarshalling
time. This is useful for reading a
-     *       XML document of unknown GML version.</li>
-     *   <li>{@code null} or missing for the default behavior, which is apply namespace
replacements only if the
-     *       {@link org.apache.sis.xml.XML#GML_VERSION} property is set to an older value
than the one supported
-     *       natively by SIS.</li>
-     * </ul>
-     *
-     * This property can be given to {@link org.apache.sis.xml.MarshallerPool} constructor,
or set directly on
-     * a {@code Marshaller} or {@code Unmarshaller} instance created by {@code MarshallerPool}
by invoking its
-     * {@code setProperty(String, Object)} method.
-     */
-    public static final String APPLY_NAMESPACE_REPLACEMENTS = "org.apache.sis.xml.applyNamespaceReplacements";
-
-    /**
      * Do not allow instantiation of this class.
      */
     private LegacyNamespaces() {

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java?rev=1819927&r1=1819926&r2=1819927&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/Pooled.java
[UTF-8] Wed Jan  3 05:35:30 2018
@@ -113,29 +113,6 @@ abstract class Pooled {
     private Map<String,String> schemas;
 
     /**
-     * Whether {@link FilteredNamespaces} shall be used of not. Values can be:
-     *
-     * <ul>
-     *   <li>{@value #DEFAULT_REPLACEMENT} for the default behavior, which applies
namespace replacements
-     *       only if the {@link XML#GML_VERSION} property is set to an older value than the
one supported
-     *       natively by SIS.</li>
-     *   <li>{@value #FORCE_REPLACEMENT} for forcing namespace replacements at unmarshalling
time.
-     *       This is useful for reading a XML document of unknown GML version.</li>
-     *   <li>{@value #DISABLE_REPLACEMENT} for disabling namespace replacements. XML
(un)marshalling
-     *       will use the namespaces URI supported natively by SIS as declared in JAXB annotations.
-     *       This is sometime useful for debugging purpose.</li>
-     * </ul>
-     *
-     * @see LegacyNamespaces#APPLY_NAMESPACE_REPLACEMENTS
-     */
-    private byte xmlnsReplaceCode;
-
-    /**
-     * Enumeration values for {@link #xmlnsReplaceCode}.
-     */
-    private static final byte DEFAULT_REPLACEMENT = 0, FORCE_REPLACEMENT = 1, DISABLE_REPLACEMENT
= 2;
-
-    /**
      * The GML version to be marshalled or unmarshalled, or {@code null} if unspecified.
      * If null, then the latest version is assumed.
      *
@@ -238,7 +215,6 @@ abstract class Pooled {
         locale           = template.locale;
         timezone         = template.timezone;
         schemas          = template.schemas;
-        xmlnsReplaceCode = template.xmlnsReplaceCode;
         versionGML       = template.versionGML;
         versionMetadata  = template.versionMetadata;
         resolver         = template.resolver;
@@ -274,29 +250,19 @@ abstract class Pooled {
      * @see FilteredNamespaces
      */
     final FilterVersion getFilterVersion() {
-        switch (xmlnsReplaceCode) {
-            case DEFAULT_REPLACEMENT: {
-                // Apply namespace replacements only for older versions than the one supported
natively by SIS.
-                if (versionGML != null) {
-                    if (versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) {
-                        return FilterVersion.GML31;
-                    }
-                }
-                if (versionMetadata != null) {
-                    if (versionMetadata.compareTo(LegacyNamespaces.ISO_19115_3) < 0) {
-                        return FilterVersion.ISO19139;
-                    }
-                }
-                break;
+        if (versionGML != null) {
+            // Apply namespace replacements only for older versions than the one supported
natively by SIS.
+            if (versionGML.compareTo(LegacyNamespaces.VERSION_3_2_1) < 0) {
+                return FilterVersion.GML31;
             }
-            case FORCE_REPLACEMENT: {
-                // Force namespace replacements at unmarshalling time (illegal for marshalling).
-                if ((bitMasks & Context.MARSHALLING) == 0) {
-                    return FilterVersion.ALL;
-                }
-                break;
+        } else if (versionMetadata != null) {
+            // Only if GML version is unspecified, because GML version implies metadata version.
+            if (versionMetadata.compareTo(LegacyNamespaces.ISO_19115_3) < 0) {
+                return FilterVersion.ISO19139;
             }
-            // case DISABLE_REPLACEMENT: disable namespace replacements.
+        } else if ((bitMasks & Context.MARSHALLING) == 0) {
+            // Force namespace replacements at unmarshalling time (illegal for marshalling).
+            return FilterVersion.ALL;
         }
         return null;
     }
@@ -401,13 +367,6 @@ abstract class Pooled {
                     warningListener = (WarningListener<?>) value;
                     return;
                 }
-                case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
-                    xmlnsReplaceCode = DEFAULT_REPLACEMENT;
-                    if (value != null) {
-                        xmlnsReplaceCode = ((Boolean) value) ? FORCE_REPLACEMENT : DISABLE_REPLACEMENT;
-                    }
-                    return;
-                }
                 case TypeRegistration.ROOT_ADAPTERS: {
                     rootAdapters = (TypeRegistration[]) value;
                     // No clone for now because ROOT_ADAPTERS is not yet a public API.
@@ -455,13 +414,6 @@ abstract class Pooled {
                 if ((bitMasks & Context.SUBSTITUTE_MIMETYPE) != 0) substitutes[n++] =
"mimetype";
                 return (n != 0) ? ArraysExt.resize(substitutes, n) : null;
             }
-            case LegacyNamespaces.APPLY_NAMESPACE_REPLACEMENTS: {
-                switch (xmlnsReplaceCode) {
-                    case FORCE_REPLACEMENT:   return Boolean.TRUE;
-                    case DISABLE_REPLACEMENT: return Boolean.FALSE;
-                    default:                  return null;
-                }
-            }
             case TypeRegistration.ROOT_ADAPTERS: return (rootAdapters != null) ? rootAdapters.clone()
: null;
             default: {
                 if (internal) {

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt?rev=1819927&r1=1819926&r2=1819927&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt
[UTF-8] Wed Jan  3 05:35:30 2018
@@ -76,14 +76,8 @@ http://standards.iso.org/iso/19115/-3/ci
     party
     role
   CI_ResponsibleParty
-    <type>
-    contactInfo
     extent
-    individualName
-    organisationName
     party
-    positionName
-    role
   CI_RoleCode
     <type>
   CI_Series

Modified: sis/branches/ISO-19115-3/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/ide-project/NetBeans/build.xml?rev=1819927&r1=1819926&r2=1819927&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/ide-project/NetBeans/build.xml (original)
+++ sis/branches/ISO-19115-3/ide-project/NetBeans/build.xml Wed Jan  3 05:35:30 2018
@@ -69,6 +69,7 @@
       <!-- Other resources (properties files, SQL scripts, native libraries). -->
       <fileset dir="${project.root}/core/sis-utility/src/main/resources">
         <include name="**/*.properties"/>
+        <include name="**/*.txt"/>
       </fileset>
       <fileset dir="${project.root}/core/sis-metadata/src/main/resources">
         <include name="**/*.sql"/>



Mime
View raw message