Commit 03d03c50 authored by Grégory Mantelet's avatar Grégory Mantelet
Browse files

[ADQL,TAP] + isCaseSensitive() in DBSchema, DBTable and DBColumn + Change rules

about TAP_SCHEMA columns `schema_name`, `table_name` and `column_name`
(see tap_schema_requirements.md for more details).
parent c8782d4d
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ dependencies {

    testCompile 'junit:junit:4.12'
    testCompile 'com.h2database:h2:1.4.193'
    testCompile fileTree(dir: 'lib', include: 'astroh2-0.3.jar')
    testCompile fileTree(dir: 'lib', include: 'astroh2-0.4.jar')
    testCompile 'org.slf4j:slf4j-simple:1.7.25'
    
    testRuntime 'simple-jndi:simple-jndi:0.11.4.1'

lib/astroh2-0.3.jar

deleted100644 → 0
−15.9 KiB

File deleted.

lib/astroh2-0.4.jar

0 → 100644
+16.7 KiB

File added.

No diff preview for this file type.

+32 −19
Original line number Diff line number Diff line
@@ -16,20 +16,21 @@ package adql.db;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2011-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2011-2019 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

/**
 * <p>Definition of a valid target column.</p>
 * Definition of a valid target column.
 *
 * <p>
 * 	This column can be used in an ADQL query with its ADQL name ({@link #getADQLName()})
 * 	and corresponds to a real column in the "database" with its DB name ({@link #getDBName()}).
 * 	This column can be used in an ADQL query with its ADQL name
 * 	({@link #getADQLName()}) and corresponds to a real column in the "database"
 * 	with its DB name ({@link #getDBName()}).
 * </p>
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 1.4 (07/2016)
 * @version 2.0 (09/2019)
 */
public interface DBColumn {

@@ -40,6 +41,18 @@ public interface DBColumn {
	 */
	public String getADQLName();

	/**
	 * Tell whether the column name used in ADQL queries must be delimited
	 * (i.e. surrounded by <code>"</code>). In such case, it will be case
	 * sensitive.
	 *
	 * @return	<code>true</code> if the ADQL column name is case sensitive,
	 *        	<code>false</code> otherwise.
	 *
	 * @since 2.0
	 */
	public boolean isCaseSensitive();

	/**
	 * Gets the name of this column in the "database".
	 *
+93 −56
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@ package adql.db;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
 * Copyright 2014-2019 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

import java.util.ArrayList;
@@ -26,15 +27,19 @@ import adql.db.exception.UnresolvedJoinException;
import adql.query.ADQLQuery;

/**
 * This is a special column which exists only after a NATURAL JOIN or a JOIN ... USING between two tables.
 * It lets unify several columns of the joined tables in a single column.
 * 
 * Thus, the writer of an ADQL query can use the column name without table prefix (since after the join there will be only one)
 * or with a prefix table of the joined tables. The list of all covered tables is stored in this object and can be extended
 * in case of several JOINs.
 * 
 * @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
 * @version 1.3 (05/2015)
 * This is a special column which exists only after a NATURAL JOIN or
 * a JOIN ... USING between two tables. It lets unify several columns of the
 * joined tables in a single column.
 *
 * <p>
 * 	Thus, the writer of an ADQL query can use the column name without table
 * 	prefix (since after the join there will be only one) or with a prefix table
 * 	of the joined tables. The list of all covered tables is stored in this
 * 	object and can be extended in case of several JOINs.
 * </p>
 *
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 2.0 (09/2019)
 * @since 1.2
 */
public class DBCommonColumn implements DBColumn {
@@ -45,18 +50,33 @@ public class DBCommonColumn implements DBColumn {
	/**
	 * Create a column which merges both of the given columns.
	 *
	 * This special {@link DBColumn} implementation is not associated with one table,
	 * and can be listed in a {@link DBTable} ONLY IF the latter is the result of a sub-query (see {@link ADQLQuery#getResultingColumns()}).
	 * 
	 * A column resulting from a tables join is common only to the joined tables. That's why a list of all tables covered
	 * by this column is created or update at each merge. It can be accessed thanks to {@link #getCoveredTables()}.
	 * 
	 * Note: In the case one or both of the columns to join are {@link DBCommonColumn}, the list of their covered tables are also merged.
	 * 
	 * @param leftCol	Column of the left join table. May be a {@link DBCommonColumn}.
	 * @param rightCol	Column of the right join table. May be a {@link DBCommonColumn}.
	 * 
	 * @throws UnresolvedJoinException	If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
	 * <p>
	 * 	This special {@link DBColumn} implementation is not associated with one
	 * 	table, and can be listed in a {@link DBTable} ONLY IF the latter is the
	 * 	result of a sub-query (see {@link ADQLQuery#getResultingColumns()}).
	 * </p>
	 *
	 * <p>
	 * 	A column resulting from a tables join is common only to the joined
	 * 	tables. That's why a list of all tables covered by this column is
	 * 	created or update at each merge. It can be accessed thanks to
	 * 	{@link #getCoveredTables()}.
	 * </p>
	 *
	 * <p><i><b>Note:</b>
	 * 	In the case one or both of the columns to join are
	 * 	{@link DBCommonColumn}, the list of their covered tables are also
	 * 	merged.
	 * </i></p>
	 *
	 * @param leftCol	Column of the left join table.
	 *               	May be a {@link DBCommonColumn}.
	 * @param rightCol	Column of the right join table.
	 *               	May be a {@link DBCommonColumn}.
	 *
	 * @throws UnresolvedJoinException	If the type of the two given columns are
	 *                                	not roughly (just testing numeric,
	 *                                	string or geometry) compatible.
	 */
	public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoinException {
		// Test whether type of both columns are compatible:
@@ -95,7 +115,9 @@ public class DBCommonColumn implements DBColumn {
	 * Constructor by copy.
	 * It returns a copy of this instance of {@link DBCommonColumn}.
	 *
	 * Note: The list of covered tables is NOT deeply copied!
	 * <p><i><b>Note:</b>
	 * 	The list of covered tables is NOT deeply copied!
	 * </i></p>
	 *
	 * @param toCopy	The {@link DBCommonColumn} to copy.
	 * @param dbName	The new DB name of this {@link DBCommonColumn}.
@@ -112,6 +134,11 @@ public class DBCommonColumn implements DBColumn {
		return generalColumnDesc.getADQLName();
	}

	@Override
	public final boolean isCaseSensitive() {
		return generalColumnDesc.isCaseSensitive();
	}

	@Override
	public final String getDBName() {
		return generalColumnDesc.getDBName();
@@ -128,7 +155,8 @@ public class DBCommonColumn implements DBColumn {
	}

	/**
	 * Get an iterator over the list of all tables covered by this common column.
	 * Get an iterator over the list of all tables covered by this common
	 * column.
	 *
	 * @return	Iterator over all covered tables.
	 */
@@ -139,7 +167,9 @@ public class DBCommonColumn implements DBColumn {
	/**
	 * Add a table that this common column must cover from now.
	 *
	 * Warning: no unicity check is never done !
	 * <p><i><b>Warning:</b>
	 * 	No unicity check is never done!
	 * </i></p>
	 *
	 * @param table	Table to add in the covered tables list.
	 */
@@ -149,16 +179,23 @@ public class DBCommonColumn implements DBColumn {
	}

	/**
	 * WARNING: This copy function does not make a real copy of this DBCommonColumn !
	 *          It returns a modified copy of the general column description it contains.
	 * <p><i><b>WARNING:</b>
	 * 	This copy function does not make a real copy of this DBCommonColumn!
	 * 	It returns a modified copy of the general column description it
	 * 	contains.
	 * </i></p>
	 *
	 * Note: To make a real copy of this DBCommonColumn use the Constructor by copy {@link #DBCommonColumn(DBCommonColumn, String, String)}.
	 * <p><i><b>Note:</b>
	 * 	To make a real copy of this DBCommonColumn use the Constructor by copy
	 * 	{@link #DBCommonColumn(DBCommonColumn, String, String)}.
	 * </i></p>
	 *
	 * @param dbName	Its new DB name.
	 * @param adqlName	Its new ADQL name.
	 * @param dbTable	Its new DBTable
	 *
	 * @return			A modified copy of the general column description this common column represents.
	 * @return	A modified copy of the general column description this common
	 *        	column represents.
	 *
	 * @see adql.db.DBColumn#copy(java.lang.String, java.lang.String, adql.db.DBTable)
	 */
Loading