Modified: sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-netcdf/src/main/java/org/apache/sis/storage/netcdf/NetcdfStore.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -26,6 +26,7 @@ import org.apache.sis.storage.StorageCon import org.apache.sis.internal.netcdf.Decoder; import org.apache.sis.metadata.ModifiableMetadata; import org.apache.sis.setup.OptionKey; +import org.apache.sis.storage.Resource; import org.apache.sis.util.CharSequences; import org.apache.sis.util.Version; import ucar.nc2.constants.CDM; @@ -117,6 +118,17 @@ public class NetcdfStore extends DataSto } /** + * This implementation does not provide any resource yet. + * + * @return currently {@code null} (will be implemented in future Apache SIS version). + * @throws DataStoreException if an error occurred while reading the data. + */ + @Override + public Resource getRootResource() throws DataStoreException { + return null; + } + + /** * Returns the version number of the Climate and Forecast (CF) conventions used in the NetCDF file. * The use of CF convention is mandated by the OGC 11-165r2 standard * (<cite>CF-netCDF3 Data Model Extension standard</cite>).
Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/FeatureCatalogBuilder.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -39,7 +39,7 @@ import org.opengis.feature.FeatureType; * @since 0.8 * @module */ -public class FeatureCatalogBuilder extends MetadataBuilder { +public final class FeatureCatalogBuilder extends MetadataBuilder { /** * The data store for which the metadata will be created, or {@code null} if unknown. * This is used for producing error message if an exception is thrown. Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/MetadataBuilder.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -52,8 +52,8 @@ import org.opengis.metadata.identificati import org.opengis.metadata.distribution.Format; import org.opengis.metadata.quality.Element; import org.opengis.geometry.DirectPosition; +import org.opengis.referencing.ReferenceSystem; import org.opengis.referencing.crs.VerticalCRS; -import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.opengis.referencing.operation.TransformException; import org.apache.sis.geometry.AbstractEnvelope; import org.apache.sis.metadata.iso.DefaultMetadata; @@ -123,7 +123,7 @@ import org.opengis.metadata.citation.Res * API of this class may change in any future SIS versions. * * @author Martin Desruisseaux (Geomatys) - * @author Rémi Marechal (Geomatys) + * @author Rémi Maréchal (Geomatys) * @version 0.8 * @since 0.8 * @module @@ -1611,7 +1611,7 @@ parse: for (int i = 0; i < length;) * * @param crs the coordinate reference system to add to the metadata, or {@code null} for no-operation. */ - public final void addReferenceSystem(final CoordinateReferenceSystem crs) { + public final void addReferenceSystem(final ReferenceSystem crs) { if (crs != null) { addIfNotPresent(metadata().getReferenceSystemInfo(), crs); } Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -149,6 +149,16 @@ public final class Resources extends Ind public static final short ProcessingExecutedOn_1 = 12; /** + * More than one resource have the “{1}” identifier in the “{0}” data store. + */ + public static final short ResourceIdentifierCollision_2 = 23; + + /** + * No resource found for the “{1}” identifier in the “{0}” data store. + */ + public static final short ResourceNotFound_2 = 24; + + /** * The “{1}” element must be declared before “{0}”. */ public static final short ShallBeDeclaredBefore_2 = 22; Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources.properties [ISO-8859-1] Tue Aug 8 12:43:28 2017 @@ -36,6 +36,8 @@ IllegalOutputTypeForWriter_2 = The InconsistentNameComponents_2 = Components of the \u201c{1}\u201d name are inconsistent with those of the name previously binded in \u201c{0}\u201d data store. MissingSchemeInURI_1 = Missing scheme in \u201c{0}\u201d URI. ProcessingExecutedOn_1 = Processing executed on {0}. +ResourceIdentifierCollision_2 = More than one resource have the \u201c{1}\u201d identifier in the \u201c{0}\u201d data store. +ResourceNotFound_2 = No resource found for the \u201c{1}\u201d identifier in the \u201c{0}\u201d data store. ShallBeDeclaredBefore_2 = The \u201c{1}\u201d element must be declared before \u201c{0}\u201d. StreamIsForwardOnly_1 = Can not move backward in the \u201c{0}\u201d stream. StreamIsReadOnce_1 = The \u201c{0}\u201d data store can be read only once. Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/Resources_fr.properties [ISO-8859-1] Tue Aug 8 12:43:28 2017 @@ -41,6 +41,8 @@ IllegalOutputTypeForWriter_2 = Le l InconsistentNameComponents_2 = Les \u00e9l\u00e9ments qui composent le nom \u00ab\u202f{1}\u202f\u00bb ne sont pas coh\u00e9rents avec ceux du nom qui avait \u00e9t\u00e9 pr\u00e9c\u00e9demment li\u00e9 dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. MissingSchemeInURI_1 = Il manque le sch\u00e9ma dans l\u2019URI \u00ab\u202f{0}\u202f\u00bb. ProcessingExecutedOn_1 = Traitement ex\u00e9cut\u00e9 sur {0}. +ResourceIdentifierCollision_2 = Plusieurs ressources utilisent l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. +ResourceNotFound_2 = Aucune ressource n\u2019a \u00e9t\u00e9 trouv\u00e9e pour l\u2019identifiant \u00ab\u202f{1}\u202f\u00bb dans les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb. ShallBeDeclaredBefore_2 = L\u2019\u00e9l\u00e9ment \u00ab\u202f{1}\u202f\u00bb doit \u00eatre d\u00e9clar\u00e9 avant \u00ab\u202f{0}\u202f\u00bb. StreamIsForwardOnly_1 = Ne peut pas reculer dans le flux de donn\u00e9es \u00ab\u202f{0}\u202f\u00bb. StreamIsReadOnce_1 = Les donn\u00e9es de \u00ab\u202f{0}\u202f\u00bb ne peuvent \u00eatre lues qu\u2019une seule fois. Copied: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java (from r1804404, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java?p2=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java&r1=1804404&r2=1804411&rev=1804411&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/FeatureAccess.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -23,9 +23,9 @@ import org.apache.sis.internal.storage.A import org.apache.sis.util.logging.WarningListeners; // Branch-dependent imports -import java.util.stream.Stream; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; +import org.apache.sis.internal.jdk8.Stream; /** Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/csv/Store.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -44,17 +44,16 @@ import org.apache.sis.internal.referenci import org.apache.sis.internal.util.UnmodifiableArrayList; import org.apache.sis.internal.storage.MetadataBuilder; import org.apache.sis.internal.storage.io.IOUtilities; -import org.apache.sis.internal.storage.FeatureStore; import org.apache.sis.internal.feature.Geometries; import org.apache.sis.internal.feature.MovingFeature; import org.apache.sis.internal.storage.Resources; import org.apache.sis.geometry.GeneralEnvelope; import org.apache.sis.metadata.iso.DefaultMetadata; import org.apache.sis.metadata.sql.MetadataStoreException; +import org.apache.sis.storage.DataStore; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreContentException; import org.apache.sis.storage.DataStoreReferencingException; -import org.apache.sis.storage.IllegalNameException; import org.apache.sis.storage.StorageConnector; import org.apache.sis.setup.OptionKey; import org.apache.sis.util.ArraysExt; @@ -67,6 +66,7 @@ import org.apache.sis.internal.jdk8.Inst import org.apache.sis.internal.jdk8.DateTimeException; import org.apache.sis.internal.jdk8.Stream; import org.apache.sis.internal.jdk8.StreamSupport; +import org.apache.sis.storage.Resource; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; import org.opengis.feature.PropertyType; @@ -82,7 +82,7 @@ import org.opengis.feature.AttributeType * @since 0.7 * @module */ -public final class Store extends FeatureStore { +public final class Store extends DataStore { /** * The character at the beginning of lines to ignore in the header. * Note that this is not part of OGC Moving Feature Specification. @@ -603,28 +603,13 @@ public final class Store extends Feature } /** - * Returns the feature type for the given name. The {@code name} argument should be the - * value specified at the following path (only one such value exists for a CSV data store): + * Returns the {@code FeatureSet} from which all features in this data store can be accessed. * - * <blockquote> - * {@link #getMetadata()} / - * {@link org.apache.sis.metadata.iso.DefaultMetadata#getContentInfo() contentInfo} / - * {@link org.apache.sis.metadata.iso.content.DefaultFeatureCatalogueDescription#getFeatureTypeInfo() featureTypes} / - * {@link org.apache.sis.metadata.iso.content.DefaultFeatureTypeInfo#getFeatureTypeName() featureTypeName} - * </blockquote> - * - * @param name the name of the feature type to get. - * @return the feature type of the given name (never {@code null}). - * @throws IllegalNameException if the given name was not found. - * - * @since 0.8 + * @return the starting point of all features in this data store. */ @Override - public FeatureType getFeatureType(String name) throws IllegalNameException { - if (featureType.getName().toString().equals(name)) { - return featureType; - } - throw new IllegalNameException(getLocale(), getDisplayName(), name); + public Resource getRootResource() { + return new FeatureAccess(this, listeners); } /** @@ -637,8 +622,7 @@ public final class Store extends Feature * @todo Needs to reset the position when doing another pass on the features. * @todo If sequential order, publish Feature as soon as identifier changed. */ - @Override - public synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException { + final synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException { /* * If the user asks for one feature instance per line, then we can return a FeatureIter instance directly. * Since each feature is fully constructed from a single line and each line are read atomically, we can Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/wkt/Store.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -17,8 +17,8 @@ package org.apache.sis.internal.storage.wkt; import java.util.List; -import java.util.ArrayList; import java.util.Arrays; +import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.LogRecord; import java.io.Reader; @@ -33,12 +33,13 @@ import org.apache.sis.internal.storage.R import org.apache.sis.internal.system.Loggers; import org.apache.sis.io.wkt.WKTFormat; import org.apache.sis.io.wkt.Warnings; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreContentException; import org.apache.sis.internal.referencing.DefinitionVerifier; -import org.apache.sis.metadata.iso.DefaultMetadata; +import org.apache.sis.internal.storage.MetadataBuilder; import org.apache.sis.util.resources.Errors; import org.apache.sis.util.CharSequences; @@ -171,7 +172,7 @@ final class Store extends DataStore { /** * Returns the metadata associated to the parsed objects, or {@code null} if none. * The current implementation retains only instances of {@link ReferenceSystem} - * and ignore other cases. + * and ignore other objects. * * @return the metadata associated to the parsed object, or {@code null} if none. * @throws DataStoreException if an error occurred during the parsing process. @@ -180,19 +181,28 @@ final class Store extends DataStore { public synchronized Metadata getMetadata() throws DataStoreException { if (metadata == null) { parse(); - DefaultMetadata md = null; + final MetadataBuilder builder = new MetadataBuilder(); + builder.addTitle(getDisplayName()); for (final Object object : objects) { if (object instanceof ReferenceSystem) { - if (md == null) md = new DefaultMetadata(); - md.getReferenceSystemInfo().add((ReferenceSystem) object); + builder.addReferenceSystem((ReferenceSystem) object); } } - metadata = md; + metadata = builder.build(true); } return metadata; } /** + * There is currently no resource associated to Well Known Text format since we parse only CRS. + * Future versions may return resources if we parse also geometries. + */ + @Override + public Resource getRootResource() throws DataStoreException { + return null; + } + + /** * Closes this data store and releases any underlying resources. * * @throws DataStoreException if an error occurred while closing this data store. Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/internal/storage/xml/Store.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -30,6 +30,7 @@ import org.opengis.util.FactoryException import org.opengis.referencing.ReferenceSystem; import org.opengis.referencing.crs.CoordinateReferenceSystem; import org.apache.sis.xml.XML; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; @@ -37,10 +38,9 @@ import org.apache.sis.metadata.iso.Defau import org.apache.sis.util.logging.WarningListener; import org.apache.sis.util.resources.Errors; import org.apache.sis.internal.system.Loggers; +import org.apache.sis.internal.storage.MetadataBuilder; import org.apache.sis.internal.referencing.DefinitionVerifier; -import static java.util.Collections.singleton; - /** * A data store which creates data objects from a XML file. @@ -199,15 +199,25 @@ final class Store extends DataStore { if (object instanceof Metadata) { metadata = (Metadata) object; } else if (object instanceof ReferenceSystem) { - final DefaultMetadata md = new DefaultMetadata(); - md.setReferenceSystemInfo(singleton((ReferenceSystem) object)); - metadata = md; + final MetadataBuilder builder = new MetadataBuilder(); + builder.addReferenceSystem((ReferenceSystem) object); + builder.addTitle(getDisplayName()); + metadata = builder.build(true); } } return metadata; } /** + * Current implementation does not provide any resource since it is only about metadata. + * Futures versions may return resources if Apache SIS provides a wider GML support. + */ + @Override + public Resource getRootResource() throws DataStoreException { + return null; + } + + /** * Closes this data store and releases any underlying resources. * * @throws DataStoreException if an error occurred while closing this data store. Modified: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/DataStore.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -17,12 +17,17 @@ package org.apache.sis.storage; import java.util.Locale; +import java.util.Map; +import java.util.IdentityHashMap; import java.util.NoSuchElementException; import org.opengis.metadata.Metadata; +import org.opengis.metadata.identification.Identification; import org.apache.sis.util.Localized; import org.apache.sis.util.ArgumentChecks; import org.apache.sis.util.logging.WarningListener; import org.apache.sis.util.logging.WarningListeners; +import org.apache.sis.internal.storage.Resources; +import org.apache.sis.internal.util.Citations; /** @@ -164,16 +169,107 @@ public abstract class DataStore implemen } /** - * Returns information about the dataset as a whole. The returned metadata object, if any, can contain - * information such as the spatiotemporal extent of the dataset, contact information about the creator - * or distributor, data quality, update frequency, usage constraints and more. + * Returns information about the data store as a whole. The returned metadata object can contain + * information such as the spatiotemporal extent of all contained {@linkplain Resource resources}, + * contact information about the creator or distributor, data quality, update frequency, usage constraints, + * file format and more. * - * @return information about the dataset, or {@code null} if none. + * @return information about resources in the data store, or {@code null} if none. * @throws DataStoreException if an error occurred while reading the data. + * + * @see Resource#getMetadata() */ public abstract Metadata getMetadata() throws DataStoreException; /** + * Returns the starting point from which all resources in this data store can be accessed. + * A resource can be for example a air temperature map or the set of all bridges in a city. + * If this data store contains only one resource, then that resource is returned directly. + * Otherwise if this data store contains more than one resource, then this method returns + * an {@link Aggregate} from which other resources can be accessed. + * + * @return the starting point of all resources in this data store, + * or {@code null} if this data store does not contain any resources. + * @throws DataStoreException if an error occurred while reading the data. + */ + public abstract Resource getRootResource() throws DataStoreException; + + /** + * Searches for a resource identified by the given identifier. + * The given identifier should match the following metadata element of a resource: + * + * <blockquote>{@link Resource#getMetadata() metadata} / + * {@link org.apache.sis.metadata.iso.DefaultMetadata#getIdentificationInfo() identificationInfo} / + * {@link org.apache.sis.metadata.iso.identification.AbstractIdentification#getCitation() citation} / + * {@link org.apache.sis.metadata.iso.citation.DefaultCitation#getIdentifiers() identifier}</blockquote> + * + * Implementation may also accept aliases for convenience. For example if the full name of a resource + * is {@code "foo:bar"}, then this method may accept {@code "bar"} as a synonymous of {@code "foo:bar"} + * provided that it does not introduce ambiguity. + * + * <p>The default implementation verifies the {@linkplain #getRootResource() root resource}, then iterates over + * components of {@link Aggregate}s. If a match is found without ambiguity, the associated resource is returned. + * Otherwise an exception is thrown. Subclasses are encouraged to override this method with a more efficient + * implementation.</p> + * + * @param identifier identifier of the resource to fetch. Must be non-null. + * @return resource associated to the given identifier (never {@code null}). + * @throws IllegalNameException if no resource is found for the given identifier, or if more than one resource is found. + * @throws DataStoreException if another kind of error occurred while searching resources. + */ + public Resource findResource(final String identifier) throws DataStoreException { + ArgumentChecks.ensureNonEmpty("identifier", identifier); + final Resource resource = findResource(identifier, getRootResource(), new IdentityHashMap<Resource,Boolean>()); + if (resource != null) { + return resource; + } + throw new IllegalNameException(Resources.forLocale(getLocale()) + .getString(Resources.Keys.ResourceNotFound_2, getDisplayName(), identifier)); + } + + /** + * Recursively searches for a resource identified by the given identifier. + * This is the implementation of {@link #findResource(String)}. + * + * @param identifier identifier of the resource to fetch. + * @param candidate a resource to compare against the identifier. + * @param visited resources visited so-far, for avoiding never-ending loops if cycles exist. + * @return resource associated to the given identifier, or {@code null} if not found. + */ + private Resource findResource(final String identifier, final Resource candidate, + final Map<Resource,Boolean> visited) throws DataStoreException + { + if (candidate != null && visited.put(candidate, Boolean.TRUE) == null) { + final Metadata metadata = candidate.getMetadata(); + if (metadata != null) { + for (final Identification identification : metadata.getIdentificationInfo()) { + if (identification != null) { // Paranoiac check. + if (Citations.identifierMatches(identification.getCitation(), null, identifier)) { + return candidate; + } + } + } + } + if (candidate instanceof Aggregate) { + Resource result = null; + for (final Resource child : ((Aggregate) candidate).components()) { + final Resource match = findResource(identifier, child, visited); + if (match != null) { + if (result == null) { + result = match; + } else { + throw new IllegalNameException(Resources.forLocale(getLocale()) + .getString(Resources.Keys.ResourceIdentifierCollision_2, getDisplayName(), identifier)); + } + } + } + return result; + } + } + return null; + } + + /** * Adds a listener to be notified when a warning occurred while reading from or writing to the storage. * When a warning occurs, there is a choice: * Copied: sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java (from r1804404, sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java?p2=sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java&p1=sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java&r1=1804404&r2=1804411&rev=1804411&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/main/java/org/apache/sis/storage/FeatureSet.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -16,10 +16,12 @@ */ package org.apache.sis.storage; -import java.util.stream.Stream; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; +// Branch-dependent imports +import org.apache.sis.internal.jdk8.Stream; + /** * A dataset providing access to a stream of features. Modified: sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreMock.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreMock.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreMock.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-storage/src/test/java/org/apache/sis/storage/DataStoreMock.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -54,6 +54,11 @@ final strictfp class DataStoreMock exten } @Override + public Resource getRootResource() throws DataStoreException { + return null; + } + + @Override public void close() { } } Copied: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java (from r1804404, sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java) URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java?p2=sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java&p1=sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java&r1=1804404&r2=1804411&rev=1804411&view=diff ============================================================================== --- sis/branches/JDK8/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/FeatureAccess.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -23,9 +23,9 @@ import org.apache.sis.internal.storage.A import org.apache.sis.util.logging.WarningListeners; // Branch-dependent imports -import java.util.stream.Stream; import org.opengis.feature.Feature; import org.opengis.feature.FeatureType; +import org.apache.sis.internal.jdk8.Stream; /** Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Store.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -21,6 +21,7 @@ import org.opengis.util.NameFactory; import org.opengis.util.FactoryException; import org.opengis.metadata.Metadata; import org.opengis.metadata.distribution.Format; +import org.apache.sis.storage.Resource; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; import org.apache.sis.storage.DataStoreContentException; @@ -167,14 +168,27 @@ public final class Store extends StaxDat } /** + * Returns the {@code FeatureSet} from which all features in this data store can be accessed. + * + * @return the starting point of all features in this data store. + */ + @Override + public Resource getRootResource() { + return new FeatureAccess(this, listeners); + } + + /** * Returns the feature type for the given name. The {@code name} argument should be the result of calling * {@link org.opengis.util.GenericName#toString()} on the name of one of the feature types in this data store. * * @param name the name or alias of the feature type to get. * @return the feature type of the given name or alias (never {@code null}). * @throws IllegalNameException if the given name was not found or is ambiguous. + * + * @deprecated We are not sure yet if we will keep this method. Decision is pending acquisition of + * more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}. */ - @Override + @Deprecated public FeatureType getFeatureType(final String name) throws IllegalNameException { return types.names.get(this, name); } @@ -182,12 +196,10 @@ public final class Store extends StaxDat /** * Returns the stream of features. * - * @param parallel ignored in current implementation. * @return a stream over all features in the XML file. * @throws DataStoreException if an error occurred while creating the feature stream. */ - @Override - public synchronized Stream<Feature> features(final boolean parallel) throws DataStoreException { + final synchronized Stream<Feature> features() throws DataStoreException { Reader r = reader; reader = null; if (r == null) try { Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/gpx/Types.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -64,6 +64,11 @@ import org.opengis.feature.FeatureType; */ final class Types { /** + * The parent of all other feature types. + */ + final FeatureType parent; + + /** * Way point GPX feature type. */ final FeatureType wayPoint; @@ -91,7 +96,11 @@ final class Types { /** * Binding from names to feature type instances. * Shall not be modified after construction. + * + * @deprecated We are not sure yet if we will keep this field. Decision is pending acquisition of + * more experience with the API proposed by {@link org.apache.sis.storage.FeatureSet}. */ + @Deprecated final FeatureNaming<FeatureType> names; /** @@ -143,7 +152,7 @@ final class Types { final FeatureTypeBuilder builder = new FeatureTypeBuilder(factory, library, locale); builder.setNameSpace(Tags.PREFIX).setName("GPXEntity").setAbstract(true); builder.addAttribute(Integer.class).setName(AttributeConvention.IDENTIFIER_PROPERTY); - final FeatureType parent = builder.build(); + parent = builder.build(); /* * WayPoint ⇾ GPXEntity * ┌──────────────────┬────────────────┬────────────────────────┬─────────────┐ Modified: sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/main/java/org/apache/sis/internal/storage/xml/stream/StaxDataStore.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -38,7 +38,6 @@ import org.apache.sis.setup.OptionKey; import org.apache.sis.storage.DataStore; import org.apache.sis.storage.StorageConnector; import org.apache.sis.storage.DataStoreException; -import org.apache.sis.internal.storage.FeatureStore; import org.apache.sis.internal.storage.io.ChannelFactory; import org.apache.sis.internal.storage.io.IOUtilities; import org.apache.sis.internal.storage.io.Markable; @@ -65,7 +64,7 @@ import org.apache.sis.util.Debug; * @since 0.8 * @module */ -public abstract class StaxDataStore extends FeatureStore { +public abstract class StaxDataStore extends DataStore { /** * The locale to use for locale-sensitive data (<strong>not</strong> for logging or warning messages), * or {@code null} if unspecified. Modified: sis/branches/JDK7/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java URL: http://svn.apache.org/viewvc/sis/branches/JDK7/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java?rev=1804411&r1=1804410&r2=1804411&view=diff ============================================================================== --- sis/branches/JDK7/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java [UTF-8] (original) +++ sis/branches/JDK7/storage/sis-xmlstore/src/test/java/org/apache/sis/internal/storage/gpx/ReaderTest.java [UTF-8] Tue Aug 8 12:43:28 2017 @@ -224,7 +224,7 @@ public final strictfp class ReaderTest e try (Store reader = create("1.0/waypoint.xml")) { verifyAlmostEmptyMetadata((Metadata) reader.getMetadata()); assertEquals("version", StoreProvider.V1_0, reader.getVersion()); - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyPoint(it.next(), 0, false); verifyPoint(it.next(), 1, false); @@ -245,7 +245,7 @@ public final strictfp class ReaderTest e try (Store reader = create("1.1/waypoint.xml")) { verifyAlmostEmptyMetadata((Metadata) reader.getMetadata()); assertEquals("version", StoreProvider.V1_1, reader.getVersion()); - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyPoint(it.next(), 0, true); verifyPoint(it.next(), 1, true); @@ -266,7 +266,7 @@ public final strictfp class ReaderTest e try (Store reader = create("1.0/route.xml")) { verifyAlmostEmptyMetadata((Metadata) reader.getMetadata()); assertEquals("version", StoreProvider.V1_0, reader.getVersion()); - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyRoute(it.next(), false, 1); verifyEmpty(it.next(), "rtept"); @@ -295,7 +295,7 @@ public final strictfp class ReaderTest e * This verification is shared by {@link #testRoute110()} and {@link #testSequentialReads()}. */ static void verifyRoute110(final Store reader) throws DataStoreException { - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyRoute(it.next(), true, 3); verifyEmpty(it.next(), "rtept"); @@ -373,7 +373,7 @@ public final strictfp class ReaderTest e try (Store reader = create("1.0/track.xml")) { verifyAlmostEmptyMetadata((Metadata) reader.getMetadata()); assertEquals("version", StoreProvider.V1_0, reader.getVersion()); - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyTrack(it.next(), false, 1); verifyEmpty(it.next(), "trkseg"); @@ -393,7 +393,7 @@ public final strictfp class ReaderTest e try (Store reader = create("1.1/track.xml")) { verifyAlmostEmptyMetadata((Metadata) reader.getMetadata()); assertEquals("version", StoreProvider.V1_1, reader.getVersion()); - try (Stream<Feature> features = reader.features(false)) { + try (Stream<Feature> features = reader.features()) { final Iterator<Feature> it = features.iterator(); verifyTrack(it.next(), true, 3); verifyEmpty(it.next(), "trkseg"); @@ -610,13 +610,13 @@ public final strictfp class ReaderTest e @DependsOnMethod("testSequentialReads") public void testConcurrentReads() throws DataStoreException { try (Store reader = createFromURL()) { - final Stream<Feature> f1 = reader.features(false); + final Stream<Feature> f1 = reader.features(); final Iterator<Feature> i1 = f1.iterator(); verifyRoute(i1.next(), true, 3); - final Stream<Feature> f2 = reader.features(false); + final Stream<Feature> f2 = reader.features(); final Iterator<Feature> i2 = f2.iterator(); verifyEmpty(i1.next(), "rtept"); - final Stream<Feature> f3 = reader.features(false); + final Stream<Feature> f3 = reader.features(); final Iterator<Feature> i3 = f3.iterator(); verifyRoute(i2.next(), true, 3); verifyRoute(i3.next(), true, 3);