Class TapSchemaInterrogator


  • public class TapSchemaInterrogator
    extends java.lang.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:
    TAP standard
    • Constructor Detail

      • TapSchemaInterrogator

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

      • getEndpointSet

        public EndpointSet getEndpointSet()
        Returns the TAP endpoint locations used by this interrogator.
        Returns:
        TAP endpoints
      • queryMetadata

        public SchemaMeta[] queryMetadata()
                                   throws java.io.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:
        java.io.IOException
      • readSchemas

        public SchemaMeta[] readSchemas​(boolean populateSchemas,
                                        boolean populateTables,
                                        boolean addOrphanTables)
                                 throws java.io.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:
        java.io.IOException
      • readMap

        public <T> java.util.Map<java.lang.String,​java.util.List<T>> readMap​(TapSchemaInterrogator.MetaQuerier<T> mq,
                                                                                   java.lang.String moreAdql)
                                                                            throws java.io.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:
        java.io.IOException
      • readList

        public <T> java.util.List<T> readList​(TapSchemaInterrogator.MetaQuerier<T> mq,
                                              java.lang.String moreAdql)
                                       throws java.io.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:
        java.io.IOException
      • populateForeignKey

        public void populateForeignKey​(ForeignMeta fmeta,
                                       java.util.Map<java.lang.String,​java.util.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,
                                  java.util.Map<java.lang.String,​java.util.List<ForeignMeta>> fMap,
                                  java.util.Map<java.lang.String,​java.util.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,
                                   java.util.Map<java.lang.String,​java.util.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​(java.lang.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 java.io.IOException
        Performs an ADQL TAP query to this interrogator's service. May be overridden.
        Parameters:
        tq - tap query
        Returns:
        output table
        Throws:
        java.io.IOException
      • main

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