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

[TAP] Fix the TAP_SCHEMA mapping.

When defining in the configuration file a different name for TAP_SCHEMA content,
the service implementor was also forced to define the same mapping in the
database with the column `dbName`.

This is no longer necessary. From now on, the `dbName` column will be ignored
for all standard TAP_SCHEMA content. Instead, the name specified in the
configuration file (if any) will be used instead. This way, the mapping for
standard TAP_SCHEMA content is only specified once and at only one place:
the configuration file.

_This commit resolves the GitHub issue #98_
parent bad46063
Loading
Loading
Loading
Loading
+32 −15
Original line number Diff line number Diff line
@@ -1042,6 +1042,10 @@ public class JDBCConnection implements DBConnection {
					newSchema.setDBName(dbName);
				newSchema.setIndex(schemaIndex);

				// force the dbName of TAP_SCHEMA to be the same as the used one:
				if (STDSchema.TAPSCHEMA.label.equalsIgnoreCase(schemaName))
					newSchema.setDBName(tableDef.getDBSchemaName());

				// add the new schema inside the given metadata:
				metadata.addSchema(newSchema);
			}
@@ -1146,7 +1150,8 @@ public class JDBCConnection implements DBConnection {
				if (typeStr != null){
					try{
						type = TableType.valueOf(typeStr.toLowerCase());
					}catch(IllegalArgumentException iae){}
					}catch(IllegalArgumentException iae){
					}
				}

				// create the new table:
@@ -1154,6 +1159,13 @@ public class JDBCConnection implements DBConnection {
				newTable.setDBName(dbName);
				newTable.setIndex(tableIndex);

				// force the dbName of TAP_SCHEMA table to be the same as the used one:
				if (STDSchema.TAPSCHEMA.label.equalsIgnoreCase(schemaName)){
					String simpleTableName = (endPrefix > 0) ? tableName.substring(endPrefix + 1) : tableName;
					if (tableDef.getSchema() != null && tableDef.getSchema().getTable(simpleTableName) != null)
						newTable.setDBName(tableDef.getSchema().getTable(simpleTableName).getDBName());
				}

				// add the new table inside its corresponding schema:
				schema.addTable(newTable);
				lstTables.add(newTable);
@@ -1349,7 +1361,8 @@ public class JDBCConnection implements DBConnection {
				if (datatype != null){
					try{
						tapDatatype = DBDatatype.valueOf(datatype.toUpperCase());
					}catch(IllegalArgumentException iae){}
					}catch(IllegalArgumentException iae){
					}
				}
				// ...build the column type:
				DBType type;
@@ -1381,6 +1394,10 @@ public class JDBCConnection implements DBConnection {
					}
				}

				// force the dbName of TAP_SCHEMA column to be the same as the used one:
				if (STDSchema.TAPSCHEMA.label.equalsIgnoreCase(table.getADQLSchemaName()) && tableDef.getSchema() != null && tableDef.getSchema().getTable(table.getADQLName()) != null && tableDef.getSchema().getTable(table.getADQLName()).getColumn(columnName) != null)
					newColumn.setDBName(tableDef.getSchema().getTable(table.getADQLName()).getColumn(columnName).getDBName());

				// add the new column inside its corresponding table:
				table.addColumn(newColumn);
			}