From 8ae5b6c82178fa526fea55bb32fc16069ab75064 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Tue, 10 May 2016 18:15:15 +0200 Subject: [PATCH] Implement getServices() filter. --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java | 36 ++++++++++++++++++++++++++++++++---- src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java | 1 - src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java | 9 +++------ 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java index 28e0389..3f37218 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java @@ -115,15 +115,43 @@ public class EpnTapFacade implements EpnTapInterface { @Override public List getEPNServices(List attributes) throws CantGetVOTableException, VOResourceException { - // TODO process attributes - return null; + List voTables = new ArrayList<>(); + List ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE); + // TODO: optimiser le nombre de requêtes + for (String ivoid : ivoids) { + try { + String tableName = getEPNCoreTableName(ivoid); + String query = String.format(Queries.SELECT_FROM, StringJoiner.join(attributes), + tableName); + VOTableController ctrl = new VOTableController(getTAPURL(ivoid), query); + ctrl.readTable(); + voTables.add(ctrl.getVOTable()); + } catch (CantGetVOTableException e) { + logger.info("Can not get the service " + ivoid + ", skipping..."); + } + } + return voTables; } @Override public List getEPNServices(Map keywords, List attributes) throws CantGetVOTableException, VOResourceException { - // TODO process attributes and keywords - return null; + List voTables = new ArrayList<>(); + List ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE, keywords); + // TODO: optimiser le nombre de requêtes + for (String ivoid : ivoids) { + try { + String tableName = getEPNCoreTableName(ivoid); + String query = String.format(Queries.SELECT_FROM, StringJoiner.join(attributes), + tableName); + VOTableController ctrl = new VOTableController(getTAPURL(ivoid), query); + ctrl.readTable(); + voTables.add(ctrl.getVOTable()); + } catch (CantGetVOTableException e) { + logger.info("Can not get the service " + ivoid + ", skipping..."); + } + } + return voTables; } // *** Getters *** 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 bcfd765..2c24545 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 @@ -98,7 +98,6 @@ public class VOResourceCtrl { parameters.put("keywords", keywordJoiner.toString()); parameters.put("max", String.valueOf(VOResourceCtrl.MAX_VORESOURCES)); String query = Network.buildQuery(GET_IVOID_RESOURCES_URL, parameters); - System.out.println(query); try { ivoidResources = parseIvoidResources(Network.readJson(query)); } catch (CantSendQueryException e) { diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java b/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java index afcffbc..37fc191 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java @@ -94,17 +94,14 @@ public class TestEpnTapFacade { System.out.println("\n*** 4. Services ***\n"); List epnServices = facade.getEPNServices(); - System.out.println("4.1 getEPNServices()\n\t" - + Debug.toJson(epnServices)); + System.out.println("4.1 getEPNServices()\n\t"); List epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES); - System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t" - + Debug.toJson(epnServices2)); + System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t"); List epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES); System.out.println("4.3 getEPNServices(" + strKeywords + ", " - + strServiceAttributes + ")\n\t" - + Debug.toJson(epnServices3)); + + strServiceAttributes + ")\n\t"); System.out.println("\n*** 5. Getters***\n"); -- libgit2 0.21.2