diff --git a/TASMAN-core/pom.xml b/TASMAN-core/pom.xml index cec38d266a7a2cc1cd49da4ee73fd3cf770e0e52..11b6869f0a6c16992b8bc0f284fe07275c0c37ca 100644 --- a/TASMAN-core/pom.xml +++ b/TASMAN-core/pom.xml @@ -13,15 +13,23 @@ <netbeans.hint.license>inaf-license-netbeans</netbeans.hint.license> </properties> <dependencies> + <dependency> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-jdbc</artifactId> + <version>8.5.19</version> + <scope>compile</scope> + </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.37</version> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.3-1104-jdbc41</version> + <scope>runtime</scope> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -45,6 +53,14 @@ <show>public</show> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.20</version> + <configuration> + <trimStackTrace>false</trimStackTrace> + </configuration> + </plugin> </plugins> </build> </project> \ No newline at end of file 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 51b0e17eb4d405d42840a49136459c17152b26bd..96cf36cda44a777db5ec33f4fa520628cdeed57f 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 @@ -38,6 +38,11 @@ public class Column extends ChildEntity<Table> { public final static String ARRAYSIZE_KEY = "arraysize"; public final static String INDEXED_KEY = "indexed"; public final static String PRIMARY_KEY = "primary_key"; + public final static String PRINCIPAL_KEY = "principal"; + public final static String STD_KEY = "std"; + public final static String UTYPE_KEY = "utype"; + public final static String UCD_KEY = "ucd"; + public final static String UNIT_KEY = "unit"; private static final long serialVersionUID = 9175956487892235521L; private static final Logger LOG = LoggerFactory.getLogger(Column.class); diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TSMUtil.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TSMUtil.java index abde2e34f44a4a14840f8b79da4e868928972ca3..fef324ec5aec28067d9e508f393bd54faedc3c95 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TSMUtil.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TSMUtil.java @@ -22,10 +22,8 @@ */ package it.inaf.ia2.tsm; -import it.inaf.ia2.tsm.datalayer.Credentials; import it.inaf.ia2.tsm.datalayer.DatabaseType; import it.inaf.ia2.tsm.datalayer.DBWrapper; -import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; @@ -33,7 +31,6 @@ import java.util.Collections; import java.util.List; import java.util.Map; import javax.sql.DataSource; -import org.postgresql.ds.PGPoolingDataSource; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -47,36 +44,6 @@ public class TSMUtil { private static final Logger LOG = LoggerFactory.getLogger(TSMUtil.class); - public static DataSource createDataSource(Credentials credentials) { - - switch (credentials.getDatabaseType()) { - - case MYSQL: - MysqlDataSource myds = new MysqlDataSource(); - - myds.setServerName(credentials.getHostname()); - myds.setPortNumber(credentials.getPort()); - myds.setUser(credentials.getUsername()); - myds.setPassword(credentials.getPassword()); - - return myds; - - case POSTGRES: - PGPoolingDataSource pgds = new PGPoolingDataSource(); - - pgds.setServerName(credentials.getHostname()); - pgds.setPortNumber(credentials.getPort()); - pgds.setUser(credentials.getUsername()); - pgds.setPassword(credentials.getPassword()); - pgds.setDatabaseName(credentials.getDatabase()); - - return pgds; - - default: - throw new UnsupportedOperationException(credentials.getDatabaseType() + " not supported yet."); - } - } - protected static List<String> sortStringsList(List<String> list) { Collections.sort(list, String.CASE_INSENSITIVE_ORDER); return list; @@ -236,11 +203,6 @@ public class TSMUtil { return null; } -// private static void setTSColumnDescription(Table table, String columnName, String description) { -// Column column = table.getChild(columnName); -// column.setDescription(description); -// column.setStd(true); -// } public static String getNaturalLangueName(TapSchemaEntity entity) { if (entity instanceof Schema) { return "schema"; diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java index e4385711c77d278f5540820743bdbd0fd132c1c7..740b28d84762a28815e4bb3c92ef2bf1ea48ea30 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/TapSchema.java @@ -56,7 +56,6 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { public static final String KEY_COLUMNS_TABLE = "key_columns"; public static final String DESCRIPTION_KEY = "description"; - public static final String STD_KEY = "std"; private static final long serialVersionUID = 1678083091602571256L; @@ -458,7 +457,7 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { // Adding TAP_SCHEMA into TAP_SCHEMA addEntireSchema(tapSchemaName); - fillColumnDescriptionsAndStd(tapSchemaModel, tapSchemaName); + fillColumnProperties(tapSchemaModel, tapSchemaName); if (obscore) { SchemaModel ivoaSchemaModel = getIvoaSchemaModel(); @@ -680,11 +679,22 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { return visibleKeys; } + private Integer getIntAsBool(Boolean value) { + if (value == null) { + return null; + } + return value ? 1 : 0; + } + /** * Fill descriptions of the TAP_SCHEMA schema entities for a given * SchemaModel (TAP_SCHEMA or ivoa). */ - private void fillColumnDescriptionsAndStd(SchemaModel schemaModel, String schemaName) { + private void fillColumnProperties(SchemaModel schemaModel, String schemaName) { + + // check only on std, but valid also for principal (it depends on TS version) + boolean useIntegerAsBool = getTapSchemaModel().get(COLUMNS_TABLE).get(Column.STD_KEY).getJavaType() == Integer.class; + Schema schema = getChild(schemaName); schema.setValue(DESCRIPTION_KEY, schemaModel.getDescription()); for (TableModel tableModel : schemaModel.getTables().values()) { @@ -693,14 +703,19 @@ public class TapSchema implements EntitiesContainer<Schema>, Serializable { for (PropertyModel propertyModel : tableModel.getProperties().values()) { Column column = table.getChild(propertyModel.getName()); column.setValue(DESCRIPTION_KEY, propertyModel.getDescription()); - if (propertyModel.isStandard()) { - column.setValue(STD_KEY, 1); - } + column.setValue(Column.UCD_KEY, propertyModel.getUcd()); + column.setValue(Column.UNIT_KEY, propertyModel.getUnit()); + column.setValue(Column.UTYPE_KEY, propertyModel.getUtype()); + + Object compatibleStd = useIntegerAsBool ? getIntAsBool(propertyModel.isStandard()) : propertyModel.isStandard(); + Object compatiblePrincipal = useIntegerAsBool ? getIntAsBool(propertyModel.isPrincipal()) : propertyModel.isPrincipal(); + column.setValue(Column.STD_KEY, compatibleStd); + column.setValue(Column.PRINCIPAL_KEY, compatiblePrincipal); } } } private void fillColumnDescriptionsAndStd(SchemaModel schemaModel) { - fillColumnDescriptionsAndStd(schemaModel, schemaModel.getName()); + fillColumnProperties(schemaModel, schemaModel.getName()); } } diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataSourceWrapper.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataSourceWrapper.java index 266794a7083e3031673bc478aaf29bee85168de1..4f020e095639c4642beefd4df610bfe02a41b8f3 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataSourceWrapper.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/DataSourceWrapper.java @@ -22,10 +22,8 @@ */ package it.inaf.ia2.tsm.datalayer; -import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; import java.io.Serializable; import javax.sql.DataSource; -import org.postgresql.ds.PGPoolingDataSource; /** * Serializable wrapper for a DataSource. @@ -48,32 +46,32 @@ public class DataSourceWrapper implements Serializable { public DataSource getDataSource() { if (dataSource == null) { + String driverClassName, url; switch (credentials.getDatabaseType()) { - case MYSQL: - MysqlDataSource myds = new MysqlDataSource(); - - myds.setServerName(credentials.getHostname()); - myds.setPortNumber(credentials.getPort()); - myds.setUser(credentials.getUsername()); - myds.setPassword(credentials.getPassword()); - - return myds; - + driverClassName = "com.mysql.jdbc.Driver"; + url = String.format("jdbc:mysql://%s:%s", credentials.getHostname(), credentials.getPort()); + break; case POSTGRES: - PGPoolingDataSource pgds = new PGPoolingDataSource(); - - pgds.setServerName(credentials.getHostname()); - pgds.setPortNumber(credentials.getPort()); - pgds.setUser(credentials.getUsername()); - pgds.setPassword(credentials.getPassword()); - pgds.setDatabaseName(credentials.getDatabase()); - - return pgds; - + driverClassName = "org.postgresql.Driver"; + url = String.format("jdbc:postgresql://%s:%s/%s", + credentials.getHostname(), credentials.getPort(), credentials.getDatabase()); + break; default: throw new UnsupportedOperationException(credentials.getDatabaseType() + " not supported yet."); } + + org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource(); + ds.setDriverClassName(driverClassName); + ds.setUrl(url); + ds.setUsername(credentials.getUsername()); + ds.setPassword(credentials.getPassword()); + ds.setInitialSize(5); + ds.setMaxActive(10); + ds.setMaxIdle(5); + ds.setMinIdle(2); + + dataSource = ds; } return dataSource; } diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/PropertyModel.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/PropertyModel.java index 557b1420a4db204530e87c8fa6c2de69978f9a88..d41f6f7a90e46a8cd3a8c137af4f27aaf41773d6 100644 --- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/PropertyModel.java +++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/model/PropertyModel.java @@ -40,14 +40,21 @@ public class PropertyModel implements Serializable { private boolean updatable; private boolean nullable; private boolean standard; + private boolean mandatory; private String defaultValueString; private String loaderKey; private String description; + private String ucd; + private String utype; + private String unit; + private boolean principal; public PropertyModel() { // default values updatable = true; nullable = true; + // Currently this is used only for ObsCore + mandatory = true; } @XmlElement(name = "name") @@ -104,6 +111,15 @@ public class PropertyModel implements Serializable { this.standard = standard; } + @XmlElement(name = "mandatory", defaultValue = "true") + public boolean isMandatory() { + return mandatory; + } + + public void setMandatory(boolean mandatory) { + this.mandatory = mandatory; + } + @XmlElement(name = "default-value") public String getDefaultValueString() { return defaultValueString; @@ -131,6 +147,42 @@ public class PropertyModel implements Serializable { this.description = description; } + @XmlElement(name = "ucd") + public String getUcd() { + return ucd; + } + + public void setUcd(String ucd) { + this.ucd = ucd; + } + + @XmlElement(name = "utype") + public String getUtype() { + return utype; + } + + public void setUtype(String utype) { + this.utype = utype; + } + + @XmlElement(name = "unit") + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + @XmlElement(name = "principal", defaultValue = "false") + public boolean isPrincipal() { + return principal; + } + + public void setPrincipal(boolean principal) { + this.principal = principal; + } + @XmlTransient public Object getDefaultValue() { if (defaultValueString == null) { 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 b4c5205b5f100f28f644e020713013298467612f..6458b40344bd9af22c2376aa0bce737d4f387919 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 @@ -103,7 +103,11 @@ public class SchemaModels { tableModel = new TableModel(tableXmlModel); } for (PropertyModel property : tableXmlModel.getAdd()) { - tableModel.getProperties().put(property.getName(), property); + if (tableModel.getProperties().get(property.getName()) == null) { + // Add property only if it didn't exist in child structure + // this allows to override properties in children + tableModel.getProperties().put(property.getName(), property); + } } model.getTables().put(tableName, tableModel); } diff --git a/TASMAN-core/src/main/resources/schema_definition/ivoa-1_1.xml b/TASMAN-core/src/main/resources/schema_definition/ivoa-1_1.xml index 5d71c1c463f4a725e3d08d587718a40a0341360c..6f3e50d4f6246c408c70f77bc97be27275b36e42 100644 --- a/TASMAN-core/src/main/resources/schema_definition/ivoa-1_1.xml +++ b/TASMAN-core/src/main/resources/schema_definition/ivoa-1_1.xml @@ -31,6 +31,22 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <updatable>true</updatable> <description>Logical data product type (image etc.)</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>ObsDataset.dataProductType</utype> + <ucd>meta.id</ucd> + <principal>true</principal> + </property> + <property> + <name>dataproduct_subtype</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Data product specific type</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>ObsDataset.dataProductSubtype</utype> + <ucd>meta.id</ucd> + <principal>true</principal> </property> <property> <name>calib_level</name> @@ -39,6 +55,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <nullable>false</nullable> <description>Calibration level {0, 1, 2, 3, 4}</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>ObsDataset.calibLevel</utype> + <ucd>meta.code;obs.calib</ucd> + <principal>true</principal> </property> <property> <name>obs_collection</name> @@ -48,6 +68,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <nullable>false</nullable> <description>Name of the data collection</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>DataID.collection</utype> + <ucd>meta.id</ucd> + <principal>true</principal> </property> <property> <name>obs_id</name> @@ -55,8 +79,106 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <size>255</size> <updatable>true</updatable> <nullable>false</nullable> - <description>Observation ID</description> + <description>Internal ID given by the ObsTAP service</description> + <standard>true</standard> + <mandatory>true</mandatory> + <utype>DataID.observationID</utype> + <ucd>meta.id</ucd> + <principal>true</principal> + </property> + <property> + <name>obs_title</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Brief description of dataset in free format</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>DataID.title</utype> + <ucd>meta.title;obs</ucd> + <principal>true</principal> + </property> + <property> + <name>obs_creation_date</name> + <type>TIMESTAMP</type> + <updatable>true</updatable> + <description>Date when the dataset was created</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>DataID.date</utype> + <ucd>time;meta.dataset</ucd> + <principal>true</principal> + </property> + <property> + <name>obs_creator_name</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Name of the creator of the data</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>DataID.creator</utype> + <ucd>meta.id</ucd> + <principal>true</principal> + </property> + <property> + <name>obs_creator_did</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>IVOA dataset identifier given by the creator</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>DataID.creatorDID</utype> + <ucd>meta.id</ucd> + <principal>false</principal> + </property> + <property> + <name>obs_release_date</name> + <type>TIMESTAMP</type> + <updatable>true</updatable> + <description>Observation release date (ISO 8601)</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Curation.releaseDate</utype> + <ucd>time.release</ucd> + <principal>true</principal> + </property> + <property> + <name>publisher_id</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>IVOA-ID for the Publisher</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Curation.publisherID</utype> + <ucd>meta.ref.uri;meta.curation</ucd> + <principal>true</principal> + </property> + <property> + <name>bib_reference</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Service bibliographic reference</description> <standard>true</standard> + <mandatory>false</mandatory> + <utype>Curation.reference</utype> + <ucd>meta.bib</ucd> + <principal>false</principal> + </property> + <property> + <name>data_rights</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Public/Secure/Proprietary</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Curation.rights</utype> + <ucd>meta.code</ucd> + <principal>false</principal> </property> <property> <name>obs_publisher_did</name> @@ -66,6 +188,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <nullable>false</nullable> <description>Dataset identifier given by the publisher</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Curation.publisherDID</utype> + <ucd>meta.ref.uri;meta.curation</ucd> + <principal>true</principal> </property> <property> <name>access_url</name> @@ -74,22 +200,35 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <updatable>true</updatable> <description>URL used to access (download) dataset</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Access.reference</utype> + <ucd>meta.ref.url</ucd> + <principal>true</principal> </property> <property> <name>access_format</name> <type>VARCHAR</type> <size>255</size> <updatable>true</updatable> - <description>File content format</description> + <description>Content format of the dataset</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Access.format</utype> + <ucd>meta.code.mime</ucd> + <principal>true</principal> </property> <property> <name>access_estsize</name> - <type>INTEGER</type> + <type>BIGINT</type> <updatable>true</updatable> <description>Estimated size of dataset in kilo bytes</description> <standard>true</standard> <unit>kbyte</unit> + <mandatory>true</mandatory> + <utype>Access.size</utype> + <unit>kbyte</unit> + <ucd>phys.size;meta.file</ucd> + <principal>true</principal> </property> <property> <name>target_name</name> @@ -98,30 +237,61 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <updatable>true</updatable> <description>Astronomical object observed, if any</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Target.name</utype> + <ucd>meta.id;src</ucd> + <principal>true</principal> + </property> + <property> + <name>target_class</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Class of the Target object as in SSA</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Target.class</utype> + <ucd>src.class</ucd> + <principal>true</principal> </property> <property> <name>s_ra</name> <type>DOUBLE</type> <updatable>true</updatable> - <description>Central right ascension, ICRS</description> + <description>Central Spatial Position in ICRS Right ascension</description> <standard>true</standard> <unit>deg</unit> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.Coverage.Location.Coord.Position2D.Value2.C1</utype> + <unit>deg</unit> + <ucd>pos.eq.ra</ucd> + <principal>true</principal> </property> <property> <name>s_dec</name> <type>DOUBLE</type> <updatable>true</updatable> - <description>Central declination, ICRS</description> + <description>Central Spatial Position in ICRS Declination</description> <standard>true</standard> <unit>deg</unit> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.Coverage.Location.Coord.Position2D.Value2.C2</utype> + <unit>deg</unit> + <ucd>pos.eq.dec</ucd> + <principal>true</principal> </property> <property> <name>s_fov</name> <type>DOUBLE</type> <updatable>true</updatable> - <description>Diameter (bounds) of the covered region</description> + <description>Estimated size of the covered region as the diameter of a containing circle</description> <standard>true</standard> <unit>deg</unit> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.Coverage.Bounds.Extent.diameter</utype> + <unit>deg</unit> + <ucd>phys.angSize;instr.fov</ucd> + <principal>true</principal> </property> <property> <name>s_region</name> @@ -130,28 +300,129 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <updatable>true</updatable> <description>Sky region covered by the data product (expressed in ICRS frame)</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.Coverage.Support.Area</utype> + <ucd>pos.outline;obs.field</ucd> + <principal>true</principal> </property> <property> <name>s_xel1</name> - <type>INTEGER</type> + <type>BIGINT</type> <updatable>true</updatable> - <description>Number of elements along the first spatial axis</description> + <description>Number of elements along the first coordinate of the spatial axis</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.numBins1</utype> + <ucd>meta.number</ucd> + <principal>true</principal> </property> <property> <name>s_xel2</name> - <type>INTEGER</type> + <type>BIGINT</type> + <updatable>true</updatable> + <description>Number of elements along the second coordinate of the spatial axis</description> + <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.numBins2</utype> + <ucd>meta.number</ucd> + <principal>true</principal> + </property> + <property> + <name>s_ucd</name> + <type>VARCHAR</type> + <size>255</size> <updatable>true</updatable> - <description>Number of elements along the second spatial axis</description> + <description>UCD for the nature of the spatial axis (pos or u,v data)</description> <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.ucd</utype> + <ucd>meta.ucd</ucd> + <principal>true</principal> + </property> + <property> + <name>s_unit</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Unit used for spatial axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.unit</utype> + <ucd>meta.unit</ucd> + <principal>true</principal> </property> <property> <name>s_resolution</name> <type>DOUBLE</type> <updatable>true</updatable> - <description>Spatial resolution of data as FWHM</description> + <description>Spatial resolution of data as FWHM of PSF</description> + <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpatialAxis.Resolution.refval.value</utype> + <unit>arcsec</unit> + <ucd>pos.angResolution</ucd> + <principal>true</principal> + </property> + <property> + <name>s_resolution_min</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Resolution min value on spatial axis (FHWM of PSF)</description> <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.Resolution.Bounds.Limits.LoLimit</utype> <unit>arcsec</unit> + <ucd>pos.angResolution;stat.min</ucd> + <principal>true</principal> + </property> + <property> + <name>s_resolution_max</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Resolution max value on spatial axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis .Resolution.Bounds.Limits.HiLimit</utype> + <unit>arcsec</unit> + <ucd>pos.angResolution;stat.max</ucd> + <principal>true</principal> + </property> + <property> + <name>s_calib_status</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Type of calibration along the spatial axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.calibrationStatus</utype> + <ucd>meta.code.qual</ucd> + <principal>true</principal> + </property> + <property> + <name>s_stat_error</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Astrometric precision along the spatial axis</description> + <standard>true</standard> + <unit>arcsec</unit> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.Accuracy.StatError.Refval.value</utype> + <unit>arcsec</unit> + <ucd>stat.error;pos.eq</ucd> + <principal>false</principal> + </property> + <property> + <name>s_pixel_scale</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Sampling period in world coordinate units along the spatial axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpatialAxis.Sampling.RefVal.SamplingPeriod</utype> + <unit>arcsec</unit> + <ucd>phys.angSize;instr.pixel</ucd> + <principal>true</principal> </property> <property> <name>t_min</name> @@ -160,6 +431,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Start time in MJD</description> <standard>true</standard> <unit>d</unit> + <mandatory>true</mandatory> + <utype>Char.TimeAxis.Coverage.Bounds.Limits.StartTime</utype> + <ucd>time.start;obs.exposure</ucd> + <principal>true</principal> </property> <property> <name>t_max</name> @@ -168,6 +443,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Stop time in MJD</description> <standard>true</standard> <unit>d</unit> + <mandatory>true</mandatory> + <utype>Char.TimeAxis.Coverage.Bounds.Limits.StopTime</utype> + <ucd>time.end;obs.exposure</ucd> + <principal>true</principal> </property> <property> <name>t_exptime</name> @@ -176,6 +455,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Total exposure time</description> <standard>true</standard> <unit>s</unit> + <mandatory>true</mandatory> + <utype>Char.TimeAxis.Coverage.Support.Extent</utype> + <ucd>time.duration;obs.exposure</ucd> + <principal>true</principal> </property> <property> <name>t_resolution</name> @@ -184,13 +467,55 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Temporal resolution FWHM</description> <standard>true</standard> <unit>s</unit> + <mandatory>true</mandatory> + <utype>Char.TimeAxis.Resolution.Refval.valueResolution.Refval.value</utype> + <ucd>time.resolution</ucd> + <principal>true</principal> + </property> + <property> + <name>t_calib_status</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Type of time coordinate calibration</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.TimeAxis.calibrationStatus</utype> + <ucd>meta.code.qual</ucd> + <principal>false</principal> + </property> + <property> + <name>t_stat_error</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Time coord statistical error</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.TimeAxis.Accuracy.StatError.Refval.value</utype> + <unit>s</unit> + <ucd>stat.error;time</ucd> + <principal>false</principal> </property> <property> <name>t_xel</name> - <type>INTEGER</type> + <type>BIGINT</type> <updatable>true</updatable> <description>Number of elements along the time axis</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.TimeAxis.numBins</utype> + <ucd>meta.number</ucd> + <principal>true</principal> + </property> + <property> + <name>t_refpos</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Time Axis Reference Position as defined in STC REC</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.TimeAxis.ReferencePosition</utype> </property> <property> <name>em_min</name> @@ -199,6 +524,10 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Start in spectral coordinates</description> <standard>true</standard> <unit>m</unit> + <mandatory>true</mandatory> + <utype>Char.SpectralAxis.Coverage.Bounds.Limits.LoLimit</utype> + <ucd>em.wl;stat.min</ucd> + <principal>true</principal> </property> <property> <name>em_max</name> @@ -207,43 +536,184 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <description>Stop in spectral coordinates</description> <standard>true</standard> <unit>m</unit> + <mandatory>true</mandatory> + <utype>Char.SpectralAxis.Coverage.Bounds.Limits.HiLimit</utype> + <ucd>em.wl;stat.max</ucd> + <principal>true</principal> </property> <property> <name>em_res_power</name> <type>DOUBLE</type> <updatable>true</updatable> - <description>Spectral resolving power</description> + <description>Value of the resolving power along the spectral axis. (R)</description> + <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpectralAxis.Resolution.ResolPower.refVal</utype> + <ucd>spect.resolution</ucd> + <principal>true</principal> + </property> + <property> + <name>em_res_power_min</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Resolving power min value on spectral axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.Resolution.ResolPower.LoLimit</utype> + <ucd>spect.resolution;stat.min</ucd> + <principal>true</principal> + </property> + <property> + <name>em_res_power_max</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Resolving power max value on spectral axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.Resolution.ResolPower.HiLimit</utype> + <ucd>spect.resolution;stat.max</ucd> + <principal>true</principal> + </property> + <property> + <name>em_resolution</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Value of Resolution along the spectral axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.Resolution.Refval.value</utype> + <unit>m</unit> + <ucd>spect.resolution;stat.mean</ucd> + <principal>true</principal> + </property> + <property> + <name>em_stat_error</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Spectral coord statistical error</description> <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.Accuracy.StatError.Refval.value</utype> + <unit>m</unit> + <ucd>stat.error;em</ucd> + <principal>false</principal> </property> <property> <name>em_xel</name> - <type>INTEGER</type> + <type>BIGINT</type> <updatable>true</updatable> <description>Number of elements along the spectral axis</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.SpectralAxis.numBins</utype> + <ucd>meta.number</ucd> + </property> + <property> + <name>em_ucd</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Nature of the spectral axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.ucd</utype> + <ucd>meta.ucd</ucd> + <principal>true</principal> + </property> + <property> + <name>em_unit</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Units along the spectral axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.unit</utype> + <ucd>meta.unit</ucd> + <principal>true</principal> + </property> + <property> + <name>em_calib_status</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Type of spectral coord calibration</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.SpectralAxis.calibrationStatus</utype> + <ucd>meta.code.qual</ucd> + <principal>false</principal> </property> <property> <name>o_ucd</name> <type>VARCHAR</type> <size>255</size> <updatable>true</updatable> - <description>UCD of observable (e.g. phot.flux.density, phot.count, etc.)</description> + <description>UCD of the observable axis (e.g. phot.flux.density, phot.count, etc.)</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.ObservableAxis.ucd</utype> + <ucd>meta.ucd</ucd> + <principal>true</principal> + </property> + <property> + <name>o_unit</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Units used for the observable values</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.ObservableAxis.unit</utype> + <ucd>meta.unit</ucd> + <principal>true</principal> + </property> + <property> + <name>o_calib_status</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Type of calibration for the observable coordinate</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.ObservableAxis.calibrationStatus</utype> + <ucd>meta.code.qual</ucd> + <principal>true</principal> + </property> + <property> + <name>o_stat_error</name> + <type>DOUBLE</type> + <updatable>true</updatable> + <description>Statistical error on the Observable axis</description> + <standard>true</standard> + <mandatory>false</mandatory> + <utype>Char.ObservableAxis.Accuracy.StatError.Refval.value</utype> + <!-- units specified by o_unit --> + <ucd>stat.error;phot.flux</ucd> + <principal>false</principal> </property> <property> <name>pol_states</name> <type>VARCHAR</type> <size>255</size> <updatable>true</updatable> - <description>List of polarization states or NULL if not applicable</description> + <description>List of polarization states present in the data file or NULL if not applicable</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.PolarizationAxis.stateList</utype> + <ucd>meta.code;phys.polarization</ucd> + <principal>true</principal> </property> <property> <name>pol_xel</name> - <type>INTEGER</type> + <type>BIGINT</type> <updatable>true</updatable> - <description>Number of polarization samples</description> + <description>Number of elements along the polarization axis</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Char.PolarizationAxis.numBins</utype> + <ucd>meta.number</ucd> + <principal>true</principal> </property> <property> <name>facility_name</name> @@ -252,14 +722,34 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <updatable>true</updatable> <description>Name of the facility used for this observation</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Provenance.ObsConfig.Facility.name</utype> + <ucd>meta.id;instr.tel</ucd> + <principal>true</principal> </property> <property> <name>instrument_name</name> <type>VARCHAR</type> <size>255</size> <updatable>true</updatable> - <description>Name of the instrument used for this observation</description> + <description>The name of the instrument used for the observation</description> <standard>true</standard> + <mandatory>true</mandatory> + <utype>Provenance.ObsConfig.Instrument.name</utype> + <ucd>meta.id;instr</ucd> + <principal>true</principal> + </property> + <property> + <name>proposal_id</name> + <type>VARCHAR</type> + <size>255</size> + <updatable>true</updatable> + <description>Identifier of proposal to which observation belongs</description> + <standard>false</standard> + <mandatory>true</mandatory> + <utype>Provenance.Proposal.identifier</utype> + <ucd>meta.id; obs.proposal</ucd> + <principal>false</principal> </property> </add> </table> diff --git a/TASMAN-core/src/main/resources/sql_type_mapping.xml b/TASMAN-core/src/main/resources/sql_type_mapping.xml index cb60fd4bebf81fcddcea57b52de4a5ef60d056b8..45161135688d27dfee88b712e47138f34251af69 100644 --- a/TASMAN-core/src/main/resources/sql_type_mapping.xml +++ b/TASMAN-core/src/main/resources/sql_type_mapping.xml @@ -71,5 +71,17 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <pgsql>text</pgsql> <java>java.lang.String</java> </type> + <type> + <adql>TIMESTAMP</adql> + <mysql>TIMESTAMP</mysql> + <pgsql>timestamp</pgsql> + <java>java.lang.String</java> + </type> + <type> + <adql>REGION</adql> + <mysql>VARCHAR</mysql> + <pgsql>character varying</pgsql> + <java>java.lang.String</java> + </type> </sql_type_mapping> diff --git a/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java b/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java index 759ba1ecf5a157817f6f9869aa94eb2906092673..0e272c7bb4bef8fe83f21319e0b89abfd044e078 100644 --- a/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java +++ b/TASMAN-embedded/src/main/java/it/inaf/ia2/tap/tasman/Main.java @@ -1,7 +1,11 @@ package it.inaf.ia2.tap.tasman; import java.io.File; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.util.log.Log; +import org.eclipse.jetty.util.log.StdErrLog; import org.eclipse.jetty.webapp.WebAppContext; /** @@ -10,11 +14,29 @@ import org.eclipse.jetty.webapp.WebAppContext; */ public class Main { + private static final int DEFAULT_PORT = 8080; + /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { - Server server = new Server(2500); + + int port = DEFAULT_PORT; + + if (args.length == 1) { + try { + port = Integer.parseInt(args[0]); + } catch (NumberFormatException e) { + System.err.println("First argument must be a port number"); + } + } + + final int serverPort = port; + + // Suppress log verbosity + ((StdErrLog) Log.getRootLogger()).setLevel(StdErrLog.LEVEL_WARN); + + Server server = new Server(serverPort); WebAppContext webapp = new WebAppContext(); webapp.setContextPath("/"); @@ -22,17 +44,26 @@ public class Main { webapp.setWar(warFile.getAbsolutePath()); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=477705 - //https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty + // https://docs.jboss.org/weld/reference/latest/en-US/html/environments.html#_jetty webapp.prependServerClass("-org.eclipse.jetty.server.handler.ContextHandler"); webapp.prependServerClass("-org.eclipse.jetty.servlet.FilterHolder"); webapp.prependServerClass("-org.eclipse.jetty.servlet.ServletContextHandler"); webapp.prependServerClass("-org.eclipse.jetty.servlet.ServletHolder"); + webapp.addEventListener(new ServletContextListener() { + @Override + public void contextInitialized(ServletContextEvent sce) { + System.out.println("TASMAN initialized. Visit http://localhost:" + serverPort); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + } + }); + server.setHandler(webapp); server.start(); - server.dumpStdErr(); - // The use of server.join() the will make the current thread join and // wait until the server is done executing. server.join(); diff --git a/TASMAN-webapp/pom.xml b/TASMAN-webapp/pom.xml index 7c6bdff97b149e43cede5ee20a42521053345af8..a0dbb0fcb5076d35e46e0a43bc16b08f66e910e0 100644 --- a/TASMAN-webapp/pom.xml +++ b/TASMAN-webapp/pom.xml @@ -111,6 +111,13 @@ <groupId>it.inaf.ia2.tap</groupId> <artifactId>tasman-core</artifactId> <version>1.2.0</version> + <exclusions> + <!-- exclusion due to tomcat-jdbc dependency conflicting with Jetty --> + <exclusion> + <groupId>org.apache.tomcat</groupId> + <artifactId>tomcat-juli</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>ari.ucidy</groupId> diff --git a/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml b/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml index cb584df0722e5c7b2d6f3a767874fbc0943abbc4..c2eda280c1d5444bfddb911b308841f9ae26b0d7 100644 --- a/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml +++ b/TASMAN-webapp/src/main/webapp/WEB-INF/web.xml @@ -97,5 +97,36 @@ <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> + <servlet> + <servlet-name>REST</servlet-name> + <servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class> + <init-param> + <param-name>jersey.config.server.provider.packages</param-name> + <param-value>it.inaf.ia2.tsm.webapp it.inaf.ia2.tsm.webapp.env</param-value> + </init-param> + <load-on-startup>1</load-on-startup> + </servlet> + + <servlet-mapping> + <servlet-name>REST</servlet-name> + <url-pattern>/rest/*</url-pattern> + </servlet-mapping> + + <servlet> + <servlet-name>default</servlet-name> + <servlet-class>org.eclipse.jetty.servlet.DefaultServlet</servlet-class> + <init-param> + <param-name>dirAllowed</param-name> + <param-value>false</param-value> + </init-param> + <init-param> + <param-name>welcomeServlets</param-name> + <param-value>true</param-value> + </init-param> + <init-param> + <param-name>redirectWelcome</param-name> + <param-value>true</param-value> + </init-param> + </servlet> ${enable.jetty.config.start} --> </web-app>