Loading TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java +18 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.TableModel; import it.inaf.ia2.tsm.model.TypesMapping; import java.util.Objects; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -63,6 +65,22 @@ public class Column extends ChildEntity<Table> { setStatus(Status.LOADED); } private void overrideDataTypeFromModels() { Schema parentSchema = parentTable.getParent(); String type = null; if (tapSchema.getName().equals(parentSchema.getName())) { TableModel tableModel = tapSchema.getTapSchemaModel().get(parentTable.getName()); type = tableModel.get(getName()).getType(); } if (type != null) { String compatibleType = TypesMapping.getCompatibleADQLType(type, tapSchema.getVersion()); getProperty(DATATYPE_KEY).init(compatibleType); } } public Key getForeignKey() { if (!foreignKeySearched) { // lazy loading (but the foreignKey value can be null, so we use this boolean) Loading TASMAN-core/src/main/java/it/inaf/ia2/tsm/EntityProperty.java +3 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import java.io.Serializable; /** Loading @@ -35,7 +35,7 @@ public class EntityProperty<T> implements Serializable { private static final long serialVersionUID = 6735553751078589085L; private PropertyModel propertyModel; private ColumnModel propertyModel; private Class<T> type; private T originalValue; private T value; Loading @@ -44,7 +44,7 @@ public class EntityProperty<T> implements Serializable { private EntityProperty() { } public EntityProperty(PropertyModel propertyModel, T defaultValue) { public EntityProperty(ColumnModel propertyModel, T defaultValue) { this.propertyModel = propertyModel; this.type = propertyModel.getJavaType(); this.init(defaultValue); Loading TASMAN-core/src/main/java/it/inaf/ia2/tsm/Table.java +13 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.datalayer.DBBroker; import it.inaf.ia2.tsm.model.TableModel; import java.sql.SQLException; import java.util.List; import java.util.Map; Loading Loading @@ -56,6 +57,17 @@ public class Table extends ChildEntity<Schema> implements EntitiesContainer<Colu super(); } private TableModel getModel() { if (tapSchema.getName().equals(parentSchema.getName())) { return tapSchema.getTapSchemaModel().get(simpleName); } if (tapSchema.isHasObscore() && parentSchema.getName().equals("ivoa") && simpleName.equals("obscore")) { return tapSchema.getIvoaSchemaModel().get(simpleName); } return null; } protected Table(TapSchema tapSchema, Schema schema, String tableSimpleName) throws SQLException { super(tapSchema, tapSchema.getTableModel(TapSchema.TABLES_TABLE), schema.getTableMetadata(tableSimpleName)); Loading @@ -65,7 +77,7 @@ public class Table extends ChildEntity<Schema> implements EntitiesContainer<Colu columns = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); DBBroker broker = tapSchema.getDBBroker(schema.getName()); columnsMetadata = broker.getAllColumnsMetadata(schema.getName(), tableSimpleName); columnsMetadata = broker.getAllColumnsMetadata(schema.getName(), tableSimpleName, getModel(), tapSchema.getVersion()); for (Map.Entry<String, Map<String, Object>> entry : columnsMetadata.entrySet()) { // Adding table names to columns metadata entry.getValue().put(Column.TABLE_NAME_KEY, schema.getName() + "." + tableSimpleName); Loading TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java +7 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.datalayer.DBBroker; import it.inaf.ia2.tsm.datalayer.DBBrokerFactory; import it.inaf.ia2.tsm.datalayer.DBWrapper; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import it.inaf.ia2.tsm.model.TableModel; import it.inaf.ia2.tsm.model.SchemaModel; import it.inaf.ia2.tsm.model.SchemaModels; Loading Loading @@ -427,7 +427,7 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { schemas.put(schemaName, null); } private SchemaModel getIvoaSchemaModel() { public SchemaModel getIvoaSchemaModel() { if (obscore) { return SchemaModels.getIvoaSchemaModel(obscoreVersion); } Loading Loading @@ -686,6 +686,10 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { return value ? 1 : 0; } public boolean isHasObscore() { return obscore; } /** * Fill descriptions of the TAP_SCHEMA schema entities for a given * SchemaModel (TAP_SCHEMA or ivoa). Loading @@ -700,7 +704,7 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { for (TableModel tableModel : schemaModel.getTables().values()) { Table table = schema.getChild(tableModel.getName()); table.setValue(DESCRIPTION_KEY, tableModel.getDescription()); for (PropertyModel propertyModel : tableModel.getProperties().values()) { for (ColumnModel propertyModel : tableModel.getColumns()) { Column column = table.getChild(propertyModel.getName()); column.setValue(DESCRIPTION_KEY, propertyModel.getDescription()); column.setValue(Column.UCD_KEY, propertyModel.getUcd()); Loading TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchemaEntity.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import it.inaf.ia2.tsm.model.TableModel; import java.io.Serializable; import java.util.ArrayList; Loading Loading @@ -64,7 +64,7 @@ public abstract class TapSchemaEntity implements Serializable { } private void fillProperties() { for (PropertyModel propModel : tableModel.getProperties().values()) { for (ColumnModel propModel : tableModel.getColumns()) { Object defaultValue = null; if (propModel.getLoaderKey() != null) { defaultValue = metadata.get(propModel.getLoaderKey()); Loading Loading
TASMAN-core/src/main/java/it/inaf/ia2/tsm/Column.java +18 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,8 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.TableModel; import it.inaf.ia2.tsm.model.TypesMapping; import java.util.Objects; import org.slf4j.Logger; import org.slf4j.LoggerFactory; Loading Loading @@ -63,6 +65,22 @@ public class Column extends ChildEntity<Table> { setStatus(Status.LOADED); } private void overrideDataTypeFromModels() { Schema parentSchema = parentTable.getParent(); String type = null; if (tapSchema.getName().equals(parentSchema.getName())) { TableModel tableModel = tapSchema.getTapSchemaModel().get(parentTable.getName()); type = tableModel.get(getName()).getType(); } if (type != null) { String compatibleType = TypesMapping.getCompatibleADQLType(type, tapSchema.getVersion()); getProperty(DATATYPE_KEY).init(compatibleType); } } public Key getForeignKey() { if (!foreignKeySearched) { // lazy loading (but the foreignKey value can be null, so we use this boolean) Loading
TASMAN-core/src/main/java/it/inaf/ia2/tsm/EntityProperty.java +3 −3 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import java.io.Serializable; /** Loading @@ -35,7 +35,7 @@ public class EntityProperty<T> implements Serializable { private static final long serialVersionUID = 6735553751078589085L; private PropertyModel propertyModel; private ColumnModel propertyModel; private Class<T> type; private T originalValue; private T value; Loading @@ -44,7 +44,7 @@ public class EntityProperty<T> implements Serializable { private EntityProperty() { } public EntityProperty(PropertyModel propertyModel, T defaultValue) { public EntityProperty(ColumnModel propertyModel, T defaultValue) { this.propertyModel = propertyModel; this.type = propertyModel.getJavaType(); this.init(defaultValue); Loading
TASMAN-core/src/main/java/it/inaf/ia2/tsm/Table.java +13 −1 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.datalayer.DBBroker; import it.inaf.ia2.tsm.model.TableModel; import java.sql.SQLException; import java.util.List; import java.util.Map; Loading Loading @@ -56,6 +57,17 @@ public class Table extends ChildEntity<Schema> implements EntitiesContainer<Colu super(); } private TableModel getModel() { if (tapSchema.getName().equals(parentSchema.getName())) { return tapSchema.getTapSchemaModel().get(simpleName); } if (tapSchema.isHasObscore() && parentSchema.getName().equals("ivoa") && simpleName.equals("obscore")) { return tapSchema.getIvoaSchemaModel().get(simpleName); } return null; } protected Table(TapSchema tapSchema, Schema schema, String tableSimpleName) throws SQLException { super(tapSchema, tapSchema.getTableModel(TapSchema.TABLES_TABLE), schema.getTableMetadata(tableSimpleName)); Loading @@ -65,7 +77,7 @@ public class Table extends ChildEntity<Schema> implements EntitiesContainer<Colu columns = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); DBBroker broker = tapSchema.getDBBroker(schema.getName()); columnsMetadata = broker.getAllColumnsMetadata(schema.getName(), tableSimpleName); columnsMetadata = broker.getAllColumnsMetadata(schema.getName(), tableSimpleName, getModel(), tapSchema.getVersion()); for (Map.Entry<String, Map<String, Object>> entry : columnsMetadata.entrySet()) { // Adding table names to columns metadata entry.getValue().put(Column.TABLE_NAME_KEY, schema.getName() + "." + tableSimpleName); Loading
TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java +7 −3 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.datalayer.DBBroker; import it.inaf.ia2.tsm.datalayer.DBBrokerFactory; import it.inaf.ia2.tsm.datalayer.DBWrapper; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import it.inaf.ia2.tsm.model.TableModel; import it.inaf.ia2.tsm.model.SchemaModel; import it.inaf.ia2.tsm.model.SchemaModels; Loading Loading @@ -427,7 +427,7 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { schemas.put(schemaName, null); } private SchemaModel getIvoaSchemaModel() { public SchemaModel getIvoaSchemaModel() { if (obscore) { return SchemaModels.getIvoaSchemaModel(obscoreVersion); } Loading Loading @@ -686,6 +686,10 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { return value ? 1 : 0; } public boolean isHasObscore() { return obscore; } /** * Fill descriptions of the TAP_SCHEMA schema entities for a given * SchemaModel (TAP_SCHEMA or ivoa). Loading @@ -700,7 +704,7 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { for (TableModel tableModel : schemaModel.getTables().values()) { Table table = schema.getChild(tableModel.getName()); table.setValue(DESCRIPTION_KEY, tableModel.getDescription()); for (PropertyModel propertyModel : tableModel.getProperties().values()) { for (ColumnModel propertyModel : tableModel.getColumns()) { Column column = table.getChild(propertyModel.getName()); column.setValue(DESCRIPTION_KEY, propertyModel.getDescription()); column.setValue(Column.UCD_KEY, propertyModel.getUcd()); Loading
TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchemaEntity.java +2 −2 Original line number Diff line number Diff line Loading @@ -22,7 +22,7 @@ */ package it.inaf.ia2.tsm; import it.inaf.ia2.tsm.model.PropertyModel; import it.inaf.ia2.tsm.model.ColumnModel; import it.inaf.ia2.tsm.model.TableModel; import java.io.Serializable; import java.util.ArrayList; Loading Loading @@ -64,7 +64,7 @@ public abstract class TapSchemaEntity implements Serializable { } private void fillProperties() { for (PropertyModel propModel : tableModel.getProperties().values()) { for (ColumnModel propModel : tableModel.getColumns()) { Object defaultValue = null; if (propModel.getLoaderKey() != null) { defaultValue = metadata.get(propModel.getLoaderKey()); Loading