sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 01/02: Complete ISOMetadata.setIdentifier(Identifier) with a getIdentifier() method. This method was initially not provided because of the risk of collision if a subclass want to provide an "identifier" property of different kind. But ISOMetadata is only for ISO 19115 metadata, and this collision do not happen for that particular conceptual model.
Date Tue, 03 Jul 2018 13:39:23 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 086db2d55757e001179e338be1ee35a9ad52c51f
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Tue Jul 3 11:18:08 2018 +0200

    Complete ISOMetadata.setIdentifier(Identifier) with a getIdentifier() method.
    This method was initially not provided because of the risk of collision if a subclass
want to provide an "identifier" property of different kind.
    But ISOMetadata is only for ISO 19115 metadata, and this collision do not happen for that
particular conceptual model.
---
 .../sis/internal/jaxb/NonMarshalledAuthority.java  |  2 +-
 .../apache/sis/metadata/iso/DefaultMetadata.java   |  5 ++-
 .../org/apache/sis/metadata/iso/ISOMetadata.java   | 42 ++++++++++++++++++----
 .../sis/metadata/iso/acquisition/DefaultEvent.java |  3 +-
 .../iso/acquisition/DefaultInstrument.java         |  3 +-
 .../metadata/iso/acquisition/DefaultOperation.java |  3 +-
 .../metadata/iso/acquisition/DefaultPlatform.java  |  3 +-
 .../iso/acquisition/DefaultPlatformPass.java       |  3 +-
 .../iso/acquisition/DefaultRequirement.java        |  3 +-
 .../metadata/iso/distribution/DefaultMedium.java   |  3 +-
 .../iso/identification/DefaultCoupledResource.java | 14 +++-----
 .../metadata/iso/lineage/DefaultProcessing.java    |  3 +-
 12 files changed, 50 insertions(+), 37 deletions(-)

diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
index 24f1af4..f4eb0c0 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/NonMarshalledAuthority.java
@@ -109,7 +109,7 @@ public final class NonMarshalledAuthority<T> extends CitationConstant.Authority<
 
     /**
      * Returns the first marshallable identifier from the given collection. This method omits
-     * "special" identifiers (ISO 19115-3 attributes, ISBN codes...), which are recognized
by
+     * "special" identifiers (ISO 19115-3 attributes, ISBN codes…), which are recognized
by
      * the implementation class of their authority.
      *
      * <p>This method is used for implementation of {@code getIdentifier()} methods
(singular form)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
index 75a18f7..6635325 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
@@ -70,7 +70,6 @@ import org.apache.sis.internal.jaxb.lan.LocaleAdapter;
 import org.apache.sis.internal.xml.LegacyNamespaces;
 import org.apache.sis.internal.jaxb.FilterByVersion;
 import org.apache.sis.internal.jaxb.Context;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 import org.apache.sis.internal.jaxb.metadata.CI_Citation;
 import org.apache.sis.internal.jaxb.metadata.MD_Identifier;
 
@@ -418,7 +417,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
     @XmlElement(name = "metadataIdentifier")
     @XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
     public Identifier getMetadataIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
@@ -462,7 +461,7 @@ public class DefaultMetadata extends ISOMetadata implements Metadata {
     @Deprecated
     public void setFileIdentifier(final String newValue) {
         // See "Note about deprecated methods implementation"
-        DefaultIdentifier identifier = DefaultIdentifier.castOrCopy(NonMarshalledAuthority.getMarshallable(identifiers));
+        DefaultIdentifier identifier = DefaultIdentifier.castOrCopy(super.getIdentifier());
         if (identifier == null) {
             if (newValue == null) return;
             identifier = new DefaultIdentifier();
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
index da47139..13b8ac8 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/ISOMetadata.java
@@ -133,7 +133,20 @@ public class ISOMetadata extends ModifiableMetadata implements IdentifiedObject,
     // --------------------------------------------------------------------------------------
 
     /**
-     * {@inheritDoc}
+     * Returns all identifiers associated to this object (from conceptual model and from
XML document).
+     * This collection may contain identifiers from different sources:
+     *
+     * <ul class="verbose">
+     *   <li>Identifiers specified in the ISO 19115-1 or 19115-2 abstract models,
+     *       typically (but not necessarily) as an {@code identifier} property
+     *       (may also be {@link DefaultMetadata#getMetadataIdentifier() metadataIdentifier},
+     *       {@link org.apache.sis.metadata.iso.citation.DefaultCitation#getISBN() ISBN}
or
+     *       {@link org.apache.sis.metadata.iso.citation.DefaultCitation#getISSN() ISSN}
properties).</li>
+     *   <li>Identifiers specified in the ISO 19115-3 or 19115-4 XML schemas.
+     *       Those identifiers are typically stored as a result of unmarshalling an XML document.
+     *       Those identifiers can be recognized by an {@linkplain Identifier#getAuthority()
authority}
+     *       sets as one of the {@link IdentifierSpace} constants.</li>
+     * </ul>
      */
     @Override
     public Collection<Identifier> getIdentifiers() {
@@ -166,14 +179,29 @@ public class ISOMetadata extends ModifiableMetadata implements IdentifiedObject,
     }
 
     /**
-     * Sets the identifier for metadata objects that are expected to contain at most one
ISO 19115-1 identifier.
-     * This convenience method is used for implementation of public {@link setIdentifier(Identifier)}
methods in
-     * subclasses having a [0 … 1] cardinality for the {@code identifier} property.
+     * Returns the first identifier which is presumed to be defined by ISO 19115 conceptual
model.
+     * This method checks the {@linkplain Identifier#getAuthority() authority} for filtering
ignorable
+     * identifiers like ISBN/ISSN codes and XML attributes.
+     * This convenience method is provided for implementation of public {@code getIdentifier(Identifier)}
+     * methods in subclasses having an {@code identifier} property with [0 … 1] cardinality.
      *
-     * <p>The default implementation removes all identifiers that are not ISO 19115-3
identifiers before to add
-     * the given one in the {@link #identifiers} collection.</p>
+     * @return an identifier from ISO 19115-3 conceptual model (excluding XML identifiers),
+     *         or {@code null} if none.
+     *
+     * @since 1.0
+     */
+    protected Identifier getIdentifier() {
+        return NonMarshalledAuthority.getMarshallable(identifiers);
+    }
+
+    /**
+     * Sets the identifier for metadata objects that are expected to contain at most one
ISO 19115 identifier.
+     * This convenience method is provided for implementation of public {@code setIdentifier(Identifier)}
methods
+     * in subclasses having an {@code identifier} property with [0 … 1] cardinality.
+     * The default implementation removes all identifiers that would be returned by {@link
#getIdentifier()}
+     * before to add the given one in the {@link #identifiers} collection.
      *
-     * @param  newValue  the new identifier value, or {@code null} for removing the ISO
19115-1 identifier.
+     * @param  newValue  the new identifier value, or {@code null} for removing the identifier.
      *
      * @since 1.0
      */
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
index 39f3e27..b1ffe20 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEvent.java
@@ -30,7 +30,6 @@ import org.opengis.metadata.acquisition.PlatformPass;
 import org.opengis.metadata.acquisition.Sequence;
 import org.opengis.metadata.acquisition.Trigger;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 import static org.apache.sis.internal.metadata.MetadataUtilities.toDate;
 import static org.apache.sis.internal.metadata.MetadataUtilities.toMilliseconds;
