Class QueryAnalyzer

java.lang.Object
org.apache.sis.internal.sql.feature.FeatureAnalyzer
org.apache.sis.internal.sql.feature.QueryAnalyzer

final class QueryAnalyzer extends FeatureAnalyzer
Constructor for a Table based on a query, to be considered as a virtual table. User should build a query where each column has a distinct name (using "AS" if needed). Current implementation follows "import" foreigner keys but not "export" foreigner keys.
Since:
1.1
Version:
1.1
  • Field Details

    • query

      private final String query
      The query submitted by user.
    • columns

      private final Column[] columns
      All columns, without filtering for separating attributes from associations.
    • columnsPerTable

      private final Map<TableReference,Map<String,Column>> columnsPerTable
      Columns grouped by the tables that contain them. The String keys of inner Maps are Column.name values.
  • Constructor Details

    • QueryAnalyzer

      QueryAnalyzer(Analyzer analyzer, org.opengis.util.GenericName name, String query, String definition) throws Exception
      Creates a new analyzer for a query.
      Parameters:
      name - name to give to the virtual table.
      query - the query submitted by user.
      definition - concise definition of the resource in natural language.
      Throws:
      Exception
  • Method Details

    • getForeignerKeys

      Relation[] getForeignerKeys(Relation.Direction direction) throws SQLException, DataStoreException
      Returns a list of associations between the table read by this method and other tables. Current implementation supports only "import" foreigner keys, i.e. associations from the query to another table (not the opposite direction).
      Specified by:
      getForeignerKeys in class FeatureAnalyzer
      Parameters:
      direction - direction of the foreigner key for which to return components.
      Returns:
      components of the foreigner key for the requested direction.
      Throws:
      SQLException - if an error occurred while fetching information from the database.
      DataStoreException - if a logical error occurred while analyzing the relations.
    • createAttributes

      Column[] createAttributes() throws Exception
      Configures the feature builder with attributes inferred from the query.
      Specified by:
      createAttributes in class FeatureAnalyzer
      Returns:
      the columns for attribute values (not including associations).
      Throws:
      SQLException - if an error occurred while fetching information from the database.
      DataStoreException - if a logical error occurred while analyzing the relations.
      Exception - for WKB parsing error or other kinds of errors.