Author: desruisseaux
Date: Thu Feb 1 20:03:14 2018
New Revision: 1822899
URL: http://svn.apache.org/viewvc?rev=1822899&view=rev
Log:
Fix more JAXB annotations.
Modified:
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/SchemaCompliance.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -54,7 +54,7 @@ public final class MetadataUtilities ext
}
/**
- * Returns the given milliseconds time to a date object, or returns null
+ * Converts the given milliseconds time to a date object, or returns null
* if the given time is {@link Long#MIN_VALUE}.
*
* @param value the time in milliseconds.
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultEnvironmentalRecord.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -57,7 +57,7 @@ import static org.apache.sis.internal.me
"averageAirTemperature",
"maxRelativeHumidity",
"maxAltitude",
- "meterologicalConditions" // Really spelled that way in XSD file.
+ "meteorologicalConditions"
})
@XmlRootElement(name = "MI_EnvironmentalRecord")
public class DefaultEnvironmentalRecord extends ISOMetadata implements EnvironmentalRecord
{
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/acquisition/DefaultRequirement.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -78,7 +78,7 @@ import static org.apache.sis.internal.me
"priority",
"requestedDate",
"expiryDate",
- "satisifiedPlan" // Really spelled that way in XSD file.
+ "satisfiedPlans"
})
@XmlRootElement(name = "MI_Requirement")
public class DefaultRequirement extends ISOMetadata implements Requirement {
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultBand.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -66,10 +66,7 @@ import static org.apache.sis.internal.me
"boundMin",
"boundUnits",
"peakResponse",
- "bitsPerValue",
"toneGradation",
- "scaleFactor",
- "offset",
"bandBoundaryDefinition",
"nominalSpatialResolution",
"transferFunctionType",
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultDataIdentification.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -218,7 +218,7 @@ public class DefaultDataIdentification e
* @return character coding standard(s) used.
*/
@Override
- @XmlElement(name = "characterSet")
+ @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD)
public Collection<Charset> getCharacterSets() {
return characterSets = nonNullCollection(characterSets, Charset.class);
}
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultProcessStep.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlElem
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.opengis.util.InternationalString;
+import org.opengis.temporal.TemporalPrimitive;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.citation.Responsibility;
import org.opengis.metadata.maintenance.Scope;
@@ -34,12 +35,11 @@ import org.opengis.metadata.lineage.Proc
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.Namespaces;
import org.apache.sis.internal.jaxb.FilterByVersion;
+import org.apache.sis.internal.jaxb.LegacyNamespaces;
+import org.apache.sis.internal.jaxb.gml.TM_Primitive;
import org.apache.sis.internal.jaxb.metadata.MD_Scope;
-
-import static org.apache.sis.internal.metadata.MetadataUtilities.toDate;
-import static org.apache.sis.internal.metadata.MetadataUtilities.toMilliseconds;
+import org.apache.sis.internal.util.TemporalUtilities;
/**
@@ -73,7 +73,8 @@ import static org.apache.sis.internal.me
@XmlType(name = "LI_ProcessStep_Type", propOrder = {
"description",
"rationale",
- "date",
+ "stepDateTime", // New in ISO 19115:2014
+ "date", // Legacy ISO 19115:2003
"processors",
"reference", // New in ISO 19115:2014
"scope", // New in ISO 19115:2014
@@ -88,7 +89,7 @@ public class DefaultProcessStep extends
/**
* Serial number for inter-operability with different versions.
*/
- private static final long serialVersionUID = -535020568951006598L;
+ private static final long serialVersionUID = -2338712901907082970L;
/**
* Description of the event, including related parameters or tolerances.
@@ -101,11 +102,9 @@ public class DefaultProcessStep extends
private InternationalString rationale;
/**
- * Date and time or range of date and time on or over which the process step occurred,
- * in milliseconds elapsed since January 1st, 1970. If there is no such date, then this
- * field is set to the special value {@link Long#MIN_VALUE}.
+ * Date, time or range of date and time over which the process step occurred.
*/
- private long date = Long.MIN_VALUE;
+ private TemporalPrimitive stepDateTime;
/**
* Identification of, and means of communication with, person(s) and
@@ -174,7 +173,7 @@ public class DefaultProcessStep extends
if (object != null) {
description = object.getDescription();
rationale = object.getRationale();
- date = toMilliseconds(object.getDate());
+ stepDateTime = TemporalUtilities.createInstant(object.getDate());
processors = copyCollection(object.getProcessors(), Responsibility.class);
references = copyCollection(object.getReferences(), Citation.class);
sources = copyCollection(object.getSources(), Source.class);
@@ -253,24 +252,54 @@ public class DefaultProcessStep extends
}
/**
+ * Returns the date, time or range of date and time over which the process step occurred.
+ *
+ * @return date, time or period over which the process step occurred, or {@code null}.
+ *
+ * @since 1.0
+ */
+ @XmlElement(name = "stepDateTime")
+ @XmlJavaTypeAdapter(TM_Primitive.Since2014.class)
+ public TemporalPrimitive getStepDateTime() {
+ return stepDateTime;
+ }
+
+ /**
+ * Sets the date, time or range of date and time over which the process step occurred.
+ *
+ * @param newValue the new date, time or period.
+ *
+ * @since 1.0
+ */
+ public void setStepDateTime(final TemporalPrimitive newValue) {
+ checkWritePermission();
+ stepDateTime = newValue;
+ }
+
+ /**
* Returns the date and time or range of date and time on or over which the process step
occurred.
*
* @return date on or over which the process step occurred, or {@code null}.
+ *
+ * @deprecated As of ISO 19115-1:2014, replaced by {@link #getStepDateTime()}.
*/
@Override
- @XmlElement(name = "dateTime")
+ @Deprecated
+ @XmlElement(name = "dateTime", namespace = LegacyNamespaces.GMD)
public Date getDate() {
- return toDate(date);
+ return FilterByVersion.LEGACY_METADATA.accept() ? TemporalUtilities.getDate(getStepDateTime())
: null;
}
/**
* Sets the date and time or range of date and time on or over which the process step
occurred.
*
* @param newValue the new date.
+ *
+ * @deprecated As of ISO 19115-1:2014, replaced by {@link #setStepDateTime(TemporalPrimitive)}.
*/
+ @Deprecated
public void setDate(final Date newValue) {
- checkWritePermission();
- date = toMilliseconds(newValue);
+ setStepDateTime(TemporalUtilities.createInstant(newValue));
}
/**
@@ -371,7 +400,7 @@ public class DefaultProcessStep extends
* @return product generated as a result of the process step.
*/
@Override
- @XmlElement(name = "output", namespace = Namespaces.GMI)
+ @XmlElement(name = "output")
public Collection<Source> getOutputs() {
return outputs = nonNullCollection(outputs, Source.class);
}
@@ -393,7 +422,7 @@ public class DefaultProcessStep extends
* @return procedure by which the algorithm was applied to derive geographic data, or
{@code null}.
*/
@Override
- @XmlElement(name = "processingInformation", namespace = Namespaces.GMI)
+ @XmlElement(name = "processingInformation")
public Processing getProcessingInformation() {
return processingInformation;
}
@@ -416,7 +445,7 @@ public class DefaultProcessStep extends
* @return report generated by the process step.
*/
@Override
- @XmlElement(name = "report", namespace = Namespaces.GMI)
+ @XmlElement(name = "report")
public Collection<ProcessStepReport> getReports() {
return reports = nonNullCollection(reports, ProcessStepReport.class);
}
Modified: sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/SchemaCompliance.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/SchemaCompliance.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/SchemaCompliance.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-metadata/src/test/java/org/apache/sis/test/xml/SchemaCompliance.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -33,7 +33,6 @@ import java.util.Arrays;
import java.util.Objects;
import java.util.Collections;
import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
import javax.xml.XMLConstants;
import javax.xml.bind.annotation.XmlNs;
import javax.xml.bind.annotation.XmlType;
@@ -94,6 +93,7 @@ public final strictfp class SchemaCompli
private static final Map<String,String> TYPES_TO_MERGE;
static {
final Map<String,String> m = new HashMap<>();
+ m.put("LE_ProcessStep_Type", "LI_ProcessStep_Type");
m.put("MI_Band_Type", "MD_Band_Type");
m.put("MI_CoverageDescription_Type", "MD_CoverageDescription_Type");
m.put("AbstractMX_File_Type", "MX_DataFile_Type");
@@ -680,10 +680,8 @@ public final strictfp class SchemaCompli
final String name = element.name();
final String ns = element.namespace();
isDeprecated = DEPRECATED_NAMESPACES.contains(ns);
- if (isDeprecated != method.isAnnotationPresent(Deprecated.class))
{
- if (!Modifier.isPrivate(method.getModifiers())) {
- throw new SchemaException("Unexpected deprecation status
of " + className + '.' + name);
- }
+ if (!isDeprecated && method.isAnnotationPresent(Deprecated.class))
{
+ throw new SchemaException("Unexpected deprecation status of "
+ className + '.' + name);
}
final Info info = properties.get(name);
if (info == null) {
Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/jaxb/gml/TM_Primitive.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -34,11 +34,11 @@ import org.apache.sis.util.resources.Err
*
* @author Guilhem Legal (Geomatys)
* @author Martin Desruisseaux (Geomatys)
- * @version 0.4
+ * @version 1.0
* @since 0.3
* @module
*/
-public final class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive>
{
+public class TM_Primitive extends PropertyType<TM_Primitive, TemporalPrimitive> {
/**
* Empty constructor for JAXB.
*/
@@ -71,7 +71,7 @@ public final class TM_Primitive extends
* @return {@code TemporalPrimitive.class}
*/
@Override
- protected Class<TemporalPrimitive> getBoundType() {
+ protected final Class<TemporalPrimitive> getBoundType() {
return TemporalPrimitive.class;
}
@@ -82,7 +82,7 @@ public final class TM_Primitive extends
* @return the time period, or {@code null}.
*/
@XmlElement(name = "TimePeriod")
- public TimePeriod getTimePeriod() {
+ public final TimePeriod getTimePeriod() {
final TemporalPrimitive metadata = this.metadata;
return (metadata instanceof Period) ? new TimePeriod((Period) metadata) : null;
}
@@ -94,7 +94,7 @@ public final class TM_Primitive extends
* @return the time instant, or {@code null}.
*/
@XmlElement(name = "TimeInstant")
- public TimeInstant getTimeInstant() {
+ public final TimeInstant getTimeInstant() {
final TemporalPrimitive metadata = this.metadata;
return (metadata instanceof Instant) ? new TimeInstant((Instant) metadata) : null;
}
@@ -105,7 +105,7 @@ public final class TM_Primitive extends
*
* @param period the wrapper to set.
*/
- public void setTimePeriod(final TimePeriod period) {
+ public final void setTimePeriod(final TimePeriod period) {
metadata = null; // Cleaned first in case
of failure.
if (period != null) {
final Context context = Context.current();
@@ -137,7 +137,7 @@ public final class TM_Primitive extends
*
* @param instant the wrapper to set.
*/
- public void setTimeInstant(final TimeInstant instant) {
+ public final void setTimeInstant(final TimeInstant instant) {
metadata = null; // Cleaned first in case
of failure.
if (instant != null) {
final Date position = XmlUtilities.toDate(Context.current(), instant.timePosition);
@@ -168,4 +168,23 @@ public final class TM_Primitive extends
Context.warningOccured(Context.current(), TM_Primitive.class, method, e, true);
}
}
+
+ /**
+ * Wraps the value only if marshalling ISO 19115-3 element.
+ * Otherwise (i.e. if marshalling a legacy ISO 19139:2007 document), omit the element.
+ */
+ public static final class Since2014 extends TM_Primitive {
+ /** Empty constructor used only by JAXB. */
+ private 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_Primitive wrap(final TemporalPrimitive value) {
+ return accept2014() ? super.wrap(value) : null;
+ }
+ }
}
Modified: sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
URL: http://svn.apache.org/viewvc/sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java?rev=1822899&r1=1822898&r2=1822899&view=diff
==============================================================================
--- sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
[UTF-8] (original)
+++ sis/branches/ISO-19115-3/core/sis-utility/src/main/java/org/apache/sis/internal/util/TemporalUtilities.java
[UTF-8] Thu Feb 1 20:03:14 2018
@@ -20,6 +20,7 @@ import java.util.Date;
import org.opengis.temporal.Instant;
import org.opengis.temporal.Period;
import org.opengis.temporal.TemporalFactory;
+import org.opengis.temporal.TemporalPrimitive;
import org.apache.sis.util.Static;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.internal.system.DefaultFactories;
@@ -31,7 +32,7 @@ import org.apache.sis.internal.system.De
*
* @author Martin Desruisseaux (Geomatys)
* @author Guilhem Legal (Geomatys)
- * @version 0.8
+ * @version 1.0
* @since 0.3
* @module
*/
@@ -99,4 +100,28 @@ public final class TemporalUtilities ext
final TemporalFactory factory = getTemporalFactory();
return factory.createPeriod(createInstant(factory, begin), createInstant(factory,
end));
}
+
+ /**
+ * 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.
+ *
+ * @since 1.0
+ */
+ public static Date getDate(final TemporalPrimitive time) {
+ Instant instant;
+ if (time instanceof Instant) {
+ instant = (Instant) time;
+ } else if (time instanceof Period) {
+ instant = ((Period) time).getEnding();
+ if (instant == null) {
+ instant = ((Period) time).getBeginning();
+ }
+ } else {
+ return null;
+ }
+ return instant.getDate();
+ }
}
|