Class TapSchemaInterrogator

java.lang.Object
uk.ac.starlink.vo.TapSchemaInterrogator

public class TapSchemaInterrogator extends Object
Interrogates the TAP_SCHEMA tables from a TAP service to acquire table metadata information. In the current implementation, synchronous queries are used.
Since:
6 Jun 2011
Author:
Mark Taylor
See Also:
  • Field Details

  • Constructor Details

    • TapSchemaInterrogator

      public TapSchemaInterrogator(TapService service, int maxrec, uk.ac.starlink.util.ContentCoding coding)
      Constructs an interrogator with explicit configuration.
      Parameters:
      service - TAP service description
      maxrec - maximum number of records to retrieve per query
      coding - configures HTTP compression
  • Method Details

    • getTapService

      public TapService getTapService()
      Returns the TAP service used by this interrogator.
      Returns:
      TAP service description
    • queryMetadata

      public SchemaMeta[] queryMetadata() throws IOException
      This convenience method returns an array of fully filled in SchemaMeta objects describing the tables available from the service.
      Returns:
      fully populated array of known schemas
      Throws:
      IOException
    • readSchemas

      public SchemaMeta[] readSchemas(boolean populateSchemas, boolean populateTables, boolean addOrphanTables) throws IOException
      Reads all schemas. According to the options, the schemas may or may not have their tables filled in, and those tables may or may not have their columns and foreign key information filled in.
      Parameters:
      populateSchemas - if true, schemas will contain non-null table lists
      populateTables - if true, tables will contain non-null column/key lists (ignored if populateSchemas is false)
      addOrphanTables - if true include tables whose schemas are not explicitly declared
      Returns:
      schema list
      Throws:
      IOException
    • readMap

      public <T> Map<String,List<T>> readMap(TapSchemaInterrogator.MetaQuerier<T> mq, String moreAdql) throws IOException
      Reads a map of metadata items using a given MetaQuerier object. The key of the map is the name of the parent object of the map value list type. See the documentation of the specific querier object for details.

      The form of the basic SELECT statement generated by this call is "SELECT <columns> FROM <table>". If non-null the text of the moreAdql parameter is appended (after a space), so it may be used to qualify the query further.

      Parameters:
      mq - type-specific querier
      moreAdql - additional ADQL text to append after the FROM clause (for example a WHERE clause); may be null
      Returns:
      map from parent metadata item name to list of metadata items
      Throws:
      IOException
    • readList

      public <T> List<T> readList(TapSchemaInterrogator.MetaQuerier<T> mq, String moreAdql) throws IOException
      Reads a list of metadata items using a given MetaQuerier object.

      The form of the basic SELECT statement generated by this call is "SELECT <columns> FROM <table>". If non-null the text of the moreAdql parameter is appended (after a space), so it may be used to qualify the query further.

      Parameters:
      mq - type-specific querier
      moreAdql - additional ADQL text to append after the FROM clause (for example a WHERE clause); may be null
      Returns:
      list of metadata items
      Throws:
      IOException
    • populateForeignKey

      public void populateForeignKey(ForeignMeta fmeta, Map<String,List<ForeignMeta.Link>> lMap)
      Fills in link information for a ForeignMeta object. Any relevant entries are removed from the supplied map. If the map contains no relevant entries, an empty list is filled in.
      Parameters:
      fmeta - unpopulated foreign key item
      lMap - map acquired using LINK_QUERIER
    • populateTable

      public void populateTable(TableMeta tmeta, Map<String,List<ForeignMeta>> fMap, Map<String,List<ColumnMeta>> cMap)
      Fills in foreign key and column information for a TableMeta object, Any relevant entries are removed from the supplied maps. Where the maps contain no relevant entries, an empty list is filled in.
      Parameters:
      tmeta - unpopulated table metadata item
      fMap - map acquired using FKEY_QUERIER
      cMap - map acquired using COLUMN_QUERIER
    • populateSchema

      public void populateSchema(SchemaMeta smeta, Map<String,List<TableMeta>> tMap)
      Fills in table information for a SchemaMeta object. Any relevant entries are removed from the supplied map. If the map contains no relevant entries, an empty list is filled in.
      Parameters:
      smeta - unpopulated schema metadata item
      tMap - map acquired using TABLE_QUERIER
    • createTapQuery

      protected TapQuery createTapQuery(String adql)
      Constructs a TAP query for a given ADQL string. May be overridden.
      Parameters:
      adql - query text
      Returns:
      query to execute
    • executeQuery

      protected uk.ac.starlink.table.StarTable executeQuery(TapQuery tq) throws IOException
      Performs an ADQL TAP query to this interrogator's service. May be overridden.
      Parameters:
      tq - tap query
      Returns:
      output table
      Throws:
      IOException
    • main

      public static void main(String[] args) throws IOException
      Prints out metadata content of a given TAP service.
      Parameters:
      args - first element is TAP service URL
      Throws:
      IOException