From 78f330b07128c6eb0acc9d79fe31be07100b96e0 Mon Sep 17 00:00:00 2001 From: Sonia Zorba Date: Tue, 8 Aug 2017 16:09:07 +0200 Subject: [PATCH] UI and core modification for ObsCore creation --- .../main/java/it/inaf/ia2/tsm/TapSchema.java | 6 ++-- .../it/inaf/ia2/tsm/model/PropertyModel.java | 5 ++- .../it/inaf/ia2/tsm/model/SchemaModels.java | 12 +++++-- .../resources/schema_definition/ivoa-1_1.xml | 32 ++++++++++++++++++- .../ia2/tsm/webapp/CredentialsEditing.java | 20 ++++++++++-- .../inaf/ia2/tsm/webapp/TapSchemaLoader.java | 15 +++++++-- .../tsm/webapp/xmlconfig/TapCredentials.java | 10 ++++++ .../src/main/webapp/credentialsEditing.xhtml | 14 +++++++- 8 files changed, 101 insertions(+), 13 deletions(-) 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 821cd90..ebdcc66 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 @@ -684,12 +684,12 @@ public class TapSchema implements EntitiesContainer, Serializable { private void fillColumnDescriptionsAndStd(SchemaModel schemaModel, String schemaName) { Schema schema = getChild(schemaName); schema.setValue(DESCRIPTION_KEY, schemaModel.getDescription()); - for (TableModel tableModel : getTapSchemaModel().getTables().values()) { + for (TableModel tableModel : schemaModel.getTables().values()) { Table table = schema.getChild(tableModel.getName()); - schema.setValue(DESCRIPTION_KEY, tableModel.getDescription()); + table.setValue(DESCRIPTION_KEY, tableModel.getDescription()); for (PropertyModel propertyModel : tableModel.getProperties().values()) { Column column = table.getChild(propertyModel.getName()); - schema.setValue(DESCRIPTION_KEY, propertyModel.getDescription()); + column.setValue(DESCRIPTION_KEY, propertyModel.getDescription()); if (propertyModel.isStandard()) { column.setValue(STD_KEY, 1); } 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 95228f1..557b142 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 @@ -22,6 +22,7 @@ */ package it.inaf.ia2.tsm.model; +import java.io.Serializable; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlTransient; @@ -29,7 +30,9 @@ import javax.xml.bind.annotation.XmlTransient; * * @author Sonia Zorba {@literal } */ -public class PropertyModel { +public class PropertyModel implements Serializable { + + private static final long serialVersionUID = -982004697900839996L; private String name; private String type; 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 192c513..b4c5205 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 @@ -148,14 +148,22 @@ public class SchemaModels { return getTapSchemaModel(version).getTables().get(tableName); } - public static List getAvailableTapSchemaVersions() { + private static List getAvailableVersions(Map schemaModels) { List versions = new ArrayList<>(); - for (SchemaModel tapSchemaModel : TAP_SCHEMA_MODELS.values()) { + for (SchemaModel tapSchemaModel : schemaModels.values()) { versions.add(tapSchemaModel.getVersion()); } return versions; } + public static List getAvailableTapSchemaVersions() { + return getAvailableVersions(TAP_SCHEMA_MODELS); + } + + public static List getAvailableIvoaSchemaVersions() { + return getAvailableVersions(IVOA_SCHEMA_MODELS); + } + public static SchemaModel getIvoaSchemaModel(String version) { return IVOA_SCHEMA_MODELS.get(version); } 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 9a5c96d..5d71c1c 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 @@ -30,6 +30,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true Logical data product type (image etc.) + true calib_level @@ -37,6 +38,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. true false Calibration level {0, 1, 2, 3, 4} + true obs_collection @@ -45,6 +47,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. true false Name of the data collection + true obs_id @@ -53,6 +56,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. true false Observation ID + true obs_publisher_did @@ -61,13 +65,15 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. true false Dataset identifier given by the publisher + true access_url - VARCHAR + CLOB 255 true URL used to access (download) dataset + true access_format @@ -75,12 +81,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true File content format + true access_estsize INTEGER true Estimated size of dataset in kilo bytes + true kbyte @@ -89,12 +97,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true Astronomical object observed, if any + true s_ra DOUBLE true Central right ascension, ICRS + true deg @@ -102,6 +112,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Central declination, ICRS + true deg @@ -109,6 +120,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Diameter (bounds) of the covered region + true deg @@ -117,24 +129,28 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true Sky region covered by the data product (expressed in ICRS frame) + true s_xel1 INTEGER true Number of elements along the first spatial axis + true s_xel2 INTEGER true Number of elements along the second spatial axis + true s_resolution DOUBLE true Spatial resolution of data as FWHM + true arcsec @@ -142,6 +158,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Start time in MJD + true d @@ -149,6 +166,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Stop time in MJD + true d @@ -156,6 +174,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Total exposure time + true s @@ -163,6 +182,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Temporal resolution FWHM + true s @@ -170,12 +190,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. INTEGER true Number of elements along the time axis + true em_min DOUBLE true Start in spectral coordinates + true m @@ -183,6 +205,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Stop in spectral coordinates + true m @@ -190,12 +213,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. DOUBLE true Spectral resolving power + true em_xel INTEGER true Number of elements along the spectral axis + true o_ucd @@ -203,6 +228,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true UCD of observable (e.g. phot.flux.density, phot.count, etc.) + true pol_states @@ -210,12 +236,14 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true List of polarization states or NULL if not applicable + true pol_xel INTEGER true Number of polarization samples + true facility_name @@ -223,6 +251,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true Name of the facility used for this observation + true instrument_name @@ -230,6 +259,7 @@ Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 255 true Name of the instrument used for this observation + true diff --git a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java index a5e4e71..48e1b0f 100644 --- a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java +++ b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/CredentialsEditing.java @@ -66,6 +66,7 @@ public class CredentialsEditing implements Serializable { private boolean credentialsDialogOpened; private List tapSchemaVersions; + private List obscoreVersions; private boolean separateCredentials; private Credentials sourceCredentials; @@ -73,10 +74,12 @@ public class CredentialsEditing implements Serializable { private String tapSchemaName; private String tapSchemaVersion; private boolean hasObscore; + private String obscoreVersion; @PostConstruct public void init() { this.tapSchemaVersions = SchemaModels.getAvailableTapSchemaVersions(); + obscoreVersions = SchemaModels.getAvailableIvoaSchemaVersions(); } public List getSavedCredentials() { @@ -106,6 +109,7 @@ public class CredentialsEditing implements Serializable { tapSchemaName = credentials.getTapSchemaName(); tapSchemaVersion = credentials.getTapSchemaVersion(); hasObscore = credentials.isHasObscore(); + obscoreVersion = credentials.getObscoreVersion(); } public void addNewCredentialsInEditing() { @@ -116,6 +120,7 @@ public class CredentialsEditing implements Serializable { tapSchemaName = ""; tapSchemaVersion = ""; hasObscore = false; + obscoreVersion = ""; } public void loadTapSchema(TapCredentials tapCredentials) throws SQLException { @@ -174,9 +179,10 @@ public class CredentialsEditing implements Serializable { editedCredentials = new JoinedCredentials(sourceCredentials); } - editedCredentials.setHasObscore(hasObscore); editedCredentials.setTapSchemaName(tapSchemaName); editedCredentials.setTapSchemaVersion(tapSchemaVersion); + editedCredentials.setHasObscore(hasObscore); + editedCredentials.setObscoreVersion(obscoreVersion); if (credentialsInEditing == null) { // New credentials @@ -191,8 +197,8 @@ public class CredentialsEditing implements Serializable { return tapSchemaVersions; } - public void setTapSchemaVersions(List tapSchemaVersions) { - this.tapSchemaVersions = tapSchemaVersions; + public List getObscoreVersions() { + return obscoreVersions; } public boolean isSeparateCredentials() { @@ -250,4 +256,12 @@ public class CredentialsEditing implements Serializable { public void setHasObscore(boolean hasObscore) { this.hasObscore = hasObscore; } + + public String getObscoreVersion() { + return obscoreVersion; + } + + public void setObscoreVersion(String obscoreVersion) { + this.obscoreVersion = obscoreVersion; + } } diff --git a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaLoader.java b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaLoader.java index ff5951b..1095927 100644 --- a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaLoader.java +++ b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/TapSchemaLoader.java @@ -23,6 +23,7 @@ package it.inaf.ia2.tsm.webapp; import it.inaf.ia2.tsm.TapSchema; +import it.inaf.ia2.tsm.TapSchemaSettings; import it.inaf.ia2.tsm.datalayer.DBBroker; import it.inaf.ia2.tsm.datalayer.DBBrokerFactory; import it.inaf.ia2.tsm.datalayer.DBWrapper; @@ -95,6 +96,15 @@ public class TapSchemaLoader implements Serializable { // Otherwise create TAP_SCHEMA only if user press Ok on confirmation dialog } + private TapSchemaSettings getTapSchemaSettings(TapCredentials tapCredentials) { + TapSchemaSettings settings = new TapSchemaSettings(); + settings.setTapSchemaName(tapCredentials.getTapSchemaName()); + settings.setTapSchemaVersion(tapCredentials.getTapSchemaVersion()); + settings.setHasObscore(tapCredentials.isHasObscore()); + settings.setObscoreVersion(tapCredentials.getObscoreVersion()); + return settings; + } + public void edit() { loadedTapSchema = null; @@ -105,7 +115,8 @@ public class TapSchemaLoader implements Serializable { @Override public void run() { try { - loadedTapSchema = new TapSchema(tapCredentials.getTapSchemaVersion(), dbWrapper, tapCredentials.getTapSchemaName(), true); + + loadedTapSchema = new TapSchema(dbWrapper, getTapSchemaSettings(tapCredentials), true); } catch (Throwable e) { LOG.error("Exception caught", e); loadingError = e.getMessage(); @@ -128,7 +139,7 @@ public class TapSchemaLoader implements Serializable { @Override public void run() { try { - loadedTapSchema = new TapSchema(tapCredentials.getTapSchemaVersion(), dbWrapper, tapCredentials.getTapSchemaName(), false); + loadedTapSchema = new TapSchema(dbWrapper, getTapSchemaSettings(tapCredentials), false); } catch (Throwable e) { LOG.error("Exception caught", e); if (e.getMessage() != null) { diff --git a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/TapCredentials.java b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/TapCredentials.java index 2924a81..d615b0a 100644 --- a/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/TapCredentials.java +++ b/TASMAN-webapp/src/main/java/it/inaf/ia2/tsm/webapp/xmlconfig/TapCredentials.java @@ -36,6 +36,7 @@ public abstract class TapCredentials implements Serializable { private String tapSchemaName; private String tapSchemaVersion; private boolean hasObscore; + private String obscoreVersion; public TapCredentials() { } @@ -73,4 +74,13 @@ public abstract class TapCredentials implements Serializable { public void setHasObscore(boolean hasObscore) { this.hasObscore = hasObscore; } + + @XmlElement(name = "obscore_version") + public String getObscoreVersion() { + return obscoreVersion; + } + + public void setObscoreVersion(String obscoreVersion) { + this.obscoreVersion = obscoreVersion; + } } diff --git a/TASMAN-webapp/src/main/webapp/credentialsEditing.xhtml b/TASMAN-webapp/src/main/webapp/credentialsEditing.xhtml index ab1f7da..577bccd 100644 --- a/TASMAN-webapp/src/main/webapp/credentialsEditing.xhtml +++ b/TASMAN-webapp/src/main/webapp/credentialsEditing.xhtml @@ -38,6 +38,7 @@ TAP_SCHEMA name Version Obscore + Obscore version Login @@ -67,6 +68,7 @@ #{c.tapSchemaName} #{c.tapSchemaVersion} + #{c.obscoreVersion} @@ -241,10 +243,20 @@
+ + ObsCore version +
+ + + +
+