@@ -177,7 +176,7 @@ public class DefaultEvent extends ISOMetadata implements Event {
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.java
index c254041..9ef0545 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultInstrument.java
@@ -26,7 +26,6 @@ import org.opengis.metadata.acquisition.Platform;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.util.InternationalString;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 
 /**
@@ -166,7 +165,7 @@ public class DefaultInstrument extends ISOMetadata implements Instrument
{
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultOperation.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultOperation.java
index 78f790a..425d859 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultOperation.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultOperation.java
@@ -31,7 +31,6 @@ import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.identification.Progress;
 import org.opengis.util.InternationalString;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 
 /**
@@ -238,7 +237,7 @@ public class DefaultOperation extends ISOMetadata implements Operation
{
     @Override
     @XmlElement(name = "identifier")
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.java
index fe4451a..34bed9c 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatform.java
@@ -27,7 +27,6 @@ import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.Responsibility;
 import org.opengis.util.InternationalString;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 
 /**
@@ -171,7 +170,7 @@ public class DefaultPlatform extends ISOMetadata implements Platform {
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatformPass.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatformPass.java
index e26f716..78a128a 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatformPass.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultPlatformPass.java
@@ -25,7 +25,6 @@ import org.opengis.metadata.Identifier;
 import org.opengis.metadata.acquisition.Event;
 import org.opengis.metadata.acquisition.PlatformPass;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 
 /**
@@ -130,7 +129,7 @@ public class DefaultPlatformPass extends ISOMetadata implements PlatformPass
{
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
index a3886d6..f7bbc0b 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
@@ -29,7 +29,6 @@ import org.opengis.metadata.acquisition.Requirement;
 import org.opengis.metadata.citation.Citation;
 import org.opengis.metadata.citation.Responsibility;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 import static org.apache.sis.internal.metadata.MetadataUtilities.toDate;
 import static org.apache.sis.internal.metadata.MetadataUtilities.toMilliseconds;
@@ -206,7 +205,7 @@ public class DefaultRequirement extends ISOMetadata implements Requirement
{
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
index 31c0691..d8d92df 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
@@ -35,7 +35,6 @@ import org.apache.sis.metadata.iso.ISOMetadata;
 import org.apache.sis.internal.jaxb.gco.GO_Real;
 import org.apache.sis.internal.jaxb.FilterByVersion;
 import org.apache.sis.internal.xml.LegacyNamespaces;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 import org.apache.sis.internal.jaxb.metadata.MD_Identifier;
 import org.apache.sis.internal.metadata.Dependencies;
 import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
@@ -376,7 +375,7 @@ public class DefaultMedium extends ISOMetadata implements Medium {
     @XmlElement(name = "identifier")
     @XmlJavaTypeAdapter(MD_Identifier.Since2014.class)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
index c892b85..4ee2f81 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultCoupledResource.java
@@ -62,7 +62,7 @@ import org.apache.sis.xml.Namespaces;
     "resource",                 // Ibid.
     "operation",                // Ibid.
     "operationName",            // Legacy ISO 19139:2007
-    "identifier",               // Ibid.
+    "id",                       // Ibid.
     "legacyName"                // Legacy ISO 19139:2007 way to write scoped name
 })
 @XmlRootElement(name = "SV_CoupledResource", namespace = Namespaces.SRV)
@@ -287,10 +287,11 @@ public class DefaultCoupledResource extends ISOMetadata implements CoupledResour
 
     /**
      * Returns the resource identifier, which is assumed to be the name as a string.
-     * Used in legacy ISO 19139:2007 documents.
+     * 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 = LegacyNamespaces.SRV)
-    private String getIdentifier() {
+    private String getId() {
         if (FilterByVersion.LEGACY_METADATA.accept()) {
             final ScopedName name = getScopedName();
             if (name != null) {
@@ -301,13 +302,6 @@ public class DefaultCoupledResource extends ISOMetadata implements CoupledResour
     }
 
     /**
-     * Handled as a synonymous of {@code <srv:operationName>}.
-     */
-    private void setIdentifier(final String identifier) {
-        setOperationName(identifier);
-    }
-
-    /**
      * Returns the {@code <gco:ScopedName>} element to marshal in legacy ISO 19139:2007
element.
      * The {@code <srv:scopedName>} element wrapper (note the lower-case "s") was missing
in that
      * legacy specification. This departure from ISO patterns has been fixed in ISO 19115-3:2016.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessing.java
b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessing.java
index c9896fc..c4a734f 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessing.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessing.java
@@ -26,7 +26,6 @@ import org.opengis.metadata.lineage.Algorithm;
 import org.opengis.metadata.lineage.Processing;
 import org.opengis.util.InternationalString;
 import org.apache.sis.metadata.iso.ISOMetadata;
-import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
 
 
 /**
@@ -154,7 +153,7 @@ public class DefaultProcessing extends ISOMetadata implements Processing
{
     @Override
     @XmlElement(name = "identifier", required = true)
     public Identifier getIdentifier() {
-        return NonMarshalledAuthority.getMarshallable(identifiers);
+        return super.getIdentifier();
     }
 
     /**


Mime
View raw message