Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/lib/EpnTapController.java 3.34 KB
1353e182   Nathanael Jourdane   Add minimal eleme...
1
2
3
4
5
/*
 * 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.
1e543ea0   Nathanael Jourdane   Code clean-up
6
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
7
8
9
10
11
12
13
14
15
16
 * 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/>.
 */

bfe5db3a   Nathanael Jourdane   rename epnTapLib ...
17
package eu.omp.irap.vespa.epntapclient.lib;
1353e182   Nathanael Jourdane   Add minimal eleme...
18

5af53be7   Nathanael Jourdane   Make the applicat...
19
20
import java.util.HashMap;
import java.util.Map;
5d3c344e   Nathanael Jourdane   Use Java logging ...
21
import java.util.logging.Logger;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
22

1353e182   Nathanael Jourdane   Add minimal eleme...
23
import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableController;
0f1bce56   Nathanael Jourdane   Use a listerner i...
24
25
import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantDisplayVOTableException;
import eu.omp.irap.vespa.epntapclient.votable.controller.VOTableException.CantSendQueryException;
bfe5db3a   Nathanael Jourdane   rename epnTapLib ...
26
import eu.omp.irap.vespa.epntapclient.votable.utils.Consts;
1353e182   Nathanael Jourdane   Add minimal eleme...
27
28

/**
a227a22d   Nathanael Jourdane   Add comments.
29
 * The main controller which manage views and controllers.
1e543ea0   Nathanael Jourdane   Code clean-up
30
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
31
32
 * @author N. Jourdane
 */
6dd0d332   Nathanael Jourdane   The controller do...
33
public class EpnTapController {
aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
34

5d3c344e   Nathanael Jourdane   Use Java logging ...
35
	/** The logger for the class EpnTapController. */
6dd0d332   Nathanael Jourdane   The controller do...
36
	private static final Logger logger = Logger.getLogger(EpnTapController.class.getName());
1353e182   Nathanael Jourdane   Add minimal eleme...
37

4cc84b63   Nathanael Jourdane   Add the possibili...
38
	/** The controller of the VOTable displaying the list of services. */
6dd0d332   Nathanael Jourdane   The controller do...
39
	protected VOTableController servicesCtrl;
6415d908   Nathanael Jourdane   Get all tap servi...
40

6dd0d332   Nathanael Jourdane   The controller do...
41
42
	/** The controller of the VOTable displaying the list of services. */
	protected VOTableController resultsCtrl;
ccd40d6d   Nathanael Jourdane   Add download button
43

1353e182   Nathanael Jourdane   Add minimal eleme...
44
	/**
5af53be7   Nathanael Jourdane   Make the applicat...
45
46
	 * The parameters fields for the request.
	 */
6dd0d332   Nathanael Jourdane   The controller do...
47
	protected Map<String, Object> paramValues = new HashMap<>();
5af53be7   Nathanael Jourdane   Make the applicat...
48

aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
49

5af53be7   Nathanael Jourdane   Make the applicat...
50
	/**
a227a22d   Nathanael Jourdane   Add comments.
51
	 * Method constructor, which initialize servicesController, resultsController and mainView.
1353e182   Nathanael Jourdane   Add minimal eleme...
52
53
	 */
	public EpnTapController() {
bfe5db3a   Nathanael Jourdane   rename epnTapLib ...
54
		servicesCtrl = new VOTableController(Consts.DEFAULT_REGISTRY_URL, "ADQL",
8a39b260   Nathanael Jourdane   Get only EPN-core...
55
				Queries.GET_EPN_TAP_SERVICES);
6dd0d332   Nathanael Jourdane   The controller do...
56
57
58
59
60
61
62
63
64
		try {
			servicesCtrl.readTable();
		} catch (CantDisplayVOTableException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (CantSendQueryException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
1353e182   Nathanael Jourdane   Add minimal eleme...
65
66
	}

6dd0d332   Nathanael Jourdane   The controller do...
67
68
69
70
71
	public String sendQuery(String query, String tableServiceURL)
			throws CantDisplayVOTableException, CantSendQueryException {
		resultsCtrl = new VOTableController(tableServiceURL, "ADQL", query);
		resultsCtrl.readTable();
		return resultsCtrl.getVOTablePath();
1353e182   Nathanael Jourdane   Add minimal eleme...
72
73
74
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
75
	 * @return The controller of the VOTable which displays the result of the query.
1353e182   Nathanael Jourdane   Add minimal eleme...
76
77
	 */
	public VOTableController getResultsController() {
6dd0d332   Nathanael Jourdane   The controller do...
78
		return resultsCtrl;
1353e182   Nathanael Jourdane   Add minimal eleme...
79
80
81
	}

	/**
a227a22d   Nathanael Jourdane   Add comments.
82
	 * @return The controller of the VOTable which displays the list of services.
1353e182   Nathanael Jourdane   Add minimal eleme...
83
84
	 */
	public VOTableController getServicesController() {
6dd0d332   Nathanael Jourdane   The controller do...
85
		return servicesCtrl;
18446806   Jean-Michel Glorian   add custom EPN TA...
86
87
	}

6dd0d332   Nathanael Jourdane   The controller do...
88
	public void updateParameter(String paramName, Object paramValue) {
0f1bce56   Nathanael Jourdane   Use a listerner i...
89
		paramValues.put(paramName, paramValue);
0f1bce56   Nathanael Jourdane   Use a listerner i...
90
	}
5af53be7   Nathanael Jourdane   Make the applicat...
91

6dd0d332   Nathanael Jourdane   The controller do...
92
	public void removeParameter(String paramName) {
0f1bce56   Nathanael Jourdane   Use a listerner i...
93
		paramValues.remove(paramName);
6dd0d332   Nathanael Jourdane   The controller do...
94
95
96
97
	}

	public Map<String, Object> getParamValues() {
		return paramValues;
5af53be7   Nathanael Jourdane   Make the applicat...
98
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
99
}