Commit 8ae5b6c82178fa526fea55bb32fc16069ab75064

Authored by Nathanael Jourdane
1 parent 4b3a296c
Exists in master

Implement getServices() filter.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java
@@ -115,15 +115,43 @@ public class EpnTapFacade implements EpnTapInterface { @@ -115,15 +115,43 @@ public class EpnTapFacade implements EpnTapInterface {
115 @Override 115 @Override
116 public List<VOTABLE> getEPNServices(List<String> attributes) 116 public List<VOTABLE> getEPNServices(List<String> attributes)
117 throws CantGetVOTableException, VOResourceException { 117 throws CantGetVOTableException, VOResourceException {
118 - // TODO process attributes  
119 - return null; 118 + List<VOTABLE> voTables = new ArrayList<>();
  119 + List<String> ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE);
  120 + // TODO: optimiser le nombre de requêtes
  121 + for (String ivoid : ivoids) {
  122 + try {
  123 + String tableName = getEPNCoreTableName(ivoid);
  124 + String query = String.format(Queries.SELECT_FROM, StringJoiner.join(attributes),
  125 + tableName);
  126 + VOTableController ctrl = new VOTableController(getTAPURL(ivoid), query);
  127 + ctrl.readTable();
  128 + voTables.add(ctrl.getVOTable());
  129 + } catch (CantGetVOTableException e) {
  130 + logger.info("Can not get the service " + ivoid + ", skipping...");
  131 + }
  132 + }
  133 + return voTables;
120 } 134 }
121 135
122 @Override 136 @Override
123 public List<VOTABLE> getEPNServices(Map<String, String> keywords, List<String> attributes) 137 public List<VOTABLE> getEPNServices(Map<String, String> keywords, List<String> attributes)
124 throws CantGetVOTableException, VOResourceException { 138 throws CantGetVOTableException, VOResourceException {
125 - // TODO process attributes and keywords  
126 - return null; 139 + List<VOTABLE> voTables = new ArrayList<>();
  140 + List<String> ivoids = VOResourceCtrl.getIvoidResources(ServiceCore.EPNCORE, keywords);
  141 + // TODO: optimiser le nombre de requêtes
  142 + for (String ivoid : ivoids) {
  143 + try {
  144 + String tableName = getEPNCoreTableName(ivoid);
  145 + String query = String.format(Queries.SELECT_FROM, StringJoiner.join(attributes),
  146 + tableName);
  147 + VOTableController ctrl = new VOTableController(getTAPURL(ivoid), query);
  148 + ctrl.readTable();
  149 + voTables.add(ctrl.getVOTable());
  150 + } catch (CantGetVOTableException e) {
  151 + logger.info("Can not get the service " + ivoid + ", skipping...");
  152 + }
  153 + }
  154 + return voTables;
127 } 155 }
128 156
129 // *** Getters *** 157 // *** Getters ***
src/main/java/eu/omp/irap/vespa/epntapclient/voresource/VOResourceCtrl.java
@@ -98,7 +98,6 @@ public class VOResourceCtrl { @@ -98,7 +98,6 @@ public class VOResourceCtrl {
98 parameters.put("keywords", keywordJoiner.toString()); 98 parameters.put("keywords", keywordJoiner.toString());
99 parameters.put("max", String.valueOf(VOResourceCtrl.MAX_VORESOURCES)); 99 parameters.put("max", String.valueOf(VOResourceCtrl.MAX_VORESOURCES));
100 String query = Network.buildQuery(GET_IVOID_RESOURCES_URL, parameters); 100 String query = Network.buildQuery(GET_IVOID_RESOURCES_URL, parameters);
101 - System.out.println(query);  
102 try { 101 try {
103 ivoidResources = parseIvoidResources(Network.readJson(query)); 102 ivoidResources = parseIvoidResources(Network.readJson(query));
104 } catch (CantSendQueryException e) { 103 } catch (CantSendQueryException e) {
src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java
@@ -94,17 +94,14 @@ public class TestEpnTapFacade { @@ -94,17 +94,14 @@ public class TestEpnTapFacade {
94 System.out.println("\n*** 4. Services ***\n"); 94 System.out.println("\n*** 4. Services ***\n");
95 95
96 List<VOTABLE> epnServices = facade.getEPNServices(); 96 List<VOTABLE> epnServices = facade.getEPNServices();
97 - System.out.println("4.1 getEPNServices()\n\t"  
98 - + Debug.toJson(epnServices)); 97 + System.out.println("4.1 getEPNServices()\n\t");
99 98
100 List<VOTABLE> epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES); 99 List<VOTABLE> epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES);
101 - System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t"  
102 - + Debug.toJson(epnServices2)); 100 + System.out.println("4.2 getEPNServices(" + strServiceAttributes + ")\n\t");
103 101
104 List<VOTABLE> epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES); 102 List<VOTABLE> epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES);
105 System.out.println("4.3 getEPNServices(" + strKeywords + ", " 103 System.out.println("4.3 getEPNServices(" + strKeywords + ", "
106 - + strServiceAttributes + ")\n\t"  
107 - + Debug.toJson(epnServices3)); 104 + + strServiceAttributes + ")\n\t");
108 105
109 System.out.println("\n*** 5. Getters***\n"); 106 System.out.println("\n*** 5. Getters***\n");
110 107