sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1821837 - in /sis/branches/ISO-19115-3/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/ sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ sis-metadata/src/main/java/org/apache/sis/metad...
Date Mon, 22 Jan 2018 11:25:26 GMT
Author: desruisseaux
Date: Mon Jan 22 11:25:26 2018
New Revision: 1821837

URL: http://svn.apache.org/viewvc?rev=1821837&view=rev
Log:
Adaptation of commit 5b6d24d241a809993a09f8c5f9f5e0da14068844 from Image Matter (Refactored FilteredStreamReader).
DefaultServiceIdentificationTest on legacy XML fail because of the way <gco:MemberName> and <gco:ScopedName> were marshalled
(they were inserted directly in the XML document, without <srv:scopedName> wrapper contrarily to what ISO 19139 usually does.)
The new ISO 19115-3:2016 schema is more consistent, but compatibility with legacy ISO 19139:2007 schema is uneasy to implement.
We accept the test failures for now, and will consider a change in our approach later. Current plan is to replace our use of
JDK's XMLStreamReader by XMLEventReader, so we can more easily apply on-the-fly bigger changes than just changing the namespace.

Added:
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_MemberName.java
      - copied, changed from r1821836, sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_ScopedName.java
      - copied, changed from r1821836, sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
Removed:
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java
Modified:
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameterTest.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/ServiceIdentification.xml
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredStreamReader.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/resources/org/apache/sis/xml/NamespaceContent.txt
    sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -21,7 +21,6 @@ import java.util.Objects;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.measure.Unit;
 import org.opengis.util.TypeName;
 import org.opengis.util.MemberName;
@@ -32,8 +31,8 @@ import org.opengis.parameter.ParameterVa
 import org.opengis.parameter.ParameterDirection;
 import org.opengis.parameter.ParameterDescriptor;
 import org.apache.sis.internal.simple.SimpleIdentifiedObject;
-import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName;
 import org.apache.sis.internal.jaxb.FilterByVersion;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.metadata.ReferencingServices;
 import org.apache.sis.internal.metadata.NameToIdentifier;
 import org.apache.sis.util.ComparisonMode;
@@ -63,7 +62,7 @@ import static org.apache.sis.internal.ut
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
  * @since   0.5
  * @module
  */
@@ -73,6 +72,7 @@ import static org.apache.sis.internal.ut
     "direction",
     "description",
     "optionality",
+    "optionalityLabel",     // Legacy ISO 19139:2007 way to marshal optionality.
     "repeatability",
     "valueType"
 })
@@ -84,12 +84,14 @@ public final class ServiceParameter exte
     private static final long serialVersionUID = -5335736212313243889L;
 
     /**
-     * The name, as used by the service for this parameter.
+     * The name, as used by the service for this parameter. Note that in ISO 19115-3:2016, this element is
+     * inside a {@code <gco:MemberName>} element  (i.e. ISO inserts the same kind of {@code Property_Type}
+     * element as it does for all other attributes) while in ISO 19139:2007 it was not (i.e. name attributes
+     * like {@code <gco:aName>} were marshalled directly, without wrapper).
      *
      * @see #getValueType()
      */
     @XmlElement(required=true, name="name")
-    @XmlJavaTypeAdapter(GO_MemberName.class)
     MemberName memberName;
 
     /**
@@ -108,12 +110,12 @@ public final class ServiceParameter exte
      * Indication if the parameter is required.
      *
      * <ul>
-     *   <li>In ISO 19115, this is represented by "{@code true}" or "{@code false}".</li>
-     *   <li>In ISO 19119, this is marshalled as "{@code Optional}" or "{@code Mandatory}".</li>
+     *   <li>In ISO 19115-3:2016, this is represented by "{@code true}" or "{@code false}".</li>
+     *   <li>In ISO 19139:2007, this was marshalled as "{@code Optional}" or "{@code Mandatory}".</li>
      * </ul>
      *
      * @see #getOptionality()
-     * @see #setOptionality(String)
+     * @see #setOptionality(Boolean)
      */
     public boolean optionality;
 
@@ -263,22 +265,33 @@ public final class ServiceParameter exte
     }
 
     /**
-     * Returns {@code true} if {@link #optionality} is "{@code true}" or "{@code Optional}",
-     * or {@code false} otherwise.
+     * Returns the optionality as a boolean (ISO 19115-3:2016 way).
      */
     @XmlElement(name = "optionality", required = true)
-    final String getOptionality() {
-        if (FilterByVersion.CURRENT_METADATA.accept()) {
-            return Boolean.toString(optionality);
-        } else {
-            return optionality ? "Optional" : "Mandatory";
-        }
+    final Boolean getOptionality() {
+        return FilterByVersion.CURRENT_METADATA.accept() ? optionality : null;
+    }
+
+    /**
+     * Sets whether this parameter is optional.
+     */
+    final void setOptionality(final Boolean optional) {
+        if (optional != null) optionality = optional;
+    }
+
+    /**
+     * Returns {@code "Optional"} if {@link #optionality} is {@code true} or {@code "Mandatory"} otherwise.
+     * This is the legacy ISO 19139:2007 way to marshal optionality.
+     */
+    @XmlElement(name = "optionality", namespace = LegacyNamespaces.SRV)
+    final String getOptionalityLabel() {
+        return FilterByVersion.LEGACY_METADATA.accept() ? (optionality ? "Optional" : "Mandatory") : null;
     }
 
     /**
      * Sets whether this parameter is optional.
      */
-    final void setOptionality(final String optional) {
+    final void setOptionalityLabel(final String optional) {
         if (optional != null) {
             optionality = Boolean.parseBoolean(optional) || optional.equalsIgnoreCase("Optional");
         }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -50,6 +50,7 @@
     @XmlJavaTypeAdapter(StringAdapter.class),
     @XmlJavaTypeAdapter(InternationalStringAdapter.class),
     @XmlJavaTypeAdapter(GO_GenericName.class),
+    @XmlJavaTypeAdapter(GO_MemberName.class),
     @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class)
 })
 package org.apache.sis.internal.jaxb.metadata.replace;
