From b641f672e7a227e8969821a6b470d2c3993c7d31 Mon Sep 17 00:00:00 2001 From: Sonia Zorba <zorba@oats.inaf.it> Date: Thu, 1 Feb 2018 14:51:17 +0100 Subject: [PATCH] Added (a lots of) comments to code; unused methods cleanup --- .../src/main/java/it/inaf/ia2/tsm/Column.java | 2 +- .../java/it/inaf/ia2/tsm/ColumnHolder.java | 6 +- .../src/main/java/it/inaf/ia2/tsm/Key.java | 2 +- .../java/it/inaf/ia2/tsm/WrongDataType.java | 9 +- .../it/inaf/ia2/tsm/datalayer/DBBroker.java | 142 +++++++++++++++++- .../ia2/tsm/datalayer/DBBrokerFactory.java | 6 + .../ia2/tsm/datalayer/DBBrokerTemplate.java | 73 ++++++++- .../it/inaf/ia2/tsm/datalayer/DBWrapper.java | 2 +- .../inaf/ia2/tsm/datalayer/DataTypeMode.java | 12 ++ .../tsm/datalayer/mysql/MySQLDBBroker.java | 14 +- .../tsm/datalayer/pgsql/PostgresDBBroker.java | 12 +- .../it/inaf/ia2/tsm/model/ColumnModel.java | 15 +- .../tsm/model/CommaSeparatedListAdapter.java | 2 + .../it/inaf/ia2/tsm/model/DBTypeMapping.java | 16 ++ .../ia2/tsm/model/DataTypeModeAdapter.java | 2 + .../ia2/tsm/model/ModelLoadingException.java | 2 + .../it/inaf/ia2/tsm/model/SchemaModel.java | 8 + .../it/inaf/ia2/tsm/model/SchemaModels.java | 7 + .../it/inaf/ia2/tsm/model/TableModel.java | 2 + .../it/inaf/ia2/tsm/model/TypeMapping.java | 3 + .../it/inaf/ia2/tsm/model/TypesMapping.java | 108 ++++++++++--- .../java/it/inaf/ia2/tsm/model/XMLMerger.java | 10 +- .../inaf/ia2/tsm/model/XMLModelsLoader.java | 12 ++ 23 files changed, 411 insertions(+), 56 deletions(-) diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java index 5d3e208..7c461d1 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java @@ -52,7 +52,7 @@ public class Column extends ChildEntity<Table> { /** * Original datatype (computed from information_schema data), used for * consistency checking inside the method - * {@link #it.inaf.ia2.tsm.datalayer.DBBroker.getAllColumnsMetadata()} + * {@link it.inaf.ia2.tsm.datalayer.DBBroker#getAllColumnsMetadata} * * @see it.inaf.ia2.tsm.ConsistencyChecks */ diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/ColumnHolder.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/ColumnHolder.java index 431953c..71cced9 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/ColumnHolder.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/ColumnHolder.java @@ -26,8 +26,10 @@ import java.io.Serializable; import java.util.Objects; /** - * Models a column during the consistency checking phase (it is used to display - * information about columns not already loaded/added into the TAP_SCHEMA). + * Models the reference to a column in the database during the consistency + * checking phase (it is used to display information about columns not already + * loaded/added into the TAP_SCHEMA or to represent a column which doesn't exist + * yet). * * @see it.inaf.ia2.tsm.ConsistencyChecks * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Key.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Key.java index 3c652ea..6272f55 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Key.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/Key.java @@ -113,7 +113,7 @@ public class Key extends TapSchemaEntity implements Serializable { /** * Sets the identifier for this key. * - * @see {@code getId()} + * @see #getId */ public void setId(String id) { setValue(ID_KEY, id); diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/WrongDataType.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/WrongDataType.java index bc459d2..c7870e2 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/WrongDataType.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/WrongDataType.java @@ -27,8 +27,9 @@ import java.io.Serializable; /** * Models an inconsistency in a column definition detected in an existing * column. This happens when the column datatype read from the database metadata - * is different from what is expected according the {@link ColumnModel} defining - * that column. To fix this issue an {@code ALTER TABLE} is necessary. + * is different from what is expected according the + * {@link it.inaf.ia2.tsm.model.ColumnModel} defining that column. To fix this + * issue an {@code ALTER TABLE} is necessary. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -77,8 +78,8 @@ public class WrongDataType implements Serializable { } /** - * Returns the expected datatype, according to the {@link ColumnModel} - * associated to this column. + * Returns the expected datatype, according to the + * {@link it.inaf.ia2.tsm.model.ColumnModel} associated to this column. */ public String getCorrectDataType() { return correctDataType; diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBroker.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBroker.java index 0c20470..d556899 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBroker.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBroker.java @@ -57,6 +57,9 @@ public interface DBBroker { /** * Returns the name of all schemata which structure is compatible with a * TAP_SCHEMA schema structure. + * + * @param allSchemas a list of all schemata names to use for searching; + * names must be real schemata names (not renamed). */ List<String> getAllTAPSchemaNames(List<String> allSchemas) throws SQLException; @@ -65,6 +68,7 @@ public interface DBBroker { * structure (e.<!-- -->g.<!-- --> the presence of the set of columns * defined into the related XML model). * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). * @return the name of the guessed TAP_SCHEMA version. */ String detectVersion(String tapSchemaName) throws SQLException; @@ -72,11 +76,15 @@ public interface DBBroker { /** * Returns a list of all the schemata exposed by an existing TAP_SCHEMA. * Queries the {@code TAP_SCHEMA.schemas} schema. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). */ List<String> getExposedSchemas(String tapSchemaName) throws SQLException; /** * Returns all the tables owned by a schema, given its name. + * + * @param schemaName the real schema name (not the renamed one). */ List<String> getAllTablesNames(String schemaName) throws SQLException; @@ -84,6 +92,7 @@ public interface DBBroker { * Returns the table type ("table" or "view") for all the tables owned by a * schema, given its name. * + * @param schemaName the real schema name (not the renamed one). * @return a {@code Map} having table names as keys and table types as * values. */ @@ -91,13 +100,16 @@ public interface DBBroker { /** * Returns the list of the names of the columns contained in a given table. + * + * @param schemaName the real schema name (not the renamed one). + * @param tableName the name of the table. */ List<String> getAllColumnsNames(String schemaName, String tableName) throws SQLException; /** * Returns the metadata of all the columns contained in a given table. * - * @param schemaName the name of the schema. + * @param schemaName the real schema name (not the renamed one). * @param tableSimpleName the name of the table. * @param tableModel the {@link TableModel} of the owner column if it is a * TAP_SCHEMA table or the ObsCore table, null otherwise. This is used for @@ -110,37 +122,157 @@ public interface DBBroker { */ Map<String, Map<String, Object>> getAllColumnsMetadata(String schemaName, String tableSimpleName, TableModel tableModel, DataTypeMode dataTypeMode) throws SQLException; + /** + * Returns a list of all the foreign key relationships the columns of which + * are contained in a given schema. + * + * @param schemaName the schema name as exposed by the TAP_SCHEMA + * (eventually renamed). + * @param realSchemaName the real schema name (not renamed). + */ List<Key> getKeys(TapSchema tapSchema, String schemaName, String realSchemaName) throws SQLException; - List<Map<String, Object>> getSavedItems(String tapSchemaName, TableModel tableModel, String whereCondition, Object[] whereParams) throws SQLException; - + /** + * Retrieves TAP_SCHEMA items saved into an existing TAP_SCHEMA, for a given + * TAP_SCHEMA table, given its {@link TableModel}. For example, if the + * {@code TableModel} models the {@code columns} table, this method will + * return a list representing all the rows in the {@code columns} table. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param tableModel the model for the TAP_SCHEMA table to read. + * @return A {@code List} representing all the rows in a specific TAP_SCHEMA + * table. Each element of the list is a {@code Map} having column names as + * keys and row values as values. + */ List<Map<String, Object>> getSavedItems(String tapSchemaName, TableModel tableModel) throws SQLException; + /** + * Inserts a new row in a TAP_SCHEMA table. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param entity the entity to insert (this is used to specify the table to + * use and the values to insert). + * @param conn the database connection. + */ void insertItem(String tapSchemaName, TapSchemaEntity entity, Connection conn) throws SQLException; + /** + * Updates an existing row in a TAP_SCHEMA table. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param entity the entity to update (this is used to specify the table to + * use and the new values to insert). + * @param conn the database connection. + * @param whereCondition a SQL {@code WHERE} condition to add to the query. + * @param whereParams a sequence of parameters for the {@code WHERE} + * condition. + */ void updateItem(String tapSchemaName, TapSchemaEntity entity, Connection conn, String whereCondition, Object... whereParams) throws SQLException; + /** + * Creates all the tables of a TAP_SCHEMA. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param tapSchemaModel the {@link SchemaModel} used to represent the + * TAP_SCHEMA schema. + */ void createTapSchemaStructure(String tapSchemaName, SchemaModel tapSchemaModel) throws SQLException; + /** + * Creates all the tables of an ivoa schema. + * + * @param ivoaSchemaModel the {@link SchemaModel} used to represent the ivoa + * schema. + * @param realIvoaSchemaName the real name of the ivoa schema (not the + * renamed one). + */ void createIvoaSchemaStructure(SchemaModel ivoaSchemaModel, String realIvoaSchemaName) throws SQLException; + /** + * Saves all the TAP_SCHEMA modifications into the database (creates a new + * TAP_SCHEMA or update an existing one). + */ void save(TapSchema tapSchema) throws SQLException; + /** + * Create a new table into the database. + * + * @param schemaName the real schema name (not the renamed one). + * @param tableModel the {@link TableModel} representing the table to + * create. + */ void createTable(String schemaName, TableModel tableModel) throws SQLException; + /** + * Alter an existing table adding a new column. + * + * @param columnHolder a model representing a reference to a column which + * doesn't exist yet. + * @param columnModel the model used for representing the column structure. + */ void addColumn(ColumnHolder columnHolder, ColumnModel columnModel) throws SQLException; /** - * @param like is for using both the schema name and the complete table name - * in the query + * Retrieves all the keys where the {@code from_table} or + * {@code target_table} properties start by a given parameter, which must be + * a schema name or a complete table name ({@code schema_name} plus + * {@code table_name}). In this way it is possible to select keys that needs + * to be removed both if the consistency checking mechanism has detected an + * inexistent schema or an inexistent table. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param like a string representing a schema name or a table complete name + * ({@code schema_name} plus {@code table_name}). + * + * @see it.inaf.ia2.tsm.ConsistencyChecks */ Set<String> getKeysToRemove(String tapSchemaName, String like) throws SQLException; + /** + * Deletes rows from the TAP_SCHEMA. + * + * @param keysToRemoveIds a {@code Set} of all the identifiers of the keys + * to remove; the logic used to create this set is inside the + * {@link it.inaf.ia2.tsm.TapSchemaMender} class. + * + * @see it.inaf.ia2.tsm.ConsistencyChecks + * @see it.inaf.ia2.tsm.TapSchemaMender + */ void deleteUnexistingEntities(String tapSchemaName, ConsistencyChecks consistencyChecks, Set<String> keysToRemoveIds) throws SQLException; + /** + * Retrieves all the key identifiers related to an inexistent column. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param unexistingColumn a reference to the inexistent column. + * @return a {@code Set} of key identifier + * + * @see it.inaf.ia2.tsm.ConsistencyChecks + * @see it.inaf.ia2.tsm.TapSchemaMender + */ Set<String> getKeysToRemoveFromUnexistingColumn(String tapSchemaName, ColumnHolder unexistingColumn) throws SQLException; + /** + * Update the (wrong) property value of column exposed by a TAP_SCHEMA. + * + * @param tapSchemaName the real TAP_SCHEMA name (not the renamed one). + * @param completeTableName the complete name of the table + * ({@code schema_name} plus {@code table_name}). + * @param columnName the name of the column. + * @param key the name of the TAP_SCHEMA column property. + * @param value the new value. + * + * @see it.inaf.ia2.tsm.ConsistencyChecks + * @see it.inaf.ia2.tsm.TapSchemaMender + */ void updateTapSchemaColumnValue(String tapSchemaName, String completeTableName, String columnName, String key, Object value) throws SQLException; + /** + * Alter an existing TAP_SCHEMA or ObsCore column having an incoherent + * datatype according to its {@link ColumnModel}. + * + * @see it.inaf.ia2.tsm.ConsistencyChecks + * @see it.inaf.ia2.tsm.TapSchemaMender + */ void alterDataType(String schemaName, String tableName, String columnName, String adqlDataType, Integer size) throws SQLException; } diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerFactory.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerFactory.java index 73e2915..5927bd6 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerFactory.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerFactory.java @@ -26,11 +26,17 @@ import it.inaf.ia2.tsm.datalayer.mysql.MySQLDBBroker; import it.inaf.ia2.tsm.datalayer.pgsql.PostgresDBBroker; /** + * Utility class for retrieving the desired {@link DBBroker} implementation. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ public class DBBrokerFactory { + /** + * Retrieves the desired {@link DBBroker}, instantiating the proper + * implementation according to the {@link DatabaseType} defined into the + * {@link DataSourceWrapper} passed as parameter. + */ public static DBBroker getDBBroker(DataSourceWrapper dataSourceWrapper, DataTypeMode dataTypeMode) { switch (dataSourceWrapper.getDatabaseType()) { case MYSQL: diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerTemplate.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerTemplate.java index ddb3b6a..f32c6b1 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerTemplate.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBBrokerTemplate.java @@ -57,6 +57,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * Template class containing all {@link DBBroker} features that are not vendor + * specific. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -116,6 +118,9 @@ public abstract class DBBrokerTemplate implements DBBroker { sb.append(String.format("(%s)", size)); } + /** + * {@inheritDoc} + */ @Override public void createTable(String schemaName, TableModel tableModel) throws SQLException { try (Connection conn = dataSource.getConnection()) { @@ -146,6 +151,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void createTapSchemaStructure(String tapSchemaName, SchemaModel tapSchemaModel) throws SQLException { @@ -181,6 +189,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void createIvoaSchemaStructure(SchemaModel ivoaSchemaModel, String realIvoaSchemaName) throws SQLException { try (Connection conn = dataSource.getConnection()) { @@ -191,6 +202,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void save(TapSchema tapSchema) throws SQLException { @@ -408,8 +422,11 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override - public List<Map<String, Object>> getSavedItems(String tapSchemaName, TableModel tableModel, String whereCondition, Object[] whereParams) throws SQLException { + public List<Map<String, Object>> getSavedItems(String tapSchemaName, TableModel tableModel) throws SQLException { StringBuilder querySb = new StringBuilder("SELECT "); @@ -428,7 +445,6 @@ public abstract class DBBrokerTemplate implements DBBroker { querySb.append("."); querySb.append(escape(tableModel.getName())); - // TODO: Manage where condition String query = querySb.toString(); LOG.debug("Executing query {}", query); @@ -455,11 +471,6 @@ public abstract class DBBrokerTemplate implements DBBroker { } } - @Override - public List<Map<String, Object>> getSavedItems(String tapSchemaName, TableModel tableModel) throws SQLException { - return getSavedItems(tapSchemaName, tableModel, null, null); - } - private int getSQLType(Class type) { if (type == String.class) { return Types.VARCHAR; @@ -474,6 +485,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void insertItem(String tapSchemaName, TapSchemaEntity tapSchemaItem, Connection conn) throws SQLException { @@ -530,6 +544,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void updateItem(String tapSchemaName, TapSchemaEntity tapSchemaItem, Connection conn, String whereCondition, Object... whereParams) throws SQLException { @@ -587,6 +604,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract String getSchemaTablesQuery(String schemaName); + /** + * {@inheritDoc} + */ @Override public List<String> getAllTAPSchemaNames(List<String> allSchemata) throws SQLException { @@ -645,6 +665,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return allTAPSchemas; } + /** + * {@inheritDoc} + */ protected abstract String getColumnNamesQuery(String tapSchemaName, String tableName); private List<String> getColumns(String tapSchemaName, String tableName, Connection connection) throws SQLException { @@ -678,6 +701,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return true; } + /** + * {@inheritDoc} + */ @Override public String detectVersion(String tapSchemaName) throws SQLException { @@ -706,6 +732,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract String getTableTypesQuery(String schemaName); + /** + * {@inheritDoc} + */ @Override public Map<String, String> getAllTableTypes(String schemaName) throws SQLException { LOG.debug("getTablesTypes"); @@ -728,6 +757,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return tablesTypes; } + /** + * {@inheritDoc} + */ @Override public List<String> getExposedSchemas(String tapSchemaName) throws SQLException { @@ -750,6 +782,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract String getAllSchemaNamesQuery(); + /** + * {@inheritDoc} + */ @Override public List<String> getAllSchemaNames() throws SQLException { String query = getAllSchemaNamesQuery(); @@ -761,6 +796,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract String getAllTablesNamesQuery(String schemaName); + /** + * {@inheritDoc} + */ @Override public List<String> getAllTablesNames(String schemaName) throws SQLException { String query = getAllTablesNamesQuery(schemaName); @@ -770,6 +808,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return allTables; } + /** + * {@inheritDoc} + */ @Override public List<String> getAllColumnsNames(String schemaName, String tableName) throws SQLException { String query = getColumnNamesQuery(schemaName, tableName); @@ -780,6 +821,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract Map<String, Map<String, Object>> getAllColumnsOriginalMetadata(String schemaName, String tableName) throws SQLException; + /** + * {@inheritDoc} + */ @Override public Map<String, Map<String, Object>> getAllColumnsMetadata(String schemaName, String tableName, TableModel tableModel, DataTypeMode dataTypeMode) throws SQLException { @@ -812,6 +856,9 @@ public abstract class DBBrokerTemplate implements DBBroker { protected abstract String getDataTypeFromADQLType(String adqlType); + /** + * {@inheritDoc} + */ @Override public void addColumn(ColumnHolder columnHolder, ColumnModel columnModel) throws SQLException { @@ -832,6 +879,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public Set<String> getKeysToRemove(String tapSchemaName, String like) throws SQLException { @@ -855,6 +905,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return keysId; } + /** + * {@inheritDoc} + */ @Override public Set<String> getKeysToRemoveFromUnexistingColumn(String tapSchemaName, ColumnHolder unexistingColumn) throws SQLException { @@ -895,6 +948,9 @@ public abstract class DBBrokerTemplate implements DBBroker { return keysToRemoveIds; } + /** + * {@inheritDoc} + */ @Override public void deleteUnexistingEntities(String tapSchemaName, ConsistencyChecks consistencyChecks, Set<String> keysToRemoveIds) throws SQLException { try (Connection conn = dataSource.getConnection()) { @@ -995,6 +1051,9 @@ public abstract class DBBrokerTemplate implements DBBroker { } } + /** + * {@inheritDoc} + */ @Override public void updateTapSchemaColumnValue(String tapSchemaName, String completeTableName, String columnName, String key, Object value) throws SQLException { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBWrapper.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBWrapper.java index 70a6385..5d80baf 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBWrapper.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DBWrapper.java @@ -37,7 +37,7 @@ import org.slf4j.LoggerFactory; * {@code ObsCore} table, is stored into the source database (because one could * perform SQL JOINS between astronomical data schemata and the ObsCore table). * <p> - * An user asks, for example, {@link getSourceDataSource()}, and the + * An user asks, for example, {@link #getSourceDataSource()}, and the * {@code DBWrapper} returns the correct {@code DataSource}, both if it is * separated from the TAP_SCHEMA {@code DataSource} or if they are the same * object. diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataTypeMode.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataTypeMode.java index 20b9da0..7b49c41 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataTypeMode.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataTypeMode.java @@ -23,12 +23,24 @@ package it.inaf.ia2.tsm.datalayer; /** + * This enum is used to specify the syntax used by a TAP_SCHEMA for representing + * the data types. + * <p> + * The {@code DataTypeMode} for a given TAP_SCHEMA is specified into the XML + * configuration as an attribute of the schema element. * + * @see it.inaf.ia2.tsm.model.SchemaModel * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ public enum DataTypeMode { + /** + * For TAP 1.0: VARCHAR, SMALLINT, INTEGER, BIGINT, BLOB, ... + */ ADQL("ADQL"), + /** + * For TAP 1.1: char, short, int, long, unsignedByte, ... + */ VOTABLE("VOTable"); private final String name; diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/mysql/MySQLDBBroker.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/mysql/MySQLDBBroker.java index 2cc1204..a27550d 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/mysql/MySQLDBBroker.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/mysql/MySQLDBBroker.java @@ -44,7 +44,8 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * MySQL implementation of a {@link it.inaf.ia2.tsm.datalayer.DBBroker}. + * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ public class MySQLDBBroker extends DBBrokerTemplate { @@ -91,6 +92,9 @@ public class MySQLDBBroker extends DBBrokerTemplate { return null; } + /** + * {@inheritDoc} + */ @Override public Map<String, Map<String, Object>> getAllColumnsOriginalMetadata(String schemaName, String tableName) throws SQLException { @@ -124,7 +128,7 @@ public class MySQLDBBroker extends DBBrokerTemplate { // Datatype and Size String dbType = resultSet.getString("Type").toUpperCase(); - ADQL adqlType = TypesMapping.getADQLFromDBType(dbType); + ADQL adqlType = TypesMapping.getADQLFromMySQLType(dbType); String datatype = TypesMapping.getDataTypeFromMySQLType(dbType, getDataTypeMode()); Integer size = getSize(dbType); @@ -210,6 +214,9 @@ public class MySQLDBBroker extends DBBrokerTemplate { buildColumnsList(fromKeyColumns), escape(tapSchemaName), escape(targetTableName), buildColumnsList(toKeyColumns)); } + /** + * {@inheritDoc} + */ @Override public List<Key> getKeys(TapSchema tapSchema, String schemaName, String realSchemaName) throws SQLException { StringBuilder sb = new StringBuilder(); @@ -292,6 +299,9 @@ public class MySQLDBBroker extends DBBrokerTemplate { return "SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = '" + schemaName + "'"; } + /** + * {@inheritDoc} + */ @Override public void alterDataType(String schemaName, String tableName, String columnName, String adqlDataType, Integer size) throws SQLException { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/pgsql/PostgresDBBroker.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/pgsql/PostgresDBBroker.java index e4237e1..d5f2d89 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/pgsql/PostgresDBBroker.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/pgsql/PostgresDBBroker.java @@ -46,6 +46,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * PostgreSQL implementation of a {@link it.inaf.ia2.tsm.datalayer.DBBroker}. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -207,6 +208,9 @@ public class PostgresDBBroker extends DBBrokerTemplate { return sb.toString(); } + /** + * {@inheritDoc} + */ @Override public Map<String, Map<String, Object>> getAllColumnsOriginalMetadata(String schemaName, String tableSimpleName) throws SQLException { @@ -275,7 +279,7 @@ public class PostgresDBBroker extends DBBrokerTemplate { arraydimension = resultSet.getInt("arraydim"); } - ADQL adqlType = TypesMapping.getADQLFromDBType(dbType); + ADQL adqlType = TypesMapping.getADQLFromPostgresType(dbType); String datatype = TypesMapping.getDataTypeFromPostgresType(dbType, getDataTypeMode()); if (!isArray && (ADQL.VARCHAR.equals(adqlType) || ADQL.CHAR.equals(adqlType))) { @@ -304,6 +308,9 @@ public class PostgresDBBroker extends DBBrokerTemplate { return allColumnsMetadata; } + /** + * {@inheritDoc} + */ @Override public List<Key> getKeys(TapSchema tapSchema, String schemaName, String realSchemaName) throws SQLException { @@ -448,6 +455,9 @@ public class PostgresDBBroker extends DBBrokerTemplate { return String.format("SELECT tablename FROM pg_catalog.pg_tables where schemaname = '%s'", schemaName); } + /** + * {@inheritDoc} + */ @Override public void alterDataType(String schemaName, String tableName, String columnName, String adqlDataType, Integer size) throws SQLException { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ColumnModel.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ColumnModel.java index 2317fcb..356bb39 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ColumnModel.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ColumnModel.java @@ -30,7 +30,8 @@ import javax.xml.bind.annotation.XmlTransient; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** - * Models a database column managed by TASMAN. + * JAXB model for the structure and the behavior of a database column which is + * created and edited by TASMAN. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -150,7 +151,7 @@ public class ColumnModel implements Serializable { } /** - * Specify the column default value. + * Specifies the column default value. */ @XmlElement(name = "default-value") public String getDefaultValueString() { @@ -248,7 +249,7 @@ public class ColumnModel implements Serializable { } /** - * Define the minimum value allowed for the column. + * Defines the minimum value allowed for the column. */ @XmlElement(name = "min", nillable = true, required = false) public Integer getMinValue() { @@ -260,7 +261,7 @@ public class ColumnModel implements Serializable { } /** - * Define the maximum value allowed for the column. + * Defines the maximum value allowed for the column. */ @XmlElement(name = "max", nillable = true, required = false) public Integer getMaxValue() { @@ -272,18 +273,18 @@ public class ColumnModel implements Serializable { } /** - * Retrieve the default value. + * Retrieves the default value. */ @XmlTransient public Object getDefaultValue() { if (defaultValueString == null) { return null; } - return TypesMapping.parseDefaultValue(defaultValueString, getType()); + return TypesMapping.parseTypedValue(defaultValueString, getType()); } /** - * Retrieve the Java type from the column datatype. + * Retrieves the Java type from the column datatype. */ @XmlTransient public Class getJavaType() { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/CommaSeparatedListAdapter.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/CommaSeparatedListAdapter.java index 450e734..62d73e5 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/CommaSeparatedListAdapter.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/CommaSeparatedListAdapter.java @@ -27,6 +27,8 @@ import java.util.List; import javax.xml.bind.annotation.adapters.XmlAdapter; /** + * JAXB adapter for marshalling and unmarshalling a String containing a comma + * separated list of values in an instance of {@code List<String>}. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DBTypeMapping.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DBTypeMapping.java index 7d827f6..22914e6 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DBTypeMapping.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DBTypeMapping.java @@ -29,7 +29,10 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; /** + * JAXB model containing information about a vendor-specific RDBMS datatype. The + * name of the tag ("mysql" or "pgsql") identify the kind of database. * + * @see TypesMapping * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ public class DBTypeMapping { @@ -41,6 +44,15 @@ public class DBTypeMapping { types = new ArrayList<>(); } + /** + * Tells if the {@link TypeMapping} having this element as a child must be + * used to convert the vendor-specific datatype into a datatype used by + * TASMAN. + * <p> + * This is necessary because there could be more ADQL types mapping to the + * same database type (e.g. Postgres bytea datatype is used both for ADQL, + * BLOB, BINARY and VARBINARY data types). + */ @XmlAttribute(name = "inverse") public boolean isInverse() { return inverse; @@ -50,6 +62,10 @@ public class DBTypeMapping { this.inverse = inverse; } + /** + * Returns a list of datatype names that are considered synonymous by + * TASMAN. + */ @XmlElements({ @XmlElement(name = "type") }) diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DataTypeModeAdapter.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DataTypeModeAdapter.java index 02fcd4e..fa21199 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DataTypeModeAdapter.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/DataTypeModeAdapter.java @@ -26,6 +26,8 @@ import it.inaf.ia2.tsm.datalayer.DataTypeMode; import javax.xml.bind.annotation.adapters.XmlAdapter; /** + * JAXB adapter for converting a string into a {@link DataTypeMode} enum + * allowing null values. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ModelLoadingException.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ModelLoadingException.java index d50d247..fc8380c 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ModelLoadingException.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/ModelLoadingException.java @@ -23,6 +23,8 @@ package it.inaf.ia2.tsm.model; /** + * Exception thrown if there are problems in loading TASMAN XML configuration + * files. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModel.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModel.java index f82241e..cff9ec7 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModel.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModel.java @@ -33,6 +33,7 @@ import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; /** + * JAXB model for defining a schema which is created and edited by TASMAN. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -73,6 +74,9 @@ public class SchemaModel implements Serializable { this.version = version; } + /** + * The version from which this model inherits its structure. + */ @XmlAttribute(name = "extends") public String getExtendsFrom() { return extendsFrom; @@ -107,6 +111,10 @@ public class SchemaModel implements Serializable { return null; } + /** + * The format used for representing data types (used only for TAP_SCHEMA + * models). + */ @XmlAttribute(name = "datatype") @XmlJavaTypeAdapter(DataTypeModeAdapter.class) public DataTypeMode getDataTypeMode() { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModels.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModels.java index 6a6fcf3..b8290d1 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModels.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/SchemaModels.java @@ -31,6 +31,7 @@ import java.util.Map; import java.util.Properties; /** + * Utility class for retrieving models of schemata managed by TASMAN. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -86,6 +87,12 @@ public class SchemaModels { return TAP_SCHEMA_MODELS.values(); } + /** + * Returns the {@link TableModel} of TAP_SCHEMA table. + * + * @param tableName the name of the table. + * @param version TAP_SCHEMA version. + */ public static TableModel getTapSchemaTableModel(String tableName, String version) { return getTapSchemaModel(version).getTable(tableName); } diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TableModel.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TableModel.java index b63fab6..5372831 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TableModel.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TableModel.java @@ -30,6 +30,8 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElements; /** + * JAXB model for a table which is created and edited by TASMAN, like TAP_SCHEMA + * tables or ObsCore. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypeMapping.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypeMapping.java index eba8e4b..c260e68 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypeMapping.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypeMapping.java @@ -26,7 +26,10 @@ import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; /** + * JAXB representation of a mapping between datatype using different + * syntaxes/languages. * + * @see TypesMapping * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ public class TypeMapping { diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypesMapping.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypesMapping.java index 484b480..4185534 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypesMapping.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/TypesMapping.java @@ -33,6 +33,9 @@ import javax.xml.bind.annotation.XmlElements; import javax.xml.bind.annotation.XmlRootElement; /** + * Utility class for converting data types having different syntaxes. + * <p> + * It parses the sql_type_mapping.xml resource file. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -76,6 +79,9 @@ public class TypesMapping { return null; } + /** + * Converts an ADQL datatype into a Java type. + */ public static Class getClassFromAdqlType(String adqlType) { TypeMapping typeMapping = getTypeMappingFromADQLType(adqlType); if (typeMapping == null) { @@ -84,6 +90,9 @@ public class TypesMapping { return typeMapping.getJavaType(); } + /** + * Converts an ADQL datatype to MySQL datatype. + */ public static String getMySQLTypeFromADQLType(String adqlType) { TypeMapping typeMapping = getTypeMappingFromADQLType(adqlType); if (typeMapping == null) { @@ -92,6 +101,9 @@ public class TypesMapping { return typeMapping.getMySQLMapping().getTypes().get(0); } + /** + * Converts an ADQL datatype to PostgreSQL datatype. + */ public static String getPostgresSQLTypeFromADQLType(String adqlType) { TypeMapping typeMapping = getTypeMappingFromADQLType(adqlType); if (typeMapping == null) { @@ -100,6 +112,15 @@ public class TypesMapping { return typeMapping.getPgsqlMapping().getTypes().get(0); } + /** + * Returns the correct datatype according to the {@link DataTypeMode} used + * by a TAP_SCHEMA. + * + * @param adqlType the datatype in ADQL format; this format is used in XML + * configuration files contained into the {@code schema_definition} + * resources folder. + * @param mode the {@code DataTypeMode} used by the TAP_SCHEMA. + */ public static String getDataType(String adqlType, DataTypeMode mode) { switch (mode) { case ADQL: @@ -111,6 +132,13 @@ public class TypesMapping { } } + /** + * Retrieves the {@code TypeMapping} for a datatype expressed in the mode + * used by a given TAP_SCHEMA. + * + * @param dataType the datatype, as exposed by the TAP_SCHEMA. + * @param mode the {@code DataTypeMode} used by the TAP_SCHEMA. + */ public static TypeMapping getTypeMapping(String dataType, DataTypeMode mode) { for (TypeMapping typeMapping : TYPES) { switch (mode) { @@ -179,6 +207,28 @@ public class TypesMapping { } } + /** + * Retrieves a datatype having the format required by a given TAP_SCHEMA + * from a MySQL datatype. + * + * @param mode the {@code DataTypeMode} used by the TAP_SCHEMA. + */ + public static String getDataTypeFromMySQLType(String mysqlType, DataTypeMode mode) { + + return (new DataTypeFromDBTypeMapper(mode) { + @Override + DBTypeMapping getDBTypeMapping(TypeMapping typeMapping) { + return typeMapping.getMySQLMapping(); + } + }).getDataTypeFromDBType(mysqlType); + } + + /** + * Retrieves a datatype having the format required by a given TAP_SCHEMA + * from a PostrgreSQL datatype. + * + * @param mode the {@code DataTypeMode} used by the TAP_SCHEMA. + */ public static String getDataTypeFromPostgresType(String pgsqlType, DataTypeMode mode) { return (new DataTypeFromDBTypeMapper(mode) { @@ -189,45 +239,55 @@ public class TypesMapping { }).getDataTypeFromDBType(pgsqlType); } - public static ADQL getADQLFromDBType(String dbType) { + /** + * Converts a MySQL datatype to an ADQL datatype. + * + * @param mysqlDBType the datatype, as read from MySQL information_schema. + */ + public static ADQL getADQLFromMySQLType(String mysqlDBType) { try { - return ADQL.valueOf(TypesMapping.getDataTypeFromPostgresType(dbType, DataTypeMode.ADQL)); + return ADQL.valueOf(getDataTypeFromMySQLType(mysqlDBType, DataTypeMode.ADQL)); } catch (IllegalArgumentException e) { return null; } } - public static String getDataTypeFromMySQLType(String mysqlType, DataTypeMode mode) { - - return (new DataTypeFromDBTypeMapper(mode) { - @Override - DBTypeMapping getDBTypeMapping(TypeMapping typeMapping) { - return typeMapping.getMySQLMapping(); - } - }).getDataTypeFromDBType(mysqlType); - } - - public static Object parseDefaultValue(String defaultValue, String type) { - return parseDefaultValue(defaultValue, ADQL.valueOf(type)); + /** + * Converts a PostgreSQL datatype to an ADQL datatype. + * + * @param postgresDBType the datatype, as read from PostgreSQL + * information_schema. + */ + public static ADQL getADQLFromPostgresType(String postgresDBType) { + try { + return ADQL.valueOf(getDataTypeFromPostgresType(postgresDBType, DataTypeMode.ADQL)); + } catch (IllegalArgumentException e) { + return null; + } } - public static Object parseDefaultValue(String defaultValue, ADQL type) { - - switch (type) { + /** + * Parses a string converting it in a typed object according to the datatype + * specified in ADQL format. + * + * @param type datatype in ADQL format + */ + public static Object parseTypedValue(String value, String type) { + switch (ADQL.valueOf(type)) { case BOOLEAN: - return Boolean.parseBoolean(defaultValue); + return Boolean.parseBoolean(value); case SMALLINT: - return Short.parseShort(defaultValue); + return Short.parseShort(value); case INTEGER: - return Integer.parseInt(defaultValue); + return Integer.parseInt(value); case BIGINT: - return Long.parseLong(defaultValue); + return Long.parseLong(value); case REAL: - return Float.parseFloat(defaultValue); + return Float.parseFloat(value); case DOUBLE: - return Double.parseDouble(defaultValue); + return Double.parseDouble(value); default: - return defaultValue; + return value; } } } diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLMerger.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLMerger.java index d0ca8bd..bd979bd 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLMerger.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLMerger.java @@ -37,6 +37,7 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; /** + * Performs inheritance between TASMAN schema definition XML files. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -47,7 +48,11 @@ public class XMLMerger { private final Document parentDoc; private final Document childDoc; - XMLMerger(Document parentDoc, Document childDoc) throws ParserConfigurationException { + /** + * @param parentDoc the parent XML schema definition + * @param childDoc the XML schema definition which inherits from parent + */ + public XMLMerger(Document parentDoc, Document childDoc) throws ParserConfigurationException { // Cloning parent document this.parentDoc = cloneDocument(parentDoc); this.childDoc = childDoc; @@ -63,6 +68,9 @@ public class XMLMerger { return clonedDocument; } + /** + * Returns an XML document which is the result of the document inheritance. + */ public Document getMergedDocument() { Element root = parentDoc.getDocumentElement(); diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLModelsLoader.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLModelsLoader.java index 017f8af..89a337c 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLModelsLoader.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/XMLModelsLoader.java @@ -42,6 +42,8 @@ import org.w3c.dom.Element; import org.xml.sax.SAXException; /** + * Class used to parse TASMAN XML configuration files used to defining schemata + * structure and convert them into instances of {@link SchemaModel}. * * @author Sonia Zorba {@literal <zorba at oats.inaf.it>} */ @@ -62,10 +64,20 @@ public class XMLModelsLoader { inheritanceLevels = new HashMap<>(); } + /** + * Loads the XML files and obtains schemata models. + * + * @return a {@code Map} having versions as keys and {@link SchemaModel}s + * as values. + */ public Map<String, SchemaModel> load() { return load(XMLModelsLoader.class.getClassLoader()); } + /** + * This variant is used for testing (specifying a {@code ClassLoader} it is + * possible to use test resource files instead of real application files). + */ public Map<String, SchemaModel> load(ClassLoader classLoader) { try { -- GitLab