You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2017/05/26 13:31:31 UTC
svn commit: r1796285 - in /sis/trunk: ./
core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/
core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/
core/sis-metad...
Author: desruisseaux
Date: Fri May 26 13:31:31 2017
New Revision: 1796285
URL: http://svn.apache.org/viewvc?rev=1796285&view=rev
Log:
Merge from the JDK7 branch.
Added:
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java
- copied unchanged from r1796283, sis/branches/JDK7/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/Dependencies.java
Modified:
sis/trunk/ (props changed)
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultExtendedElementInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/Dispatcher.java
sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
Propchange: sis/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri May 26 13:31:31 2017
@@ -1,5 +1,5 @@
/sis/branches/Android:1430670-1480699
/sis/branches/JDK6:1394364-1758914
-/sis/branches/JDK7:1394913-1795923
-/sis/branches/JDK8:1584960-1795919
+/sis/branches/JDK7:1394913-1796283
+/sis/branches/JDK8:1584960-1796282
/sis/branches/JDK9:1773327-1789983
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=1796285&r1=1796284&r2=1796285&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] Fri May 26 13:31:31 2017
@@ -29,6 +29,7 @@ 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.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
@@ -548,6 +549,7 @@ 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/DefaultMetadata.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java?rev=1796285&r1=1796284&r2=1796285&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] Fri May 26 13:31:31 2017
@@ -64,6 +64,7 @@ import org.apache.sis.metadata.iso.ident
import org.apache.sis.metadata.iso.identification.DefaultDataIdentification;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
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.Context;
@@ -413,6 +414,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "fileIdentifier")
+ @Dependencies("getMetadataIdentifier")
public String getFileIdentifier() {
final Identifier identifier = getMetadataIdentifier();
return (identifier != null) ? identifier.getCode() : null;
@@ -485,6 +487,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "language")
+ @Dependencies("getLanguages")
public Locale getLanguage() {
return CollectionsExt.first(getLanguages());
/*
@@ -523,6 +526,7 @@ public class DefaultMetadata extends ISO
@Deprecated
@XmlElement(name = "locale")
@XmlJavaTypeAdapter(PT_Locale.class)
+ @Dependencies("getLanguages")
public Collection<Locale> getLocales() {
return OtherLocales.filter(getLanguages());
}
@@ -591,6 +595,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "characterSet")
+ @Dependencies("getCharacterSets")
public CharacterSet getCharacterSet() {
final Charset cs = LegacyPropertyAdapter.getSingleton(getCharacterSets(),
Charset.class, null, DefaultMetadata.class, "getCharacterSet");
@@ -655,6 +660,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "parentIdentifier")
+ @Dependencies("getParentMetadata")
public String getParentIdentifier() {
final Citation parentMetadata = getParentMetadata();
if (parentMetadata != null) {
@@ -676,7 +682,8 @@ public class DefaultMetadata extends ISO
@Deprecated
public void setParentIdentifier(final String newValue) {
checkWritePermission();
- DefaultCitation parent = DefaultCitation.castOrCopy(parentMetadata); // See "Note about deprecated methods implementation"
+ // See "Note about deprecated methods implementation"
+ DefaultCitation parent = DefaultCitation.castOrCopy(parentMetadata);
if (parent == null) {
parent = new DefaultCitation();
}
@@ -728,6 +735,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "hierarchyLevel")
+ @Dependencies("getMetadataScopes")
public final Collection<ScopeCode> getHierarchyLevels() {
return new MetadataScopeAdapter<ScopeCode>(getMetadataScopes()) {
/** Stores a legacy value into the new kind of value. */
@@ -773,6 +781,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "hierarchyLevelName")
+ @Dependencies("getMetadataScopes")
public final Collection<String> getHierarchyLevelNames() {
return new MetadataScopeAdapter<String>(getMetadataScopes()) {
/** Stores a legacy value into the new kind of value. */
@@ -870,6 +879,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "dateStamp", required = true)
+ @Dependencies("getDateInfo")
public Date getDateStamp() {
final Collection<CitationDate> dates = getDateInfo();
if (dates != null) {
@@ -1051,6 +1061,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "metadataStandardName")
+ @Dependencies("getMetadataStandards")
public String getMetadataStandardName() {
return getMetadataStandard(false);
}
@@ -1079,6 +1090,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "metadataStandardVersion")
+ @Dependencies("getMetadataStandards")
public String getMetadataStandardVersion() {
return getMetadataStandard(true);
}
@@ -1130,6 +1142,7 @@ public class DefaultMetadata extends ISO
@Override
@Deprecated
@XmlElement(name = "dataSetURI")
+ @Dependencies("getIdentificationInfo")
public String getDataSetUri() {
String linkage = null;
final Collection<Identification> info = getIdentificationInfo();
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultContact.java [UTF-8] Fri May 26 13:31:31 2017
@@ -32,6 +32,7 @@ import org.opengis.metadata.citation.Onl
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.resources.Messages;
import org.apache.sis.internal.jaxb.Context;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import org.apache.sis.internal.geoapi.evolution.UnsupportedCodeList;
@@ -229,6 +230,7 @@ public class DefaultContact extends ISOM
@Override
@Deprecated
@XmlElement(name = "phone")
+ @Dependencies("getPhones")
public Telephone getPhone() {
Telephone phone = null;
final Collection<Telephone> phones = getPhones();
@@ -316,6 +318,7 @@ public class DefaultContact extends ISOM
@Override
@Deprecated
@XmlElement(name = "address")
+ @Dependencies("getAddresses")
public Address getAddress() {
return LegacyPropertyAdapter.getSingleton(getAddresses(), Address.class, null, DefaultContact.class, "getAddress");
}
@@ -367,6 +370,7 @@ public class DefaultContact extends ISOM
@Override
@Deprecated
@XmlElement(name = "onlineResource")
+ @Dependencies("getOnlineResources")
public OnlineResource getOnlineResource() {
return LegacyPropertyAdapter.getSingleton(getOnlineResources(), OnlineResource.class, null, DefaultContact.class, "getOnlineResource");
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultResponsibleParty.java [UTF-8] Fri May 26 13:31:31 2017
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Res
import org.opengis.metadata.citation.Role;
import org.opengis.util.InternationalString;
import org.apache.sis.util.iso.Types;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
@@ -171,7 +172,7 @@ public class DefaultResponsibleParty ext
final Class<? extends AbstractParty> type, final boolean position)
{
InternationalString name = null;
- if (parties != null) { // May be null on marshalling.
+ if (parties != null) { // May be null on marshalling.
for (final AbstractParty party : parties) {
if (type.isInstance(party)) {
if (name != null) {
@@ -228,6 +229,7 @@ public class DefaultResponsibleParty ext
@Override
@Deprecated
@XmlElement(name = "individualName")
+ @Dependencies("getParties")
public String getIndividualName() {
final InternationalString name = getIndividual(false);
return (name != null) ? name.toString() : null;
@@ -267,6 +269,7 @@ public class DefaultResponsibleParty ext
@Override
@Deprecated
@XmlElement(name = "organisationName")
+ @Dependencies("getParties")
public InternationalString getOrganisationName() {
return getName(getParties(), DefaultOrganisation.class, false);
}
@@ -306,6 +309,7 @@ public class DefaultResponsibleParty ext
@Override
@Deprecated
@XmlElement(name = "positionName")
+ @Dependencies("getParties")
public InternationalString getPositionName() {
return getIndividual(true);
}
@@ -342,6 +346,7 @@ public class DefaultResponsibleParty ext
@Override
@Deprecated
@XmlElement(name = "contactInfo")
+ @Dependencies("getParties")
public Contact getContactInfo() {
final Collection<AbstractParty> parties = getParties();
if (parties != null) { // May be null on marshalling.
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/citation/DefaultTelephone.java [UTF-8] Fri May 26 13:31:31 2017
@@ -28,6 +28,7 @@ import org.opengis.metadata.citation.Tel
import org.apache.sis.internal.util.CollectionsExt;
import org.apache.sis.internal.geoapi.evolution.UnsupportedCodeList;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.metadata.Dependencies;
import static org.opengis.annotation.Obligation.OPTIONAL;
import static org.opengis.annotation.Obligation.MANDATORY;
@@ -311,6 +312,7 @@ public class DefaultTelephone extends IS
@Override
@Deprecated
@XmlElement(name = "voice")
+ @Dependencies({"getNumber", "getNumberType"})
public final Collection<String> getVoices() {
return new LegacyTelephones(getOwner(), UnsupportedCodeList.VOICE);
}
@@ -343,6 +345,7 @@ public class DefaultTelephone extends IS
@Override
@Deprecated
@XmlElement(name = "facsimile")
+ @Dependencies({"getNumber", "getNumberType"})
public final Collection<String> getFacsimiles() {
return new LegacyTelephones(getOwner(), UnsupportedCodeList.FACSIMILE);
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultCoverageDescription.java [UTF-8] Fri May 26 13:31:31 2017
@@ -31,6 +31,7 @@ import org.opengis.metadata.content.Rang
import org.opengis.metadata.content.RangeElementDescription;
import org.opengis.util.RecordType;
import org.apache.sis.xml.Namespaces;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import static org.opengis.annotation.Obligation.OPTIONAL;
import static org.opengis.annotation.Specification.ISO_19115;
@@ -242,13 +243,14 @@ public class DefaultCoverageDescription
@Override
@Deprecated
@XmlElement(name = "contentType", required = true)
+ @Dependencies("getAttributeGroups")
public CoverageContentType getContentType() {
CoverageContentType type = null;
final Collection<DefaultAttributeGroup> groups = getAttributeGroups();
- if (groups != null) { // May be null on marshalling.
+ if (groups != null) { // May be null on marshalling.
for (final DefaultAttributeGroup g : groups) {
final Collection<? extends CoverageContentType> contentTypes = g.getContentTypes();
- if (contentTypes != null) { // May be null on marshalling.
+ if (contentTypes != null) { // May be null on marshalling.
for (final CoverageContentType t : contentTypes) {
if (type == null) {
type = t;
@@ -304,6 +306,7 @@ public class DefaultCoverageDescription
@Override
@Deprecated
@XmlElement(name = "dimension")
+ @Dependencies("getAttributeGroups")
public final Collection<RangeDimension> getDimensions() {
return new LegacyPropertyAdapter<RangeDimension,DefaultAttributeGroup>(getAttributeGroups()) {
/** Stores a legacy value into the new kind of value. */
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultFeatureCatalogueDescription.java [UTF-8] Fri May 26 13:31:31 2017
@@ -25,6 +25,7 @@ import org.opengis.annotation.UML;
import org.opengis.util.GenericName;
import org.opengis.metadata.citation.Citation;
import org.opengis.metadata.content.FeatureCatalogueDescription;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import static org.opengis.annotation.Obligation.OPTIONAL;
@@ -256,6 +257,7 @@ public class DefaultFeatureCatalogueDesc
@Override
@Deprecated
@XmlElement(name = "featureTypes")
+ @Dependencies("getFeatureTypeInfo")
public final Collection<GenericName> getFeatureTypes() {
return new LegacyPropertyAdapter<GenericName,DefaultFeatureTypeInfo>(getFeatureTypeInfo()) {
/** Stores a legacy value into the new kind of value. */
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/content/DefaultRangeDimension.java [UTF-8] Fri May 26 13:31:31 2017
@@ -29,6 +29,7 @@ import org.opengis.metadata.content.Rang
import org.opengis.metadata.content.Band;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.metadata.TitleProperty;
+import org.apache.sis.internal.metadata.Dependencies;
import static org.opengis.annotation.Obligation.OPTIONAL;
import static org.opengis.annotation.Specification.ISO_19115;
@@ -199,6 +200,7 @@ public class DefaultRangeDimension exten
@Override
@Deprecated
@XmlElement(name = "descriptor")
+ @Dependencies("getDescription")
public InternationalString getDescriptor() {
return getDescription();
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultDigitalTransferOptions.java [UTF-8] Fri May 26 13:31:31 2017
@@ -30,6 +30,7 @@ import org.opengis.metadata.distribution
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import org.apache.sis.measure.ValueRange;
import org.apache.sis.metadata.iso.ISOMetadata;
+import org.apache.sis.internal.metadata.Dependencies;
import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
@@ -267,6 +268,7 @@ public class DefaultDigitalTransferOptio
@Override
@Deprecated
@XmlElement(name = "offLine")
+ @Dependencies("getOffLines")
public Medium getOffLine() {
return LegacyPropertyAdapter.getSingleton(getOffLines(), Medium.class, null, DefaultDigitalTransferOptions.class, "getOffLine");
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultFormat.java [UTF-8] Fri May 26 13:31:31 2017
@@ -27,6 +27,7 @@ import org.opengis.metadata.citation.Cit
import org.opengis.metadata.distribution.Format;
import org.opengis.metadata.distribution.Medium;
import org.opengis.metadata.distribution.Distributor;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
import org.apache.sis.metadata.iso.ISOMetadata;
@@ -256,6 +257,7 @@ public class DefaultFormat extends ISOMe
@Override
@Deprecated
@XmlElement(name = "specification")
+ @Dependencies("getFormatSpecificationCitation")
public InternationalString getSpecification() {
final Citation citation = getFormatSpecificationCitation();
return (citation != null) ? citation.getTitle() : null;
@@ -292,6 +294,7 @@ public class DefaultFormat extends ISOMe
@Override
@Deprecated
@XmlElement(name = "name", required = true)
+ @Dependencies("getFormatSpecificationCitation")
public InternationalString getName() {
final Citation citation = getFormatSpecificationCitation();
if (citation != null) {
@@ -332,6 +335,7 @@ public class DefaultFormat extends ISOMe
@Override
@Deprecated
@XmlElement(name = "version", required = true)
+ @Dependencies("getFormatSpecificationCitation")
public InternationalString getVersion() {
final Citation citation = getFormatSpecificationCitation();
return (citation != null) ? citation.getEdition() : null;
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/distribution/DefaultMedium.java [UTF-8] Fri May 26 13:31:31 2017
@@ -31,6 +31,7 @@ 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.NonMarshalledAuthority;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import static org.apache.sis.internal.metadata.MetadataUtilities.ensurePositive;
@@ -228,6 +229,7 @@ public class DefaultMedium extends ISOMe
@Override
@Deprecated
@XmlElement(name = "density")
+ @Dependencies("getDensity")
public Collection<Double> getDensities() {
return densities = nonNullCollection(densities, Double.class);
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/AbstractIdentification.java [UTF-8] Fri May 26 13:31:31 2017
@@ -43,6 +43,7 @@ import org.opengis.metadata.identificati
import org.opengis.metadata.maintenance.MaintenanceInformation;
import org.opengis.metadata.spatial.SpatialRepresentationType;
import org.opengis.util.InternationalString;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.util.iso.Types;
@@ -750,6 +751,7 @@ public class AbstractIdentification exte
@Override
@Deprecated
@XmlElement(name = "aggregationInfo")
+ @Dependencies("getAssociatedResources")
public Collection<AggregateInformation> getAggregationInfo() {
return new LegacyPropertyAdapter<AggregateInformation,DefaultAssociatedResource>(getAssociatedResources()) {
@Override protected DefaultAssociatedResource wrap(final AggregateInformation value) {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/identification/DefaultAggregateInformation.java [UTF-8] Fri May 26 13:31:31 2017
@@ -28,6 +28,7 @@ import org.opengis.metadata.identificati
import org.opengis.metadata.identification.AssociationType;
import org.opengis.metadata.identification.InitiativeType;
import org.apache.sis.metadata.iso.citation.DefaultCitation;
+import org.apache.sis.internal.metadata.Dependencies;
/**
@@ -137,6 +138,7 @@ public class DefaultAggregateInformation
@Override
@Deprecated
@XmlElement(name = "aggregateDataSetName")
+ @Dependencies("getName")
public Citation getAggregateDataSetName() {
return getName();
}
@@ -163,6 +165,7 @@ public class DefaultAggregateInformation
@Override
@Deprecated
@XmlElement(name = "aggregateDataSetIdentifier")
+ @Dependencies("getName")
public Identifier getAggregateDataSetIdentifier() {
return getAggregateDataSetIdentifier(getAggregateDataSetName());
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/lineage/DefaultSource.java [UTF-8] Fri May 26 13:31:31 2017
@@ -38,6 +38,7 @@ import org.apache.sis.metadata.TitleProp
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.metadata.iso.maintenance.DefaultScope;
import org.apache.sis.metadata.iso.identification.DefaultResolution;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.util.iso.Types;
import org.apache.sis.xml.Namespaces;
@@ -261,6 +262,7 @@ public class DefaultSource extends ISOMe
@Override
@Deprecated
@XmlElement(name = "scaleDenominator")
+ @Dependencies("getSourceSpatialResolution")
public RepresentativeFraction getScaleDenominator() {
final Resolution resolution = getSourceSpatialResolution();
return (resolution != null) ? resolution.getEquivalentScale() : null;
@@ -401,6 +403,7 @@ public class DefaultSource extends ISOMe
@Override
@Deprecated
@XmlElement(name = "sourceExtent")
+ @Dependencies("getScope")
public Collection<Extent> getSourceExtents() {
Scope scope = getScope();
if (!(scope instanceof DefaultScope)) {
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultMaintenanceInformation.java [UTF-8] Fri May 26 13:31:31 2017
@@ -37,6 +37,7 @@ import org.opengis.util.InternationalStr
import org.apache.sis.metadata.iso.ISOMetadata;
import org.apache.sis.metadata.iso.citation.DefaultCitationDate;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
+import org.apache.sis.internal.metadata.Dependencies;
import static org.opengis.annotation.Obligation.OPTIONAL;
import static org.opengis.annotation.Specification.ISO_19115;
@@ -246,6 +247,7 @@ public class DefaultMaintenanceInformati
@Override
@Deprecated
@XmlElement(name = "dateOfNextUpdate")
+ @Dependencies("getMaintenanceDates")
public Date getDateOfNextUpdate() {
final Collection<CitationDate> dates = getMaintenanceDates();
if (dates != null) { // May be null on XML marshalling.
@@ -352,6 +354,7 @@ public class DefaultMaintenanceInformati
@Override
@Deprecated
@XmlElement(name = "updateScope")
+ @Dependencies("getMaintenanceScopes")
public final Collection<ScopeCode> getUpdateScopes() {
return new LegacyPropertyAdapter<ScopeCode,Scope>(getMaintenanceScopes()) {
/** Stores a legacy value into the new kind of value. */
@@ -402,6 +405,7 @@ public class DefaultMaintenanceInformati
@Override
@Deprecated
@XmlElement(name = "updateScopeDescription")
+ @Dependencies("getMaintenanceScopes")
public final Collection<ScopeDescription> getUpdateScopeDescriptions() {
return new LegacyPropertyAdapter<ScopeDescription,Scope>(getMaintenanceScopes()) {
/** Stores a legacy value into the new kind of value. */
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/maintenance/DefaultScope.java [UTF-8] Fri May 26 13:31:31 2017
@@ -25,6 +25,7 @@ import org.opengis.metadata.extent.Exten
import org.opengis.metadata.quality.Scope;
import org.opengis.metadata.maintenance.ScopeCode;
import org.opengis.metadata.maintenance.ScopeDescription;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.internal.metadata.LegacyPropertyAdapter;
import org.apache.sis.metadata.iso.ISOMetadata;
@@ -195,6 +196,7 @@ public class DefaultScope extends ISOMet
*/
@Override
@Deprecated
+ @Dependencies("getExtents")
public Extent getExtent() {
return LegacyPropertyAdapter.getSingleton(getExtents(), Extent.class, null, DefaultScope.class, "getExtent");
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/Dispatcher.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/Dispatcher.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/Dispatcher.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/Dispatcher.java [UTF-8] Fri May 26 13:31:31 2017
@@ -25,9 +25,11 @@ import org.apache.sis.util.Classes;
import org.apache.sis.util.resources.Errors;
import org.apache.sis.util.collection.BackingStoreException;
import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.metadata.KeyNamePolicy;
import org.apache.sis.metadata.ValueExistencePolicy;
import org.apache.sis.internal.system.Semaphores;
+import org.apache.sis.internal.metadata.Dependencies;
// Branch-dependent imports
import org.apache.sis.internal.jdk8.JDK8;
@@ -128,13 +130,11 @@ final class Dispatcher implements Invoca
*/
@Override
public Object invoke(final Object proxy, final Method method, final Object[] args) {
- final Class<?> type = method.getDeclaringClass();
- final String name = method.getName();
- final int n = (args != null) ? args.length : 0;
- switch (name) {
+ final int n = (args != null) ? args.length : 0;
+ switch (method.getName()) {
case "toString": {
if (n != 0) break;
- return toString(type);
+ return toString(method.getDeclaringClass());
}
case "hashCode": {
if (n != 0) break;
@@ -149,28 +149,80 @@ final class Dispatcher implements Invoca
return (args[0] == source) ? identifier : null;
}
default: {
- if (n != 0 || !source.standard.isMetadata(type)) {
- throw new BackingStoreException(Errors.format(Errors.Keys.UnsupportedOperation_1,
- Classes.getShortName(type) + '.' + name));
+ if (n != 0) break;
+ /*
+ * The invoked method is a method from the metadata interface.
+ * Consequently, the information should exist in the database.
+ * First, we will check the cache. If the value is not present, we will query the database and
+ * fetch the cache again (because the class that implement the cache may perform some computation).
+ */
+ Object value;
+ try {
+ value = fetchValue(source.getLookupInfo(method.getDeclaringClass()), method);
+ } catch (ReflectiveOperationException | SQLException | MetadataStoreException e) {
+ Class<?> returnType = method.getReturnType();
+ if (Collection.class.isAssignableFrom(returnType)) {
+ final Class<?> elementType = Classes.boundOfParameterizedProperty(method);
+ if (elementType != null) {
+ returnType = elementType;
+ }
+ }
+ throw new BackingStoreException(Errors.format(Errors.Keys.DatabaseError_2, returnType, identifier), e);
}
- break;
+ /*
+ * At this point we got the metadata property value, which may be null.
+ * If the method returns a collection, replace null value by empty set or empty list.
+ */
+ if (value == null) {
+ final Class<?> returnType = method.getReturnType();
+ if (Collection.class.isAssignableFrom(returnType)) {
+ value = CollectionsExt.empty(returnType);
+ }
+ }
+ return value;
}
}
/*
- * The invoked method is a method from the metadata interface.
- * Consequently, the information should exist in the database.
- * First, we will check the cache. If the value is not present, we will query the database and
- * fetch the cache again (because the class that implement the cache may perform some computation).
+ * Unknown method invoked, or wrong number of arguments.
*/
+ throw new BackingStoreException(Errors.format(Errors.Keys.UnsupportedOperation_1,
+ Classes.getShortName(method.getDeclaringClass()) + '.' + method.getName()));
+ }
+
+ /**
+ * Gets, computes or read from the database a metadata property value.
+ * This method returns the first non-null value in the following choices:
+ *
+ * <ol>
+ * <li>If the property value is present in the {@linkplain #cache}, the cached value.</li>
+ * <li>If the "cache" can compute the value from other property values, the result of that computation.
+ * This case happen mostly for deprecated properties that are replaced by one or more newer properties.</li>
+ * <li>The value stored in the database. The database is queried only once for the requested property
+ * and the result is cached for future reuse.</li>
+ * </ol>
+ *
+ * @param info information related to the <em>interface</em> of the metadata object for which a property
+ * value is requested. This is used for fetching information from the {@link MetadataStandard}.
+ * @param method the method to be invoked. The class given by {@link Method#getDeclaringClass()} is usually
+ * the same than the one given by {@link LookupInfo#getMetadataType()}, but not necessarily.
+ * The two classes may differ if the method is declared only in the implementation class.
+ * @return the property value, or {@code null} if none.
+ * @throws ReflectiveOperationException if an error occurred while querying the {@link #cache}.
+ * @throws SQLException if an error occurred while querying the database.
+ * @throws MetadataStoreException if a value was not found or can not be converted to the expected type.
+ */
+ private Object fetchValue(final LookupInfo info, final Method method)
+ throws ReflectiveOperationException, SQLException, MetadataStoreException
+ {
Object value = null;
- final LookupInfo info = source.getLookupInfo(type);
final long nullBit = 1L << info.asIndexMap(source.standard).get(method.getName()); // Okay even if overflow.
/*
* The NULL_COLLECTION semaphore prevents creation of new empty collections by getter methods
* (a consequence of lazy instantiation). The intend is to avoid creation of unnecessary objects
* for all unused properties. Users should not see behavioral difference.
*/
- if ((nullValues & nullBit) == 0) try {
+ if ((nullValues & nullBit) == 0) {
+ final Class<?> type = info.getMetadataType();
final boolean allowNull = Semaphores.queryAndSet(Semaphores.NULL_COLLECTION);
try {
Object cache = this.cache;
@@ -202,6 +254,31 @@ final class Dispatcher implements Invoca
value = method.invoke(cache);
}
}
+ } else {
+ /*
+ * If we found no explicit value for the requested property, maybe it is a deprecated property
+ * computed from other property values and those other properties have not yet been stored in
+ * the cache object (because that "cache" is also the object computing deprecated properties).
+ */
+ final Class<?> impl = source.standard.getImplementation(type);
+ if (impl != null) {
+ final Dependencies dependencies = impl.getMethod(method.getName()).getAnnotation(Dependencies.class);
+ if (dependencies != null) {
+ boolean hasValue = false;
+ for (final String dep : dependencies.value()) {
+ info.setMetadataType(type);
+ hasValue |= (fetchValue(info, impl.getMethod(dep)) != null);
+ }
+ if (hasValue) {
+ cache = this.cache; // Created by recursive 'invoke(…)' call above.
+ if (cache != null) {
+ synchronized (cache) {
+ value = method.invoke(cache); // Attempt a new computation.
+ }
+ }
+ }
+ }
+ }
}
}
} finally {
@@ -209,22 +286,9 @@ final class Dispatcher implements Invoca
Semaphores.clear(Semaphores.NULL_COLLECTION);
}
}
- } catch (ReflectiveOperationException | SQLException | MetadataStoreException e) {
- Class<?> returnType = method.getReturnType();
- if (Collection.class.isAssignableFrom(returnType)) {
- final Class<?> elementType = Classes.boundOfParameterizedProperty(method);
- if (elementType != null) {
- returnType = elementType;
- }
- }
- throw new BackingStoreException(Errors.format(Errors.Keys.DatabaseError_2, returnType, identifier), e);
}
if (value == null) {
nullValues |= nullBit;
- final Class<?> returnType = method.getReturnType();
- if (Collection.class.isAssignableFrom(returnType)) {
- value = CollectionsExt.empty(returnType);
- }
}
return value;
}
Modified: sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/main/java/org/apache/sis/metadata/sql/MetadataSource.java [UTF-8] Fri May 26 13:31:31 2017
@@ -913,14 +913,11 @@ public class MetadataSource implements A
}
}
/*
- * Now converts the value to its final type, including conversion of null
- * value to empty collections if the return value should be a collection.
+ * Now converts the value to its final type. To be strict, we should convert null values into empty collections
+ * if the return type is a collection type. But we leave this task to the caller (which is the Dispatcher class)
+ * for making easier to detect when a value is absent, for allowing Dispatcher to manage its cache.
*/
- if (value == null) {
- if (wantCollection) {
- return CollectionsExt.empty(returnType);
- }
- } else {
+ if (value != null) {
if (isMetadata) {
value = lookup(elementType, value.toString());
} else try {
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/MetadataTestCase.java [UTF-8] Fri May 26 13:31:31 2017
@@ -20,12 +20,15 @@ import java.util.Date;
import java.util.Locale;
import java.util.Random;
import java.util.Collection;
+import java.util.Map;
+import java.lang.reflect.Method;
import org.opengis.util.CodeList;
import org.opengis.metadata.identification.CharacterSet;
import org.apache.sis.util.Numbers;
import org.apache.sis.util.ArraysExt;
import org.apache.sis.util.collection.CheckedContainer;
import org.apache.sis.internal.util.CollectionsExt;
+import org.apache.sis.internal.metadata.Dependencies;
import org.apache.sis.test.AnnotationsTestCase;
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.DependsOn;
@@ -112,7 +115,7 @@ public abstract strictfp class MetadataT
* @param type the type of value to create.
* @return the value of the given {@code type}, or of a type convertible to the given type.
*/
- protected Object valueFor(final String property, final Class<?> type) {
+ protected Object sampleValueFor(final String property, final Class<?> type) {
if (CharSequence.class.isAssignableFrom(type)) {
return "Dummy value for " + property + '.';
}
@@ -271,7 +274,7 @@ public abstract strictfp class MetadataT
fail("Non writable property: " + accessor + '.' + property);
}
if (isWritable) {
- final Object newValue = valueFor(property, elementType);
+ final Object newValue = sampleValueFor(property, elementType);
final Object oldValue = accessor.set(i, instance, newValue, PropertyAccessor.RETURN_PREVIOUS);
assertEquals("PropertyAccessor.set(…) shall return the value previously returned by get(…).", value, oldValue);
value = accessor.get(i, instance);
@@ -346,5 +349,51 @@ public abstract strictfp class MetadataT
}
}
}
+ }
+
+ /**
+ * Verifies the {@link Dependencies} annotations. This method verifies that the annotation is applied on
+ * deprecated getter methods, that the referenced properties exist and the getter methods of referenced
+ * properties are not deprecated.
+ *
+ * @throws NoSuchMethodException if {@link PropertyAccessor} references a non-existent method (would be a bug).
+ *
+ * @since 0.8
+ */
+ @Test
+ public void testDependenciesAnnotation() throws NoSuchMethodException {
+ for (final Class<?> type : types) {
+ final Class<?> impl = standard.getImplementation(type);
+ if (impl != null) {
+ Map<String,String> names = null;
+ for (final Method method : impl.getDeclaredMethods()) {
+ final Dependencies dep = method.getAnnotation(Dependencies.class);
+ if (dep != null) {
+ final String name = method.getName();
+ if (names == null) {
+ names = standard.asNameMap(type, KeyNamePolicy.JAVABEANS_PROPERTY, KeyNamePolicy.METHOD_NAME);
+ }
+ /*
+ * Currently, @Dependencies is applied only on deprecated getter methods.
+ * However this policy may change in future Apache SIS versions.
+ */
+ assertTrue(name, name.startsWith("get"));
+ assertTrue(name, method.isAnnotationPresent(Deprecated.class));
+ /*
+ * All dependencies shall be non-deprecated methods. Combined with above
+ * restriction about @Dependencies applied only on deprected methods, this
+ * ensure that there is no cycle.
+ */
+ for (final String ref : dep.value()) {
+ // Verify that the dependency is a property name.
+ assertEquals(name, names.get(ref), ref);
+
+ // Verify that the referenced method is non-deprecated.
+ assertFalse(name, impl.getMethod(names.get(ref)).isAnnotationPresent(Deprecated.class));
+ }
+ }
+ }
+ }
+ }
}
}
Modified: sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java
URL: http://svn.apache.org/viewvc/sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java?rev=1796285&r1=1796284&r2=1796285&view=diff
==============================================================================
--- sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java [UTF-8] (original)
+++ sis/trunk/core/sis-metadata/src/test/java/org/apache/sis/metadata/sql/MetadataWriterTest.java [UTF-8] Fri May 26 13:31:31 2017
@@ -16,6 +16,7 @@
*/
package org.apache.sis.metadata.sql;
+import java.util.Collections;
import javax.sql.DataSource;
import org.postgresql.ds.PGSimpleDataSource;
import org.opengis.metadata.citation.Citation;
@@ -23,8 +24,10 @@ import org.opengis.metadata.citation.Pre
import org.opengis.metadata.citation.OnLineFunction;
import org.opengis.metadata.citation.OnlineResource;
import org.opengis.metadata.citation.Role;
+import org.opengis.metadata.citation.Telephone;
import org.apache.sis.internal.metadata.sql.TestDatabase;
import org.apache.sis.metadata.iso.citation.HardCodedCitations;
+import org.apache.sis.metadata.iso.citation.DefaultTelephone;
import org.apache.sis.metadata.MetadataStandard;
import org.apache.sis.test.TestUtilities;
import org.apache.sis.test.TestCase;
@@ -69,6 +72,7 @@ public final strictfp class MetadataWrit
write();
search();
read();
+ readWriteDeprecated();
source.close();
} finally {
TestDatabase.drop(ds);
@@ -92,6 +96,7 @@ public final strictfp class MetadataWrit
write();
search();
read();
+ readWriteDeprecated();
} finally {
source.close();
}
@@ -180,4 +185,28 @@ public final strictfp class MetadataWrit
assertEquals("EPSG", source.proxy (c));
assertEquals("EPSG", source.search(c));
}
+
+ /**
+ * Read and write a metadata object containing deprecated properties.
+ * The metadata tested by this method is:
+ *
+ * {@preformat text
+ * Telephone
+ * ├─Number………………… 01.02.03.04
+ * └─Number type…… Voice
+ * }
+ *
+ * The metadata should be stored in columns named {@code "number"} and {@code "numberType"} even if we
+ * constructed the metadata using the deprecated {@code "voice"} property. Conversely, at reading time
+ * the deprecated {@code "voice"} property should be converted in reading of non-deprecated properties.
+ */
+ @SuppressWarnings("deprecation")
+ private void readWriteDeprecated() throws MetadataStoreException {
+ final DefaultTelephone tel = new DefaultTelephone();
+ tel.setVoices(Collections.singleton("01.02.03.04"));
+ assertEquals("01.02.03.04", source.add(tel));
+
+ final Telephone check = source.lookup(Telephone.class, "01.02.03.04");
+ assertEquals("01.02.03.04", TestUtilities.getSingleton(check.getVoices()));
+ }
}