This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 99646bbeb716490485d6541f732a460288dedf63
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Wed Sep 14 15:18:30 2022 +0200

    Remove reference to source `Resource` in metadata of derived resource.
    This is a partial revert of f2f389fa68f4112a35733d85182b06951e0de3ca.
---
 .../sis/internal/storage/MetadataBuilder.java      |  46 +++---
 .../sis/internal/storage/ResourceLineage.java      | 184 +++++++--------------
 .../sis/internal/storage/StoreUtilities.java       |  26 ---
 .../storage/aggregate/AggregatedResource.java      |   7 -
 .../aggregate/ConcatenatedGridResource.java        |  20 ---
 .../storage/aggregate/CoverageAggregator.java      |  22 +--
 .../internal/storage/aggregate/GroupAggregate.java |  19 ---
 .../apache/sis/internal/storage/folder/Store.java  |   1 -
 .../org/apache/sis/storage/CoverageSubset.java     |   2 +-
 .../java/org/apache/sis/storage/FeatureSubset.java |   2 +-
 .../org/apache/sis/storage/CoverageQueryTest.java  |   8 +-
 .../org/apache/sis/storage/FeatureQueryTest.java   |   6 -
 12 files changed, 92 insertions(+), 251 deletions(-)

diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
index e6fbad0cd9..7b2e0d2c55 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java
@@ -73,7 +73,6 @@ import org.apache.sis.metadata.iso.maintenance.*;
 import org.apache.sis.metadata.iso.spatial.*;
 import org.apache.sis.metadata.sql.MetadataStoreException;
 import org.apache.sis.metadata.sql.MetadataSource;
-import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.AbstractResource;
 import org.apache.sis.storage.AbstractFeatureSet;
 import org.apache.sis.storage.AbstractGridCoverageResource;
