From 45fb45834d8620a93826aa3d7b5df2f83232ae14 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Mon, 23 May 2016 17:55:25 +0200 Subject: [PATCH] Sort methods and fields in each class. --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java | 40 ++++++++++++++++++++-------------------- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java | 12 ++++++------ src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java | 72 ++++++++++++++++++++++++++++++++++++------------------------------------ src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleEnum.java | 189 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/GUIDim.java | 20 ++++++++++---------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java | 4 ++-- src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java | 70 +++++++++++++++++++++++++++++++++++----------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java | 10 +++++----- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java | 10 +++++----- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java | 6 +++--- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java | 54 +++++++++++++++++++++++++++--------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java | 70 +++++++++++++++++++++++++++++++++++----------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java | 38 +++++++++++++++++++------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java | 26 +++++++++++++------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java | 40 ++++++++++++++++++++-------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java | 92 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java | 56 ++++++++++++++++++++++++++++---------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java | 224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCore.java | 8 ++++---- src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java | 92 ++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java | 78 +++++++++++++++++++++++++++++++++++++++--------------------------------------- src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java | 60 ++++++++++++++++++++++++++++++------------------------------ src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java | 248 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------- src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java | 12 ++++++------ 27 files changed, 972 insertions(+), 971 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java index 5aaa548..6695667 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java @@ -44,28 +44,13 @@ public class EpnTapConnection implements EpnTapInterface { // *** Resource *** @Override - public Resource getEPNVOresource(String ivoid) throws VOResourceException { - return VOResourceCtrl.getVOresource(ivoid); + public String getEPNCoreTableName(String ivoid) throws VOTableException { + return (String) ServiceCtrl.getParameter(ivoid, "table_name"); } // *** Resources *** @Override - public List getEPNVOResources() throws VOResourceException { - List ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE); - return VOResourceCtrl.getVOResources(ivoids); - } - - @Override - public List getEPNVOResources(List keywords) - throws VOResourceException { - List ivoids = VOResourceCtrl.getVOResources(ServiceCore.EPNCORE, keywords); - return VOResourceCtrl.getVOResources(ivoids); - } - - // *** Service *** - - @Override public VOTABLE getEPNService(String ivoid) throws VOTableException { String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_IVOID, ivoid); return ServiceCtrl.getVoTable(query); @@ -79,7 +64,7 @@ public class EpnTapConnection implements EpnTapInterface { return ServiceCtrl.getVoTable(query); } - // *** Services *** + // *** Service *** @Override public VOTABLE getEPNServices() throws VOTableException { @@ -95,6 +80,8 @@ public class EpnTapConnection implements EpnTapInterface { return ServiceCtrl.getVoTable(query); } + // *** Services *** + @Override public VOTABLE getEPNServices(List keywords, List attributes) throws VOTableException { @@ -109,11 +96,24 @@ public class EpnTapConnection implements EpnTapInterface { return ServiceCtrl.getVoTable(query); } + @Override + public Resource getEPNVOresource(String ivoid) throws VOResourceException { + return VOResourceCtrl.getVOresource(ivoid); + } + + @Override + public List getEPNVOResources() throws VOResourceException { + List ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE); + return VOResourceCtrl.getVOResources(ivoids); + } + // *** Getters *** @Override - public String getEPNCoreTableName(String ivoid) throws VOTableException { - return (String) ServiceCtrl.getParameter(ivoid, "table_name"); + public List getEPNVOResources(List keywords) + throws VOResourceException { + List ivoids = VOResourceCtrl.getVOResources(ServiceCore.EPNCORE, keywords); + return VOResourceCtrl.getVOResources(ivoids); } @Override diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java index f105fb3..314da2e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java @@ -37,12 +37,6 @@ public abstract class EpnTapController { /** The logger for the class EpnTapController. */ private static final Logger LOGGER = Logger.getLogger(EpnTapController.class.getName()); - /** - * The path of the VOTable to parse. Will be affected to a temporary folder if not assigned - * through the controller. - */ - private String voTablePath; - /** The request controller, to manage requests. */ private RequestCtrl requestCtrl; @@ -52,6 +46,12 @@ public abstract class EpnTapController { /** The controller of the VOTable displaying the list of services. */ private VOTableController servicesCtrl; + /** + * The path of the VOTable to parse. Will be affected to a temporary folder if not assigned + * through the controller. + */ + private String voTablePath; + /** * Method constructor, which initialize servicesController, resultsController and mainView. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java index 22388e5..d7c024b 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java @@ -33,42 +33,17 @@ public interface EpnTapInterface { // *** Resource *** /** - * Returns the VOResource element of the service identified by the ivoID. + * Returns the name of the EPNCore Table related to a service. * - * @param ivoid the ivoid of the service. - * @return The Resource of a service corresponding to the ivoid - * @throws VOResourceException Can not get the VOResource. + * @param ivoid The ivoid of the service. + * @return The table name of the service, used usually in the 'FROM' keyword in a ADQL query. + * @throws VOTableException Can not get the VOTable. */ - public Resource getEPNVOresource(String ivoid) throws VOResourceException; + public String getEPNCoreTableName(String ivoid) throws VOTableException; // *** Resources *** /** - * Returns a set of VOResource elements (one per EPN-TAP service). - * - * @return A list containing the VOResources of all EpnTap services. - * @throws VOResourceException Can not get the VOResource. - */ - public List getEPNVOResources() throws VOResourceException; - - /** - * Returns a set of VOREsource elements (one per EPN-TAP service corresponding to the keywords). - * The way keywords are defined is still to be defined. - * - * @param keywords A list of keywords, which are the content of the *subject* JSON node in the - * query. - * @see - * this example request - * @return A list containing the selected VOResources. - * @throws VOResourceException Can not get the VOResource. - */ - public List getEPNVOResources(List keywords) - throws VOResourceException; - - // *** Service *** - - /** * Returns a VOTable containing the attributes of the corresponding service (from a predefined * list). * @@ -91,7 +66,7 @@ public interface EpnTapInterface { public VOTABLE getEPNService(String ivoid, List attributes) throws VOTableException; - // *** Services *** + // *** Service *** /** * Returns a VOTable containing the list of EPN-TAP services and their attributes (from a @@ -112,6 +87,8 @@ public interface EpnTapInterface { */ public VOTABLE getEPNServices(List attributes) throws VOTableException; + // *** Services *** + /** * Returns a VOTable containing the list of EPN-TAP services corresponding to the keywords and * their attributes (from the list of attributes). @@ -125,16 +102,39 @@ public interface EpnTapInterface { public VOTABLE getEPNServices(List keywords, List attributes) throws VOTableException; + /** + * Returns the VOResource element of the service identified by the ivoID. + * + * @param ivoid the ivoid of the service. + * @return The Resource of a service corresponding to the ivoid + * @throws VOResourceException Can not get the VOResource. + */ + public Resource getEPNVOresource(String ivoid) throws VOResourceException; + + /** + * Returns a set of VOResource elements (one per EPN-TAP service). + * + * @return A list containing the VOResources of all EpnTap services. + * @throws VOResourceException Can not get the VOResource. + */ + public List getEPNVOResources() throws VOResourceException; + // *** Getters *** /** - * Returns the name of the EPNCore Table related to a service. + * Returns a set of VOREsource elements (one per EPN-TAP service corresponding to the keywords). + * The way keywords are defined is still to be defined. * - * @param ivoid The ivoid of the service. - * @return The table name of the service, used usually in the 'FROM' keyword in a ADQL query. - * @throws VOTableException Can not get the VOTable. + * @param keywords A list of keywords, which are the content of the *subject* JSON node in the + * query. + * @see + * this example request + * @return A list containing the selected VOResources. + * @throws VOResourceException Can not get the VOResource. */ - public String getEPNCoreTableName(String ivoid) throws VOTableException; + public List getEPNVOResources(List keywords) + throws VOResourceException; /** * Returns the Access URL of an EPN-TAP Service. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java index f70c658..786aba0 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java @@ -32,15 +32,15 @@ import eu.omp.irap.vespa.votable.votabledata.VOTableData; */ public class GranuleCtrl { + /** The error message when the specified row is not found. */ + private static final String ERROR_MSG = "%s not found in the rowId %s: return %s."; + /** The logger for the class GranuleCtrl. */ private static final Logger LOGGER = Logger.getLogger(GranuleCtrl.class.getName()); /** The data to parse */ private VOTableData data; - /** The error message when the specified row is not found. */ - private static final String ERROR_MSG = "%s not found in the rowId %s: return %s."; - /** * Constructor of GranuleCtrl @@ -52,79 +52,6 @@ public class GranuleCtrl { } /** - * Parse a String value in the VOTable data at the specified row and column. - * - * @param rowId The row identifier - * @param granule The Granule enumeration, representing the column name. - * @return The value as String. - * @throws CanNotParseDataException The column name was not found in the list. - */ - private String parseString(int rowId, GranuleEnum granule) throws CanNotParseDataException { - String res = ""; - try { - res = (String) data.getCell(rowId, granule.toString()); - } catch (IllegalArgumentException e) { - LOGGER.log(Level.WARNING, String.format(ERROR_MSG, granule, rowId, "empty string"), e); - } - return res; - } - - /** - * Parse a Date value in the VOTable data at the specified row and column. - * - * @param rowId The row identifier - * @param granule The Granule enumeration, representing the column name. - * @return The value as Date. - * @throws ParseException The date format is not correct. - * @throws CanNotParseDataException The column name was not found in the list. - */ - private Date parseDate(int rowId, GranuleEnum granule) - throws ParseException, CanNotParseDataException { - SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); - Date date = new Date(); - try { - date = sdf.parse((String) data.getCell(rowId, granule.toString())); - } catch (IllegalArgumentException e) { - LOGGER.log(Level.WARNING, String.format(ERROR_MSG, granule, rowId, "empty date"), e); - } - - return date; - } - - /** - * Parse a Double value in the VOTable data at the specified row and column. - * - * @param rowId The row identifier - * @param granule The Granule enumeration, representing the column name. - * @return The value as Double. - * @throws CanNotParseDataException The column name was not found in the list. - */ - private Double parseDouble(int rowId, GranuleEnum granule) throws CanNotParseDataException { - Double d = null; - Object lObj = data.getCell(rowId, granule.toString()); - if (lObj instanceof Double) { - d = (Double) lObj; - } - if (lObj instanceof Float) { - d = new Double((Float) lObj); - } - - return d == null ? Double.NaN : d; - } - - /** - * Parse a Double value in the VOTable data at the specified row and column. - * - * @param rowId The row identifier - * @param granule The Granule enumeration, representing the column name. - * @return The value as Double. - * @throws CanNotParseDataException The column name was not found in the list. - */ - private Integer parseInteger(int rowId, GranuleEnum granule) throws CanNotParseDataException { - return (Integer) data.getCell(rowId, granule.toString()); - } - - /** * Get a Granule object from a VOTable data row. * * @param rowId the row identified @@ -190,13 +117,6 @@ public class GranuleCtrl { } /** - * @return true if the VOTable data implements the EpnCoreV2. - */ - public boolean isV2() { - return !data.isContainingColumnName("index"); - } - - /** * @return A list of Granules from a VOTable, where each Granule is a row of the VOTable data. * @throws ParseException If the granule can not be parsed. * @throws CanNotParseDataException The column name was not found in the list. @@ -216,4 +136,84 @@ public class GranuleCtrl { return granules; } + /** + * @return true if the VOTable data implements the EpnCoreV2. + */ + public boolean isV2() { + return !data.isContainingColumnName("index"); + } + + /** + * Parse a Date value in the VOTable data at the specified row and column. + * + * @param rowId The row identifier + * @param granule The Granule enumeration, representing the column name. + * @return The value as Date. + * @throws ParseException The date format is not correct. + * @throws CanNotParseDataException The column name was not found in the list. + */ + private Date parseDate(int rowId, GranuleEnum granule) + throws ParseException, CanNotParseDataException { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd"); + Date date = new Date(); + try { + date = sdf.parse((String) data.getCell(rowId, granule.toString())); + } catch (IllegalArgumentException e) { + LOGGER.log(Level.WARNING, String.format(ERROR_MSG, granule, rowId, "empty date"), e); + } + + return date; + } + + /** + * Parse a Double value in the VOTable data at the specified row and column. + * + * @param rowId The row identifier + * @param granule The Granule enumeration, representing the column name. + * @return The value as Double. + * @throws CanNotParseDataException The column name was not found in the list. + */ + private Double parseDouble(int rowId, GranuleEnum granule) throws CanNotParseDataException { + Double d = null; + Object lObj = data.getCell(rowId, granule.toString()); + if (lObj instanceof Double) { + d = (Double) lObj; + } + if (lObj instanceof Float) { + d = new Double((Float) lObj); + } + + return d == null ? Double.NaN : d; + } + + /** + * Parse a Double value in the VOTable data at the specified row and column. + * + * @param rowId The row identifier + * @param granule The Granule enumeration, representing the column name. + * @return The value as Double. + * @throws CanNotParseDataException The column name was not found in the list. + */ + private Integer parseInteger(int rowId, GranuleEnum granule) throws CanNotParseDataException { + return (Integer) data.getCell(rowId, granule.toString()); + } + + /** + * Parse a String value in the VOTable data at the specified row and column. + * + * @param rowId The row identifier + * @param granule The Granule enumeration, representing the column name. + * @return The value as String. + * @throws CanNotParseDataException The column name was not found in the list. + */ + private String parseString(int rowId, GranuleEnum granule) throws CanNotParseDataException { + String res = ""; + try { + res = (String) data.getCell(rowId, granule.toString()); + } catch (IllegalArgumentException e) { + LOGGER.log(Level.WARNING, String.format(ERROR_MSG, granule, rowId, "empty string"), e); + } + return res; + } + } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleEnum.java b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleEnum.java index 4dff93b..bf1e592 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleEnum.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleEnum.java @@ -25,95 +25,93 @@ import java.util.Date; */ @SuppressWarnings("javadoc") public enum GranuleEnum { - //@noformat - GRANULE_UID("granule_uid", String.class, true, true, "", "meta.id", ""), - GRANULE_GID("granule_gid", String.class, true, true, "", "meta.id", "Common to granules of same type (e.g. same map projection, or geometry data products). Can be alphanum."), - OBS_ID("obs_id", String.class, true, true, "", "meta.id", "Associates granules derived from the same data (e.g. various representations / processing levels). Can be alphanum., may be the ID of original observation."), - DATAPRODUCT_TYPE("dataproduct_type", String.class, true, true, "", "meta.code.class", "Organization of the data product, from enumerated list"), - TARGET_NAME("target_name", String.class, true, true, "", "meta.id;src", "Standard IAU name of target (from a list related to target class), case sensitive"), - TARGET_CLASS("target_class", String.class, true, true, "", "meta.code.class;src", "Type of target, from enumerated list"), - TIME_MIN("time_min", Double.class, true, false, "d (date as JD)", "time.start", ""), - TIME_MAX("time_max", Double.class, true, false, "d (date as JD)", "time.end", ""), - TIME_SAMPLING_STEP_MIN("time_sampling_step_min", Double.class, true, false, "s", "time.interval;stat.min", "Min time sampling step"), - TIME_SAMPLING_STEP_MAX("time_sampling_step_max", Double.class, true, false, "s", "time.interval;stat.max", "Max time sampling step"), - TIME_EXP_MIN("time_exp_min", Double.class, true, false, "s", "", "Min integration time"), - TIME_EXP_MAX("time_exp_max", Double.class, true, false, "s", "time.duration;obs.exposure;stat.max", "Max integration time"), - SPECTRAL_RANGE_MIN("spectral_range_min", Double.class, true, false, "Hz", "em.freq;stat.min", "Min spectral range (frequency)"), - SPECTRAL_RANGE_MAX("spectral_range_max", Double.class, true, false, "Hz", "em.freq;stat.max", "Max spectral range (frequency)"), - SPECTRAL_SAMPLING_STEP_MIN("spectral_sampling_step_min", Double.class, true, false, "Hz", "", "Min spectral sampling step"), - SPECTRAL_SAMPLING_STEP_MAX("spectral_sampling_step_max", Double.class, true, false, "Hz", "", "Max spectral sampling step"), - SPECTRAL_RESOLUTION_MIN("spectral_resolution_min", Double.class, true, false, "Hz", "spect.resolution;stat.min", ""), - SPECTRAL_RESOLUTION_MAX("spectral_resolution_max", Double.class, true, false, "Hz", "spect.resolution;stat.max", "Max spectral resolution"), - C1MIN("c1min", Double.class, true, false, "", "pos;stat.min", "Min of first coordinate"), - C1MAX("c1max", Double.class, true, false, "", "pos;stat.max", "Max of first coordinate"), - C2MIN("c2min", Double.class, true, false, "", "pos;stat.min", "Min of second coordinate"), - C2MAX("c2max", Double.class, true, false, "", "pos;stat.max", "Max of second coordinate"), - C3MIN("c3min", Double.class, true, false, "", "pos;stat.min", "Min of third coordinate"), - C3MAX("c3max", Double.class, true, false, "", "pos;stat.max", "Max of third coordinate"), - S_REGION("s_region", String.class, true, false, "", "instr.fov", "ObsCore-like footprint, assume spatial_coordinate_description"), - C1_RESOL_MIN("c1_resol_min", Double.class, true, false, "", "", "Min resolution in first coordinate"), + + ACCESS_ESTSIZE("access_estsize", Integer.class, false, false, "kbyte", "", "Estimate file size in kbyte (with this spelling)"), + ACCESS_FORMAT("access_format", String.class, false, false, "", "meta.code.mime", ""), + ACCESS_MD5("access_md5", String.class, false, false, "", "", "MD5 Hash for the file when available (real file)"), + ACCESS_URL("access_url", String.class, false, false, "", "meta.ref.url;meta.file", ""), + ALT_TARGET_NAME("alt_target_name", String.class, false, false, "", "meta.id;src", "Provides alternative target name if more common (e.g. comets)"), + BIB_REFERENCE("bib_reference", String.class, false, false, "", "meta.bib", "Bibcode, doi, or other biblio id, URL"), C1_RESOL_MAX("c1_resol_max", Double.class, true, false, "", "pos.resolution;stat.max", "Max resolution in first coordinate"), - C2_RESOL_MIN("c2_resol_min", Double.class, true, false, "", "pos.resolution;stat.min", "Min resolution in second coordinate"), + C1_RESOL_MIN("c1_resol_min", Double.class, true, false, "", "", "Min resolution in first coordinate"), + C1MAX("c1max", Double.class, true, false, "", "pos;stat.max", "Max of first coordinate"), + C1MIN("c1min", Double.class, true, false, "", "pos;stat.min", "Min of first coordinate"), C2_RESOL_MAX("c2_resol_max", Double.class, true, false, "", "pos.resolution;stat.max", "Max resolution in second coordinate"), - C3_RESOL_MIN("c3_resol_min", Double.class, true, false, "", "pos.resolution;stat.min", "Min resolution in third coordinate"), + C2_RESOL_MIN("c2_resol_min", Double.class, true, false, "", "pos.resolution;stat.min", "Min resolution in second coordinate"), + C2MAX("c2max", Double.class, true, false, "", "pos;stat.max", "Max of second coordinate"), + C2MIN("c2min", Double.class, true, false, "", "pos;stat.min", "Min of second coordinate"), C3_RESOL_MAX("c3_resol_max", Double.class, true, false, "", "pos.resolution;stat.max", "Max resolution in third coordinate"), - SPATIAL_FRAME_TYPE("spatial_frame_type", String.class, true, false, "", "meta.code.class;pos.frame", "Flavor of coordinate system, defines the nature of coordinates. From enumerated list"), - INCIDENCE_MIN("incidence_min", Double.class, true, false, "deg", "pos.posAng;stat.min", "Min incidence angle (solar zenithal angle)"), - INCIDENCE_MAX("incidence_max", Double.class, true, false, "deg", "pos.posAng;stat.max", "Max incidence angle (solar zenithal angle)"), - EMERGENCE_MIN("emergence_min", Double.class, true, false, "deg", "pos.posAng;stat.min", "Min emergence angle"), + C3_RESOL_MIN("c3_resol_min", Double.class, true, false, "", "pos.resolution;stat.min", "Min resolution in third coordinate"), + C3MAX("c3max", Double.class, true, false, "", "pos;stat.max", "Max of third coordinate"), + C3MIN("c3min", Double.class, true, false, "", "pos;stat.min", "Min of third coordinate"), + CREATION_DATE("creation_date", Date.class, true, true, "", "time.creation", "Date of first entry of this granule"), + DATA_ACCESS_URL("data_access_url", String.class, false, false, "", "", "If access_format indicates a detached label, this parameter is mandatory and points to the corresponding data file - both will be handled by the client before samping it to tools or downloading"), + DATAPRODUCT_TYPE("dataproduct_type", String.class, true, true, "", "meta.code.class", "Organization of the data product, from enumerated list"), + DEC("dec", Double.class, false, false, "deg", "pos.eq.dec;meta.main", "Declination"), EMERGENCE_MAX("emergence_max", Double.class, true, false, "deg", "pos.posAng;stat.max", "Max emergence angle"), - PHASE_MIN("phase_min", Double.class, true, false, "deg", "pos.phaseAng;stat.min", "Min phase angle"), - PHASE_MAX("phase_max", Double.class, true, false, "deg", "pos.phaseAng;stat.max", "Max phase angle"), + EMERGENCE_MIN("emergence_min", Double.class, true, false, "deg", "pos.posAng;stat.min", "Min emergence angle"), + FEATURE_NAME("feature_name", String.class, false, false, "", "meta.id;pos", ""), + FILE_NAME("file_name", String.class, false, false, "", "meta.id;meta.file", "Name of the data file only, case sensitive"), + GRANULE_GID("granule_gid", String.class, true, true, "", "meta.id", "Common to granules of same type (e.g. same map projection, or geometry data products). Can be alphanum."), + GRANULE_UID("granule_uid", String.class, true, true, "", "meta.id", ""), + INCIDENCE_MAX("incidence_max", Double.class, true, false, "deg", "pos.posAng;stat.max", "Max incidence angle (solar zenithal angle)"), + INCIDENCE_MIN("incidence_min", Double.class, true, false, "deg", "pos.posAng;stat.min", "Min incidence angle (solar zenithal angle)"), INSTRUMENT_HOST_NAME("instrument_host_name", String.class, true, false, "", "", "Standard name of the observatory or spacecraft"), INSTRUMENT_NAME("instrument_name", String.class, true, false, "", "meta.id;instr", "Standard name of instrument"), + LOCAL_TIME_MAX("local_time_max", Double.class, false, false, "h", "time.phase;stat.max?", "Local time at observed region"), + LOCAL_TIME_MIN("local_time_min", Double.class, false, false, "h", "time.phase;stat.min?", "Local time at observed region"), MEASUREMENT_TYPE("measurement_type", String.class, true, false, "", "meta.ucd", "UCD(s) defining the data"), - PROCESSING_LEVEL("processing_level", Integer.class, true, false, "", "meta.code;obs.calib", "CODMAC calibration level in v1"), - CREATION_DATE("creation_date", Date.class, true, true, "", "time.creation", "Date of first entry of this granule"), MODIFICATION_DATE("modification_date", Date.class, true, true, "", "time.update", "Date of last modification (used to handle mirroring)"), - RELEASE_DATE("release_date", Date.class, true, true, "", "time.release", ""), - SERVICE_TITLE("service_title", String.class, true, true, "", "meta.title", ""), - ACCESS_URL("access_url", String.class, false, false, "", "meta.ref.url;meta.file", ""), - ACCESS_FORMAT("access_format", String.class, false, false, "", "meta.code.mime", ""), - ACCESS_ESTSIZE("access_estsize", Integer.class, false, false, "kbyte", "", "Estimate file size in kbyte (with this spelling)"), - DATA_ACCESS_URL("data_access_url", String.class, false, false, "", "", "If access_format indicates a detached label, this parameter is mandatory and points to the corresponding data file - both will be handled by the client before samping it to tools or downloading"), - ACCESS_MD5("access_md5", String.class, false, false, "", "", "MD5 Hash for the file when available (real file)"), - THUMBNAIL_URL("thumbnail_url", String.class, false, false, "", "meta.ref.url;meta.file", "URL of a thumbnail image with predefined size (png ~200 pix, for use in a client only)"), - FILE_NAME("file_name", String.class, false, false, "", "meta.id;meta.file", "Name of the data file only, case sensitive"), - SPECIES("species", String.class, false, false, "", "meta.id;phys.atmol", "Identifies a chemical species, case sensitive"), - ALT_TARGET_NAME("alt_target_name", String.class, false, false, "", "meta.id;src", "Provides alternative target name if more common (e.g. comets)"), - TARGET_REGION("target_region", String.class, false, false, "", "meta.id;class", ""), - FEATURE_NAME("feature_name", String.class, false, false, "", "meta.id;pos", ""), - BIB_REFERENCE("bib_reference", String.class, false, false, "", "meta.bib", "Bibcode, doi, or other biblio id, URL"), - RA("ra", Double.class, false, false, "deg or h:m:s?", "pos.eq.ra;meta.main", ""), - DEC("dec", Double.class, false, false, "deg", "pos.eq.dec;meta.main", "Declination"), - SOLAR_LONGITUDE_MIN("solar_longitude_min", Double.class, false, false, "deg", "pos.posangle (TBC)", "Min Solar longitude Ls (location on orbit / season)"), - SOLAR_LONGITUDE_MAX("solar_longitude_max", Double.class, false, false, "deg", "pos.posangle (TBC)", "Max Solar longitude Ls (location on orbit / season)"), - LOCAL_TIME_MIN("local_time_min", Double.class, false, false, "h", "time.phase;stat.min?", "Local time at observed region"), - LOCAL_TIME_MAX("local_time_max", Double.class, false, false, "h", "time.phase;stat.max?", "Local time at observed region"), - TARGET_DISTANCE_MIN("target_distance_min", Double.class, false, false, "km", "pos.distance;stat.min", "Observer-target distance"), - TARGET_DISTANCE_MAX("target_distance_max", Double.class, false, false, "km", "pos.distance;stat.max", "Observer-target distance"), - TARGET_TIME_MIN("target_time_min", Double.class, false, false, "d", "", ""), - TARGET_TIME_MAX("target_time_max", Double.class, false, false, "d", "", ""), - PARTICLE_SPECTRAL_TYPE("particle_spectral_type", String.class, false, false, "", "", ""), - PARTICLE_SPECTRAL_RANGE_MIN("particle_spectral_range_min", Double.class, false, false, "", "", ""), + OBS_ID("obs_id", String.class, true, true, "", "meta.id", "Associates granules derived from the same data (e.g. various representations / processing levels). Can be alphanum., may be the ID of original observation."), PARTICLE_SPECTRAL_RANGE_MAX("particle_spectral_range_max", Double.class, false, false, "", "", ""), - PARTICLE_SPECTRAL_SAMPLING_STEP_MIN("particle_spectral_sampling_step_min", Double.class, false, false, "", "", ""), - PARTICLE_SPECTRAL_SAMPLING_STEP_MAX("particle_spectral_sampling_step_max", Double.class, false, false, "", "", ""), - PARTICLE_SPECTRAL_RESOLUTION_MIN("particle_spectral_resolution_min", Double.class, false, false, "", "spect.resolution;stat.min", ""), + PARTICLE_SPECTRAL_RANGE_MIN("particle_spectral_range_min", Double.class, false, false, "", "", ""), PARTICLE_SPECTRAL_RESOLUTION_MAX("particle_spectral_resolution_max", Double.class, false, false, "", "spect.resolution;stat.max", ""), + PARTICLE_SPECTRAL_RESOLUTION_MIN("particle_spectral_resolution_min", Double.class, false, false, "", "spect.resolution;stat.min", ""), + PARTICLE_SPECTRAL_SAMPLING_STEP_MAX("particle_spectral_sampling_step_max", Double.class, false, false, "", "", ""), + PARTICLE_SPECTRAL_SAMPLING_STEP_MIN("particle_spectral_sampling_step_min", Double.class, false, false, "", "", ""), + PARTICLE_SPECTRAL_TYPE("particle_spectral_type", String.class, false, false, "", "", ""), + PHASE_MAX("phase_max", Double.class, true, false, "deg", "pos.phaseAng;stat.max", "Max phase angle"), + PHASE_MIN("phase_min", Double.class, true, false, "deg", "pos.phaseAng;stat.min", "Min phase angle"), + PROCESSING_LEVEL("processing_level", Integer.class, true, false, "", "meta.code;obs.calib", "CODMAC calibration level in v1"), PUBLISHER("publisher", String.class, false, false, "", "meta.name", "Resource publisher"), + RA("ra", Double.class, false, false, "deg or h:m:s?", "pos.eq.ra;meta.main", ""), + RELEASE_DATE("release_date", Date.class, true, true, "", "time.release", ""), + S_REGION("s_region", String.class, true, false, "", "instr.fov", "ObsCore-like footprint, assume spatial_coordinate_description"), + SERVICE_TITLE("service_title", String.class, true, true, "", "meta.title", ""), + SOLAR_LONGITUDE_MAX("solar_longitude_max", Double.class, false, false, "deg", "pos.posangle (TBC)", "Max Solar longitude Ls (location on orbit / season)"), + SOLAR_LONGITUDE_MIN("solar_longitude_min", Double.class, false, false, "deg", "pos.posangle (TBC)", "Min Solar longitude Ls (location on orbit / season)"), SPATIAL_COORDINATE_DESCRIPTION("spatial_coordinate_description", String.class, false, false, "", "", "ID of specific coordinate system and version"), + SPATIAL_FRAME_TYPE("spatial_frame_type", String.class, true, false, "", "meta.code.class;pos.frame", "Flavor of coordinate system, defines the nature of coordinates. From enumerated list"), SPATIAL_ORIGIN("spatial_origin", String.class, false, false, "", "meta.ref;pos.frame", "Defines the frame origin"), + SPECIES("species", String.class, false, false, "", "meta.id;phys.atmol", "Identifies a chemical species, case sensitive"), + SPECTRAL_RANGE_MAX("spectral_range_max", Double.class, true, false, "Hz", "em.freq;stat.max", "Max spectral range (frequency)"), + SPECTRAL_RANGE_MIN("spectral_range_min", Double.class, true, false, "Hz", "em.freq;stat.min", "Min spectral range (frequency)"), + SPECTRAL_RESOLUTION_MAX("spectral_resolution_max", Double.class, true, false, "Hz", "spect.resolution;stat.max", "Max spectral resolution"), + SPECTRAL_RESOLUTION_MIN("spectral_resolution_min", Double.class, true, false, "Hz", "spect.resolution;stat.min", ""), + SPECTRAL_SAMPLING_STEP_MAX("spectral_sampling_step_max", Double.class, true, false, "Hz", "", "Max spectral sampling step"), + SPECTRAL_SAMPLING_STEP_MIN("spectral_sampling_step_min", Double.class, true, false, "Hz", "", "Min spectral sampling step"), + TARGET_CLASS("target_class", String.class, true, true, "", "meta.code.class;src", "Type of target, from enumerated list"), + TARGET_DISTANCE_MAX("target_distance_max", Double.class, false, false, "km", "pos.distance;stat.max", "Observer-target distance"), + TARGET_DISTANCE_MIN("target_distance_min", Double.class, false, false, "km", "pos.distance;stat.min", "Observer-target distance"), + TARGET_NAME("target_name", String.class, true, true, "", "meta.id;src", "Standard IAU name of target (from a list related to target class), case sensitive"), + TARGET_REGION("target_region", String.class, false, false, "", "meta.id;class", ""), + TARGET_TIME_MAX("target_time_max", Double.class, false, false, "d", "", ""), + TARGET_TIME_MIN("target_time_min", Double.class, false, false, "d", "", ""), + THUMBNAIL_URL("thumbnail_url", String.class, false, false, "", "meta.ref.url;meta.file", "URL of a thumbnail image with predefined size (png ~200 pix, for use in a client only)"), + TIME_EXP_MAX("time_exp_max", Double.class, true, false, "s", "time.duration;obs.exposure;stat.max", "Max integration time"), + TIME_EXP_MIN("time_exp_min", Double.class, true, false, "s", "", "Min integration time"), + TIME_MAX("time_max", Double.class, true, false, "d (date as JD)", "time.end", ""), + TIME_MIN("time_min", Double.class, true, false, "d (date as JD)", "time.start", ""), TIME_ORIGIN("time_origin", String.class, false, false, "", "", ""), + TIME_SAMPLING_STEP_MAX("time_sampling_step_max", Double.class, true, false, "s", "time.interval;stat.max", "Max time sampling step"), + TIME_SAMPLING_STEP_MIN("time_sampling_step_min", Double.class, true, false, "s", "time.interval;stat.min", "Min time sampling step"), TIME_SCALE("time_scale", String.class, false, false, "", "time.scale", ""); - //@format - /** The name of the granule parameter. */ - private String name; + //@format - /** The type of the granule parameter. */ - private Class type; + /** A short text describing the granule parameter. */ + private String description; /** true if the granule parameter is mandatory, false if it is optional. */ private boolean isMandatory; @@ -121,14 +119,17 @@ public enum GranuleEnum { /** true if the granule parameter must be actually filled, false if the value can be null. */ private boolean mustBeFilled; - /** The unit of the granule parameter (ie. degree, km, etc.). */ - private String unit; + /** The name of the granule parameter. */ + private String name; + + /** The type of the granule parameter. */ + private Class type; /** The UCD of the granule parameter. */ private String ucd; - /** A short text describing the granule parameter. */ - private String description; + /** The unit of the granule parameter (ie. degree, km, etc.). */ + private String unit; /** @@ -153,9 +154,11 @@ public enum GranuleEnum { this.description = description; } - @Override - public String toString() { - return name; + /** + * @return A short text describing the granule parameter. + */ + public String getDescription() { + return description; } /** @@ -173,17 +176,10 @@ public enum GranuleEnum { } /** - * @return true if the granule parameter is mandatory, false if it is optional. - */ - public boolean isMandatory() { - return isMandatory; - } - - /** - * @return true if the granule parameter must be actually filled false if the value can be null. + * @return The UCD of the granule parameter. */ - public boolean isMustBeFilled() { - return mustBeFilled; + public String getUcd() { + return ucd; } /** @@ -194,17 +190,22 @@ public enum GranuleEnum { } /** - * @return The UCD of the granule parameter. + * @return true if the granule parameter is mandatory, false if it is optional. */ - public String getUcd() { - return ucd; + public boolean isMandatory() { + return isMandatory; } /** - * @return A short text describing the granule parameter. + * @return true if the granule parameter must be actually filled false if the value can be null. */ - public String getDescription() { - return description; + public boolean isMustBeFilled() { + return mustBeFilled; + } + + @Override + public String toString() { + return name; } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/GUIDim.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/GUIDim.java index a272645..5e74d00 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/GUIDim.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/GUIDim.java @@ -23,30 +23,30 @@ package eu.omp.irap.vespa.epntapclient.gui.mainpanel; */ public class GUIDim { - /** The width of the left panel (services view). */ - public static final int LEFT_PANEL_WIDTH = 550; + /** The height of the bottom panel (result view). */ + public static final int BOTTOM_PANEL_HEIGHT = 150; + + /** The minimum height of the bottom panel (result view). */ + public static final int BOTTOM_PANEL_MIN_HEIGHT = 100; /** The minimum width of the left panel (services view). */ public static final int LEFT_PANEL_MIN_WIDTH = 300; - /** The width of the right panel (request view). */ - public static final int RIGHT_PANEL_WIDTH = 450; + /** The width of the left panel (services view). */ + public static final int LEFT_PANEL_WIDTH = 550; /** The minimum width of the right panel (request view). */ public static final int RIGHT_PANEL_MIN_WIDTH = 220; + /** The width of the right panel (request view). */ + public static final int RIGHT_PANEL_WIDTH = 450; + /** The height of the top panel (request view and services view). */ public static final int TOP_PANEL_HEIGHT = 400; /** The minimum height of the top panel (request view and services view). */ public static final int TOP_PANEL_MIN_HEIGHT = 100; - /** The height of the bottom panel (result view). */ - public static final int BOTTOM_PANEL_HEIGHT = 150; - - /** The minimum height of the bottom panel (result view). */ - public static final int BOTTOM_PANEL_MIN_HEIGHT = 100; - /** Private constructor to hide the implicit public one. */ private GUIDim() { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java index 4fdcc35..f626762 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java @@ -23,11 +23,11 @@ import java.util.List; */ public interface MainPanelListener { + void displayError(String message, Exception e); + List getTableNames(); void sendQuery(); void updateQuery(); - - void displayError(String message, Exception e); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java index d935e85..1971dba 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelView.java @@ -37,15 +37,15 @@ public class MainPanelView extends JPanel { /** The serial version UID. */ private static final long serialVersionUID = 1L; + /** The JPanel where the user build the query. */ + private RequestPanelView requestPanel; + /** The JPanel where the VOTable results is displayed. */ private ResultPanelView resultPanel; /** The JPanel where the list of services is displayed. */ private ServicesPanelView servicesPanel; - /** The JPanel where the user build the query. */ - private RequestPanelView requestPanel; - /** * The main view constructor, which create all the panels. @@ -61,6 +61,38 @@ public class MainPanelView extends JPanel { } /** + * Display an error message. Usually used each time an error happens. + * + * @param title The title of the error. + * @param message The message of the error. + */ + public void displayError(String title, String message) { + JOptionPane.showMessageDialog(this, message, title, + JOptionPane.ERROR_MESSAGE); + } + + /** + * @return The JPanel containing the GUI elements to build the query. + */ + public RequestPanelView getRequestPanel() { + return requestPanel; + } + + /** + * @return The JPanel where the VOTable result is displayed. + */ + public ResultPanelView getResultsPanel() { + return resultPanel; + } + + /** + * @return The JPanel where the list of services is displayed. + */ + public ServicesPanelView getServicesPanel() { + return servicesPanel; + } + + /** * Build the panel and add GUI elements on it. */ private void buildMainView() { @@ -98,36 +130,4 @@ public class MainPanelView extends JPanel { GUIDim.BOTTOM_PANEL_MIN_HEIGHT)); } - /** - * @return The JPanel where the VOTable result is displayed. - */ - public ResultPanelView getResultsPanel() { - return resultPanel; - } - - /** - * @return The JPanel containing the GUI elements to build the query. - */ - public RequestPanelView getRequestPanel() { - return requestPanel; - } - - /** - * @return The JPanel where the list of services is displayed. - */ - public ServicesPanelView getServicesPanel() { - return servicesPanel; - } - - /** - * Display an error message. Usually used each time an error happens. - * - * @param title The title of the error. - * @param message The message of the error. - */ - public void displayError(String title, String message) { - JOptionPane.showMessageDialog(this, message, title, - JOptionPane.ERROR_MESSAGE); - } - } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java index e8be638..ba22ffb 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelListener.java @@ -22,11 +22,6 @@ package eu.omp.irap.vespa.epntapclient.gui.requestpanel; public interface RequestPanelListener { /** - * Method called when the used click on the 'Send query' button. - */ - void onSendButtonClicked(); - - /** * Method called when the user remove a parameter with a parameter field. * * @param paramName The name of the removed parameter @@ -40,4 +35,9 @@ public interface RequestPanelListener { * @param paramValue The new value of the parameter. */ void onParameterUpdated(String paramName, Object paramValue); + + /** + * Method called when the used click on the 'Send query' button. + */ + void onSendButtonClicked(); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java index d2e2ae7..2d265ec 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelView.java @@ -42,20 +42,26 @@ import eu.omp.irap.vespa.epntapclient.gui.requestpanel.paramfield.TargetNameFiel */ public class RequestPanelView extends JPanel { + /** The height of the buttons panel. */ + private static final int BUTTON_PANEL_HEIGHT = 20; + /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The height of the buttons panel. */ - private static final int BUTTON_PANEL_HEIGHT = 20; + /** The GUI element of the button to send the query. */ + private JButton buttonSend; - /** The listener for the request panel. */ - RequestPanelListener listener; + /** A field to set the dataproduct_type parameter. */ + private DataProductTypeField dataProductTypeField; + + /** The parameters fields for the request. */ + private List paramFields; /** The text area where the user write the query. */ private JTextArea queryArea; - /** The parameters fields for the request. */ - private List paramFields; + /** A field to set the spectral_range parameter. */ + private FloatRangeField spectralRangeField; /** A field to set the target_name parameter. */ private TargetNameField targetNameField; @@ -63,14 +69,8 @@ public class RequestPanelView extends JPanel { /** A field to set the time_range parameter. */ private DateRangeField timeRangeField; - /** A field to set the spectral_range parameter. */ - private FloatRangeField spectralRangeField; - - /** A field to set the dataproduct_type parameter. */ - private DataProductTypeField dataProductTypeField; - - /** The GUI element of the button to send the query. */ - private JButton buttonSend; + /** The listener for the request panel. */ + RequestPanelListener listener; /** @@ -84,33 +84,6 @@ public class RequestPanelView extends JPanel { } /** - * Add GUI elements to the request panel. - */ - private void buildRequestPanel() { - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - - JPanel queryPanel = new JPanel(); - queryPanel.setBorder(BorderFactory.createTitledBorder("Query for the selected service(s)")); - queryPanel.setLayout(new BorderLayout()); - queryPanel.add(getQueryArea(), BorderLayout.CENTER); - - JPanel paramPanel = new JPanel(); - paramPanel.setLayout(new BoxLayout(paramPanel, BoxLayout.Y_AXIS)); - paramPanel.setBorder(BorderFactory.createTitledBorder("Query parameters")); - for (ParamField field : getParamFields()) { - paramPanel.add(field); - } - - JPanel buttonPanel = new JPanel(); - buttonPanel.add(getButtonSend()); - buttonPanel.setMaximumSize(new Dimension(1000, BUTTON_PANEL_HEIGHT)); - - this.add(paramPanel, this); - this.add(queryPanel, this); - this.add(buttonPanel, this); - } - - /** * Get the GUI element of the send button. If it doesn't exist, create it. * * @return The button. @@ -130,6 +103,20 @@ public class RequestPanelView extends JPanel { } /** + * Get the GUI element of the data product field. If it doesn't exist, create it. + * + * @return The data product field. + */ + public DataProductTypeField getDataProductTypeField() { + if (dataProductTypeField == null) { + dataProductTypeField = new DataProductTypeField(listener, + "dataproduct_type"); + } + + return dataProductTypeField; + } + + /** * Get the GUI element of the parameters fields list. If it doesn't exist, create it. * * @return The parameters fields list. @@ -146,17 +133,17 @@ public class RequestPanelView extends JPanel { } /** - * Get the GUI element of the data product field. If it doesn't exist, create it. + * Get the GUI element of the query area. If it doesn't exist, create it. * - * @return The data product field. + * @return The target query area. */ - public DataProductTypeField getDataProductTypeField() { - if (dataProductTypeField == null) { - dataProductTypeField = new DataProductTypeField(listener, - "dataproduct_type"); + public JTextArea getQueryArea() { + if (queryArea == null) { + queryArea = new JTextArea(""); + queryArea.setToolTipText("The query sent to the service(s)."); + queryArea.setLineWrap(true); } - - return dataProductTypeField; + return queryArea; } /** @@ -173,19 +160,6 @@ public class RequestPanelView extends JPanel { } /** - * Get the GUI element of the time range field. If it doesn't exist, create it. - * - * @return The time range field. - */ - public DateRangeField getTimeRangeField() { - if (timeRangeField == null) { - timeRangeField = new DateRangeField(listener, "time_"); - } - - return timeRangeField; - } - - /** * Get the GUI element of the target name field. If it doesn't exist, create it. * * @return The target name field. @@ -199,17 +173,16 @@ public class RequestPanelView extends JPanel { } /** - * Get the GUI element of the query area. If it doesn't exist, create it. + * Get the GUI element of the time range field. If it doesn't exist, create it. * - * @return The target query area. + * @return The time range field. */ - public JTextArea getQueryArea() { - if (queryArea == null) { - queryArea = new JTextArea(""); - queryArea.setToolTipText("The query sent to the service(s)."); - queryArea.setLineWrap(true); + public DateRangeField getTimeRangeField() { + if (timeRangeField == null) { + timeRangeField = new DateRangeField(listener, "time_"); } - return queryArea; + + return timeRangeField; } /** @@ -220,4 +193,31 @@ public class RequestPanelView extends JPanel { public void updateQueryArea(String query) { queryArea.setText(query); } + + /** + * Add GUI elements to the request panel. + */ + private void buildRequestPanel() { + setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + + JPanel queryPanel = new JPanel(); + queryPanel.setBorder(BorderFactory.createTitledBorder("Query for the selected service(s)")); + queryPanel.setLayout(new BorderLayout()); + queryPanel.add(getQueryArea(), BorderLayout.CENTER); + + JPanel paramPanel = new JPanel(); + paramPanel.setLayout(new BoxLayout(paramPanel, BoxLayout.Y_AXIS)); + paramPanel.setBorder(BorderFactory.createTitledBorder("Query parameters")); + for (ParamField field : getParamFields()) { + paramPanel.add(field); + } + + JPanel buttonPanel = new JPanel(); + buttonPanel.add(getButtonSend()); + buttonPanel.setMaximumSize(new Dimension(1000, BUTTON_PANEL_HEIGHT)); + + this.add(paramPanel, this); + this.add(queryPanel, this); + this.add(buttonPanel, this); + } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java index 44b5cd5..2c44cac 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DataProductTypeField.java @@ -37,6 +37,59 @@ import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; */ public class DataProductTypeField extends ParamField { + /** + * An enumeration of all available data product types. Each values comes with an id because + * EPN-TAP table can possibly be filled with the id instead of the name, so the query have to + * ask for both of them. + * + * @author N. Jourdane + */ + @SuppressWarnings("javadoc") + public enum DataProductType { + // @noformat + ALL("All", "all"), CA("Catalog", "ca"), CU("Cube", "cu"), + DS("Dynamic spectrum", "ds"), IM("Image", "im"), MO("Movie", "mo"), + PR("Profile", "pr"), SC("Spectral cube", "sc"), SP("Spectrum", "sp"), + SV("Spatial vector", "sv"), TS("Time series", "ts"), VO("Volume", "vo"); + // @format + + /** The id of the data product type, such as `ds`. */ + private String id = ""; + + /** The full name of the data product type, such as `Dynamic spectrum`. */ + private String name = ""; + + + /** + * Method constructor for the enumeration. + * + * @param name The full name of the data product type, such as `Dynamic spectrum`. + * @param id The id of the data product type, such as `ds`. + */ + DataProductType(String name, String id) { + this.name = name; + this.id = id; + } + + /** + * @return A list of two strings, containing the name (formated for the query) and the id, + * used in the query. A list is used instead of a array because the getQuery + * function ( @see Queries) needs to know the parameter type. + */ + public List query() { + List item = new ArrayList<>(); + item.add(name.replace(" ", "-").toLowerCase()); + item.add(id); + return item; + } + + @Override + public String toString() { + return name; + } + } + + /** The serial version UID. */ private static final long serialVersionUID = 1L; @@ -89,57 +142,4 @@ public class DataProductTypeField extends ParamField { } } - - /** - * An enumeration of all available data product types. Each values comes with an id because - * EPN-TAP table can possibly be filled with the id instead of the name, so the query have to - * ask for both of them. - * - * @author N. Jourdane - */ - @SuppressWarnings("javadoc") - public enum DataProductType { - // @noformat - ALL("All", "all"), IM("Image", "im"), SP("Spectrum", "sp"), - DS("Dynamic spectrum", "ds"), SC("Spectral cube", "sc"), PR("Profile", "pr"), - VO("Volume", "vo"), MO("Movie", "mo"), CU("Cube", "cu"), - TS("Time series", "ts"), CA("Catalog", "ca"), SV("Spatial vector", "sv"); - // @format - - /** The full name of the data product type, such as `Dynamic spectrum`. */ - private String name = ""; - - /** The id of the data product type, such as `ds`. */ - private String id = ""; - - - /** - * Method constructor for the enumeration. - * - * @param name The full name of the data product type, such as `Dynamic spectrum`. - * @param id The id of the data product type, such as `ds`. - */ - DataProductType(String name, String id) { - this.name = name; - this.id = id; - } - - /** - * @return A list of two strings, containing the name (formated for the query) and the id, - * used in the query. A list is used instead of a array because the getQuery - * function ( @see Queries) needs to know the parameter type. - */ - public List query() { - List item = new ArrayList<>(); - item.add(name.replace(" ", "-").toLowerCase()); - item.add(id); - return item; - } - - @Override - public String toString() { - return name; - } - } - } \ No newline at end of file diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java index 66d9755..f20d533 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/DateRangeField.java @@ -38,21 +38,21 @@ import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; */ public class DateRangeField extends ParamField implements TextFieldListener { - /** The serial version UID. */ - private static final long serialVersionUID = 1L; - /** The date format used in the DateRange field */ private static final String DATE_FORMAT = "dd/MM/yyyy"; /** The regex used to validate the Date fields */ private static final String DATE_REGEX = "(^(((0[1-9]|1[0-9]|2[0-8])[\\/](0[1-9]|1[012]))|((29|30|31)[\\/](0[13578]|1[02]))|((29|30)[\\/](0[4,6,9]|11)))[\\/](19|[2-9][0-9])\\d\\d$)|(^29[\\/]02[\\/](19|[2-9][0-9])(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96)$)"; - /** The JTextField used to put the parameter minimum value of the range. */ - private JTextField fieldMin; + /** The serial version UID. */ + private static final long serialVersionUID = 1L; /** The JTextField used to put the parameter maximum value of the range. */ private JTextField fieldMax; + /** The JTextField used to put the parameter minimum value of the range. */ + private JTextField fieldMin; + /** * Method constructor diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java index b27be3d..b6fe7a6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/FloatRangeField.java @@ -34,12 +34,12 @@ public class FloatRangeField extends ParamField implements TextFieldListener { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The JTextField used to put the parameter minimum value of the range. */ - private JTextField fieldMin; - /** The JTextField used to put the parameter maximum value of the range. */ private JTextField fieldMax; + /** The JTextField used to put the parameter minimum value of the range. */ + private JTextField fieldMin; + /** * Method constructor diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java index fd1904c..a97b617 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/ParamField.java @@ -40,30 +40,30 @@ public abstract class ParamField extends JPanel { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The minimum width of the field. */ - protected static final int MIN_FIELD_WIDTH = 30; - /** The preferred field height. */ protected static final int FIELD_HEIGHT = 20; - /** The maximum width of the field. */ - protected static final int MAX_FIELD_WIDTH = 400; - /** The preferred label width. */ protected static final int LABEL_WIDTH = 140; - /** The suffix used in REG-TAP parameters names, indicating that it's a beginning of a range. */ - protected static final String MIN_SUFFIX = "min"; + /** The maximum width of the field. */ + protected static final int MAX_FIELD_WIDTH = 400; /** The suffix used in REG-TAP parameters names, indicating that it is a end of a range. */ protected static final String MAX_SUFFIX = "max"; - /** The main view of the application. */ - protected RequestPanelListener requestPanelListener; + /** The minimum width of the field. */ + protected static final int MIN_FIELD_WIDTH = 30; + + /** The suffix used in REG-TAP parameters names, indicating that it's a beginning of a range. */ + protected static final String MIN_SUFFIX = "min"; /** The parameter name of the field */ protected String paramName; + /** The main view of the application. */ + protected RequestPanelListener requestPanelListener; + /** * Method constructor for the parameter field abstract class, which do all common action for all @@ -82,21 +82,6 @@ public abstract class ParamField extends JPanel { } /** - * Build the panel and add GUI elements on it. - */ - private void buildParamField() { - setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); - - setMaximumSize(new Dimension(MAX_FIELD_WIDTH, FIELD_HEIGHT)); - - String strLabel = paramName.replaceAll("_", " ").trim(); - JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1)); - label.setPreferredSize(new Dimension(LABEL_WIDTH, FIELD_HEIGHT)); - - this.add(label); - } - - /** * To add the listener. @see TextFieldListener * * @param changeListener The listener of text fields. @@ -108,7 +93,7 @@ public abstract class ParamField extends JPanel { field.getDocument().addDocumentListener(new DocumentListener() { @Override - public void removeUpdate(DocumentEvent de) { + public void changedUpdate(DocumentEvent de) { changeListener.update(field); } @@ -118,10 +103,25 @@ public abstract class ParamField extends JPanel { } @Override - public void changedUpdate(DocumentEvent de) { + public void removeUpdate(DocumentEvent de) { changeListener.update(field); } }); } + + /** + * Build the panel and add GUI elements on it. + */ + private void buildParamField() { + setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); + + setMaximumSize(new Dimension(MAX_FIELD_WIDTH, FIELD_HEIGHT)); + + String strLabel = paramName.replaceAll("_", " ").trim(); + JLabel label = new JLabel(strLabel.substring(0, 1).toUpperCase() + strLabel.substring(1)); + label.setPreferredSize(new Dimension(LABEL_WIDTH, FIELD_HEIGHT)); + + this.add(label); + } } \ No newline at end of file diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java index 38dc876..79ac93a 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetClassField.java @@ -35,6 +35,41 @@ import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener; */ public class TargetClassField extends ParamField { + /** + * An enumeration of all available target classes. + * + * @author N. Jourdane + */ + @SuppressWarnings("javadoc") + enum TargetClass { + // @noformat + ALL("All"), COMET("Comet"), EXOPLANET("Exoplanet"), INTERPLANETARY_MEDIUM("Interplanetary medium"), + RING("Ring"), SAMPLE("Sample"), SKY("Sky"), SPACECRAFT("Spacecraft"), + SPACEJUNK("Spacejunk"), STAR("Star"); + // @format + + /** The name of the target class. */ + String name; + + + /** + * Method constructor for the enumeration. + * + * @param name The name of the target class. + */ + TargetClass(String name) { + this.name = name; + } + + /** + * @return The name formated for the query. + */ + String query() { + return name.replace(" ", "_").toLowerCase(); + } + } + + /** The serial version UID. */ private static final long serialVersionUID = 1L; @@ -74,39 +109,4 @@ public class TargetClassField extends ParamField { } } - - /** - * An enumeration of all available target classes. - * - * @author N. Jourdane - */ - @SuppressWarnings("javadoc") - enum TargetClass { - // @noformat - ALL("All"), COMET("Comet"), EXOPLANET("Exoplanet"), RING("Ring"), - SAMPLE("Sample"), SKY("Sky"), SPACECRAFT("Spacecraft"), SPACEJUNK("Spacejunk"), - STAR("Star"), INTERPLANETARY_MEDIUM("Interplanetary medium"); - // @format - - /** The name of the target class. */ - String name; - - - /** - * Method constructor for the enumeration. - * - * @param name The name of the target class. - */ - TargetClass(String name) { - this.name = name; - } - - /** - * @return The name formated for the query. - */ - String query() { - return name.replace(" ", "_").toLowerCase(); - } - } - } \ No newline at end of file diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java index 286e3e3..9c2507b 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java @@ -83,11 +83,6 @@ public class TargetNameField extends ParamField implements TextFieldListener { this(new RequestPanelListener() { @Override - public void onSendButtonClicked() { - /** No SendButtonClicked event, we just want the field itself. */ - } - - @Override public void onParameterRemoved(String paramName) { /** No ParameterRemoved event, we just want the field itself. */ } @@ -96,10 +91,29 @@ public class TargetNameField extends ParamField implements TextFieldListener { public void onParameterUpdated(String paramName, Object paramValue) { /** No ParameterChanged event, we just want the field itself. */ } + + @Override + public void onSendButtonClicked() { + /** No SendButtonClicked event, we just want the field itself. */ + } }, paraName); } /** + * This method is called each time the field is modified. + */ + @Override + public void update(JTextField textField) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + updateComboBox(); + } + }); + } + + /** * This method is called each time the field is modified. A Runnable is used it is impossible to * modify the comboBox from a DocumentEvent. */ @@ -128,18 +142,4 @@ public class TargetNameField extends ParamField implements TextFieldListener { } } - /** - * This method is called each time the field is modified. - */ - @Override - public void update(JTextField textField) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - updateComboBox(); - } - }); - } - } \ No newline at end of file diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java index 596a6e6..770ff7b 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java @@ -34,12 +34,12 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis /** The logger for the class ResultPanelCtrl. */ private static final Logger LOGGER = Logger.getLogger(ResultPanelCtrl.class.getName()); - /** The result panel view. */ - private ResultPanelView view; - /** The listener of the main panel. */ private MainPanelListener listener; + /** The result panel view. */ + private ResultPanelView view; + /** * Constructor of ResultPanelCtrl. @@ -49,6 +49,13 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis view = new ResultPanelView(this); } + /** + * @return The view of the result panel. Used in MainPanelCtrl to add panels in the main window. + */ + public ResultPanelView getView() { + return view; + } + @Override public void onDownloadButtonClicked(File file) { try { @@ -58,11 +65,9 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis } } - /** - * @return The view of the result panel. Used in MainPanelCtrl to add panels in the main window. - */ - public ResultPanelView getView() { - return view; + @Override + public void onRowsSelected() { + LOGGER.info("Selected row: " + StringJoiner.join(view.getSelectedRows())); } @Override @@ -70,9 +75,4 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis throws eu.omp.irap.vespa.votable.controller.VOTableException { view.fillTable(voTableData); } - - @Override - public void onRowsSelected() { - LOGGER.info("Selected row: " + StringJoiner.join(view.getSelectedRows())); - } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java index 6ca1ec5..8fb3089 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelView.java @@ -35,14 +35,14 @@ public class ResultPanelView extends VOTableView { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The listener of the result panel. */ - ResultPanelListener listener; + /** The GUI element of the button to save the result of the query. */ + private JButton fileButton; /** A label to display several informations (aka. status bar). */ private JLabel infoLabel; - /** The GUI element of the button to save the result of the query. */ - private JButton fileButton; + /** The listener of the result panel. */ + ResultPanelListener listener; /** @@ -70,22 +70,6 @@ public class ResultPanelView extends VOTableView { } /** - * Returns the info label, create it if doesn't exist. - * - * @return The info label. - */ - public JLabel getInfoLabel() { - return infoLabel == null ? new JLabel() : infoLabel; - } - - /** - * @param infoText The text to display in the status-bar, which will override the old one. - */ - public void setInfoText(String infoText) { - infoLabel.setText(infoText); - } - - /** * Returns the button to save the VOTable, create it if doesn't exist. * * @return The button to save the VOTable. @@ -106,4 +90,20 @@ public class ResultPanelView extends VOTableView { return fileButton; } + /** + * Returns the info label, create it if doesn't exist. + * + * @return The info label. + */ + public JLabel getInfoLabel() { + return infoLabel == null ? new JLabel() : infoLabel; + } + + /** + * @param infoText The text to display in the status-bar, which will override the old one. + */ + public void setInfoText(String infoText) { + infoLabel.setText(infoText); + } + } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java index 20c9110..dc733d3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java @@ -33,41 +33,41 @@ import eu.omp.irap.vespa.votable.utils.StringJoiner; */ public class ServicesPanelCtrl extends VOTableController implements ServicesPanelListener { + /** The separator used between each services in the custom service text fields. */ + private static final String CUSTOM_SERVICES_SEPARATOR = ";"; + /** The logger for the class ServicesPanelCtrl. */ private static final Logger LOGGER = Logger.getLogger(ServicesPanelCtrl.class.getName()); - /** The position of the column displaying the table names in the service table. */ - private static final int TABLE_NAME_COLUMN_POSITION = 4; - /** The position of the column displaying the services target URLs in the service table. */ private static final int SERVICE_URL_COLUMN_POSITION = 1; - /** The separator used between each services in the custom service text fields. */ - private static final String CUSTOM_SERVICES_SEPARATOR = ";"; + /** The position of the column displaying the table names in the service table. */ + private static final int TABLE_NAME_COLUMN_POSITION = 4; - /** The view of the services panel. */ - private ServicesPanelView view; + /** The list of services target Urls selected by the user on the service panel. */ + private List customServicesUrls; /** The list of services table names selected by the user on the service panel. */ - private List tablesNames; + private List customTablesNames; + + /** The listener of the main panel. */ + private MainPanelListener listener; /** The list of services target Urls selected by the user on the service panel. */ - private List servicesUrls; + private List selectedServicesUrls; /** The list of services table names selected by the user on the service panel. */ private List selectedTablesNames; /** The list of services target Urls selected by the user on the service panel. */ - private List selectedServicesUrls; + private List servicesUrls; /** The list of services table names selected by the user on the service panel. */ - private List customTablesNames; - - /** The list of services target Urls selected by the user on the service panel. */ - private List customServicesUrls; + private List tablesNames; - /** The listener of the main panel. */ - private MainPanelListener listener; + /** The view of the services panel. */ + private ServicesPanelView view; /** @@ -85,11 +85,10 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane } /** - * @return The view of the services panel. Used in MainPanelCtrl to add panels in the main - * window. + * @return The list of services target Urls selected by the user on the service panel. */ - public ServicesPanelView getView() { - return view; + public List getServicesUrls() { + return servicesUrls; } /** @@ -100,33 +99,11 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane } /** - * @return The list of services target Urls selected by the user on the service panel. + * @return The view of the services panel. Used in MainPanelCtrl to add panels in the main + * window. */ - public List getServicesUrls() { - return servicesUrls; - } - - @Override - public void onRowsSelected() { - List newServicesUrls = new ArrayList<>(); - List newTablesNames = new ArrayList<>(); - - for (int row : view.getSelectedRows()) { - newServicesUrls.add((String) view.getValueAt(SERVICE_URL_COLUMN_POSITION, row)); - newTablesNames.add((String) view.getValueAt(TABLE_NAME_COLUMN_POSITION, row)); - } - - selectedServicesUrls = newServicesUrls; - selectedTablesNames = newTablesNames; - - servicesUrls = customServicesUrls; - tablesNames = customTablesNames; - servicesUrls.addAll(selectedServicesUrls); - tablesNames.addAll(customTablesNames); - - listener.updateQuery(); - LOGGER.info("Updated selected services URLs: " + StringJoiner.join(selectedServicesUrls)); - LOGGER.info("Updated selected tables names: " + StringJoiner.join(selectedTablesNames)); + public ServicesPanelView getView() { + return view; } @Override @@ -158,4 +135,27 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane } } } + + @Override + public void onRowsSelected() { + List newServicesUrls = new ArrayList<>(); + List newTablesNames = new ArrayList<>(); + + for (int row : view.getSelectedRows()) { + newServicesUrls.add((String) view.getValueAt(SERVICE_URL_COLUMN_POSITION, row)); + newTablesNames.add((String) view.getValueAt(TABLE_NAME_COLUMN_POSITION, row)); + } + + selectedServicesUrls = newServicesUrls; + selectedTablesNames = newTablesNames; + + servicesUrls = customServicesUrls; + tablesNames = customTablesNames; + servicesUrls.addAll(selectedServicesUrls); + tablesNames.addAll(customTablesNames); + + listener.updateQuery(); + LOGGER.info("Updated selected services URLs: " + StringJoiner.join(selectedServicesUrls)); + LOGGER.info("Updated selected tables names: " + StringJoiner.join(selectedTablesNames)); + } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java index 32182a9..68aa67c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java @@ -34,15 +34,15 @@ public class ServicesPanelView extends VOTableView { /** The serial version UID. */ private static final long serialVersionUID = 1L; - /** The listener of the services panel view. */ - ServicesPanelListener listener; - /** The text field to manually set the service URL. */ private JTextField serviceUrlTextField; /** The text field to manually set the service table name. */ private JTextField tableNameTextField; + /** The listener of the services panel view. */ + ServicesPanelListener listener; + /** * Method constructor which customize the services panel, but don't build it from scratch since @@ -56,22 +56,6 @@ public class ServicesPanelView extends VOTableView { buildServicesPanel(); } - /** Build the service panel and add the graphical elements on it. */ - private void buildServicesPanel() { - serviceUrlTextField = new JTextField(10); - addEventListener(serviceUrlTextField); - tableNameTextField = new JTextField(10); - addEventListener(tableNameTextField); - - JPanel addServicePanel = new JPanel(); - addServicePanel.add(new JLabel("Service URL")); - addServicePanel.add(serviceUrlTextField); - addServicePanel.add(new JLabel("Table name")); - addServicePanel.add(tableNameTextField); - - add(addServicePanel, BorderLayout.SOUTH); - } - public void addEventListener(JTextField textField) { textField.getDocument().addDocumentListener(new DocumentListener() { @@ -81,18 +65,27 @@ public class ServicesPanelView extends VOTableView { } @Override - public void removeUpdate(DocumentEvent e) { + public void insertUpdate(DocumentEvent e) { listener.onCustomServiceUpdated(); } @Override - public void insertUpdate(DocumentEvent e) { + public void removeUpdate(DocumentEvent e) { listener.onCustomServiceUpdated(); } }); } /** + * Returns the field to set a custom service URL. Create it if doesn't exist. + * + * @return The service URL JTextField. + */ + public JTextField getServiceUrlTextField() { + return serviceUrlTextField; + } + + /** * Returns the field to set a custom table name. Create it if doesn't exist. * * @return The table name JTextField. @@ -101,13 +94,20 @@ public class ServicesPanelView extends VOTableView { return tableNameTextField; } - /** - * Returns the field to set a custom service URL. Create it if doesn't exist. - * - * @return The service URL JTextField. - */ - public JTextField getServiceUrlTextField() { - return serviceUrlTextField; + /** Build the service panel and add the graphical elements on it. */ + private void buildServicesPanel() { + serviceUrlTextField = new JTextField(10); + addEventListener(serviceUrlTextField); + tableNameTextField = new JTextField(10); + addEventListener(tableNameTextField); + + JPanel addServicePanel = new JPanel(); + addServicePanel.add(new JLabel("Service URL")); + addServicePanel.add(serviceUrlTextField); + addServicePanel.add(new JLabel("Table name")); + addServicePanel.add(tableNameTextField); + + add(addServicePanel, BorderLayout.SOUTH); } } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java b/src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java index 0832cbd..512088a 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java @@ -22,32 +22,25 @@ package eu.omp.irap.vespa.epntapclient.service; public class Service { /** - * The ivoid of the service:
- * Unambiguous reference to the resource conforming to the IVOA - * standard for identifiers. - */ - private String ivoid; - - /** - * The title of the service:
- * The full name given to the resource. + * The content_level of the service:
+ * A hash-separated list of content levels specifying the intended audience. */ - private String title; + private String contentLevel; /** - * The short_name of the service:
- * A short name or abbreviation given to something. This name will be used where brief - * annotations for the re- source name are required. Applications may use it to refer to the - * resource in a compact display. One word or a few letters is recommended. No more than sixteen - * characters are allowed. + * The created date of the service, as a string:
+ * The UTC date and time this resource metadata de- scription was created. This timestamp must + * not be in the future. This time is not required to be accurate; it should be at least + * accurate to the day. Any insignificant time elds should be set to zero. */ - private String shortName; + private String created; /** - * The type of the service:
- * Resource type (something like vs:datacollection, vs:catalogservice, etc). + * The creator of the service:
+ * The creator(s) of the resource in the order given by the resource record author, separated by + * semicolons. */ - private String type; + private String creator; /** * The description of the service:
@@ -56,17 +49,11 @@ public class Service { private String description; /** - * The creator of the service:
- * The creator(s) of the resource in the order given by the resource record author, separated by - * semicolons. - */ - private String creator; - - /** - * The content_level of the service:
- * A hash-separated list of content levels specifying the intended audience. + * The ivoid of the service:
+ * Unambiguous reference to the resource conforming to the IVOA + * standard for identifiers. */ - private String contentLevel; + private String ivoid; /** * The reference_rul of the service:
@@ -75,12 +62,25 @@ public class Service { private String referenceURL; /** - * The created date of the service, as a string:
- * The UTC date and time this resource metadata de- scription was created. This timestamp must - * not be in the future. This time is not required to be accurate; it should be at least - * accurate to the day. Any insignificant time elds should be set to zero. + * The short_name of the service:
+ * A short name or abbreviation given to something. This name will be used where brief + * annotations for the re- source name are required. Applications may use it to refer to the + * resource in a compact display. One word or a few letters is recommended. No more than sixteen + * characters are allowed. */ - private String created; + private String shortName; + + /** + * The title of the service:
+ * The full name given to the resource. + */ + private String title; + + /** + * The type of the service:
+ * Resource type (something like vs:datacollection, vs:catalogservice, etc). + */ + private String type; /** * The updated date of the service, as a string:
@@ -101,31 +101,57 @@ public class Service { } /** - * @return true if all parameter of the service are not null. + * Get the service {@link #contentLevel}. + * + * @return The service {@link #contentLevel}. */ - public boolean isValid() { - boolean isValid = ivoid != null && title != null && shortName != null; - isValid = isValid && type != null && description != null && creator != null; - isValid = isValid && contentLevel != null && referenceURL != null && created != null; - return isValid && updated != null; + public String getContentLevel() { + return contentLevel; } /** - * Get the service {@link #title}. + * Get the service {@link #created} date. * - * @return The service {@link #title}. + * @return The service {@link #created} date. */ - public String getTitle() { - return title; + public String getCreated() { + return created; } /** - * Set the service {@link #title}. + * Get the service {@link #creator}. * - * @param title The service {@link #title} + * @return The service {@link #creator}. */ - public void setTitle(String title) { - this.title = title; + public String getCreator() { + return creator; + } + + /** + * Get the service {@link #description}. + * + * @return The service {@link #description}. + */ + public String getDescription() { + return description; + } + + /** + * Get the service {@link #ivoid}. + * + * @return The service {@link #ivoid}. + */ + public String getIvoid() { + return ivoid; + } + + /** + * Get the service {@link #referenceURL}. + * + * @return The service {@link #referenceURL}. + */ + public String getReferenceURL() { + return referenceURL; } /** @@ -138,12 +164,12 @@ public class Service { } /** - * Set the service {@link #shortName}. + * Get the service {@link #title}. * - * @param shortName The service {@link #shortName} + * @return The service {@link #title}. */ - public void setShortName(String shortName) { - this.shortName = shortName; + public String getTitle() { + return title; } /** @@ -156,39 +182,40 @@ public class Service { } /** - * Set the service {@link #type}. + * Get the service {@link #updated} date. * - * @param type The service {@link #type} + * @return The service {@link #updated} date. */ - public void setType(String type) { - this.type = type; + public String getUpdated() { + return updated; } /** - * Get the service {@link #description}. - * - * @return The service {@link #description}. + * @return true if all parameter of the service are not null. */ - public String getDescription() { - return description; + public boolean isValid() { + boolean isValid = ivoid != null && title != null && shortName != null; + isValid = isValid && type != null && description != null && creator != null; + isValid = isValid && contentLevel != null && referenceURL != null && created != null; + return isValid && updated != null; } /** - * Set the service {@link #description}. + * Set the service {@link #contentLevel}. * - * @param description The service {@link #description} + * @param contentLevel The service {@link #contentLevel} */ - public void setDescription(String description) { - this.description = description; + public void setContentLevel(String contentLevel) { + this.contentLevel = contentLevel; } /** - * Get the service {@link #creator}. + * Set the service {@link #created}. * - * @return The service {@link #creator}. + * @param created The service {@link #created} */ - public String getCreator() { - return creator; + public void setCreated(String created) { + this.created = created; } /** @@ -201,30 +228,12 @@ public class Service { } /** - * Get the service {@link #contentLevel}. - * - * @return The service {@link #contentLevel}. - */ - public String getContentLevel() { - return contentLevel; - } - - /** - * Set the service {@link #contentLevel}. - * - * @param contentLevel The service {@link #contentLevel} - */ - public void setContentLevel(String contentLevel) { - this.contentLevel = contentLevel; - } - - /** - * Get the service {@link #referenceURL}. + * Set the service {@link #description}. * - * @return The service {@link #referenceURL}. + * @param description The service {@link #description} */ - public String getReferenceURL() { - return referenceURL; + public void setDescription(String description) { + this.description = description; } /** @@ -237,30 +246,30 @@ public class Service { } /** - * Get the service {@link #created} date. + * Set the service {@link #shortName}. * - * @return The service {@link #created} date. + * @param shortName The service {@link #shortName} */ - public String getCreated() { - return created; + public void setShortName(String shortName) { + this.shortName = shortName; } /** - * Set the service {@link #created}. + * Set the service {@link #title}. * - * @param created The service {@link #created} + * @param title The service {@link #title} */ - public void setCreated(String created) { - this.created = created; + public void setTitle(String title) { + this.title = title; } /** - * Get the service {@link #updated} date. + * Set the service {@link #type}. * - * @return The service {@link #updated} date. + * @param type The service {@link #type} */ - public String getUpdated() { - return updated; + public void setType(String type) { + this.type = type; } /** @@ -272,13 +281,4 @@ public class Service { this.updated = updated; } - /** - * Get the service {@link #ivoid}. - * - * @return The service {@link #ivoid}. - */ - public String getIvoid() { - return ivoid; - } - } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCore.java b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCore.java index 525fef1..1f61e27 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCore.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCore.java @@ -20,10 +20,10 @@ package eu.omp.irap.vespa.epntapclient.service; * @author N. Jourdane */ public enum ServiceCore { - /** The ObsCore service appellation, used in several queries. */ - OBSCORE("ObsCore"), /** The EpnCore service appellation, used in several queries. */ - EPNCORE("EpnCore"); + EPNCORE("EpnCore"), + /** The ObsCore service appellation, used in several queries. */ + OBSCORE("ObsCore"); /** The type of the service (ie. ObsCore, EpnCore, etc.). */ private String type; @@ -31,7 +31,7 @@ public enum ServiceCore { /** * Constructor of ServiceCore enumeration. - * + * * @param type The type of the service (ie. ObsCore, EpnCore, etc.). */ ServiceCore(String type) { diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java index 94869b2..c5b093e 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java @@ -51,6 +51,41 @@ public class ServiceCtrl { } /** + * @param ivoid The ivoid of the service. + * @param parameter The unique parameter to get. + * @return The value of the parameter. + * @throws VOTableException Can not get the VOTable. + */ + public static Object getParameter(String ivoid, String parameter) + throws VOTableException { + String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameter, ivoid); + return getVoTableData(query).getCell(0, 0); + } + + /** + * @param ivoid The ivoid of the service. + * @param parameters A list of parameters to get. + * @return A map of resulting the request. + * @throws VOTableException Can not get the VOTable. + */ + public static Map getParameters(String ivoid, List parameters) + throws VOTableException { + return getParameters(ivoid, StringJoiner.join(parameters)); + } + + /** + * @param ivoid The ivoid of the service. + * @param parameters The parameters to get, separated by commas. + * @return A map of resulting the request. + * @throws VOTableException Can not get the VOTable. + */ + public static Map getParameters(String ivoid, String parameters) + throws VOTableException { + String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameters, ivoid); + return getVoTableData(query).getRowMap(0); + } + + /** * Parse a Resource and returns the corresponding Service. * * @param resource the resource to parse. @@ -111,6 +146,17 @@ public class ServiceCtrl { } /** + * @param query The query. + * @return The VOTable resulting the query. + * @throws VOTableException Can not get the VOTable. + */ + public static VOTABLE getVoTable(String query) throws VOTableException { + VOTableController voTableCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); + voTableCtrl.readTable(); + return voTableCtrl.getVOTable(); + } + + /** * @param query The query to get the service. * @return The VOTableData * @throws VOTableException Can not get the VOTable. @@ -136,52 +182,6 @@ public class ServiceCtrl { } /** - * @param query The query. - * @return The VOTable resulting the query. - * @throws VOTableException Can not get the VOTable. - */ - public static VOTABLE getVoTable(String query) throws VOTableException { - VOTableController voTableCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); - voTableCtrl.readTable(); - return voTableCtrl.getVOTable(); - } - - /** - * @param ivoid The ivoid of the service. - * @param parameters The parameters to get, separated by commas. - * @return A map of resulting the request. - * @throws VOTableException Can not get the VOTable. - */ - public static Map getParameters(String ivoid, String parameters) - throws VOTableException { - String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameters, ivoid); - return getVoTableData(query).getRowMap(0); - } - - /** - * @param ivoid The ivoid of the service. - * @param parameters A list of parameters to get. - * @return A map of resulting the request. - * @throws VOTableException Can not get the VOTable. - */ - public static Map getParameters(String ivoid, List parameters) - throws VOTableException { - return getParameters(ivoid, StringJoiner.join(parameters)); - } - - /** - * @param ivoid The ivoid of the service. - * @param parameter The unique parameter to get. - * @return The value of the parameter. - * @throws VOTableException Can not get the VOTable. - */ - public static Object getParameter(String ivoid, String parameter) - throws VOTableException { - String query = String.format(Queries.SELECT_TAP_SERVICES_WHERE_IVOID, parameter, ivoid); - return getVoTableData(query).getCell(0, 0); - } - - /** * Convert a date from XMLGregorianCalendar to a string literal. * * @param date The date to convert diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java index 3850fbe..7e77034 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java @@ -49,30 +49,30 @@ import eu.omp.irap.vespa.votable.utils.XMLUtils; */ public class VOResourceCtrl { - /** The logger for the class VOResourceController. */ - private static final Logger LOGGER = Logger.getLogger(VOResourceCtrl.class.getName()); + /** The URL used to get the resources in JSON format. */ + private static final String GET_JSONRESOURCES_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search"; /** The URL used to get the resources in VOResource (XML) format. */ private static final String GET_VORESOURCE_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources.xml"; - /** The URL used to get the resources in JSON format. */ - private static final String GET_JSONRESOURCES_URL = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search"; + /** The logger for the class VOResourceController. */ + private static final Logger LOGGER = Logger.getLogger(VOResourceCtrl.class.getName()); /** The maximum number of resulting resources. */ private static final int MAX_VORESOURCES = 100; + /** The URL of the TR namespace, since it is not present in the dowloaded VOResource. */ + private static final String NAMESPACE_TR = "http://www.ivoa.net/xml/VODataService/v1.1"; + + /** The URL of the VS namespace, since it is not present in the dowloaded VOResource. */ + private static final String NAMESPACE_VS = "http://www.ivoa.net/xml/TAPRegExt/v1.0"; + /** The new schema location, since one in the dowloaded VOResource is not compliant. */ private static final String SCHEMA_LOCATION = "http://www.ivoa.net/xml/RegistryInterface/v1.0 " + "http://www.ivoa.net/xml/RegistryInterface/v1.0 " + "http://www.ivoa.net/xml/VODataService/v1.1 " + "http://www.ivoa.net/xml/TAPRegExt/v1.0"; - /** The URL of the VS namespace, since it is not present in the dowloaded VOResource. */ - private static final String NAMESPACE_VS = "http://www.ivoa.net/xml/TAPRegExt/v1.0"; - - /** The URL of the TR namespace, since it is not present in the dowloaded VOResource. */ - private static final String NAMESPACE_TR = "http://www.ivoa.net/xml/VODataService/v1.1"; - /** Private constructor to hide the default public one. */ private VOResourceCtrl() { @@ -102,35 +102,6 @@ public class VOResourceCtrl { } /** - * Get the list of ivoIDs of all resources which implements the specified core and match with - * the keywords. - * - * @param core The service core (ie. ObsCore, EpnCore, etc.) - * @param keywords A list of keywords to filter the result. The keywords are the subjects of the - * resources, for example, 'Space plasmas'. - * @return A list of ivoIDs - * @throws CantGetVOResourceException Can not get the VOResource. - */ - public static List getVOResources(ServiceCore core, List keywords) - throws CantGetVOResourceException { - List ivoidResources; - Map parameters = new HashMap<>(); - String subjects = StringJoiner.join(keywords); - parameters.put("keywords", - "datamodel:\"" + core.toString() + "\" subjects:\"" + subjects + "\""); - parameters.put("max", String.valueOf(MAX_VORESOURCES)); - - String query = Network.buildGetRequest(GET_JSONRESOURCES_URL, parameters); - try { - ivoidResources = parseIvoidResources(Network.readJson(query)); - } catch (CantSendQueryException e) { - throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); - } - LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); - return ivoidResources; - } - - /** * Get a resource from its identifier. * * @param identifier The resource identifier. @@ -189,6 +160,35 @@ public class VOResourceCtrl { } /** + * Get the list of ivoIDs of all resources which implements the specified core and match with + * the keywords. + * + * @param core The service core (ie. ObsCore, EpnCore, etc.) + * @param keywords A list of keywords to filter the result. The keywords are the subjects of the + * resources, for example, 'Space plasmas'. + * @return A list of ivoIDs + * @throws CantGetVOResourceException Can not get the VOResource. + */ + public static List getVOResources(ServiceCore core, List keywords) + throws CantGetVOResourceException { + List ivoidResources; + Map parameters = new HashMap<>(); + String subjects = StringJoiner.join(keywords); + parameters.put("keywords", + "datamodel:\"" + core.toString() + "\" subjects:\"" + subjects + "\""); + parameters.put("max", String.valueOf(MAX_VORESOURCES)); + + String query = Network.buildGetRequest(GET_JSONRESOURCES_URL, parameters); + try { + ivoidResources = parseIvoidResources(Network.readJson(query)); + } catch (CantSendQueryException e) { + throw new CantGetVOResourceException(GET_VORESOURCE_URL, e); + } + LOGGER.info("Got resources: " + StringJoiner.join(ivoidResources)); + return ivoidResources; + } + + /** * Change the namespaces of the VOResource to make the XML file valid against its XSD. * * @param voResourcePath The file path of the VOResource. diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java index f5550ea..b5d0a12 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceException.java @@ -23,55 +23,35 @@ package eu.omp.irap.vespa.epntapclient.voresource; */ public abstract class VOResourceException extends Exception { - /** The serial version UID. */ - private static final long serialVersionUID = 1L; - - - /** - * @param message The message describing the exception displayed in the error dialog. - */ - public VOResourceException(String message) { - super(message); - } - - /** - * @param message The message describing the exception displayed in the error dialog. - * @param e The exception thrown. - */ - public VOResourceException(String message, Exception e) { - super(message, e); - } - - - /** An exception thrown when we can not read the VOResource. */ - public static class CantReadVOResourceException extends VOResourceException { + /** An exception thrown when we can not get the VOResource, ie. an error in the query. */ + public static class CantGetVOResourceException extends VOResourceException { /** The serial version UID. */ private static final long serialVersionUID = 1L; /** - * @param voResourcePath The path of the VOResource. + * @param voResourceRequest The path of the VOResource. * @param e The exception thrown. */ - public CantReadVOResourceException(String voResourcePath, Exception e) { - super("Can not read the VOResource which should be stored in: " + voResourcePath, e); + public CantGetVOResourceException(String voResourceRequest, Exception e) { + super("Can not get the remote VOResource with the request: " + voResourceRequest, e); } } - /** An exception thrown when we can not get the VOResource, ie. an error in the query. */ - public static class CantGetVOResourceException extends VOResourceException { + /** An exception thrown when we can not read the VOResource. */ + public static class CantReadVOResourceException extends VOResourceException { /** The serial version UID. */ private static final long serialVersionUID = 1L; /** - * @param voResourceRequest The path of the VOResource. + * @param voResourcePath The path of the VOResource. * @param e The exception thrown. */ - public CantGetVOResourceException(String voResourceRequest, Exception e) { - super("Can not get the remote VOResource with the request: " + voResourceRequest, e); + public CantReadVOResourceException(String voResourcePath, Exception e) { + super("Can not read the VOResource which should be stored in: " + voResourcePath, e); } } @@ -93,4 +73,24 @@ public abstract class VOResourceException extends Exception { + "\n See the VOResource file for more details: " + voResourcePath, e); } } + + + /** The serial version UID. */ + private static final long serialVersionUID = 1L; + + + /** + * @param message The message describing the exception displayed in the error dialog. + */ + public VOResourceException(String message) { + super(message); + } + + /** + * @param message The message describing the exception displayed in the error dialog. + * @param e The exception thrown. + */ + public VOResourceException(String message, Exception e) { + super(message, e); + } } diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java index 83472eb..a603e0b 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -42,8 +42,8 @@ import eu.omp.irap.vespa.votable.votabledata.VOTableData; @SuppressWarnings("static-method") public class EpnTapConnectionTest { - /** The logger for the class Main. */ - private static final Logger LOGGER = Logger.getLogger(EpnTapConnectionTest.class.getName()); + /** The AMDA access URL, for testing purposes. */ + private static final String AMDA_ACCESS_URL = "http://cdpp-epntap.cesr.fr/__system__/tap/run/tap"; /** The AMDA ivoid, for testing purposes. */ private static final String AMDA_IVOID = "ivo://cdpp/amda"; @@ -51,9 +51,6 @@ public class EpnTapConnectionTest { /** The AMDA short name (to compare with the returned value), for testing purposes. */ private static final String AMDA_SHORT_NAME = "AMDA"; - /** The AMDA access URL, for testing purposes. */ - private static final String AMDA_ACCESS_URL = "http://cdpp-epntap.cesr.fr/__system__/tap/run/tap"; - /** A subject associated with the AMDA service, for testing purposes. */ private static final String AMDA_SUBJECT = "Space plasmas"; @@ -63,6 +60,9 @@ public class EpnTapConnectionTest { /** The APIS short name (to compare with the returned value), for testing purposes. */ private static final String APIS_SHORT_NAME = "APIS"; + /** The logger for the class Main. */ + private static final Logger LOGGER = Logger.getLogger(EpnTapConnectionTest.class.getName()); + /** The URL access of a service implementing the EpnCorev2, for testing purposes. */ private static final String SERVICE_EPNCOREV2_ACCESS_URL = "http://voparis-tap-planeto.obspm.fr/__system__/tap/run/tap"; @@ -75,126 +75,18 @@ public class EpnTapConnectionTest { /** - * Unit test for the class {@link EpnTapConnection#getEPNVOresource(String)}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getVOResourceTest() throws VOResourceException { - LOGGER.info("getVOResourceTest"); - EpnTapConnection facade = new EpnTapConnection(); - - Resource resource = facade.getEPNVOresource(AMDA_IVOID); - - assertEquals("AMDA", resource.getShortName()); - assertEquals("CDPP AMDA DataBase", resource.getTitle()); - assertEquals("Centre de Données de la Physique des Plasmas", - resource.getCuration().getCreator().get(0).getName().getValue()); - } - - /** - * Unit test for the class {@link EpnTapConnection#getEPNVOResources()}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getEPNVOResourcesTest() throws VOResourceException { - LOGGER.info("getEPNVOResourcesTest"); - EpnTapConnection facade = new EpnTapConnection(); - - List resources = facade.getEPNVOResources(); - - int nbResources = resources.size(); - assertTrue(nbResources + " ∉ [13;20]", nbResources >= 13 && nbResources <= 20); - - Resource amda = null; - Resource apis = null; - for (Resource resource : resources) { - if (AMDA_IVOID.equals(resource.getIdentifier())) { - amda = resource; - } - if (APIS_IVOID.equals(resource.getIdentifier())) { - apis = resource; - } - } - assertNotNull("AMDA resource should be present.", amda); - assertNotNull("APIS resource should be present.", apis); - assertEquals(AMDA_SHORT_NAME, amda.getShortName()); - assertEquals(APIS_SHORT_NAME, apis.getShortName()); - } - - /** - * Unit test for the class {@link EpnTapConnection#getEPNVOResources(List)}. - * - * @throws VOResourceException Can not get the VOresource. - */ - @Test - public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { - LOGGER.info("getEPNVOResourcesWithKeywordsTest"); - EpnTapConnection facade = new EpnTapConnection(); - - final List keywords = new ArrayList<>(); - keywords.add(AMDA_SUBJECT); - List resources = facade.getEPNVOResources(keywords); - - assertEquals(resources.size(), 1); - - Resource amda = null; - for (Resource resource : resources) { - if (AMDA_IVOID.equals(resource.getIdentifier())) { - amda = resource; - } - } - assertNotNull("AMDA resource should be present.", amda); - } - - // *** Services *** - - /** - * Unit test for the class {@link EpnTapConnection#getEPNService(String)}. - * - * @throws VOTableException Can not get the VOTable corresponding to the service. - */ - @Test - public void getEPNServiceTest() throws VOTableException { - LOGGER.info("getEPNServiceTest"); - EpnTapConnection facade = new EpnTapConnection(); - - VOTABLE voTable = facade.getEPNService(AMDA_IVOID); - VOTableData data = ServiceCtrl.getVoTableData(voTable); - - assertEquals(1, data.getNbRows()); - assertTrue("Column name ivoid not found.", data.isContainingColumnName("ivoid")); - assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url")); - assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name")); - assertEquals(AMDA_IVOID, data.getCell(0, "ivoid")); - assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url")); - assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); - } - - /** - * Unit test for the class {@link EpnTapConnection#getEPNService(String, List)}. + * Unit test for the class {@link EpnTapConnection#getEPNCoreTableName(String)}. * * @throws VOTableException Can not get the VOTable corresponding to the service. */ @Test - public void getEPNServiceWithAttributesTest() throws VOTableException { - LOGGER.info("getEPNServiceWithAttributesTest"); + public void getEPNCoreTableNameTest() throws VOTableException { + LOGGER.info("getEPNCoreTableNameTest"); EpnTapConnection facade = new EpnTapConnection(); - final List attributes = new ArrayList<>(); - attributes.add("access_url"); - attributes.add("short_name"); - - VOTABLE voTable = facade.getEPNService(AMDA_IVOID, attributes); - VOTableData data = ServiceCtrl.getVoTableData(voTable); + String epnCoreTableName = facade.getEPNCoreTableName(AMDA_IVOID); - assertEquals(1, data.getNbRows()); - assertEquals(2, data.getNbColumns()); - assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url")); - assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name")); - assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url")); - assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); + assertEquals("amdadb.epn_core", epnCoreTableName); } /** @@ -262,6 +154,8 @@ public class EpnTapConnectionTest { assertEquals(AMDA_SHORT_NAME, amda.get("short_name")); } + // *** Services *** + /** * Unit test for the class {@link EpnTapConnection#getEPNServices(List, List)}. * @@ -296,23 +190,111 @@ public class EpnTapConnectionTest { assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url")); } - // *** Getters *** + /** + * Unit test for the class {@link EpnTapConnection#getEPNService(String)}. + * + * @throws VOTableException Can not get the VOTable corresponding to the service. + */ + @Test + public void getEPNServiceTest() throws VOTableException { + LOGGER.info("getEPNServiceTest"); + EpnTapConnection facade = new EpnTapConnection(); + + VOTABLE voTable = facade.getEPNService(AMDA_IVOID); + VOTableData data = ServiceCtrl.getVoTableData(voTable); + + assertEquals(1, data.getNbRows()); + assertTrue("Column name ivoid not found.", data.isContainingColumnName("ivoid")); + assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url")); + assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name")); + assertEquals(AMDA_IVOID, data.getCell(0, "ivoid")); + assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url")); + assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); + } /** - * Unit test for the class {@link EpnTapConnection#getEPNCoreTableName(String)}. + * Unit test for the class {@link EpnTapConnection#getEPNService(String, List)}. * * @throws VOTableException Can not get the VOTable corresponding to the service. */ @Test - public void getEPNCoreTableNameTest() throws VOTableException { - LOGGER.info("getEPNCoreTableNameTest"); + public void getEPNServiceWithAttributesTest() throws VOTableException { + LOGGER.info("getEPNServiceWithAttributesTest"); EpnTapConnection facade = new EpnTapConnection(); - String epnCoreTableName = facade.getEPNCoreTableName(AMDA_IVOID); + final List attributes = new ArrayList<>(); + attributes.add("access_url"); + attributes.add("short_name"); - assertEquals("amdadb.epn_core", epnCoreTableName); + VOTABLE voTable = facade.getEPNService(AMDA_IVOID, attributes); + VOTableData data = ServiceCtrl.getVoTableData(voTable); + + assertEquals(1, data.getNbRows()); + assertEquals(2, data.getNbColumns()); + assertTrue("Column name short_name not found.", data.isContainingColumnName("access_url")); + assertTrue("Column name short_name not found.", data.isContainingColumnName("short_name")); + assertEquals(AMDA_ACCESS_URL, data.getCell(0, "access_url")); + assertEquals(AMDA_SHORT_NAME, data.getCell(0, "short_name")); + } + + /** + * Unit test for the class {@link EpnTapConnection#getEPNVOResources()}. + * + * @throws VOResourceException Can not get the VOresource. + */ + @Test + public void getEPNVOResourcesTest() throws VOResourceException { + LOGGER.info("getEPNVOResourcesTest"); + EpnTapConnection facade = new EpnTapConnection(); + + List resources = facade.getEPNVOResources(); + + int nbResources = resources.size(); + assertTrue(nbResources + " ∉ [13;20]", nbResources >= 13 && nbResources <= 20); + + Resource amda = null; + Resource apis = null; + for (Resource resource : resources) { + if (AMDA_IVOID.equals(resource.getIdentifier())) { + amda = resource; + } + if (APIS_IVOID.equals(resource.getIdentifier())) { + apis = resource; + } + } + assertNotNull("AMDA resource should be present.", amda); + assertNotNull("APIS resource should be present.", apis); + assertEquals(AMDA_SHORT_NAME, amda.getShortName()); + assertEquals(APIS_SHORT_NAME, apis.getShortName()); + } + + /** + * Unit test for the class {@link EpnTapConnection#getEPNVOResources(List)}. + * + * @throws VOResourceException Can not get the VOresource. + */ + @Test + public void getEPNVOResourcesWithKeywordsTest() throws VOResourceException { + LOGGER.info("getEPNVOResourcesWithKeywordsTest"); + EpnTapConnection facade = new EpnTapConnection(); + + final List keywords = new ArrayList<>(); + keywords.add(AMDA_SUBJECT); + List resources = facade.getEPNVOResources(keywords); + + assertEquals(resources.size(), 1); + + Resource amda = null; + for (Resource resource : resources) { + if (AMDA_IVOID.equals(resource.getIdentifier())) { + amda = resource; + } + } + assertNotNull("AMDA resource should be present.", amda); } + // *** Getters *** + /** * Unit test for the class {@link EpnTapConnection#getTAPURL(String)}. * @@ -328,6 +310,24 @@ public class EpnTapConnectionTest { assertEquals("http://cdpp-epntap.cesr.fr/__system__/tap/run/tap", tapURL); } + /** + * Unit test for the class {@link EpnTapConnection#getEPNVOresource(String)}. + * + * @throws VOResourceException Can not get the VOresource. + */ + @Test + public void getVOResourceTest() throws VOResourceException { + LOGGER.info("getVOResourceTest"); + EpnTapConnection facade = new EpnTapConnection(); + + Resource resource = facade.getEPNVOresource(AMDA_IVOID); + + assertEquals("AMDA", resource.getShortName()); + assertEquals("CDPP AMDA DataBase", resource.getTitle()); + assertEquals("Centre de Données de la Physique des Plasmas", + resource.getCuration().getCreator().get(0).getName().getValue()); + } + // *** Queries *** /** diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java index 537b307..95cc05f 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java @@ -28,12 +28,6 @@ import org.junit.Test; */ public class GranuleTest { - public static Granule createIncompleteGranule() { - Granule incompleteGranule = new Granule("Mercury"); - incompleteGranule.setGranuleGid("Planet"); - return incompleteGranule; - } - public static Granule createCompleteGranule() { Granule completeGranule = new Granule("Mercury"); completeGranule.setGranuleGid("Planet"); @@ -82,6 +76,12 @@ public class GranuleTest { return completeGranule; } + public static Granule createIncompleteGranule() { + Granule incompleteGranule = new Granule("Mercury"); + incompleteGranule.setGranuleGid("Planet"); + return incompleteGranule; + } + @Test public static void isNotValidTest() { assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid()); -- libgit2 0.21.2