From c60d0aecbca63a9a052ee32dc7c40ba179d12a92 Mon Sep 17 00:00:00 2001 From: Nathanael Jourdane Date: Tue, 24 May 2016 19:02:56 +0200 Subject: [PATCH] Add Javadoc. --- src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java | 1 + src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java | 27 ++++++++++++++++++++++++++- src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java | 16 ++++++++++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java | 9 +++++++++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java | 6 ------ src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java | 16 ++++++++++++---- src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java | 2 ++ src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java | 2 -- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java | 2 +- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java | 5 ++++- src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java | 11 ++++++++--- src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java | 39 +++++++++++++++++++++++++-------------- src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java | 25 +++++++++++++++++++++++++ 13 files changed, 129 insertions(+), 32 deletions(-) diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java index 42186f7..2974342 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java @@ -34,6 +34,7 @@ public class EpnTapException extends Exception { /** * @param message A message describing the error. + * @param e The exception thrown. */ public EpnTapException(String message, Exception e) { super(message, e); 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 8d60abf..d7aac69 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java @@ -57,7 +57,8 @@ 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, containing {@link #KEYWORD_TABLE_NAME} which will be replaced by the + * actual name of each table. */ private String query; @@ -75,6 +76,7 @@ public class RequestCtrl { * Constructor of RequestCtrl. * * @param nbMaxResult The maximum number of rows returned by the query. + * @param columnNames The names of the columns used in the SELECT keyword in the query. */ public RequestCtrl(int nbMaxResult, List columnNames) { this.nbMaxResult = nbMaxResult; @@ -104,6 +106,9 @@ public class RequestCtrl { return targetNames; } + /** + * @return The names of the columns used in the SELECT keyword in the query. + */ public List getColumnNames() { return columnNames; } @@ -124,10 +129,20 @@ public class RequestCtrl { return parameters; } + /** + * @return The query to send, with the name of the table is replaced by + * {@link #KEYWORD_TABLE_NAME}. + */ public String getQuery() { return query; } + /** + * Get the query and replace the {@link #KEYWORD_TABLE_NAME} by the specified tableName. + * + * @param tableName The name of the table, to put in the FROM ADQL keyword. + * @return The ADQL query, containing the specified table name. + */ public String getQuery(String tableName) { return query.replace(KEYWORD_TABLE_NAME, tableName); } @@ -142,6 +157,11 @@ public class RequestCtrl { LOGGER.info("removed " + paramName); } + /** + * Set the names of the columns used in the SELECT keyword in the query. + * + * @param columnNames The columns names. + */ public void setColumnNames(List columnNames) { this.columnNames = columnNames; } @@ -155,6 +175,11 @@ public class RequestCtrl { nbMaxResult = nbRows; } + /** + * Set the query, containing {@link #KEYWORD_TABLE_NAME}. + * + * @param query The query. + */ public void setQuery(String query) { this.query = query; } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java b/src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java index 6ea81c4..80f32a6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java @@ -30,12 +30,16 @@ public class ServicesList { /** The logger for the class ServicesList. */ private static final Logger LOGGER = Logger.getLogger(ServicesList.class.getName()); + /** The list of table names entered in the custom table name field. */ private List customTableNames; + /** The list of target URLs entered in the custom target URL field. */ private List customTargetUrls; + /** The list of table names selected in the services table. */ private List selectedTableNames; + /** The list of target URLs selected in the services table. */ private List selectedTargetUrls; @@ -69,6 +73,12 @@ public class ServicesList { return targetUrls; } + /** + * Update the services (table name and target URLs) entered in the custom services fields. + * + * @param customTableNamesToAdd The list of the table names to update. + * @param customTargetUrlsToAdd The list of the target URLs to update. + */ public void updateCustomServices(List customTableNamesToAdd, List customTargetUrlsToAdd) { customTableNames = customTableNamesToAdd; @@ -77,6 +87,12 @@ public class ServicesList { LOGGER.info("Updated custom services URLs: " + StringJoiner.join(customTargetUrls)); } + /** + * Update the services (table name and target URLs) selected in the services table. + * + * @param selectedTableNamesToAdd The list of the table names to update. + * @param selectedTargetUrlsToAdd The list of the target URLs to update. + */ public void updateSelectedServices(List selectedTableNamesToAdd, List selectedTargetUrlsToAdd) { selectedTableNames = selectedTableNamesToAdd; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java index 29e121a..fef612c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java @@ -291,6 +291,11 @@ public class Granule { this.granuleUid = granuleUid; } + /** + * Convert the Granule to a Map, as . + * + * @return the Granule as a map. + */ public Map asMap() { Map map = new HashMap<>(); map.put(GranuleEnum.GRANULE_UID.toString(), granuleUid); @@ -948,6 +953,10 @@ public class Granule { return true; } + /** + * @return a string containing all the parameters of the Granule, as strings (key: value). Used + * to be printed for debug purposes. + */ public String printAll() { String s = ""; for (Map.Entry parameter : asMap().entrySet()) { 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 9b30bf4..00c0bc6 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 @@ -16,7 +16,6 @@ package eu.omp.irap.vespa.epntapclient.gui.mainpanel; -import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -89,11 +88,6 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener return servicesPanelCtrl; } - @Override - public List getTableNames() { - return servicesPanelCtrl.getServices().getTableNames(); - } - /** * @return The main view of the application. */ diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java index f626762..312403d 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java @@ -16,18 +16,26 @@ package eu.omp.irap.vespa.epntapclient.gui.mainpanel; -import java.util.List; - /** * @author N. Jourdane */ public interface MainPanelListener { + /** + * Ask the main panel to open a pop-up and display the specified error. + * + * @param message A short message describing the error, which will be the pop-up title. + * @param e The error itself. + */ void displayError(String message, Exception e); - List getTableNames(); - + /** + * Ask the main panel to send the query. + */ void sendQuery(); + /** + * Ask the main panel to update the query. + */ void updateQuery(); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java index cf30014..24fc078 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java @@ -44,6 +44,8 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis /** * Constructor of ResultPanelCtrl. + * + * @param listener The listener of the main panel. */ public ResultPanelCtrl(MainPanelListener listener) { this.listener = listener; diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java index f19d99b..c8c2dd6 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java @@ -18,7 +18,6 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel; import java.io.File; -import eu.omp.irap.vespa.votable.controller.VOTableException.CantSaveVOTableException; import eu.omp.irap.vespa.votable.view.VOTableViewListener; /** @@ -31,7 +30,6 @@ public interface ResultPanelListener extends VOTableViewListener { * * @param file The file selected by the user in the FileChooser pop-up, corresponding to the * place where save the VOTable. - * @throws CantSaveVOTableException The VOTable can not be saved at the specified location. */ public void onDownloadButtonClicked(File file); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java index 2b9be9a..daa2e28 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java @@ -93,7 +93,7 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane } @Override - public void onServiceUpdated() { + public void onServiceListUpdated() { String tableName = view.getTableNameTextField().getText(); String targetUrl = view.getServiceUrlTextField().getText(); List customTableNames = Arrays.asList(tableName.split(CUSTOM_SERVICES_SEPARATOR)); diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java index f9c2e62..47aa32c 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java @@ -23,5 +23,8 @@ import eu.omp.irap.vespa.votable.view.VOTableViewListener; */ public interface ServicesPanelListener extends VOTableViewListener { - public void onServiceUpdated(); + /** + * This method is called when the services list is updated. + */ + public void onServiceListUpdated(); } diff --git a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java index a338651..8911f96 100644 --- a/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java +++ b/src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java @@ -56,22 +56,27 @@ public class ServicesPanelView extends VOTableView { buildServicesPanel(); } + /** + * Add to a textField a listener to listen for text update events (changed, inserted, removed). + * + * @param textField the textField to listen. + */ public void addEventListener(JTextField textField) { textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { - listener.onServiceUpdated(); + listener.onServiceListUpdated(); } @Override public void insertUpdate(DocumentEvent e) { - listener.onServiceUpdated(); + listener.onServiceListUpdated(); } @Override public void removeUpdate(DocumentEvent e) { - listener.onServiceUpdated(); + listener.onServiceListUpdated(); } }); } diff --git a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java index 742b872..45c0bb7 100644 --- a/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java +++ b/src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java @@ -32,28 +32,23 @@ import eu.omp.irap.vespa.votable.votabledata.VoTableDataTest; */ public class GranuleCtrlTest { + /** The granule controller, initialized with {@link VoTableDataTest#createVoTableData()}. */ GranuleCtrl granuleCtrl; + /** + * Constructor of GranuleCtrlTest. + */ public GranuleCtrlTest() { granuleCtrl = new GranuleCtrl(VoTableDataTest.createVoTableData()); } + /** + * Test the method {@link GranuleCtrl#getGranuleFromVOTableRow(int)} by comparing the granules + * with voTableData. + */ @Test - public void getGranulesTest() { - List granules = null; - try { - granules = granuleCtrl.getGranules(); - } catch (CanNotParseDataException e) { - fail("Can not parse granule: " + e.getMessage()); - } - assertNotNull(granules); - assertTrue(granules.get(0).equals(GranuleTest.createGranule1())); - assertTrue(granules.get(1).equals(GranuleTest.createGranule2())); - } - - @Test - public void parseStringTest() { + public void getGranuleFromVOTableRowTest() { Granule g1 = null; Granule g2 = null; try { @@ -67,4 +62,20 @@ public class GranuleCtrlTest { assertTrue(g1.equals(GranuleTest.createGranule1())); assertTrue(g2.equals(GranuleTest.createGranule2())); } + + /** + * Test the method {@link GranuleCtrl#getGranules()} by comparing the granules with voTableData. + */ + @Test + public void getGranulesTest() { + List granules = null; + try { + granules = granuleCtrl.getGranules(); + } catch (CanNotParseDataException e) { + fail("Can not parse granule: " + e.getMessage()); + } + assertNotNull(granules); + assertTrue(granules.get(0).equals(GranuleTest.createGranule1())); + assertTrue(granules.get(1).equals(GranuleTest.createGranule2())); + } } 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 642f3a2..6f9e1cd 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 @@ -27,6 +27,8 @@ import java.util.logging.Logger; import org.junit.Test; +import eu.omp.irap.vespa.votable.votabledata.VoTableDataTest; + /** * @author N. Jourdane */ @@ -36,6 +38,12 @@ public class GranuleTest { private static final Logger LOGGER = Logger.getLogger(GranuleTest.class.getName()); + /** + * Create a granule for tests purposes. It is planetary data for Uranus, got from an actual ADQL + * query, exactly the same content that {@link VoTableDataTest#createDataArray1()} + * + * @return The granule. + */ public static Granule createGranule1() { Date testDate = null; try { @@ -91,6 +99,12 @@ public class GranuleTest { return completeGranule; } + /** + * Create a granule for tests purposes. It is planetary data for Neptune, got from an actual + * query, exactly the same content that {@link VoTableDataTest#createDataArray2()} + * + * @return The granule. + */ public static Granule createGranule2() { Date testDate = null; try { @@ -146,18 +160,29 @@ public class GranuleTest { return completeGranule; } + /** + * Create an incomplete granule without many mandatory parameters, which is forbidden. + * + * @return the granule. + */ public static Granule createIncompleteGranule() { Granule incompleteGranule = new Granule("Mercury"); incompleteGranule.setGranuleGid("Planet"); return incompleteGranule; } + /** + * Test if the incomplete granule appears like not valid. + */ @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. @Test public void isNotValidTest() { assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid()); } + /** + * Test if a complete granule appears like valid. + */ @SuppressWarnings("static-method") // Otherwise JUnit doesn't work. @Test public void isValidTest() { -- libgit2 0.21.2