Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java 3.53 KB
1353e182   Nathanael Jourdane   Add minimal eleme...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * This file is a part of EpnTAPClient.
 * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer.
 * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861
 * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie.
 * 
 * This program is free software: you can
 * redistribute it and/or modify it under the terms of the GNU General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or (at your option) any later
 * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
 * PURPOSE. See the GNU General Public License for more details. You should have received a copy of
 * the GNU General Public License along with this program. If not, see
 * <http://www.gnu.org/licenses/>.
 */

package eu.omp.irap.vespa.epntapclient.controller;

5799764b   Nathanael Jourdane   Use Log4j2 instea...
19
20
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
21

6b021d84   Nathanael Jourdane   VOTable view can ...
22
import eu.omp.irap.vespa.epntapclient.utils.Const;
6b021d84   Nathanael Jourdane   VOTable view can ...
23
import eu.omp.irap.vespa.epntapclient.utils.Queries;
1353e182   Nathanael Jourdane   Add minimal eleme...
24
25
import eu.omp.irap.vespa.epntapclient.view.EpnTapMainView;
import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController;
4dd68979   Nathanael Jourdane   Improve Exception...
26
import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException;
6b021d84   Nathanael Jourdane   VOTable view can ...
27
import eu.omp.irap.vespa.epntapclient.votable.view.VOTableView;
1353e182   Nathanael Jourdane   Add minimal eleme...
28
29
30
31
32

/**
 * @author N. Jourdane
 */
public class EpnTapController {
7706bfa4   Nathanael Jourdane   Use log4j as logg...
33
	/** The logger for this class. */
5799764b   Nathanael Jourdane   Use Log4j2 instea...
34
	private static final Logger logger = LogManager.getLogger(EpnTapController.class);
7706bfa4   Nathanael Jourdane   Use log4j as logg...
35

1353e182   Nathanael Jourdane   Add minimal eleme...
36
37
38
	/** The view of EPN-TAP application. */
	EpnTapMainView view;

4cc84b63   Nathanael Jourdane   Add the possibili...
39
40
41
	/** The controller of the VOTable displaying the list of services. */
	VOTableController servicesController;

1353e182   Nathanael Jourdane   Add minimal eleme...
42
43
44
	/** The controller of the VOTable displaying the query results. */
	VOTableController resultsController;

4cc84b63   Nathanael Jourdane   Add the possibili...
45
46
	/** The URL of the service selected by the user on the services list panel. */
	String selectedServiceURL;
1353e182   Nathanael Jourdane   Add minimal eleme...
47
48
49
50
51

	/**
	 * Method constructor
	 */
	public EpnTapController() {
a7aff3e3   Nathanael Jourdane   Fix Sonar issues
52

4cc84b63   Nathanael Jourdane   Add the possibili...
53
		// TODO: Get only *EPN* TAP services
6b021d84   Nathanael Jourdane   VOTable view can ...
54
55
		servicesController = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL",
				Queries.GET_TAP_SERVICES);
43c14591   Nathanael Jourdane   View: Add methods...
56

4cc84b63   Nathanael Jourdane   Add the possibili...
57
		resultsController = new VOTableController();
43c14591   Nathanael Jourdane   View: Add methods...
58

4cc84b63   Nathanael Jourdane   Add the possibili...
59
60
61
62
		VOTableView serviceView = servicesController.getView();
		VOTableView resultsView = resultsController.getView();
		view = new EpnTapMainView(this, serviceView, resultsView);
		setSelectedService(0);
1353e182   Nathanael Jourdane   Add minimal eleme...
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
	}

	/**
	 * @return the EPN-TAP view.
	 */
	public EpnTapMainView getView() {
		return view;
	}

	/**
	 * @return The controller of the VOTable displaying the query results.
	 */
	public VOTableController getResultsController() {
		return resultsController;
	}

	/**
	 * @return The controller of the VOTable displaying the list of services.
	 */
	public VOTableController getServicesController() {
		return servicesController;
	}
4cc84b63   Nathanael Jourdane   Add the possibili...
85
86
87
88
89
90
91
92

	/**
	 * @param row The row selected by the user on the Jtable.
	 */
	public void setSelectedService(int row) {
		String serviceURL = (String) view.getServices().getValueAt(1, row);
		if (!serviceURL.equals(selectedServiceURL)) {
			selectedServiceURL = serviceURL;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
93
			logger.info("Selected service URL: " + selectedServiceURL);
4cc84b63   Nathanael Jourdane   Add the possibili...
94
95
96
97
98
		}
	}

	/**
	 * @param query The query to send to the selected service.
4dd68979   Nathanael Jourdane   Improve Exception...
99
	 * @throws VOTableException Can not fill the Table
4cc84b63   Nathanael Jourdane   Add the possibili...
100
	 */
4dd68979   Nathanael Jourdane   Improve Exception...
101
	public void sendQuery(String query) throws VOTableException {
7706bfa4   Nathanael Jourdane   Use log4j as logg...
102
		logger.info("Sending query: " + query + " on " + selectedServiceURL);
4cc84b63   Nathanael Jourdane   Add the possibili...
103
104
		resultsController.fillTable(selectedServiceURL, "ADQL", query);
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
105
}