You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2022/11/23 17:53:42 UTC
[sis] 05/06: Apply ISO 19115:2014 amendment 1 (2018). https://github.com/opengeospatial/geoapi/issues/77
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 922f8aea9f42da7c59f5843b5dd0d0a66c546cfd
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Wed Nov 23 18:09:11 2022 +0100
Apply ISO 19115:2014 amendment 1 (2018).
https://github.com/opengeospatial/geoapi/issues/77
---
.../jaxb/metadata/MI_RangeElementDescription.java | 29 +++++++++++---
.../sis/metadata/iso/citation/AbstractParty.java | 45 +++++++++++++++++++++-
.../sis/metadata/iso/citation/package-info.java | 2 +-
.../iso/content/DefaultSampleDimension.java | 40 ++++++++++++++++++-
.../sis/metadata/iso/content/package-info.java | 2 +-
.../iso/spatial/AbstractSpatialRepresentation.java | 38 +++++++++++++++++-
.../sis/metadata/iso/spatial/package-info.java | 2 +-
.../sis/test/xml/AnnotationConsistencyCheck.java | 8 ++--
.../org/apache/sis/test/xml/PackageVerifier.java | 17 ++++++++
.../apache/sis/internal/storage/gpx/Copyright.java | 13 ++++++-
10 files changed, 179 insertions(+), 17 deletions(-)
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MI_RangeElementDescription.java b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MI_RangeElementDescription.java
index 225b295413..f2eec6ea3a 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MI_RangeElementDescription.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MI_RangeElementDescription.java
@@ -28,11 +28,11 @@ import org.apache.sis.internal.jaxb.gco.PropertyType;
*
* @author Cédric Briançon (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.3
+ * @version 1.3
* @since 0.3
* @module
*/
-public final class MI_RangeElementDescription extends
+public class MI_RangeElementDescription extends
PropertyType<MI_RangeElementDescription, RangeElementDescription>
{
/**
@@ -49,7 +49,7 @@ public final class MI_RangeElementDescription extends
* @return {@code RangeElementDescription.class}
*/
@Override
- protected Class<RangeElementDescription> getBoundType() {
+ protected final Class<RangeElementDescription> getBoundType() {
return RangeElementDescription.class;
}
@@ -80,7 +80,7 @@ public final class MI_RangeElementDescription extends
* @return the metadata to be marshalled.
*/
@XmlElementRef
- public DefaultRangeElementDescription getElement() {
+ public final DefaultRangeElementDescription getElement() {
return DefaultRangeElementDescription.castOrCopy(metadata);
}
@@ -89,7 +89,26 @@ public final class MI_RangeElementDescription extends
*
* @param value the unmarshalled metadata.
*/
- public void setElement(final DefaultRangeElementDescription value) {
+ public final void setElement(final DefaultRangeElementDescription value) {
metadata = value;
}
+
+ /**
+ * Wraps the value only if marshalling an element from the ISO 19115:2014 metadata model.
+ * Otherwise (i.e. if marshalling according legacy ISO 19115:2003 model), omits the element.
+ */
+ public static final class Since2014 extends MI_RangeElementDescription {
+ /** Empty constructor used only by JAXB. */
+ public Since2014() {
+ }
+
+ /**
+ * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document.
+ *
+ * @return a non-null value only if marshalling ISO 19115-3 or newer.
+ */
+ @Override protected MI_RangeElementDescription wrap(final RangeElementDescription value) {
+ return accept2014() ? super.wrap(value) : null;
+ }
+ }
}
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java
index 3e73833ab9..1b53fcf885 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/AbstractParty.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSeeAlso;
import org.opengis.util.InternationalString;
+import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Contact;
import org.opengis.metadata.citation.Individual;
import org.opengis.metadata.citation.Organisation;
@@ -29,6 +30,8 @@ import org.opengis.metadata.citation.Party;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.metadata.TitleProperty;
import org.apache.sis.util.iso.Types;
+import org.apache.sis.xml.IdentifierSpace;
+import org.apache.sis.internal.jaxb.NonMarshalledAuthority;
/**
@@ -50,14 +53,15 @@ import org.apache.sis.util.iso.Types;
*
* @author Rémi Maréchal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 1.0
+ * @version 1.3
* @since 0.5
* @module
*/
@TitleProperty(name = "name")
@XmlType(name = "AbstractCI_Party_Type", propOrder = {
"name",
- "contactInfo"
+ "contactInfo",
+ "identifiers"
})
@XmlRootElement(name = "AbstractCI_Party")
@XmlSeeAlso({
@@ -172,6 +176,43 @@ public class AbstractParty extends ISOMetadata implements Party {
name = newValue;
}
+ /**
+ * Identifiers of the party.
+ *
+ * <h4>Unified identifiers view</h4>
+ * In this SIS implementation, the collection returned by this method includes the XML identifiers
+ * ({@linkplain IdentifierSpace#ID ID}, {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>),
+ * thus providing a unified view of every kind of identifiers associated to this party.
+ *
+ * <div class="note"><b>XML note:</b>
+ * The {@code <mac:identifier>} element marshalled to XML will exclude all the above cited identifiers,
+ * for compliance with ISO 19115 model. Those identifiers will appear in other XML elements or attributes.</div>
+ *
+ * @return identifiers of the party, or an empty collection if none.
+ *
+ * @since 1.3
+ */
+ @Override
+ @XmlElement(name = "partyIdentifier")
+ public Collection<Identifier> getIdentifiers() {
+ return NonMarshalledAuthority.filterOnMarshalling(super.getIdentifiers());
+ }
+
+ /**
+ * Sets the identifiers of the party.
+ *
+ * <p>XML identifiers ({@linkplain IdentifierSpace#ID ID}, {@linkplain IdentifierSpace#UUID UUID}, <i>etc.</i>),
+ * are not affected by this method, unless they are explicitly provided in the given collection.</p>
+ *
+ * @param newValues the new identifiers values.
+ *
+ * @since 1.3
+ */
+ public void setIdentifiers(Collection<? extends Identifier> newValues) {
+ newValues = NonMarshalledAuthority.setMarshallables(identifiers, newValues);
+ identifiers = writeCollection(newValues, identifiers, Identifier.class);
+ }
+
/**
* Returns the contact information for the party.
*
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/package-info.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/package-info.java
index cefc7e6c01..0b982693df 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/package-info.java
@@ -87,7 +87,7 @@
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @author Cullen Rombach (Image Matters)
- * @version 1.2
+ * @version 1.3
* @since 0.3
* @module
*/
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
index fcba92456e..eab7d2ddfb 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java
@@ -16,6 +16,7 @@
*/
package org.apache.sis.metadata.iso.content;
+import java.util.Collection;
import javax.measure.Unit;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@@ -26,6 +27,7 @@ import org.opengis.metadata.content.Band;
import org.opengis.metadata.content.SampleDimension;
import org.opengis.metadata.content.CoverageContentType;
import org.opengis.metadata.content.TransferFunctionType;
+import org.opengis.metadata.content.RangeElementDescription;
import org.opengis.util.Record;
import org.opengis.util.RecordType;
import org.apache.sis.measure.ValueRange;
@@ -33,6 +35,7 @@ import org.apache.sis.internal.jaxb.gco.GO_Real;
import org.apache.sis.internal.jaxb.gco.GO_Integer;
import org.apache.sis.internal.jaxb.gco.GO_Record;
import org.apache.sis.internal.jaxb.gco.GO_RecordType;
+import org.apache.sis.internal.jaxb.metadata.MI_RangeElementDescription;
import static org.apache.sis.internal.metadata.ImplementationHelper.ensurePositive;
@@ -63,7 +66,7 @@ import static org.apache.sis.internal.metadata.ImplementationHelper.ensurePositi
* @author Rémi Maréchal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
* @author Cullen Rombach (Image Matters)
- * @version 1.0
+ * @version 1.3
* @since 0.5
* @module
*/
@@ -80,7 +83,8 @@ import static org.apache.sis.internal.metadata.ImplementationHelper.ensurePositi
"standardDeviation",
"otherPropertyType",
"otherProperty",
- "bitsPerValue"
+ "bitsPerValue",
+ "rangeElementDescriptions"
})
@XmlRootElement(name = "MD_SampleDimension")
@XmlSeeAlso({DefaultBand.class, DefaultRangeDimension.class})
@@ -147,6 +151,12 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements Sam
*/
private Integer bitsPerValue;
+ /**
+ * Provides the description and values of the specific range elements of a sample dimension.
+ */
+ @SuppressWarnings("serial")
+ private Collection<RangeElementDescription> rangeElementDescriptions;
+
/**
* Smallest distance between which separate points can be distinguished, as specified in
* instrument design.
@@ -475,6 +485,32 @@ public class DefaultSampleDimension extends DefaultRangeDimension implements Sam
}
}
+ /**
+ * Provides the description and values of the specific range elements of a sample dimension.
+ * Example: missing data.
+ *
+ * @return description and values of the specific range elements.
+ *
+ * @since 1.3
+ */
+ @Override
+ @XmlElement(name = "rangeElementDescription")
+ @XmlJavaTypeAdapter(MI_RangeElementDescription.Since2014.class)
+ public Collection<RangeElementDescription> getRangeElementDescriptions() {
+ return rangeElementDescriptions = nonNullCollection(rangeElementDescriptions, RangeElementDescription.class);
+ }
+
+ /**
+ * Sets the description and values of the specific range elements of a sample dimension.
+ *
+ * @param newValues the new range element description.
+ *
+ * @since 1.3
+ */
+ public void setRangeElementDescriptions(final Collection<? extends RangeElementDescription> newValues) {
+ rangeElementDescriptions = writeCollection(newValues, rangeElementDescriptions, RangeElementDescription.class);
+ }
+
/**
* Returns the smallest distance between which separate points can be distinguished,
* as specified in instrument design.
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
index eed8aa9aa4..3a8365c50a 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java
@@ -81,7 +81,7 @@
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @author Cullen Rombach (Image Matters)
- * @version 1.0
+ * @version 1.3
* @since 0.3
* @module
*/
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
index 075a945a17..6ac5fbe269 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/AbstractSpatialRepresentation.java
@@ -18,11 +18,15 @@ package org.apache.sis.metadata.iso.spatial;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.XmlSeeAlso;
+import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import org.opengis.metadata.maintenance.Scope;
import org.opengis.metadata.spatial.SpatialRepresentation;
import org.opengis.metadata.spatial.GridSpatialRepresentation;
import org.opengis.metadata.spatial.VectorSpatialRepresentation;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.jaxb.metadata.MD_Scope;
/**
@@ -40,7 +44,7 @@ import org.apache.sis.metadata.iso.ISOMetadata;
* @author Martin Desruisseaux (IRD, Geomatys)
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
- * @version 1.0
+ * @version 1.3
* @since 0.3
* @module
*/
@@ -56,6 +60,12 @@ public class AbstractSpatialRepresentation extends ISOMetadata implements Spatia
*/
private static final long serialVersionUID = -2238840586154687777L;
+ /**
+ * Level and extent of the spatial representation.
+ */
+ @SuppressWarnings("serial")
+ private Scope scope;
+
/**
* Constructs an initially empty spatial representation.
*/
@@ -75,6 +85,32 @@ public class AbstractSpatialRepresentation extends ISOMetadata implements Spatia
super(object);
}
+ /**
+ * Returns the level and extent of the spatial representation.
+ *
+ * @return level and extent of the spatial representation, or {@code null} if none.
+ *
+ * @since 1.3
+ */
+ @Override
+ @XmlElement(name = "scope")
+ @XmlJavaTypeAdapter(MD_Scope.Since2014.class)
+ public Scope getScope() {
+ return scope;
+ }
+
+ /**
+ * Sets the level and extent of the spatial representation.
+ *
+ * @param newValue the new type of resource.
+ *
+ * @since 1.3
+ */
+ public void setScope(final Scope newValue) {
+ checkWritePermission(scope);
+ scope = newValue;
+ }
+
/**
* Returns a SIS metadata implementation with the values of the given arbitrary implementation.
* This method performs the first applicable action in the following choices:
diff --git a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/package-info.java b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/package-info.java
index 6247c68e01..c706f04840 100644
--- a/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/package-info.java
+++ b/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/spatial/package-info.java
@@ -84,7 +84,7 @@
* @author Touraïvane (IRD)
* @author Cédric Briançon (Geomatys)
* @author Cullen Rombach (Image Matters)
- * @version 1.0
+ * @version 1.3
* @since 0.3
* @module
*/
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/test/xml/AnnotationConsistencyCheck.java b/core/sis-metadata/src/test/java/org/apache/sis/test/xml/AnnotationConsistencyCheck.java
index 28ed7b39a0..05b10aaf34 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/test/xml/AnnotationConsistencyCheck.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/test/xml/AnnotationConsistencyCheck.java
@@ -323,13 +323,15 @@ public abstract strictfp class AnnotationConsistencyCheck extends TestCase {
* General cases (after we processed all the special cases)
* based on which standard defines the type or property.
*/
- if (uml.version() != 0) {
- switch (uml.specification()) {
+ final short version = uml.version();
+ final Specification specification = uml.specification();
+ if (version != 0 && version < specification.defaultVersion()) {
+ switch (specification) {
case ISO_19115: return LegacyNamespaces.GMD;
case ISO_19115_2: return LegacyNamespaces.GMI;
}
}
- switch (uml.specification()) {
+ switch (specification) {
case ISO_19115:
case ISO_19115_2:
case ISO_19115_3: return CodeListUID.METADATA_ROOT;
diff --git a/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java b/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
index 1543bd470a..f1e1c34ba5 100644
--- a/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
+++ b/core/sis-metadata/src/test/java/org/apache/sis/test/xml/PackageVerifier.java
@@ -104,6 +104,20 @@ final strictfp class PackageVerifier {
TYPE_EQUIVALENCES = Collections.unmodifiableMap(m);
}
+ /**
+ * XML elements that are not yet in the XML schema used by this verifier.
+ * They are XML elements added by corrigendum applied on abstract models,
+ * but not yet (at the time of writing this test) propagated in the XML schema.
+ */
+ private static final Map<Class<?>, String> PENDING_XML_ELEMENTS;
+ static {
+ final Map<Class<?>,String> m = new HashMap<>();
+ m.put(org.apache.sis.metadata.iso.citation.AbstractParty.class, "partyIdentifier");
+ m.put(org.apache.sis.metadata.iso.content.DefaultSampleDimension.class, "rangeElementDescription");
+ m.put(org.apache.sis.metadata.iso.spatial.AbstractSpatialRepresentation.class, "scope");
+ PENDING_XML_ELEMENTS = Collections.unmodifiableMap(m);
+ }
+
/**
* The schemas to compare with the JAXB annotations.
* Additional schemas will be loaded as needed.
@@ -436,6 +450,9 @@ final strictfp class PackageVerifier {
}
final SchemaCompliance.Element info = properties.get(name);
if (info == null) {
+ if (name.equals(PENDING_XML_ELEMENTS.get(currentClass))) {
+ return;
+ }
throw new SchemaException(errorInClassMember(javaName)
.append("Unexpected XML element: ").append(name).toString());
}
diff --git a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Copyright.java b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Copyright.java
index c6ced5b153..a544011381 100644
--- a/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Copyright.java
+++ b/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Copyright.java
@@ -25,6 +25,7 @@ import java.util.Locale;
import java.util.Objects;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import org.opengis.metadata.Identifier;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.CitationDate;
import org.opengis.metadata.citation.DateType;
@@ -59,7 +60,7 @@ import org.opengis.metadata.citation.Responsibility;
*
* @author Johann Sorel (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.8
+ * @version 1.3
* @since 0.8
* @module
*/
@@ -250,6 +251,16 @@ resp: for (final Responsibility r : c.getResponsibleParties()) {
return (author != null) ? new SimpleInternationalString(author) : null;
}
+ /**
+ * Returns citation or party identifiers, which is an empty list.
+ *
+ * @return empty.
+ */
+ @Override
+ public Collection<Identifier> getIdentifiers() {
+ return Collections.emptyList();
+ }
+
/* -----------------------------------------------------------------------------------
* Implementation of the Citation object returned by LegalConstraints.getReferences().