@@ -1199,7 +1198,7 @@ public class MetadataBuilder {
      * This operation does nothing if the title is already defined and the 
given
      * title is already used as an identifier (this policy is a complement of 
the
      * {@link #addTitleOrIdentifier(String, Scope)} behavior).
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/identificationInfo/citation/title} if not yet 
used</li>
@@ -1980,7 +1979,7 @@ parse:      for (int i = 0; i < length;) {
 
     /**
      * Adds descriptions for the given feature.
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/featureTypes/featureTypeName}</li>
@@ -2009,7 +2008,7 @@ parse:      for (int i = 0; i < length;) {
 
     /**
      * Adds descriptions for a feature of the given name.
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/featureTypes/featureTypeName}</li>
@@ -2187,7 +2186,7 @@ parse:      for (int i = 0; i < length;) {
 
     /**
      * Sets whether parameters for transformation, control/check point(s) or 
orientation parameters are available.
-     * Storage location are:
+     * Storage locations are:
      *
      * <ul>
      *   <li>If georeferenceable:<ul>
@@ -2242,7 +2241,7 @@ parse:      for (int i = 0; i < length;) {
      * Adds <cite>check points</cite> (if georectified) or <cite>ground 
control points</cite> (if georeferenceable).
      * Ground control points (GCP) are large marked targets on the ground. GCP 
should not be used for storing the
      * localization grid (e.g. "model tie points" in a GeoTIFF file).
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code 
metadata/spatialRepresentationInfo/checkPoint/geographicCoordinates} if 
georectified</li>
@@ -2607,7 +2606,7 @@ parse:      for (int i = 0; i < length;) {
     /**
      * Sets the scale factor and offset which have been applied to the cell 
value.
      * The transfer function type is declared {@linkplain 
TransferFunctionType#LINEAR linear}
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/contentInfo/attributeGroup/attribute/scale}</li>
@@ -2895,32 +2894,35 @@ parse:      for (int i = 0; i < length;) {
     }
 
     /**
-     * Adds metadata about the sources of a resource.
-     * Storage location is:
+     * Adds a source described by the given metadata.
+     * Storage locations are:
      *
      * <ul>
-     *   <li>{@code metadata/resourceLineage/source}</li>
+     *   <li>{@code metadata/resourceLineage/source/description}</li>
+     *   <li>{@code metadata/resourceLineage/source/citation}</li>
+     *   <li>{@code metadata/resourceLineage/source/scope/level}</li>
+     *   <li>{@code metadata/resourceLineage/source/scope/extent}</li>
+     *   <li>{@code metadata/resourceLineage/source/sourceReferenceSystem}</li>
+     *   <li>{@code 
metadata/resourceLineage/source/sourceSpatialResolution}</li>
      * </ul>
      *
-     * @param  sources  the sources of the resource for which to describe the 
lineage.
-     * @throws DataStoreException if an error occurred while fetching metadata 
from a resource.
+     * @param  source  metadata about a source of the resource for which to 
describe the lineage.
      *
      * @see #addLineage(CharSequence)
      * @see #addProcessDescription(CharSequence)
      */
-    public final void addSources(final Resource... sources) throws 
DataStoreException {
-        if (sources != null && sources.length != 0) {
-            final ResourceLineage[] wrappers  = new 
ResourceLineage[sources.length];
-            for (int i=0; i<wrappers.length; i++) {
-                wrappers[i] = new ResourceLineage(sources[i]);
+    public final void addSource(final Metadata source) {
+        if (source != null) {
+            final ResourceLineage r = new ResourceLineage(source);
+            if (!r.isEmpty()) {
+                addIfNotPresent(lineage().getSources(), r.build());
             }
-            lineage().getSources().addAll(Arrays.asList(wrappers));
         }
     }
 
     /**
      * Adds information about a source of data used for producing the resource.
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/resourceLineage/source/description}</li>
@@ -2936,7 +2938,7 @@ parse:      for (int i = 0; i < length;) {
      * @param  level        hierarchical level of the source (e.g. model), or 
{@code null} if unspecified.
      * @param  feature      more detailed name for {@code level}, or {@code 
null} if none.
      *
-     * @see #addSources(Resource...)
+     * @see #addSource(Metadata)
      * @see #addProcessing(CharSequence, String)
      * @see #addProcessDescription(CharSequence)
      */
@@ -2958,7 +2960,7 @@ parse:      for (int i = 0; i < length;) {
 
     /**
      * Adds information about a source of data used for producing the resource.
-     * Storage location is:
+     * Storage locations are:
      *
      * <ul>
      *   <li>{@code metadata/resourceLineage/source/scope/level}</li>
@@ -2978,7 +2980,7 @@ parse:      for (int i = 0; i < length;) {
      * @param  level     hierarchical level of the source (e.g. feature). 
Should not be null.
      * @param  features  names of dataset, features or attributes used in the 
source.
      *
-     * @see #addSources(Resource...)
+     * @see #addSource(Metadata)
      */
     public final void addSource(final Metadata metadata, final ScopeCode 
level, final CharSequence... features) {
         if (metadata != null) {
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceLineage.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceLineage.java
index 6e81c658e0..a5e3aba17e 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceLineage.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/ResourceLineage.java
@@ -20,20 +20,16 @@ import java.util.Collection;
 import org.opengis.metadata.Metadata;
 import org.opengis.metadata.MetadataScope;
 import org.opengis.metadata.extent.Extent;
-import org.opengis.metadata.lineage.Source;
-import org.opengis.metadata.maintenance.Scope;
-import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.citation.Citation;
+import org.opengis.metadata.maintenance.ScopeCode;
 import org.opengis.metadata.identification.Resolution;
 import org.opengis.metadata.identification.Identification;
 import org.opengis.referencing.ReferenceSystem;
 import org.opengis.util.InternationalString;
 import org.apache.sis.internal.util.CollectionsExt;
-import org.apache.sis.metadata.ModifiableMetadata;
 import org.apache.sis.metadata.iso.extent.Extents;
+import org.apache.sis.metadata.iso.lineage.DefaultSource;
 import org.apache.sis.metadata.iso.maintenance.DefaultScope;
-import org.apache.sis.storage.DataStoreException;
-import org.apache.sis.storage.Resource;
 
 import static org.apache.sis.internal.util.CollectionsExt.nonNull;
 
@@ -47,95 +43,77 @@ import static 
org.apache.sis.internal.util.CollectionsExt.nonNull;
  * @since   1.3
  * @module
  */
-final class ResourceLineage implements Source {
+final class ResourceLineage {
     /**
-     * The source of the derived resource described by the lineage.
+     * Description of the level of the source data, or {@code null} if none.
+     * Current implementation uses the first non-null title of a citation.
      */
-    public final Resource source;
+    private InternationalString description;
 
     /**
-     * Metadata of the source, or {@code null} if none.
-     * All properties returned by this class are inferred from those metadata.
+     * Recommended reference to be used for the source data, or {@code null}.
+     * Current implementation uses the first citation provided by {@link 
Metadata#getIdentificationInfo()}.
      */
-    private final Metadata metadata;
+    private Citation sourceCitation;
 
     /**
-     * The scope, computed when first requested.
-     *
-     * @see #getScope()
+     * The type and extent of the source, or {@code null} if none.
+     * Current implementation uses the resource scope declared in source 
metadata,
+     * together with the source extents.
      */
-    private transient Scope scope;
+    private DefaultScope scope;
 
     /**
-     * Whether {@link #scope} has been initialized. The result may still be 
null.
+     * She spatial reference system used by the source data, or {@code null} 
if none.
+     * Current implementation uses the first reference system declared by 
metadata.
      */
-    private boolean scopeInitialized;
+    private ReferenceSystem referenceSystem;
 
     /**
-     * Creates a new source wrapping the given resource.
-     *
-     * @param  source  the source of the derived resource described by the 
resource lineage.
-     * @throws DataStoreException if an error occurred while fetching metadata 
from the source.
+     * Spatial resolution expressed as a scale factor, an angle or a level of 
detail.
+     * Current implementation uses the first resolution found in 
identification information.
      */
-    ResourceLineage(final Resource source) throws DataStoreException {
-        this.source = source;
-        metadata = source.getMetadata();
-    }
+    private Resolution resolution;
 
     /**
-     * Returns a description of the level of the source data.
-     * Default implementation returns the title of the {@linkplain 
#getSourceCitation() source citation}.
-     *
-     * @return description of the level of the source data, or {@code null} if 
none.
+     * Returns {@code false} if this object has at least one non-null value.
      */
-    @Override
-    public InternationalString getDescription() {
-        final Citation citation = getSourceCitation();
-        return (citation != null) ? citation.getTitle() : null;
+    final boolean isEmpty() {
+        return description == null && sourceCitation == null && scope == null
+                && referenceSystem == null && resolution == null;
     }
 
     /**
-     * Returns the recommended reference to be used for the source data.
-     * Default implementation returns the first citation having a non-null 
title
-     * among the citations provided by {@link 
Metadata#getIdentificationInfo()}.
+     * Collects information about a source of the derived resource for which 
to provide lineage.
      *
-     * @return recommended reference to be used for the source data, or {@code 
null}.
+     * @param  source  metadata of a source of the derived resource for which 
to provide lineage.
      */
-    @Override
-    public Citation getSourceCitation() {
-        if (metadata != null) {
-            for (final Identification info : 
nonNull(metadata.getIdentificationInfo())) {
-                final Citation citation = info.getCitation();
-                if (citation != null) {
-                    if (citation.getTitle() != null) {
-                        return citation;
+    ResourceLineage(final Metadata source) {
+        referenceSystem = 
CollectionsExt.first(source.getReferenceSystemInfo());
+        for (final Identification info : 
nonNull(source.getIdentificationInfo())) {
+            final Citation citation = info.getCitation();
+            if (citation != null) {
+                if (sourceCitation == null) {
+                    sourceCitation = citation;
+                }
+                if (description == null) {
+                    description = citation.getTitle();
+                }
+            }
+            if (resolution == null) {
+                for (final Resolution candidate : 
nonNull(info.getSpatialResolutions())) {
+                    if (candidate != null) {
+                        resolution = candidate;
                     }
                 }
             }
         }
-        return null;
-    }
-
-    /**
-     * Returns the type and extent of the source. Default implementation 
returns the resource scope
-     * declared in source metadata, together with the {@linkplain 
#getSourceExtents() source extents}.
-     *
-     * @return type and extent of the source, or {@code null} if none.
-     */
-    @Override
-    public synchronized Scope getScope() {
-        if (!scopeInitialized) {
-            scopeInitialized = true;
-            final ScopeCode level = getScopeLevel();
-            final Collection<? extends Extent> extents = getSourceExtents();
-            if (level != null || !extents.isEmpty()) {
-                final DefaultScope scope = new DefaultScope(level);
-                scope.setExtents(extents);
-                scope.transitionTo(ModifiableMetadata.State.FINAL);
-                this.scope = scope;
-            }
+        final ScopeCode level = getScopeLevel(source);
+        final Collection<? extends Extent> extents = 
Extents.fromIdentificationInfo(source);
+        if (level != null || !extents.isEmpty()) {
+            scope = new DefaultScope(level);
+            scope.setExtents(extents);
         }
-        return scope;
     }
 
     /**
@@ -143,18 +121,16 @@ final class ResourceLineage implements Source {
      *
      * @return scope level (coverage, feature, …), or {@code null} if none.
      */
-    private ScopeCode getScopeLevel() {
+    private static ScopeCode getScopeLevel(final Metadata source) {
         ScopeCode level = null;
-        if (metadata != null) {
-            for (final MetadataScope ms : 
nonNull(metadata.getMetadataScopes())) {
-                final ScopeCode c = ms.getResourceScope();
-                if (c != null) {
-                    if (level == null) {
-                        level = c;
-                    } else if (!level.equals(c)) {
-                        level = null;
-                        break;
-                    }
+        for (final MetadataScope ms : nonNull(source.getMetadataScopes())) {
+            final ScopeCode c = ms.getResourceScope();
+            if (c != null) {
+                if (level == null) {
+                    level = c;
+                } else if (!level.equals(c)) {
+                    level = null;
+                    break;
                 }
             }
         }
@@ -162,47 +138,15 @@ final class ResourceLineage implements Source {
     }
 
     /**
-     * Information about the spatial, vertical and temporal extent of the 
source data.
-     * Default implementation returns all extents declared in {@link 
Metadata#getIdentificationInfo()}.
-     *
-     * @return information about the extent of the source data, or an empty 
collection if none.
-     *
-     * @deprecated As of ISO 19115:2014, moved to {@link Scope#getExtents()}.
-     */
-    @Override
-    @Deprecated
-    public Collection<? extends Extent> getSourceExtents() {
-        return Extents.fromIdentificationInfo(metadata);
-    }
-
-    /**
-     * Returns the spatial reference system used by the source data.
-     * Default implementation returns the first reference system declared by 
metadata.
-     *
-     * @return spatial reference system used by the source data, or {@code 
null}.
+     * Creates an ISO 19115 metadata object from the information collected in 
this class.
      */
-    @Override
-    public ReferenceSystem getSourceReferenceSystem() {
-        return (metadata != null) ? 
CollectionsExt.first(metadata.getReferenceSystemInfo()) : null;
-    }
-
-    /**
-     * Spatial resolution expressed as a scale factor, an angle or a level of 
detail.
-     * Default implementation returns the first resolution found in 
identification information.
-     *
-     * @return spatial resolution, or {@code null} if none.
-     */
-    @Override
-    public Resolution getSourceSpatialResolution() {
-        if (metadata != null) {
-            for (final Identification info : 
nonNull(metadata.getIdentificationInfo())) {
-                for (final Resolution candidate : 
nonNull(info.getSpatialResolutions())) {
-                    if (candidate != null) {
-                        return candidate;
-                    }
-                }
-            }
-        }
-        return null;
+    final DefaultSource build() {
+        final DefaultSource source = new DefaultSource();
+        source.setDescription(description);
+        source.setSourceCitation(sourceCitation);
+        source.setScope(scope);
+        source.setSourceReferenceSystem(referenceSystem);
+        source.setSourceSpatialResolution(resolution);
+        return source;
     }
 }
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java
index e9b9586c91..eaeb355bab 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/StoreUtilities.java
@@ -18,8 +18,6 @@ package org.apache.sis.internal.storage;
 
 import java.util.Set;
 import java.util.EnumSet;
-import java.util.List;
-import java.util.ArrayList;
 import java.util.Optional;
 import java.util.stream.Stream;
 import java.util.logging.Filter;
@@ -36,8 +34,6 @@ import org.opengis.metadata.extent.GeographicExtent;
 import org.opengis.metadata.extent.GeographicBoundingBox;
 import org.opengis.metadata.identification.Identification;
 import org.opengis.metadata.identification.DataIdentification;
-import org.opengis.metadata.lineage.Lineage;
-import org.opengis.metadata.lineage.Source;
 import org.apache.sis.util.Static;
 import org.apache.sis.storage.FeatureSet;
 import org.apache.sis.storage.Resource;
@@ -56,8 +52,6 @@ import org.apache.sis.util.resources.Errors;
 import org.apache.sis.util.CharSequences;
 import org.apache.sis.util.Classes;
 
-import static org.apache.sis.internal.util.CollectionsExt.nonNull;
-
 // Branch-dependent imports
 import org.opengis.feature.Feature;
 
@@ -214,26 +208,6 @@ public final class StoreUtilities extends Static {
         return bounds;
     }
 
-    /**
-     * Fetches all resources that are the sources of a resource described by 
given metadata.
-     *
-     * @param  metadata  metadata of the resource for which to get the 
sources, or {@code null} if none.
-     * @return sources found in given metadata.
-     */
-    public static List<Resource> getSources(final Metadata metadata) {
-        final List<Resource> sources = new ArrayList<>();
-        if (metadata != null) {
-            for (final Lineage lineage : 
nonNull(metadata.getResourceLineages())) {
-                for (final Source candidate : nonNull(lineage.getSources())) {
-                    if (candidate instanceof ResourceLineage) {
-                        sources.add(((ResourceLineage) candidate).source);
-                    }
-                }
-            }
-        }
-        return sources;
-    }
-
     /**
      * Returns the most specific interface implemented by the given class.
      * For indicative purpose only, as this method has arbitrary behavior if 
more than one leaf is found.
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/AggregatedResource.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/AggregatedResource.java
index 315d96d246..2537d356b6 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/AggregatedResource.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/AggregatedResource.java
@@ -16,8 +16,6 @@
  */
 package org.apache.sis.internal.storage.aggregate;
 
-import org.apache.sis.storage.Resource;
-
 
 /**
  * The result of an aggregation computed by {@link CoverageAggregator}.
@@ -34,9 +32,4 @@ interface AggregatedResource {
      * @param  name  new name of the resource.
      */
     void setName(String name);
-
-    /**
-     * Specifies the resource to declare in lineage metadata as the source of 
this resource.
-     */
-    void setSourceMetadata(Resource source);
 }
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/ConcatenatedGridResource.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/ConcatenatedGridResource.java
index 9bf705d312..0b5f48fa67 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/ConcatenatedGridResource.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/ConcatenatedGridResource.java
@@ -29,7 +29,6 @@ import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.coverage.grid.GridRoundingMode;
 import org.apache.sis.geometry.ImmutableEnvelope;
-import org.apache.sis.storage.Resource;
 import org.apache.sis.storage.AbstractGridCoverageResource;
 import org.apache.sis.storage.DataStoreException;
 import org.apache.sis.storage.GridCoverageResource;
@@ -130,12 +129,6 @@ final class ConcatenatedGridResource extends 
AbstractGridCoverageResource implem
      */
     private double[][] resolutions;
 
-    /**
-     * An optional resource to declare as the source of this aggregate in 
lineage metadata.
-     * This is reset to {@code null} when no longer needed.
-     */
-    private Resource sourceMetadata;
-
     /**
      * Creates a new aggregated resource.
      *
@@ -177,15 +170,6 @@ final class ConcatenatedGridResource extends 
AbstractGridCoverageResource implem
         this.name = name;
     }
 
-    /**
-     * Specifies the resource to declare in lineage metadata as the source of 
this resource.
-     * This information is used for metadata.
-     */
-    @Override
-    public void setSourceMetadata(final Resource source) {
-        sourceMetadata = source;
-    }
-
     /**
      * Creates when first requested the metadata about this resource.
      */
@@ -194,10 +178,6 @@ final class ConcatenatedGridResource extends 
AbstractGridCoverageResource implem
         final MetadataBuilder builder = new MetadataBuilder();
         builder.addTitle(name);
         builder.addDefaultMetadata(this, listeners);
-        if (sourceMetadata != null) {
-            builder.addSources(sourceMetadata);
-            sourceMetadata = null;
-        }
         return builder.build();
     }
 
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/CoverageAggregator.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/CoverageAggregator.java
index b6e5cbfca9..b16486ddbe 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/CoverageAggregator.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/CoverageAggregator.java
@@ -58,11 +58,6 @@ public final class CoverageAggregator extends 
Group<GroupBySample> {
      */
     private final Map<Set<Resource>, Queue<Aggregate>> aggregates;
 
-    /**
-     * An optional resource to declare as the source of this aggregate in 
lineage metadata.
-     */
-    private Resource sourceMetadata;
-
     /**
      * Creates an initially empty aggregator.
      *
@@ -187,17 +182,6 @@ public final class CoverageAggregator extends 
Group<GroupBySample> {
         return Optional.empty();
     }
 
-    /**
-     * Sets the resource to declare as the source in lineage metadata.
-     * Note that it will cause the aggregation returned by {@link #build()}
-     * to hold a strong reference to the resource specified to this method.
-     *
-     * @param  source  the resource to declare as the source in lineage 
metadata.
-     */
-    public void setSourceMetadata(final Resource source) {
-        sourceMetadata = source;
-    }
-
     /**
      * Builds a resource which is the aggregation or concatenation of all 
components added to this aggregator.
      * The returned resource will be an instance of {@link 
GridCoverageResource} if possible,
@@ -212,10 +196,6 @@ public final class CoverageAggregator extends 
Group<GroupBySample> {
     public Resource build() {
         final GroupAggregate aggregate = prepareAggregate(listeners);
         aggregate.fillWithChildAggregates(this, 
GroupBySample::createComponents);
-        final Resource result = aggregate.simplify(this);
-        if (result instanceof AggregatedResource) {
-            ((AggregatedResource) result).setSourceMetadata(sourceMetadata);
-        }
-        return result;
+        return aggregate.simplify(this);
     }
 }
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/GroupAggregate.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/GroupAggregate.java
index f28902ecf8..ace63ef45c 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/GroupAggregate.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/aggregate/GroupAggregate.java
@@ -98,12 +98,6 @@ final class GroupAggregate extends AbstractResource 
implements Aggregate, Aggreg
      */
     List<SampleDimension> sampleDimensions;
 
-    /**
-     * An optional resource to declare as the source of this aggregate in 
lineage metadata.
-     * This is reset to {@code null} when no longer needed.
-     */
-    private Resource sourceMetadata;
-
     /**
      * Creates a new aggregate with the specified number of components.
      * One of the {@code fill(…)} methods must be invoked after this 
constructor.
@@ -237,15 +231,6 @@ final class GroupAggregate extends AbstractResource 
implements Aggregate, Aggreg
         this.name = name;
     }
 
-    /**
-     * Specifies the resource to declare in lineage metadata as the source of 
this resource.
-     * This information is used for metadata.
-     */
-    @Override
-    public void setSourceMetadata(final Resource source) {
-        sourceMetadata = source;
-    }
-
     /**
      * Creates when first requested the metadata about this aggregate.
      * The metadata contains the title for this aggregation, the sample 
dimensions
@@ -265,10 +250,6 @@ final class GroupAggregate extends AbstractResource 
implements Aggregate, Aggreg
                 builder.addNewBand(band);
             }
         }
-        if (sourceMetadata != null) {
-            builder.addSources(sourceMetadata);
-            sourceMetadata = null;
-        }
         return builder.build();
     }
 
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
index 540bd1b6bf..364a1e4dda 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/folder/Store.java
@@ -417,7 +417,6 @@ class Store extends DataStore implements StoreResource, 
UnstructuredAggregate, D
         if (structuredView == null) {
             final CoverageAggregator aggregator = new 
CoverageAggregator(listeners);
             aggregator.addComponents(this);
-            aggregator.setSourceMetadata(this);
             structuredView = aggregator.build();
         }
         return structuredView;
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
index b8d90c82c6..dab4082bcd 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/CoverageSubset.java
@@ -78,7 +78,7 @@ final class CoverageSubset extends 
AbstractGridCoverageResource {
         builder.addDefaultMetadata(this, listeners);
         
builder.addLineage(Resources.formatInternational(Resources.Keys.UnfilteredData));
         
builder.addProcessDescription(Resources.formatInternational(Resources.Keys.SubsetQuery_1,
 StoreUtilities.getLabel(source)));
-        builder.addSources(source);
+        builder.addSource(source.getMetadata());
         return builder.build();
     }
 
diff --git 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
index 4ffd33face..cbd8acfc28 100644
--- 
a/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
+++ 
b/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSubset.java
@@ -81,7 +81,7 @@ final class FeatureSubset extends AbstractFeatureSet {
         builder.addDefaultMetadata(this, listeners);
         
builder.addLineage(Resources.formatInternational(Resources.Keys.UnfilteredData));
         
builder.addProcessDescription(Resources.formatInternational(Resources.Keys.SubsetQuery_1,
 StoreUtilities.getLabel(source)));
-        builder.addSources(source);
+        builder.addSource(source.getMetadata());
         return builder.build();
     }
 
diff --git 
a/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
 
b/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
index ebe47db3cc..305908c2a8 100644
--- 
a/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
+++ 
b/storage/sis-storage/src/test/java/org/apache/sis/storage/CoverageQueryTest.java
@@ -23,20 +23,18 @@ import org.apache.sis.coverage.grid.GridCoverage;
 import org.apache.sis.coverage.grid.GridExtent;
 import org.apache.sis.coverage.grid.GridGeometry;
 import org.apache.sis.internal.referencing.j2d.AffineTransform2D;
-import org.apache.sis.internal.storage.StoreUtilities;
 import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.apache.sis.test.TestUtilities.getSingleton;
 
 
 /**
  * Tests {@link CoverageQuery} and (indirectly) {@link CoverageSubset}.
  *
  * @author  Johann Sorel (Geomatys)
- * @version 1.3
+ * @version 1.1
  * @since   1.1
  */
 public final strictfp class CoverageQueryTest extends TestCase {
@@ -180,9 +178,5 @@ public final strictfp class CoverageQueryTest extends 
TestCase {
             request = createSubGrid(-4 + expansion);
         }
         assertEquals(request, coverage.getGridGeometry());
-        /*
-         * Verify lineage metadata. They are stored in specialized sub-type of 
`Source`.
-         */
-        assertSame(resource, 
getSingleton(StoreUtilities.getSources(subset.getMetadata())));
     }
 }
diff --git 
a/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
 
b/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
index 3e8313826a..5013f02848 100644
--- 
a/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
+++ 
b/storage/sis-storage/src/test/java/org/apache/sis/storage/FeatureQueryTest.java
@@ -22,14 +22,12 @@ import java.util.Iterator;
 import java.util.stream.Collectors;
 import org.apache.sis.feature.builder.FeatureTypeBuilder;
 import org.apache.sis.internal.storage.MemoryFeatureSet;
-import org.apache.sis.internal.storage.StoreUtilities;
 import org.apache.sis.filter.DefaultFilterFactory;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
 
 import static org.junit.Assert.*;
-import static org.apache.sis.test.TestUtilities.getSingleton;
 
 // Branch-dependent imports
 import org.opengis.feature.Feature;
@@ -143,10 +141,6 @@ public final strictfp class FeatureQueryTest extends 
TestCase {
                                  + "Actual:%n%s%n", i, expected, actual));
             }
         }
-        /*
-         * Verify lineage metadata. They are stored in specialized sub-type of 
`Source`.
-         */
-        assertSame(featureSet, 
getSingleton(StoreUtilities.getSources(fs.getMetadata())));
     }
 
     /**

Reply via email to