diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java index be7910a..2c579a9 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapController.java @@ -56,7 +56,6 @@ public abstract class EpnTapController { * Method constructor, which initialize servicesController, resultsController and mainView. */ public EpnTapController() { - // TODO: Should not init controllers, because the default ctrl is called by subclasses. String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE, ServiceCore.EPNCORE); servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, query); @@ -104,25 +103,17 @@ public abstract class EpnTapController { /** * ... * - * @param tableNames - * @param servicesUrls + * @param services The services to send the queries. * @throws VOTableException Can not update the VOTable. - * @throws EpnTapException The lists are empty. */ - public void sendQuery(List tableNames, List servicesUrls) - throws VOTableException, EpnTapException { + public void sendQueries(ServicesList services) throws VOTableException { // Here getRequestCtrl() and getResultsCtrl() are used instead of class fields requestCtrl // and resultCtrl to get the subclass field, since subclasses overrides getRequestCtrl() and // getResultsCtrl(). + List servicesUrls = services.getTargetUrls(); LOGGER.info("Sending query(ies) on " + StringJoiner.join(servicesUrls)); - if (tableNames.isEmpty()) { - throw new EpnTapException("There is no service to query."); - } else if (tableNames.size() != servicesUrls.size()) { - throw new EpnTapException( - "list of tableNames and list of servicesUrls are not the same size."); - } - for (int i = 0; i < tableNames.size(); i++) { - String query = getRequestCtrl().getQuery(tableNames.get(i)); + for (int i = 0; i < servicesUrls.size(); i++) { + String query = getRequestCtrl().getQuery(services.getTableNames().get(i)); getResultsCtrl().updateVOTable(servicesUrls.get(i), query); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java index abdd95a..8d60abf 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java @@ -35,14 +35,14 @@ import eu.omp.irap.vespa.votable.utils.StringJoiner; public class RequestCtrl { /** The text in the query to replaced by the actual table name. */ - private static final String KEYWORD_TABLE_NAME_ = "#tablename#"; + private static final String KEYWORD_TABLE_NAME = "#tablename#"; /** The logger for the class RequestCtrl. */ private static final Logger LOGGER = Logger.getLogger(RequestCtrl.class.getName()); /** The query template to get granules. */ private static final String QUERY_TEMPLATE = "SELECT DISTINCT TOP %s %s FROM " - + KEYWORD_TABLE_NAME_ + "%s"; + + KEYWORD_TABLE_NAME + "%s"; /** The URL of the resolver used for the `target name` field. */ private static final String RESOLVER_URL = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete"; @@ -57,7 +57,7 @@ public class RequestCtrl { private Map parameters = new HashMap<>(); /** - * The query to send, with the name of the table is replaced by {@link #KEYWORD_TABLE_NAME_}. + * The query to send, with the name of the table is replaced by {@link #KEYWORD_TABLE_NAME}. */ private String query; @@ -129,7 +129,7 @@ public class RequestCtrl { } public String getQuery(String tableName) { - return query.replace(KEYWORD_TABLE_NAME_, tableName); + return query.replace(KEYWORD_TABLE_NAME, tableName); } /** diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java index b3ceb81..2f5fceb 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrl.java @@ -21,7 +21,6 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.logging.Logger; import eu.omp.irap.vespa.votable.controller.VOTableException.CanNotParseDataException; import eu.omp.irap.vespa.votable.votabledata.VOTableData; @@ -31,12 +30,6 @@ import eu.omp.irap.vespa.votable.votabledata.VOTableData; */ public class GranuleCtrl { - /** The error message when the specified row is not found. */ - private static final String ERROR_MSG = "%s not found in the rowId %s: return %s."; - - /** The logger for the class GranuleCtrl. */ - private static final Logger LOGGER = Logger.getLogger(GranuleCtrl.class.getName()); - /** The data to parse */ private VOTableData data; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java index e6735dd..9b30bf4 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java @@ -23,7 +23,6 @@ import java.util.logging.Logger; import javax.swing.JOptionPane; import eu.omp.irap.vespa.epntapclient.EpnTapController; -import eu.omp.irap.vespa.epntapclient.EpnTapException; import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelCtrl; import eu.omp.irap.vespa.epntapclient.gui.resultpanel.ResultPanelCtrl; import eu.omp.irap.vespa.epntapclient.gui.servicespanel.ServicesPanelCtrl; @@ -114,12 +113,8 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener @Override public void sendQuery() { - List tableNames = servicesPanelCtrl.getServices().getTableNames(); - List targetUrls = servicesPanelCtrl.getServices().getTargetUrls(); try { - sendQuery(tableNames, targetUrls); - } catch (EpnTapException e) { - displayError("There is no service selected.", e); + sendQueries(servicesPanelCtrl.getServices()); } catch (VOTableException e) { displayError("Can not update the VOTable.", e); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java index 49d1385..3054513 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/RequestPanelCtrl.java @@ -38,7 +38,6 @@ public class RequestPanelCtrl extends RequestCtrl implements RequestPanelListene */ public RequestPanelCtrl(MainPanelListener listener) { this.listener = listener; - // TODO: Add panel to enter column names and the max results. view = new RequestPanelView(this); } diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java index baa7afb..642f3a2 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java @@ -22,6 +22,7 @@ import static org.junit.Assert.assertTrue; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.logging.Level; import java.util.logging.Logger; import org.junit.Test; @@ -40,7 +41,7 @@ public class GranuleTest { try { testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20"); } catch (ParseException e) { - LOGGER.warning("Can not parse the test date."); + LOGGER.log(Level.WARNING, "Can not parse the test date.", e); } Granule completeGranule = new Granule("Uranus"); @@ -95,7 +96,7 @@ public class GranuleTest { try { testDate = new SimpleDateFormat("yyyy-mm-dd").parse("2015-08-20"); } catch (ParseException e) { - LOGGER.warning("Can not parse the test date."); + LOGGER.log(Level.WARNING, "Can not parse the test date.", e); } Granule completeGranule = new Granule("Neptune"); @@ -151,11 +152,13 @@ public class GranuleTest { return incompleteGranule; } + @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. @Test public void isNotValidTest() { assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid()); } + @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. @Test public void isValidTest() { assertTrue("The complete granule is not valid.", createGranule1().isValid()); -- libgit2 0.21.2