Project

General

Profile

Download (22.7 KB) Statistics
| Branch: | Revision:

git_sitools_idoc / sitools-idoc / hesiod / javaExt / src / fr / ias / sitools / vo / ssa / SimpleSpectralAccessResponse.java @ 779bac69

1
 /*******************************************************************************
2
 * Copyright 2010-2013 CNES - CENTRE NATIONAL d'ETUDES SPATIALES
3
 *
4
 * This file is part of SITools2.
5
 *
6
 * SITools2 is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * SITools2 is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with SITools2.  If not, see <http://www.gnu.org/licenses/>.
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
 * Votable response for cone search.
57
 *
58
 * @author Jean-Christophe Malapert <jean-christophe.malapert@cnes.fr>
59
 */
60
public class SimpleSpectralAccessResponse implements SimpleSpectralAccessDataModelInterface {
61
    
62
  /**
63
   * Logger.
64
   */
65
  private static final Logger LOG = Logger.getLogger(SimpleSpectralAccessResponse.class.getName());
66
  
67
  /**
68
   * Data model.
69
   */
70
  private final transient Map dataModel = new HashMap();
71
  
72
  /**
73
   * Sitools Settings
74
   */
75
  private SitoolsSettings sitoolsSettings = null;
76
  /**
77
   * Right Ascenscion.
78
   */
79
  private final double ra;
80
  /**
81
   * Declination.
82
   */
83
  private final double dec;
84

    
85
  /**
86
   * Time 
87
   */
88
  private final String[] time;
89
  /**
90
   * Band 
91
   */
92
  private final double[] band;
93
  
94
  /**
95
   * Constructor.
96
   *
97
   * @param inputParameters input parameters
98
   * @param model data model
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
   * Creates VOTable response.
111
   *
112
   * @param inputParameters Input parameters
113
   * @param model data model
114
   */
115
  private void createResponse(final SimpleSpectralAccessInputParameters inputParameters, final ResourceModel model) {
116
    // createResponse
117
    final String dictionaryName = model.getParameterByName(SimpleSpectralAccessProtocolLibrary.DICTIONARY).getValue();
118

    
119
    // Set Votable parameters
120
    setVotableParametersFromConfiguration(dataModel, model);
121

    
122
    // Set Votable resources
123
    setVotableResource(inputParameters.getDatasetApplication(), inputParameters, model, dictionaryName);
124
   
125
  }
126

    
127
  /**
128
   * Sets VOTable parameters coming from administration configuration.
129
   *
130
   * @param dataModel data model to set
131
   * @param model parameters from administration
132
   */
133
  private void setVotableParametersFromConfiguration(final Map dataModel, final ResourceModel model) {
134
    final List<Param> params = new ArrayList<Param>();
135
    //setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.COVERAGE, DataType.CHAR);
136
    //setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.TEMPORAL, DataType.CHAR);
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
    //setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.WAVEBAND, DataType.CHAR);
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
/* POURQUOI BOOLEAN ?? Alors qu'il peut prendre 0,1,2 ou 3 comme valeurs    setVotableParam(params, model, SimpleSpectralAccessProtocolLibrary.VERB, DataType.BOOLEAN);*/
147
    if (Util.isSet(params)) {
148
      dataModel.put("params", params);
149
    }
150
  }
151

    
152
  /**
153
   * Sets Votable Param.
154
   *
155
   * @param params List of params
156
   * @param model data model
157
   * @param parameterName parameter name
158
   * @param datatype datatype
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
   * Creates the response based on Table.
174
   *
175
   * @param datasetApp Dataset application
176
   * @param inputParameters Input Parameters
177
   * @param model data model
178
   * @param dictionaryName Cone search dictionary
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
      // Get the concepts from the dictionary
189
      List<ColumnConceptMappingDTO> mappingList = getDicoFromConfiguration(datasetApp, dictionaryName);
190

    
191
      mappingList = checkRequiredMapping(mappingList, inputParameters.getVerb());
192

    
193
      // Get query parameters
194
      final DatabaseRequestParameters dbParams = setQueryParameters(datasetApp, model, inputParameters, mappingList);
195
      databaseRequest = DatabaseRequestFactory.getDatabaseRequest(dbParams);
196
      // Execute query
197
      databaseRequest.createRequest();
198

    
199
      LOG.log(Level.FINEST, "DB request: {0}", databaseRequest.getRequestAsString());
200
      
201
      //Fill the template with query status and param
202
      fillInfosParamAboutQuery(model);
203
      
204
      // complete data model with fields
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
      // Complete data model with data
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
   * Set Query parameters to the database.
243
   *
244
   * @param datasetApp Dataset Application
245
   * @param model Data model
246
   * @param inputParameters Input Parameters
247
   * @return DatabaseRequestParamerters object
248
   */
249
  @SuppressWarnings("empty-statement")
250
  private DatabaseRequestParameters setQueryParameters(final DataSetApplication datasetApp, final ResourceModel model,
251
          final SimpleSpectralAccessInputParameters inputParameters, List<ColumnConceptMappingDTO> mappingList) {
252

    
253
    // Get the dataset
254
    final DataSetExplorerUtil dsExplorerUtil = new DataSetExplorerUtil(datasetApp, inputParameters.getRequest(),
255
            inputParameters.getContext());
256

    
257
    // Get query parameters
258
    final DatabaseRequestParameters dbParams = dsExplorerUtil.getDatabaseParams();
259

    
260
    // Get dataset records
261
    final int nbRecordsInDataSet = datasetApp.getDataSet().getNbRecords();
262

    
263
    // Get max records that is defined by admin
264
    int nbMaxRecords = Integer.valueOf(model.getParameterByName(SimpleSpectralAccessProtocolLibrary.MAX_RECORDS).getValue());
265
    nbMaxRecords = (nbMaxRecords > nbRecordsInDataSet || nbMaxRecords == -1) ? nbRecordsInDataSet : nbMaxRecords;
266

    
267
    // Set max records
268
    dbParams.setPaginationExtend(nbMaxRecords);
269

    
270
    // Create predicat definition   
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;//Arrays.asList(raColTarget, decColTarget,timeColTarget,bandColTarget);
300
    //final Object geometry = 
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
   * Set the votable error.
314
   *
315
   * @param infos infos
316
   * @param id id 
317
   * @param name name
318
   * @param value value
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
   * Returns the data model.
332
   * @return the data model
333
   */
334
  @Override
335
  public final Map getDataModel() {
336
    return Collections.unmodifiableMap(this.dataModel);
337
  }
338

    
339
  /**
340
   * Provide the mapping between SQL column/concept for a given dictionary.
341
   *
342
   * @param datasetApp Application where this service is attached
343
   * @param dicoToFind Dictionary name to find
344
   * @return Returns a mapping SQL column/Concept
345
   * @throws SitoolsException No mapping has been done or cannot find the dico
346
   */
347
  private List<ColumnConceptMappingDTO> getDicoFromConfiguration(final DataSetApplication datasetApp,
348
          final String dicoToFind) throws SitoolsException {
349
    List<ColumnConceptMappingDTO> colConceptMappingDTOList = null;
350

    
351
    // Get the list of dictionnaries related to the datasetApplication
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
    // For each dictionary, find the interesting one and return the mapping SQLcolumn/concept
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
   * Set Fields and columnSqlAliasList.
370
   *
371
   * @param fieldList List of fields to display on the VOTable
372
   * @param columnList List of SQL column
373
   * @param mappingList List of SQL column/concept
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
   * Checks required mapping and filter columns to map according to VERB.
457
   *
458
   * @param mappingList list of mapping defined by the administrator
459
   * @param verb VERB of Cone search protocol
460
   * @return Returns the new mapping according to VERB
461
   * @throws SitoolsException columns with UCD ID_MAIN, POS_EQ_RA_MAIN, POS_EQ_DEC_MAIN must be mapped
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
//-------------------------- AJOUT POUR LE PROTOCOLE SSA --------------------------------------------
510
    /*
511
    param = new Param();
512
    param.setName("TIME");
513
    param.setValue(this.time.toString());
514
    //param.setUnit("");
515
    param.setDatatype(DataType.CHAR);
516
    listQueryParam.add(param);
517
    
518
    param = new Param();
519
    param.setName("BAND");
520
    param.setValue(this.band.toString());
521
    param.setUnit("m");
522
    param.setDatatype(DataType.DOUBLE);
523
    listQueryParam.add(param);
524
    */
525
    addTimeBandAndSize(listQueryParam);
526
//**************************** FIN DU RAJOUT *********************************
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
      // ADD TIME
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
      // ADD BAND
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
      // ADD SIZE 
584
      /*
585
      if(this.time.length == 2){
586
        Param param = new Param();
587
        param.setName("TIME");
588
        param.setValue("From : "+this.time[0]+" to "+this.time[1]);
589
        param.setDatatype(DataType.CHAR);
590
        listOfParams.add(param);
591
      }else{
592
        Param param = new Param();
593
        param.setName("TIME");
594
        param.setValue(this.time[0]);
595
        param.setDatatype(DataType.CHAR);
596
        listOfParams.add(param);
597
      }*/
598
      return listOfParams;
599
  }
600
}