Commit 9144ee77c543d71dfec1cec43fb1e86e70adc0ce
1 parent
71d8a8ee
Exists in
master
Implement Service filter.
Showing
4 changed files
with
36 additions
and
19 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapFacade.java
... | ... | @@ -34,6 +34,7 @@ import eu.omp.irap.vespa.epntapclient.votable.model.VOTABLE; |
34 | 34 | import eu.omp.irap.vespa.votable.Consts; |
35 | 35 | import eu.omp.irap.vespa.votable.controller.CantGetVOTableException; |
36 | 36 | import eu.omp.irap.vespa.votable.controller.VOTableController; |
37 | +import eu.omp.irap.vespa.votable.utils.StringJoiner; | |
37 | 38 | import eu.omp.irap.vespa.votable.votabledata.VOTableData; |
38 | 39 | |
39 | 40 | /** |
... | ... | @@ -82,8 +83,12 @@ public class EpnTapFacade implements EpnTapInterface { |
82 | 83 | @Override |
83 | 84 | public VOTABLE getEPNService(String ivoid, List<String> attributes) |
84 | 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 | 94 | // *** Services *** |
... | ... | @@ -104,7 +109,7 @@ public class EpnTapFacade implements EpnTapInterface { |
104 | 109 | } |
105 | 110 | |
106 | 111 | @Override |
107 | - public VOTABLE getEPNServices(List<String> keywords, List<String> attributes) | |
112 | + public VOTABLE getEPNServices(Map<String, String> keywords, List<String> attributes) | |
108 | 113 | throws CantGetVOTableException { |
109 | 114 | // TODO process attributes and keywords |
110 | 115 | return getEPNServices(); | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapInterface.java
... | ... | @@ -96,7 +96,7 @@ public interface EpnTapInterface { |
96 | 96 | * @throws CantGetXMLException |
97 | 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 | 100 | throws CantGetVOTableException; |
101 | 101 | |
102 | 102 | // *** Getters *** | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/service/Queries.java
... | ... | @@ -61,11 +61,14 @@ public final class Queries { |
61 | 61 | /** Query to get the TAP service with the specified ivoid. */ |
62 | 62 | public static final String GET_TAP_SERVICES_WHERE_IVOID = |
63 | 63 | Queries.SELECT + Queries.FROM + Queries.WHERE_TAP |
64 | - + "AND ivoid = '%s' "; | |
64 | + + "AND ivoid = '%s'"; | |
65 | 65 | |
66 | 66 | public static final String GET_TAP_SERVICES_SELECT_WHERE_IVOID = |
67 | 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 | 73 | //@format |
71 | 74 | ... | ... |
src/test/java/eu/omp/irap/vespa/epntapclient/TestEpnTapFacade.java
... | ... | @@ -54,6 +54,16 @@ public class TestEpnTapFacade { |
54 | 54 | public static void main(String[] args) { |
55 | 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 | 67 | try { |
58 | 68 | facade.getEPNServices(); |
59 | 69 | |
... | ... | @@ -73,10 +83,8 @@ public class TestEpnTapFacade { |
73 | 83 | System.out.println("2.1 getEPNVOResources()\n\t" |
74 | 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 | 88 | + Debug.toJson(resources2)); |
81 | 89 | |
82 | 90 | System.out.println("\n*** 3. Service ***\n"); |
... | ... | @@ -85,10 +93,9 @@ public class TestEpnTapFacade { |
85 | 93 | System.out.println("3.1 getEPNService(\"" + TEST_SERVICE_IVOID + "\")\n\t" |
86 | 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 | 99 | + Debug.toJson(epnService2)); |
93 | 100 | |
94 | 101 | System.out.println("\n*** 4. Services ***\n"); |
... | ... | @@ -97,12 +104,14 @@ public class TestEpnTapFacade { |
97 | 104 | System.out.println("4.1 getEPNServices()\n\t" |
98 | 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 | 115 | + Debug.toJson(epnServices3)); |
107 | 116 | |
108 | 117 | System.out.println("\n*** 5. Getters***\n"); | ... | ... |