sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1818143 - in /sis/branches/ISO-19115-3/core: sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/ sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/ sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/r...
Date Thu, 14 Dec 2017 15:00:26 GMT
Author: desruisseaux
Date: Thu Dec 14 15:00:26 2017
New Revision: 1818143

URL: http://svn.apache.org/viewvc?rev=1818143&view=rev
Log:
Adjustment in the switch between ISO 19139 and ISO 19115-3 marshalling.

Modified:
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/CI_Responsibility.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultFeatureTypeList.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
    sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/package-info.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
    sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/code/PT_Locale.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -131,7 +131,7 @@ public final class PT_Locale extends Xml
          */
         @XmlElement(name = "languageCode")
         private LanguageCode getLanguageCode() {
-            return Context.isLatestMetadata() ? null : languageCode;
+            return Context.isLegacyMetadata() ? languageCode : null;
         }
 
         /**
@@ -147,7 +147,7 @@ public final class PT_Locale extends Xml
          */
         @XmlElement(name = "language")
         private LanguageCode getLanguage() {
-            return Context.isLatestMetadata() ? languageCode : null;
+            return Context.isLegacyMetadata() ? null : languageCode;
         }
 
         /**

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/CI_Responsibility.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/CI_Responsibility.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/CI_Responsibility.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/CI_Responsibility.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -82,10 +82,10 @@ public final class CI_Responsibility ext
     @XmlElementRef
     @SuppressWarnings("deprecation")
     public DefaultResponsibility getElement() {
-        if (Context.isLatestMetadata()) {
-            return DefaultResponsibility.castOrCopy(metadata);
-        } else {
+        if (Context.isLegacyMetadata()) {
             return DefaultResponsibleParty.castOrCopy(metadata);
+        } else {
+            return DefaultResponsibility.castOrCopy(metadata);
         }
     }
 

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.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/ReferenceSystemMetadata.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -32,7 +32,7 @@ import org.apache.sis.util.ComparisonMod
 /**
  * An implementation of {@link ReferenceSystem} marshalled as specified in ISO 19115.
  * This is different than the {@code ReferenceSystem} implementation provided in the
- * referencing module, since the later marshall the CRS as specified in GML (close
+ * referencing module, since the later marshals the CRS as specified in GML (close
  * to ISO 19111 model).
  *
  * <p>Note that this implementation is very simple and serves no other purpose than
being
@@ -91,7 +91,7 @@ public class ReferenceSystemMetadata ext
     @XmlElement(name = "referenceSystemIdentifier")
     @XmlJavaTypeAdapter(MD_Identifier.class)
     public final Identifier getName() {
-        return Context.isLatestMetadata() ? super.getName() : null;
+        return Context.isLegacyMetadata() ? null : super.getName();
     }
 
     /**
@@ -110,7 +110,7 @@ public class ReferenceSystemMetadata ext
     @XmlElement(name = "referenceSystemIdentifier")
     @XmlJavaTypeAdapter(RS_Identifier.class)
     private Identifier getLegacyName() {
-        return Context.isLatestMetadata() ? null : getName();
+        return Context.isLegacyMetadata() ? super.getName() : null;
     }
 
     /**

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -31,7 +31,7 @@ import org.apache.sis.metadata.TitleProp
 import org.apache.sis.measure.ValueRange;
 import org.apache.sis.util.iso.Types;
 import org.apache.sis.xml.Namespaces;
-import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.apache.sis.internal.metadata.Dependencies;
 import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
 
@@ -305,9 +305,9 @@ public class DefaultExtendedElementInfor
      */
     @Override
     @Deprecated
-    @XmlElement(name = "shortName")
+    @XmlElement(name = "shortName", namespace = LegacyNamespaces.GMD)
     public String getShortName()  {
-    	return Context.isLatestMetadata() ? null : shortName;
+        return shortName;
     }
 
     /**
@@ -334,9 +334,9 @@ public class DefaultExtendedElementInfor
      */
     @Override
     @Deprecated
-    @XmlElement(name = "domainCode")
+    @XmlElement(name = "domainCode", namespace = LegacyNamespaces.GMD)
     public Integer getDomainCode() {
-        return Context.isLatestMetadata() ? null : domainCode;
+        return domainCode;
     }
 
     /**

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultFeatureTypeList.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultFeatureTypeList.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultFeatureTypeList.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultFeatureTypeList.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -19,6 +19,7 @@ package org.apache.sis.metadata.iso;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
 import org.opengis.metadata.FeatureTypeList;
 
 
@@ -42,7 +43,7 @@ import org.opengis.metadata.FeatureTypeL
  * @author  Martin Desruisseaux (IRD, Geomatys)
  * @author  Touraïvane (IRD)
  * @author  Cédric Briançon (Geomatys)
- * @version 0.3
+ * @version 1.0
  * @since   0.3
  * @module
  *
@@ -50,11 +51,11 @@ import org.opengis.metadata.FeatureTypeL
  */
 @Deprecated                                     // TODO: after deletion, search "FeatureTypeList"
