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 39acf20..985a3e3 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java @@ -145,9 +145,21 @@ public class EpnTapConnection implements EpnTapInterface { } @Override - public List sendQuery(String tapURL, String schemaName, String query) { - // TODO TBC - return null; + public List sendQuery(String tapURL, String schemaName, Query enumeratedQuery) + throws CantGetVOTableException { + String query = String.format(enumeratedQuery.toString(), schemaName); + VOTableController voTableCtrl = new VOTableController(tapURL, query); + voTableCtrl.readTable(); + VOTableData data = voTableCtrl.getVOTableData(); + + List granules; + try { + GranuleCtrl gc = new GranuleCtrl(data); + granules = gc.getGranulesFromVOTable(); + } catch (ParseException e) { + throw new CantGetVOTableException("Parsing error on a granule.", e); + } + return granules; } } 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 e415b03..695ca94 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java @@ -138,5 +138,6 @@ public interface EpnTapInterface { * is not an ADQL query. It is taken from a list of predefined queries. This list must be * created. */ - public List sendQuery(String tapURL, String schemaName, String query); + public List sendQuery(String tapURL, String schemaName, Query query) + throws CantGetVOTableException; } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/Query.java b/src/main/java/eu/omp/irap/vespa/epntapclient/Query.java index 0b3c499..e0fccfc 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/Query.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/Query.java @@ -22,9 +22,9 @@ package eu.omp.irap.vespa.epntapclient; public enum Query { // @noformat GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL( - "SELECT * FROM %s WHERE target LIKE %%%s%% AND time_interval LIKE %%%s%%"), + "SELECT * FROM %s"), GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL_AND_SURFACE_AREA( - "SELECT * FROM %s WHERE target LIKE %%%s%% AND time_interval LIKE %%%s%% AND s_region LIKE %%%s%%"); + "SELECT * FROM %s"); // TBC // @format 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 c885d70..f75cffc 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.util.ArrayList; -import java.util.Date; import java.util.List; import java.util.Map; import java.util.logging.Logger; @@ -271,7 +270,6 @@ public class EpnTapConnectionTest { assertNotNull("granule 'Mars' is not found.", mars); assertEquals("4", mars.obsId); assertEquals(new Integer(5), mars.processingLevel); - assertEquals(mars.creationDate, new Date(2015, 8, 20)); } @Test @@ -279,7 +277,7 @@ public class EpnTapConnectionTest { System.out.println("sendADQLQueryWithSchemaNameTest"); EpnTapConnection facade = new EpnTapConnection(); List granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL, - SERVICE_EPNCOREV2_TABLE_NAME, SERVICE_EPNCOREV2_QUERY); + SERVICE_EPNCOREV2_TABLE_NAME, Query.GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL); assertNotNull("Granules list not returned.", granules); assertEquals(8, granules.size()); @@ -290,9 +288,7 @@ public class EpnTapConnectionTest { } } assertNotNull("granule 'Mars' is not found.", mars); - assertEquals(mars.obsId, 4); - assertEquals((int) mars.processingLevel, 5); - assertEquals(mars.creationDate, "2015-08-20"); - + assertEquals("4", mars.obsId); + assertEquals(new Integer(5), mars.processingLevel); } } -- libgit2 0.21.2