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_DATA_OPAR) public Map viewDataOpar() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_DDU) public Map viewDataDdu() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_OMP) public Map viewDataOmp() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_VDA) public Map viewDataVda() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_BRI) public Map viewDataBri() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_SCO) public Map viewDataSco() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_AND) public Map viewDataAnd() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_SOD) public Map viewDataSod() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_ZHI) public Map viewDataZhi() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_SAL) public Map viewDataSal() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_BOR) public Map viewDataBor() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_TAR) public Map viewDataTar() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_BAU) public Map viewDataBau() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_KER) public Map viewDataKer() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_RIO) public Map viewDataRio() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_DATA_CON) public Map viewDataCon() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_BIBLIO) public Map viewBiblio() throws WebException { return new HashMap(); } @ControllerMethod(view = VIEW_INTRA) public Map viewIntra() 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 ); } } @ControllerMethod(view = VIEW_ECC_RT) public Map selectEccRT( @ParamName("dateinf") String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument, @ParamName("type") final String type ) throws WebException { try { 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/ecc"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "2012"; month = "01"; } } 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"; } dateinf=year+month+"01"; final List plotsList = _plotService.getPlotsByDateByInstrumentByStationByType( instrument, dateinf, "yyyyMMdd", station, type ); //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); final List listeDates = _serviceTools.getListeDates(); final Map model = new HashMap(); model.put( "plotsList", plotsList ); model.put( "listeDates", listeDates ); model.put( "firstDate", dateinf ); model.put( "month", month ); model.put( "year", year ); model.put( "station", station ); // model.put( "dateinf", dateinf ); 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 ); } } @ControllerMethod(view = VIEW_LIDAR_O3S) public Map selectLidarO3s( @ParamName("dateinf") final String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException /*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 = "DDUModelAndView"; if( year.compareTo( "1970" ) == 0 ) { year = "1991"; //month="04"; } //year="2006"; } final Map modelAndView = new HashMap(); //plotsList=null; modelAndView.put( "plotsList", plotsList ); modelAndView.put( "listeDates", listeDates ); modelAndView.put( "firstDate", dateinf ); modelAndView.put( "month", month ); modelAndView.put( "year", year ); modelAndView.put( "station", station ); modelAndView.put( "rep", rep ); return modelAndView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @ControllerMethod(view = VIEW_LIDAR_O3T) public Map selectLidarO3t( @ParamName("dateinf") String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException { try { 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 Map mView = new HashMap(); //plotsList=null; mView.put( "plotsList", plotsList ); mView.put( "listeDates", listeDates ); mView.put( "firstDate", dateinf ); //String month = dateinf.substring(4,6); mView.put( "month", month ); mView.put( "year", year ); mView.put( "station", station ); mView.put( "rep", rep ); return mView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @ControllerMethod(view = VIEW_UMK) public Map selectUmk( @ParamName("dateinf") String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException { try { //dateinf="02021980"; //List ListDates = _plotService.getLastDate(instrument); String rep = ""; String year = dateinf.substring( 0, 4 ); String month = dateinf.substring( 4, 6 ); rep = "./resources/visu/ohp/umk"; station = "OHP"; if( year.compareTo( "1970" ) == 0 ) { year = "1983"; month = "09"; dateinf = year + month + "03"; } // dateinf="20120101"; dateinf=year+month+"01"; List plotsList = _plotService.getPlotsByDateByInstrumentByStation( instrument, dateinf, "yyyyMMdd", station ); final List listeDates = _serviceTools.getListeDates(); final Map model = new HashMap(); model.put( "plotsList", plotsList ); final Map mView = new HashMap(); //plotsList=null; mView.put( "plotsList", plotsList ); mView.put( "listeDates", listeDates ); mView.put( "firstDate", dateinf ); //String month = dateinf.substring(4,6); mView.put( "month", month ); mView.put( "year", year ); mView.put( "station", station ); mView.put( "rep", rep ); return mView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @ControllerMethod(view = VIEW_LIDAR_TEMP) public Map selectLidarTemp( @ParamName("dateinf") String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException { try { 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 Map mView = new HashMap(); mView.put( "plotsList", plotsList ); mView.put( "listeDates", listeDates ); mView.put( "firstDate", dateinf ); mView.put( "month", month ); mView.put( "year", year ); mView.put( "station", station ); mView.put( "rep", rep ); return mView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @ControllerMethod(view = VIEW_LIDAR_AEROSOLS) public Map selectLidarAerosols( @ParamName("dateinf") String dateinf, @ParamName("station") String station, @ParamName("instrument") final String instrument ) throws WebException { try { 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 = "11"; } } final Map mView = new HashMap(); //plotsList=null; mView.put( "plotsList", plotsList ); mView.put( "listeDates", listeDates ); mView.put( "firstDate", dateinf ); //String month = dateinf.substring(4,6); mView.put( "month", month ); mView.put( "year", year ); mView.put( "station", station ); mView.put( "rep", rep ); return mView; } catch( ServiceException e ) { throw new WebException( WebException.WebCode.SERVICE_PROBLEM, e ); } } @ControllerMethod(view =VIEW_SPECTRO_UV) public Map viewSpectroUV( @ParamName("dateinf") String dateinf, @ParamName("especes") String especes, @ParamName("instrument") final String instrument ) throws WebException { try { String m[]; m = new String[12]; String fname, iname, year; 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 Map mView = new HashMap(); mView.put( "plotsList", plotsList ); mView.put( "listeDates", listeDates ); mView.put( "firstDate", dateinf ); mView.put( "especes", especes ); year = dateinf.substring( 0, 4 ); mView.put( "year", year ); mView.put( "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 mView; } 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_UMK = "visus_umk"; private static final String VIEW_ECC = "visus_ecc"; private static final String VIEW_ECC_RT = "visus_ecc_realtime"; 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"; private static final String VIEW_DATA_OPAR = "data_opar"; private static final String VIEW_DATA_DDU = "data_ddu"; private static final String VIEW_DATA_OMP = "data_lannemezan"; private static final String VIEW_DATA_VDA = "data_villeneuve"; private static final String VIEW_DATA_BRI = "data_briancon"; private static final String VIEW_DATA_SCO = "data_scorebysund"; private static final String VIEW_DATA_AND = "data_andoya"; private static final String VIEW_DATA_SOD = "data_sodankyla"; private static final String VIEW_DATA_ZHI = "data_zhigansk"; private static final String VIEW_DATA_SAL = "data_salekhard"; private static final String VIEW_DATA_BOR = "data_bordeaux"; private static final String VIEW_DATA_TAR = "data_tarawa"; private static final String VIEW_DATA_BAU = "data_bauru"; private static final String VIEW_DATA_KER = "data_kerguelen"; private static final String VIEW_DATA_RIO = "data_riogallegos"; private static final String VIEW_DATA_CON = "data_concordia"; private static final String VIEW_BIBLIO = "biblio"; private static final String VIEW_INTRA = "community"; //services que le controller peut utiliser private StationService _stationService; private InstrumentService _instrumentService; private ServiceTools _serviceTools; private PlotService _plotService; }