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
Loading
Loading
Loading
Loading
+20 −17
Original line number Diff line number Diff line
@@ -903,6 +903,7 @@ public class JDBCConnection implements DBConnection {
	 * <ol>
	 * 	<li>{@link #loadSchemas(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 #loadKeys(TAPTable, TAPTable, List, Statement)}</li>
	 * </ol>
@@ -942,10 +943,15 @@ public class JDBCConnection implements DBConnection {

			// load all coordinate systems from TAP_SCHEMA.coosys: [non standard]
			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)
					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:
@@ -1189,9 +1195,8 @@ public class JDBCConnection implements DBConnection {
			// Create all coosys:
			HashMap<String,TAPCoosys> mapCoosys = new HashMap<String,TAPCoosys>();
			while(rs.next()){
				String coosysId = rs.getString(1),
						system = rs.getString(2), equinox = rs.getString(3),
						epoch = rs.getString(4);
				String coosysId = rs.getString(1), system = rs.getString(2),
						equinox = rs.getString(3), epoch = rs.getString(4);

				// create the new coosys:
				TAPCoosys newCoosys = new TAPCoosys(coosysId, system, nullifyIfNeeded(equinox), nullifyIfNeeded(epoch));
@@ -1211,8 +1216,6 @@ public class JDBCConnection implements DBConnection {
		}
	}



	/**
	 * <p>Load into the corresponding tables all columns listed in TAP_SCHEMA.columns.</p>
	 *
+20 −14
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ import javax.servlet.http.HttpServletResponse;
import adql.db.DBTable;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;
import tap.db.JDBCConnection;
import tap.metadata.TAPTable.TableType;
import tap.resource.Capabilities;
import tap.resource.TAPResource;
@@ -892,6 +893,23 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
		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>
	 * 
@@ -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);
				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:
				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);
@@ -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("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("coosys_id", new DBType(DBDatatype.VARCHAR), "ID of the used coordinate systems (if any).", null, null, null, false, false, false);
				return columns;

			case KEYS:
@@ -1031,14 +1040,11 @@ public class TAPMetadata implements Iterable<TAPSchema>, VOSIResource, TAPResour
	 * Enumeration of all tables of TAP_SCHEMA.
	 * 
	 * @author Gr&eacute;gory Mantelet (ARI)
	 * @version 2.1 (07/2017)
	 * @version 2.1 (09/2017)
	 * @since 2.0
	 */
	public enum STDTable{
		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");
		SCHEMAS("schemas"), TABLES("tables"), COLUMNS("columns"), KEYS("keys"), KEY_COLUMNS("key_columns");

		/** Real name of the table. */
		public final String label;