This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/sis.git
commit a95eaf7f5a88dfe41cddda7b5dbebf23228441df Merge: aad6819d0b ea550df01a Author: Martin Desruisseaux <[email protected]> AuthorDate: Thu May 9 15:02:00 2024 +0200 Merge branch 'geoapi-3.1'. .../main/org/apache/sis/filter/TemporalFilter.java | 94 +++----------- .../test/org/apache/sis/filter/PeriodLiteral.java | 13 +- .../org.apache.sis.metadata/main/module-info.java | 1 - .../DefaultDigitalTransferOptions.java | 18 +-- .../metadata/iso/distribution/package-info.java | 2 +- .../sis/metadata/iso/extent/DefaultExtent.java | 2 - .../metadata/iso/extent/DefaultTemporalExtent.java | 31 ++--- .../apache/sis/metadata/iso/extent/Extents.java | 4 - .../iso/identification/AbstractIdentification.java | 41 +++++- .../metadata/iso/identification/package-info.java | 2 +- .../metadata/iso/lineage/DefaultProcessStep.java | 5 +- .../maintenance/DefaultMaintenanceInformation.java | 14 +- .../sis/metadata/iso/maintenance/package-info.java | 2 +- .../sis/metadata/privy/TemporalUtilities.java | 144 --------------------- .../apache/sis/metadata/simple/SimpleDuration.java | 76 ----------- .../apache/sis/pending/temporal/DefaultPeriod.java | 2 +- .../pending/temporal/DefaultPeriodDuration.java} | 42 +++--- .../sis/pending/temporal/TemporalUtilities.java | 103 +++++++++++++++ .../apache/sis/pending/temporal/package-info.java | 6 +- .../org/apache/sis/xml/bind/gml/TM_Primitive.java | 9 +- .../org/apache/sis/xml/bind/gml/TimeInstant.java | 23 ++-- .../apache/sis/xml/bind/gml/TimePeriodBound.java | 4 +- .../org/apache/sis/xml/bind/gts/TM_Duration.java | 136 +++++++++++++++---- .../apache/sis/xml/bind/gts/TM_PeriodDuration.java | 129 ++---------------- .../apache/sis/metadata/PropertyAccessorTest.java | 3 +- .../apache/sis/xml/bind/gml/TimePeriodTest.java | 28 ++-- .../referencing/operation/projection/Robinson.java | 20 ++- .../sis/storage/geotiff/reader/XMLMetadata.java | 3 +- .../apache/sis/storage/netcdf/base/CRSBuilder.java | 4 +- .../apache/sis/storage/base/MetadataBuilder.java | 55 +++++++- .../src/org.apache.sis.util/main/module-info.java | 3 - .../sis/pending/geoapi/temporal/Duration.java | 28 ---- .../sis/pending/geoapi/temporal/Instant.java | 37 ------ .../apache/sis/pending/geoapi/temporal/Period.java | 3 +- .../pending/geoapi/temporal/PeriodDuration.java | 69 ---------- .../sis/pending/geoapi/temporal/Position.java | 36 ------ .../pending/geoapi/temporal/TemporalFactory.java | 39 ------ .../sis/pending/geoapi/temporal/package-info.java | 2 +- .../pending/temporal/DefaultPeriodDuration.java | 85 ------------ .../pending/temporal/DefaultTemporalFactory.java | 63 --------- 40 files changed, 451 insertions(+), 930 deletions(-) diff --cc endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java index e7e0f4d030,f6e567be64..ae78bad713 --- a/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java +++ b/endorsed/src/org.apache.sis.feature/main/org/apache/sis/filter/TemporalFilter.java @@@ -16,12 -16,14 +16,11 @@@ */ package org.apache.sis.filter; - import java.util.Date; import java.time.Instant; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import org.opengis.temporal.Period; -import org.opengis.filter.Filter; -import org.opengis.filter.Expression; -import org.opengis.filter.TemporalOperator; -import org.opengis.filter.TemporalOperatorName; +// Specific to the main branch: +import org.apache.sis.pending.geoapi.temporal.Period; +import org.apache.sis.pending.geoapi.filter.TemporalOperatorName; /** diff --cc endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java index 9a08a1a780,2df1ede402..3c5b646d5b --- a/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java +++ b/endorsed/src/org.apache.sis.feature/test/org/apache/sis/filter/PeriodLiteral.java @@@ -17,6 -17,6 +17,7 @@@ package org.apache.sis.filter; import java.util.Date; ++import java.time.Instant; import java.io.Serializable; // Test dependencies @@@ -51,23 -60,17 +52,15 @@@ final class PeriodLiteral implements Pe * Returns the constant value held by this object. */ @Override public Period getValue() {return this;} + @Override public Period apply(AbstractFeature input) {return this;} /** Returns a bound of this period. */ - @Override public org.apache.sis.pending.geoapi.temporal.Instant getBeginning() {return instant(begin);} - @Override public org.apache.sis.pending.geoapi.temporal.Instant getEnding() {return instant(end);} - - /** Wraps the value that defines a period. */ - private static org.apache.sis.pending.geoapi.temporal.Instant instant(final long t) { - return new org.apache.sis.pending.geoapi.temporal.Instant() { - @Override public Date getDate() {return new Date(t);} - @Override public String toString() {return "Instant[" + TestUtilities.format(getDate()) + '[';} - }; - } + @Override public Instant getBeginning() {return Instant.ofEpochMilli(begin);} + @Override public Instant getEnding() {return Instant.ofEpochMilli(end);} /** Not needed for the tests. */ - @Override public ReferenceIdentifier getName() {throw new UnsupportedOperationException();} - @Override public RelativePosition relativePosition(TemporalPrimitive o) {throw new UnsupportedOperationException();} - @Override public TemporalAmount distance(TemporalGeometricPrimitive o) {throw new UnsupportedOperationException();} - @Override public TemporalAmount length() {throw new UnsupportedOperationException();} - @Override public <N> Expression<Feature,N> toValueType(Class<N> target) {throw new UnsupportedOperationException();} + @Override public <N> Expression<AbstractFeature,N> toValueType(Class<N> target) {throw new UnsupportedOperationException();} + @Override public Class<AbstractFeature> getResourceClass() {return AbstractFeature.class;} /** * Hash code value. Used by the tests for checking the results of deserialization. diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java index 77c6cb5978,06708bb349..955d031cf3 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java @@@ -305,10 -296,10 +306,9 @@@ public class DefaultDigitalTransferOpti * * @since 0.5 */ - @Override @XmlElement(name = "transferFrequency") - @XmlJavaTypeAdapter(TM_PeriodDuration.Since2014.class) - @UML(identifier="transferFrequency", obligation=OPTIONAL, specification=ISO_19115) - public PeriodDuration getTransferFrequency() { + @XmlJavaTypeAdapter(TM_Duration.Since2014.class) + public TemporalAmount getTransferFrequency() { return transferFrequency; } diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java index cd7960e566,cff6577ffc..7e7ae5b81d --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java @@@ -17,6 -17,6 +17,7 @@@ package org.apache.sis.metadata.iso.extent; import java.util.Date; ++import java.time.Instant; import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlSeeAlso; import jakarta.xml.bind.annotation.XmlElement; @@@ -32,9 -32,9 +33,8 @@@ import org.apache.sis.pending.temporal. import org.apache.sis.xml.NilObject; import org.apache.sis.xml.NilReason; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -import org.opengis.temporal.Period; +// Specific to the main branch: +import org.apache.sis.pending.geoapi.temporal.Period; - import org.apache.sis.pending.geoapi.temporal.Instant; /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java index 95501849a0,a495ddccf2..cf319d933c --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/identification/AbstractIdentification.java @@@ -17,6 -17,6 +17,7 @@@ package org.apache.sis.metadata.iso.identification; import java.util.Collection; ++import java.time.temporal.TemporalAmount; import jakarta.xml.bind.annotation.XmlType; import jakarta.xml.bind.annotation.XmlSeeAlso; import jakarta.xml.bind.annotation.XmlElement; @@@ -289,18 -300,7 +298,19 @@@ public class AbstractIdentification ext descriptiveKeywords = copyCollection(object.getDescriptiveKeywords(), Keywords.class); resourceSpecificUsages = copyCollection(object.getResourceSpecificUsages(), Usage.class); resourceConstraints = copyCollection(object.getResourceConstraints(), Constraints.class); - associatedResources = copyCollection(object.getAssociatedResources(), AssociatedResource.class); + if (object instanceof AbstractIdentification) { + final AbstractIdentification c = (AbstractIdentification) object; + spatialRepresentationTypes = copyCollection(c.getSpatialRepresentationTypes(), SpatialRepresentationType.class); + spatialResolutions = copyCollection(c.getSpatialResolutions(), Resolution.class); ++ temporalResolutions = copyCollection(c.getTemporalResolutions(), TemporalAmount.class); + topicCategories = copyCollection(c.getTopicCategories(), TopicCategory.class); + extents = copyCollection(c.getExtents(), Extent.class); + additionalDocumentations = copyCollection(c.getAdditionalDocumentations(), Citation.class); + processingLevel = c.getProcessingLevel(); + associatedResources = copyCollection(c.getAssociatedResources(), DefaultAssociatedResource.class); + } else { + setAggregationInfo(object.getAggregationInfo()); + } } } @@@ -534,6 -534,30 +544,30 @@@ spatialResolutions = writeCollection(newValues, spatialResolutions, Resolution.class); } + /** + * Returns the smallest resolvable temporal period in a resource. + * + * @return smallest resolvable temporal period in a resource. + * + * @since 1.5 + */ - @Override + // @XmlElement at the end of this class. ++ @UML(identifier="temporalResolution", obligation=OPTIONAL, specification=ISO_19115) + public Collection<TemporalAmount> getTemporalResolutions() { + return temporalResolutions = nonNullCollection(temporalResolutions, TemporalAmount.class); + } + + /** + * Sets the smallest resolvable temporal period in a resource. + * + * @param newValues the new temporal resolutions. + * + * @since 1.5 + */ + public void setTemporalResolutions(final Collection<? extends TemporalAmount> newValues) { + temporalResolutions = writeCollection(newValues, temporalResolutions, TemporalAmount.class); + } + /** * Returns the main theme(s) of the resource. * @@@ -869,7 -866,15 +903,12 @@@ * 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. - * - * @todo Currently, the {@code XmlJavaTypeAdapter} used here just internally converts {@code Duration} objects - * into {@code PeriodDuration} objects. Need to add support for {@code IntervalLength} in the future. */ + @XmlElement(name = "temporalResolution") + private Collection<TemporalAmount> getTemporalResolution() { + return FilterByVersion.CURRENT_METADATA.accept() ? getTemporalResolutions() : null; + } + @XmlElement(name = "additionalDocumentation") private Collection<Citation> getAdditionalDocumentation() { return FilterByVersion.CURRENT_METADATA.accept() ? getAdditionalDocumentations() : null; diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java index ab1cbbe71d,dd275b64e4..b788537646 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java @@@ -91,13 -88,8 +91,13 @@@ public class DefaultMaintenanceInformat /** * Serial number for inter-operability with different versions. */ - private static final long serialVersionUID = -8736825706141936429L; + private static final long serialVersionUID = -7934472150551882812L; + /** + * New code list item defined in ISO 19115:2014. + */ + private static final DateType NEXT_UPDATE = DateType.valueOf("NEXT_UPDATE"); + /** * Frequency with which changes and additions are made to the resource after the * initial resource is completed. diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java index f5f507afe2,12a7573630..ce43f62a4b --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriod.java @@@ -17,10 -17,12 +17,10 @@@ package org.apache.sis.pending.temporal; import java.util.Objects; - -// Specific to the geoapi-3.1 and geoapi-4.0 branches: + import java.time.Instant; -import java.time.Duration; -import java.time.temporal.TemporalAmount; -import org.opengis.temporal.Period; + +// Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.Instant; +import org.apache.sis.pending.geoapi.temporal.Period; /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriodDuration.java index f0e014c206,0000000000..6959334a2d mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriodDuration.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/DefaultPeriodDuration.java @@@ -1,59 -1,0 +1,59 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.pending.temporal; + - import java.util.Date; - - // Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.Instant; ++import java.time.temporal.TemporalAmount; ++import org.opengis.temporal.PeriodDuration; + + +/** - * Default implementation of GeoAPI instant. This is a temporary class; ++ * Default implementation of GeoAPI period duration. This is a temporary class; + * GeoAPI temporal interfaces are expected to change a lot in a future revision. + * + * @author Martin Desruisseaux (Geomatys) + */ - final class DefaultInstant implements Instant { - /** The date in milliseconds since epoch. */ - private final long millis; - - /** Creates a new instant for the given date. */ - DefaultInstant(final Date time) { - millis = time.getTime(); - } - - /** Returns the date used for describing temporal position. */ - @Override public Date getDate() { - return new Date(millis); ++public final class DefaultPeriodDuration implements PeriodDuration { ++ /** ++ * The temporal object providing the duration value. ++ */ ++ public final TemporalAmount duration; ++ ++ /** ++ * Creates a new duration. ++ */ ++ public DefaultPeriodDuration(final TemporalAmount duration) { ++ this.duration = duration; + } + - /** String representation in ISO format. */ ++ /** String representation. */ + @Override public String toString() { - return java.time.Instant.ofEpochMilli(millis).toString(); ++ return duration.toString(); + } + + /** Hash code value of the time position. */ + @Override public int hashCode() { - return Long.hashCode(millis) ^ 57; ++ return duration.hashCode() ^ 879337943; + } + + /** Compares with given object for equality. */ + @Override public boolean equals(final Object obj) { - return (obj instanceof DefaultInstant) && ((DefaultInstant) obj).millis == millis; ++ if (obj instanceof DefaultPeriodDuration) { ++ duration.equals(((DefaultPeriodDuration) obj).duration); ++ } ++ return false; + } +} diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java index 0000000000,8c7b1dac7c..97b2c4d75e mode 000000,100644..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/pending/temporal/TemporalUtilities.java @@@ -1,0 -1,103 +1,103 @@@ + /* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.sis.pending.temporal; + + import java.util.Date; ++import java.time.Instant; + import org.opengis.temporal.TemporalPrimitive; + -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -import org.opengis.temporal.Period; ++// Specific to the main branch: ++import org.apache.sis.pending.geoapi.temporal.Period; + + + /** + * Utilities related to ISO 19108 objects. + * + * @author Martin Desruisseaux (Geomatys) + * @author Guilhem Legal (Geomatys) + */ + public final class TemporalUtilities { + /** + * Do not allow instantiation of this class. + */ + private TemporalUtilities() { + } + + /** + * Creates an instant for the given date. + * + * @param time the date for which to create instant, or {@code null}. + * @return the instant, or {@code null} if the given time was null. + * @throws UnsupportedOperationException if the temporal factory is not available on the module path. + */ + public static TemporalPrimitive createInstant(final Date time) throws UnsupportedOperationException { + if (time == null) return null; + final Instant t = time.toInstant(); + return new DefaultPeriod(t, t); + } + + /** + * Creates a period for the given begin and end dates. + * + * @param begin the begin date (inclusive), or {@code null}. + * @param end the end date (inclusive), or {@code null}. + * @return the period, or {@code null} if both arguments are null. + * @throws UnsupportedOperationException if the temporal factory is not available on the module path. + */ + public static TemporalPrimitive createPeriod(final Date begin, final Date end) throws UnsupportedOperationException { + if (begin == null && end == null) return null; + return new DefaultPeriod( + (begin != null) ? begin.toInstant() : null, + (end != null) ? end.toInstant() : null); + } + + /** + * Returns the given value as an instant if the period is a single point in time, or {@code null} otherwis. + * + * @param time the instant or period for which to get a date, or {@code null}. + * @return the instant, or {@code null} if none. + */ + public static Instant getInstant(final TemporalPrimitive time) { + if (time instanceof Period) { + var p = (Period) time; + final Instant begin = p.getBeginning(); + final Instant end = p.getEnding(); + if (begin == null) return end; + if (end == null) return begin; + if (begin.equals(end)) return end; + } + return null; + } + + /** + * Infers a value from the extent as a {@link Date} object. + * This method is used for compatibility with legacy API and may disappear in future SIS version. + * + * @param time the instant or period for which to get a date, or {@code null}. + * @return the requested time as a Java date, or {@code null} if none. + */ + public static Date getAnyDate(final TemporalPrimitive time) { + if (time instanceof Period) { + var p = (Period) time; + Instant instant; + if ((instant = p.getEnding()) != null || (instant = p.getBeginning()) != null) { + return Date.from(instant); + } + } + return null; + } + } diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java index a629d31582,c7a23ec8e8..944ef6900a --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TM_Primitive.java @@@ -17,17 -17,17 +17,17 @@@ package org.apache.sis.xml.bind.gml; import java.util.Date; ++import java.time.Instant; import jakarta.xml.bind.annotation.XmlElement; import org.opengis.temporal.TemporalPrimitive; import org.apache.sis.xml.privy.XmlUtilities; import org.apache.sis.xml.bind.Context; import org.apache.sis.xml.bind.gco.PropertyType; - import org.apache.sis.metadata.privy.TemporalUtilities; + import org.apache.sis.pending.temporal.TemporalUtilities; import org.apache.sis.util.resources.Errors; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -import org.opengis.temporal.Period; +// Specific to the main branch: +import org.apache.sis.pending.geoapi.temporal.Period; - import org.apache.sis.pending.geoapi.temporal.Instant; /** diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java index 764b47d09b,3f3cbebe49..6f98717bb4 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimeInstant.java @@@ -17,6 -17,6 +17,7 @@@ package org.apache.sis.xml.bind.gml; import java.util.Date; ++import java.time.Instant; import javax.xml.datatype.XMLGregorianCalendar; import javax.xml.datatype.DatatypeConfigurationException; import jakarta.xml.bind.annotation.XmlType; @@@ -26,9 -26,9 +27,6 @@@ import org.apache.sis.xml.bind.Context import org.apache.sis.util.privy.Strings; import org.apache.sis.xml.privy.XmlUtilities; - // Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.Instant; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -- /** * Encapsulates a {@code gml:TimeInstant}. This element may be used alone, or included in a diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java index f185aee797,01fe46259c..288abe64ea --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gml/TimePeriodBound.java @@@ -16,15 -16,15 +16,13 @@@ */ package org.apache.sis.xml.bind.gml; ++import java.time.Instant; import javax.xml.datatype.XMLGregorianCalendar; import jakarta.xml.bind.annotation.XmlValue; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlTransient; - // Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.Instant; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -- /** * The {@linkplain TimePeriod#begin begin} or {@linkplain TimePeriod#end end} position in diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_Duration.java index ff54bae54c,945dca99d8..1673c6bd7d --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_Duration.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_Duration.java @@@ -16,16 -16,22 +16,20 @@@ */ package org.apache.sis.xml.bind.gts; + import java.math.BigDecimal; + import java.math.BigInteger; ++import java.time.Period; ++import java.time.temporal.ChronoUnit; ++import java.time.temporal.TemporalAmount; ++import java.time.temporal.TemporalUnit; + import javax.xml.datatype.Duration; + import javax.xml.datatype.DatatypeConfigurationException; import jakarta.xml.bind.annotation.XmlElement; - import org.opengis.temporal.PeriodDuration; import org.apache.sis.xml.bind.Context; + import org.apache.sis.xml.privy.XmlUtilities; import org.apache.sis.xml.bind.gco.PropertyType; - import org.apache.sis.util.Classes; import org.apache.sis.util.resources.Errors; - // Specific to the main branch: - import javax.xml.datatype.Duration; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Period; -import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalAmount; -import java.time.temporal.TemporalUnit; -- /** * Wraps a {@code gts:TM_Duration} element. @@@ -48,7 -52,7 +50,7 @@@ public class TM_Duration extends Proper * * @param metadata the metadata value to marshal. */ - private TM_Duration(final Duration metadata) { - private TM_Duration(final TemporalAmount metadata) { ++ TM_Duration(final TemporalAmount metadata) { super(metadata); } @@@ -64,17 -68,17 +66,24 @@@ } /** - * Returns the GeoAPI interface which is bound by this adapter. + * Returns the interface which is bound by this adapter. * - * @return {@code Duration.class} + * @return {@code TemporalAmount.class} */ @Override - protected Class<Duration> getBoundType() { - return Duration.class; + protected final Class<TemporalAmount> getBoundType() { + return TemporalAmount.class; + } + ++ /** ++ * Returns the wrapped metadata value. ++ */ ++ final TemporalAmount get() { ++ return metadata; + } + /** - * Returns the {@link Duration} generated from the metadata value. + * Returns the {@code Duration} generated from the metadata value. * This method is systematically called at marshalling time by JAXB. * * @return the time period, or {@code null}. diff --cc endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java index a2d7efbdd7,0000000000..472c346555 mode 100644,000000..100644 --- a/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java +++ b/endorsed/src/org.apache.sis.metadata/main/org/apache/sis/xml/bind/gts/TM_PeriodDuration.java @@@ -1,205 -1,0 +1,100 @@@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sis.xml.bind.gts; + - import java.math.BigDecimal; - import java.math.BigInteger; ++import java.time.temporal.TemporalAmount; +import javax.xml.datatype.Duration; - import javax.xml.datatype.DatatypeFactory; - import javax.xml.datatype.DatatypeConfigurationException; +import jakarta.xml.bind.annotation.XmlElement; +import org.opengis.temporal.PeriodDuration; - import org.opengis.util.InternationalString; - import org.apache.sis.xml.bind.Context; - import org.apache.sis.xml.privy.XmlUtilities; ++import org.apache.sis.pending.temporal.DefaultPeriodDuration; +import org.apache.sis.xml.bind.gco.PropertyType; - import org.apache.sis.metadata.privy.TemporalUtilities; - import org.apache.sis.util.SimpleInternationalString; - - // Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.TemporalFactory; + + +/** + * Wraps a {@code gts:TM_PeriodDuration} element. + * - * @todo The work done in the {@link #getElement()} and {@link #setElement(Duration)} methods should move - * to {@link org.apache.sis.xml.ValueConverter}. However, they rely on the {@link org.opengis.temporal} - * API in geoapi-pending, which is not very clear... We prefer to hide this for now. - * + * @author Guilhem Legal (Geomatys) + * @author Martin Desruisseaux (Geomatys) + */ - public class TM_PeriodDuration extends PropertyType<TM_PeriodDuration, PeriodDuration> { ++public final class TM_PeriodDuration extends PropertyType<TM_PeriodDuration, PeriodDuration> { + /** + * Empty constructor for JAXB. + */ + public TM_PeriodDuration() { + } + + /** + * Wraps a Temporal Period Duration value at marshalling-time. + * + * @param metadata the metadata value to marshal. + */ + private TM_PeriodDuration(final PeriodDuration metadata) { + super(metadata); + } + + /** + * Returns the Period Duration value wrapped by a {@code gts:TM_PeriodDuration} element. + * + * @param value the value to marshal. + * @return the adapter which wraps the metadata value. + */ + @Override + protected TM_PeriodDuration wrap(final PeriodDuration value) { + return new TM_PeriodDuration(value); + } + + /** + * Returns the GeoAPI interface which is bound by this adapter. + * + * @return {@code PeriodDuration.class} + */ + @Override + protected final Class<PeriodDuration> getBoundType() { + return PeriodDuration.class; + } + + /** + * Returns the {@link Duration} generated from the metadata value. + * This method is systematically called at marshalling time by JAXB. + * + * @return the time period, or {@code null}. + */ + @XmlElement(name = "TM_PeriodDuration") + public final Duration getElement() { - return toXML(metadata); - } - - /** - * Converts the given ISO 19108 duration into a Java XML duration. - */ - static Duration toXML(final PeriodDuration duration) { - if (duration instanceof org.apache.sis.pending.geoapi.temporal.PeriodDuration) try { - final org.apache.sis.pending.geoapi.temporal.PeriodDuration metadata = - (org.apache.sis.pending.geoapi.temporal.PeriodDuration) duration; - /* - * Get the DatatypeFactory first because if not available, then we don't need to parse - * the calendar fields. This has the side effect of not validating the calendar fields - * syntax (which should be integer values), but maybe this is what the user wants. - */ - final DatatypeFactory factory = XmlUtilities.getDatatypeFactory(); - InternationalString value; - BigInteger years = null; - if ((value = metadata.getYears()) != null) { - years = new BigInteger(value.toString()); - } - BigInteger months = null; - if ((value = metadata.getMonths()) != null) { - months = new BigInteger(value.toString()); - } - BigInteger days = null; - if ((value = metadata.getDays()) != null) { - days = new BigInteger(value.toString()); - } - BigInteger hours = null; - if ((value = metadata.getHours()) != null) { - hours = new BigInteger(value.toString()); - } - BigInteger minutes = null; - if ((value = metadata.getMinutes()) != null) { - minutes = new BigInteger(value.toString()); - } - BigDecimal seconds = null; - if ((value = metadata.getSeconds()) != null) { - seconds = new BigDecimal(value.toString()); - } - return factory.newDuration(true, years, months, days, hours, minutes, seconds); - } catch (DatatypeConfigurationException e) { - Context.warningOccured(Context.current(), TM_PeriodDuration.class, "toXML", e, true); ++ if (metadata instanceof TemporalAmount) { ++ return new TM_Duration((TemporalAmount) metadata).getElement(); + } + return null; + } + + /** + * Sets the value from the {@link Duration}. + * This method is called at unmarshalling time by JAXB. + * + * @param duration the adapter to set. + */ + public final void setElement(final Duration duration) { - metadata = toISO(duration); - } - - /** - * Converts the given Java XML duration into an ISO 19108 duration. - */ - static PeriodDuration toISO(final Duration duration) { - if (duration != null) { - final TemporalFactory factory = TemporalUtilities.getTemporalFactory(); - InternationalString years = null; - int value; - if ((value = duration.getYears()) != 0) { - years = new SimpleInternationalString(Integer.toString(value)); - } - InternationalString months = null; - if ((value = duration.getMonths()) != 0) { - months = new SimpleInternationalString(Integer.toString(value)); - } - InternationalString weeks = null; // No weeks in javax.xml.datatype.Duration - InternationalString days = null; - if ((value = duration.getDays()) != 0) { - days = new SimpleInternationalString(Integer.toString(value)); - } - InternationalString hours = null; - if ((value = duration.getHours()) != 0) { - hours = new SimpleInternationalString(Integer.toString(value)); - } - InternationalString minutes = null; - if ((value = duration.getMinutes()) != 0) { - minutes = new SimpleInternationalString(Integer.toString(value)); - } - InternationalString seconds = null; - if ((value = duration.getSeconds()) != 0) { - seconds = new SimpleInternationalString(Integer.toString(value)); - } - return factory.createPeriodDuration(years, months, weeks, days, hours, minutes, seconds); - } - return null; - } - - /** - * 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 TM_PeriodDuration { - /** 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 TM_PeriodDuration wrap(final PeriodDuration value) { - return accept2014() ? super.wrap(value) : null; ++ var p = new TM_Duration(); ++ p.setElement(duration); ++ TemporalAmount t = p.get(); ++ if (t == null || t instanceof PeriodDuration) { ++ metadata = (PeriodDuration) t; ++ } else { ++ metadata = new DefaultPeriodDuration(t); + } + } +} diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java index e5a8c9a11d,4425dfc907..10f885b76f --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/metadata/PropertyAccessorTest.java @@@ -23,6 -23,6 +23,7 @@@ import java.util.ArrayList import java.util.Collection; import java.util.Locale; import java.util.Date; ++import java.time.temporal.TemporalAmount; import org.opengis.metadata.Identifier; import org.opengis.metadata.extent.Extent; import org.opengis.metadata.citation.Series; @@@ -214,13 -214,13 +215,13 @@@ public final class PropertyAccessorTes Identification.class, "getCredits", "credits", "credit", "Credits", String[].class, Identification.class, "getStatus", "status", "status", "Status", Progress[].class, Identification.class, "getPointOfContacts", "pointOfContacts", "pointOfContact", "Point of contacts", ResponsibleParty[].class, - Identification.class, "getSpatialRepresentationTypes", "spatialRepresentationTypes", "spatialRepresentationType", "Spatial representation types", SpatialRepresentationType[].class, - Identification.class, "getSpatialResolutions", "spatialResolutions", "spatialResolution", "Spatial resolutions", Resolution[].class, - Identification.class, "getTemporalResolutions", "temporalResolutions", "temporalResolution", "Temporal resolutions", TemporalAmount[].class, - Identification.class, "getTopicCategories", "topicCategories", "topicCategory", "Topic categories", TopicCategory[].class, - Identification.class, "getExtents", "extents", "extent", "Extents", Extent[].class, - Identification.class, "getAdditionalDocumentations", "additionalDocumentations", "additionalDocumentation", "Additional documentations", Citation[].class, - Identification.class, "getProcessingLevel", "processingLevel", "processingLevel", "Processing level", Identifier.class, + DataIdentification.class, "getSpatialRepresentationTypes", "spatialRepresentationTypes", "spatialRepresentationType", "Spatial representation types", SpatialRepresentationType[].class, + DataIdentification.class, "getSpatialResolutions", "spatialResolutions", "spatialResolution", "Spatial resolutions", Resolution[].class, - // Identification.class, "getTemporalResolutions", "temporalResolutions", "temporalResolution", "Temporal resolutions", Duration[].class, ++ AbstractIdentification.class, "getTemporalResolutions", "temporalResolutions", "temporalResolution", "Temporal resolutions", TemporalAmount[].class, + DataIdentification.class, "getTopicCategories", "topicCategories", "topicCategory", "Topic categories", TopicCategory[].class, + DataIdentification.class, "getExtents", "extents", "extent", "Extents", Extent[].class, + AbstractIdentification.class, "getAdditionalDocumentations", "additionalDocumentations", "additionalDocumentation", "Additional documentations", Citation[].class, + AbstractIdentification.class, "getProcessingLevel", "processingLevel", "processingLevel", "Processing level", Identifier.class, Identification.class, "getResourceMaintenances", "resourceMaintenances", "resourceMaintenance", "Resource maintenances", MaintenanceInformation[].class, Identification.class, "getGraphicOverviews", "graphicOverviews", "graphicOverview", "Graphic overviews", BrowseGraphic[].class, Identification.class, "getResourceFormats", "resourceFormats", "resourceFormat", "Resource formats", Format[].class, diff --cc endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java index e24d47dafc,3036090230..4699f274c3 --- a/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java +++ b/endorsed/src/org.apache.sis.metadata/test/org/apache/sis/xml/bind/gml/TimePeriodTest.java @@@ -18,6 -18,6 +18,7 @@@ package org.apache.sis.xml.bind.gml import java.util.HashMap; import java.util.Locale; ++import java.time.Instant; import javax.xml.datatype.DatatypeConfigurationException; import jakarta.xml.bind.Marshaller; import jakarta.xml.bind.Unmarshaller; @@@ -38,9 -37,9 +38,6 @@@ import static org.apache.sis.metadata.A import static org.apache.sis.test.TestUtilities.date; import static org.apache.sis.test.TestUtilities.format; - // Specific to the main branch: - import org.apache.sis.pending.geoapi.temporal.Instant; -// Specific to the geoapi-3.1 and geoapi-4.0 branches: -import java.time.Instant; -- /** * Tests the {@link TimePeriod} class. The XML fragments used in this test cases are derived from diff --cc endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java index a58ca86ac7,b54574c342..73a426fd3f --- a/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java +++ b/endorsed/src/org.apache.sis.storage/main/org/apache/sis/storage/base/MetadataBuilder.java @@@ -3179,17 -3219,8 +3216,23 @@@ public class MetadataBuilder for (Constraints r : info.getResourceConstraints()) { addIfNotPresent(identification.getResourceConstraints(), r); } - identification.getTopicCategories().addAll(info.getTopicCategories()); - identification.getSpatialRepresentationTypes().addAll(info.getSpatialRepresentationTypes()); + if (info instanceof DataIdentification) { - final DataIdentification di = (DataIdentification) info; ++ final var di = (DataIdentification) info; + for (Extent e : di.getExtents()) { + addIfNotPresent(identification.getExtents(), e); + } + for (Resolution r : di.getSpatialResolutions()) { + addIfNotPresent(identification.getSpatialResolutions(), r); + } + identification.getTopicCategories().addAll(di.getTopicCategories()); + identification.getSpatialRepresentationTypes().addAll(di.getSpatialRepresentationTypes()); + } ++ if (info instanceof AbstractIdentification) { ++ final var di = (AbstractIdentification) info; ++ for (TemporalAmount r : di.getTemporalResolutions()) { ++ addIfNotPresent(identification.getTemporalResolutions(), r); ++ } ++ } } @SuppressWarnings("LocalVariableHidesMemberVariable") final DefaultMetadata metadata = metadata(); diff --cc endorsed/src/org.apache.sis.util/main/module-info.java index f94456b624,6391f7b34d..de0142c595 --- a/endorsed/src/org.apache.sis.util/main/module-info.java +++ b/endorsed/src/org.apache.sis.util/main/module-info.java @@@ -126,13 -128,6 +126,10 @@@ module org.apache.sis.util org.apache.sis.referencing.epsg, // In the "non-free" sub-project. org.apache.sis.referencing.database; // In the "non-free" sub-project. - exports org.apache.sis.pending.temporal to - org.apache.sis.metadata; - + exports org.apache.sis.pending.geoapi.temporal to + org.apache.sis.metadata, + org.apache.sis.feature; + exports org.apache.sis.converter to org.apache.sis.metadata, org.apache.sis.referencing, diff --cc endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/Period.java index 05c94dcccf,5406add651..9187bc9c74 --- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/Period.java +++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/Period.java @@@ -14,30 -14,16 +14,31 @@@ * See the License for the specific language governing permissions and * limitations under the License. */ +package org.apache.sis.pending.geoapi.temporal; + ++import java.time.Instant; +import org.opengis.temporal.TemporalPrimitive; + /** - * Utility methods for testing XML files or JAXB annotations. - * {@link org.apache.sis.xml.test.AnnotationConsistencyCheck} and - * {@link org.apache.sis.xml.test.SchemaCompliance} verifies JAXB annotations. - * {@link org.apache.sis.xml.test.DocumentComparator} compares an actual XML document with the expected one. - * - * <p>Objects defined in this package are only for SIS testing purpose any many change - * in any future version without notice.</p> + * Placeholder for a GeoAPI interfaces not present in GeoAPI 3.0. * * @author Martin Desruisseaux (Geomatys) + * @since 0.3 - * @version 0.3 ++ * @version 1.5 */ -package org.apache.sis.xml.test; +public interface Period extends TemporalPrimitive { + /** + * Links this period to the instant at which it ends. + * + * @return The beginning instant. + */ + Instant getBeginning(); + + /** + * Links this period to the instant at which it ends. + * + * @return The end instant. + */ + Instant getEnding(); +} diff --cc endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/package-info.java index 95801fd543,d4b582c1b0..f5965ef039 --- a/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/package-info.java +++ b/endorsed/src/org.apache.sis.util/main/org/apache/sis/pending/geoapi/temporal/package-info.java @@@ -23,8 -25,11 +23,8 @@@ * This package is for internal use by SIS only. Classes in this package * may change in incompatible ways in any future version without notice. * - * <h2>Implementation notes</h2> - * Feature type analysis is done through {@link org.apache.sis.storage.sql.feature.Analyzer} class. - * - * @author Johann Sorel (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @author Alexis Manin (Geomatys) + * @since 0.3 - * @version 0.3 ++ * @version 1.5 */ -package org.apache.sis.storage.sql.feature; +package org.apache.sis.pending.geoapi.temporal;
