diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/lib/Queries.java
deleted file mode 100644
index edab5e8..0000000
--- a/src/main/java/eu/omp/irap/vespa/epntapclient/lib/Queries.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * This file is a part of EpnTAPClient.
- * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
- * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
- * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
- *
- * This program is free software: you can
- * redistribute it and/or modify it under the terms of the GNU General Public License as published
- * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
- * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
- * the GNU General Public License along with this program. If not, see
- * .
- */
-
-package eu.omp.irap.vespa.epntapclient.lib;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import eu.omp.irap.vespa.epntapclient.votable.utils.Strings.StringJoiner;
-
-/**
- * Defines the queries and the query patterns usually used in the application.
- *
- * @author N. Jourdane
- */
-public final class Queries {
-
- /** Query to get all EPN-TAP services. */
- public static final String GET_EPN_TAP_SERVICES = "SELECT short_name, "
- + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
- + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
- + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
- + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
- + "intf_type='vs:paramhttp' AND "
- + "detail_xpath='/capability/dataModel/@ivo-id' AND "
- + "1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/EpnCore%') "
- + "ORDER BY short_name, table_name";
-
- /** Query to get all EPN-TAP services. */
- public static final String GET_TAP_OBSCOR_SERVICES = "SELECT short_name, "
- + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
- + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
- + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
- + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
- + "intf_type='vs:paramhttp' AND "
- + "detail_xpath='/capability/dataModel/@ivo-id' AND "
- + "1=ivo_nocasematch(detail_value, 'ivo://ivoa.net/std/ObsCore%') "
- + "ORDER BY short_name, table_name";
-
- /** Query to get all EPN-TAP services. */
- public static final String GET_TAP_SERVICES = "SELECT short_name, "
- + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
- + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
- + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
- + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
- + "intf_type='vs:paramhttp' AND "
- + "detail_xpath='/capability/dataModel/@ivo-id' "
- + "ORDER BY short_name, table_name";
-
- /** Query to get all VO-resources which implements epn-tap core. */
- public static final String GET_VO_RESOURCES = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search?"
- + "keywords=standardid:%22ivo://ivoa.net/std/TAP%22%20datamodel:%22EpnCore%22&max=100";
-
-
- /** Constructor to hide the implicit public one. */
- private Queries() {
- }
-
- /**
- * The default query, with these parameters, respectively: max_rows, target_name, time_min,
- * time_max, dataproduct_type, spectral_range_min, spectral_range_max.
- *
- * @param nbRow The maximum number of rows returned.
- * @param tableName The name of the target table for the query.
- * @param params A map of parameters, for the `WHERE` keywords.
- * @return The literal string of the query.
- */
- public static String getQuery(String tableName, Map params, int nbRow) {
- StringJoiner addJoin = new StringJoiner(" AND ");
- for (Map.Entry param : params.entrySet()) {
- if (param.getValue() instanceof ArrayList) {
- StringJoiner orJoin = new StringJoiner(" OR ");
- @SuppressWarnings("unchecked")
- List possibleValues = (List) param.getValue();
- for (String possibleValue : possibleValues) {
- orJoin.add(param.getKey() + " LIKE '" + possibleValue + "'");
- }
- addJoin.add("(" + orJoin + ")");
- } else if (param.getValue() instanceof String) {
- addJoin.add(param.getKey() + " LIKE '" + param.getValue() + "'");
- } else {
- addJoin.add(param.getKey() + " = " + param.getValue().toString());
- }
- }
- String where = addJoin.isEmpty() ? "" : " WHERE " + addJoin;
- return "SELECT TOP " + nbRow + " target_name, target_class FROM " + tableName + where;
- }
-
-}
diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java b/src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java
new file mode 100644
index 0000000..c993af5
--- /dev/null
+++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java
@@ -0,0 +1,103 @@
+/*
+ * This file is a part of EpnTAPClient.
+ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
+ * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
+ * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
+ *
+ * This program is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
+ * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
+ * the GNU General Public License along with this program. If not, see
+ * .
+ */
+
+package eu.omp.irap.vespa.epntapclient.service;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import eu.omp.irap.vespa.epntapclient.votable.utils.StringJoiner;
+
+/**
+ * Defines the queries and the query patterns usually used in the application.
+ *
+ * @author N. Jourdane
+ */
+public final class Queries {
+
+ /** Query to get all EPN-TAP services. */
+ public static final String GET_EPN_TAP_SERVICES = "SELECT short_name, "
+ + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
+ + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
+ + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
+ + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
+ + "intf_type='vs:paramhttp' AND "
+ + "detail_xpath='/capability/dataModel/@ivo-id' AND "
+ + "1=ivo_nocasematch(detail_value, 'ivo://vopdc.obspm/std/EpnCore%') "
+ + "ORDER BY short_name, table_name";
+
+ /** Query to get all EPN-TAP services. */
+ public static final String GET_TAP_OBSCOR_SERVICES = "SELECT short_name, "
+ + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
+ + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
+ + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
+ + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
+ + "intf_type='vs:paramhttp' AND "
+ + "detail_xpath='/capability/dataModel/@ivo-id' AND "
+ + "1=ivo_nocasematch(detail_value, 'ivo://ivoa.net/std/ObsCore%') "
+ + "ORDER BY short_name, table_name";
+
+ /** Query to get all EPN-TAP services. */
+ public static final String GET_TAP_SERVICES = "SELECT short_name, "
+ + "res_title AS schema_title, table_name, schema_name, ivoid, access_url "
+ + "FROM rr.resource NATURAL JOIN rr.res_schema NATURAL JOIN rr.res_table "
+ + "NATURAL JOIN rr.interface NATURAL JOIN rr.res_detail NATURAL JOIN rr.capability "
+ + "WHERE standard_id='ivo://ivoa.net/std/tap' AND "
+ + "intf_type='vs:paramhttp' AND "
+ + "detail_xpath='/capability/dataModel/@ivo-id' "
+ + "ORDER BY short_name, table_name";
+
+ /** Query to get all VO-resources which implements epn-tap core. */
+ public static final String GET_VO_RESOURCES = "http://voparis-registry.obspm.fr/vo/ivoa/1/voresources/search?"
+ + "keywords=standardid:%22ivo://ivoa.net/std/TAP%22%20datamodel:%22EpnCore%22&max=100";
+
+
+ /** Constructor to hide the implicit public one. */
+ private Queries() {
+ }
+
+ /**
+ * The default query, with these parameters, respectively: max_rows, target_name, time_min,
+ * time_max, dataproduct_type, spectral_range_min, spectral_range_max.
+ *
+ * @param nbRow The maximum number of rows returned.
+ * @param tableName The name of the target table for the query.
+ * @param params A map of parameters, for the `WHERE` keywords.
+ * @return The literal string of the query.
+ */
+ public static String getQuery(String tableName, Map params, int nbRow) {
+ StringJoiner addJoin = new StringJoiner(" AND ");
+ for (Map.Entry param : params.entrySet()) {
+ if (param.getValue() instanceof ArrayList) {
+ StringJoiner orJoin = new StringJoiner(" OR ");
+ @SuppressWarnings("unchecked")
+ List possibleValues = (List) param.getValue();
+ for (String possibleValue : possibleValues) {
+ orJoin.add(param.getKey() + " LIKE '" + possibleValue + "'");
+ }
+ addJoin.add("(" + orJoin + ")");
+ } else if (param.getValue() instanceof String) {
+ addJoin.add(param.getKey() + " LIKE '" + param.getValue() + "'");
+ } else {
+ addJoin.add(param.getKey() + " = " + param.getValue().toString());
+ }
+ }
+ String where = addJoin.isEmpty() ? "" : " WHERE " + addJoin;
+ return "SELECT TOP " + nbRow + " target_name, target_class FROM " + tableName + where;
+ }
+
+}
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
new file mode 100644
index 0000000..ee26c1b
--- /dev/null
+++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/Service.java
@@ -0,0 +1,153 @@
+/*
+ * This file is a part of EpnTAPClient.
+ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
+ * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
+ * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
+ *
+ * This program is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
+ * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
+ * the GNU General Public License along with this program. If not, see
+ * .
+ */
+
+package eu.omp.irap.vespa.epntapclient.service;
+
+/**
+ * @author N. Jourdane
+ */
+public class ServiceModel {
+
+ private String ivoid;
+
+ private String resTitle;
+
+ private String shortName;
+
+ private String type;
+
+ private String description;
+
+ private String creator;
+
+ private String contentLevel;
+
+ private String referenceURL;
+
+ private String created;
+
+ private String updated;
+
+
+ public enum ServiceType {
+
+ OBSCORE("obscore"), EPNCORE("epncore");
+
+ private String type = "";
+
+
+ ServiceType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return type;
+ }
+ }
+
+
+ private ServiceModel() {
+ }
+
+ ServiceModel(String ivoid) {
+ this.ivoid = ivoid;
+ }
+
+ public boolean isValid() {
+ boolean isValid = ivoid != null && resTitle != 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 getIvoid() {
+ return ivoid;
+ }
+
+ public String getResTitle() {
+ return resTitle;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getCreator() {
+ return creator;
+ }
+
+ public String getContentLevel() {
+ return contentLevel;
+ }
+
+ public String getReferenceURL() {
+ return referenceURL;
+ }
+
+ public String getCreated() {
+ return created;
+ }
+
+ public String getUpdated() {
+ return updated;
+ }
+
+ public void setTitle(String resTitle) {
+ this.resTitle = resTitle;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public void setCreator(String creator) {
+ this.creator = creator;
+ }
+
+ public void setContentLevel(String contentLevel) {
+ this.contentLevel = contentLevel;
+ }
+
+ public void setReferenceURL(String referenceURL) {
+ this.referenceURL = referenceURL;
+ }
+
+ public void setCreated(String created) {
+ this.created = created;
+ }
+
+ public void setUpdated(String updated) {
+ this.updated = updated;
+ }
+
+}
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
new file mode 100644
index 0000000..e8c2077
--- /dev/null
+++ b/src/main/java/eu/omp/irap/vespa/epntapclient/service/ServiceCtrl.java
@@ -0,0 +1,97 @@
+/*
+ * This file is a part of EpnTAPClient.
+ * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
+ * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
+ * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
+ *
+ * This program is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
+ * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
+ * the GNU General Public License along with this program. If not, see
+ * .
+ */
+
+package eu.omp.irap.vespa.epntapclient.service;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import eu.omp.irap.vespa.epntapclient.voresource.model.ContentLevel;
+import eu.omp.irap.vespa.epntapclient.voresource.model.Creator;
+import eu.omp.irap.vespa.epntapclient.voresource.model.Resource;
+import eu.omp.irap.vespa.epntapclient.voresource.model.Type;
+import eu.omp.irap.vespa.epntapclient.votable.data.VOTableData;
+import eu.omp.irap.vespa.epntapclient.votable.utils.StringJoiner;
+
+/**
+ * @author N. Jourdane
+ */
+public class ServiceCtrl {
+
+ /** The logger for the class ServiceCtrl. */
+ private static final Logger logger = Logger.getLogger(ServiceCtrl.class.getName());
+
+ public static final String DATE_FORMAT = "yyyy/MM/dd HH:mm:ss";
+
+
+ public final ServiceModel getServiceFromResource(ServiceModel.ServiceType serviceType,
+ Resource resource) {
+ ServiceModel service = new ServiceModel(resource.getIdentifier());
+ service.setTitle(resource.getTitle());
+ service.setShortName(resource.getShortName());
+ StringJoiner types = new StringJoiner(", ");
+ for (Type type : resource.getContent().getType()) {
+ types.add(type.toString());
+ }
+ service.setType(types.toString());
+ service.setDescription(resource.getContent().getDescription());
+ StringJoiner creators = new StringJoiner(", ");
+ for (Creator creator : resource.getCuration().getCreator()) {
+ creators.add(creator.getName().getValue());
+ }
+ service.setCreator(creators.toString());
+ StringJoiner contentLevels = new StringJoiner(", ");
+ for (ContentLevel contentLevel : resource.getContent().getContentLevel()) {
+ contentLevels.add(contentLevel.value());
+ }
+
+ service.setContentLevel(contentLevels.toString());
+ service.setReferenceURL(resource.getContent().getReferenceURL());
+ service.setCreated(ServiceCtrl.XMLDateToString(resource.getCreated()));
+ service.setUpdated(ServiceCtrl.XMLDateToString(resource.getUpdated()));
+ return service;
+ }
+
+ private static String XMLDateToString(XMLGregorianCalendar date) {
+ SimpleDateFormat sdf = new SimpleDateFormat(ServiceCtrl.DATE_FORMAT);
+ return sdf.format(date.toGregorianCalendar().getTime());
+ }
+
+ public final List getServiceFromVOTableData(ServiceModel.ServiceType serviceType,
+ VOTableData data) {
+ List services = new ArrayList<>();
+ for (int i = 0; i < data.getNbRows(); i++) {
+ ServiceModel service = new ServiceModel((String) data.getCell(i, "ivoid"));
+ service.setTitle((String) data.getCell(i, "res_title"));
+ service.setShortName((String) data.getCell(i, "short_name"));
+ service.setType((String) data.getCell(i, "content_type"));
+ service.setDescription((String) data.getCell(i, "res_description"));
+ service.setCreator((String) data.getCell(i, "creator_seq"));
+ service.setContentLevel((String) data.getCell(i, "content_level"));
+ service.setReferenceURL((String) data.getCell(i, "reference_url"));
+ service.setCreated((String) data.getCell(i, "created"));
+ service.setUpdated((String) data.getCell(i, "updated"));
+ // TODO: Convert date format
+ services.add(service);
+ }
+
+ return services;
+ }
+}
--
libgit2 0.21.2