@@ -61,10 +62,7 @@ import javax.xml.bind.annotation.XmlAcce
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
-import org.apache.sis.internal.jaxb.gco.GO_Boolean;
-import org.apache.sis.internal.jaxb.gco.GO_GenericName;
-import org.apache.sis.internal.jaxb.gco.StringAdapter;
-import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter;
 import org.apache.sis.internal.jaxb.metadata.RS_Identifier;
 import org.apache.sis.internal.jaxb.code.SV_ParameterDirection;
+import org.apache.sis.internal.jaxb.gco.*;
 import org.apache.sis.xml.Namespaces;

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -19,7 +19,6 @@ package org.apache.sis.metadata.iso.iden
 import java.util.Collection;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementRef;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import org.opengis.util.ScopedName;
@@ -28,9 +27,9 @@ import org.opengis.metadata.identificati
 import org.opengis.metadata.identification.CoupledResource;
 import org.opengis.metadata.identification.OperationMetadata;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.metadata.direct.GO_ScopedName;
 import org.apache.sis.internal.jaxb.metadata.SV_OperationMetadata;
 import org.apache.sis.internal.jaxb.FilterByVersion;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.xml.Namespaces;
 
 
@@ -55,12 +54,12 @@ import org.apache.sis.xml.Namespaces;
  */
 @SuppressWarnings("CloneableClassWithoutClone")                 // ModifiableMetadata needs shallow clones.
 @XmlType(name = "SV_CoupledResource_Type", namespace = Namespaces.SRV, propOrder = {
-    "operationName",
-    "identifier",
     "scopedName",
-    "resourceReference",
-    "resource",
-    "operation"
+    "resourceReference",        // New in ISO 19115:2014
+    "resource",                 // Ibid.
+    "operation",                // Ibid.
+    "operationName",            // Legacy ISO 19139:2007
+    "identifier"                // Ibid.
 })
 @XmlRootElement(name = "SV_CoupledResource", namespace = Namespaces.SRV)
 public class DefaultCoupledResource extends ISOMetadata implements CoupledResource {
@@ -164,8 +163,7 @@ public class DefaultCoupledResource exte
      * @return identifier of the resource, or {@code null} if none.
      */
     @Override
-    @XmlElementRef
-    @XmlJavaTypeAdapter(GO_ScopedName.class)
+    @XmlElement(name = "scopedName")
     public ScopedName getScopedName() {
         return scopedName;
     }
@@ -226,7 +224,7 @@ public class DefaultCoupledResource exte
      * @return the service operation, or {@code null} if none.
      */
     @Override
-    @XmlElement(name = "operation", namespace = Namespaces.SRV)
+    @XmlElement(name = "operation")
     @XmlJavaTypeAdapter(SV_OperationMetadata.Since2014.class)
     public OperationMetadata getOperation() {
         return operation;
@@ -259,7 +257,7 @@ public class DefaultCoupledResource exte
     /**
      * For JAXB marshalling of ISO 19139:2007 document only (XML based on legacy ISO 19115:2003 model).
      */
-    @XmlElement(name = "operationName", namespace = Namespaces.SRV)
+    @XmlElement(name = "operationName", namespace = LegacyNamespaces.SRV)
     private String getOperationName() {
         if (FilterByVersion.LEGACY_METADATA.accept()) {
             final OperationMetadata operation = getOperation();
@@ -284,8 +282,10 @@ public class DefaultCoupledResource exte
 
     /**
      * Returns the resource identifier, which is assumed to be the name as a string.
+     * Used in legacy ISO 19139:2007 documents. There is no setter method; we expect
+     * the XML to declare {@code <srv:operationName>} instead.
      */
-    @XmlElement(name = "identifier", namespace = Namespaces.SRV)
+    @XmlElement(name = "identifier", namespace = LegacyNamespaces.SRV)
     private String getIdentifier() {
         if (FilterByVersion.LEGACY_METADATA.accept()) {
             final ScopedName name = getScopedName();
@@ -306,7 +306,12 @@ public class DefaultCoupledResource exte
         return FilterByVersion.CURRENT_METADATA.accept() ? getResourceReferences() : null;
     }
 
-    @XmlElement(name = "resource", namespace = Namespaces.SRV)
+    /**
+     * Invoked by JAXB at both marshalling and unmarshalling time.
+     * This attribute has been added by ISO 19115:2014 standard.
+     * If (and only if) marshalling an older standard version, we omit this attribute.
+     */
+    @XmlElement(name = "resource")
     private Collection<DataIdentification> getResource() {
         return FilterByVersion.CURRENT_METADATA.accept() ? getResources() : null;
     }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultOperationMetadata.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Onl
 import org.opengis.metadata.identification.DistributedComputingPlatform;
 import org.opengis.metadata.identification.OperationMetadata;
 import org.apache.sis.internal.jaxb.FilterByVersion;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.metadata.TitleProperty;
 import org.apache.sis.xml.Namespaces;
@@ -66,8 +67,9 @@ import org.apache.sis.xml.Namespaces;
     "DCP",                              // Former name of "distributedComputingPlatform" used in ISO 19115:2003.
     "operationDescription",
     "invocationName",
-    "parameters",
-    "connectPoints",
+    "parameterList",                    // Actually "parameters" — was the spelling in ISO 19115:2003.
+    "connectPoints",                    // Was after "parameters" in ISO 19115:2003.
+    "parameter",                        // New spelling in ISO 19115-3:2016.
     "dependsOn"
 })
 @XmlRootElement(name = "SV_OperationMetadata", namespace = Namespaces.SRV)
@@ -293,7 +295,7 @@ public class DefaultOperationMetadata ex
      */
     @Override
     @SuppressWarnings({"unchecked", "rawtypes"})
-    @XmlElement(name = "parameter")
+    // @XmlElement at the end of this class.
     public Collection<ParameterDescriptor<?>> getParameters() {
         return parameters = nonNullCollection(parameters, (Class) ParameterDescriptor.class);
     }
@@ -357,8 +359,26 @@ public class DefaultOperationMetadata ex
      * This attribute was defined by ISO 19115:2003 standard.
      * If (and only if) marshalling a more recent standard version, we omit this attribute.
      */
-    @XmlElement(name = "DCP")
+    @XmlElement(name = "DCP", namespace = LegacyNamespaces.SRV)
     private Collection<DistributedComputingPlatform> getDCP() {
         return FilterByVersion.LEGACY_METADATA.accept() ? getDistributedComputingPlatforms() : null;
     }
+
+    /**
+     * Invoked by JAXB for (un)marshalling using ISO 19115-3:2016 spelling.
+     * Note that 19115-1:2014 still use the "parameters" spelling
+     * (we seem to have an 19115-1 / ISO 19115-3 discrepancy here).
+     */
+    @XmlElement(name = "parameter")
+    private Collection<ParameterDescriptor<?>> getParameter() {
+        return FilterByVersion.CURRENT_METADATA.accept() ? getParameters() : null;
+    }
+
+    /**
+     * Invoked by JAXB for (un)marshalling using legacy ISO 19115:2003 spelling.
+     */
+    @XmlElement(name = "parameters", namespace = LegacyNamespaces.SRV)
+    private Collection<ParameterDescriptor<?>> getParameterList() {
+        return FilterByVersion.LEGACY_METADATA.accept() ? getParameters() : null;
+    }
 }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentification.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -78,8 +78,8 @@ import org.apache.sis.xml.Namespaces;
     "serviceType",
     "serviceTypeVersions",
     "accessProperties",
+    "couplingType",             // "couplingType" and "coupledResource" were in reverse order in ISO 19115:2003.
     "coupledResources",
-    "couplingType",
     "operatedDataset",
     "profile",
     "serviceStandard",
@@ -407,7 +407,7 @@ public class DefaultServiceIdentificatio
      * @return information about the operations that comprise the service.
      */
     @Override
-    @XmlElement(name = "containsOperations", namespace = Namespaces.SRV)
+    @XmlElement(name = "containsOperations")
     public Collection<OperationMetadata> getContainsOperations() {
         return containsOperations = nonNullCollection(containsOperations, OperationMetadata.class);
     }
@@ -427,7 +427,7 @@ public class DefaultServiceIdentificatio
      * @return information on the resources that the service operates on.
      */
     @Override
-    @XmlElement(name = "operatesOn", namespace = Namespaces.SRV)
+    @XmlElement(name = "operatesOn")
     public Collection<DataIdentification> getOperatesOn() {
         return operatesOn = nonNullCollection(operatesOn, DataIdentification.class);
     }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/package-info.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -152,6 +152,7 @@
     @XmlJavaTypeAdapter(InternationalStringAdapter.class),
     @XmlJavaTypeAdapter(GO_DateTime.class),
     @XmlJavaTypeAdapter(GO_GenericName.class),
+    @XmlJavaTypeAdapter(GO_ScopedName.class),
     @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class)
 })
 package org.apache.sis.metadata.iso.identification;

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameterTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameterTest.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameterTest.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameterTest.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -53,6 +53,16 @@ public final strictfp class ServiceParam
     }
 
     /**
+     * Tests {@link ServiceParameter#getName()}.
+     */
+    @Test
+    public void testGetName() {
+        final ServiceParameter param = create();
+        assertEquals("name", "Version", String.valueOf(param.getName()));
+        assertEquals("valueClass", String.class, param.getValueClass());
+    }
+
+    /**
      * Tests {@link ServiceParameter#getValueType()} and {@link ServiceParameter#getValueClass()}.
      */
     @Test
