Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java 3.81 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;

5d3c344e   Nathanael Jourdane   Use Java logging ...
19
import java.util.logging.Logger;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
20

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

/**
 * @author N. Jourdane
 */
public class EpnTapController {
5d3c344e   Nathanael Jourdane   Use Java logging ...
32
33
	/** The logger for the class EpnTapController. */
	Logger logger = Logger.getLogger(EpnTapController.class.getName());
7706bfa4   Nathanael Jourdane   Use log4j as logg...
34

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

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

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

6415d908   Nathanael Jourdane   Get all tap servi...
44
45
46
47
48
	/** The name of the table selected by the user on the table list panel. */
	String selectedTableName;

	/** The URL of the service corresponding to the selected table. */
	String selectedTableServiceURL;
1353e182   Nathanael Jourdane   Add minimal eleme...
49
50
51
52
53

	/**
	 * Method constructor
	 */
	public EpnTapController() {
6b021d84   Nathanael Jourdane   VOTable view can ...
54
		servicesController = new VOTableController(Const.DEFAULT_REGISTRY_URL, "ADQL",
8a39b260   Nathanael Jourdane   Get only EPN-core...
55
				Queries.GET_EPN_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
		VOTableView serviceView = servicesController.getView();
		VOTableView resultsView = resultsController.getView();
		view = new EpnTapMainView(this, serviceView, resultsView);
6415d908   Nathanael Jourdane   Get all tap servi...
62
		updateSelected(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

	/**
	 * @param row The row selected by the user on the Jtable.
	 */
6415d908   Nathanael Jourdane   Get all tap servi...
89
90
91
92
93
94
	public void updateSelected(int row) {
		String serviceURL = (String) view.getServicesView().getValueAt(5, row);
		String tableName = (String) view.getServicesView().getValueAt(2, row);
		if (!tableName.equals(selectedTableName)) {
			selectedTableServiceURL = serviceURL;
			selectedTableName = tableName;
0b616d80   Nathanael Jourdane   Updtate the query...
95
			view.getRequestView().updateQueryArea();
6415d908   Nathanael Jourdane   Get all tap servi...
96
97
			logger.info("Selected table: " + selectedTableName + " - service: "
					+ selectedTableServiceURL);
4cc84b63   Nathanael Jourdane   Add the possibili...
98
99
100
		}
	}

6415d908   Nathanael Jourdane   Get all tap servi...
101
102
103
104
	public String getSelectedTable() {
		return selectedTableName;
	}

4cc84b63   Nathanael Jourdane   Add the possibili...
105
106
	/**
	 * @param query The query to send to the selected service.
4dd68979   Nathanael Jourdane   Improve Exception...
107
	 * @throws VOTableException Can not fill the Table
4cc84b63   Nathanael Jourdane   Add the possibili...
108
	 */
4dd68979   Nathanael Jourdane   Improve Exception...
109
	public void sendQuery(String query) throws VOTableException {
6415d908   Nathanael Jourdane   Get all tap servi...
110
111
		logger.info("Sending query: " + query + " on " + selectedTableServiceURL);
		resultsController.fillTable(selectedTableServiceURL, "ADQL", query);
4cc84b63   Nathanael Jourdane   Add the possibili...
112
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
113
}