source: ether_ndacc/trunk/web/src/com/ether/Controller.java @ 127

Last change on this file since 127 was 127, checked in by rboipsl, 13 years ago

v2 pour toutes les stations

File size: 15.1 KB
Line 
1package com.ether;
2
3import java.util.List;
4
5import javax.servlet.http.HttpServletRequest;
6import javax.servlet.http.HttpServletResponse;
7
8import org.springframework.web.servlet.ModelAndView;
9import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
10
11import com.ether.instrument.Instrument;
12import com.ether.station.Station;
13
14/**
15 * @author vmipsl
16 * @date 02 feb 2011
17 */
18public class Controller extends MultiActionController
19{
20    // Default view if methodName is unknown
21    public ModelAndView home(final HttpServletRequest request, final HttpServletResponse response) 
22        throws WebException
23    {
24        return new ModelAndView("index");
25    }
26
27   
28    public ModelAndView viewLidarO3s(final HttpServletRequest request, final HttpServletResponse response) 
29        throws WebException
30    {
31                try {
32                        final List<String> listeDates = _serviceTools.getListeDates();
33
34                        final ModelAndView modelAndView = new ModelAndView(VIEW_LIDAR_O3S);
35                        modelAndView.addObject("listeDates", listeDates);
36                       
37                        return modelAndView;
38
39                } catch (ServiceException e) {
40                        throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
41                }
42    }
43   
44   
45    public ModelAndView selectEcc(final HttpServletRequest request, final HttpServletResponse response) 
46        throws WebException
47        {
48        try {
49                String dateinf = request.getParameter("dateinf");
50                String station = request.getParameter("station");
51               
52                final String instrument = request.getParameter("instrument");
53
54                List<String> plotsList = _plotService.getPlotsByDateByInstrumentByStation(instrument, dateinf,"yyyyMMdd",station);
55                 
56                //dateinf="02021980";
57                //List<String> ListDates = _plotService.getLastDate(instrument);
58                final List<String> listeDates = _serviceTools.getListeDates();
59                String rep="";
60                String year = dateinf.substring(0, 4);
61               
62                if (station.compareTo("OHP")==0 || station.compareTo("ohp")==0 ) {
63                        rep="./resources/visu/ohp/ecc";
64                        station="OHP";
65                        if (year.compareTo("1970") == 0) year="2007";
66                }
67                else if (station.compareTo("LA REUNION")==0 || station.compareTo("reunion")==0 ) {
68                        rep="./resources/visu/reu/ecc";
69                        //rep="./resources/visu/ohp/lidar/o3_strato";
70                        station="LA REUNION";
71                        if (year.compareTo("1970") == 0) year="2006";
72                        //year="2006";
73                }
74                else if (station.compareTo("DDU")==0 || station.compareTo("ddu")==0 ) {
75                        rep="./resources/visu/ddu/ecc";
76                        //rep="./resources/visu/ohp/lidar/o3_strato";
77                        station="DDU";
78                        if (year.compareTo("1970") == 0) year="1991";
79                        //year="2006";
80                }
81               
82               
83                final ModelAndView modelAndView = new ModelAndView(VIEW_ECC);
84                //plotsList=null;
85                modelAndView.addObject("plotsList", plotsList);
86               
87                modelAndView.addObject("listeDates", listeDates);
88                modelAndView.addObject("firstDate", dateinf);                   
89               
90                String month = dateinf.substring(4,6);
91                modelAndView.addObject("month", month);
92                modelAndView.addObject("year", year);
93                modelAndView.addObject("station", station);
94                modelAndView.addObject("rep", rep);
95               
96                return modelAndView;
97
98        } catch (ServiceException e) {
99                throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
100        }
101}
102
103   
104    public ModelAndView selectLidarO3s(final HttpServletRequest request, final HttpServletResponse response) 
105        throws WebException
106    {
107                try {
108                        String dateinf = request.getParameter("dateinf");
109                        String station = request.getParameter("station");
110                       
111                        final String instrument = request.getParameter("instrument");
112
113                        List<String> plotsList = _plotService.getPlotsByDateByInstrumentByStation(instrument, dateinf,"yyyyMMdd",station);
114                         
115                        //dateinf="02021980";
116                        //List<String> ListDates = _plotService.getLastDate(instrument);
117                        final List<String> listeDates = _serviceTools.getListeDates();
118                        String rep="";
119                        String year = dateinf.substring(0, 4);
120                        String month = dateinf.substring(4,6);
121                       
122                        if (station.compareTo("OHP")==0 || station.compareTo("ohp")==0 ) {
123                                rep="./resources/visu/ohp/lidar/o3_strato";
124                                station="OHP";
125                                if (year.compareTo("1970") == 0) {
126                                       
127                                        year="1991";
128                                }
129                        }
130                        else if (station.compareTo("REU")==0 || station.compareTo("reu")==0 ) {
131                                rep="./resources/visu/reu/lidar/o3_strato";
132                                station="LA REUNION";
133                                if (year.compareTo("1970") == 0) year="2006";
134                                //year="2006";
135                        }
136                       
137                        else {
138                                rep="./resources/visu/ddu/lidar/o3_strato";
139                                station="DDU";
140                                if (year.compareTo("1970") == 0) {
141                                                year="1991";
142                                                //month="04";                           
143                                }
144                                //year="2006";
145                        }
146                       
147                        final ModelAndView modelAndView = new ModelAndView(VIEW_LIDAR_O3S);
148                        //plotsList=null;
149                        modelAndView.addObject("plotsList", plotsList);
150                       
151                        modelAndView.addObject("listeDates", listeDates);
152                        modelAndView.addObject("firstDate", dateinf);                   
153                       
154                       
155                        modelAndView.addObject("month", month);
156                        modelAndView.addObject("year", year);
157                        modelAndView.addObject("station", station);
158                        modelAndView.addObject("rep", rep);
159                       
160                        return modelAndView;
161
162                } catch (ServiceException e) {
163                        throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
164                }
165    }
166   
167    public ModelAndView selectLidarO3t(final HttpServletRequest request, final HttpServletResponse response) 
168        throws WebException
169{
170        try {
171                String dateinf = request.getParameter("dateinf");
172                String station = request.getParameter("station");
173               
174                final String instrument = request.getParameter("instrument");
175
176                List<String> plotsList = _plotService.getPlotsByDateByInstrumentByStation(instrument, dateinf,"yyyyMMdd",station);
177                 
178                //dateinf="02021980";
179                //List<String> ListDates = _plotService.getLastDate(instrument);
180                final List<String> listeDates = _serviceTools.getListeDates();
181                String rep="";
182                String year = dateinf.substring(0, 4);
183                String month = dateinf.substring(4, 6);
184               
185                if (station.compareTo("OHP")==0 || station.compareTo("ohp")==0 ) {
186                        rep="./resources/visu/ohp/lidar/o3_tropo";
187                        station="OHP";
188                        if (year.compareTo("1970") == 0) {
189                                        year="2007";
190                                        month="05";
191                                        dateinf=year+month+"01";
192                        }
193                }
194                //else if (station.compareTo("reunion")==0) {
195                else {
196                        rep="./resources/visu/reu/lidar/o3_tropo";
197                        //rep="./resources/visu/ohp/lidar/o3_strato";
198                        station="LA REUNION";
199                        if (year.compareTo("1970") == 0) {
200                                        year="2006";
201                                       
202                        }
203                        //year="2006";
204                }
205               
206               
207                final ModelAndView modelAndView = new ModelAndView(VIEW_LIDAR_O3T);
208                //plotsList=null;
209                modelAndView.addObject("plotsList", plotsList);
210               
211                modelAndView.addObject("listeDates", listeDates);
212                modelAndView.addObject("firstDate", dateinf);                   
213               
214                //String month = dateinf.substring(4,6);
215                modelAndView.addObject("month", month);
216                modelAndView.addObject("year", year);
217                modelAndView.addObject("station", station);
218                modelAndView.addObject("rep", rep);
219               
220                return modelAndView;
221
222        } catch (ServiceException e) {
223                throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
224        }
225}
226
227    public ModelAndView selectLidarTemp(final HttpServletRequest request, final HttpServletResponse response) 
228        throws WebException
229{
230        try {
231                String dateinf = request.getParameter("dateinf");
232                String station = request.getParameter("station");
233               
234                final String instrument = request.getParameter("instrument");
235
236                List<String> plotsList = _plotService.getPlotsByDateByInstrumentByStation(instrument, dateinf,"yyyyMMdd",station);
237                 
238                //dateinf="02021980";
239                //List<String> ListDates = _plotService.getLastDate(instrument);
240                final List<String> listeDates = _serviceTools.getListeDates();
241                String rep="";
242                String year = dateinf.substring(0, 4);
243                String month = dateinf.substring(4, 6);
244               
245                if (station.compareTo("OHP")==0 || station.compareTo("ohp")==0 ) {
246                        rep="./resources/visu/ohp/lidar/temp";
247                        station="OHP";
248                        if (year.compareTo("1970") == 0) {
249                                        year="2009";
250                                        month="01";
251                        }
252                }
253               
254                if (station.compareTo("REU")==0 || station.compareTo("reu")==0 ) {
255                        rep="./resources/visu/reu/lidar/temp";
256                        station="REU";
257                        if (year.compareTo("1970") == 0) {
258                                        year="1994";
259                                        month="05";
260                        }
261                }
262               
263                final ModelAndView modelAndView = new ModelAndView(VIEW_LIDAR_TEMP);
264                //plotsList=null;
265                modelAndView.addObject("plotsList", plotsList);
266               
267                modelAndView.addObject("listeDates", listeDates);
268                modelAndView.addObject("firstDate", dateinf);                   
269               
270                //String month = dateinf.substring(4,6);
271                modelAndView.addObject("month", month);
272                modelAndView.addObject("year", year);
273                modelAndView.addObject("station", station);
274                modelAndView.addObject("rep", rep);
275               
276                return modelAndView;
277
278        } catch (ServiceException e) {
279                throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
280        }
281}
282
283   
284    public ModelAndView selectLidarAerosols(final HttpServletRequest request, final HttpServletResponse response) 
285        throws WebException
286{
287        try {
288                String dateinf = request.getParameter("dateinf");
289                String station = request.getParameter("station");
290               
291                final String instrument = request.getParameter("instrument");
292
293                List<String> plotsList = _plotService.getPlotsByDateByInstrumentByStation(instrument, dateinf,"yyyyMMdd",station);
294                 
295                //dateinf="02021980";
296                //List<String> ListDates = _plotService.getLastDate(instrument);
297                final List<String> listeDates = _serviceTools.getListeDates();
298                String rep="";
299                String year = dateinf.substring(0, 4);
300                String month = dateinf.substring(4, 6);
301               
302                if (station.compareTo("OHP")==0 || station.compareTo("ohp")==0 ) {
303                        rep="./resources/visu/ohp/lidar/aerosols";
304                        station="OHP";
305                        if (year.compareTo("1970") == 0) {
306                                        year="2009";
307                                        month="01";
308                        }
309                }
310               
311                if (station.compareTo("DDU")==0 || station.compareTo("ddu")==0 ) {
312                        rep="./resources/visu/ddu/lidar/aerosols";
313                        station="DDU";
314                        if (year.compareTo("1970") == 0) {
315                                        year="2010";
316                                        month="01";
317                        }
318                }
319               
320                final ModelAndView modelAndView = new ModelAndView(VIEW_LIDAR_AEROSOLS);
321                //plotsList=null;
322                modelAndView.addObject("plotsList", plotsList);
323               
324                modelAndView.addObject("listeDates", listeDates);
325                modelAndView.addObject("firstDate", dateinf);                   
326               
327                //String month = dateinf.substring(4,6);
328                modelAndView.addObject("month", month);
329                modelAndView.addObject("year", year);
330                modelAndView.addObject("station", station);
331                modelAndView.addObject("rep", rep);
332               
333                return modelAndView;
334
335        } catch (ServiceException e) {
336                throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
337        }
338}
339
340    public ModelAndView viewSpectroUV(final HttpServletRequest request, final HttpServletResponse response) throws WebException
341        {
342        try {
343                String dateinf = request.getParameter("dateinf");
344                //List<String> m = new ArrayList<String>(12);
345               
346                String m[];
347                m = new String[12];
348                String fname, iname, year;             
349                               
350                final String instrument = request.getParameter("instrument");
351                String especes = request.getParameter("especes");
352               
353                if (especes.equals("nan")) {
354                        especes="uvauvb";
355                }
356               
357                if (dateinf.equals("nan")) {
358                        year = "2008";
359                        dateinf="2008";
360                       
361                }
362
363                List<String> plotsList = _plotService.getPlotsByDateByInstrument(instrument, dateinf,"yyyy");           
364                final List<String> listeDates = _serviceTools.getListeDates();
365               
366                final ModelAndView modelAndView = new ModelAndView(VIEW_SPECTRO_UV);
367                modelAndView.addObject("plotsList", plotsList);
368               
369                modelAndView.addObject("listeDates", listeDates);
370                modelAndView.addObject("firstDate", dateinf);
371                modelAndView.addObject("especes", especes);
372                year = dateinf.substring(0, 4);
373               
374                modelAndView.addObject("year", year);
375                modelAndView.addObject("m", m);
376               
377                fname="vasp_";
378                fname=fname.concat(especes);
379                fname=fname.concat("_");
380                fname=fname.concat(year);
381               
382                iname=fname.concat("01_plot1.jpg");
383                if (plotsList.contains(iname)) m[0]=iname;
384                else m[0]="no";
385
386                iname=fname.concat("02_plot1.jpg");
387                if (plotsList.contains(iname)) m[1]=iname;
388                else m[1]="no";
389               
390                iname=fname.concat("03_plot1.jpg");
391                if (plotsList.contains(iname)) m[2]=iname;
392                else m[2]="no";
393
394                iname=fname.concat("04_plot1.jpg");
395                if (plotsList.contains(iname)) m[3]=iname;
396                else m[3]="no";
397
398                iname=fname.concat("05_plot1.jpg");
399                if (plotsList.contains(iname)) m[4]=iname;
400                else m[4]="no";
401               
402                iname=fname.concat("06_plot1.jpg");
403                if (plotsList.contains(iname)) m[5]=iname;
404                else m[5]="no";
405               
406                iname=fname.concat("07_plot1.jpg");
407                if (plotsList.contains(iname)) m[6]=iname;
408                else m[6]="no";
409
410                iname=fname.concat("08_plot1.jpg");
411                if (plotsList.contains(iname)) m[7]=iname;
412                else m[7]="no";
413               
414                iname=fname.concat("09_plot1.jpg");
415                if (plotsList.contains(iname)) m[8]=iname;
416                else m[8]="no";
417                               
418                iname=fname.concat("10_plot1.jpg");
419                if (plotsList.contains(iname)) m[9]=iname;
420                else m[9]="no";
421
422                iname=fname.concat("11_plot1.jpg");
423                if (plotsList.contains(iname)) m[10]=iname;
424                else m[10]="no";
425               
426                iname=fname.concat("12_plot1.jpg");
427                if (plotsList.contains(iname)) m[11]=iname;
428                else m[11]="no";
429
430                return modelAndView;
431
432        } catch (ServiceException e) {
433                throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
434        }
435        }
436
437 
438   
439    public ModelAndView viewInstruments(final HttpServletRequest request, final HttpServletResponse response) 
440        throws WebException
441    {
442                try {
443                        final List<Instrument> instruments = _instrumentService.getAllInstruments();
444
445                        final ModelAndView modelAndView = new ModelAndView(VIEW_INSTRUMENT);
446                        modelAndView.addObject("instruments", instruments);
447                        return modelAndView;
448
449                } catch (ServiceException e) {
450                        throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
451                }
452    }
453
454    public ModelAndView viewStation(final HttpServletRequest request, final HttpServletResponse response) throws WebException
455    {
456                try {
457                        final Long stationId = Long.valueOf(request.getParameter("stationId"));
458                        final Station station = _stationService.getStationById(stationId);
459
460                        final ModelAndView modelAndView = new ModelAndView(VIEW_STATION);
461                        modelAndView.addObject("station", station);
462                        return modelAndView;
463
464                } catch (ServiceException e) {
465                        throw new WebException(WebException.WebCode.SERVICE_PROBLEM, e);
466                }
467    }
468
469    public void setStationService(final StationService stationService)
470    {
471        _stationService = stationService;
472    }
473
474    public void setInstrumentService(final InstrumentService instrumentService)
475    {
476        _instrumentService = instrumentService;
477    }
478   
479    public void setServiceTools(final ServiceTools serviceTools)
480    {
481        _serviceTools=serviceTools;
482    }
483   
484    public void setPlotService(final PlotService plotService)
485    {
486        _plotService=plotService;
487    }
488
489    private static final String VIEW_INSTRUMENT = "instrument";
490    private static final String VIEW_STATION = "station";
491    private static final String VIEW_LIDAR_O3S = "visus_lidar_o3s";
492    private static final String VIEW_LIDAR_O3T = "visus_lidar_o3t";
493    private static final String VIEW_ECC = "visus_ecc";
494    private static final String VIEW_SPECTRO_UV = "visus_spectro";
495    private static final String VIEW_LIDAR_TEMP = "visus_lidar_temp";
496    private static final String VIEW_LIDAR_AEROSOLS = "visus_lidar_aerosols";
497
498    //services que le controller peut utiliser
499    private StationService _stationService;
500    private InstrumentService _instrumentService;
501    private ServiceTools _serviceTools;
502    private PlotService _plotService;
503}
Note: See TracBrowser for help on using the repository browser.