@@ -63,27 +73,28 @@ public final strictfp class ServiceParam
     }
 
     /**
-     * Tests {@link ServiceParameter#getOptionality()} and {@link ServiceParameter#setOptionality(String)}.
+     * Tests {@link ServiceParameter#getOptionalityLabel()} and {@link ServiceParameter#setOptionalityLabel(String)}.
      */
     @Test
     public void testOptionalityLabel() {
         final ServiceParameter param = create();
-        assertEquals("Optional", param.getOptionality());
+        assertEquals("Optional", param.getOptionalityLabel());
 
         param.optionality = false;
-        assertEquals("Mandatory", param.getOptionality());
+        assertEquals("Mandatory", param.getOptionalityLabel());
 
-        param.setOptionality("Optional");
+        param.setOptionalityLabel("Optional");
         assertTrue(param.optionality);
 
-        param.setOptionality("Mandatory");
+        param.setOptionalityLabel("Mandatory");
         assertFalse(param.optionality);
     }
 
     /**
      * Tests marshalling of an almost empty parameter (except for default mandatory values).
      * The main purpose is to ensure that the XML does not contains spurious elements like
-     * empty enumeration wrapper.
+     * empty enumeration wrapper. For testing a complete marshalling,
+     * see {@link org.apache.sis.metadata.iso.identification.DefaultServiceIdentificationTest}.
      *
      * @throws JAXBException if an error occurred during marshalling.
      */
