Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java (from r1825261, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java&r1=1825261&r2=1825355&rev=1825355&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_FeatureTypeInfo.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -20,7 +20,6 @@ import javax.xml.bind.annotation.XmlElem import org.apache.sis.internal.jaxb.gco.PropertyType; import org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo; -import org.opengis.metadata.content.FeatureTypeInfo; /** @@ -32,7 +31,7 @@ import org.opengis.metadata.content.Feat * @version 1.0 * @module */ -public final class MD_FeatureTypeInfo extends PropertyType<MD_FeatureTypeInfo, FeatureTypeInfo> { +public final class MD_FeatureTypeInfo extends PropertyType<MD_FeatureTypeInfo, DefaultFeatureTypeInfo> { /** * Empty constructor for JAXB only. */ @@ -47,14 +46,14 @@ public final class MD_FeatureTypeInfo ex * @return {@code FeatureTypeInfo.class} */ @Override - protected Class<FeatureTypeInfo> getBoundType() { - return FeatureTypeInfo.class; + protected Class<DefaultFeatureTypeInfo> getBoundType() { + return DefaultFeatureTypeInfo.class; } /** * Constructor for the {@link #wrap} method only. */ - private MD_FeatureTypeInfo(final FeatureTypeInfo metadata) { + private MD_FeatureTypeInfo(final DefaultFeatureTypeInfo metadata) { super(metadata); } @@ -66,7 +65,7 @@ public final class MD_FeatureTypeInfo ex * @return a {@code PropertyType} wrapping the given the metadata element. */ @Override - protected MD_FeatureTypeInfo wrap(final FeatureTypeInfo metadata) { + protected MD_FeatureTypeInfo wrap(final DefaultFeatureTypeInfo metadata) { return new MD_FeatureTypeInfo(metadata); } @@ -79,7 +78,7 @@ public final class MD_FeatureTypeInfo ex */ @XmlElementRef public DefaultFeatureTypeInfo getElement() { - return DefaultFeatureTypeInfo.castOrCopy(metadata); + return metadata; } /**
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Identifier.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -31,11 +31,11 @@ import org.apache.sis.internal.jaxb.gco. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.7 + * @version 1.0 * @since 0.3 * @module */ -public final class MD_Identifier extends PropertyType<MD_Identifier, Identifier> { +public class MD_Identifier extends PropertyType<MD_Identifier, Identifier> { /** * Empty constructor for JAXB only. */ @@ -50,7 +50,7 @@ public final class MD_Identifier extends * @return {@code Identifier.class} */ @Override - protected Class<Identifier> getBoundType() { + protected final Class<Identifier> getBoundType() { return Identifier.class; } @@ -85,7 +85,7 @@ public final class MD_Identifier extends @XmlElementRef(type = ImmutableIdentifier.class) }) @SuppressWarnings("deprecation") - public Identifier getElement() { + public final Identifier getElement() { if (metadata instanceof ReferenceIdentifier) { return ImmutableIdentifier.castOrCopy((ReferenceIdentifier) metadata); } @@ -97,7 +97,26 @@ public final class MD_Identifier extends * * @param metadata the unmarshalled metadata. */ - public void setElement(final Identifier metadata) { + public final void setElement(final Identifier metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends MD_Identifier { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected MD_Identifier wrap(final Identifier value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_KeywordClass.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_KeywordClass.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_KeywordClass.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_KeywordClass.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -26,11 +26,11 @@ import org.apache.sis.internal.jaxb.gco. * package documentation for more information about JAXB and interface. * * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @version 1.0 * @since 0.5 * @module */ -public final class MD_KeywordClass extends PropertyType<MD_KeywordClass, DefaultKeywordClass> { +public class MD_KeywordClass extends PropertyType<MD_KeywordClass, DefaultKeywordClass> { /** * Empty constructor for JAXB only. */ @@ -45,7 +45,7 @@ public final class MD_KeywordClass exten * @return {@code KeywordClass.class} */ @Override - protected Class<DefaultKeywordClass> getBoundType() { + protected final Class<DefaultKeywordClass> getBoundType() { return DefaultKeywordClass.class; } @@ -76,7 +76,7 @@ public final class MD_KeywordClass exten * @return the metadata to be marshalled. */ @XmlElementRef - public DefaultKeywordClass getElement() { + public final DefaultKeywordClass getElement() { return metadata; } @@ -85,7 +85,26 @@ public final class MD_KeywordClass exten * * @param metadata the unmarshalled metadata. */ - public void setElement(final DefaultKeywordClass metadata) { + public final void setElement(final DefaultKeywordClass metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends MD_KeywordClass { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected MD_KeywordClass wrap(final DefaultKeywordClass value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Medium.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Medium.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Medium.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Medium.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -28,11 +28,11 @@ import org.apache.sis.internal.jaxb.gco. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ -public final class MD_Medium extends PropertyType<MD_Medium, Medium> { +public class MD_Medium extends PropertyType<MD_Medium, Medium> { /** * Empty constructor for JAXB only. */ @@ -47,7 +47,7 @@ public final class MD_Medium extends Pro * @return {@code Medium.class} */ @Override - protected Class<Medium> getBoundType() { + protected final Class<Medium> getBoundType() { return Medium.class; } @@ -78,7 +78,7 @@ public final class MD_Medium extends Pro * @return the metadata to be marshalled. */ @XmlElementRef - public DefaultMedium getElement() { + public final DefaultMedium getElement() { return DefaultMedium.castOrCopy(metadata); } @@ -87,7 +87,26 @@ public final class MD_Medium extends Pro * * @param metadata the unmarshalled metadata. */ - public void setElement(final DefaultMedium metadata) { + public final void setElement(final DefaultMedium metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends MD_Medium { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected MD_Medium wrap(final Medium value) { + return accept2014() ? super.wrap(value) : null; + } + } } Copied: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java (from r1825261, sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java) URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java?p2=sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java&p1=sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java&r1=1825261&r2=1825355&rev=1825355&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Releasability.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -19,7 +19,6 @@ package org.apache.sis.internal.jaxb.met import javax.xml.bind.annotation.XmlElementRef; import org.apache.sis.internal.jaxb.gco.PropertyType; import org.apache.sis.metadata.iso.constraint.DefaultReleasability; -import org.opengis.metadata.constraint.Releasability; /** @@ -32,7 +31,7 @@ import org.opengis.metadata.constraint.R * @version 1.0 * @module */ -public class MD_Releasability extends PropertyType<MD_Releasability, Releasability> { +public class MD_Releasability extends PropertyType<MD_Releasability, DefaultReleasability> { /** * Empty constructor for JAXB only. */ @@ -47,14 +46,14 @@ public class MD_Releasability extends Pr * @return {@code Releasability.class} */ @Override - protected final Class<Releasability> getBoundType() { - return Releasability.class; + protected final Class<DefaultReleasability> getBoundType() { + return DefaultReleasability.class; } /** * Constructor for the {@link #wrap} method only. */ - private MD_Releasability(final Releasability metadata) { + private MD_Releasability(final DefaultReleasability metadata) { super(metadata); } @@ -66,7 +65,7 @@ public class MD_Releasability extends Pr * @return a {@code PropertyType} wrapping the given the metadata element. */ @Override - protected MD_Releasability wrap(final Releasability metadata) { + protected MD_Releasability wrap(final DefaultReleasability metadata) { return new MD_Releasability(metadata); } @@ -79,7 +78,7 @@ public class MD_Releasability extends Pr */ @XmlElementRef public final DefaultReleasability getElement() { - return DefaultReleasability.castOrCopy(metadata); + return metadata; } /** @@ -105,7 +104,7 @@ public class MD_Releasability extends Pr * * @return a non-null value only if marshalling ISO 19115-3 or newer. */ - @Override protected MD_Releasability wrap(final Releasability value) { + @Override protected MD_Releasability wrap(final DefaultReleasability value) { return accept2014() ? super.wrap(value) : null; } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Resolution.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Resolution.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Resolution.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Resolution.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -28,11 +28,11 @@ import org.apache.sis.internal.jaxb.gco. * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ -public final class MD_Resolution extends PropertyType<MD_Resolution, Resolution> { +public class MD_Resolution extends PropertyType<MD_Resolution, Resolution> { /** * Empty constructor for JAXB only. */ @@ -47,7 +47,7 @@ public final class MD_Resolution extends * @return {@code Resolution.class} */ @Override - protected Class<Resolution> getBoundType() { + protected final Class<Resolution> getBoundType() { return Resolution.class; } @@ -78,7 +78,7 @@ public final class MD_Resolution extends * @return the metadata to be marshalled. */ @XmlElementRef - public DefaultResolution getElement() { + public final DefaultResolution getElement() { return DefaultResolution.castOrCopy(metadata); } @@ -87,7 +87,26 @@ public final class MD_Resolution extends * * @param metadata the unmarshalled metadata. */ - public void setElement(final DefaultResolution metadata) { + public final void setElement(final DefaultResolution metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends MD_Resolution { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected MD_Resolution wrap(final Resolution value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Scope.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Scope.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Scope.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/MD_Scope.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -28,11 +28,11 @@ import org.apache.sis.internal.jaxb.gco. * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.3 + * @version 1.0 * @since 0.3 * @module */ -public final class MD_Scope extends PropertyType<MD_Scope, Scope> { +public class MD_Scope extends PropertyType<MD_Scope, Scope> { /** * Empty constructor for JAXB only. */ @@ -47,7 +47,7 @@ public final class MD_Scope extends Prop * @return {@code Scope.class} */ @Override - protected Class<Scope> getBoundType() { + protected final Class<Scope> getBoundType() { return Scope.class; } @@ -60,7 +60,7 @@ public final class MD_Scope extends Prop /** * Invoked by {@link PropertyType} at marshalling time for wrapping the given metadata value - * in a {@code <gmd:MD_Scope>} XML element. + * in a {@code <mcc:MD_Scope>} XML element. * * @param metadata the metadata element to marshall. * @return a {@code PropertyType} wrapping the given the metadata element. @@ -72,13 +72,13 @@ public final class MD_Scope extends Prop /** * Invoked by JAXB at marshalling time for getting the actual metadata to write - * inside the {@code <gmd:MD_Scope>} XML element. + * inside the {@code <mcc:MD_Scope>} XML element. * This is the value or a copy of the value given in argument to the {@code wrap} method. * * @return the metadata to be marshalled. */ @XmlElementRef - public DefaultScope getElement() { + public final DefaultScope getElement() { return DefaultScope.castOrCopy(metadata); } @@ -87,7 +87,26 @@ public final class MD_Scope extends Prop * * @param metadata the unmarshalled metadata. */ - public void setElement(final DefaultScope metadata) { + public final void setElement(final DefaultScope metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends MD_Scope { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected MD_Scope wrap(final Scope value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_Identifier.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -26,7 +26,7 @@ import org.apache.sis.internal.jaxb.gco. * JAXB adapter mapping the GeoAPI {@link ReferenceIdentifier} to an implementation class that can * be marshalled. See the package documentation for more information about JAXB and interfaces. * - * <p>The XML produced by this adapter shall be compliant to the ISO 19139 syntax.</p> + * <p>The XML produced by this adapter shall be compliant to the ISO 19115-3 syntax.</p> * * Note that a class of the same name is defined in the {@link org.apache.sis.internal.jaxb.referencing} * package, which serves the same purpose (wrapping exactly the same interface) but using the GML syntax Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_ReferenceSystem.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_ReferenceSystem.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_ReferenceSystem.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/RS_ReferenceSystem.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -27,11 +27,11 @@ import org.apache.sis.internal.jaxb.meta * package documentation for more information about JAXB and interface. * * @author Guilhem Legal (Geomatys) - * @version 0.4 + * @version 1.0 * @since 0.3 * @module */ -public final class RS_ReferenceSystem extends PropertyType<RS_ReferenceSystem, ReferenceSystem> { +public class RS_ReferenceSystem extends PropertyType<RS_ReferenceSystem, ReferenceSystem> { /** * Empty constructor for JAXB only. */ @@ -46,7 +46,7 @@ public final class RS_ReferenceSystem ex * @return {@code ReferenceSystem.class} */ @Override - protected Class<ReferenceSystem> getBoundType() { + protected final Class<ReferenceSystem> getBoundType() { return ReferenceSystem.class; } @@ -79,7 +79,7 @@ public final class RS_ReferenceSystem ex * @return the metadata to be marshalled. */ @XmlElementRef - public ReferenceSystemMetadata getElement() { + public final ReferenceSystemMetadata getElement() { final ReferenceSystem metadata = this.metadata; if (metadata == null) { return null; @@ -95,7 +95,26 @@ public final class RS_ReferenceSystem ex * * @param metadata the unmarshalled metadata. */ - public void setElement(final ReferenceSystemMetadata metadata) { + public final void setElement(final ReferenceSystemMetadata metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends RS_ReferenceSystem { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected RS_ReferenceSystem wrap(final ReferenceSystem value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/SV_OperationMetadata.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/SV_OperationMetadata.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/SV_OperationMetadata.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/SV_OperationMetadata.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -26,11 +26,11 @@ import org.apache.sis.internal.jaxb.gco. * package documentation for more information about JAXB and interface. * * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @version 1.0 * @since 0.5 * @module */ -public final class SV_OperationMetadata extends PropertyType<SV_OperationMetadata, DefaultOperationMetadata> { +public class SV_OperationMetadata extends PropertyType<SV_OperationMetadata, DefaultOperationMetadata> { /** * Empty constructor for JAXB only. */ @@ -43,7 +43,7 @@ public final class SV_OperationMetadata * @return {@code OperationMetadata.class} */ @Override - protected Class<DefaultOperationMetadata> getBoundType() { + protected final Class<DefaultOperationMetadata> getBoundType() { return DefaultOperationMetadata.class; } @@ -74,7 +74,7 @@ public final class SV_OperationMetadata * @return the metadata to be marshalled. */ @XmlElementRef - public DefaultOperationMetadata getElement() { + public final DefaultOperationMetadata getElement() { return metadata; } @@ -83,7 +83,26 @@ public final class SV_OperationMetadata * * @param metadata the unmarshalled metadata. */ - public void setElement(final DefaultOperationMetadata metadata) { + public final void setElement(final DefaultOperationMetadata metadata) { this.metadata = metadata; } + + /** + * Wraps the value only if marshalling an element from the ISO 19115:2003 metadata model. + * Otherwise (i.e. if marshalling according legacy ISO 19115:2014 model), omits the element. + */ + public static final class Since2014 extends SV_OperationMetadata { + /** Empty constructor used only by JAXB. */ + public Since2014() { + } + + /** + * Wraps the given value in an ISO 19115-3 element, unless we are marshalling an older document. + * + * @return a non-null value only if marshalling ISO 19115-3 or newer. + */ + @Override protected SV_OperationMetadata wrap(final DefaultOperationMetadata value) { + return accept2014() ? super.wrap(value) : null; + } + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -49,7 +49,8 @@ * * @author Cédric Briançon (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @since 1.0 * * @see javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter * Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ReferenceSystemMetadata.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -17,18 +17,26 @@ package org.apache.sis.internal.jaxb.metadata.replace; import java.util.Objects; +import javax.xml.bind.Marshaller; +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.referencing.ReferenceSystem; import org.opengis.referencing.ReferenceIdentifier; +import org.apache.sis.internal.jaxb.metadata.MD_Identifier; +import org.apache.sis.internal.jaxb.metadata.RS_Identifier; import org.apache.sis.internal.simple.SimpleIdentifiedObject; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; import org.apache.sis.util.ComparisonMode; +import org.apache.sis.xml.Namespaces; /** * An implementation of {@link ReferenceSystem} marshalled as specified in ISO 19115. * This is different than the {@code ReferenceSystem} implementation provided in the - * referencing module, since the later marshall the CRS as specified in GML (close + * referencing module, since the later marshals the CRS as specified in GML (close * to ISO 19111 model). * * <p>Note that this implementation is very simple and serves no other purpose than being @@ -37,14 +45,16 @@ import org.apache.sis.util.ComparisonMod * * @author Guilhem Legal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see org.apache.sis.referencing.AbstractReferenceSystem * * @since 0.3 * @module */ -@XmlRootElement(name = "MD_ReferenceSystem") +@XmlType(name = "MD_ReferenceSystem_Type", namespace = Namespaces.MRS) +@XmlRootElement(name = "MD_ReferenceSystem", namespace = Namespaces.MRS) public class ReferenceSystemMetadata extends SimpleIdentifiedObject implements ReferenceSystem { /** * For cross-version compatibility. @@ -52,6 +62,11 @@ public class ReferenceSystemMetadata ext private static final long serialVersionUID = 2810145397032096087L; /** + * {@code true} if marshalling ISO 19115:2003 model, or {@code false} if marshalling ISO 19115:2014 model. + */ + private boolean isLegacyMetadata; + + /** * Creates a reference system without identifier. * This constructor is mainly for JAXB. */ @@ -77,14 +92,23 @@ public class ReferenceSystemMetadata ext } /** + * Invoked by JAXB {@link javax.xml.bind.Marshaller} before this object is marshalled to XML. + */ + private void beforeMarshal(final Marshaller marshaller) { + isLegacyMetadata = !FilterByVersion.CURRENT_METADATA.accept(); + } + + /** * Returns the primary name by which this object is identified. + * This method can be invoked during ISO 19115-3 marshalling. * * @return the identifier given at construction time. */ @Override @XmlElement(name = "referenceSystemIdentifier") - public final ReferenceIdentifier getName() { - return super.getName(); + @XmlJavaTypeAdapter(MD_Identifier.class) + public ReferenceIdentifier getName() { + return isLegacyMetadata ? null : super.getName(); } /** @@ -96,6 +120,24 @@ public class ReferenceSystemMetadata ext this.name = name; } + /** + * Gets the name for this reference system metadata (used in ISO 19115:2003 model). + * This method can be invoked during marshalling of legacy XML documents. + */ + @XmlElement(name = "referenceSystemIdentifier", namespace = LegacyNamespaces.GMD) + @XmlJavaTypeAdapter(RS_Identifier.class) + private ReferenceIdentifier getLegacyName() { + return isLegacyMetadata ? super.getName() : null; + } + + /** + * Sets the name for this reference system metadata (used in ISO 19115:2003 model). + */ + @SuppressWarnings("unused") + private void setLegacyName(final ReferenceIdentifier name) { + this.name = name; + } + /** * Compares this object with the given one for equality. * Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/ServiceParameter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -32,15 +32,18 @@ import org.opengis.parameter.ParameterVa import org.opengis.parameter.ParameterDescriptor; import org.opengis.referencing.ReferenceIdentifier; import org.apache.sis.internal.simple.SimpleIdentifiedObject; -import org.apache.sis.internal.jaxb.metadata.direct.GO_MemberName; +import org.apache.sis.internal.jaxb.FilterByVersion; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.gco.GO_GenericName; import org.apache.sis.internal.metadata.ReferencingServices; import org.apache.sis.internal.metadata.NameToIdentifier; -import org.apache.sis.util.ComparisonMode; +import org.apache.sis.util.iso.DefaultMemberName; import org.apache.sis.util.iso.Names; import org.apache.sis.xml.Namespaces; +import org.apache.sis.util.ComparisonMode; +import org.apache.sis.util.resources.Errors; import static org.apache.sis.internal.util.CollectionsExt.nonNull; -import static org.apache.sis.internal.jaxb.gco.PropertyType.LEGACY_XML; /** @@ -62,15 +65,17 @@ import static org.apache.sis.internal.ja * * @author Rémi Maréchal (Geomatys) * @author Martin Desruisseaux (Geomatys) - * @version 0.5 + * @version 1.0 * @since 0.5 * @module */ @SuppressWarnings("rawtypes") // For the omission of <T> in ParameterDescriptor<T> - see javadoc. @XmlType(name = "SV_Parameter_Type", namespace = Namespaces.SRV, propOrder = { - "memberName", + "memberName", // The ISO 19115-3:2016 way to marshal name. + "legacyName", // Legacy ISO 19139:2007 way to marshal name. "description", "optionality", + "optionalityLabel", // Legacy ISO 19139:2007 way to marshal optionality. "repeatability", "valueType" }) @@ -82,12 +87,26 @@ public final class ServiceParameter exte private static final long serialVersionUID = -5335736212313243889L; /** - * The name, as used by the service for this parameter. + * The name, as used by the service for this parameter. Note that in ISO 19115-3:2016, this element is + * inside a {@code <gco:MemberName>} element (i.e. ISO inserts the same kind of {@code Property_Type} + * element as it does for all other attributes) while in ISO 19139:2007 it was not (i.e. name attributes + * like {@code <gco:aName>} were marshalled directly, without wrapper). Example: * + * {@preformat xml + * <srv:name> + * <gco:MemberName> + * <gco:aName> + * <gco:CharacterString>A parameter name</gco:CharacterString> + * </gco:aName> + * </gco:MemberName> + * </srv:name> + * } + * + * @see #getLegacyName() * @see #getValueType() */ @XmlElement(required=true, name="name") - @XmlJavaTypeAdapter(GO_MemberName.class) + @XmlJavaTypeAdapter(GO_GenericName.Since2014.class) MemberName memberName; /** @@ -100,12 +119,12 @@ public final class ServiceParameter exte * Indication if the parameter is required. * * <ul> - * <li>In ISO 19115, this is represented by "{@code true}" or "{@code false}".</li> - * <li>In ISO 19119, this is marshalled as "{@code Optional}" or "{@code Mandatory}".</li> + * <li>In ISO 19115-3:2016, this is represented by "{@code true}" or "{@code false}".</li> + * <li>In ISO 19139:2007, this was marshalled as "{@code Optional}" or "{@code Mandatory}".</li> * </ul> * * @see #getOptionality() - * @see #setOptionality(String) + * @see #setOptionality(Boolean) */ public boolean optionality; @@ -187,6 +206,48 @@ public final class ServiceParameter exte } /** + * Returns the name to be marshalled in the ISO 19139:2007 way. Example: + * + * {@preformat xml + * <srv:name> + * <gco:aName> + * <gco:CharacterString>A parameter name</gco:CharacterString> + * </gco:aName> + * </srv:name> + * } + * + * @return the name if marshalling legacy ISO 19139:2007 format, or {@code null} otherwise. + */ + @XmlElement(name = "name", namespace = LegacyNamespaces.SRV) + private DefaultMemberName getLegacyName() { + return FilterByVersion.LEGACY_METADATA.accept() ? DefaultMemberName.castOrCopy(memberName) : null; + } + + /** + * Sets the value from the {@code <gco:aName>} (legacy ISO 19139:2007 format). + * This method is called at unmarshalling-time by JAXB. + * + * @param value the new name. + * @throws IllegalStateException if a name is already defined. + */ + @SuppressWarnings("unused") + private void setLegacyName(final DefaultMemberName value) { + ensureUndefined(); + memberName = value; + } + + /** + * Ensures that the {@linkplain #memberName} is not already defined. + * + * @throws IllegalStateException if a name is already defined. + */ + private void ensureUndefined() throws IllegalStateException { + if (memberName != null) { + throw new IllegalStateException(Errors.format(Errors.Keys.ValueAlreadyDefined_1, "name")); + } + } + + /** * Returns the name as an {@code Identifier}, which is the type requested by ISO 19111. * Note that this is different than the type requested by ISO 19115, which is {@link MemberName}. * @@ -220,13 +281,17 @@ public final class ServiceParameter exte } /** - * For JAXB marhalling of ISO 19119 document only. + * For JAXB marshalling of ISO 19139:2007 document only. * Note that there is not setter method, since we expect the same information * to be provided in the {@link #name} attribute type. */ - @XmlElement(name = "valueType") + @XmlElement(name = "valueType", namespace = LegacyNamespaces.SRV) + @XmlJavaTypeAdapter(GO_GenericName.class) // Not in package-info because shall not be applied to getLegacyName(). final TypeName getValueType() { - return (LEGACY_XML && memberName != null) ? memberName.getAttributeType() : null; + if (memberName != null && FilterByVersion.LEGACY_METADATA.accept()) { + return memberName.getAttributeType(); + } + return null; } /** @@ -239,18 +304,33 @@ public final class ServiceParameter exte } /** - * Returns {@code true} if {@link #optionality} is "{@code true}" or "{@code Optional}", - * or {@code false} otherwise. + * Returns the optionality as a boolean (ISO 19115-3:2016 way). */ @XmlElement(name = "optionality", required = true) - final String getOptionality() { - return LEGACY_XML ? (optionality ? "Optional" : "Mandatory") : Boolean.toString(optionality); + final Boolean getOptionality() { + return FilterByVersion.CURRENT_METADATA.accept() ? optionality : null; + } + + /** + * Sets whether this parameter is optional. + */ + final void setOptionality(final Boolean optional) { + if (optional != null) optionality = optional; + } + + /** + * Returns {@code "Optional"} if {@link #optionality} is {@code true} or {@code "Mandatory"} otherwise. + * This is the legacy ISO 19139:2007 way to marshal optionality. + */ + @XmlElement(name = "optionality", namespace = LegacyNamespaces.SRV) + final String getOptionalityLabel() { + return FilterByVersion.LEGACY_METADATA.accept() ? (optionality ? "Optional" : "Mandatory") : null; } /** * Sets whether this parameter is optional. */ - final void setOptionality(final String optional) { + final void setOptionalityLabel(final String optional) { if (optional != null) { optionality = Boolean.parseBoolean(optional) || optional.equalsIgnoreCase("Optional"); } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/jaxb/metadata/replace/package-info.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -29,25 +29,26 @@ * * @author Martin Desruisseaux (Geomatys) * @author Rémi Maréchal (Geomatys) - * @version 0.5 + * @author Cullen Rombach (Image Matters) + * @since 1.0 * @since 0.5 * @module */ -@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, namespace = Namespaces.GMD, xmlns = { - @XmlNs(prefix = "gmd", namespaceURI = Namespaces.GMD), - @XmlNs(prefix = "srv", namespaceURI = Namespaces.SRV), - @XmlNs(prefix = "gco", namespaceURI = Namespaces.GCO), - @XmlNs(prefix = "xsi", namespaceURI = Namespaces.XSI) +@XmlSchema(elementFormDefault = XmlNsForm.QUALIFIED, xmlns = { + @XmlNs(prefix = "mcc", namespaceURI = Namespaces.MCC), // Metadata Common Classes + @XmlNs(prefix = "mrs", namespaceURI = Namespaces.MRS), // Metadata for Reference System + @XmlNs(prefix = "srv", namespaceURI = Namespaces.SRV), // Metadata for Services 2.0 + @XmlNs(prefix = "srv1", namespaceURI = LegacyNamespaces.SRV), // Metadata for Services 1.0 + @XmlNs(prefix = "gmd", namespaceURI = LegacyNamespaces.GMD) // Metadata ISO 19139:2007 }) @XmlAccessorType(XmlAccessType.NONE) @XmlJavaTypeAdapters({ - @XmlJavaTypeAdapter(RS_Identifier.class), + @XmlJavaTypeAdapter(GO_Boolean.class), // Java types, primitive types and basic OGC types handling @XmlJavaTypeAdapter(StringAdapter.class), @XmlJavaTypeAdapter(InternationalStringAdapter.class), - @XmlJavaTypeAdapter(GO_GenericName.class), - @XmlJavaTypeAdapter(GO_Boolean.class), @XmlJavaTypeAdapter(type=boolean.class, value=GO_Boolean.class) + @XmlJavaTypeAdapter(value=GO_Boolean.class, type=boolean.class) }) package org.apache.sis.internal.jaxb.metadata.replace; @@ -58,9 +59,6 @@ import javax.xml.bind.annotation.XmlAcce import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapters; -import org.apache.sis.internal.jaxb.gco.GO_Boolean; -import org.apache.sis.internal.jaxb.gco.GO_GenericName; -import org.apache.sis.internal.jaxb.gco.StringAdapter; -import org.apache.sis.internal.jaxb.gco.InternationalStringAdapter; -import org.apache.sis.internal.jaxb.metadata.RS_Identifier; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.gco.*; import org.apache.sis.xml.Namespaces; Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -24,9 +24,9 @@ import java.lang.annotation.RetentionPol /** * Indicates that the value of a property is computed from values of other properties. - * This annotation can be applied on getter methods. All dependent properties must be - * in the same class than the annotated method. Transitive dependencies do not need to - * be declared, but the dependency graph shall not contain cycle. + * This annotation can be applied on public getter methods. All dependent properties + * must be in the same class than the annotated method. Transitive dependencies do not + * need to be declared, but the dependency graph shall not contain cycle. * * <div class="note"><b>Example:</b> * {@code ResponsibleParty.individualName} is now deprecated and replaced by the first {@code Individual.name} value Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/LegacyPropertyAdapter.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -79,7 +79,7 @@ public abstract class LegacyPropertyAdap protected abstract L unwrap(final N container); /** - * Update a new value with the given legacy value. + * Updates a new value with the given legacy value. * * @param container the new value to be used as a container for the old value. * @param value the value to update in the container. Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/MetadataUtilities.java [UTF-8] Mon Feb 26 11:28:17 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/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -91,7 +91,7 @@ public final class OtherLocales extends @Override public Iterator<Locale> iterator() { final Iterator<Locale> it = languages.iterator(); - if (it.hasNext()) it.next(); // Skip the first element. + if (it.hasNext()) it.next(); // Skip the first element. return it; } @@ -114,7 +114,7 @@ public final class OtherLocales extends if (languages.isEmpty()) { Locale defaultLocale = Locale.getDefault(); if (defaultLocale.equals(locale)) { - defaultLocale = Locale.ROOT; // Same default than merge(Locale, Collection). + defaultLocale = Locale.ROOT; // Same default than merge(Locale, Collection). } languages.add(defaultLocale); } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyAccessor.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -68,8 +68,8 @@ import static org.apache.sis.util.collec * except {@link #equals(Object, Object, ComparisonMode)} and {@link #freeze(Object)}.</li> * * <li>Extra properties defined by the {@link IdentifiedObject} interface. Those properties - * invisible in the ISO 19115 model, but appears in ISO 19139 XML marshalling. So we do - * the same in the SIS implementation: invisible in map and tree view, but visible in + * invisible in the ISO 19115-1 model, but appears in ISO 19115-3 XML marshalling. So we + * do the same in the SIS implementation: invisible in map and tree view, but visible in * XML marshalling.</li> * </ul> * @@ -100,8 +100,8 @@ class PropertyAccessor { /** * Additional getter to declare in every list of getter methods that do not already provide * their own {@code getIdentifiers()} method. We handle this method specially because it is - * needed for XML marshalling in ISO 19139 compliant document, while not part of abstract - * ISO 19115 specification. + * needed for XML marshalling in ISO 19115-3 compliant document, while not part of abstract + * ISO 19115-1 specification. * * @see IdentifiedObject#getIdentifiers() */ Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/PropertyComparator.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -24,6 +24,7 @@ import javax.xml.bind.annotation.XmlType import org.opengis.annotation.UML; import org.opengis.annotation.Obligation; +import org.opengis.metadata.citation.ResponsibleParty; /** @@ -43,7 +44,7 @@ import org.opengis.annotation.Obligation * </ol> * * @author Martin Desruisseaux (Geomatys) - * @version 0.8 + * @version 1.0 * @since 0.3 * @module */ @@ -128,10 +129,13 @@ final class PropertyComparator implement * the parent class, and we want the properties in the parent class to be sorted first. * If duplicated properties are found, keep the first occurence (i.e. sort the property * with the most specialized child that declared it). + * + * We make an exception for ResponsibleParty.role, which should be replaced by Party.role + * but this replacement is not yet effective in GeoAPI 3.0. */ - final Integer old = order.put(propOrder[i], order.size()); - if (old != null) { - order.put(propOrder[i], old); + final String prop = propOrder[i]; + if (!"role".equals(prop) || !ResponsibleParty.class.isAssignableFrom(implementation)) { + order.putIfAbsent(prop, order.size()); } } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/StandardImplementation.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -157,14 +157,6 @@ final class StandardImplementation exten length = p.length(); continue; } - if (candidate.isAnnotationPresent(Deprecated.class)) { - // Skip deprecated implementations. - candidate = candidate.getSuperclass(); - if (!type.isAssignableFrom(candidate) || candidate.isAnnotationPresent(Deprecated.class)) { - length = p.length(); - continue; - } - } implementations.put(type, candidate); return candidate.asSubclass(type); } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultApplicationSchemaInformation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultApplicationSchemaInformation.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultApplicationSchemaInformation.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultApplicationSchemaInformation.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -20,9 +20,11 @@ import java.net.URI; 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.ApplicationSchemaInformation; import org.opengis.metadata.citation.Citation; import org.opengis.metadata.citation.OnlineResource; +import org.apache.sis.xml.Namespaces; /** @@ -48,12 +50,13 @@ import org.opengis.metadata.citation.Onl * @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_ApplicationSchemaInformation_Type", propOrder = { +@XmlType(name = "MD_ApplicationSchemaInformation_Type", namespace = Namespaces.MAS, propOrder = { "name", "schemaLanguage", "constraintLanguage", @@ -62,7 +65,7 @@ import org.opengis.metadata.citation.Onl "softwareDevelopmentFile", "softwareDevelopmentFileFormat" }) -@XmlRootElement(name = "MD_ApplicationSchemaInformation") +@XmlRootElement(name = "MD_ApplicationSchemaInformation", namespace = Namespaces.MAS) public class DefaultApplicationSchemaInformation extends ISOMetadata implements ApplicationSchemaInformation { /** * Serial number for inter-operability with different versions. @@ -247,6 +250,7 @@ public class DefaultApplicationSchemaInf */ @Override @XmlElement(name = "schemaAscii") + @XmlJavaTypeAdapter(URIStringAdapter.class) public URI getSchemaAscii() { return schemaAscii; } @@ -277,6 +281,7 @@ public class DefaultApplicationSchemaInf */ @Override @XmlElement(name = "graphicsFile") + @XmlJavaTypeAdapter(OnlineResourceAdapter.class) public URI getGraphicsFile() { return graphicsFile; } @@ -308,6 +313,7 @@ public class DefaultApplicationSchemaInf */ @Override @XmlElement(name = "softwareDevelopmentFile") + @XmlJavaTypeAdapter(OnlineResourceAdapter.class) public URI getSoftwareDevelopmentFile() { return softwareDevelopmentFile; } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -20,7 +20,6 @@ import java.util.Collection; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.opengis.annotation.UML; import org.opengis.metadata.Datatype; import org.opengis.metadata.Obligation; import org.opengis.metadata.citation.ResponsibleParty; @@ -29,12 +28,16 @@ import org.opengis.util.InternationalStr import org.apache.sis.metadata.TitleProperty; import org.apache.sis.measure.ValueRange; import org.apache.sis.util.iso.Types; +import org.apache.sis.xml.Namespaces; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive; // Branch-specific imports +import org.opengis.annotation.UML; import static org.opengis.annotation.Obligation.OPTIONAL; import static org.opengis.annotation.Specification.ISO_19115; @@ -72,13 +75,14 @@ import static org.opengis.annotation.Spe * @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_ExtendedElementInformation_Type", propOrder = { +@XmlType(name = "MD_ExtendedElementInformation_Type", namespace = Namespaces.MEX, propOrder = { "name", "shortName", "domainCode", @@ -90,10 +94,10 @@ import static org.opengis.annotation.Spe "domainValue", "parentEntity", "rule", - "rationales", + "rationale", "sources" }) -@XmlRootElement(name = "MD_ExtendedElementInformation") +@XmlRootElement(name = "MD_ExtendedElementInformation", namespace = Namespaces.MEX) public class DefaultExtendedElementInformation extends ISOMetadata implements ExtendedElementInformation { /** * Serial number for inter-operability with different versions. @@ -305,9 +309,9 @@ public class DefaultExtendedElementInfor */ @Override @Deprecated - @XmlElement(name = "shortName") + @XmlElement(name = "shortName", namespace = LegacyNamespaces.GMD) public String getShortName() { - return shortName; + return FilterByVersion.LEGACY_METADATA.accept() ? shortName : null; } /** @@ -334,9 +338,9 @@ public class DefaultExtendedElementInfor */ @Override @Deprecated - @XmlElement(name = "domainCode") + @XmlElement(name = "domainCode", namespace = LegacyNamespaces.GMD) public Integer getDomainCode() { - return domainCode; + return FilterByVersion.LEGACY_METADATA.accept() ? domainCode : null; } /** @@ -541,6 +545,7 @@ public class DefaultExtendedElementInfor * * @since 0.5 */ + @XmlElement(name = "rationale") @UML(identifier="rationale", obligation=OPTIONAL, specification=ISO_19115) public InternationalString getRationale() { return LegacyPropertyAdapter.getSingleton(rationales, InternationalString.class, null, @@ -565,7 +570,6 @@ public class DefaultExtendedElementInfor */ @Override @Deprecated - @XmlElement(name = "rationale") @Dependencies("getRationale") public Collection<InternationalString> getRationales() { return rationales = nonNullCollection(rationales, InternationalString.class); Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultIdentifier.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -19,14 +19,16 @@ package org.apache.sis.metadata.iso; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; -import org.opengis.annotation.UML; import org.opengis.metadata.Identifier; import org.opengis.metadata.citation.Citation; import org.opengis.referencing.ReferenceIdentifier; import org.opengis.util.InternationalString; import org.apache.sis.metadata.TitleProperty; import org.apache.sis.metadata.iso.citation.Citations; +import org.apache.sis.xml.Namespaces; +// Branch-specific imports +import org.opengis.annotation.UML; import static org.opengis.annotation.Obligation.OPTIONAL; import static org.opengis.annotation.Specification.ISO_19115; @@ -87,7 +89,8 @@ import static org.opengis.annotation.Spe * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.7 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * * @see ImmutableIdentifier * @see org.apache.sis.referencing.IdentifiedObjects#toURN(Class, Identifier) @@ -97,11 +100,14 @@ import static org.opengis.annotation.Spe */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. @TitleProperty(name = "code") -@XmlType(name = "MD_Identifier_Type", propOrder = { +@XmlType(name = "MD_Identifier_Type", namespace = Namespaces.MCC, propOrder = { "authority", - "code" + "code", + "codeSpace", + "version", + "description" }) -@XmlRootElement(name = "MD_Identifier") +@XmlRootElement(name = "MD_Identifier", namespace = Namespaces.MCC) public class DefaultIdentifier extends ISOMetadata implements Identifier { /** * Serial number for inter-operability with different versions. @@ -301,6 +307,7 @@ public class DefaultIdentifier extends I * * @since 0.5 */ + @XmlElement(name = "codeSpace") @UML(identifier="codeSpace", obligation=OPTIONAL, specification=ISO_19115) public String getCodeSpace() { return codeSpace; @@ -327,6 +334,7 @@ public class DefaultIdentifier extends I * * @return the version identifier for the namespace, or {@code null} if none. */ + @XmlElement(name = "version") @UML(identifier="version", obligation=OPTIONAL, specification=ISO_19115) public String getVersion() { return version; @@ -351,6 +359,7 @@ public class DefaultIdentifier extends I * * @since 0.5 */ + @XmlElement(name = "description") @UML(identifier="description", obligation=OPTIONAL, specification=ISO_19115) public InternationalString getDescription() { return description; Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -31,7 +31,6 @@ import javax.xml.bind.annotation.XmlSeeA import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import org.opengis.annotation.UML; import org.opengis.metadata.Identifier; import org.opengis.metadata.Metadata; import org.opengis.metadata.ApplicationSchemaInformation; @@ -66,10 +65,15 @@ import org.apache.sis.internal.metadata. import org.apache.sis.internal.metadata.OtherLocales; import org.apache.sis.internal.metadata.Dependencies; import org.apache.sis.internal.util.CollectionsExt; -import org.apache.sis.internal.jaxb.code.PT_Locale; +import org.apache.sis.internal.jaxb.gmd.LocaleAdapter; +import org.apache.sis.internal.jaxb.LegacyNamespaces; +import org.apache.sis.internal.jaxb.FilterByVersion; import org.apache.sis.internal.jaxb.Context; -import org.apache.sis.xml.Namespaces; +import org.apache.sis.internal.jaxb.metadata.CI_Citation; +import org.apache.sis.internal.jaxb.metadata.MD_Identifier; +// Branch-specific imports +import org.opengis.annotation.UML; import static org.opengis.annotation.Obligation.OPTIONAL; import static org.opengis.annotation.Obligation.MANDATORY; import static org.opengis.annotation.Obligation.CONDITIONAL; @@ -126,24 +130,45 @@ import static org.opengis.annotation.Spe * @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_Metadata_Type", propOrder = { + // Attributes new in ISO 19115:2014 + "metadataIdentifier", + "defaultLocale", + "parentMetadata", + + // Legacy ISO 19115:2003 attributes "fileIdentifier", "language", "characterSet", "parentIdentifier", "hierarchyLevels", "hierarchyLevelNames", + + // Common to both versions "contacts", + + // Attributes new in ISO 19115:2014 + "dates", // actually "dateInfo" + "metadataStandard", + "metadataProfile", + "alternativeMetadataReference", + "otherLocales", + "metadataLinkage", + + // Legacy ISO 19115:2003 attributes "dateStamp", "metadataStandardName", "metadataStandardVersion", "dataSetUri", "locales", + + // Common to both metadata models "spatialRepresentationInfo", "referenceSystemInfo", "metadataExtensionInfo", @@ -155,6 +180,12 @@ import static org.opengis.annotation.Spe "metadataConstraints", "applicationSchemaInfo", "metadataMaintenance", + "resourceLineage", + + // Attributes new in ISO 19115:2014 + "metadataScope", + + // GMI extension "acquisitionInformation" }) @XmlRootElement(name = "MD_Metadata") @@ -413,6 +444,8 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + @XmlElement(name = "metadataIdentifier") + @XmlJavaTypeAdapter(MD_Identifier.Since2014.class) @UML(identifier="metadataIdentifier", obligation=OPTIONAL, specification=ISO_19115) public Identifier getMetadataIdentifier() { return metadataIdentifier; @@ -440,11 +473,14 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "fileIdentifier") @Dependencies("getMetadataIdentifier") + @XmlElement(name = "fileIdentifier", namespace = LegacyNamespaces.GMD) public String getFileIdentifier() { - final Identifier identifier = getMetadataIdentifier(); - return (identifier != null) ? identifier.getCode() : null; + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Identifier identifier = getMetadataIdentifier(); + if (identifier != null) return identifier.getCode(); + } + return null; } /** @@ -482,6 +518,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="defaultLocale+otherLocale", obligation=CONDITIONAL, specification=ISO_19115) public Collection<Locale> getLanguages() { return languages = nonNullCollection(languages, Locale.class); @@ -500,7 +537,7 @@ public class DefaultMetadata extends ISO */ public void setLanguages(final Collection<Locale> newValues) { languages = writeCollection(newValues, languages, Locale.class); - // The "magik" applying this language to every children + // The "magic" applying this language to every children // is performed by the 'beforeMarshal(Marshaller)' method. } @@ -513,10 +550,11 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "language") @Dependencies("getLanguages") + @XmlElement(name = "language", namespace = LegacyNamespaces.GMD) + @XmlJavaTypeAdapter(LocaleAdapter.class) public Locale getLanguage() { - return CollectionsExt.first(getLanguages()); + return FilterByVersion.LEGACY_METADATA.accept() ? CollectionsExt.first(getLanguages()) : null; /* * No warning if the collection contains more than one locale, because * this is allowed by the "getLanguage() + getLocales()" contract. @@ -539,7 +577,7 @@ public class DefaultMetadata extends ISO @Deprecated public void setLanguage(final Locale newValue) { checkWritePermission(); - setLanguages(OtherLocales.setFirst(languages, newValue)); // See "Note about deprecated methods implementation" + setDefaultLocale(newValue); } /** @@ -551,11 +589,10 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "locale") - @XmlJavaTypeAdapter(PT_Locale.class) @Dependencies("getLanguages") + @XmlElement(name = "locale", namespace = LegacyNamespaces.GMD) public Collection<Locale> getLocales() { - return OtherLocales.filter(getLanguages()); + return FilterByVersion.LEGACY_METADATA.accept() ? OtherLocales.filter(getLanguages()) : null; } /** @@ -568,7 +605,7 @@ public class DefaultMetadata extends ISO @Deprecated public void setLocales(final Collection<? extends Locale> newValues) { checkWritePermission(); - setLanguages(OtherLocales.merge(CollectionsExt.first(languages), newValues)); // See "Note about deprecated methods implementation" + setOtherLocales(newValues); } /** @@ -593,6 +630,7 @@ public class DefaultMetadata extends ISO * @see #getLanguages() * @see org.opengis.metadata.identification.DataIdentification#getCharacterSets() * @see Charset#forName(String) + * @see <a href="https://issues.apache.org/jira/browse/SIS-402">SIS-402</a> * * @since 0.5 */ @@ -621,23 +659,25 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "characterSet") @Dependencies("getCharacterSets") + @XmlElement(name = "characterSet", namespace = LegacyNamespaces.GMD) public CharacterSet getCharacterSet() { - final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(), - Charset.class, null, DefaultMetadata.class, "getCharacterSet"); - if (cs == null) { - return null; - } - final String name = cs.name(); - for (final CharacterSet candidate : CharacterSet.values()) { - for (final String n : candidate.names()) { - if (name.equals(n)) { - return candidate; + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(), + Charset.class, null, DefaultMetadata.class, "getCharacterSet"); + if (cs != null) { + final String name = cs.name(); + for (final CharacterSet candidate : CharacterSet.values()) { + for (final String n : candidate.names()) { + if (name.equals(n)) { + return candidate; + } + } } + return CharacterSet.valueOf(name); } } - return CharacterSet.valueOf(name); + return null; } /** @@ -660,6 +700,8 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + @XmlElement(name = "parentMetadata") + @XmlJavaTypeAdapter(CI_Citation.Since2014.class) @UML(identifier="parentMetadata", obligation=CONDITIONAL, specification=ISO_19115) public Citation getParentMetadata() { return parentMetadata; @@ -686,14 +728,16 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "parentIdentifier") @Dependencies("getParentMetadata") + @XmlElement(name = "parentIdentifier", namespace = LegacyNamespaces.GMD) public String getParentIdentifier() { - final Citation parentMetadata = getParentMetadata(); - if (parentMetadata != null) { - final InternationalString title = parentMetadata.getTitle(); - if (title != null) { - return title.toString(); + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Citation parentMetadata = getParentMetadata(); + if (parentMetadata != null) { + final InternationalString title = parentMetadata.getTitle(); + if (title != null) { + return title.toString(); + } } } return null; @@ -730,6 +774,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="metadataScope", obligation=CONDITIONAL, specification=ISO_19115) public Collection<DefaultMetadataScope> getMetadataScopes() { return metadataScopes = nonNullCollection(metadataScopes, DefaultMetadataScope.class); @@ -761,9 +806,10 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "hierarchyLevel") @Dependencies("getMetadataScopes") + @XmlElement(name = "hierarchyLevel", namespace = LegacyNamespaces.GMD) public final Collection<ScopeCode> getHierarchyLevels() { + if (!FilterByVersion.LEGACY_METADATA.accept()) return null; return new MetadataScopeAdapter<ScopeCode>(getMetadataScopes()) { /** Stores a legacy value into the new kind of value. */ @Override protected DefaultMetadataScope wrap(final ScopeCode value) { @@ -807,9 +853,10 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "hierarchyLevelName") @Dependencies("getMetadataScopes") + @XmlElement(name = "hierarchyLevelName", namespace = LegacyNamespaces.GMD) public final Collection<String> getHierarchyLevelNames() { + if (!FilterByVersion.LEGACY_METADATA.accept()) return null; return new MetadataScopeAdapter<String>(getMetadataScopes()) { /** Stores a legacy value into the new kind of value. */ @Override protected DefaultMetadataScope wrap(final String value) { @@ -879,6 +926,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="dateInfo", obligation=MANDATORY, specification=ISO_19115) public Collection<CitationDate> getDateInfo() { return dateInfo = nonNullCollection(dateInfo, CitationDate.class); @@ -905,14 +953,16 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "dateStamp", required = true) @Dependencies("getDateInfo") + @XmlElement(name = "dateStamp", namespace = LegacyNamespaces.GMD) public Date getDateStamp() { - final Collection<CitationDate> dates = getDateInfo(); - if (dates != null) { - for (final CitationDate date : dates) { - if (DateType.CREATION.equals(date.getDateType())) { - return date.getDate(); + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Collection<CitationDate> dates = getDateInfo(); + if (dates != null) { + for (final CitationDate date : dates) { + if (DateType.CREATION.equals(date.getDateType())) { + return date.getDate(); + } } } } @@ -968,6 +1018,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="metadataStandard", obligation=OPTIONAL, specification=ISO_19115) public Collection<Citation> getMetadataStandards() { return metadataStandards = nonNullCollection(metadataStandards, Citation.class); @@ -995,6 +1046,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="metadataProfile", obligation=OPTIONAL, specification=ISO_19115) public Collection<Citation> getMetadataProfiles() { return metadataProfiles = nonNullCollection(metadataProfiles, Citation.class); @@ -1019,6 +1071,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="alternativeMetadataReference", obligation=OPTIONAL, specification=ISO_19115) public Collection<Citation> getAlternativeMetadataReferences() { return alternativeMetadataReferences = nonNullCollection(alternativeMetadataReferences, Citation.class); @@ -1039,12 +1092,15 @@ public class DefaultMetadata extends ISO * Implementation of legacy {@link #getMetadataStandardName()} and {@link #getMetadataStandardVersion()} methods. */ private String getMetadataStandard(final boolean version) { - final Citation standard = LegacyPropertyAdapter.getSingleton(getMetadataStandards(), - Citation.class, null, DefaultMetadata.class, version ? "getMetadataStandardName" : "getMetadataStandardVersion"); - if (standard != null) { - final InternationalString title = version ? standard.getEdition() : standard.getTitle(); - if (title != null) { - return title.toString(); + if (FilterByVersion.LEGACY_METADATA.accept()) { + final Citation standard = LegacyPropertyAdapter.getSingleton(getMetadataStandards(), + Citation.class, null, DefaultMetadata.class, + version ? "getMetadataStandardName" : "getMetadataStandardVersion"); + if (standard != null) { + final InternationalString title = version ? standard.getEdition() : standard.getTitle(); + if (title != null) { + return title.toString(); + } } } return null; @@ -1087,8 +1143,8 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "metadataStandardName") @Dependencies("getMetadataStandards") + @XmlElement(name = "metadataStandardName", namespace = LegacyNamespaces.GMD) public String getMetadataStandardName() { return getMetadataStandard(false); } @@ -1116,8 +1172,8 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "metadataStandardVersion") @Dependencies("getMetadataStandards") + @XmlElement(name = "metadataStandardVersion", namespace = LegacyNamespaces.GMD) public String getMetadataStandardVersion() { return getMetadataStandard(true); } @@ -1142,6 +1198,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="metadataLinkage", obligation=OPTIONAL, specification=ISO_19115) public Collection<OnlineResource> getMetadataLinkages() { return metadataLinkages = nonNullCollection(metadataLinkages, OnlineResource.class); @@ -1168,12 +1225,12 @@ public class DefaultMetadata extends ISO */ @Override @Deprecated - @XmlElement(name = "dataSetURI") @Dependencies("getIdentificationInfo") + @XmlElement(name = "dataSetURI", namespace = LegacyNamespaces.GMD) public String getDataSetUri() { String linkage = null; - final Collection<Identification> info = getIdentificationInfo(); - if (info != null) { + final Collection<Identification> info; + if (FilterByVersion.LEGACY_METADATA.accept() && (info = getIdentificationInfo()) != null) { for (final Identification identification : info) { final Citation citation = identification.getCitation(); if (citation instanceof DefaultCitation) { @@ -1458,7 +1515,7 @@ public class DefaultMetadata extends ISO * @return the acquisition of data. */ @Override - @XmlElement(name = "acquisitionInformation", namespace = Namespaces.GMI) + @XmlElement(name = "acquisitionInformation") public Collection<AcquisitionInformation> getAcquisitionInformation() { return acquisitionInformation = nonNullCollection(acquisitionInformation, AcquisitionInformation.class); } @@ -1504,6 +1561,7 @@ public class DefaultMetadata extends ISO * * @since 0.5 */ + // @XmlElement at the end of this class. @UML(identifier="resourceLineage", obligation=OPTIONAL, specification=ISO_19115) public Collection<Lineage> getResourceLineages() { return resourceLineages = nonNullCollection(resourceLineages, Lineage.class); @@ -1538,6 +1596,7 @@ public class DefaultMetadata extends ISO * Invoked by JAXB {@link javax.xml.bind.Marshaller} before this object is marshalled to XML. * This method sets the locale to be used for XML marshalling to the metadata language. */ + @SuppressWarnings("unused") private void beforeMarshal(final Marshaller marshaller) { Context.push(CollectionsExt.first(languages)); } @@ -1546,7 +1605,78 @@ public class DefaultMetadata extends ISO * Invoked by JAXB {@link javax.xml.bind.Marshaller} after this object has been marshalled to * XML. This method restores the locale to be used for XML marshalling to its previous value. */ + @SuppressWarnings("unused") private void afterMarshal(final Marshaller marshaller) { Context.pull(); } + + /** + * Gets the default locale for this record (used in ISO 19115-3 format). + */ + @XmlElement(name = "defaultLocale") + private Locale getDefaultLocale() { + return FilterByVersion.CURRENT_METADATA.accept() ? CollectionsExt.first(getLanguages()) : null; + } + + /** + * Sets the default locale for this record (used in ISO 19115-3 format). + */ + private void setDefaultLocale(final Locale newValue) { + setLanguages(OtherLocales.setFirst(languages, newValue)); // See "Note about deprecated methods implementation" + } + + /** + * Gets the other locales for this record (used in ISO 19115-3 format). + */ + @XmlElement(name = "otherLocale") + private Collection<Locale> getOtherLocales() { + return FilterByVersion.CURRENT_METADATA.accept() ? OtherLocales.filter(getLanguages()) : null; + } + + /** + * Sets the other locales for this record (used in ISO 19115-3 format). + */ + private void setOtherLocales(final Collection<? extends Locale> newValues) { + setLanguages(OtherLocales.merge(CollectionsExt.first(languages), newValues)); + } + + /** + * 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 = "dateInfo", required = true) + private Collection<CitationDate> getDates() { + return FilterByVersion.CURRENT_METADATA.accept() ? getDateInfo() : null; + } + + @XmlElement(name = "metadataStandard") + private Collection<Citation> getMetadataStandard() { + return FilterByVersion.CURRENT_METADATA.accept() ? getMetadataStandards() : null; + } + + @XmlElement(name = "metadataProfile") + private Collection<Citation> getMetadataProfile() { + return FilterByVersion.CURRENT_METADATA.accept() ? getMetadataProfiles() : null; + } + + @XmlElement(name = "alternativeMetadataReference") + private Collection<Citation> getAlternativeMetadataReference() { + return FilterByVersion.CURRENT_METADATA.accept() ? getAlternativeMetadataReferences() : null; + } + + @XmlElement(name = "metadataLinkage") + private Collection<OnlineResource> getMetadataLinkage() { + return FilterByVersion.CURRENT_METADATA.accept() ? getMetadataLinkages() : null; + } + + @XmlElement(name = "resourceLineage") + private Collection<Lineage> getResourceLineage() { + return FilterByVersion.CURRENT_METADATA.accept() ? getResourceLineages() : null; + } + + @XmlElement(name = "metadataScope") + private Collection<DefaultMetadataScope> getMetadataScope() { + return FilterByVersion.CURRENT_METADATA.accept() ? getMetadataScopes() : null; + } } Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadataExtensionInformation.java URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadataExtensionInformation.java?rev=1825355&r1=1825354&r2=1825355&view=diff ============================================================================== --- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadataExtensionInformation.java [UTF-8] (original) +++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadataExtensionInformation.java [UTF-8] Mon Feb 26 11:28:17 2018 @@ -23,6 +23,7 @@ import javax.xml.bind.annotation.XmlRoot import org.opengis.metadata.citation.OnlineResource; import org.opengis.metadata.ExtendedElementInformation; import org.opengis.metadata.MetadataExtensionInformation; +import org.apache.sis.xml.Namespaces; /** @@ -40,16 +41,17 @@ import org.opengis.metadata.MetadataExte * @author Martin Desruisseaux (IRD, Geomatys) * @author Touraïvane (IRD) * @author Cédric Briançon (Geomatys) - * @version 0.3 + * @author Cullen Rombach (Image Matters) + * @version 1.0 * @since 0.3 * @module */ @SuppressWarnings("CloneableClassWithoutClone") // ModifiableMetadata needs shallow clones. -@XmlType(name = "MD_MetadataExtensionInformation_Type", propOrder = { +@XmlType(name = "MD_MetadataExtensionInformation_Type", namespace = Namespaces.MEX, propOrder = { "extensionOnLineResource", "extendedElementInformation" }) -@XmlRootElement(name = "MD_MetadataExtensionInformation") +@XmlRootElement(name = "MD_MetadataExtensionInformation", namespace = Namespaces.MEX) public class DefaultMetadataExtensionInformation extends ISOMetadata implements MetadataExtensionInformation { /** * Serial number for compatibility with different versions.
