# Class SimpleFeatureStore

Object
DataStore
SQLStore
SimpleFeatureStore

All Implemented Interfaces:
  `AutoCloseable, Aggregate, Resource, Localized`

public class SimpleFeatureStore extends SQLStore
A concrete data store capable to read and write features from/to a spatial SQL database. All resources created by this class are `FeatureSet`s. The data are specified by two main arguments given at construction time:

- A `DataSource` (specified indirectly) providing connections to the database. While not mandatory, a pooled data source is recommended because `SimpleFeatureStore` may open and close connections many times.
- A list of tables, views or queries to view as `FeatureSet`s. This list is provided by `ResourceDefinition` objects. Only the main tables need to be specified. Dependencies inferred by foreigner keys will be followed automatically.

Despite the `SimpleFeatureStore` class name, this class supports complex features, i.e. features having associations to other features. The associations are discovered automatically by following the foreigner keys.

Since:
  1.5
See Also:
  - OGC Simple feature access - Part 2: SQL option

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Resource

  `Resource​.FileSet`

- ## Field Summary

  ### Fields inherited from class SQLStore

  `contentLocale, source`

  ### Fields inherited from class DataStore

  `listeners, provider`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleFeatureStore(DataStoreProvider provider, StorageConnector connector, ResourceDefinition... resources)`
  Creates a new `SimpleFeatureStore` for the given data source and tables, views or queries.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Collection<FeatureSet>`
  `components()`
  Returns the tables (feature sets) in this SQL store.
  `FeatureSet`
  `findResource(String identifier)`
  Searches for a resource identified by the given identifier.
  `Optional<ParameterValueGroup>`
  `getOpenParameters()`
  Returns parameters that can be used for opening this Simple Features data store.
  `protected ResourceDefinition[]`
  `readResourceDefinitions(DataAccess dao)`
  Returns the resource definitions equivalent to the ones specified at construction time.

  ### Methods inherited from class SQLStore

  `addListener, close, getDatabaseSoftwareVersions, getDataSource, getIdentifier, getMetadata, initialize, newDataAccess, vacuum`

  ### Methods inherited from class DataStore

  `getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toString`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface Resource

  `getFileSet, removeListener`

- ## Constructor Details

  - ### SimpleFeatureStore

    public SimpleFeatureStore(DataStoreProvider provider, StorageConnector connector, ResourceDefinition... resources) throws DataStoreException
    Creates a new `SimpleFeatureStore` for the given data source and tables, views or queries. The given `connector` shall contain a `DataSource` instance. Tables or views to include in the store are specified by the `resources` argument. Only the main tables need to be specified, as dependencies will be followed automatically.
    Parameters:
      `provider` - the factory that created this `DataStore` instance, or `null` if unspecified.
      `connector` - information about the storage (JDBC data source, etc).
      `resources` - tables, views or queries to include in this store.
    Throws:
      `DataStoreException` - if an error occurred while creating the data store for the given storage.

- ## Method Details

  - ### getOpenParameters

    public Optional<ParameterValueGroup> getOpenParameters()
    Returns parameters that can be used for opening this Simple Features data store. The parameters are described by `SQLStoreProvider​.getOpenParameters()` and can contain some or all of the following:
    - A parameter named "location" with a `DataSource` value.
    - `SQLStoreProvider​.TABLES_PARAM` with `ResourceDefinition`s specified at construction time for tables.
    - `SQLStoreProvider​.QUERIES_PARAM` with `ResourceDefinition`s specified at construction time for queries.
    Overrides:
      `getOpenParameters` in class `SQLStore`
    Returns:
      parameters used for opening this data store.
    See Also:
      - `DataStoreProvider​.getOpenParameters()`

  - ### components

    public Collection<FeatureSet> components() throws DataStoreException
    Returns the tables (feature sets) in this SQL store. The collection contains only the tables matching a `ResourceDefinition` given at construction time.
    Specified by:
      `components` in interface `Aggregate`
    Overrides:
      `components` in class `SQLStore`
    Returns:
      children resources that are components of this SQL store.
    Throws:
      `DataStoreException` - if an error occurred while fetching the components.

  - ### findResource

    public FeatureSet findResource(String identifier) throws DataStoreException
    Searches for a resource identified by the given identifier. The given identifier shall match the name of one of the tables, views or queries inferred at construction time. It may be a table named explicitly at construction time, or a dependency inferred by following foreigner keys. The given identifier may be qualified with the schema name, or may be only the table name if there is no ambiguity.
    Overrides:
      `findResource` in class `SQLStore`
    Parameters:
      `identifier` - identifier of the resource to fetch. Must be non-null.
    Returns:
      resource associated to the given identifier (never `null`).
    See Also:
      - `Resource​.getIdentifier()`
      - `FeatureNaming`

  - ### readResourceDefinitions

    protected ResourceDefinition[] readResourceDefinitions(DataAccess dao)
    Returns the resource definitions equivalent to the ones specified at construction time. This method is defined for completness, but is not used by `SimpleFeatureStore`.
    Specified by:
      `readResourceDefinitions` in class `SQLStore`
    Parameters:
      `dao` - ignored.
    Returns:
      tables or views to include in the store. Only the main tables need to be specified. Dependencies (inferred from the foreigner keys) will be followed automatically.
    See Also:
      - `SQLStore​.initialize(Connection)`