@@ -94,7 +105,7 @@ public final strictfp class ServiceParam
                 "<srv:SV_Parameter xmlns:srv=\"" + Namespaces.SRV + '"' +
                                  " xmlns:gco=\"" + Namespaces.GCO + "\">\n" +
                 "  <srv:optionality>\n" +
-                "    <gco:CharacterString>Mandatory</gco:CharacterString>\n" +
+                "    <gco:Boolean>false</gco:Boolean>\n" +
                 "  </srv:optionality>\n" +
                 "  <srv:repeatability>\n" +
                 "    <gco:Boolean>false</gco:Boolean>\n" +

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResourceTest.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -37,7 +37,7 @@ import static org.junit.Assert.*;
  * Tests {@link DefaultCoupledResource}.
  *
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @version 1.0
  * @since   0.5
  * @module
  */
@@ -46,14 +46,13 @@ public final strictfp class DefaultCoupl
     /**
      * Creates the resource to use for testing purpose.
      */
-    static DefaultCoupledResource create() {
+    static DefaultCoupledResource create(final NameFactory factory) {
         final DefaultOperationMetadata operation = new DefaultOperationMetadata("Get Map",
                 DistributedComputingPlatform.WEB_SERVICES, null);
         operation.setParameters(singleton((ParameterDescriptor<?>) ServiceParameterTest.create()));
         operation.setConnectPoints(singleton(NilReason.MISSING.createNilObject(OnlineResource.class)));
 
         final DefaultCoupledResource resource = new DefaultCoupledResource();
-        final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
         resource.setScopedName((ScopedName) factory.createGenericName(null, "mySpace", "ABC-123"));
         resource.setOperation(operation);
         return resource;
@@ -64,7 +63,7 @@ public final strictfp class DefaultCoupl
      */
     @Test
     public void testOperationNameResolve() {
-        final DefaultCoupledResource resource  = DefaultCoupledResourceTest.create();
+        final DefaultCoupledResource resource  = create(DefaultFactories.forBuildin(NameFactory.class));
         final OperationMetadata      operation = resource.getOperation();
         /*
          * Test OperationName replacement when the name matches.

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/metadata/iso/identification/DefaultServiceIdentificationTest.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -18,18 +18,25 @@ package org.apache.sis.metadata.iso.iden
 
 import javax.xml.bind.JAXBException;
 import org.opengis.util.NameFactory;
+import org.opengis.parameter.ParameterDirection;
+import org.opengis.parameter.ParameterDescriptor;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.identification.CouplingType;
+import org.opengis.metadata.identification.CoupledResource;
+import org.opengis.metadata.identification.OperationMetadata;
+import org.opengis.metadata.identification.ServiceIdentification;
+import org.opengis.metadata.identification.DistributedComputingPlatform;
+import org.apache.sis.metadata.iso.citation.DefaultCitation;
 import org.apache.sis.internal.system.DefaultFactories;
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
-import org.apache.sis.util.ComparisonMode;
 import org.apache.sis.xml.NilReason;
 import org.apache.sis.test.DependsOn;
 import org.apache.sis.test.XMLTestCase;
 import org.junit.Test;
 
-import static org.apache.sis.test.Assert.*;
 import static java.util.Collections.singleton;
+import static org.apache.sis.test.MetadataAssert.*;
+import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
 /**
@@ -61,7 +68,8 @@ public final strictfp class DefaultServi
      */
     private static DefaultServiceIdentification create() {
         final NameFactory factory = DefaultFactories.forBuildin(NameFactory.class);
-        final DefaultCoupledResource resource = DefaultCoupledResourceTest.create();
+        final DefaultCoupledResource resource = DefaultCoupledResourceTest.create(factory);
+        resource.setResourceReferences(singleton(new DefaultCitation("WMS specification")));
         final DefaultServiceIdentification id = new DefaultServiceIdentification(
                 factory.createGenericName(null, "Web Map Server"),      // serviceType
                 NilReason.MISSING.createNilObject(Citation.class),      // citation
@@ -74,6 +82,34 @@ public final strictfp class DefaultServi
     }
 
     /**
+     * Compare values of the given service identifications against the value expected for the
+     * instance created by {@link #create()} method.
+     */
+    private static void verify(final ServiceIdentification id) {
+        assertEquals("serviceTypeVersion", "1.0",                                  getSingleton(id.getServiceTypeVersions()));
+        assertEquals("serviceType",        "Web Map Server",                       String.valueOf(id.getServiceType()));
+        assertEquals("abstract",           "A dummy service for testing purpose.", String.valueOf(id.getAbstract()));
+        assertEquals("citation",           NilReason.MISSING,                      NilReason.forObject(id.getCitation()));
+        assertEquals("couplingType",       CouplingType.LOOSE,                     id.getCouplingType());
+
+        final CoupledResource resource = getSingleton(id.getCoupledResources());
+//      assertEquals("scopedName",        "mySpace:ABC-123",   …)  skipped because not present in new ISO 19115-3:2016.
+//      assertEquals("resourceReference", "WMS specification", …)  skipped because not present in legacy ISO 19139:2007.
+
+        final OperationMetadata op = resource.getOperation();
+        assertNotNull("operation", op);
+        assertEquals("operationName", "Get Map", op.getOperationName());
+        assertEquals("distributedComputingPlatform", DistributedComputingPlatform.WEB_SERVICES, getSingleton(op.getDistributedComputingPlatforms()));
+        assertEquals("connectPoints", NilReason.MISSING, NilReason.forObject(getSingleton(op.getConnectPoints())));
+
+        final ParameterDescriptor<?> param = getSingleton(op.getParameters());
+        assertEquals("name",          "Version",             String.valueOf(param.getName()));
+        assertEquals("minimumOccurs", 0,                     param.getMinimumOccurs());
+        assertEquals("maximumOccurs", 1,                     param.getMaximumOccurs());
+        assertEquals("direction",     ParameterDirection.IN, param.getDirection());
+    }
+
+    /**
      * Tests the marshalling of a service metadata.
      *
      * @throws JAXBException if an error occurred during the during marshalling process.
@@ -103,7 +139,10 @@ public final strictfp class DefaultServi
      */
     @Test
     public void testUnmarshal() throws JAXBException {
-        assertTrue(create().equals(unmarshalFile(DefaultServiceIdentification.class, XML_FILE), ComparisonMode.DEBUG));
+        final ServiceIdentification id = unmarshalFile(ServiceIdentification.class, XML_FILE);
+        verify(id);
+        final CoupledResource resource = getSingleton(id.getCoupledResources());
+        assertTitleEquals("resourceReference", "WMS specification", getSingleton(resource.getResourceReferences()));
     }
 
     /**
@@ -113,6 +152,9 @@ public final strictfp class DefaultServi
      */
     @Test
     public void testUnmarshalLegacy() throws JAXBException {
-        assertTrue(create().equals(unmarshalFile(DefaultServiceIdentification.class, XML_FILE_LEGACY), ComparisonMode.DEBUG));
+        final ServiceIdentification id = unmarshalFile(ServiceIdentification.class, XML_FILE_LEGACY);
+        verify(id);
+        final CoupledResource resource = getSingleton(id.getCoupledResources());
+        assertEquals("scopedName", "mySpace:ABC-123", String.valueOf(resource.getScopedName()));
     }
 }

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/ServiceIdentification.xml
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/ServiceIdentification.xml?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/ServiceIdentification.xml (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/resources/org/apache/sis/metadata/iso/identification/ServiceIdentification.xml Mon Jan 22 11:25:26 2018
@@ -21,6 +21,7 @@
 <srv:SV_ServiceIdentification
     xmlns:srv = "http://standards.iso.org/iso/19115/-3/srv/2.0"
     xmlns:mri = "http://standards.iso.org/iso/19115/-3/mri/1.0"
+    xmlns:cit = "http://standards.iso.org/iso/19115/-3/cit/1.0"
     xmlns:gco = "http://standards.iso.org/iso/19115/-3/gco/1.0"
     xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation = "http://standards.iso.org/iso/19115/-3/srv/2.0
@@ -32,7 +33,7 @@
   </mri:abstract>
 
   <srv:serviceType>
-    <gco:LocalName>Web Map Server</gco:LocalName>
+    <gco:ScopedName>Web Map Server</gco:ScopedName>
   </srv:serviceType>
 
   <srv:serviceTypeVersion>
@@ -45,7 +46,16 @@
 
   <srv:coupledResource>
     <srv:SV_CoupledResource>
-      <gco:ScopedName>mySpace:ABC-123</gco:ScopedName>
+      <srv:scopedName>
+        <gco:ScopedName>mySpace:ABC-123</gco:ScopedName>
+      </srv:scopedName>
+      <srv:resourceReference>
+        <cit:CI_Citation>
+          <cit:title>
+             <gco:CharacterString>WMS specification</gco:CharacterString>
+          </cit:title>
+       </cit:CI_Citation>
+      </srv:resourceReference>
       <srv:operation>
         <srv:SV_OperationMetadata>
           <srv:operationName>
@@ -58,16 +68,18 @@
           <srv:parameter>
             <srv:SV_Parameter>
               <srv:name>
-                <gco:aName>
-                  <gco:CharacterString>Version</gco:CharacterString>
-                </gco:aName>
-                <gco:attributeType>
-                  <gco:TypeName>
-                    <gco:aName>
-                      <gco:CharacterString>CharacterString</gco:CharacterString>
-                    </gco:aName>
-                  </gco:TypeName>
-                </gco:attributeType>
+                <gco:MemberName>
+                  <gco:aName>
+                    <gco:CharacterString>Version</gco:CharacterString>
+                  </gco:aName>
+                  <gco:attributeType>
+                    <gco:TypeName>
+                      <gco:aName>
+                        <gco:CharacterString>CharacterString</gco:CharacterString>
+                      </gco:aName>
+                    </gco:TypeName>
+                  </gco:attributeType>
+                </gco:MemberName>
               </srv:name>
               <srv:direction>
                 <srv:SV_ParameterDirection>in</srv:SV_ParameterDirection>
@@ -97,16 +109,18 @@
       <srv:parameter>
         <srv:SV_Parameter>
           <srv:name>
-            <gco:aName>
-              <gco:CharacterString>Version</gco:CharacterString>
-            </gco:aName>
-            <gco:attributeType>
-              <gco:TypeName>
-                <gco:aName>
-                  <gco:CharacterString>CharacterString</gco:CharacterString>
-                </gco:aName>
-              </gco:TypeName>
-            </gco:attributeType>
+            <gco:MemberName>
+              <gco:aName>
+                <gco:CharacterString>Version</gco:CharacterString>
+              </gco:aName>
+              <gco:attributeType>
+                <gco:TypeName>
+                  <gco:aName>
+                    <gco:CharacterString>CharacterString</gco:CharacterString>
+                  </gco:aName>
+                </gco:TypeName>
+              </gco:attributeType>
+            </gco:MemberName>
           </srv:name>
           <srv:direction>
             <srv:SV_ParameterDirection>in</srv:SV_ParameterDirection>

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_GenericName.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -53,7 +53,7 @@ public final class GO_GenericName extend
     }
 
     /**
-     * Does the link between an {@link GenericName} and the adapter associated.
+     * Replaces a generic name by its wrapper.
      * JAXB calls automatically this method at marshalling-time.
      *
      * @param  value  the implementing class for this metadata value.
@@ -65,7 +65,7 @@ public final class GO_GenericName extend
     }
 
     /**
-     * Does the link between adapters and the way they will be unmarshalled.
+     * Unwraps the generic name from the given element.
      * JAXB calls automatically this method at unmarshalling-time.
      *
      * @param  value  the wrapper, or {@code null} if none.

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_LocalName.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -20,7 +20,10 @@ import org.opengis.util.LocalName;
 
 
 /**
- * JAXB wrapper in order to map implementing class with the GeoAPI interface.
+ * Same as {@link GO_GenericName}, but for cases where the element type is declared as {@code LocalName}
+ * instead than {@code GenericName}. This adapter does not provide any new functionality;
+ * its sole purpose is to declare types matching JAXB expectation.
+ *
  * This adapter is used for all the following mutually exclusive properties
  * (only one can be defined at time):
  *
@@ -52,8 +55,8 @@ public final class GO_LocalName extends
     }
 
     /**
-     * Does the link between an {@link org.apache.sis.util.iso.AbstractName} and the adapter associated.
-     * JAXB calls automatically this method at marshalling-time.
+     * Replaces a generic name by its wrapper.
+     * JAXB calls automatically this method at marshalling time.
      *
      * @param  value  the implementing class for this metadata value.
      * @return an wrapper which contains the metadata value.
@@ -64,8 +67,8 @@ public final class GO_LocalName extends
     }
 
     /**
-     * Does the link between adapters and the way they will be unmarshalled.
-     * JAXB calls automatically this method at unmarshalling-time.
+     * Unwraps the generic name from the given element.
+     * JAXB calls automatically this method at unmarshalling time.
      *
      * @param  value  the wrapper, or {@code null} if none.
      * @return the implementing class.

Copied: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_MemberName.java (from r1821836, sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java)
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_MemberName.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_MemberName.java&p1=sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java&r1=1821836&r2=1821837&rev=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_MemberName.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_MemberName.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -14,30 +14,58 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.jaxb.metadata.direct;
+package org.apache.sis.internal.jaxb.gco;
 
-import org.apache.sis.util.iso.DefaultMemberName;
 import org.opengis.util.MemberName;
 
 
 /**
- * JAXB adapter mapping implementing class to the GeoAPI interface. See
- * package documentation for more information about JAXB and interface.
+ * Same as {@link GO_GenericName}, but for cases where the element type is declared as {@code MemberName}
+ * instead than {@code GenericName}. This adapter does not provide any new functionality; its sole purpose
+ * is to declare types matching JAXB expectation.
  *
+ * @author  Cédric Briançon (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
- * @version 0.5
- * @since   0.5
+ * @version 1.0
+ * @since   1.0
  * @module
  */
-public final class GO_MemberName extends MetadataAdapter<MemberName, DefaultMemberName> {
+public final class GO_MemberName extends NameAdapter<GO_MemberName, MemberName> {
     /**
-     * Converts a GeoAPI interface to the SIS implementation for XML marshalling.
+     * Empty constructor for JAXB only.
+     */
+    public GO_MemberName() {
+    }
+
+    /**
+     * Wraps a name at marshalling-time.
+     */
+    private GO_MemberName(final MemberName value) {
+        name = value;
+    }
+
+    /**
+     * Replaces a generic name by its wrapper.
+     * JAXB calls automatically this method at marshalling time.
+     *
+     * @param  value  the implementing class for this metadata value.
+     * @return an wrapper which contains the metadata value.
+     */
+    @Override
+    public GO_MemberName marshal(final MemberName value) {
+        return (value != null) ? new GO_MemberName(value) : null;
+    }
+
+    /**
+     * Unwraps the generic name from the given element.
+     * JAXB calls automatically this method at unmarshalling time.
      *
-     * @param  value  the bound type value, here the GeoAPI interface.
-     * @return the adapter for the given value, here the SIS implementation.
+     * @param  value  the wrapper, or {@code null} if none.
+     * @return the implementing class.
      */
     @Override
-    public DefaultMemberName marshal(MemberName value) {
-        return DefaultMemberName.castOrCopy(value);
+    public MemberName unmarshal(final GO_MemberName value) {
+        return (value != null) ? (MemberName) value.name : null;
     }
 }

Copied: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_ScopedName.java (from r1821836, sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java)
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_ScopedName.java?p2=sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_ScopedName.java&p1=sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java&r1=1821836&r2=1821837&rev=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/direct/GO_ScopedName.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/GO_ScopedName.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -14,57 +14,58 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.jaxb.metadata.direct;
+package org.apache.sis.internal.jaxb.gco;
 
-import javax.xml.bind.annotation.adapters.XmlAdapter;
 import org.opengis.util.ScopedName;
-import org.opengis.util.GenericName;
-import org.apache.sis.internal.jaxb.gco.NameValue;
 
 
 /**
- * JAXB adapter mapping implementing class to the GeoAPI interface. See
- * package documentation for more information about JAXB and interface.
+ * Same as {@link GO_GenericName}, but for cases where the element type is declared as {@code ScopedName}
+ * instead than {@code GenericName}. This adapter does not provide any new functionality; its sole purpose
+ * is to declare types matching JAXB expectation.
  *
+ * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
- *
- * @see org.apache.sis.internal.jaxb.gco.GO_GenericName
- *
- * @since 0.5
+ * @author  Guilhem Legal (Geomatys)
+ * @version 1.0
+ * @since   1.0
  * @module
  */
-public final class GO_ScopedName extends XmlAdapter<NameValue.Scoped, ScopedName> {
+public final class GO_ScopedName extends NameAdapter<GO_ScopedName, ScopedName> {
+    /**
+     * Empty constructor for JAXB only.
+     */
+    public GO_ScopedName() {
+    }
+
+    /**
+     * Wraps a name at marshalling-time.
+     */
+    private GO_ScopedName(final ScopedName value) {
+        name = value;
+    }
+
     /**
-     * Converts a GeoAPI interface to the SIS implementation for XML marshalling.
+     * Replaces a generic name by its wrapper.
+     * JAXB calls automatically this method at marshalling time.
      *
-     * @param  name  the bound type value, here the GeoAPI interface.
-     * @return the adapter for the given value, here the SIS implementation.
+     * @param  value  the implementing class for this metadata value.
+     * @return an wrapper which contains the metadata value.
      */
     @Override
-    public NameValue.Scoped marshal(final ScopedName name) {
-        if (name != null) {
-            final NameValue.Scoped code = new NameValue.Scoped();
-            code.setName(name);
-            return code;
-        }
-        return null;
+    public GO_ScopedName marshal(final ScopedName value) {
+        return (value != null) ? new GO_ScopedName(value) : null;
     }
 
     /**
-     * Returns the scope name from the given string.
+     * Unwraps the generic name from the given element.
+     * JAXB calls automatically this method at unmarshalling time.
      *
-     * @param  code  the metadata value.
-     * @return the value to marshal (which is the same).
+     * @param  value  the wrapper, or {@code null} if none.
+     * @return the implementing class.
      */
     @Override
-    public ScopedName unmarshal(final NameValue.Scoped code) {
-        if (code != null) {
-            final GenericName parsed = code.getName();
-            if (parsed instanceof ScopedName) {
-                return (ScopedName) parsed;
-            }
-        }
-        return null;
+    public ScopedName unmarshal(final GO_ScopedName value) {
+        return (value != null) ? (ScopedName) value.name : null;
     }
 }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gco/NameAdapter.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -27,6 +27,7 @@ import org.apache.sis.util.iso.DefaultLo
 import org.apache.sis.util.iso.DefaultTypeName;
 import org.apache.sis.util.iso.DefaultMemberName;
 import org.apache.sis.util.resources.Errors;
+import org.apache.sis.internal.jaxb.FilterByVersion;
 
 
 /**
@@ -44,7 +45,7 @@ import org.apache.sis.util.resources.Err
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
  * @author  Guilhem Legal (Geomatys)
- * @version 0.8
+ * @version 1.0
  * @since   0.3
  * @module
  */
@@ -74,7 +75,7 @@ abstract class NameAdapter<ValueType ext
     }
 
     /**
-     * Returns the {@code LocalName} or {@code ScopedName} to marshall. Returns {@code null} if the name
+     * Returns the {@code LocalName} or {@code ScopedName} to marshal. Returns {@code null} if the name
      * is a {@link TypeName} or a {@link MemberName}, in order to use {@link #getName()} instead.
      * Example:
      *
@@ -93,8 +94,11 @@ abstract class NameAdapter<ValueType ext
         if (name instanceof LocalName) {
             if (name instanceof TypeName || name instanceof MemberName) {
                 return null;
-            } else {
+            } else if (FilterByVersion.LEGACY_METADATA.accept()) {
                 code = new NameValue.Local();
+            } else {
+                // ISO 19115-3:2016 does not seem to define gco:LocalName anymore.
+                code = new NameValue.Scoped();
             }
         } else if (name instanceof ScopedName) {
             code = new NameValue.Scoped();
@@ -106,7 +110,7 @@ abstract class NameAdapter<ValueType ext
     }
 
     /**
-     * Returns the {@code TypeName} or {@code MemberName} to marshall. Returns {@code null} if the name
+     * Returns the {@code TypeName} or {@code MemberName} to marshal. Returns {@code null} if the name
      * is a {@link LocalName} or {@link ScopedName}, in order to use {@link #getValue()} instead.
      * Example:
      *

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilterVersion.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -18,6 +18,7 @@ package org.apache.sis.xml;
 
 import java.util.Map;
 import java.util.HashMap;
+import java.util.Collections;
 import org.apache.sis.util.collection.Containers;
 import org.apache.sis.internal.jaxb.LegacyNamespaces;
 
@@ -72,7 +73,15 @@ enum FilterVersion {
         new String[] {
             Namespaces.GCX, LegacyNamespaces.GMX,
             Namespaces.GCO, LegacyNamespaces.GCO,
-            Namespaces.SRV, LegacyNamespaces.SRV}),
+            Namespaces.SRV, LegacyNamespaces.SRV},
+        Collections.singletonMap(LegacyNamespaces.GCO, Namespaces.GCO)),
+        /*
+         * For the way back from legacy ISO 19139:2007 to new ISO 19115-3:2016, we must rely on
+         * FilteredStreamResolver (do NOT declare entries in 'toImpl', because some namespaces
+         * must be left unchanged). An exception to this rule is the "gco" namespace because
+         * FilteredStreamResolver renames only element namespaces while we need to rename also
+         * attributes in "gco" namespace (e.g. "gco:nilReason").
+         */
 
     /**
      * GML using the legacy {@code "http://www.opengis.net/gml"} namespace.
@@ -131,17 +140,17 @@ enum FilterVersion {
      * @param  additional  additional (<var>impl</var>, <var>view</var>) mapping for a few namespaces
      *                     having different {@code view} values.
      */
-    private FilterVersion(final String[] impl, final String view, final String[] additional) {
+    private FilterVersion(final String[] impl, final String view, final String[] additional,
+            final Map<String,String> toImpl)
+    {
         toView = new HashMap<>(Containers.hashMapCapacity(impl.length));
-        toImpl = new HashMap<>();
+        this.toImpl = toImpl;
         for (final String e : impl) {
             toView.put(e, view);
         }
         for (int i=0; i<additional.length;) {
-            final String p = additional[i++];
-            final String v = additional[i++];
-            toView.put(p, v);
-            toImpl.put(v, p);
+            toView.put(additional[i++],
+                       additional[i++]);
         }
         manyToOne = true;
     }

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredStreamReader.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredStreamReader.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredStreamReader.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/xml/FilteredStreamReader.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -26,7 +26,7 @@ import javax.xml.stream.util.StreamReade
 /**
  * A filter replacing the namespaces found in a XML document by the namespaces expected by SIS at unmarshalling time.
  * This class forwards every method calls to the wrapped {@link XMLStreamReader}, with all {@code namespaceURI}
- * arguments filtered before to be delegated.
+ * arguments filtered before being delegated.
  *
  * See {@link FilteredNamespaces} for more information.
  *

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=1821837&r1=1821836&r2=1821837&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] Mon Jan 22 11:25:26 2018
@@ -4,13 +4,6 @@
 # Lines with two-spaces  indentation are classes.
 # Lines with four-spaces indentation are attributes.
 #
-http://www.isotc211.org/2005/gmd
-  RS_Identifier
-    <type>
-    authority
-    code
-    codeSpace
-    version
 http://standards.iso.org/iso/19115/-3/cit/1.0
   CI_Address
     <type>
@@ -957,9 +950,7 @@ http://standards.iso.org/iso/19115/-3/sr
     <type>
   SV_CoupledResource
     <type>
-    identifier
     operation
-    operationName
     resource
     resourceReference
   SV_CouplingType
@@ -971,20 +962,18 @@ http://standards.iso.org/iso/19115/-3/sr
     operation
   SV_OperationMetadata
     <type>
-    DCP
     connectPoint
     dependsOn
     distributedComputingPlatform
     invocationName
     operationDescription
     operationName
-    parameters
+    parameter
   SV_Parameter
     <type>
     description
     direction
     name
-    optionality
     repeatability
     valueType
   SV_ParameterDirection

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java?rev=1821837&r1=1821836&r2=1821837&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java [UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/test/java/org/apache/sis/test/XMLComparator.java [UTF-8] Mon Jan 22 11:25:26 2018
@@ -94,6 +94,7 @@ public strictfp class XMLComparator {
         map.put("xsi",   Namespaces.XSI);
         map.put("gco",   Namespaces.GCO);
         map.put("mdb",   Namespaces.MDB);
+        map.put("srv",   Namespaces.SRV);
         map.put("gml",   Namespaces.GML);
         map.put("gmd",   LegacyNamespaces.GMD);
         map.put("gmx",   LegacyNamespaces.GMX);



Mime
View raw message