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

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

Import du projet NDACC _ module web

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