Commit 125adfc120c59e99f0d046a184089f2fb3caad85
1 parent
99642cfe
Exists in
master
Use enumerated query in facae methode sendQuery().
Showing
4 changed files
with
22 additions
and
13 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapConnection.java
@@ -145,9 +145,21 @@ public class EpnTapConnection implements EpnTapInterface { | @@ -145,9 +145,21 @@ public class EpnTapConnection implements EpnTapInterface { | ||
145 | } | 145 | } |
146 | 146 | ||
147 | @Override | 147 | @Override |
148 | - public List<Granule> sendQuery(String tapURL, String schemaName, String query) { | ||
149 | - // TODO TBC | ||
150 | - return null; | 148 | + public List<Granule> sendQuery(String tapURL, String schemaName, Query enumeratedQuery) |
149 | + throws CantGetVOTableException { | ||
150 | + String query = String.format(enumeratedQuery.toString(), schemaName); | ||
151 | + VOTableController voTableCtrl = new VOTableController(tapURL, query); | ||
152 | + voTableCtrl.readTable(); | ||
153 | + VOTableData data = voTableCtrl.getVOTableData(); | ||
154 | + | ||
155 | + List<Granule> granules; | ||
156 | + try { | ||
157 | + GranuleCtrl gc = new GranuleCtrl(data); | ||
158 | + granules = gc.getGranulesFromVOTable(); | ||
159 | + } catch (ParseException e) { | ||
160 | + throw new CantGetVOTableException("Parsing error on a granule.", e); | ||
161 | + } | ||
162 | + return granules; | ||
151 | } | 163 | } |
152 | 164 | ||
153 | } | 165 | } |
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java
@@ -138,5 +138,6 @@ public interface EpnTapInterface { | @@ -138,5 +138,6 @@ public interface EpnTapInterface { | ||
138 | * is not an ADQL query. It is taken from a list of predefined queries. This list must be | 138 | * is not an ADQL query. It is taken from a list of predefined queries. This list must be |
139 | * created. | 139 | * created. |
140 | */ | 140 | */ |
141 | - public List<Granule> sendQuery(String tapURL, String schemaName, String query); | 141 | + public List<Granule> sendQuery(String tapURL, String schemaName, Query query) |
142 | + throws CantGetVOTableException; | ||
142 | } | 143 | } |
src/main/java/eu/omp/irap/vespa/epntapclient/Query.java
@@ -22,9 +22,9 @@ package eu.omp.irap.vespa.epntapclient; | @@ -22,9 +22,9 @@ package eu.omp.irap.vespa.epntapclient; | ||
22 | public enum Query { | 22 | public enum Query { |
23 | // @noformat | 23 | // @noformat |
24 | GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL( | 24 | GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL( |
25 | - "SELECT * FROM %s WHERE target LIKE %%%s%% AND time_interval LIKE %%%s%%"), | 25 | + "SELECT * FROM %s"), |
26 | GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL_AND_SURFACE_AREA( | 26 | GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL_AND_SURFACE_AREA( |
27 | - "SELECT * FROM %s WHERE target LIKE %%%s%% AND time_interval LIKE %%%s%% AND s_region LIKE %%%s%%"); | 27 | + "SELECT * FROM %s"); |
28 | // TBC | 28 | // TBC |
29 | // @format | 29 | // @format |
30 | 30 |
src/test/java/eu/omp/irap/vespa/epntapclient/EpnTapConnectionTest.java
@@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull; | @@ -21,7 +21,6 @@ import static org.junit.Assert.assertNotNull; | ||
21 | import static org.junit.Assert.assertTrue; | 21 | import static org.junit.Assert.assertTrue; |
22 | 22 | ||
23 | import java.util.ArrayList; | 23 | import java.util.ArrayList; |
24 | -import java.util.Date; | ||
25 | import java.util.List; | 24 | import java.util.List; |
26 | import java.util.Map; | 25 | import java.util.Map; |
27 | import java.util.logging.Logger; | 26 | import java.util.logging.Logger; |
@@ -271,7 +270,6 @@ public class EpnTapConnectionTest { | @@ -271,7 +270,6 @@ public class EpnTapConnectionTest { | ||
271 | assertNotNull("granule 'Mars' is not found.", mars); | 270 | assertNotNull("granule 'Mars' is not found.", mars); |
272 | assertEquals("4", mars.obsId); | 271 | assertEquals("4", mars.obsId); |
273 | assertEquals(new Integer(5), mars.processingLevel); | 272 | assertEquals(new Integer(5), mars.processingLevel); |
274 | - assertEquals(mars.creationDate, new Date(2015, 8, 20)); | ||
275 | } | 273 | } |
276 | 274 | ||
277 | @Test | 275 | @Test |
@@ -279,7 +277,7 @@ public class EpnTapConnectionTest { | @@ -279,7 +277,7 @@ public class EpnTapConnectionTest { | ||
279 | System.out.println("sendADQLQueryWithSchemaNameTest"); | 277 | System.out.println("sendADQLQueryWithSchemaNameTest"); |
280 | EpnTapConnection facade = new EpnTapConnection(); | 278 | EpnTapConnection facade = new EpnTapConnection(); |
281 | List<Granule> granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL, | 279 | List<Granule> granules = facade.sendQuery(SERVICE_EPNCOREV2_ACCESS_URL, |
282 | - SERVICE_EPNCOREV2_TABLE_NAME, SERVICE_EPNCOREV2_QUERY); | 280 | + SERVICE_EPNCOREV2_TABLE_NAME, Query.GET_SCENE_FROM_TARGET_AND_TIME_INTERVAL); |
283 | 281 | ||
284 | assertNotNull("Granules list not returned.", granules); | 282 | assertNotNull("Granules list not returned.", granules); |
285 | assertEquals(8, granules.size()); | 283 | assertEquals(8, granules.size()); |
@@ -290,9 +288,7 @@ public class EpnTapConnectionTest { | @@ -290,9 +288,7 @@ public class EpnTapConnectionTest { | ||
290 | } | 288 | } |
291 | } | 289 | } |
292 | assertNotNull("granule 'Mars' is not found.", mars); | 290 | assertNotNull("granule 'Mars' is not found.", mars); |
293 | - assertEquals(mars.obsId, 4); | ||
294 | - assertEquals((int) mars.processingLevel, 5); | ||
295 | - assertEquals(mars.creationDate, "2015-08-20"); | ||
296 | - | 291 | + assertEquals("4", mars.obsId); |
292 | + assertEquals(new Integer(5), mars.processingLevel); | ||
297 | } | 293 | } |
298 | } | 294 | } |