1 |
779bac69
|
Marc NICOLAS
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
|
19 |
|
|
package fr.ias.sitools.vo.ssa;
|
20 |
|
|
|
21 |
|
|
import fr.cnes.sitools.astro.representation.DatabaseRequestModel;
|
22 |
|
|
import fr.cnes.sitools.common.SitoolsSettings;
|
23 |
|
|
import fr.cnes.sitools.common.application.ContextAttributes;
|
24 |
|
|
import fr.cnes.sitools.common.exception.SitoolsException;
|
25 |
|
|
import fr.cnes.sitools.dataset.DataSetApplication;
|
26 |
|
|
import fr.cnes.sitools.dataset.converter.business.ConverterChained;
|
27 |
|
|
import fr.cnes.sitools.dataset.database.DatabaseRequest;
|
28 |
|
|
import fr.cnes.sitools.dataset.database.DatabaseRequestFactory;
|
29 |
|
|
import fr.cnes.sitools.dataset.database.DatabaseRequestParameters;
|
30 |
|
|
import fr.cnes.sitools.dataset.database.common.DataSetExplorerUtil;
|
31 |
|
|
import fr.cnes.sitools.dataset.dto.ColumnConceptMappingDTO;
|
32 |
|
|
import fr.cnes.sitools.dataset.dto.DictionaryMappingDTO;
|
33 |
|
|
import fr.cnes.sitools.dataset.model.Predicat;
|
34 |
|
|
import fr.cnes.sitools.dictionary.model.Concept;
|
35 |
|
|
import fr.cnes.sitools.plugins.resources.model.ResourceModel;
|
36 |
|
|
import fr.cnes.sitools.util.Util;
|
37 |
|
|
import freemarker.template.TemplateSequenceModel;
|
38 |
|
|
import java.math.BigInteger;
|
39 |
|
|
import java.util.ArrayList;
|
40 |
|
|
import java.util.Arrays;
|
41 |
|
|
import java.util.Collections;
|
42 |
|
|
import java.util.HashMap;
|
43 |
|
|
import java.util.List;
|
44 |
|
|
import java.util.Map;
|
45 |
|
|
import java.util.logging.Level;
|
46 |
|
|
import java.util.logging.Logger;
|
47 |
|
|
import net.ivoa.xml.votable.v1.AnyTEXT;
|
48 |
|
|
import net.ivoa.xml.votable.v1.DataType;
|
49 |
|
|
import net.ivoa.xml.votable.v1.Field;
|
50 |
|
|
import net.ivoa.xml.votable.v1.Info;
|
51 |
|
|
import net.ivoa.xml.votable.v1.Param;
|
52 |
|
|
|
53 |
|
|
|
54 |
|
|
|
55 |
|
|
|
56 |
|
|
|
57 |
|
|
|
58 |
|
|
|
59 |
|
|
|
60 |
|
|
public class SimpleSpectralAccessResponse implements SimpleSpectralAccessDataModelInterface {
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
private static final Logger LOG = Logger.getLogger(SimpleSpectralAccessResponse.class.getName());
|
66 |
|
|
|
67 |
|
|
|
68 |
|
|
|
69 |
|
|
|
70 |
|
|
private final transient Map dataModel = new HashMap();
|
71 |
|
|
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
|
75 |
|
|
private SitoolsSettings sitoolsSettings = null;
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
private final double ra;
|
80 |
|
|
|
81 |
|
|
|
82 |
|
|
|
83 |
|
|
private final double dec;
|
84 |
|
|
|
85 |
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
private final String[] time;
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
private final double[] band;
|
93 |
|
|
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
|
|
|
100 |
|
|
public SimpleSpectralAccessResponse(final SimpleSpectralAccessInputParameters inputParameters, final ResourceModel model) {
|
101 |
|
|
this.sitoolsSettings = (SitoolsSettings) inputParameters.getContext().getAttributes().get(ContextAttributes.SETTINGS);
|
102 |
|
|
this.ra = inputParameters.getRa();
|
103 |
|
|
this.dec = inputParameters.getDec();
|
104 |
|
|
this.time= inputParameters.getTime();
|
105 |
|
|
this.band = inputParameters.getBand();
|
106 |
|
|
createResponse(inputParameters, model);
|
107 |
|
|
}
|
108 |
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
private void createResponse(final SimpleSpectralAccessInputParameters inputParameters, final ResourceModel model) {
|
116 |
|
|
|
117 |
|
|
final String dictionaryName = model.getParameterByName(SimpleSpectralAccessProtocolLibrary.DICTIONARY).getValue();
|
118 |
|
|
|
119 |
|
|
|
120 |
|
|
setVotableParametersFromConfiguration(dataModel, model);
|
121 |
|
|
|
122 |
|
|
|
123 |
|
|
setVotableResource(inputParameters.getDatasetApplication(), inputParameters, model, dictionaryName);
|
124 |
|
|
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
|
128 |
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
|
|
private void setVotableParametersFromConfiguration(final Map dataModel, final ResourceModel model) {
|
134 |
|
|
final List<Param> params = new ArrayList<Param>();
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.INSTRUMENT, DataType.CHAR);
|
138 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.MAX_FILE_SIZE, DataType.LONG);
|
139 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.RESPONSIBLE_PARTY, DataType.CHAR);
|
140 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.SERVICE_NAME, DataType.CHAR);
|
141 |
|
|
|
142 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.MAX_RECORDS, DataType.INT);
|
143 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.MAX_QUERY_SIZE, DataType.CHAR);
|
144 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.MAX_IMAGE_SIZE, DataType.CHAR);
|
145 |
|
|
setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.VERB, DataType.INT);
|
146 |
|
|
|
147 |
|
|
if (Util.isSet(params)) {
|
148 |
|
|
dataModel.put("params", params);
|
149 |
|
|
}
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
private void setVotableParam(final List<Param> params, final ResourceModel model, final String parameterName,
|
161 |
|
|
final DataType datatype) {
|
162 |
|
|
final String parameterValue = model.getParameterByName(parameterName).getValue();
|
163 |
|
|
if (Util.isNotEmpty(parameterValue)) {
|
164 |
|
|
final Param param = new Param();
|
165 |
|
|
param.setName(parameterName);
|
166 |
|
|
param.setValue(parameterValue);
|
167 |
|
|
param.setDatatype(datatype);
|
168 |
|
|
params.add(param);
|
169 |
|
|
}
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
|
174 |
|
|
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
private void setVotableResource(final DataSetApplication datasetApp, final SimpleSpectralAccessInputParameters inputParameters,
|
181 |
|
|
final ResourceModel model, final String dictionaryName) {
|
182 |
|
|
|
183 |
|
|
final List<Field> fieldList = new ArrayList<Field>();
|
184 |
|
|
final List<String> columnList = new ArrayList<String>();
|
185 |
|
|
DatabaseRequest databaseRequest = null;
|
186 |
|
|
|
187 |
|
|
try {
|
188 |
|
|
|
189 |
|
|
List<ColumnConceptMappingDTO> mappingList = getDicoFromConfiguration(datasetApp, dictionaryName);
|
190 |
|
|
|
191 |
|
|
mappingList = checkRequiredMapping(mappingList, inputParameters.getVerb());
|
192 |
|
|
|
193 |
|
|
|
194 |
|
|
final DatabaseRequestParameters dbParams = setQueryParameters(datasetApp, model, inputParameters, mappingList);
|
195 |
|
|
databaseRequest = DatabaseRequestFactory.getDatabaseRequest(dbParams);
|
196 |
|
|
|
197 |
|
|
databaseRequest.createRequest();
|
198 |
|
|
|
199 |
|
|
LOG.log(Level.FINEST, "DB request: {0}", databaseRequest.getRequestAsString());
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
fillInfosParamAboutQuery(model);
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
setFields(fieldList, columnList, mappingList);
|
206 |
|
|
dataModel.put("fields", fieldList);
|
207 |
|
|
dataModel.put("sqlColAlias", columnList);
|
208 |
|
|
Map conceptColAlias = new HashMap();
|
209 |
|
|
for (ColumnConceptMappingDTO map:mappingList) {
|
210 |
|
|
conceptColAlias.put(map.getColumnAlias(), map.getConcept().getPropertyFromName("ucd").getValue());
|
211 |
|
|
}
|
212 |
|
|
dataModel.put("mappingColAliasConceptSql", conceptColAlias);
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
final int count = (databaseRequest.getCount() > dbParams.getPaginationExtend()) ? dbParams.getPaginationExtend() : databaseRequest.getCount();
|
216 |
|
|
dataModel.put("nrows", count);
|
217 |
|
|
final ConverterChained converterChained = datasetApp.getConverterChained();
|
218 |
|
|
|
219 |
|
|
final TemplateSequenceModel rows = new DatabaseRequestModel(databaseRequest, converterChained);
|
220 |
|
|
((DatabaseRequestModel) rows).setSize(count);
|
221 |
|
|
dataModel.put("rows", rows);
|
222 |
|
|
|
223 |
|
|
} catch (SitoolsException ex) {
|
224 |
|
|
try {
|
225 |
|
|
if (Util.isSet(databaseRequest)) {
|
226 |
|
|
databaseRequest.close();
|
227 |
|
|
}
|
228 |
|
|
} catch (SitoolsException ex1) {
|
229 |
|
|
LOG.log(Level.FINER, null, ex1);
|
230 |
|
|
} finally {
|
231 |
|
|
final List<Info> infos = new ArrayList<Info>();
|
232 |
|
|
LOG.log(Level.FINEST, "ERROR: {0}", ex.getMessage());
|
233 |
|
|
setVotableError(infos, "Query", "Error in query", "Error in input query: " + ex.getMessage());
|
234 |
|
|
if (!infos.isEmpty()) {
|
235 |
|
|
this.dataModel.put("infos", infos);
|
236 |
|
|
}
|
237 |
|
|
}
|
238 |
|
|
}
|
239 |
|
|
}
|
240 |
|
|
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
|
|
|
247 |
|
|
|
248 |
|
|
|
249 |
|
|
@SuppressWarnings("empty-statement")
|
250 |
|
|
private DatabaseRequestParameters setQueryParameters(final DataSetApplication datasetApp, final ResourceModel model,
|
251 |
|
|
final SimpleSpectralAccessInputParameters inputParameters, List<ColumnConceptMappingDTO> mappingList) {
|
252 |
|
|
|
253 |
|
|
|
254 |
|
|
final DataSetExplorerUtil dsExplorerUtil = new DataSetExplorerUtil(datasetApp, inputParameters.getRequest(),
|
255 |
|
|
inputParameters.getContext());
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
final DatabaseRequestParameters dbParams = dsExplorerUtil.getDatabaseParams();
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
final int nbRecordsInDataSet = datasetApp.getDataSet().getNbRecords();
|
262 |
|
|
|
263 |
|
|
|
264 |
|
|
int nbMaxRecords = Integer.valueOf(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.MAX_RECORDS).getValue());
|
265 |
|
|
nbMaxRecords = (nbMaxRecords > nbRecordsInDataSet || nbMaxRecords == -1) ? nbRecordsInDataSet : nbMaxRecords;
|
266 |
|
|
|
267 |
|
|
|
268 |
|
|
dbParams.setPaginationExtend(nbMaxRecords);
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
String raColTarget = null;
|
272 |
|
|
String decColTarget = null;
|
273 |
|
|
String timeColTarget = null;
|
274 |
|
|
String bandColTarget = null;
|
275 |
|
|
for (ColumnConceptMappingDTO mapIter : mappingList) {
|
276 |
|
|
final String ucd = mapIter.getConcept().getPropertyFromName("ucd").getValue();
|
277 |
|
|
if (ucd.equals(SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.get(1))) {
|
278 |
|
|
raColTarget = mapIter.getColumnAlias();
|
279 |
|
|
}
|
280 |
|
|
if (ucd.equals(SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.get(2))) {
|
281 |
|
|
decColTarget = mapIter.getColumnAlias();
|
282 |
|
|
}
|
283 |
|
|
if (ucd.equals(SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.get(4))) {
|
284 |
|
|
timeColTarget = mapIter.getColumnAlias();
|
285 |
|
|
}
|
286 |
|
|
if (ucd.equals(SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.get(5))) {
|
287 |
|
|
bandColTarget = mapIter.getColumnAlias();
|
288 |
|
|
}
|
289 |
|
|
}
|
290 |
|
|
final AbstractSqlGeometryConstraint sql = SqlGeometryFactory.create(String.valueOf(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.INTERSECT).getValue()));
|
291 |
|
|
sql.setInputParameters(inputParameters);
|
292 |
|
|
String[] geo = null;
|
293 |
|
|
if(!Util.isNotEmpty(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.GEO_ATTRIBUT).getValue())){
|
294 |
|
|
geo = new String[]{raColTarget, decColTarget,timeColTarget,bandColTarget};
|
295 |
|
|
}
|
296 |
|
|
|
297 |
|
|
final Object geometry = (Util.isNotEmpty(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.GEO_ATTRIBUT).getValue()))
|
298 |
|
|
? model.getParameterByName(SimpleSpectralAccessProtocolLibrary.GEO_ATTRIBUT).getValue()
|
299 |
|
|
: geo;
|
300 |
|
|
|
301 |
|
|
sql.setGeometry(geometry);
|
302 |
|
|
if (sql.getSqlPredicat() != null) {
|
303 |
|
|
final Predicat predicat = new Predicat();
|
304 |
|
|
predicat.setStringDefinition(sql.getSqlPredicat());
|
305 |
|
|
final List<Predicat> predicatList = dbParams.getPredicats();
|
306 |
|
|
predicatList.add(predicat);
|
307 |
|
|
dbParams.setPredicats(predicatList);
|
308 |
|
|
}
|
309 |
|
|
return dbParams;
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
|
313 |
|
|
|
314 |
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
|
|
|
319 |
|
|
|
320 |
|
|
private void setVotableError(final List<Info> infos, final String id, final String name, final String value) {
|
321 |
|
|
if (Util.isNotEmpty(name)) {
|
322 |
|
|
final Info info = new Info();
|
323 |
|
|
info.setID(id);
|
324 |
|
|
info.setName(name);
|
325 |
|
|
info.setValueAttribute(value);
|
326 |
|
|
infos.add(info);
|
327 |
|
|
}
|
328 |
|
|
}
|
329 |
|
|
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
|
333 |
|
|
|
334 |
|
|
@Override
|
335 |
|
|
public final Map getDataModel() {
|
336 |
|
|
return Collections.unmodifiableMap(this.dataModel);
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
|
340 |
|
|
|
341 |
|
|
|
342 |
|
|
|
343 |
|
|
|
344 |
|
|
|
345 |
|
|
|
346 |
|
|
|
347 |
|
|
private List<ColumnConceptMappingDTO> getDicoFromConfiguration(final DataSetApplication datasetApp,
|
348 |
|
|
final String dicoToFind) throws SitoolsException {
|
349 |
|
|
List<ColumnConceptMappingDTO> colConceptMappingDTOList = null;
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
final List<DictionaryMappingDTO> dicoMappingList = datasetApp.getDictionaryMappings();
|
353 |
|
|
if (!Util.isSet(dicoMappingList) || dicoMappingList.isEmpty()) {
|
354 |
|
|
throw new SitoolsException("No mapping with VO concepts has been done. please contact the administrator");
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
for (DictionaryMappingDTO dicoMappingIter : dicoMappingList) {
|
359 |
|
|
final String dicoName = dicoMappingIter.getDictionaryName();
|
360 |
|
|
if (dicoToFind.equals(dicoName)) {
|
361 |
|
|
colConceptMappingDTOList = dicoMappingIter.getMapping();
|
362 |
|
|
break;
|
363 |
|
|
}
|
364 |
|
|
}
|
365 |
|
|
return colConceptMappingDTOList;
|
366 |
|
|
}
|
367 |
|
|
|
368 |
|
|
|
369 |
|
|
|
370 |
|
|
|
371 |
|
|
|
372 |
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
|
|
private void setFields(final List<Field> fieldList, final List<String> columnList, final List<ColumnConceptMappingDTO> mappingList) {
|
376 |
|
|
|
377 |
|
|
for (ColumnConceptMappingDTO mappingIter : mappingList) {
|
378 |
|
|
|
379 |
|
|
String id = null;
|
380 |
|
|
String name = null;
|
381 |
|
|
String ucd = null;
|
382 |
|
|
String utype = null;
|
383 |
|
|
String ref = null;
|
384 |
|
|
String datatype = null;
|
385 |
|
|
String width = null;
|
386 |
|
|
String precision = null;
|
387 |
|
|
String unit = null;
|
388 |
|
|
String type = null;
|
389 |
|
|
String xtype = null;
|
390 |
|
|
String arraysize = null;
|
391 |
|
|
String descriptionValue = null;
|
392 |
|
|
columnList.add(mappingIter.getColumnAlias());
|
393 |
|
|
final Concept concept = mappingIter.getConcept();
|
394 |
|
|
if (concept.getName() != null) {
|
395 |
|
|
name = concept.getName();
|
396 |
|
|
}
|
397 |
|
|
if (concept.getPropertyFromName("ID").getValue() != null) {
|
398 |
|
|
id = concept.getPropertyFromName("ID").getValue();
|
399 |
|
|
}
|
400 |
|
|
if (concept.getPropertyFromName("ucd").getValue() != null) {
|
401 |
|
|
ucd = concept.getPropertyFromName("ucd").getValue();
|
402 |
|
|
}
|
403 |
|
|
if (concept.getPropertyFromName("utype").getValue() != null) {
|
404 |
|
|
utype = concept.getPropertyFromName("utype").getValue();
|
405 |
|
|
}
|
406 |
|
|
if (concept.getPropertyFromName("ref").getValue() != null) {
|
407 |
|
|
ref = concept.getPropertyFromName("ref").getValue();
|
408 |
|
|
}
|
409 |
|
|
if (concept.getPropertyFromName("datatype").getValue() != null) {
|
410 |
|
|
datatype = concept.getPropertyFromName("datatype").getValue();
|
411 |
|
|
}
|
412 |
|
|
if (concept.getPropertyFromName("width").getValue() != null) {
|
413 |
|
|
width = concept.getPropertyFromName("width").getValue();
|
414 |
|
|
}
|
415 |
|
|
if (concept.getPropertyFromName("precision").getValue() != null) {
|
416 |
|
|
precision = concept.getPropertyFromName("precision").getValue();
|
417 |
|
|
}
|
418 |
|
|
if (concept.getPropertyFromName("unit").getValue() != null) {
|
419 |
|
|
unit = concept.getPropertyFromName("unit").getValue();
|
420 |
|
|
}
|
421 |
|
|
if (concept.getPropertyFromName("type").getValue() != null) {
|
422 |
|
|
type = concept.getPropertyFromName("type").getValue();
|
423 |
|
|
}
|
424 |
|
|
if (concept.getPropertyFromName("xtype").getValue() != null) {
|
425 |
|
|
xtype = concept.getPropertyFromName("xtype").getValue();
|
426 |
|
|
}
|
427 |
|
|
if (concept.getPropertyFromName("arraysize").getValue() != null) {
|
428 |
|
|
arraysize = concept.getPropertyFromName("arraysize").getValue();
|
429 |
|
|
}
|
430 |
|
|
if (concept.getDescription() != null) {
|
431 |
|
|
descriptionValue = concept.getDescription();
|
432 |
|
|
}
|
433 |
|
|
final Field field = new Field();
|
434 |
|
|
field.setID(id);
|
435 |
|
|
field.setName(name);
|
436 |
|
|
field.setUcd(ucd);
|
437 |
|
|
field.setUtype(utype);
|
438 |
|
|
field.setRef(ref);
|
439 |
|
|
field.setDatatype(DataType.fromValue(datatype));
|
440 |
|
|
if (width != null) {
|
441 |
|
|
field.setWidth(BigInteger.valueOf(Long.valueOf(width)));
|
442 |
|
|
}
|
443 |
|
|
field.setPrecision(precision);
|
444 |
|
|
field.setUnit(unit);
|
445 |
|
|
field.setType(type);
|
446 |
|
|
field.setXtype(xtype);
|
447 |
|
|
field.setArraysize(arraysize);
|
448 |
|
|
final AnyTEXT anyText = new AnyTEXT();
|
449 |
|
|
anyText.getContent().add(descriptionValue);
|
450 |
|
|
field.setDESCRIPTION(anyText);
|
451 |
|
|
fieldList.add(field);
|
452 |
|
|
}
|
453 |
|
|
}
|
454 |
|
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
private List<ColumnConceptMappingDTO> checkRequiredMapping(final List<ColumnConceptMappingDTO> mappingList, final int verb)
|
464 |
|
|
throws SitoolsException {
|
465 |
|
|
|
466 |
|
|
final int nbConceptToMap = SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.size();
|
467 |
|
|
int nbConcept = 0;
|
468 |
|
|
final List<ColumnConceptMappingDTO> conceptToMap = new ArrayList<ColumnConceptMappingDTO>(mappingList);
|
469 |
|
|
for (ColumnConceptMappingDTO mappingIter : mappingList) {
|
470 |
|
|
final Concept concept = mappingIter.getConcept();
|
471 |
|
|
final String ucdValue = concept.getPropertyFromName("ucd").getValue();
|
472 |
|
|
if (Util.isNotEmpty(ucdValue) && SimpleSpectralAccessProtocolLibrary.REQUIRED_UCD_CONCEPTS.contains(ucdValue)) {
|
473 |
|
|
nbConcept++;
|
474 |
|
|
} else if (verb == 1) {
|
475 |
|
|
conceptToMap.remove(mappingIter);
|
476 |
|
|
}
|
477 |
|
|
}
|
478 |
|
|
if (nbConceptToMap != nbConcept) {
|
479 |
|
|
|
480 |
|
|
final StringBuilder buffer = new StringBuilder("columns with ");
|
481 |
|
|
for (ColumnConceptMappingDTO mappingIter : mappingList) {
|
482 |
|
|
buffer.append(mappingIter.getConcept().getName()).append(" ");
|
483 |
|
|
}
|
484 |
|
|
buffer.append("must be mapped");
|
485 |
|
|
throw new SitoolsException(buffer.toString());
|
486 |
|
|
}
|
487 |
|
|
|
488 |
|
|
return conceptToMap;
|
489 |
|
|
|
490 |
|
|
}
|
491 |
|
|
|
492 |
|
|
private void fillInfosParamAboutQuery(final ResourceModel model){
|
493 |
|
|
final List<Info> listQueryInfos = new ArrayList<Info>();
|
494 |
|
|
|
495 |
|
|
final Info info = new Info();
|
496 |
|
|
info.setName("QUERY_STATUS");
|
497 |
|
|
info.setValueAttribute("OK");
|
498 |
|
|
listQueryInfos.add(info);
|
499 |
|
|
this.dataModel.put("queryInfos", listQueryInfos);
|
500 |
|
|
|
501 |
|
|
final List<Param> listQueryParam = new ArrayList<Param>();
|
502 |
|
|
Param param = new Param();
|
503 |
|
|
param.setName("POS");
|
504 |
|
|
param.setValue(this.ra+","+this.dec);
|
505 |
|
|
param.setUnit("deg");
|
506 |
|
|
param.setDatatype(DataType.DOUBLE);
|
507 |
|
|
listQueryParam.add(param);
|
508 |
|
|
|
509 |
|
|
|
510 |
|
|
|
511 |
|
|
|
512 |
|
|
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
|
|
|
520 |
|
|
|
521 |
|
|
|
522 |
|
|
|
523 |
|
|
|
524 |
|
|
|
525 |
|
|
addTimeBandAndSize(listQueryParam);
|
526 |
|
|
|
527 |
|
|
param = new Param();
|
528 |
|
|
param.setName("FORMAT");
|
529 |
|
|
param.setValue(SimpleSpectralAccessProtocolLibrary.ParamStandardFormat.ALL.name().toLowerCase());
|
530 |
|
|
param.setDatatype(DataType.CHAR);
|
531 |
|
|
param.setArraysize("*");
|
532 |
|
|
listQueryParam.add(param);
|
533 |
|
|
|
534 |
|
|
param = new Param();
|
535 |
|
|
param.setName("INTERSECT");
|
536 |
|
|
param.setValue(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.INTERSECT).getValue());
|
537 |
|
|
param.setDatatype(DataType.CHAR);
|
538 |
|
|
listQueryParam.add(param);
|
539 |
|
|
|
540 |
|
|
param = new Param();
|
541 |
|
|
param.setName("VERB");
|
542 |
|
|
param.setValue(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.VERB).getValue());
|
543 |
|
|
param.setDatatype(DataType.INT);
|
544 |
|
|
listQueryParam.add(param);
|
545 |
|
|
|
546 |
|
|
dataModel.put("queryParams", listQueryParam);
|
547 |
|
|
}
|
548 |
|
|
|
549 |
|
|
private List<Param> addTimeBandAndSize(List<Param> listOfParams){
|
550 |
|
|
|
551 |
|
|
if(this.time.length == 2){
|
552 |
|
|
Param param = new Param();
|
553 |
|
|
param.setName("TIME");
|
554 |
|
|
param.setValue("From : "+this.time[0]+" to "+this.time[1]);
|
555 |
|
|
param.setDatatype(DataType.CHAR);
|
556 |
|
|
listOfParams.add(param);
|
557 |
|
|
}else{
|
558 |
|
|
Param param = new Param();
|
559 |
|
|
param.setName("TIME");
|
560 |
|
|
param.setValue(this.time[0]);
|
561 |
|
|
param.setDatatype(DataType.CHAR);
|
562 |
|
|
listOfParams.add(param);
|
563 |
|
|
}
|
564 |
|
|
|
565 |
|
|
if(this.band.length == 2){
|
566 |
|
|
Double bandMin = this.band[0];
|
567 |
|
|
Double bandMax = this.band[1];
|
568 |
|
|
Param param = new Param();
|
569 |
|
|
param.setName("BAND");
|
570 |
|
|
param.setValue(bandMin.toString()+" , "+bandMax);
|
571 |
|
|
param.setUnit("m");
|
572 |
|
|
param.setDatatype(DataType.DOUBLE);
|
573 |
|
|
listOfParams.add(param);
|
574 |
|
|
}else{
|
575 |
|
|
Double bandValue = this.band[0];
|
576 |
|
|
Param param = new Param();
|
577 |
|
|
param.setName("BAND");
|
578 |
|
|
param.setValue(bandValue.toString());
|
579 |
|
|
param.setUnit("m");
|
580 |
|
|
param.setDatatype(DataType.DOUBLE);
|
581 |
|
|
listOfParams.add(param);
|
582 |
|
|
}
|
583 |
|
|
|
584 |
|
|
|
585 |
|
|
|
586 |
|
|
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
|
590 |
|
|
|
591 |
|
|
|
592 |
|
|
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
|
|
|
597 |
|
|
|
598 |
|
|
return listOfParams;
|
599 |
|
|
}
|
600 |
|
|
} |