Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -21,6 +21,7 @@ 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.util.MemberName; import org.opengis.util.InternationalString; import org.opengis.metadata.Identifier; @@ -29,6 +30,9 @@ import org.opengis.metadata.content.Samp import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.metadata.TitleProperty; import org.apache.sis.internal.metadata.Dependencies; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter; /** @@ -47,7 +51,8 @@ import org.apache.sis.internal.metadata. * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) * @author Rémi Maréchal (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @@ -55,8 +60,9 @@ import org.apache.sis.internal.metadata. @TitleProperty(name = "sequenceIdentifier") @XmlType(name = "MD_RangeDimension_Type", propOrder = { "sequenceIdentifier", - "descriptor", -/// "names" + "description", // New in ISO 19115:2014 + "descriptor", // Legacy ISO 19115:2003 + "name" // New in ISO 19115:2014 }) @XmlRootElement(name = "MD_RangeDimension") @XmlSeeAlso(DefaultBand.class) @@ -166,7 +172,8 @@ public class DefaultRangeDimension exten * @since 0.5 */ @Override -/// @XmlElement(name = "description") + @XmlElement(name = "description") + @XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class) public InternationalString getDescription() { return description; } @@ -193,10 +200,10 @@ public class DefaultRangeDimension exten */ @Override @Deprecated - @XmlElement(name = "descriptor") @Dependencies("getDescription") + @XmlElement(name = "descriptor", namespace = LegacyNamespaces.GMD) public InternationalString getDescriptor() { - return getDescription(); + return FilterByVersion.LEGACY_METADATA.accept() ? getDescription() : null; } /** @@ -221,7 +228,7 @@ public class DefaultRangeDimension exten * @since 0.5 */ @Override -/// @XmlElement(name = "name") + // @XmlElement at the end of this class. public Collection<Identifier> getNames() { return names = nonNullCollection(names, Identifier.class); } @@ -236,4 +243,28 @@ public class DefaultRangeDimension exten public void setNames(final Collection<? extends Identifier> newValues) { names = writeCollection(newValues, names, Identifier.class); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * 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. + */ + @XmlElement(name = "name") + private Collection<Identifier> getName() { + return FilterByVersion.CURRENT_METADATA.accept() ? getNames() : null; + } }
Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeElementDescription.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeElementDescription.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeElementDescription.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeElementDescription.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -25,7 +25,6 @@ import org.opengis.util.InternationalStr import org.opengis.metadata.content.RangeElementDescription; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.metadata.TitleProperty; -import org.apache.sis.xml.Namespaces; /** @@ -48,7 +47,7 @@ import org.apache.sis.xml.Namespaces; * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ @@ -56,10 +55,10 @@ import org.apache.sis.xml.Namespaces; @TitleProperty(name = "name") @XmlType(name = "MI_RangeElementDescription_Type", propOrder = { "name", - "definition"/*, - "rangeElements"*/ // TODO: not yet supported. + "definition", + "rangeElements" }) -@XmlRootElement(name = "MI_RangeElementDescription", namespace = Namespaces.GMI) +@XmlRootElement(name = "MI_RangeElementDescription") public class DefaultRangeElementDescription extends ISOMetadata implements RangeElementDescription { /** * Serial number for inter-operability with different versions. @@ -136,7 +135,7 @@ public class DefaultRangeElementDescript * @return designation associated with a set of range elements, or {@code null}. */ @Override - @XmlElement(name = "name", namespace = Namespaces.GMI, required = true) + @XmlElement(name = "name", required = true) public InternationalString getName() { return name; } @@ -157,7 +156,7 @@ public class DefaultRangeElementDescript * @return description of a set of specific range elements, or {@code null}. */ @Override - @XmlElement(name = "definition", namespace = Namespaces.GMI, required = true) + @XmlElement(name = "definition", required = true) public InternationalString getDefinition() { return definition; } @@ -181,7 +180,7 @@ public class DefaultRangeElementDescript * @todo implements {@link Record} in order to use the annotation. */ @Override - //@XmlElement(name = "rangeElement", namespace = Namespaces.GMI, required = true) + @XmlElement(name = "rangeElement", required = true) public Collection<Record> getRangeElements() { return rangeElements = nonNullCollection(rangeElements, Record.class); } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultSampleDimension.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -21,6 +21,7 @@ import javax.xml.bind.annotation.XmlElem import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlSeeAlso; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.metadata.content.Band; import org.opengis.metadata.content.SampleDimension; import org.opengis.metadata.content.CoverageContentType; @@ -28,6 +29,10 @@ import org.opengis.metadata.content.Tran import org.opengis.util.Record; import org.opengis.util.RecordType; import org.apache.sis.measure.ValueRange; +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 static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive; @@ -51,7 +56,8 @@ import static org.apache.sis.internal.me * * @author Rémi Maréchal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.5 * @module */ @@ -60,14 +66,16 @@ import static org.apache.sis.internal.me "maxValue", "minValue", "units", -/// "scaleFactor", -/// "offset", -/// "meanValue", -/// "numberOfValues", -/// "standardDeviation", -/// "otherPropertyType", -/// "otherProperty", -/// "bitsPerValue" + + // New in ISO 19115-3 + "scaleFactor", + "offset", + "meanValue", + "numberOfValues", + "standardDeviation", + "otherPropertyType", + "otherProperty", + "bitsPerValue" }) @XmlRootElement(name = "MD_SampleDimension") @XmlSeeAlso({DefaultBand.class, DefaultRangeDimension.class}) @@ -224,7 +232,8 @@ public class DefaultSampleDimension exte */ @Override @ValueRange(minimum = 0) -/// @XmlElement(name = "numberOfValues") + @XmlElement(name = "numberOfValues") + @XmlJavaTypeAdapter(GO_Integer.Since2014.class) public Integer getNumberOfValues() { return numberOfValues; } @@ -290,7 +299,8 @@ public class DefaultSampleDimension exte * @return the mean value of data values in each dimension included in the resource, or {@code null} if none. */ @Override -/// @XmlElement(name = "meanValue") + @XmlElement(name = "meanValue") + @XmlJavaTypeAdapter(GO_Real.Since2014.class) public Double getMeanValue() { return meanValue; } @@ -311,7 +321,8 @@ public class DefaultSampleDimension exte * @return standard deviation of data values in each dimension included in the resource, or {@code null} if none. */ @Override -/// @XmlElement(name = "standardDeviation") + @XmlElement(name = "standardDeviation") + @XmlJavaTypeAdapter(GO_Real.Since2014.class) public Double getStandardDeviation() { return standardDeviation; } @@ -353,7 +364,7 @@ public class DefaultSampleDimension exte * @return scale factor which has been applied to the cell value, or {@code null} if none. */ @Override -/// @XmlElement(name = "scaleFactor") + @XmlElement(name = "scaleFactor") public Double getScaleFactor() { return scaleFactor; } @@ -374,7 +385,7 @@ public class DefaultSampleDimension exte * @return the physical value corresponding to a cell value of zero, or {@code null} if none. */ @Override -/// @XmlElement(name = "offset") + @XmlElement(name = "offset") public Double getOffset() { return offset; } @@ -392,6 +403,12 @@ public class DefaultSampleDimension exte /** * Returns type of transfer function to be used when scaling a physical value for a given element. * + * <div class="note"><b>Note on XML marshalling:</b> + * ISO 19115-2 defines this property in {@linkplain DefaultBand a subtype} for historical reasons. + * Apache SIS moves this property up in the hierarchy since this property can apply to any sample dimension, + * not only the measurements in the electromagnetic spectrum. However this property will not appear in XML + * documents unless this {@code SampleDimension} is actually a {@code Band}.</div> + * * @return type of transfer function, or {@code null}. */ @Override @@ -418,7 +435,7 @@ public class DefaultSampleDimension exte */ @Override @ValueRange(minimum = 1) -/// @XmlElement(name = "bitsPerValues") + @XmlElement(name = "bitsPerValue") public Integer getBitsPerValue() { return bitsPerValue; } @@ -441,6 +458,12 @@ public class DefaultSampleDimension exte * Returns the smallest distance between which separate points can be distinguished, * as specified in instrument design. * + * <div class="note"><b>Note on XML marshalling:</b> + * ISO 19115-2 defines this property in {@linkplain DefaultBand a subtype} for historical reasons. + * Apache SIS moves this property up in the hierarchy since this property can apply to any sample dimension, + * not only the measurements in the electromagnetic spectrum. However this property will not appear in XML + * documents unless this {@code SampleDimension} is actually a {@code Band}.</div> + * * @return smallest distance between which separate points can be distinguished, or {@code null}. */ @Override @@ -469,7 +492,8 @@ public class DefaultSampleDimension exte * @return type of other attribute description, or {@code null} if none. */ @Override -/// @XmlElement(name = "otherPropertyType") + @XmlElement(name = "otherPropertyType") + @XmlJavaTypeAdapter(GO_RecordType.Since2014.class) public RecordType getOtherPropertyType() { return otherPropertyType; } @@ -491,7 +515,8 @@ public class DefaultSampleDimension exte * @return instance of other/attributeType that defines attributes, or {@code null} if none. */ @Override -/// @XmlElement(name = "otherProperty") + @XmlElement(name = "otherProperty") + @XmlJavaTypeAdapter(GO_Record.Since2014.class) public Record getOtherProperty() { return otherProperty; } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -80,20 +80,31 @@ * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ -@XmlSchema(location=Schemas.METADATA_XSD, elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmi", namespaceURI = Namespaces.GMI), - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), - @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO), - @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI) +@XmlSchema(location="http://standards.iso.org/iso/19115/-3/mrc/1.0/mrc.xsd", + elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.MRC, + xmlns = { + @XmlNs(prefix = "mrc", namespaceURI = Namespaces.MRC), // Metadata for Resource Content + @XmlNs(prefix = "lan", namespaceURI = Namespaces.LAN), // Language localization + @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC), // Metadata Common Classes + @XmlNs(prefix = "gmd", namespaceURI = LegacyNamespaces.GMD) }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapters({ @XmlJavaTypeAdapter(CI_Citation.class), + @XmlJavaTypeAdapter(GO_Boolean.class), + @XmlJavaTypeAdapter(GO_GenericName.class), + @XmlJavaTypeAdapter(GO_Integer.class), + @XmlJavaTypeAdapter(GO_Real.class), + @XmlJavaTypeAdapter(GO_Record.class), + @XmlJavaTypeAdapter(GO_RecordType.class), + @XmlJavaTypeAdapter(MD_AttributeGroup.class), @XmlJavaTypeAdapter(MD_CoverageContentTypeCode.class), + @XmlJavaTypeAdapter(MD_FeatureTypeInfo.class), @XmlJavaTypeAdapter(MD_Identifier.class), @XmlJavaTypeAdapter(MD_ImagingConditionCode.class), @XmlJavaTypeAdapter(MD_RangeDimension.class), @@ -101,16 +112,12 @@ @XmlJavaTypeAdapter(MI_PolarizationOrientationCode.class), @XmlJavaTypeAdapter(MI_RangeElementDescription.class), @XmlJavaTypeAdapter(MI_TransferFunctionTypeCode.class), + @XmlJavaTypeAdapter(PT_Locale.class), // Java types, primitive types and basic OGC types handling @XmlJavaTypeAdapter(UnitAdapter.class), - @XmlJavaTypeAdapter(LocaleAdapter.class), @XmlJavaTypeAdapter(InternationalStringAdapter.class), - @XmlJavaTypeAdapter(GO_GenericName.class), - @XmlJavaTypeAdapter(GO_RecordType.class), - @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class), - @XmlJavaTypeAdapter(GO_Integer.class), @XmlJavaTypeAdapter(type=int.class, value=GO_Integer.class), - @XmlJavaTypeAdapter(GO_Real.class), @XmlJavaTypeAdapter(type=double.class, value=GO_Real.class) + @XmlJavaTypeAdapter(value=GO_Boolean.class, type=boolean.class) }) package org.apache.sis.metadata.iso.content; @@ -122,8 +129,7 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; import org.apache.sis.xml.Namespaces; -import org.apache.sis.internal.jaxb.Schemas; +import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.internal.jaxb.gco.*; -import org.apache.sis.internal.jaxb.gmd.*; import org.apache.sis.internal.jaxb.code.*; import org.apache.sis.internal.jaxb.metadata.*; Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDataFile.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -16,15 +16,21 @@ */ package org.apache.sis.metadata.iso.distribution; +import java.net.URI; import java.util.Collection; +import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import org.opengis.util.LocalName; import org.opengis.metadata.distribution.Format; import org.opengis.metadata.distribution.DataFile; -import org.opengis.util.LocalName; import org.apache.sis.xml.Namespaces; import org.apache.sis.metadata.iso.ISOMetadata; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.gmx.MimeFileTypeAdapter; +import org.opengis.util.InternationalString; /** @@ -48,16 +54,20 @@ import org.apache.sis.metadata.iso.ISOMe * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. -@XmlType(name = "MX_DataFile_Type", propOrder = { +@XmlType(name = "MX_DataFile_Type", namespace = Namespaces.MDT, propOrder = { + "fileName", + "fileDescription", + "fileType", "featureTypes", "fileFormat" }) -@XmlRootElement(name = "MX_DataFile", namespace = Namespaces.GMX) +@XmlRootElement(name = "MX_DataFile", namespace = Namespaces.MDT) public class DefaultDataFile extends ISOMetadata implements DataFile { /** * Serial number for inter-operability with different versions. @@ -65,6 +75,27 @@ public class DefaultDataFile extends ISO private static final long serialVersionUID = -4556006719009557349L; /** + * Name or path of the file. + * + * @since 1.0 + */ + private URI fileName; + + /** + * Text description of the file. + * + * @since 1.0 + */ + private InternationalString fileDescription; + + /** + * Format in which the file is encoded. + * + * @since 1.0 + */ + private String fileType; + + /** * Provides the list of feature types concerned by the transfer data file. Depending on * the transfer choices, a data file may contain data related to one or many feature types. * This attribute may be omitted when the dataset is composed of a single file and/or the @@ -74,7 +105,10 @@ public class DefaultDataFile extends ISO /** * Defines the format of the transfer data file. + * + * @deprecated Removed in latest XSD schemas. */ + @Deprecated private Format fileFormat; /** @@ -97,6 +131,7 @@ public class DefaultDataFile extends ISO if (object != null) { featureTypes = copyCollection(object.getFeatureTypes(), LocalName.class); fileFormat = object.getFileFormat(); + // TODO: copy other properties. } } @@ -126,6 +161,82 @@ public class DefaultDataFile extends ISO } /** + * Returns the name or path of the file. + * + * @return file name, or {@code null}. + * + * @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileName() + * @since 1.0 + */ + @XmlElement(name = "fileName", required = true) + public URI getFileName() { + return fileName; + } + + /** + * Sets the name or path of the file. + * + * @param newValue the new filename or path. + * + * @since 1.0 + */ + public void setFileName(final URI newValue) { + checkWritePermission(); + fileName = newValue; + } + + /** + * Returns the text description of the file. + * + * @return text description of the file, or {@code null}. + * + * @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileDescription() + * @since 1.0 + */ + @XmlElement(name = "fileDescription", required = true) + public InternationalString getFileDescription() { + return fileDescription; + } + + /** + * Sets the text description of the file. + * + * @param newValue the new file description. + * + * @since 1.0 + */ + public void setFileDescription(final InternationalString newValue) { + checkWritePermission(); + fileDescription = newValue; + } + + /** + * Format in which the file is encoded. + * + * @return format in which the file is encoded, or {@code null}. + * + * @see org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic#getFileType() + * @since 1.0 + */ + @XmlElement(name = "fileType", required = true) + @XmlJavaTypeAdapter(MimeFileTypeAdapter.class) + public String getFileType() { + return fileType; + } + + /** + * Sets the format in which the illustration is encoded. + * Raster formats are encouraged to use one of the names returned by + * {@link javax.imageio.ImageIO#getReaderFormatNames()}. + * + * @param newValue the new file type. + */ + public void setFileType(final String newValue) { + checkWritePermission(); + fileType = newValue; + } + + /** * Returns the list of feature types concerned by the transfer data file. Depending on * the transfer choices, a data file may contain data related to one or many feature types. * This attribute may be omitted when the dataset is composed of a single file and/or the @@ -134,7 +245,7 @@ public class DefaultDataFile extends ISO * @return list of features types concerned by the transfer data file. */ @Override - @XmlElement(name = "featureType", namespace = Namespaces.GMX) + @XmlElement(name = "featureTypes") public Collection<LocalName> getFeatureTypes() { return featureTypes = nonNullCollection(featureTypes, LocalName.class); } @@ -152,18 +263,24 @@ public class DefaultDataFile extends ISO * Returns the format of the transfer data file. * * @return format of the transfer data file, or {@code null}. + * + * @deprecated Removed in latest XSD schemas. */ @Override - @XmlElement(name = "fileFormat", namespace = Namespaces.GMX, required = true) + @Deprecated + @XmlElement(name = "fileFormat", namespace = LegacyNamespaces.GMX) public Format getFileFormat() { - return fileFormat; + return FilterByVersion.LEGACY_METADATA.accept() ? fileFormat : null; } /** * Sets the format of the transfer data file. * * @param newValue the new file format value. + * + * @deprecated Removed in latest XSD schemas. */ + @Deprecated public void setFileFormat(final Format newValue) { checkWritePermission(); fileFormat = newValue; Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -20,6 +20,7 @@ import java.util.Collection; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.temporal.PeriodDuration; import org.opengis.metadata.citation.OnlineResource; @@ -30,6 +31,9 @@ import org.apache.sis.internal.metadata. import org.apache.sis.measure.ValueRange; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.internal.metadata.Dependencies; +import org.apache.sis.internal.jaxb.gts.TM_PeriodDuration; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.util.CollectionsExt; import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive; @@ -49,16 +53,19 @@ import static org.apache.sis.internal.me * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @XmlType(name = "MD_DigitalTransferOptions_Type", propOrder = { "unitsOfDistribution", + "distributionFormat", "transferSize", + "transferFrequency", "onLines", - "offLine" + "offLines" }) @XmlRootElement(name = "MD_DigitalTransferOptions") public class DefaultDigitalTransferOptions extends ISOMetadata implements DigitalTransferOptions { @@ -233,8 +240,14 @@ public class DefaultDigitalTransferOptio * @since 0.5 */ @Override + @XmlElement(name = "offLine") public Collection<Medium> getOffLines() { - return offLines = nonNullCollection(offLines, Medium.class); + Collection<Medium> c = offLines = nonNullCollection(offLines, Medium.class); + if (c != null && c.size() > 1 && FilterByVersion.LEGACY_METADATA.accept()) { + c = CollectionsExt.singletonOrEmpty(LegacyPropertyAdapter.getSingleton(c, + Medium.class, null, DefaultDigitalTransferOptions.class, "getOffLines")); + } + return c; } /** @@ -257,7 +270,6 @@ public class DefaultDigitalTransferOptio */ @Override @Deprecated - @XmlElement(name = "offLine") @Dependencies("getOffLines") public Medium getOffLine() { return LegacyPropertyAdapter.getSingleton(getOffLines(), Medium.class, null, DefaultDigitalTransferOptions.class, "getOffLine"); @@ -283,6 +295,8 @@ public class DefaultDigitalTransferOptio * @since 0.5 */ @Override + @XmlElement(name = "transferFrequency") + @XmlJavaTypeAdapter(TM_PeriodDuration.Since2014.class) public PeriodDuration getTransferFrequency() { return transferFrequency; } @@ -307,6 +321,7 @@ public class DefaultDigitalTransferOptio * @since 0.5 */ @Override + // @XmlElement at the end of this class. public Collection<Format> getDistributionFormats() { return distributionFormats = nonNullCollection(distributionFormats, Format.class); } @@ -321,4 +336,28 @@ public class DefaultDigitalTransferOptio public void setDistributionFormats(final Collection<? extends Format> newValues) { distributionFormats = writeCollection(newValues, distributionFormats, Format.class); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * 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. + */ + @XmlElement(name = "distributionFormat") + private Collection<Format> getDistributionFormat() { + return FilterByVersion.CURRENT_METADATA.accept() ? getDistributionFormats() : null; + } } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistribution.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -20,6 +20,7 @@ import java.util.Collection; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.metadata.distribution.DigitalTransferOptions; import org.opengis.metadata.distribution.Distribution; @@ -27,6 +28,7 @@ import org.opengis.metadata.distribution import org.opengis.metadata.distribution.Format; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.metadata.TitleProperty; +import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter; /** @@ -52,13 +54,15 @@ import org.apache.sis.metadata.TitleProp * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @TitleProperty(name = "description") @XmlType(name = "MD_Distribution_Type", propOrder = { + "description", // New in ISO 19115-3 "distributionFormats", "distributors", "transferOptions" @@ -149,6 +153,8 @@ public class DefaultDistribution extends * @since 0.5 */ @Override + @XmlElement(name = "description") + @XmlJavaTypeAdapter(InternationalStringAdapter.Since2014.class) public InternationalString getDescription() { return description; } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistributor.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistributor.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistributor.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDistributor.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -55,7 +55,7 @@ import org.apache.sis.metadata.iso.ISOMe * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -17,9 +17,11 @@ package org.apache.sis.metadata.iso.distribution; import java.util.Collection; +import java.util.function.BiConsumer; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.distribution.Format; @@ -27,12 +29,13 @@ import org.opengis.metadata.distribution import org.opengis.metadata.distribution.Distributor; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.metadata.MD_Medium; +import org.apache.sis.internal.jaxb.metadata.CI_Citation; import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.metadata.iso.ISOMetadata; -// Branch-dependent imports -import java.util.function.BiConsumer; - /** * Description of the computer language construct that specifies the representation @@ -77,17 +80,23 @@ import java.util.function.BiConsumer; * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.8 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @XmlType(name = "MD_Format_Type", propOrder = { + // ISO 19115:2003 (legacy) "name", "version", "amendmentNumber", "specification", + + // ISO 19115:2014 + "formatSpecificationCitation", "fileDecompressionTechnique", + "media", "formatDistributors" }) @XmlRootElement(name = "MD_Format") @@ -182,7 +191,8 @@ public class DefaultFormat extends ISOMe * @since 0.5 */ @Override -/// @XmlElement(name = "formatSpecificationCitation", required = true) + @XmlElement(name = "formatSpecificationCitation", required = true) + @XmlJavaTypeAdapter(CI_Citation.Since2014.class) public Citation getFormatSpecificationCitation() { return formatSpecificationCitation; } @@ -230,11 +240,16 @@ public class DefaultFormat extends ISOMe */ @Override @Deprecated - @XmlElement(name = "specification") @Dependencies("getFormatSpecificationCitation") + @XmlElement(name = "specification", namespace = LegacyNamespaces.GMD) public InternationalString getSpecification() { - final Citation citation = getFormatSpecificationCitation(); - return (citation != null) ? citation.getTitle() : null; + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Citation citation = getFormatSpecificationCitation(); + if (citation != null) { + return citation.getTitle(); + } + } + return null; } /** @@ -263,13 +278,15 @@ public class DefaultFormat extends ISOMe */ @Override @Deprecated - @XmlElement(name = "name", required = true) @Dependencies("getFormatSpecificationCitation") + @XmlElement(name = "name", namespace = LegacyNamespaces.GMD) public InternationalString getName() { - final Citation citation = getFormatSpecificationCitation(); - if (citation != null) { - return LegacyPropertyAdapter.getSingleton(citation.getAlternateTitles(), - InternationalString.class, null, DefaultFormat.class, "getName"); + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Citation citation = getFormatSpecificationCitation(); + if (citation != null) { + return LegacyPropertyAdapter.getSingleton(citation.getAlternateTitles(), + InternationalString.class, null, DefaultFormat.class, "getName"); + } } return null; } @@ -301,11 +318,16 @@ public class DefaultFormat extends ISOMe */ @Override @Deprecated - @XmlElement(name = "version", required = true) @Dependencies("getFormatSpecificationCitation") + @XmlElement(name = "version", namespace = LegacyNamespaces.GMD) public InternationalString getVersion() { - final Citation citation = getFormatSpecificationCitation(); - return (citation != null) ? citation.getEdition() : null; + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Citation citation = getFormatSpecificationCitation(); + if (citation != null) { + return citation.getEdition(); + } + } + return null; } /** @@ -376,7 +398,8 @@ public class DefaultFormat extends ISOMe * @since 0.5 */ @Override -/// @XmlElement(name = "medium") + @XmlElement(name = "medium") + @XmlJavaTypeAdapter(MD_Medium.Since2014.class) public Collection<Medium> getMedia() { return media = nonNullCollection(media, Medium.class); } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -23,6 +23,7 @@ import javax.measure.Unit; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.InternationalString; import org.opengis.metadata.Identifier; import org.opengis.metadata.distribution.Medium; @@ -31,7 +32,11 @@ import org.opengis.metadata.distribution import org.apache.sis.measure.ValueRange; import org.apache.sis.metadata.TitleProperty; 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.jaxb.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; @@ -58,14 +63,17 @@ import static org.apache.sis.internal.me * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @TitleProperty(name = "name") @XmlType(name = "MD_Medium_Type", propOrder = { + "identifier", // New in ISO 19115-3 "name", + "density", "densities", "densityUnits", "volumes", @@ -174,6 +182,9 @@ public class DefaultMedium extends ISOMe * Returns the name of the medium on which the resource can be received. * * @return name of the medium, or {@code null}. + * + * @see <a href="https://issues.apache.org/jira/browse/SIS-389">SIS-389</a> + * */ @Override @XmlElement(name = "name") @@ -200,6 +211,8 @@ public class DefaultMedium extends ISOMe * @since 0.5 */ @Override + @XmlElement(name = "density") + @XmlJavaTypeAdapter(GO_Real.Since2014.class) @ValueRange(minimum = 0, isMinIncluded = false) public Double getDensity() { return density; @@ -228,9 +241,10 @@ public class DefaultMedium extends ISOMe */ @Override @Deprecated - @XmlElement(name = "density") @Dependencies("getDensity") + @XmlElement(name = "density", namespace = LegacyNamespaces.GMD) public Collection<Double> getDensities() { + if (!FilterByVersion.LEGACY_METADATA.accept()) return null; return new AbstractSet<Double>() { /** Returns 0 if empty, or 1 if a density has been specified. */ @Override public int size() { @@ -360,7 +374,8 @@ public class DefaultMedium extends ISOMe * @since 0.5 */ @Override -/// @XmlElement(name = "identifier") + @XmlElement(name = "identifier") + @XmlJavaTypeAdapter(MD_Identifier.Since2014.class) public Identifier getIdentifier() { return NonMarshalledAuthority.getMarshallable(identifiers); } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultStandardOrderProcess.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -16,15 +16,18 @@ */ package org.apache.sis.metadata.iso.distribution; -import java.util.Currency; import java.util.Date; +import java.util.Currency; +import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.util.Record; import org.opengis.util.RecordType; import org.opengis.util.InternationalString; import org.opengis.metadata.distribution.StandardOrderProcess; +import org.apache.sis.internal.jaxb.gco.GO_RecordType; +import org.apache.sis.internal.jaxb.gco.GO_Record; import org.apache.sis.metadata.iso.ISOMetadata; import static org.apache.sis.internal.metadata.MetadataUtilities.toDate; @@ -47,7 +50,8 @@ import static org.apache.sis.internal.me * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @@ -56,7 +60,9 @@ import static org.apache.sis.internal.me "fees", "plannedAvailableDateTime", "orderingInstructions", - "turnaround" + "turnaround", + "orderOptionType", // New in ISO 19115-3 + "orderOptions" // New in ISO 19115-3 }) @XmlRootElement(name = "MD_StandardOrderProcess") public class DefaultStandardOrderProcess extends ISOMetadata implements StandardOrderProcess { @@ -291,7 +297,8 @@ public class DefaultStandardOrderProcess * @see org.apache.sis.util.iso.DefaultRecord#getRecordType() */ @Override -/// @XmlElement(name = "orderOptionType") + @XmlElement(name = "orderOptionsType") + @XmlJavaTypeAdapter(GO_RecordType.Since2014.class) public RecordType getOrderOptionType() { return orderOptionType; } @@ -320,7 +327,8 @@ public class DefaultStandardOrderProcess * orders, otherwise this method would need to be a factory rather than a getter. */ @Override -/// @XmlElement(name = "orderOptions") + @XmlElement(name = "orderOptions") + @XmlJavaTypeAdapter(GO_Record.Since2014.class) public Record getOrderOptions() { return orderOptions; } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -69,35 +69,40 @@ * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ -@XmlSchema(location=Schemas.METADATA_XSD, elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmx", namespaceURI = Namespaces.GMX), - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), - @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO), - @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI) +@XmlSchema(location="http://standards.iso.org/iso/19115/-3/mrd/1.0/mrd.xsd", + elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.MRD, + xmlns = { + @XmlNs(prefix = "mrd", namespaceURI = Namespaces.MRD), // Metadata for Resource Distribution + @XmlNs(prefix = "mdt", namespaceURI = Namespaces.MDT), // Metadata for Data Transfer + @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC), // Metadata Common Classes + @XmlNs(prefix = "gmd", namespaceURI = LegacyNamespaces.GMD), + @XmlNs(prefix = "gmx", namespaceURI = LegacyNamespaces.GMX) }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapters({ + @XmlJavaTypeAdapter(CI_OnlineResource.class), + @XmlJavaTypeAdapter(CI_Responsibility.class), + @XmlJavaTypeAdapter(GO_DateTime.class), + @XmlJavaTypeAdapter(GO_Integer.class), + @XmlJavaTypeAdapter(GO_LocalName.class), + @XmlJavaTypeAdapter(GO_Real.class), @XmlJavaTypeAdapter(MD_DigitalTransferOptions.class), @XmlJavaTypeAdapter(MD_Distributor.class), @XmlJavaTypeAdapter(MD_Format.class), @XmlJavaTypeAdapter(MD_Medium.class), @XmlJavaTypeAdapter(MD_MediumFormatCode.class), @XmlJavaTypeAdapter(MD_MediumNameCode.class), - @XmlJavaTypeAdapter(CI_OnlineResource.class), - @XmlJavaTypeAdapter(CI_Responsibility.class), @XmlJavaTypeAdapter(MD_StandardOrderProcess.class), // Java types, primitive types and basic OGC types handling + @XmlJavaTypeAdapter(URIAdapter.class), @XmlJavaTypeAdapter(UnitAdapter.class), - @XmlJavaTypeAdapter(InternationalStringAdapter.class), - @XmlJavaTypeAdapter(GO_LocalName.class), - @XmlJavaTypeAdapter(GO_DateTime.class), - @XmlJavaTypeAdapter(GO_Integer.class), @XmlJavaTypeAdapter(type=int.class, value=GO_Integer.class), - @XmlJavaTypeAdapter(GO_Real.class), @XmlJavaTypeAdapter(type=double.class, value=GO_Real.class) + @XmlJavaTypeAdapter(InternationalStringAdapter.class) }) package org.apache.sis.metadata.iso.distribution; @@ -109,7 +114,7 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; import org.apache.sis.xml.Namespaces; -import org.apache.sis.internal.jaxb.Schemas; +import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.internal.jaxb.gco.*; import org.apache.sis.internal.jaxb.code.*; import org.apache.sis.internal.jaxb.metadata.*; Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/AbstractGeographicExtent.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -42,13 +42,13 @@ import org.apache.sis.metadata.iso.ISOMe * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.4 + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @XmlType(name = "AbstractEX_GeographicExtent_Type") -@XmlRootElement(name = "EX_GeographicExtent") +@XmlRootElement(name = "AbstractEX_GeographicExtent") @XmlSeeAlso({ DefaultGeographicBoundingBox.class, DefaultBoundingPolygon.class, Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultBoundingPolygon.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -47,7 +47,7 @@ import org.opengis.metadata.extent.Bound * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) * @author Guilhem Legal (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultExtent.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -82,7 +82,7 @@ import org.apache.sis.xml.NilReason; * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.8 + * @version 1.0 * * @see Extents#getGeographicBoundingBox(Extent) * @see org.apache.sis.referencing.AbstractReferenceSystem#getDomainOfValidity() Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicBoundingBox.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -107,7 +107,7 @@ import static java.lang.Double.doubleToL * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.8 + * @version 1.0 * * @see org.apache.sis.geometry.GeneralEnvelope * Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultGeographicDescription.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -58,7 +58,7 @@ import org.apache.sis.util.iso.Types; * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.6 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultSpatialTemporalExtent.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -51,7 +51,7 @@ import org.apache.sis.internal.metadata. * @author Rémi Maréchal (Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultTemporalExtent.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -62,7 +62,7 @@ import org.apache.sis.xml.NilReason; * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/DefaultVerticalExtent.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -58,12 +58,14 @@ import org.apache.sis.xml.NilReason; * <li>Serialized objects of this class are not guaranteed to be compatible with future Apache SIS releases. * Serialization support is appropriate for short term storage or RMI between applications running the * same version of Apache SIS. For long term storage, use {@link org.apache.sis.xml.XML} instead.</li> + * <li>Coordinate Reference System can not be specified by identifier only; they have to be specified in full. + * See <a href="https://issues.apache.org/jira/browse/SIS-397">SIS-397</a>.</li> * </ul> * * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -212,9 +214,11 @@ public class DefaultVerticalExtent exten * The CRS identification includes unit of measure. * * @return the vertical CRS, or {@code null}. + * + * @see <a href="https://issues.apache.org/jira/browse/SIS-397">SIS-397</a> */ @Override - @XmlElement(name = "verticalCRS", required = true) + @XmlElement(name = "verticalCRS") public VerticalCRS getVerticalCRS() { return verticalCRS; } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/extent/package-info.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -135,30 +135,31 @@ * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) * @author Guilhem Legal (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ -@XmlSchema(location=Schemas.METADATA_XSD, elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), - @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO), - @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI) +@XmlSchema(location="http://standards.iso.org/iso/19115/-3/gex/1.0/gex.xsd", + elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.GEX, + xmlns = { + @XmlNs(prefix = "gex", namespaceURI = Namespaces.GEX), // Geospatial Extent + @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC) // Metadata Common Classes }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapters({ - @XmlJavaTypeAdapter(EX_GeographicBoundingBox.class), @XmlJavaTypeAdapter(EX_GeographicExtent.class), @XmlJavaTypeAdapter(EX_TemporalExtent.class), @XmlJavaTypeAdapter(EX_VerticalExtent.class), @XmlJavaTypeAdapter(GM_Object.class), + @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(MD_Identifier.class), @XmlJavaTypeAdapter(SC_VerticalCRS.class), @XmlJavaTypeAdapter(TM_Primitive.class), // Java types, primitive types and basic OGC types handling @XmlJavaTypeAdapter(InternationalStringAdapter.class), - @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class), - @XmlJavaTypeAdapter(GO_Decimal.class), @XmlJavaTypeAdapter(type=double.class, value=GO_Decimal.class) + @XmlJavaTypeAdapter(value=GO_Decimal.class, type=double.class) }) package org.apache.sis.metadata.iso.extent; @@ -171,7 +172,6 @@ import javax.xml.bind.annotation.adapter import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; import org.apache.sis.xml.Namespaces; -import org.apache.sis.internal.jaxb.Schemas; import org.apache.sis.internal.jaxb.gco.*; import org.apache.sis.internal.jaxb.gml.*; import org.apache.sis.internal.jaxb.metadata.*; Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -21,6 +21,7 @@ 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.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.citation.Responsibility; @@ -44,6 +45,9 @@ import org.opengis.temporal.Duration; import org.opengis.util.InternationalString; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; +import org.apache.sis.internal.jaxb.metadata.MD_Identifier; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.util.iso.Types; @@ -77,7 +81,8 @@ import org.apache.sis.util.iso.Types; * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @@ -89,17 +94,29 @@ import org.apache.sis.util.iso.Types; "credits", "status", "pointOfContacts", + "spatialRepresentationTypes", // Here in ISO 19115:2014 (was after 'aggregationInfo' in ISO 19115:2003) + "spatialResolutions", // Shall be kept next to 'spatialRepresentationTypes' + "temporalResolution", // ISO 19115-3 only + "topicCategories", // Here in ISO 19115:2014 (was in subclasses in ISO 19115:2003) + "extents", // Here in ISO 19115:2014 (was in subclasses in ISO 19115:2003) + "additionalDocumentation", // ISO 19115:2014 only + "processingLevel", // ISO 19115:2014 only "resourceMaintenances", "graphicOverviews", "resourceFormats", "descriptiveKeywords", "resourceSpecificUsages", "resourceConstraints", - "aggregationInfo", - "spatialRepresentationTypes", // After 'pointOfContact' according ISO 19115:2014, but here for ISO 19115:2003 compatibility. - "spatialResolutions" // Shall be kept next to 'spatialRepresentationTypes' + "associatedResource", + "aggregationInfo", // Legacy ISO 19115:2003 (replaced by 'associatedResources') + /* + * NOTE: legacy ISO 19115:2003 specification had 'spatialRepresentationTypes' and 'spatialResolutions' + * elements last. If we wanted to produce strictly compliant legacy XML documents, we would have + * to duplicate those attributes. We avoid this complexity on the assumption that readers are + * tolerant to different order (this relaxation is needed only for legacy XML). + */ }) -@XmlRootElement(name = "MD_Identification") +@XmlRootElement(name = "AbstractMD_Identification") @XmlSeeAlso({ DefaultDataIdentification.class, DefaultServiceIdentification.class @@ -484,7 +501,7 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "temporalResolution") + // @XmlElement at the end of this class. public Collection<Duration> getTemporalResolutions() { return temporalResolutions = nonNullCollection(temporalResolutions, Duration.class); } @@ -508,7 +525,7 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "topicCategory") + @XmlElement(name = "topicCategory") public Collection<TopicCategory> getTopicCategories() { return topicCategories = nonNullCollection(topicCategories, TopicCategory.class); } @@ -532,7 +549,7 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "extent") + @XmlElement(name = "extent") public Collection<Extent> getExtents() { return extents = nonNullCollection(extents, Extent.class); } @@ -556,7 +573,7 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "additionalDocumentation") + // @XmlElement at the end of this class. public Collection<Citation> getAdditionalDocumentations() { return additionalDocumentations = nonNullCollection(additionalDocumentations, Citation.class); } @@ -580,7 +597,8 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "processingLevel") + @XmlElement(name = "processingLevel") + @XmlJavaTypeAdapter(MD_Identifier.Since2014.class) public Identifier getProcessingLevel() { return processingLevel; } @@ -731,7 +749,7 @@ public class AbstractIdentification exte * @since 0.5 */ @Override -/// @XmlElement(name = "associatedResource") + // @XmlElement at the end of this class. public Collection<AssociatedResource> getAssociatedResources() { return associatedResources = nonNullCollection(associatedResources, AssociatedResource.class); } @@ -756,9 +774,10 @@ public class AbstractIdentification exte */ @Override @Deprecated - @XmlElement(name = "aggregationInfo") @Dependencies("getAssociatedResources") + @XmlElement(name = "aggregationInfo", namespace = LegacyNamespaces.GMD) public Collection<AggregateInformation> getAggregationInfo() { + if (!FilterByVersion.LEGACY_METADATA.accept()) return null; return new LegacyPropertyAdapter<AggregateInformation,AssociatedResource>(getAssociatedResources()) { @Override protected AssociatedResource wrap(final AggregateInformation value) { return value; @@ -785,4 +804,41 @@ public class AbstractIdentification exte public void setAggregationInfo(final Collection<? extends AggregateInformation> newValues) { setAssociatedResources(newValues); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * 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<Duration> getTemporalResolution() { + return FilterByVersion.CURRENT_METADATA.accept() ? getTemporalResolutions() : null; + } + + @XmlElement(name = "additionalDocumentation") + private Collection<Citation> getAdditionalDocumentation() { + return FilterByVersion.CURRENT_METADATA.accept() ? getAdditionalDocumentations() : null; + } + + @XmlElement(name = "associatedResource") + private Collection<AssociatedResource> getAssociatedResource() { + return FilterByVersion.CURRENT_METADATA.accept() ? getAssociatedResources() : null; + } } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -22,6 +22,7 @@ import java.util.Collection; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.identification.AggregateInformation; @@ -30,6 +31,9 @@ import org.opengis.metadata.identificati import org.opengis.metadata.identification.InitiativeType; import org.apache.sis.metadata.iso.citation.DefaultCitation; import org.apache.sis.internal.metadata.Dependencies; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.code.DS_AssociationTypeCode; +import org.apache.sis.internal.jaxb.code.DS_InitiativeTypeCode; /** @@ -58,7 +62,8 @@ import org.apache.sis.internal.metadata. * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module * @@ -66,13 +71,13 @@ import org.apache.sis.internal.metadata. */ @Deprecated @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. -@XmlType(name = "MD_AggregateInformation_Type", propOrder = { +@XmlType(name = "MD_AggregateInformation_Type", namespace = LegacyNamespaces.GMD, propOrder = { "aggregateDataSetName", "aggregateDataSetIdentifier", - "associationType", - "initiativeType" + "association", // Actually "associationType", in replacement of the one defined in parent class. + "initiative" // Actually "initiativeType", ibid. }) -@XmlRootElement(name = "MD_AggregateInformation") +@XmlRootElement(name = "MD_AggregateInformation", namespace = LegacyNamespaces.GMD) public class DefaultAggregateInformation extends DefaultAssociatedResource implements AggregateInformation { /** * Serial number for compatibility with different versions. @@ -132,8 +137,8 @@ public class DefaultAggregateInformation */ @Override @Deprecated - @XmlElement(name = "aggregateDataSetName") @Dependencies("getName") + @XmlElement(name = "aggregateDataSetName") public Citation getAggregateDataSetName() { return getName(); } @@ -159,8 +164,8 @@ public class DefaultAggregateInformation */ @Override @Deprecated - @XmlElement(name = "aggregateDataSetIdentifier") @Dependencies("getName") + @XmlElement(name = "aggregateDataSetIdentifier") public Identifier getAggregateDataSetIdentifier() { return getAggregateDataSetIdentifier(getAggregateDataSetName()); } @@ -168,7 +173,7 @@ public class DefaultAggregateInformation /** * Returns the first identifier of the given citation. */ - static Identifier getAggregateDataSetIdentifier(final Citation name) { + private static Identifier getAggregateDataSetIdentifier(final Citation name) { if (name != null) { final Collection<? extends Identifier> names = name.getIdentifiers(); if (names != null) { // May be null on XML marshalling. @@ -217,45 +222,52 @@ public class DefaultAggregateInformation } } + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** - * Association type of the aggregate dataset. - * - * @return association type of the aggregate dataset. + * For (un)marshalling the {@code associationType} element at the location expected by ISO 19139:2007 schemas. + * We do not rely on {@code org.apache.sis.xml.TransformingWriter} reordering mechanism because this element + * is interleaved with other element to reorder (namely {@code "topicCategory"} and {@code "extent"}), and + * expanding {@code TransformingWriter} to handle those cases would be complicated. */ - @Override - @XmlElement(name = "associationType", required = true) - public AssociationType getAssociationType() { - return super.getAssociationType(); + @XmlElement(name = "associationType") + @XmlJavaTypeAdapter(DS_AssociationTypeCode.class) + private AssociationType getAssociation() { + return getAssociationType(); } - /** - * Sets the association type of the aggregate dataset. - * - * @param newValue the new association type. - */ - @Override - public void setAssociationType(final AssociationType newValue) { - super.setAssociationType(newValue); + /** Must be declared together with {@link #getAssociation()}. */ + @SuppressWarnings("unused") + private void setAssociation(final AssociationType newValue) { + setAssociationType(newValue); } /** - * Type of initiative under which the aggregate dataset was produced. - * - * @return type of initiative under which the aggregate dataset was produced, or {@code null}. + * For (un)marshalling the {@code initiativeType} element at the location expected by ISO 19139:2007 schemas. + * See {@link #getAssociation()} for more explanation. */ - @Override @XmlElement(name = "initiativeType") - public InitiativeType getInitiativeType() { - return super.getInitiativeType(); + @XmlJavaTypeAdapter(DS_InitiativeTypeCode.class) + private InitiativeType getInitiative() { + return getInitiativeType(); } - /** - * Sets the type of initiative under which the aggregate dataset was produced. - * - * @param newValue the new initiative. - */ - @Override - public void setInitiativeType(final InitiativeType newValue) { - super.setInitiativeType(newValue); + /** Must be declared together with {@link #getInitiative()}. */ + @SuppressWarnings("unused") + private void setInitiative(final InitiativeType newValue) { + setInitiativeType(newValue); } } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAssociatedResource.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -19,10 +19,14 @@ package org.apache.sis.metadata.iso.iden import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.identification.AssociatedResource; import org.opengis.metadata.identification.AssociationType; import org.opengis.metadata.identification.InitiativeType; +import org.apache.sis.internal.jaxb.metadata.CI_Citation; +import org.apache.sis.internal.jaxb.code.DS_AssociationTypeCode; +import org.apache.sis.internal.jaxb.code.DS_InitiativeTypeCode; import org.apache.sis.metadata.iso.ISOMetadata; @@ -52,17 +56,18 @@ import org.apache.sis.metadata.iso.ISOMe * * @author Rémi Maréchal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.5 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. -@XmlType(name = "MD_AssociatedResource_Type" /*, propOrder = { +@XmlType(name = "MD_AssociatedResource_Type", propOrder = { "name", "associationType", "initiativeType", "metadataReference" -}*/) +}) @XmlRootElement(name = "MD_AssociatedResource") public class DefaultAssociatedResource extends ISOMetadata implements AssociatedResource { /** @@ -156,7 +161,8 @@ public class DefaultAssociatedResource e * @return Citation information about the associated resource, or {@code null} if none. */ @Override -/// @XmlElement(name = "name") + @XmlElement(name = "name") + @XmlJavaTypeAdapter(CI_Citation.Since2014.class) public Citation getName() { return name; } @@ -177,7 +183,8 @@ public class DefaultAssociatedResource e * @return type of relation between the resources. */ @Override -/// @XmlElement(name = "associationType", required = true) + @XmlElement(name = "associationType", required = true) + @XmlJavaTypeAdapter(DS_AssociationTypeCode.Since2014.class) public AssociationType getAssociationType() { return associationType; } @@ -198,7 +205,8 @@ public class DefaultAssociatedResource e * @return the type of initiative under which the associated resource was produced, or {@code null} if none. */ @Override -/// @XmlElement(name = "initiativeType") + @XmlElement(name = "initiativeType") + @XmlJavaTypeAdapter(DS_InitiativeTypeCode.Since2014.class) public InitiativeType getInitiativeType() { return initiativeType; } @@ -219,7 +227,8 @@ public class DefaultAssociatedResource e * @return reference to the metadata of the associated resource, or {@code null} if none. */ @Override -/// @XmlElement(name = "metadataReference") + @XmlElement(name = "metadataReference") + @XmlJavaTypeAdapter(CI_Citation.Since2014.class) public Citation getMetadataReference() { return metadataReference; } Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java?rev=1825254&r1=1825253&r2=1825254&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultBrowseGraphic.java [UTF-8] Sat Feb 24 16:13:58 2018 @@ -28,6 +28,8 @@ import org.opengis.metadata.constraint.C import org.opengis.metadata.identification.BrowseGraphic; import org.apache.sis.metadata.iso.ISOMetadata; import org.apache.sis.internal.jaxb.gmx.MimeFileTypeAdapter; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.xml.Namespaces; /** @@ -50,17 +52,20 @@ import org.apache.sis.internal.jaxb.gmx. * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) * @author Rémi Maréchal (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. -@XmlType(name = "MD_BrowseGraphic_Type", propOrder = { +@XmlType(name = "MD_BrowseGraphic_Type", namespace = Namespaces.MCC, propOrder = { "fileName", "fileDescription", - "fileType" + "fileType", + "linkage", // New in ISO 19115:2014 + "imageConstraint" // Ibid. }) -@XmlRootElement(name = "MD_BrowseGraphic") +@XmlRootElement(name = "MD_BrowseGraphic", namespace = Namespaces.MCC) public class DefaultBrowseGraphic extends ISOMetadata implements BrowseGraphic { /** * Serial number for compatibility with different versions. @@ -231,7 +236,7 @@ public class DefaultBrowseGraphic extend * @since 0.5 */ @Override -/// @XmlElement(name = "imageConstraints") + // @XmlElement at the end of this class. public Collection<Constraints> getImageConstraints() { return imageConstraints = nonNullCollection(imageConstraints, Constraints.class); } @@ -255,7 +260,7 @@ public class DefaultBrowseGraphic extend * @since 0.5 */ @Override -/// @XmlElement(name = "linkage") + // @XmlElement at the end of this class. public Collection<OnlineResource> getLinkages() { return linkages = nonNullCollection(linkages, OnlineResource.class); } @@ -270,4 +275,33 @@ public class DefaultBrowseGraphic extend public void setLinkages(final Collection<? extends OnlineResource> newValues) { linkages = writeCollection(newValues, linkages, OnlineResource.class); } + + + + + ////////////////////////////////////////////////////////////////////////////////////////////////// + //////// //////// + //////// XML support with JAXB //////// + //////// //////// + //////// The following methods are invoked by JAXB using reflection (even if //////// + //////// they are private) or are helpers for other methods invoked by JAXB. //////// + //////// Those methods can be safely removed if Geographic Markup Language //////// + //////// (GML) support is not needed. //////// + //////// //////// + ////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * 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. + */ + @XmlElement(name = "imageConstraints") + private Collection<Constraints> getImageConstraint() { + return FilterByVersion.CURRENT_METADATA.accept() ? getImageConstraints() : null; + } + + @XmlElement(name = "linkage") + private Collection<OnlineResource> getLinkage() { + return FilterByVersion.CURRENT_METADATA.accept() ? getLinkages() : null; + } }
