Blame view

src/main/java/eu/omp/irap/vespa/epntapclient/epntap/EpnTapController.java 3.29 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;
7706bfa4   Nathanael Jourdane   Use log4j as logg...
20

1375d734   Nathanael Jourdane   Create package ep...
21
22
23
24
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...
25
import eu.omp.irap.vespa.votable.Consts;
1375d734   Nathanael Jourdane   Create package ep...
26
27
import eu.omp.irap.vespa.votable.votable.VOTableCtrl;
import eu.omp.irap.vespa.votable.votable.VOTableException;
1353e182   Nathanael Jourdane   Add minimal eleme...
28
29

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

285505be   Nathanael Jourdane   Remove complex co...
36
37
38
39
	/** The request controller, to manage requests. */
	private RequestCtrl requestCtrl;

	/** The controller of the VOTable displaying the result. */
56349bde   Nathanael Jourdane   Add ResultsPanelC...
40
	private List<VOTableCtrl> resultsCtrls;
285505be   Nathanael Jourdane   Remove complex co...
41
42

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

45fb4583   Nathanael Jourdane   Sort methods and ...
45
46
47
48
49
50
	/**
	 * 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 ...
51

5af53be7   Nathanael Jourdane   Make the applicat...
52
	/**
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
53
54
55
56
57
58
59
	 * 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);
56349bde   Nathanael Jourdane   Add ResultsPanelC...
60
		getServicesCtrl().acquireVOTable(Consts.DEFAULT_REGISTRY_URL, query);
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
61
62
63
	}

	/**
285505be   Nathanael Jourdane   Remove complex co...
64
	 * @return The request controller.
eda63a5c   Nathanael Jourdane   Add Javadoc.
65
	 */
285505be   Nathanael Jourdane   Remove complex co...
66
67
68
69
70
71
72
	public RequestCtrl getRequestCtrl() {
		return requestCtrl;
	}

	/**
	 * @return The controller of the VOTable which displays the result of the query.
	 */
56349bde   Nathanael Jourdane   Add ResultsPanelC...
73
74
	public List<VOTableCtrl> getResultsCtrls() {
		return resultsCtrls;
285505be   Nathanael Jourdane   Remove complex co...
75
76
77
78
79
	}

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

30e4599b   Nathanael Jourdane   Add Javadoc
84
85
86
	/**
	 * @return the path of the XML VOTable file.
	 */
5672c106   Nathanael Jourdane   Fix Sonar issues.
87
88
89
90
	public String getVOTablePath() {
		return voTablePath;
	}

1353e182   Nathanael Jourdane   Add minimal eleme...
91
	/**
56349bde   Nathanael Jourdane   Add ResultsPanelC...
92
	 * Send the query to all services.
02448921   Nathanael Jourdane   Improve service p...
93
	 *
987f00a7   Nathanael Jourdane   Use ServicesList ...
94
	 * @param services The services to send the queries.
02448921   Nathanael Jourdane   Improve service p...
95
	 */
84b3dbfc   Nathanael Jourdane   Use SwingWorkers ...
96
	public void sendQueries(ServicesList services) {
56349bde   Nathanael Jourdane   Add ResultsPanelC...
97
98
99
100
		for (int i = 0; i < services.getNbServices(); i++) {
			VOTableCtrl resultCtrl = new VOTableCtrl();
			String query = requestCtrl.getQuery(services.getTableNames().get(i));
			resultCtrl.acquireVOTable(services.getTargetUrls().get(i), query);
285505be   Nathanael Jourdane   Remove complex co...
101
		}
18446806   Jean-Michel Glorian   add custom EPN TA...
102
	}
1353e182   Nathanael Jourdane   Add minimal eleme...
103
}