Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java 3.58 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/>.
 */

1375d734   Nathanael Jourdane   Create package ep...
17
package eu.omp.irap.vespa.epntapclient.epntap;
1353e182   Nathanael Jourdane   Add minimal eleme...
18

285505be   Nathanael Jourdane   Remove complex co...
19
import java.util.List;
5d3c344e   Nathanael Jourdane   Use Java logging ...
20
import java.util.logging.Logger;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
21

1375d734   Nathanael Jourdane   Create package ep...
22
23
24
25
import eu.omp.irap.vespa.epntapclient.epntap.request.RequestCtrl;
import eu.omp.irap.vespa.epntapclient.epntap.service.Queries;
import eu.omp.irap.vespa.epntapclient.epntap.service.ServiceCore;
import eu.omp.irap.vespa.epntapclient.epntap.service.ServicesList;
e2264856   Nathanael Jourdane   Delete votable pa...
26
import eu.omp.irap.vespa.votable.Consts;
285505be   Nathanael Jourdane   Remove complex co...
27
import eu.omp.irap.vespa.votable.utils.StringJoiner;
1375d734   Nathanael Jourdane   Create package ep...
28
29
import eu.omp.irap.vespa.votable.votable.VOTableCtrl;
import eu.omp.irap.vespa.votable.votable.VOTableException;
1353e182   Nathanael Jourdane   Add minimal eleme...
30
31

/**
a227a22d   Nathanael Jourdane   Add comments.
32
 * The main controller which manage views and controllers.
1e543ea0   Nathanael Jourdane   Code clean-up
33
 *
1353e182   Nathanael Jourdane   Add minimal eleme...
34
35
 * @author N. Jourdane
 */
285505be   Nathanael Jourdane   Remove complex co...
36
public abstract class EpnTapController {
aa2a59ba   Nathanael Jourdane   [coding style] 2 ...
37

5d3c344e   Nathanael Jourdane   Use Java logging ...
38
	/** The logger for the class EpnTapController. */
fd93317f   Nathanael Jourdane   Solve Sonar/Eclip...
39
	private static final Logger LOGGER = Logger.getLogger(EpnTapController.class.getName());
1353e182   Nathanael Jourdane   Add minimal eleme...
40

285505be   Nathanael Jourdane   Remove complex co...
41
42
43
44
	/** The request controller, to manage requests. */
	private RequestCtrl requestCtrl;

	/** The controller of the VOTable displaying the result. */
1375d734   Nathanael Jourdane   Create package ep...
45
	private VOTableCtrl resultsCtrl;
285505be   Nathanael Jourdane   Remove complex co...
46
47

	/** The controller of the VOTable displaying the list of services. */
1375d734   Nathanael Jourdane   Create package ep...
48
	private VOTableCtrl servicesCtrl;
285505be   Nathanael Jourdane   Remove complex co...
49

45fb4583   Nathanael Jourdane   Sort methods and ...
50
51
52
53
54
55
	/**
	 * The path of the VOTable to parse. Will be affected to a temporary folder if not assigned
	 * through the controller.
	 */
	private String voTablePath;

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

5af53be7   Nathanael Jourdane   Make the applicat...
57
	/**
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
58
59
60
61
62
63
64
65
66
67
68
	 * Get the services from the XML path or the targetURL / query.
	 *
	 * @throws VOTableException Can not read the services.
	 */
	public void acquireServices() throws VOTableException {
		String query = String.format(Queries.SELECT_ALL_TAP_SERVICES_WHERE_CORE,
				ServiceCore.EPNCORE);
		getServicesCtrl().acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query, true);
	}

	/**
285505be   Nathanael Jourdane   Remove complex co...
69
	 * @return The request controller.
eda63a5c   Nathanael Jourdane   Add Javadoc.
70
	 */
285505be   Nathanael Jourdane   Remove complex co...
71
72
73
74
75
76
77
	public RequestCtrl getRequestCtrl() {
		return requestCtrl;
	}

	/**
	 * @return The controller of the VOTable which displays the result of the query.
	 */
1375d734   Nathanael Jourdane   Create package ep...
78
	public VOTableCtrl getResultsCtrl() {
285505be   Nathanael Jourdane   Remove complex co...
79
80
81
82
83
84
		return resultsCtrl;
	}

	/**
	 * @return The controller of the VOTable which displays the list of services.
	 */
1375d734   Nathanael Jourdane   Create package ep...
85
	public VOTableCtrl getServicesCtrl() {
285505be   Nathanael Jourdane   Remove complex co...
86
		return servicesCtrl;
1353e182   Nathanael Jourdane   Add minimal eleme...
87
88
	}

30e4599b   Nathanael Jourdane   Add Javadoc
89
90
91
	/**
	 * @return the path of the XML VOTable file.
	 */
5672c106   Nathanael Jourdane   Fix Sonar issues.
92
93
94
95
	public String getVOTablePath() {
		return voTablePath;
	}

1353e182   Nathanael Jourdane   Add minimal eleme...
96
	/**
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
97
	 * Send all the queries.
02448921   Nathanael Jourdane   Improve service p...
98
	 *
987f00a7   Nathanael Jourdane   Use ServicesList ...
99
	 * @param services The services to send the queries.
02448921   Nathanael Jourdane   Improve service p...
100
	 */
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
101
	public void sendQueries(ServicesList services) {
987f00a7   Nathanael Jourdane   Use ServicesList ...
102
		List<String> servicesUrls = services.getTargetUrls();
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
103
		LOGGER.info("Sending query(ies) at " + StringJoiner.join(servicesUrls));
987f00a7   Nathanael Jourdane   Use ServicesList ...
104
105
		for (int i = 0; i < servicesUrls.size(); i++) {
			String query = getRequestCtrl().getQuery(services.getTableNames().get(i));
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
106
			getResultsCtrl().acquireVOTable(servicesUrls.get(i), query, i != 0);
285505be   Nathanael Jourdane   Remove complex co...
107
108
		}

18446806   Jean-Michel Glorian   add custom EPN TA...
109
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
110
}