uk.ac.starlink.vo
Class TapSchemaInterrogator

java.lang.Object
  extended by 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.

See Also:
TAP standard

Constructor Summary
TapSchemaInterrogator(URL serviceUrl)
          Constructs an interrogator with a default maxrec limit.
TapSchemaInterrogator(URL serviceUrl, int maxrec)
          Constructs an interrogator with a given maxrec limit.
 
Method Summary
protected  TapQuery createTapQuery(String adql)
          Constructs a TAP query for a given ADQL string.
protected  StarTable executeQuery(TapQuery tq)
          Performs an ADQL TAP query to this interrogator's service.
static void main(String[] args)
           
 SchemaMeta[] queryMetadata()
          Returns an array of SchemaMeta objects describing the tables available from the service.
 Map<String,List<ColumnMeta>> readColumns()
          Queries the TAP_SCHEMA.columns table to get a list of all columns.
 Map<String,List<ForeignMeta>> readForeignKeys(Map<String,List<ForeignMeta.Link>> lMap)
          Queries the TAP_SCHEMA.keys table to get a list of all foreign keys.
 Map<String,List<ForeignMeta.Link>> readForeignLinks()
          Queries the TAP_SCHEMA.key_columns table to get a list of all foreign key links.
 List<SchemaMeta> readSchemas(Map<String,List<TableMeta>> tMap, boolean addOrphans)
          Queries the TAP_SCHEMA.schemas table to get a list of all schemas.
 Map<String,List<TableMeta>> readTables(Map<String,List<ColumnMeta>> cMap, Map<String,List<ForeignMeta>> fMap)
          Queries the TAP_SCHEMA.tables table to get a list of all tables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TapSchemaInterrogator

public TapSchemaInterrogator(URL serviceUrl)
Constructs an interrogator with a default maxrec limit.

Parameters:
serviceUrl - TAP base service URL

TapSchemaInterrogator

public TapSchemaInterrogator(URL serviceUrl,
                             int maxrec)
Constructs an interrogator with a given maxrec limit.

Parameters:
serviceUrl - TAP base service URL
maxrec - maximum number of records to retrieve per query
Method Detail

queryMetadata

public SchemaMeta[] queryMetadata()
                           throws IOException
Returns an array of SchemaMeta objects describing the tables available from the service. The table, column and foreign key information is filled in.

Returns:
fully populated array of known schemas
Throws:
IOException

readForeignLinks

public Map<String,List<ForeignMeta.Link>> readForeignLinks()
                                                    throws IOException
Queries the TAP_SCHEMA.key_columns table to get a list of all foreign key links. The returned map associates key_id values with lists of from->to column links.

Returns:
map from key_id to link list
Throws:
IOException

readForeignKeys

public Map<String,List<ForeignMeta>> readForeignKeys(Map<String,List<ForeignMeta.Link>> lMap)
                                              throws IOException
Queries the TAP_SCHEMA.keys table to get a list of all foreign keys. The returned map associates from_table values with lists of foreign keys.

Parameters:
lMap - map of known links keyed by key_id, as returned by readForeignLinks(); entries are removed as used
Returns:
map from table name to foreign key list
Throws:
IOException

readColumns

public Map<String,List<ColumnMeta>> readColumns()
                                         throws IOException
Queries the TAP_SCHEMA.columns table to get a list of all columns. The returned map associates table names with lists of columns.

Returns:
map from table name to column list
Throws:
IOException

readTables

public Map<String,List<TableMeta>> readTables(Map<String,List<ColumnMeta>> cMap,
                                              Map<String,List<ForeignMeta>> fMap)
                                       throws IOException
Queries the TAP_SCHEMA.tables table to get a list of all tables. The returned map associates schema names with lists of tables.

Parameters:
cMap - map of known columns keyed by table name, as returned by readColumns(); entries are removed as used
fMap - map of known foreign keys keyed by table name, as returned by readForeignKeys; entries are removed as used
Returns:
map from schema name to table list
Throws:
IOException

readSchemas

public List<SchemaMeta> readSchemas(Map<String,List<TableMeta>> tMap,
                                    boolean addOrphans)
                             throws IOException
Queries the TAP_SCHEMA.schemas table to get a list of all schemas.

Parameters:
tMap - map of known tables keyed by schema name, as returned by readTables(java.util.Map>, java.util.Map>); entries are removed as used
addOrphans - if true, schema entries are faked for any schemas referenced in the table map which are not read from the database table; if false, those tables will be retained in the table map on exit
Returns:
list of schemas
Throws:
IOException

createTapQuery

protected TapQuery createTapQuery(String adql)
Constructs a TAP query for a given ADQL string.

Parameters:
adql - query text
Returns:
query to execute

executeQuery

protected StarTable executeQuery(TapQuery tq)
                          throws IOException
Performs an ADQL TAP query to this interrogator's service.

Parameters:
tq - tap query
Returns:
output table
Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException


Copyright © 2015 Central Laboratory of the Research Councils. All Rights Reserved.