Commit c60d0aecbca63a9a052ee32dc7c40ba179d12a92

Authored by Nathanael Jourdane
1 parent 987f00a7
Exists in master

Add Javadoc.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapException.java
... ... @@ -34,6 +34,7 @@ public class EpnTapException extends Exception {
34 34  
35 35 /**
36 36 * @param message A message describing the error.
  37 + * @param e The exception thrown.
37 38 */
38 39 public EpnTapException(String message, Exception e) {
39 40 super(message, e);
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/RequestCtrl.java
... ... @@ -57,7 +57,8 @@ 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, containing {@link #KEYWORD_TABLE_NAME} which will be replaced by the
  61 + * actual name of each table.
61 62 */
62 63 private String query;
63 64  
... ... @@ -75,6 +76,7 @@ public class RequestCtrl {
75 76 * Constructor of RequestCtrl.
76 77 *
77 78 * @param nbMaxResult The maximum number of rows returned by the query.
  79 + * @param columnNames The names of the columns used in the SELECT keyword in the query.
78 80 */
79 81 public RequestCtrl(int nbMaxResult, List<String> columnNames) {
80 82 this.nbMaxResult = nbMaxResult;
... ... @@ -104,6 +106,9 @@ public class RequestCtrl {
104 106 return targetNames;
105 107 }
106 108  
  109 + /**
  110 + * @return The names of the columns used in the SELECT keyword in the query.
  111 + */
107 112 public List<String> getColumnNames() {
108 113 return columnNames;
109 114 }
... ... @@ -124,10 +129,20 @@ public class RequestCtrl {
124 129 return parameters;
125 130 }
126 131  
  132 + /**
  133 + * @return The query to send, with the name of the table is replaced by
  134 + * {@link #KEYWORD_TABLE_NAME}.
  135 + */
127 136 public String getQuery() {
128 137 return query;
129 138 }
130 139  
  140 + /**
  141 + * Get the query and replace the {@link #KEYWORD_TABLE_NAME} by the specified tableName.
  142 + *
  143 + * @param tableName The name of the table, to put in the FROM ADQL keyword.
  144 + * @return The ADQL query, containing the specified table name.
  145 + */
131 146 public String getQuery(String tableName) {
132 147 return query.replace(KEYWORD_TABLE_NAME, tableName);
133 148 }
... ... @@ -142,6 +157,11 @@ public class RequestCtrl {
142 157 LOGGER.info("removed " + paramName);
143 158 }
144 159  
  160 + /**
  161 + * Set the names of the columns used in the SELECT keyword in the query.
  162 + *
  163 + * @param columnNames The columns names.
  164 + */
145 165 public void setColumnNames(List<String> columnNames) {
146 166 this.columnNames = columnNames;
147 167 }
... ... @@ -155,6 +175,11 @@ public class RequestCtrl {
155 175 nbMaxResult = nbRows;
156 176 }
157 177  
  178 + /**
  179 + * Set the query, containing {@link #KEYWORD_TABLE_NAME}.
  180 + *
  181 + * @param query The query.
  182 + */
158 183 public void setQuery(String query) {
159 184 this.query = query;
160 185 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/ServicesList.java
... ... @@ -30,12 +30,16 @@ public class ServicesList {
30 30 /** The logger for the class ServicesList. */
31 31 private static final Logger LOGGER = Logger.getLogger(ServicesList.class.getName());
32 32  
  33 + /** The list of table names entered in the custom table name field. */
33 34 private List<String> customTableNames;
34 35  
  36 + /** The list of target URLs entered in the custom target URL field. */
35 37 private List<String> customTargetUrls;
36 38  
  39 + /** The list of table names selected in the services table. */
37 40 private List<String> selectedTableNames;
38 41  
  42 + /** The list of target URLs selected in the services table. */
39 43 private List<String> selectedTargetUrls;
40 44  
41 45  
... ... @@ -69,6 +73,12 @@ public class ServicesList {
69 73 return targetUrls;
70 74 }
71 75  
  76 + /**
  77 + * Update the services (table name and target URLs) entered in the custom services fields.
  78 + *
  79 + * @param customTableNamesToAdd The list of the table names to update.
  80 + * @param customTargetUrlsToAdd The list of the target URLs to update.
  81 + */
72 82 public void updateCustomServices(List<String> customTableNamesToAdd,
73 83 List<String> customTargetUrlsToAdd) {
74 84 customTableNames = customTableNamesToAdd;
... ... @@ -77,6 +87,12 @@ public class ServicesList {
77 87 LOGGER.info("Updated custom services URLs: " + StringJoiner.join(customTargetUrls));
78 88 }
79 89  
  90 + /**
  91 + * Update the services (table name and target URLs) selected in the services table.
  92 + *
  93 + * @param selectedTableNamesToAdd The list of the table names to update.
  94 + * @param selectedTargetUrlsToAdd The list of the target URLs to update.
  95 + */
80 96 public void updateSelectedServices(List<String> selectedTableNamesToAdd,
81 97 List<String> selectedTargetUrlsToAdd) {
82 98 selectedTableNames = selectedTableNamesToAdd;
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/granule/Granule.java
... ... @@ -291,6 +291,11 @@ public class Granule {
291 291 this.granuleUid = granuleUid;
292 292 }
293 293  
  294 + /**
  295 + * Convert the Granule to a Map, as <Granule name, Granule value>.
  296 + *
  297 + * @return the Granule as a map.
  298 + */
294 299 public Map<String, Object> asMap() {
295 300 Map<String, Object> map = new HashMap<>();
296 301 map.put(GranuleEnum.GRANULE_UID.toString(), granuleUid);
... ... @@ -948,6 +953,10 @@ public class Granule {
948 953 return true;
949 954 }
950 955  
  956 + /**
  957 + * @return a string containing all the parameters of the Granule, as strings (key: value). Used
  958 + * to be printed for debug purposes.
  959 + */
951 960 public String printAll() {
952 961 String s = "";
953 962 for (Map.Entry<String, Object> parameter : asMap().entrySet()) {
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelCtrl.java
... ... @@ -16,7 +16,6 @@
16 16  
17 17 package eu.omp.irap.vespa.epntapclient.gui.mainpanel;
18 18  
19   -import java.util.List;
20 19 import java.util.logging.Level;
21 20 import java.util.logging.Logger;
22 21  
... ... @@ -89,11 +88,6 @@ public class MainPanelCtrl extends EpnTapController implements MainPanelListener
89 88 return servicesPanelCtrl;
90 89 }
91 90  
92   - @Override
93   - public List<String> getTableNames() {
94   - return servicesPanelCtrl.getServices().getTableNames();
95   - }
96   -
97 91 /**
98 92 * @return The main view of the application.
99 93 */
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/mainpanel/MainPanelListener.java
... ... @@ -16,18 +16,26 @@
16 16  
17 17 package eu.omp.irap.vespa.epntapclient.gui.mainpanel;
18 18  
19   -import java.util.List;
20   -
21 19 /**
22 20 * @author N. Jourdane
23 21 */
24 22 public interface MainPanelListener {
25 23  
  24 + /**
  25 + * Ask the main panel to open a pop-up and display the specified error.
  26 + *
  27 + * @param message A short message describing the error, which will be the pop-up title.
  28 + * @param e The error itself.
  29 + */
26 30 void displayError(String message, Exception e);
27 31  
28   - List<String> getTableNames();
29   -
  32 + /**
  33 + * Ask the main panel to send the query.
  34 + */
30 35 void sendQuery();
31 36  
  37 + /**
  38 + * Ask the main panel to update the query.
  39 + */
32 40 void updateQuery();
33 41 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelCtrl.java
... ... @@ -44,6 +44,8 @@ public class ResultPanelCtrl extends VOTableController implements ResultPanelLis
44 44  
45 45 /**
46 46 * Constructor of ResultPanelCtrl.
  47 + *
  48 + * @param listener The listener of the main panel.
47 49 */
48 50 public ResultPanelCtrl(MainPanelListener listener) {
49 51 this.listener = listener;
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/resultpanel/ResultPanelListener.java
... ... @@ -18,7 +18,6 @@ package eu.omp.irap.vespa.epntapclient.gui.resultpanel;
18 18  
19 19 import java.io.File;
20 20  
21   -import eu.omp.irap.vespa.votable.controller.VOTableException.CantSaveVOTableException;
22 21 import eu.omp.irap.vespa.votable.view.VOTableViewListener;
23 22  
24 23 /**
... ... @@ -31,7 +30,6 @@ public interface ResultPanelListener extends VOTableViewListener {
31 30 *
32 31 * @param file The file selected by the user in the FileChooser pop-up, corresponding to the
33 32 * place where save the VOTable.
34   - * @throws CantSaveVOTableException The VOTable can not be saved at the specified location.
35 33 */
36 34 public void onDownloadButtonClicked(File file);
37 35 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelCtrl.java
... ... @@ -93,7 +93,7 @@ public class ServicesPanelCtrl extends VOTableController implements ServicesPane
93 93 }
94 94  
95 95 @Override
96   - public void onServiceUpdated() {
  96 + public void onServiceListUpdated() {
97 97 String tableName = view.getTableNameTextField().getText();
98 98 String targetUrl = view.getServiceUrlTextField().getText();
99 99 List<String> customTableNames = Arrays.asList(tableName.split(CUSTOM_SERVICES_SEPARATOR));
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelListener.java
... ... @@ -23,5 +23,8 @@ import eu.omp.irap.vespa.votable.view.VOTableViewListener;
23 23 */
24 24 public interface ServicesPanelListener extends VOTableViewListener {
25 25  
26   - public void onServiceUpdated();
  26 + /**
  27 + * This method is called when the services list is updated.
  28 + */
  29 + public void onServiceListUpdated();
27 30 }
... ...
src/main/java/eu/omp/irap/vespa/epntapclient/gui/servicespanel/ServicesPanelView.java
... ... @@ -56,22 +56,27 @@ public class ServicesPanelView extends VOTableView {
56 56 buildServicesPanel();
57 57 }
58 58  
  59 + /**
  60 + * Add to a textField a listener to listen for text update events (changed, inserted, removed).
  61 + *
  62 + * @param textField the textField to listen.
  63 + */
59 64 public void addEventListener(JTextField textField) {
60 65 textField.getDocument().addDocumentListener(new DocumentListener() {
61 66  
62 67 @Override
63 68 public void changedUpdate(DocumentEvent e) {
64   - listener.onServiceUpdated();
  69 + listener.onServiceListUpdated();
65 70 }
66 71  
67 72 @Override
68 73 public void insertUpdate(DocumentEvent e) {
69   - listener.onServiceUpdated();
  74 + listener.onServiceListUpdated();
70 75 }
71 76  
72 77 @Override
73 78 public void removeUpdate(DocumentEvent e) {
74   - listener.onServiceUpdated();
  79 + listener.onServiceListUpdated();
75 80 }
76 81 });
77 82 }
... ...
src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleCtrlTest.java
... ... @@ -32,28 +32,23 @@ import eu.omp.irap.vespa.votable.votabledata.VoTableDataTest;
32 32 */
33 33 public class GranuleCtrlTest {
34 34  
  35 + /** The granule controller, initialized with {@link VoTableDataTest#createVoTableData()}. */
35 36 GranuleCtrl granuleCtrl;
36 37  
37 38  
  39 + /**
  40 + * Constructor of GranuleCtrlTest.
  41 + */
38 42 public GranuleCtrlTest() {
39 43 granuleCtrl = new GranuleCtrl(VoTableDataTest.createVoTableData());
40 44 }
41 45  
  46 + /**
  47 + * Test the method {@link GranuleCtrl#getGranuleFromVOTableRow(int)} by comparing the granules
  48 + * with voTableData.
  49 + */
42 50 @Test
43   - public void getGranulesTest() {
44   - List<Granule> granules = null;
45   - try {
46   - granules = granuleCtrl.getGranules();
47   - } catch (CanNotParseDataException e) {
48   - fail("Can not parse granule: " + e.getMessage());
49   - }
50   - assertNotNull(granules);
51   - assertTrue(granules.get(0).equals(GranuleTest.createGranule1()));
52   - assertTrue(granules.get(1).equals(GranuleTest.createGranule2()));
53   - }
54   -
55   - @Test
56   - public void parseStringTest() {
  51 + public void getGranuleFromVOTableRowTest() {
57 52 Granule g1 = null;
58 53 Granule g2 = null;
59 54 try {
... ... @@ -67,4 +62,20 @@ public class GranuleCtrlTest {
67 62 assertTrue(g1.equals(GranuleTest.createGranule1()));
68 63 assertTrue(g2.equals(GranuleTest.createGranule2()));
69 64 }
  65 +
  66 + /**
  67 + * Test the method {@link GranuleCtrl#getGranules()} by comparing the granules with voTableData.
  68 + */
  69 + @Test
  70 + public void getGranulesTest() {
  71 + List<Granule> granules = null;
  72 + try {
  73 + granules = granuleCtrl.getGranules();
  74 + } catch (CanNotParseDataException e) {
  75 + fail("Can not parse granule: " + e.getMessage());
  76 + }
  77 + assertNotNull(granules);
  78 + assertTrue(granules.get(0).equals(GranuleTest.createGranule1()));
  79 + assertTrue(granules.get(1).equals(GranuleTest.createGranule2()));
  80 + }
70 81 }
... ...
src/test/java/eu/omp/irap/vespa/epntapclient/granule/GranuleTest.java
... ... @@ -27,6 +27,8 @@ import java.util.logging.Logger;
27 27  
28 28 import org.junit.Test;
29 29  
  30 +import eu.omp.irap.vespa.votable.votabledata.VoTableDataTest;
  31 +
30 32 /**
31 33 * @author N. Jourdane
32 34 */
... ... @@ -36,6 +38,12 @@ public class GranuleTest {
36 38 private static final Logger LOGGER = Logger.getLogger(GranuleTest.class.getName());
37 39  
38 40  
  41 + /**
  42 + * Create a granule for tests purposes. It is planetary data for Uranus, got from an actual ADQL
  43 + * query, exactly the same content that {@link VoTableDataTest#createDataArray1()}
  44 + *
  45 + * @return The granule.
  46 + */
39 47 public static Granule createGranule1() {
40 48 Date testDate = null;
41 49 try {
... ... @@ -91,6 +99,12 @@ public class GranuleTest {
91 99 return completeGranule;
92 100 }
93 101  
  102 + /**
  103 + * Create a granule for tests purposes. It is planetary data for Neptune, got from an actual
  104 + * query, exactly the same content that {@link VoTableDataTest#createDataArray2()}
  105 + *
  106 + * @return The granule.
  107 + */
94 108 public static Granule createGranule2() {
95 109 Date testDate = null;
96 110 try {
... ... @@ -146,18 +160,29 @@ public class GranuleTest {
146 160 return completeGranule;
147 161 }
148 162  
  163 + /**
  164 + * Create an incomplete granule without many mandatory parameters, which is forbidden.
  165 + *
  166 + * @return the granule.
  167 + */
149 168 public static Granule createIncompleteGranule() {
150 169 Granule incompleteGranule = new Granule("Mercury");
151 170 incompleteGranule.setGranuleGid("Planet");
152 171 return incompleteGranule;
153 172 }
154 173  
  174 + /**
  175 + * Test if the incomplete granule appears like not valid.
  176 + */
155 177 @SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
156 178 @Test
157 179 public void isNotValidTest() {
158 180 assertFalse("The incomplete granule is valid.", createIncompleteGranule().isValid());
159 181 }
160 182  
  183 + /**
  184 + * Test if a complete granule appears like valid.
  185 + */
161 186 @SuppressWarnings("static-method") // Otherwise JUnit doesn't work.
162 187 @Test
163 188 public void isValidTest() {
... ...