package com.ether; import com.ether.annotation.ControllerMethod; import com.ether.annotation.ParamName; import com.ether.instrument.Instrument; import com.ether.station.Station; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Required; import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @author vmipsl * @date 17 feb 2011 */ public class Controller extends ControllerEther { /** *********************************************************** **/ /** *********************** VIEWS ***************************** **/ /** *********************************************************** **/ /** * Default view if url's methodName is unknown * * @return * @throws WebException */ @ControllerMethod(view = VIEW_INIT) public Map home() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_OHP) public Map viewDataOhp() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_ABOUT) public Map viewAbout() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_ECC) public Map selectEcc( @ParamName("dateinf") final String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException { try { final List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); String rep = ""; String year = dateinf.substring( 0, 4 ); if( station.compareTo( "OHP" ) == 0 || station.compareTo( "ohp" ) == 0 ) { rep = "./resources/visu/ohp/ecc"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) year = "2007"; } else if( station.compareTo( "LA REUNION" ) == 0 || station.compareTo( "reunion" ) == 0 ) { rep = "./resources/visu/reu/ecc"; //rep="./resources/visu/ohp/lidar/o3_strato"; station = "LA REUNION"; if( year.compareTo( "1970" ) == 0 ) year = "2006"; //year="2006"; } else if( station.compareTo( "DDU" ) == 0 || station.compareTo( "ddu" ) == 0 ) { rep = "./resources/visu/ddu/ecc"; //rep="./resources/visu/ohp/lidar/o3_strato"; station = "DDU"; if( year.compareTo( "1970" ) == 0 ) year = "1991"; //year="2006"; } final Map model = new HashMap(); model.put( "plotsList", plotsList ); model.put( "listeDates", listeDates ); model.put( "firstDate", dateinf ); final String month = dateinf.substring( 4, 6 ); model.put( "month", month ); model.put( "year", year ); model.put( "station", station ); model.put( "rep", rep ); return model; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView viewLidarO3s( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { final List listeDates = _serviceTools.getListeDates(); final ModelAndView modelAndView = new ModelAndView( VIEW_LIDAR_O3S ); modelAndView.addObject( "listeDates", listeDates ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView selectLidarO3s( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { String dateinf = request.getParameter( "dateinf" ); String station = request.getParameter( "station" ); final String instrument = request.getParameter( "instrument" ); List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); String rep = ""; String year = dateinf.substring( 0, 4 ); String month = dateinf.substring( 4, 6 ); if( station.compareTo( "OHP" ) == 0 || station.compareTo( "ohp" ) == 0 ) { rep = "./resources/visu/ohp/lidar/o3_strato"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "1991"; } } else if( station.compareTo( "REU" ) == 0 || station.compareTo( "reu" ) == 0 || station.compareTo( "LA REUNION" ) == 0 || station.compareTo( "REUNION" ) == 0 ) { rep = "./resources/visu/reu/lidar/o3_strato"; station = "LA REUNION"; if( year.compareTo( "1970" ) == 0 ) year = "2006"; //year="2006"; } else { rep = "./resources/visu/ddu/lidar/o3_strato"; station = "DDU"; if( year.compareTo( "1970" ) == 0 ) { year = "1991"; //month="04"; } //year="2006"; } final ModelAndView modelAndView = new ModelAndView( VIEW_LIDAR_O3S ); //plotsList=null; modelAndView.addObject( "plotsList", plotsList ); modelAndView.addObject( "listeDates", listeDates ); modelAndView.addObject( "firstDate", dateinf ); modelAndView.addObject( "month", month ); modelAndView.addObject( "year", year ); modelAndView.addObject( "station", station ); modelAndView.addObject( "rep", rep ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView selectLidarO3t( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { String dateinf = request.getParameter( "dateinf" ); String station = request.getParameter( "station" ); final String instrument = request.getParameter( "instrument" ); List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); String rep = ""; String year = dateinf.substring( 0, 4 ); String month = dateinf.substring( 4, 6 ); if( station.compareTo( "OHP" ) == 0 || station.compareTo( "ohp" ) == 0 ) { rep = "./resources/visu/ohp/lidar/o3_tropo"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "2007"; month = "05"; dateinf = year + month + "01"; } } //else if (station.compareTo("reunion")==0) { else { rep = "./resources/visu/reu/lidar/o3_tropo"; //rep="./resources/visu/ohp/lidar/o3_strato"; station = "LA REUNION"; if( year.compareTo( "1970" ) == 0 ) { year = "2006"; } //year="2006"; } final ModelAndView modelAndView = new ModelAndView( VIEW_LIDAR_O3T ); //plotsList=null; modelAndView.addObject( "plotsList", plotsList ); modelAndView.addObject( "listeDates", listeDates ); modelAndView.addObject( "firstDate", dateinf ); //String month = dateinf.substring(4,6); modelAndView.addObject( "month", month ); modelAndView.addObject( "year", year ); modelAndView.addObject( "station", station ); modelAndView.addObject( "rep", rep ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView selectLidarTemp( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { String dateinf = request.getParameter( "dateinf" ); String station = request.getParameter( "station" ); final String instrument = request.getParameter( "instrument" ); List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); String rep = ""; String year = dateinf.substring( 0, 4 ); String month = dateinf.substring( 4, 6 ); if( station.compareTo( "OHP" ) == 0 || station.compareTo( "ohp" ) == 0 ) { rep = "./resources/visu/ohp/lidar/temp"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "2009"; month = "01"; } } if( station.compareTo( "REU" ) == 0 || station.compareTo( "reu" ) == 0 ) { rep = "./resources/visu/reu/lidar/temp"; station = "REU"; if( year.compareTo( "1970" ) == 0 ) { year = "1994"; month = "05"; } } final ModelAndView modelAndView = new ModelAndView( VIEW_LIDAR_TEMP ); //plotsList=null; modelAndView.addObject( "plotsList", plotsList ); modelAndView.addObject( "listeDates", listeDates ); modelAndView.addObject( "firstDate", dateinf ); //String month = dateinf.substring(4,6); modelAndView.addObject( "month", month ); modelAndView.addObject( "year", year ); modelAndView.addObject( "station", station ); modelAndView.addObject( "rep", rep ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView selectLidarAerosols( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { String dateinf = request.getParameter( "dateinf" ); String station = request.getParameter( "station" ); final String instrument = request.getParameter( "instrument" ); List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); String rep = ""; String year = dateinf.substring( 0, 4 ); String month = dateinf.substring( 4, 6 ); if( station.compareTo( "OHP" ) == 0 || station.compareTo( "ohp" ) == 0 ) { rep = "./resources/visu/ohp/lidar/aerosols"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "2009"; month = "01"; } } if( station.compareTo( "DDU" ) == 0 || station.compareTo( "ddu" ) == 0 ) { rep = "./resources/visu/ddu/lidar/aerosols"; station = "DDU"; if( year.compareTo( "1970" ) == 0 ) { year = "2010"; month = "01"; } } final ModelAndView modelAndView = new ModelAndView( VIEW_LIDAR_AEROSOLS ); //plotsList=null; modelAndView.addObject( "plotsList", plotsList ); modelAndView.addObject( "listeDates", listeDates ); modelAndView.addObject( "firstDate", dateinf ); //String month = dateinf.substring(4,6); modelAndView.addObject( "month", month ); modelAndView.addObject( "year", year ); modelAndView.addObject( "station", station ); modelAndView.addObject( "rep", rep ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView viewSpectroUV( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { String dateinf = request.getParameter( "dateinf" ); //List m = new ArrayList(12); String m[]; m = new String[12]; String fname, iname, year; final String instrument = request.getParameter( "instrument" ); String especes = request.getParameter( "especes" ); if( especes.equals( "nan" ) ) { especes = "uvauvb"; } if( dateinf.equals( "nan" ) ) { year = "2008"; dateinf = "2008"; } List plotsList = _plotService.getPlotsByDateByInstrument( instrument, dateinf, "yyyy" ); final List listeDates = _serviceTools.getListeDates(); final ModelAndView modelAndView = new ModelAndView( VIEW_SPECTRO_UV ); modelAndView.addObject( "plotsList", plotsList ); modelAndView.addObject( "listeDates", listeDates ); modelAndView.addObject( "firstDate", dateinf ); modelAndView.addObject( "especes", especes ); year = dateinf.substring( 0, 4 ); modelAndView.addObject( "year", year ); modelAndView.addObject( "m", m ); fname = "vasp_"; fname = fname.concat( especes ); fname = fname.concat( "_" ); fname = fname.concat( year ); iname = fname.concat( "01_plot1.jpg" ); if( plotsList.contains( iname ) ) m[0] = iname; else m[0] = "no"; iname = fname.concat( "02_plot1.jpg" ); if( plotsList.contains( iname ) ) m[1] = iname; else m[1] = "no"; iname = fname.concat( "03_plot1.jpg" ); if( plotsList.contains( iname ) ) m[2] = iname; else m[2] = "no"; iname = fname.concat( "04_plot1.jpg" ); if( plotsList.contains( iname ) ) m[3] = iname; else m[3] = "no"; iname = fname.concat( "05_plot1.jpg" ); if( plotsList.contains( iname ) ) m[4] = iname; else m[4] = "no"; iname = fname.concat( "06_plot1.jpg" ); if( plotsList.contains( iname ) ) m[5] = iname; else m[5] = "no"; iname = fname.concat( "07_plot1.jpg" ); if( plotsList.contains( iname ) ) m[6] = iname; else m[6] = "no"; iname = fname.concat( "08_plot1.jpg" ); if( plotsList.contains( iname ) ) m[7] = iname; else m[7] = "no"; iname = fname.concat( "09_plot1.jpg" ); if( plotsList.contains( iname ) ) m[8] = iname; else m[8] = "no"; iname = fname.concat( "10_plot1.jpg" ); if( plotsList.contains( iname ) ) m[9] = iname; else m[9] = "no"; iname = fname.concat( "11_plot1.jpg" ); if( plotsList.contains( iname ) ) m[10] = iname; else m[10] = "no"; iname = fname.concat( "12_plot1.jpg" ); if( plotsList.contains( iname ) ) m[11] = iname; else m[11] = "no"; return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView viewInstruments( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { final List instruments = _instrumentService.getAllInstruments(); final ModelAndView modelAndView = new ModelAndView( VIEW_INSTRUMENT ); modelAndView.addObject( "instruments", instruments ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } public ModelAndView viewStation( final HttpServletRequest request, final HttpServletResponse response ) throws WebException { try { final Long stationId = Long.valueOf( request.getParameter( "stationId" ) ); final Station station = _stationService.getStationById( stationId ); final ModelAndView modelAndView = new ModelAndView( VIEW_STATION ); modelAndView.addObject( "station", station ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @Required public void setStationService( final StationService stationService ) { _stationService = stationService; } @Required public void setInstrumentService( final InstrumentService instrumentService ) { _instrumentService = instrumentService; } @Required public void setServiceTools( final ServiceTools serviceTools ) { _serviceTools = serviceTools; } @Required public void setPlotService( final PlotService plotService ) { _plotService = plotService; } private static final Log LOGGER = LogFactory.getLog( Controller.class ); private static final String VIEW_INIT = "init"; private static final String VIEW_INSTRUMENT = "instrument"; private static final String VIEW_STATION = "station"; private static final String VIEW_LIDAR_O3S = "visus_lidar_o3s"; private static final String VIEW_LIDAR_O3T = "visus_lidar_o3t"; private static final String VIEW_ECC = "visus_ecc"; private static final String VIEW_SPECTRO_UV = "visus_spectro"; private static final String VIEW_LIDAR_TEMP = "visus_lidar_temp"; private static final String VIEW_LIDAR_AEROSOLS = "visus_lidar_aerosols"; private static final String VIEW_DATA_OHP = "data_ohp"; private static final String VIEW_ABOUT = "about"; //services que le controller peut utiliser private StationService _stationService; private InstrumentService _instrumentService; private ServiceTools _serviceTools; private PlotService _plotService; }