Commit 794192b584aa72acb3dd0790e2ddbbb51e09edaf

Authored by Nathanael Jourdane
1 parent 58a466aa
Exists in master

Delete EpnTapGet, use RequestCtrl instead.

src/main/java/eu/omp/irap/vespa/epntapclient/EpnTapGet.java deleted
... ... @@ -1,59 +0,0 @@
1   -/*
2   - * This file is a part of EpnTAPClient.
3   - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
4   - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
5   - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
6   - *
7   - * This program is free software: you can
8   - * redistribute it and/or modify it under the terms of the GNU General Public License as published
9   - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
10   - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
11   - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
13   - * the GNU General Public License along with this program. If not, see
14   - * <http://www.gnu.org/licenses/>.
15   - */
16   -
17   -package eu.omp.irap.vespa.epntapclient;
18   -
19   -import java.util.HashMap;
20   -import java.util.Map;
21   -
22   -import com.google.gson.JsonArray;
23   -import com.google.gson.JsonObject;
24   -
25   -import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
26   -import eu.omp.irap.vespa.votable.utils.Network;
27   -
28   -/**
29   - * @author N. Jourdane
30   - */
31   -public class EpnTapGet {
32   -
33   - /** The URL of the resolver used for the `target name` field. */
34   - private static final String RESOLVER_URL = "http://voparis-registry.obspm.fr/ssodnet/1/autocomplete";
35   -
36   -
37   - /**
38   - * The method used to get target names propositions by asking to the resolver.
39   - *
40   - * @param begining The beginning of the target_name.
41   - * @return An array of Strings corresponding to the target names got.
42   - * @throws CantSendQueryException Can not send the query to get the target names.
43   - */
44   - public static String[] getTargetNames(String begining) throws CantSendQueryException {
45   - Map<String, String> params = new HashMap<>();
46   - params.put("q", "\"" + begining + "\"");
47   -
48   - String query = Network.buildQuery(RESOLVER_URL, params);
49   - JsonObject root = Network.readJson(query);
50   - int count = Integer.parseInt(root.get("count").toString());
51   - String[] targetNames = new String[count];
52   - JsonArray hits = root.getAsJsonArray("hits");
53   - for (int i = 0; i < count; i++) {
54   - JsonObject elmt = hits.get(i).getAsJsonObject();
55   - targetNames[i] = elmt.get("name").toString().replace("\"", "");
56   - }
57   - return targetNames;
58   - }
59   -}
src/main/java/eu/omp/irap/vespa/epntapclient/gui/requestpanel/paramfield/TargetNameField.java
... ... @@ -24,7 +24,7 @@ import javax.swing.JComboBox;
24 24 import javax.swing.JTextField;
25 25 import javax.swing.SwingUtilities;
26 26  
27   -import eu.omp.irap.vespa.epntapclient.EpnTapGet;
  27 +import eu.omp.irap.vespa.epntapclient.RequestCtrl;
28 28 import eu.omp.irap.vespa.epntapclient.gui.requestpanel.RequestPanelListener;
29 29 import eu.omp.irap.vespa.votable.utils.CantSendQueryException;
30 30  
... ... @@ -119,7 +119,7 @@ public class TargetNameField extends ParamField implements TextFieldListener {
119 119 lastContent = content;
120 120 comboBox.removeAllItems();
121 121 try {
122   - for (String s : EpnTapGet.getTargetNames(content)) {
  122 + for (String s : RequestCtrl.getTargetNames(content)) {
123 123 comboBox.addItem(s);
124 124 }
125 125 } catch (CantSendQueryException e) {
... ...