on the whole code base.
 @SuppressWarnings("CloneableClassWithoutClone")                 // ModifiableMetadata needs
shallow clones.
-@XmlType(propOrder = {
+@XmlType(namespace = LegacyNamespaces.GMD, propOrder = {
     "spatialObject",
     "spatialSchemaName"
 })
-@XmlRootElement(name = "MD_FeatureTypeList")
+@XmlRootElement(name = "MD_FeatureTypeList", namespace = LegacyNamespaces.GMD)
 public class DefaultFeatureTypeList extends ISOMetadata implements FeatureTypeList {
     /**
      * Serial number for inter-operability with different versions.

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ImmutableIdentifier.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -37,6 +37,7 @@ import org.apache.sis.io.wkt.Formattable
 import org.apache.sis.io.wkt.Formatter;
 import org.apache.sis.io.wkt.Convention;
 import org.apache.sis.io.wkt.ElementKind;
+import org.apache.sis.xml.Namespaces;
 
 import static org.apache.sis.util.ArgumentChecks.ensureNonNull;
 import static org.apache.sis.util.CharSequences.trimWhitespaces;
@@ -129,13 +130,13 @@ import static org.apache.sis.util.collec
  * @module
  */
 @TitleProperty(name = "code")
-@XmlType(name = "RS_Identifier_Type", propOrder = {
+@XmlType(name = "RS_Identifier_Type", namespace = Namespaces.GMD, propOrder = {
     "authority",
     "code",
     "codeSpace",
     "version"
 })
-@XmlRootElement(name = "RS_Identifier")
+@XmlRootElement(name = "RS_Identifier", namespace = Namespaces.GMD)
 public class ImmutableIdentifier extends FormattableObject implements Identifier, Serializable
{
     /**
      * For cross-version compatibility.

Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/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/acquisition/package-info.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/package-info.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/package-info.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -86,13 +86,15 @@
  *
  * @author  Cédric Briançon (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
- * @version 0.5
+ * @author  Cullen Rombach (Image Matters)
+ * @version 1.0
  * @since   0.3
  * @module
  */
-@XmlSchema(location=Schemas.METADATA_XSD, elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GMI,
xmlns = {
-    @XmlNs(prefix = "gmi", namespaceURI = Namespaces.GMI),
-    @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD),
+@XmlSchema(location=Schemas.METADATA_XSD_ACQUISITION, elementFormDefault=XmlNsForm.QUALIFIED,
namespace=Namespaces.MAC, xmlns = {
+    @XmlNs(prefix = "mac", namespaceURI = Namespaces.MAC),
+    @XmlNs(prefix = "gmw", namespaceURI = Namespaces.GMW),
+    @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC),
     @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO),
     @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI)
 })

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/Context.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -60,40 +60,46 @@ public final class Context extends Marsh
      * The bit flag telling if a marshalling process is under progress.
      * This flag is unset for unmarshalling processes.
      */
-    public static final int MARSHALLING = 1;
+    public static final int MARSHALLING = 0x1;
 
     /**
      * The bit flag for enabling substitution of language codes by character strings.
      *
      * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
-    public static final int SUBSTITUTE_LANGUAGE = 2;
+    public static final int SUBSTITUTE_LANGUAGE = 0x2;
 
     /**
      * The bit flag for enabling substitution of country codes by character strings.
      *
      * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
-    public static final int SUBSTITUTE_COUNTRY = 4;
+    public static final int SUBSTITUTE_COUNTRY = 0x4;
 
     /**
      * The bit flag for enabling substitution of filenames by character strings.
      *
      * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
-    public static final int SUBSTITUTE_FILENAME = 8;
+    public static final int SUBSTITUTE_FILENAME = 0x8;
 
     /**
      * The bit flag for enabling substitution of mime types by character strings.
      *
      * @see org.apache.sis.xml.XML#STRING_SUBSTITUTES
      */
-    public static final int SUBSTITUTE_MIMETYPE = 16;
+    public static final int SUBSTITUTE_MIMETYPE = 0x10;
 
     /**
      * Bit where to store whether {@link #finish()} shall invoke {@code Semaphores.clear(Semaphores.NULL_COLLECTION)}.
      */
-    private static final int CLEAR_SEMAPHORE = 32;
+    private static final int CLEAR_SEMAPHORE = 0x20;
+
+    /**
+     * Whether we are (un)marshalling legacy metadata as defined in 2003 (ISO 19139).
+     * If this flag is not set, then we assume latest metadata as defined in 2014 (ISO 19115:2014).
+     */
+    private static final int LEGACY_METADATA = 0x40;
 
     /**
      * The thread-local context. Elements are created in the constructor, and removed in
a
@@ -136,12 +142,6 @@ public final class Context extends Marsh
     private final Version versionGML;
 
     /**
-     * The metadata version to be marshalled or unmarshalled, or {@code null} if unspecified.
-     * If null, than the latest version is assumed.
-     */
-    private final Version versionMetadata;
-
-    /**
      * The reference resolver currently in use, or {@code null} for {@link ReferenceResolver#DEFAULT}.
      */
     private final ReferenceResolver resolver;
@@ -216,7 +216,7 @@ public final class Context extends Marsh
      * @param  warningListener  the object to inform about warnings.
      */
     @SuppressWarnings("ThisEscapedInObjectConstruction")
-    public Context(final int                bitMasks,
+    public Context(int                      bitMasks,
                    final Locale             locale,
                    final TimeZone           timezone,
                    final Map<String,String> schemas,
@@ -226,27 +226,34 @@ public final class Context extends Marsh
                    final ValueConverter     converter,
                    final WarningListener<?> warningListener)
     {
+        if (versionMetadata != null && versionMetadata.compareTo(LegacyNamespaces.ISO_19115_3)
< 0) {
+            bitMasks |= LEGACY_METADATA;
+        }
         this.bitMasks          = bitMasks;
         this.locales           = new LinkedList<>();
         this.timezone          = timezone;
         this.schemas           = schemas;               // No clone, because this class is
internal.
         this.versionGML        = versionGML;
-        this.versionMetadata   = versionMetadata;
         this.resolver          = resolver;
         this.converter         = converter;
         this.warningListener   = warningListener;
         this.identifiers       = new HashMap<>();
         this.identifiedObjects = new IdentityHashMap<>();
-        if ((bitMasks & MARSHALLING) != 0) {
-            if (!Semaphores.queryAndSet(Semaphores.NULL_COLLECTION)) {
-                this.bitMasks |= CLEAR_SEMAPHORE;
-            }
-        }
         if (locale != null) {
             locales.add(locale);
         }
         previous = CURRENT.get();
         CURRENT.set(this);
+        if ((bitMasks & MARSHALLING) != 0) {
+            /*
+             * Set global semaphore last after we are sure that construction will not fail
+             * (e.g. with an OutOfMemoryError). This is necessary for allowing the caller
+             * to invoke finish() in a finally block.
+             */
+            if (!Semaphores.queryAndSet(Semaphores.NULL_COLLECTION)) {
+                this.bitMasks |= CLEAR_SEMAPHORE;
+            }
+        }
     }
 
     /**
@@ -383,38 +390,14 @@ public final class Context extends Marsh
     }
 
     /**
-     * Returns {@code true} if the metadata version is equals or newer than the specified
version.
-     * If no metadata version was specified, then this method returns {@code true}, i.e.
newest
-     * version is assumed.
-     *
-     * <div class="note"><b>API note:</b>
-     * This method is static for the convenience of performing the check for null context.</div>
-     *
-     * @param  context  the current context, or {@code null} if none.
-     * @param  version  the version to compare to.
-     * @return {@code true} if the metadata version is equals or newer than the specified
version.
-     *
-     * @see #getVersion(String)
-     */
-    public static boolean isMetadataVersion(final Context context, final Version version)
{
-        if (context != null) {
-            final Version versionMetadata = context.versionMetadata;
-            if (versionMetadata != null) {
-                return versionMetadata.compareTo(version) >= 0;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * Returns {@code true} if we are (un)marshalling ISO 19115-3 metadata,
-     * or {@code false} if (un)marshalling ISO 19139 metadata.
-     * This is a convenience method for {@link #isMetadataVersion(Context, Version)}.
+     * Returns {@code true} if we are (un)marshalling the legacy ISO 19139:2007 metadata
format.
+     * A value of {@code false} means that we are (un)marshalling the more recent ISO 19115-3
format,
+     * or that no (un)marshalling process is under way.
      *
-     * @return whether the (un)marshalling process is for ISO 19115-3.
+     * @return whether the (un)marshalling process is for legacy ISO 19139 metadata format.
      */
-    public static boolean isLatestMetadata() {
-        return isMetadataVersion(current(), LegacyNamespaces.ISO_19115_3);
+    public static boolean isLegacyMetadata() {
+        return isFlagSet(current(), LEGACY_METADATA);
     }
 
     /**

Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java?rev=1818143&r1=1818142&r2=1818143&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gmd/Country.java
[UTF-8] Thu Dec 14 15:00:26 2017
@@ -89,7 +89,7 @@ public final class Country extends GO_Ch
      */
     @XmlElement(name = "Country")
     private CodeListUID getCountry() {
-        return Context.isLatestMetadata() ? null : identifier;
+        return Context.isLegacyMetadata() ? identifier : null;
     }
 
     /**
@@ -105,7 +105,7 @@ public final class Country extends GO_Ch
      */
     @XmlElement(name = "CountryCode")
     private CodeListUID getCountryCode() {
-        return Context.isLatestMetadata() ? identifier : null;
+        return Context.isLegacyMetadata() ? null : identifier;
     }
 
     /**



Mime
View raw message