Commit fe9b171e17c631d34c966ababc77c3df7c4df656
1 parent
84dce244
Exists in
master
Remove old EpnTap controller files, the VOTable package should be used instead.
Showing
2 changed files
with
0 additions
and
229 deletions
Show diff stats
src/main/java/eu/omp/irap/vespa/epntapclient/controller/EpnTapController.java deleted
... | ... | @@ -1,58 +0,0 @@ |
1 | -/** | |
2 | - * This file is a part of EpnTAPClient. | |
3 | - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. | |
4 | - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 | |
5 | - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. | |
6 | - * | |
7 | - * This program is free software: you can | |
8 | - * redistribute it and/or modify it under the terms of the GNU General Public License as published | |
9 | - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later | |
10 | - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
11 | - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
12 | - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of | |
13 | - * the GNU General Public License along with this program. If not, see | |
14 | - * <http://www.gnu.org/licenses/>. | |
15 | - */ | |
16 | - | |
17 | -package eu.omp.irap.vespa.epntapclient.controller; | |
18 | - | |
19 | -import eu.omp.irap.vespa.epntapclient.model.EpnTapModel; | |
20 | -import eu.omp.irap.vespa.epntapclient.view.EpnTapView; | |
21 | - | |
22 | -/** | |
23 | - * The main class of the Controller of the application. | |
24 | - * | |
25 | - * @author N. Jourdane | |
26 | - */ | |
27 | -public class EpnTapController { | |
28 | - | |
29 | - /** The view */ | |
30 | - private EpnTapView view; | |
31 | - | |
32 | - /** The model */ | |
33 | - private EpnTapModel model; | |
34 | - | |
35 | - /** | |
36 | - * Method constructor | |
37 | - */ | |
38 | - public EpnTapController() { | |
39 | - model = new EpnTapModel(); | |
40 | - view = new EpnTapView(this); | |
41 | - view.fillTable(EpnTapModel.getEPNTAPServices().getServices()); | |
42 | - } | |
43 | - | |
44 | - /** | |
45 | - * @return The model of the application. | |
46 | - */ | |
47 | - public EpnTapModel getModel() { | |
48 | - return model; | |
49 | - } | |
50 | - | |
51 | - /** | |
52 | - * @return The model of the application. | |
53 | - */ | |
54 | - public EpnTapView getView() { | |
55 | - return view; | |
56 | - } | |
57 | - | |
58 | -} |
src/main/java/eu/omp/irap/vespa/epntapclient/controller/TAPServices.java deleted
... | ... | @@ -1,171 +0,0 @@ |
1 | -/** | |
2 | - * This file is a part of EpnTAPClient. | |
3 | - * This program aims to provide EPN-TAP support for software clients, like CASSIS spectrum analyzer. | |
4 | - * See draft specifications: https://voparis-confluence.obspm.fr/pages/viewpage.action?pageId=559861 | |
5 | - * Copyright (C) 2016 Institut de Recherche en Astrophysique et Planétologie. | |
6 | - * | |
7 | - * This program is free software: you can | |
8 | - * redistribute it and/or modify it under the terms of the GNU General Public License as published | |
9 | - * by the Free Software Foundation, either version 3 of the License, or (at your option) any later | |
10 | - * version. This program is distributed in the hope that it will be useful, but WITHOUT ANY | |
11 | - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR | |
12 | - * PURPOSE. See the GNU General Public License for more details. You should have received a copy of | |
13 | - * the GNU General Public License along with this program. If not, see | |
14 | - * <http://www.gnu.org/licenses/>. | |
15 | - */ | |
16 | - | |
17 | -package eu.omp.irap.vespa.epntapclient.controller; | |
18 | - | |
19 | -import java.io.File; | |
20 | -import java.io.FileNotFoundException; | |
21 | -import java.io.PrintWriter; | |
22 | -import java.io.UnsupportedEncodingException; | |
23 | -import java.nio.ByteBuffer; | |
24 | -import java.util.ArrayList; | |
25 | -import java.util.Base64; | |
26 | -import java.util.List; | |
27 | -import java.util.logging.Level; | |
28 | - | |
29 | -import javax.xml.parsers.DocumentBuilder; | |
30 | -import javax.xml.parsers.DocumentBuilderFactory; | |
31 | - | |
32 | -import org.w3c.dom.Document; | |
33 | -import org.w3c.dom.NodeList; | |
34 | - | |
35 | -import com.google.gson.Gson; | |
36 | - | |
37 | -import eu.omp.irap.vespa.epntapclient.model.TAPField; | |
38 | -import eu.omp.irap.vespa.epntapclient.model.TAPService; | |
39 | -import eu.omp.irap.vespa.epntapclient.model.VOTableTags; | |
40 | -import eu.omp.irap.vespa.epntapclient.utils.Const; | |
41 | -import eu.omp.irap.vespa.epntapclient.utils.Err; | |
42 | -import eu.omp.irap.vespa.epntapclient.utils.Log; | |
43 | - | |
44 | -/** | |
45 | - * This class provide methods to get and use TAP services. | |
46 | - * | |
47 | - * @author N. Jourdane | |
48 | - **/ | |
49 | -public class TAPServices { | |
50 | - /** The list of all fields (ie. columns VOTABLE). */ | |
51 | - private List<TAPField> fields; | |
52 | - | |
53 | - /** The list of all services returned by the query. */ | |
54 | - private List<TAPService> tapServices; | |
55 | - | |
56 | - /** The byte array representation of the stream data stored in the XML document. */ | |
57 | - private byte[] byteArray; | |
58 | - | |
59 | - /** | |
60 | - * Method constructor | |
61 | - * | |
62 | - * @param xmlFileName The name of XML file to parse in order to get the list of services. | |
63 | - */ | |
64 | - public TAPServices(String xmlFileName) { | |
65 | - | |
66 | - // Get document | |
67 | - Document doc = null; | |
68 | - try { | |
69 | - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); | |
70 | - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); | |
71 | - doc = dBuilder.parse(new File(xmlFileName)); | |
72 | - doc.getDocumentElement().normalize(); | |
73 | - } catch (FileNotFoundException e1) { | |
74 | - Log.LOGGER.log(Level.SEVERE, Err.NOT_FOUND + xmlFileName, e1); | |
75 | - return; | |
76 | - } catch (Exception e2) { | |
77 | - Log.LOGGER.log(Level.SEVERE, Err.BAD_XML_DOC + xmlFileName, e2); | |
78 | - return; | |
79 | - } | |
80 | - | |
81 | - // Get fields | |
82 | - NodeList nodeList = doc.getElementsByTagName(VOTableTags.TAG_NAME_FIELD); | |
83 | - fields = new ArrayList<>(); | |
84 | - for (int i = 0; i < nodeList.getLength(); i++) { | |
85 | - fields.add(new TAPField(nodeList.item(i))); | |
86 | - } | |
87 | - | |
88 | - // Get byte array | |
89 | - String stream = doc.getElementsByTagName(VOTableTags.TAG_NAME_STREAM).item(0) | |
90 | - .getTextContent() | |
91 | - .replaceAll("(\\r|\\n)", ""); //$NON-NLS-1$ //$NON-NLS-2$ | |
92 | - byteArray = Base64.getDecoder().decode(stream); | |
93 | - } | |
94 | - | |
95 | - /** | |
96 | - * Fill the services list from the byte array. | |
97 | - */ | |
98 | - public void fillServices() { | |
99 | - List<TAPService> services = new ArrayList<>(); | |
100 | - TAPService service = new TAPService(); | |
101 | - | |
102 | - for (int cursor = 0, nValue = 0; cursor < byteArray.length; nValue++) { | |
103 | - TAPField column = fields.get(nValue % fields.size()); | |
104 | - Object value = null; | |
105 | - | |
106 | - if (column.getDatatype().equals(VOTableTags.SHORT_TYPE)) { | |
107 | - byte[] shortArray = { byteArray[cursor + 0], byteArray[cursor + 1] }; | |
108 | - value = Integer.valueOf(shortArray[0] * (2 ^ 8) + shortArray[1]); | |
109 | - cursor += shortArray.length; | |
110 | - } else { | |
111 | - byte[] head = { byteArray[cursor + 0], byteArray[cursor + 1], byteArray[cursor + 2], | |
112 | - byteArray[cursor + 3] }; | |
113 | - int charSize = column.getDatatype().equals(VOTableTags.UNICODE_CHAR_TYPE) ? 2 : 1; | |
114 | - int stringLength = ByteBuffer.wrap(head).getInt() * charSize; | |
115 | - cursor += head.length; | |
116 | - | |
117 | - value = new String(); | |
118 | - for (int j = 0; j < stringLength | |
119 | - && cursor < byteArray.length; cursor += charSize, j += charSize) { | |
120 | - int c = (0xFF) & (charSize == 2 | |
121 | - ? (int) (byteArray[cursor] * (2 ^ 8) + byteArray[cursor + 1]) | |
122 | - : byteArray[cursor]); | |
123 | - value = value + Character.toString((char) c); | |
124 | - } | |
125 | - } | |
126 | - | |
127 | - if (nValue % fields.size() == 0) { | |
128 | - service = new TAPService(); | |
129 | - } else if (nValue % fields.size() == fields.size() - 1) { | |
130 | - services.add(service); | |
131 | - } else { | |
132 | - service.setProperty(column.getName(), value); | |
133 | - } | |
134 | - } | |
135 | - | |
136 | - tapServices = services; | |
137 | - } | |
138 | - | |
139 | - /** | |
140 | - * @return The list of services. | |
141 | - */ | |
142 | - public List<TAPService> getServices() { | |
143 | - return tapServices; | |
144 | - } | |
145 | - | |
146 | - /** | |
147 | - * @return The list of VOTable columns. | |
148 | - */ | |
149 | - public List<TAPField> getFileds() { | |
150 | - return fields; | |
151 | - } | |
152 | - | |
153 | - /** | |
154 | - * Print the content of all the services in the specified file in JSON format. | |
155 | - * | |
156 | - * @param fileName The name of the file where the services lists is printed. | |
157 | - */ | |
158 | - public void printToFile(String fileName) { | |
159 | - PrintWriter writer; | |
160 | - String json = new Gson().toJson(tapServices); | |
161 | - try { | |
162 | - writer = new PrintWriter(fileName, Const.CHARACTER_SET); | |
163 | - writer.println(json); | |
164 | - writer.close(); | |
165 | - } catch (FileNotFoundException e1) { | |
166 | - Log.LOGGER.log(Level.SEVERE, Err.NOT_FOUND, e1); | |
167 | - } catch (UnsupportedEncodingException e2) { | |
168 | - Log.LOGGER.log(Level.SEVERE, Err.WRONG_ENCODING, e2); | |
169 | - } | |
170 | - } | |
171 | -} |