Skip to content
Snippets Groups Projects
Commit 93c36a09 authored by gmantele's avatar gmantele
Browse files

[TAP] The additional table TAP_SCHEMA.coossys must not be be returned as a

standard table. The same for the additional column
TAP_SCHEMA.columns.coosys_id.
parent ae8e18b9
No related branches found
No related tags found
No related merge requests found
...@@ -903,6 +903,7 @@ public class JDBCConnection implements DBConnection { ...@@ -903,6 +903,7 @@ public class JDBCConnection implements DBConnection {
* <ol> * <ol>
* <li>{@link #loadSchemas(TAPTable, TAPMetadata, Statement)}</li> * <li>{@link #loadSchemas(TAPTable, TAPMetadata, Statement)}</li>
* <li>{@link #loadTables(TAPTable, TAPMetadata, Statement)}</li> * <li>{@link #loadTables(TAPTable, TAPMetadata, Statement)}</li>
* <li>{@link #loadCoosys(TAPTable, TAPMetadata, Statement)}</li>
* <li>{@link #loadColumns(TAPTable, List, Statement)}</li> * <li>{@link #loadColumns(TAPTable, List, Statement)}</li>
* <li>{@link #loadKeys(TAPTable, TAPTable, List, Statement)}</li> * <li>{@link #loadKeys(TAPTable, TAPTable, List, Statement)}</li>
* </ol> * </ol>
...@@ -941,11 +942,16 @@ public class JDBCConnection implements DBConnection { ...@@ -941,11 +942,16 @@ public class JDBCConnection implements DBConnection {
List<TAPTable> lstTables = loadTables(tap_schema.getTable(STDTable.TABLES.label), metadata, stmt); List<TAPTable> lstTables = loadTables(tap_schema.getTable(STDTable.TABLES.label), metadata, stmt);
// load all coordinate systems from TAP_SCHEMA.coosys: [non standard] // load all coordinate systems from TAP_SCHEMA.coosys: [non standard]
Map<String, TAPCoosys> mapCoosys = null; Map<String,TAPCoosys> mapCoosys = null;
if (isTableExisting(tap_schema.getDBName(), STDTable.COOSYS.label, stmt.getConnection().getMetaData())){ if (isTableExisting(tap_schema.getDBName(), "coosys", stmt.getConnection().getMetaData())){
if (logger != null) if (logger != null)
logger.logDB(LogLevel.INFO, this, "LOAD_TAP_SCHEMA", "Loading TAP_SCHEMA.coosys.", null); logger.logDB(LogLevel.INFO, this, "LOAD_TAP_SCHEMA", "Loading TAP_SCHEMA.coosys.", null);
mapCoosys = loadCoosys(tap_schema.getTable(STDTable.COOSYS.label), metadata, stmt); // create the TAP_SCHEMA.coosys table:
TAPTable coosysTable = TAPMetadata.getCoosysTable();
// add TAP_SCHEMA.coosys to the schema TAP_SCHEMA:
tap_schema.addTable(coosysTable);
// load all declared coordinate systems from it:
mapCoosys = loadCoosys(coosysTable, metadata, stmt);
} }
// load all columns from TAP_SCHEMA.columns: // load all columns from TAP_SCHEMA.columns:
...@@ -1156,7 +1162,7 @@ public class JDBCConnection implements DBConnection { ...@@ -1156,7 +1162,7 @@ public class JDBCConnection implements DBConnection {
close(rs); close(rs);
} }
} }
/** /**
* Load all coordinate systems declared in the TAP_SCHEMA. * Load all coordinate systems declared in the TAP_SCHEMA.
* *
...@@ -1171,7 +1177,7 @@ public class JDBCConnection implements DBConnection { ...@@ -1171,7 +1177,7 @@ public class JDBCConnection implements DBConnection {
* *
* @since 2.1 * @since 2.1
*/ */
protected Map<String, TAPCoosys> loadCoosys(final TAPTable tableDef, final TAPMetadata metadata, final Statement stmt) throws DBException{ protected Map<String,TAPCoosys> loadCoosys(final TAPTable tableDef, final TAPMetadata metadata, final Statement stmt) throws DBException{
ResultSet rs = null; ResultSet rs = null;
try{ try{
// Build the SQL query: // Build the SQL query:
...@@ -1187,15 +1193,14 @@ public class JDBCConnection implements DBConnection { ...@@ -1187,15 +1193,14 @@ public class JDBCConnection implements DBConnection {
rs = stmt.executeQuery(sqlBuf.toString()); rs = stmt.executeQuery(sqlBuf.toString());
// Create all coosys: // Create all coosys:
HashMap<String, TAPCoosys> mapCoosys = new HashMap<String, TAPCoosys>(); HashMap<String,TAPCoosys> mapCoosys = new HashMap<String,TAPCoosys>();
while(rs.next()){ while(rs.next()){
String coosysId = rs.getString(1), String coosysId = rs.getString(1), system = rs.getString(2),
system = rs.getString(2), equinox = rs.getString(3), equinox = rs.getString(3), epoch = rs.getString(4);
epoch = rs.getString(4);
// create the new coosys: // create the new coosys:
TAPCoosys newCoosys = new TAPCoosys(coosysId, system, nullifyIfNeeded(equinox), nullifyIfNeeded(epoch)); TAPCoosys newCoosys = new TAPCoosys(coosysId, system, nullifyIfNeeded(equinox), nullifyIfNeeded(epoch));
// create and add the new coosys: // create and add the new coosys:
metadata.addCoosys(newCoosys); metadata.addCoosys(newCoosys);
mapCoosys.put(coosysId, newCoosys); mapCoosys.put(coosysId, newCoosys);
...@@ -1210,8 +1215,6 @@ public class JDBCConnection implements DBConnection { ...@@ -1210,8 +1215,6 @@ public class JDBCConnection implements DBConnection {
close(rs); close(rs);
} }
} }
/** /**
* <p>Load into the corresponding tables all columns listed in TAP_SCHEMA.columns.</p> * <p>Load into the corresponding tables all columns listed in TAP_SCHEMA.columns.</p>
...@@ -1233,7 +1236,7 @@ public class JDBCConnection implements DBConnection { ...@@ -1233,7 +1236,7 @@ public class JDBCConnection implements DBConnection {
* @throws DBException If a table can not be found, or if any other error occurs while interacting with the database. * @throws DBException If a table can not be found, or if any other error occurs while interacting with the database.
* *
* @deprecated This method is now replaced by {@link #loadColumns(TAPTable, List, Map, Statement)} which has an additional parameter: * @deprecated This method is now replaced by {@link #loadColumns(TAPTable, List, Map, Statement)} which has an additional parameter:
* the list of declared coordinate systems. * the list of declared coordinate systems.
*/ */
@Deprecated @Deprecated
protected void loadColumns(final TAPTable tableDef, final List<TAPTable> lstTables, final Statement stmt) throws DBException{ protected void loadColumns(final TAPTable tableDef, final List<TAPTable> lstTables, final Statement stmt) throws DBException{
...@@ -1262,7 +1265,7 @@ public class JDBCConnection implements DBConnection { ...@@ -1262,7 +1265,7 @@ public class JDBCConnection implements DBConnection {
* *
* @since 2.1 * @since 2.1
*/ */
protected void loadColumns(final TAPTable tableDef, final List<TAPTable> lstTables, final Map<String, TAPCoosys> mapCoosys, final Statement stmt) throws DBException{ protected void loadColumns(final TAPTable tableDef, final List<TAPTable> lstTables, final Map<String,TAPCoosys> mapCoosys, final Statement stmt) throws DBException{
ResultSet rs = null; ResultSet rs = null;
try{ try{
// Determine whether the dbName column exists: // Determine whether the dbName column exists:
...@@ -1354,10 +1357,10 @@ public class JDBCConnection implements DBConnection { ...@@ -1354,10 +1357,10 @@ public class JDBCConnection implements DBConnection {
newColumn.setStd(std); newColumn.setStd(std);
newColumn.setDBName(dbName); newColumn.setDBName(dbName);
newColumn.setIndex(colIndex); newColumn.setIndex(colIndex);
// set the coordinate system if any is specified: // set the coordinate system if any is specified:
if (hasCoosys){ if (hasCoosys){
int indCoosys = 12; int indCoosys = 12;
if (hasColumnIndex) if (hasColumnIndex)
indCoosys++; indCoosys++;
if (hasDBName) if (hasDBName)
...@@ -1366,7 +1369,7 @@ public class JDBCConnection implements DBConnection { ...@@ -1366,7 +1369,7 @@ public class JDBCConnection implements DBConnection {
if (coosysId != null){ if (coosysId != null){
newColumn.setCoosys(mapCoosys.get(coosysId)); newColumn.setCoosys(mapCoosys.get(coosysId));
if (logger != null && newColumn.getCoosys() == null) if (logger != null && newColumn.getCoosys() == null)
logger.logDB(LogLevel.WARNING, this, "LOAD_TAP_SCHEMA", "No coordinate system for the column \""+columnName+"\"! Cause: unknown coordinate system: \""+coosysId+"\".", null); logger.logDB(LogLevel.WARNING, this, "LOAD_TAP_SCHEMA", "No coordinate system for the column \"" + columnName + "\"! Cause: unknown coordinate system: \"" + coosysId + "\".", null);
} }
} }
......
...@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletResponse;
import adql.db.DBTable; import adql.db.DBTable;
import adql.db.DBType; import adql.db.DBType;
import adql.db.DBType.DBDatatype; import adql.db.DBType.DBDatatype;
import tap.db.JDBCConnection;
import tap.metadata.TAPTable.TableType; import tap.metadata.TAPTable.TableType;
import tap.resource.Capabilities; import tap.resource.Capabilities;
import tap.resource.TAPResource; import tap.resource.TAPResource;
...@@ -892,6 +893,23 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour ...@@ -892,6 +893,23 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
return tap_schema; return tap_schema;
} }
/**
* Get the minimum definition of the table TAP_SCHEMA.coosys as expected by
* the library (see {@link JDBCConnection#getTAPSchema()}.
*
* @return The created definition of TAP_SCHEMA.coosys.
*
* @since 2.1
*/
public static final TAPTable getCoosysTable(){
TAPTable coosys = new TAPTable(STDSchema.TAPSCHEMA + ".coosys", TableType.table, "List of coordinate systems of coordinate columns published in this TAP service.", null);
coosys.addColumn("id", new DBType(DBDatatype.VARCHAR), "ID of the coordinate system definition as it must be in the VOTable.", null, null, null, true, true, false);
coosys.addColumn("system", new DBType(DBDatatype.VARCHAR), "The coordinate system (among \"ICRS\", \"eq_FK5\", \"eq_FK4\", \"ecl_FK4\", \"ecl_FK5\", \"galactic\", \"supergalactic\", \"xy\", \"barycentric\", \"geo_app\").", null, null, null, false, false, false);
coosys.addColumn("equinox", new DBType(DBDatatype.VARCHAR), "Required to fix the equatorial or ecliptic systems (as e.g. \"J2000\" as the default for \"eq_FK5\" or \"B1950\" as the default for \"eq_FK4\").", null, null, null, false, false, false);
coosys.addColumn("epoch", new DBType(DBDatatype.VARCHAR), "Epoch of the positions (if necessary).", null, null, null, false, false, false);
return coosys;
}
/** /**
* <p>Get the definition of the specified standard TAP table.</p> * <p>Get the definition of the specified standard TAP table.</p>
* *
...@@ -931,14 +949,6 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour ...@@ -931,14 +949,6 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
tables.addColumn("utype", new DBType(DBDatatype.VARCHAR), "UTYPE if table corresponds to a data model", null, null, null, false, false, true); tables.addColumn("utype", new DBType(DBDatatype.VARCHAR), "UTYPE if table corresponds to a data model", null, null, null, false, false, true);
return tables; return tables;
case COOSYS:
TAPTable coosys = new TAPTable(STDSchema.TAPSCHEMA + "." + STDTable.COOSYS, TableType.table, "List of coordinate systems of coordinate columns published in this TAP service.", null);
coosys.addColumn("id", new DBType(DBDatatype.VARCHAR), "ID of the coordinate system definition as it must be in the VOTable.", null, null, null, true, true, false);
coosys.addColumn("system", new DBType(DBDatatype.VARCHAR), "The coordinate system (among \"ICRS\", \"eq_FK5\", \"eq_FK4\", \"ecl_FK4\", \"ecl_FK5\", \"galactic\", \"supergalactic\", \"xy\", \"barycentric\", \"geo_app\").", null, null, null, false, false, false);
coosys.addColumn("equinox", new DBType(DBDatatype.VARCHAR), "Required to fix the equatorial or ecliptic systems (as e.g. \"J2000\" as the default for \"eq_FK5\" or \"B1950\" as the default for \"eq_FK4\").", null, null, null, false, false, false);
coosys.addColumn("epoch", new DBType(DBDatatype.VARCHAR), "Epoch of the positions (if necessary).", null, null, null, false, false, false);
return coosys;
case COLUMNS: case COLUMNS:
TAPTable columns = new TAPTable(STDSchema.TAPSCHEMA + "." + STDTable.COLUMNS, TableType.table, "List of columns of all tables listed in TAP_SCHEMA.TABLES and published in this TAP service.", null); TAPTable columns = new TAPTable(STDSchema.TAPSCHEMA + "." + STDTable.COLUMNS, TableType.table, "List of columns of all tables listed in TAP_SCHEMA.TABLES and published in this TAP service.", null);
columns.addColumn("column_index", new DBType(DBDatatype.INTEGER), "this index is used to recommend column ordering for clients", null, null, null, false, false, true); columns.addColumn("column_index", new DBType(DBDatatype.INTEGER), "this index is used to recommend column ordering for clients", null, null, null, false, false, true);
...@@ -954,7 +964,6 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour ...@@ -954,7 +964,6 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
columns.addColumn("indexed", new DBType(DBDatatype.INTEGER), "an indexed column; 1 means true, 0 means false", null, null, null, false, false, true); columns.addColumn("indexed", new DBType(DBDatatype.INTEGER), "an indexed column; 1 means true, 0 means false", null, null, null, false, false, true);
columns.addColumn("principal", new DBType(DBDatatype.INTEGER), "a principal column; 1 means true, 0 means false", null, null, null, false, false, true); columns.addColumn("principal", new DBType(DBDatatype.INTEGER), "a principal column; 1 means true, 0 means false", null, null, null, false, false, true);
columns.addColumn("std", new DBType(DBDatatype.INTEGER), "a standard column; 1 means true, 0 means false", null, null, null, false, false, true); columns.addColumn("std", new DBType(DBDatatype.INTEGER), "a standard column; 1 means true, 0 means false", null, null, null, false, false, true);
columns.addColumn("coosys_id", new DBType(DBDatatype.VARCHAR), "ID of the used coordinate systems (if any).", null, null, null, false, false, false);
return columns; return columns;
case KEYS: case KEYS:
...@@ -1031,14 +1040,11 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour ...@@ -1031,14 +1040,11 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
* Enumeration of all tables of TAP_SCHEMA. * Enumeration of all tables of TAP_SCHEMA.
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI)
* @version 2.1 (07/2017) * @version 2.1 (09/2017)
* @since 2.0 * @since 2.0
*/ */
public enum STDTable{ public enum STDTable{
SCHEMAS("schemas"), TABLES("tables"), COLUMNS("columns"), KEYS("keys"), KEY_COLUMNS("key_columns"), SCHEMAS("schemas"), TABLES("tables"), COLUMNS("columns"), KEYS("keys"), KEY_COLUMNS("key_columns");
/** Non standard table but anyway expected by this library in order to associated coordinate columns with a coordinate system.
* @since 2.1 */
COOSYS("coosys");
/** Real name of the table. */ /** Real name of the table. */
public final String label; public final String label;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment