Commit 9144ee77c543d71dfec1cec43fb1e86e70adc0ce

Authored by Nathanael Jourdane
1 parent 71d8a8ee
Exists in master

Implement Service filter.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java
@@ -34,6 +34,7 @@ import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; @@ -34,6 +34,7 @@ import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE;
34 import eu.omp.irap.vespa.votable.Consts; 34 import eu.omp.irap.vespa.votable.Consts;
35 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; 35 import eu.omp.irap.vespa.votable.controller.CantGetVOTableException;
36 import eu.omp.irap.vespa.votable.controller.VOTableController; 36 import eu.omp.irap.vespa.votable.controller.VOTableController;
  37 +import eu.omp.irap.vespa.votable.utils.StringJoiner;
37 import eu.omp.irap.vespa.votable.votabledata.VOTableData; 38 import eu.omp.irap.vespa.votable.votabledata.VOTableData;
38 39
39 /** 40 /**
@@ -82,8 +83,12 @@ public class EpnTapFacade implements EpnTapInterface { @@ -82,8 +83,12 @@ public class EpnTapFacade implements EpnTapInterface {
82 @Override 83 @Override
83 public VOTABLE getEPNService(String ivoid, List<String> attributes) 84 public VOTABLE getEPNService(String ivoid, List<String> attributes)
84 throws CantGetVOTableException { 85 throws CantGetVOTableException {
85 - // TODO process attributes  
86 - return getEPNService(ivoid); 86 + // TODO: 2 requêtes pour obtenir tableName et URL = pas super opti.
  87 + String tableName = getEPNCoreTableName(ivoid);
  88 + String query = String.format(Queries.SELECT_FROM, StringJoiner.join(attributes), tableName);
  89 + VOTableController ctrl = new VOTableController(getTAPURL(ivoid), query);
  90 + ctrl.readTable();
  91 + return ctrl.getVOTable();
87 } 92 }
88 93
89 // *** Services *** 94 // *** Services ***
@@ -104,7 +109,7 @@ public class EpnTapFacade implements EpnTapInterface { @@ -104,7 +109,7 @@ public class EpnTapFacade implements EpnTapInterface {
104 } 109 }
105 110
106 @Override 111 @Override
107 - public VOTABLE getEPNServices(List<String> keywords, List<String> attributes) 112 + public VOTABLE getEPNServices(Map<String, String> keywords, List<String> attributes)
108 throws CantGetVOTableException { 113 throws CantGetVOTableException {
109 // TODO process attributes and keywords 114 // TODO process attributes and keywords
110 return getEPNServices(); 115 return getEPNServices();
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java
@@ -96,7 +96,7 @@ public interface EpnTapInterface { @@ -96,7 +96,7 @@ public interface EpnTapInterface {
96 * @throws CantGetXMLException 96 * @throws CantGetXMLException
97 * @throws CantDisplayVOTableException 97 * @throws CantDisplayVOTableException
98 */ 98 */
99 - public VOTABLE getEPNServices(List<String> keywords, List<String> attributes) 99 + public VOTABLE getEPNServices(Map<String, String> keywords, List<String> attributes)
100 throws CantGetVOTableException; 100 throws CantGetVOTableException;
101 101
102 // *** Getters *** 102 // *** Getters ***
src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java
@@ -61,11 +61,14 @@ public final class Queries { @@ -61,11 +61,14 @@ public final class Queries {
61 /** Query to get the TAP service with the specified ivoid. */ 61 /** Query to get the TAP service with the specified ivoid. */
62 public static final String GET_TAP_SERVICES_WHERE_IVOID = 62 public static final String GET_TAP_SERVICES_WHERE_IVOID =
63 Queries.SELECT + Queries.FROM + Queries.WHERE_TAP 63 Queries.SELECT + Queries.FROM + Queries.WHERE_TAP
64 - + "AND ivoid = '%s' "; 64 + + "AND ivoid = '%s'";
65 65
66 public static final String GET_TAP_SERVICES_SELECT_WHERE_IVOID = 66 public static final String GET_TAP_SERVICES_SELECT_WHERE_IVOID =
67 "SELECT %s " + Queries.FROM + Queries.WHERE_TAP 67 "SELECT %s " + Queries.FROM + Queries.WHERE_TAP
68 - + "AND ivoid = '%s' "; 68 + + "AND ivoid = '%s'";
  69 +
  70 + public static final String SELECT_FROM =
  71 + "SELECT %s FROM %s";
69 72
70 //@format 73 //@format
71 74
src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java
@@ -54,6 +54,16 @@ public class TestEpnTapFacade { @@ -54,6 +54,16 @@ public class TestEpnTapFacade {
54 public static void main(String[] args) { 54 public static void main(String[] args) {
55 EpnTapFacade facade = new EpnTapFacade(); 55 EpnTapFacade facade = new EpnTapFacade();
56 56
  57 + final List<String> SERVICE_ATTRIBUTES = new ArrayList<>();
  58 + SERVICE_ATTRIBUTES.add("target_name");
  59 + SERVICE_ATTRIBUTES.add("time_min");
  60 + SERVICE_ATTRIBUTES.add("time_max");
  61 + String strServiceAttributes = "[" + StringJoiner.join(SERVICE_ATTRIBUTES) + "]";
  62 +
  63 + final Map<String, String> KEYWORDS = new HashMap<>();
  64 + KEYWORDS.put("shortName", "IKS");
  65 + String strKeywords = "[shortName=IKS]";
  66 +
57 try { 67 try {
58 facade.getEPNServices(); 68 facade.getEPNServices();
59 69
@@ -73,10 +83,8 @@ public class TestEpnTapFacade { @@ -73,10 +83,8 @@ public class TestEpnTapFacade {
73 System.out.println("2.1 getEPNVOResources()\n\t" 83 System.out.println("2.1 getEPNVOResources()\n\t"
74 + Debug.toJson(resources)); 84 + Debug.toJson(resources));
75 85
76 - Map<String, String> keywords = new HashMap<>();  
77 - keywords.put("shortName", "IKS");  
78 - List<Resource> resources2 = facade.getEPNVOResources(keywords);  
79 - System.out.println("2.2 getEPNVOResources(keywords)\n\t" 86 + List<Resource> resources2 = facade.getEPNVOResources(KEYWORDS);
  87 + System.out.println("2.2 getEPNVOResources(" + strKeywords + ")\n\t"
80 + Debug.toJson(resources2)); 88 + Debug.toJson(resources2));
81 89
82 System.out.println("\n*** 3. Service ***\n"); 90 System.out.println("\n*** 3. Service ***\n");
@@ -85,10 +93,9 @@ public class TestEpnTapFacade { @@ -85,10 +93,9 @@ public class TestEpnTapFacade {
85 System.out.println("3.1 getEPNService(\"" + TEST_SERVICE_IVOID + "\")\n\t" 93 System.out.println("3.1 getEPNService(\"" + TEST_SERVICE_IVOID + "\")\n\t"
86 + Debug.toJson(epnService)); 94 + Debug.toJson(epnService));
87 95
88 - List<String> attributes = new ArrayList<>();  
89 - attributes.add("s_region");  
90 - VOTABLE epnService2 = facade.getEPNService(TEST_SERVICE_IVOID, attributes);  
91 - System.out.println("3.2 getEPNService(\"" + TEST_SERVICE_IVOID + "\", \"s_region\")\n\t" 96 + VOTABLE epnService2 = facade.getEPNService(TEST_SERVICE_IVOID, SERVICE_ATTRIBUTES);
  97 + System.out.println("3.2 getEPNService(\"" + TEST_SERVICE_IVOID + "\", "
  98 + + strServiceAttributes + ")\n\t"
92 + Debug.toJson(epnService2)); 99 + Debug.toJson(epnService2));
93 100
94 System.out.println("\n*** 4. Services ***\n"); 101 System.out.println("\n*** 4. Services ***\n");
@@ -97,12 +104,14 @@ public class TestEpnTapFacade { @@ -97,12 +104,14 @@ public class TestEpnTapFacade {
97 System.out.println("4.1 getEPNServices()\n\t" 104 System.out.println("4.1 getEPNServices()\n\t"
98 + Debug.toJson(epnServices)); 105 + Debug.toJson(epnServices));
99 106
100 - VOTABLE epnServices2 = facade.getEPNServices(attributes);  
101 - System.out.println("4.2 getEPNService(\"s_region\")\n\t"  
102 - + Debug.toJson(epnServices2)); 107 + VOTABLE epnServices2 = facade.getEPNServices(SERVICE_ATTRIBUTES);
  108 + System.out.println(
  109 + "4.2 getEPNServices(" + strServiceAttributes + ")\n\t"
  110 + + Debug.toJson(epnServices2));
103 111
104 - VOTABLE epnServices3 = facade.getEPNService(TEST_SERVICE_IVOID, attributes);  
105 - System.out.println("4.3 getEPNService(\"" + TEST_SERVICE_IVOID + "\", \"s_region\")\n\t" 112 + VOTABLE epnServices3 = facade.getEPNServices(KEYWORDS, SERVICE_ATTRIBUTES);
  113 + System.out.println("4.3 getEPNServices(" + strKeywords + ", "
  114 + + strServiceAttributes + ")\n\t"
106 + Debug.toJson(epnServices3)); 115 + Debug.toJson(epnServices3));
107 116
108 System.out.println("\n*** 5. Getters***\n"); 117 System.out.println("\n*** 5. Getters***\n");