Commit 987f00a7ec6cddf46e86c1829c5d8f05defc3a8c
1 parent
3288883d
Exists in
master
Use ServicesList in getQueries, and minor warnings fixes.
Showing
6 changed files
with
15 additions
and
34 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java
... | ... | @@ -56,7 +56,6 @@ public abstract class EpnTapController { |
56 | 56 | * Method constructor, which initialize servicesController, resultsController and mainView. |
57 | 57 | */ |
58 | 58 | public EpnTapController() { |
59 | - // TODO: Should not init controllers, because the default ctrl is called by subclasses. | |
60 | 59 | String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, |
61 | 60 | ServiceCore.EPNCORE); |
62 | 61 | servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); |
... | ... | @@ -104,25 +103,17 @@ public abstract class EpnTapController { |
104 | 103 | /** |
105 | 104 | * ... |
106 | 105 | * |
107 | - * @param tableNames | |
108 | - * @param servicesUrls | |
106 | + * @param services The services to send the queries. | |
109 | 107 | * @throws VOTableException Can not update the VOTable. |
110 | - * @throws EpnTapException The lists are empty. | |
111 | 108 | */ |
112 | - public void sendQuery(List<String> tableNames, List<String> servicesUrls) | |
113 | - throws VOTableException, EpnTapException { | |
109 | + public void sendQueries(ServicesList services) throws VOTableException { | |
114 | 110 | // Here getRequestCtrl() and getResultsCtrl() are used instead of class fields requestCtrl |
115 | 111 | // and resultCtrl to get the subclass field, since subclasses overrides getRequestCtrl() and |
116 | 112 | // getResultsCtrl(). |
113 | + List<String> servicesUrls = services.getTargetUrls(); | |
117 | 114 | LOGGER.info("Sending query(ies) on " + StringJoiner.join(servicesUrls)); |
118 | - if (tableNames.isEmpty()) { | |
119 | - throw new EpnTapException("There is no service to query."); | |
120 | - } else if (tableNames.size() != servicesUrls.size()) { | |
121 | - throw new EpnTapException( | |
122 | - "list of tableNames and list of servicesUrls are not the same size."); | |
123 | - } | |
124 | - for (int i = 0; i < tableNames.size(); i++) { | |
125 | - String query = getRequestCtrl().getQuery(tableNames.get(i)); | |
115 | + for (int i = 0; i < servicesUrls.size(); i++) { | |
116 | + String query = getRequestCtrl().getQuery(services.getTableNames().get(i)); | |
126 | 117 | getResultsCtrl().updateVOTable(servicesUrls.get(i), query); |
127 | 118 | } |
128 | 119 | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java
... | ... | @@ -35,14 +35,14 @@ import eu.omp.irap.vespa.votable.utils.StringJoiner; |
35 | 35 | public class RequestCtrl { |
36 | 36 | |
37 | 37 | /** The text in the query to replaced by the actual table name. */ |
38 | - private static final String KEYWORD_TABLE_NAME_ = "#tablename#"; | |
38 | + private static final String KEYWORD_TABLE_NAME = "#tablename#"; | |
39 | 39 | |
40 | 40 | /** The logger for the class RequestCtrl. */ |
41 | 41 | private static final Logger LOGGER = Logger.getLogger(RequestCtrl.class.getName()); |
42 | 42 | |
43 | 43 | /** The query template to get granules. */ |
44 | 44 | private static final String QUERY_TEMPLATE = "SELECT DISTINCT TOP %s %s FROM " |
45 | - + KEYWORD_TABLE_NAME_ + "%s"; | |
45 | + + KEYWORD_TABLE_NAME + "%s"; | |
46 | 46 | |
47 | 47 | /** The URL of the resolver used for the `target name` field. */ |
48 | 48 | private static final String RESOLVER_URL = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete"; |
... | ... | @@ -57,7 +57,7 @@ public class RequestCtrl { |
57 | 57 | private Map<String, Object> parameters = new HashMap<>(); |
58 | 58 | |
59 | 59 | /** |
60 | - * The query to send, with the name of the table is replaced by {@link #KEYWORD_TABLE_NAME_}. | |
60 | + * The query to send, with the name of the table is replaced by {@link #KEYWORD_TABLE_NAME}. | |
61 | 61 | */ |
62 | 62 | private String query; |
63 | 63 | |
... | ... | @@ -129,7 +129,7 @@ public class RequestCtrl { |
129 | 129 | } |
130 | 130 | |
131 | 131 | public String getQuery(String tableName) { |
132 | - return query.replace(KEYWORD_TABLE_NAME_, tableName); | |
132 | + return query.replace(KEYWORD_TABLE_NAME, tableName); | |
133 | 133 | } |
134 | 134 | |
135 | 135 | /** | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java
... | ... | @@ -21,7 +21,6 @@ import java.text.SimpleDateFormat; |
21 | 21 | import java.util.ArrayList; |
22 | 22 | import java.util.Date; |
23 | 23 | import java.util.List; |
24 | -import java.util.logging.Logger; | |
25 | 24 | |
26 | 25 | import eu.omp.irap.vespa.votable.controller.VOTableException.CanNotParseDataException; |
27 | 26 | import eu.omp.irap.vespa.votable.votabledata.VOTableData; |
... | ... | @@ -31,12 +30,6 @@ import eu.omp.irap.vespa.votable.votabledata.VOTableData; |
31 | 30 | */ |
32 | 31 | public class GranuleCtrl { |
33 | 32 | |
34 | - /** The error message when the specified row is not found. */ | |
35 | - private static final String ERROR_MSG = "%s not found in the rowId %s: return %s."; | |
36 | - | |
37 | - /** The logger for the class GranuleCtrl. */ | |
38 | - private static final Logger LOGGER = Logger.getLogger(GranuleCtrl.class.getName()); | |
39 | - | |
40 | 33 | /** The data to parse */ |
41 | 34 | private VOTableData data; |
42 | 35 | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java
... | ... | @@ -23,7 +23,6 @@ import java.util.logging.Logger; |
23 | 23 | import javax.swing.JOptionPane; |
24 | 24 | |
25 | 25 | import eu.omp.irap.vespa.epntapclient.EpnTapController; |
26 | -import eu.omp.irap.vespa.epntapclient.EpnTapException; | |
27 | 26 | import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; |
28 | 27 | import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelCtrl; |
29 | 28 | import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl; |
... | ... | @@ -114,12 +113,8 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener |
114 | 113 | |
115 | 114 | @Override |
116 | 115 | public void sendQuery() { |
117 | - List<String> tableNames = servicesPanelCtrl.getServices().getTableNames(); | |
118 | - List<String> targetUrls = servicesPanelCtrl.getServices().getTargetUrls(); | |
119 | 116 | try { |
120 | - sendQuery(tableNames, targetUrls); | |
121 | - } catch (EpnTapException e) { | |
122 | - displayError("There is no service selected.", e); | |
117 | + sendQueries(servicesPanelCtrl.getServices()); | |
123 | 118 | } catch (VOTableException e) { |
124 | 119 | displayError("Can not update the VOTable.", e); |
125 | 120 | } | ... | ... |
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java
... | ... | @@ -38,7 +38,6 @@ public class RequestPanelCtrl extends RequestCtrl implements RequestPanelListene |
38 | 38 | */ |
39 | 39 | public RequestPanelCtrl(MainPanelListener listener) { |
40 | 40 | this.listener = listener; |
41 | - // TODO: Add panel to enter column names and the max results. | |
42 | 41 | view = new RequestPanelView(this); |
43 | 42 | } |
44 | 43 | ... | ... |
src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java
... | ... | @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue; |
22 | 22 | import java.text.ParseException; |
23 | 23 | import java.text.SimpleDateFormat; |
24 | 24 | import java.util.Date; |
25 | +import java.util.logging.Level; | |
25 | 26 | import java.util.logging.Logger; |
26 | 27 | |
27 | 28 | import org.junit.Test; |
... | ... | @@ -40,7 +41,7 @@ public class GranuleTest { |
40 | 41 | try { |
41 | 42 | testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20"); |
42 | 43 | } catch (ParseException e) { |
43 | - LOGGER.warning("Can not parse the test date."); | |
44 | + LOGGER.log(Level.WARNING, "Can not parse the test date.", e); | |
44 | 45 | } |
45 | 46 | |
46 | 47 | Granule completeGranule = new Granule("Uranus"); |
... | ... | @@ -95,7 +96,7 @@ public class GranuleTest { |
95 | 96 | try { |
96 | 97 | testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20"); |
97 | 98 | } catch (ParseException e) { |
98 | - LOGGER.warning("Can not parse the test date."); | |
99 | + LOGGER.log(Level.WARNING, "Can not parse the test date.", e); | |
99 | 100 | } |
100 | 101 | |
101 | 102 | Granule completeGranule = new Granule("Neptune"); |
... | ... | @@ -151,11 +152,13 @@ public class GranuleTest { |
151 | 152 | return incompleteGranule; |
152 | 153 | } |
153 | 154 | |
155 | + @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. | |
154 | 156 | @Test |
155 | 157 | public void isNotValidTest() { |
156 | 158 | assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid()); |
157 | 159 | } |
158 | 160 | |
161 | + @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. | |
159 | 162 | @Test |
160 | 163 | public void isValidTest() { |
161 | 164 | assertTrue("The complete granule is not valid.", createGranule1().isValid()); | ... | ... |