Changeset 213


Ignore:
Timestamp:
10/03/11 15:05:25 (13 years ago)
Author:
vmipsl
Message:

download

Location:
ether_megapoli/trunk
Files:
1 deleted
19 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ether_megapoli/trunk/common/implementation/com/ether/EtherHelper.java

    r195 r213  
    33import org.apache.commons.lang.ArrayUtils; 
    44import org.jetbrains.annotations.NotNull; 
     5import org.jetbrains.annotations.Nullable; 
    56 
    67import java.util.ArrayList; 
     
    1415public abstract class EtherHelper 
    1516{ 
     17    /** 
     18     * This method returns the list with the firts values of a list of <Pair> 
     19     * 
     20     * @param pairList 
     21     * @return 
     22     */ 
     23    @NotNull 
     24    public static <T1, T2> List getFirstValues( @NotNull final List<Pair<T1, T2>> pairList ) 
     25    { 
     26        final List firstValues = new ArrayList<T1>( pairList.size() ); 
     27        for( final Pair pair : pairList ) 
     28            firstValues.add( pair.getFirstValue() ); 
     29 
     30        return firstValues; 
     31    } 
     32 
    1633    /** 
    1734     * This method returns the list with the second values of a list of <Pair> 
     
    4461    } 
    4562 
     63    // TODO : supprimer cette méthode et utiliser JSON pour récupérer pIdPIdList 
     64    @Nullable 
     65    public static List<Pair<Integer, Integer>> extractpfIdPIdListFromString( @NotNull final String pfIdPIdArrayString ) 
     66    { 
     67        if( pfIdPIdArrayString.isEmpty() ) 
     68            return null; 
     69 
     70        final String[] pfIDPIdArray = pfIdPIdArrayString.split( "," ); 
     71        final List<Pair<Integer, Integer>> pfIdPIdList = new ArrayList<Pair<Integer, Integer>>( pfIDPIdArray.length ); 
     72        for( final String pfIdPId : pfIDPIdArray ) 
     73        { 
     74            final String[] pfIdPIdSplit = pfIdPId.split( "-" ); 
     75            final Pair<Integer, Integer> pfIdPIdPair = new Pair<Integer, Integer>(); 
     76            pfIdPIdPair.setFirstValue( Integer.valueOf( pfIdPIdSplit[0] ) ); 
     77            pfIdPIdPair.setSecondValue( Integer.valueOf( pfIdPIdSplit[1] ) ); 
     78            pfIdPIdList.add( pfIdPIdPair ); 
     79        } 
     80        return pfIdPIdList; 
     81    } 
     82 
     83 
    4684} 
  • ether_megapoli/trunk/common/implementation/com/ether/MethodDescription.java

    r89 r213  
    1717        _view = annotation.view(); 
    1818        _isJsonResult = annotation.jsonResult(); 
     19        _isLoginMandatory = annotation.loginMandatory(); 
    1920        _params = new ArrayList<ParamDescription>(); 
    2021    } 
     
    6465    } 
    6566 
     67    public Boolean isLoginMandatory() 
     68    { 
     69        return _isLoginMandatory; 
     70    } 
     71 
     72    public void setLoginMandatory( final Boolean loginMandatory ) 
     73    { 
     74        _isLoginMandatory = loginMandatory; 
     75    } 
     76 
    6677    @NotNull 
    6778    private Method _method; 
     
    7182    @Nullable 
    7283    private List<ParamDescription> _params; 
     84    private Boolean _isLoginMandatory; 
    7385} 
  • ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java

    r129 r213  
    11package com.ether; 
    22 
    3 public abstract class ParameterConstants { 
    4          public static final String PARAMETER_ID = "id"; 
    5          public static final String PARAMETER_DATE = "date"; 
    6          public static final String PARAMETER_CODE = "code"; 
    7          public static final String PARAMETER_NAME = "name"; 
    8          public static final String PARAMETER_PARAMETERS = "parameters"; 
    9          public static final String PARAMETER_PLATEFORM_ID = "plateformId"; 
    10          public static final String PARAMETER_PARAMETER_ID = "parameterId";       
    11          public static final String PARAMETER_DATE_BEGIN = "dateBegin"; 
    12          public static final String PARAMETER_DATE_END = "dateEnd"; 
    13          public static final String PARAMETER_VALUES = "values"; 
     3public abstract class ParameterConstants 
     4{ 
     5    public static final String PARAMETER_ID = "id"; 
     6    public static final String PARAMETER_DATE = "date"; 
     7    public static final String PARAMETER_CODE = "code"; 
     8    public static final String PARAMETER_NAME = "name"; 
     9    public static final String PARAMETER_TITLE = "title"; 
     10    public static final String PARAMETER_AXE_TYPE = "axeType"; 
     11    public static final String PARAMETER_PARAMETERS = "parameters"; 
     12    public static final String PARAMETER_PLATEFORM_ID = "plateformId"; 
     13    public static final String PARAMETER_PARAMETER_ID = "parameterId"; 
     14    public static final String PARAMETER_DATE_BEGIN = "dateBegin"; 
     15    public static final String PARAMETER_DATE_END = "dateEnd"; 
     16    public static final String PARAMETER_VALUES = "values"; 
    1417    public static final String PARAMETER_IMAGE = "encodedImage"; 
     18    public static final String PARAMETER_PERSONNE = "personne"; 
     19    public static final String PARAMETER_PFID_PID_LIST = "pfIdPIdList"; 
    1520} 
  • ether_megapoli/trunk/common/implementation/com/ether/annotation/ControllerMethod.java

    r89 r213  
    1717        @NotNull 
    1818    boolean jsonResult() default false; 
     19 
     20    @NotNull 
     21    boolean loginMandatory() default false; 
    1922} 
  • ether_megapoli/trunk/common/implementation/com/ether/annotation/LoginMandatory.java

    r119 r213  
    11package com.ether.annotation; 
    22 
     3import java.lang.annotation.ElementType; 
    34import java.lang.annotation.Retention; 
    45import java.lang.annotation.RetentionPolicy; 
    56import java.lang.annotation.Target; 
    6 import java.lang.annotation.ElementType; 
    77 
    88@Retention(RetentionPolicy.RUNTIME) 
    99@Target(ElementType.PARAMETER) 
    10 public @interface Mandatory 
     10public @interface LoginMandatory 
    1111{ 
    1212} 
  • ether_megapoli/trunk/common/implementation/com/medias/Context.java

    r139 r213  
    1616 * Date: 27 janv. 2005 
    1717 * Time: 15:45:10 
    18  * 
     18 * <p/> 
    1919 * Permet d'accéder au contexte courant pour chaque page de l'appli 
    2020 */ 
     
    2626 
    2727 
    28         /** 
    29          * Permet d'obtenir la langue courante. 
    30          * @param request : la requête courante 
    31          * @return la langue courante. 
    32          */ 
    33         public static String getLangue(HttpServletRequest request) { 
    34                 String lang=(String) request.getSession().getAttribute("lang"); 
    35                 if (lang == null) { 
    36                     // Pour initialiser la langue en Anglais 
    37                     lang=request.getLocale().getLanguage(); 
    38                      
    39                     // Pour initialiser la langue en Français 
    40                     //lang = Locale.FRENCH.getLanguage(); 
    41                 } 
    42                 return lang; 
    43         } 
     28    /** 
     29     * Permet d'obtenir la langue courante. 
     30     * 
     31     * @param request : la requête courante 
     32     * @return la langue courante. 
     33     */ 
     34    public static String getLangue( HttpServletRequest request ) 
     35    { 
     36        String lang = (String) request.getSession().getAttribute( "lang" ); 
     37        if( lang == null ) 
     38        { 
     39            // Pour initialiser la langue en Anglais 
     40            lang = request.getLocale().getLanguage(); 
     41 
     42            // Pour initialiser la langue en Français 
     43            //lang = Locale.FRENCH.getLanguage(); 
     44        } 
     45        return lang; 
     46    } 
    4447 
    4548    /** 
     
    6265    } 
    6366 
    64         public static String getLastModified(HttpServletRequest request, 
    65                                              javax.servlet.ServletContext application) { 
    66                 Date d =new java.util.Date(new java.io.File( 
    67                     application.getRealPath(request.getServletPath())).lastModified()); 
    68                 return DateTime.dateToString(d,DateTime.formatDateStandard); 
    69         } 
     67    public static String getLastModified( HttpServletRequest request, 
     68                                          javax.servlet.ServletContext application ) 
     69    { 
     70        Date d = new java.util.Date( new java.io.File( 
     71                application.getRealPath( request.getServletPath() ) ).lastModified() ); 
     72        return DateTime.dateToString( d, DateTime.formatDateStandard ); 
     73    } 
    7074 
    71         /** 
    72          * Permet d'obtenir la date courante, sous la forme YYYYMMDD 
    73          * @return la date courante 
    74          */ 
    75         public static String getSimpleDate() { 
    76                 java.util.Calendar c = java.util.Calendar.getInstance(); 
    77                 String t= "0"+(c.get(Calendar.MONTH)+1); 
    78                 return c.get(Calendar.YEAR)+t.substring(t.length()-2)+c.get(Calendar.DAY_OF_MONTH); 
    79         } 
     75    /** 
     76     * Permet d'obtenir la date courante, sous la forme YYYYMMDD 
     77     * 
     78     * @return la date courante 
     79     */ 
     80    public static String getSimpleDate() 
     81    { 
     82        java.util.Calendar c = java.util.Calendar.getInstance(); 
     83        String t = "0" + ( c.get( Calendar.MONTH ) + 1 ); 
     84        return c.get( Calendar.YEAR ) + t.substring( t.length() - 2 ) + c.get( Calendar.DAY_OF_MONTH ); 
     85    } 
    8086 
    81         /** 
    82          * Désigne l'adresse mail du webmaster 
    83          */ 
    84         public static String getWebmaster(HttpServletRequest request) { 
    85                 String webmaster = (String)request.getSession().getServletContext().getAttribute("APP_WEBMASTER"); 
    86                 return webmaster; 
    87         } 
    88          
    89         /** 
    90          * Permet de définir le nom de la racine à partir de laquelle les paths sont calculés. 
    91          * @return le nom de la racine. 
    92          */ 
    93         public static String getWebroot(HttpServletRequest request) { 
    94                 String path = request.getSession().getServletContext().getRealPath(""); 
    95                 return path.substring(path.lastIndexOf("/")+1); 
    96         } 
     87    /** 
     88     * Désigne l'adresse mail du webmaster 
     89     */ 
     90    public static String getWebmaster( HttpServletRequest request ) 
     91    { 
     92        String webmaster = (String) request.getSession().getServletContext().getAttribute( "APP_WEBMASTER" ); 
     93        return webmaster; 
     94    } 
    9795 
    98         /** 
    99          * Permet d'obtenir l'uri de la page courante. 
    100          * @param request : la requête courante 
    101          * @return l'uri de la page courante 
    102          */ 
    103   public static String getPageURI(HttpServletRequest request) { 
    104           return request.getRequestURI().substring(request.getRequestURI().indexOf('/')+1); 
    105   } 
     96    /** 
     97     * Permet de définir le nom de la racine à partir de laquelle les paths sont calculés. 
     98     * 
     99     * @return le nom de la racine. 
     100     */ 
     101    public static String getWebroot( HttpServletRequest request ) 
     102    { 
     103        String path = request.getSession().getServletContext().getRealPath( "" ); 
     104        return path.substring( path.lastIndexOf( "/" ) + 1 ); 
     105    } 
    106106 
    107         /** 
    108          * Permet d'obtenir l'URI relative de la page courante. 
    109          * Cette méthode est en particulier utilisée pour retomber sur la page courante lorsqu'on 
    110          * change de langue. 
    111          * @param request 
    112          * @return 
    113          */ 
    114         public static String getRelativePageURI(HttpServletRequest request) { 
    115                 String pageUri = getPageURI(request); 
    116                 if (pageUri.indexOf('/') != -1) { 
    117                     pageUri = pageUri.substring(pageUri.indexOf('/')); 
     107    /** 
     108     * Permet d'obtenir l'uri de la page courante. 
     109     * 
     110     * @param request : la requête courante 
     111     * @return l'uri de la page courante 
     112     */ 
     113    public static String getPageURI( HttpServletRequest request ) 
     114    { 
     115        return request.getRequestURI().substring( request.getRequestURI().indexOf( '/' ) + 1 ); 
     116    } 
     117 
     118    /** 
     119     * Permet d'obtenir l'URI relative de la page courante. 
     120     * Cette méthode est en particulier utilisée pour retomber sur la page courante lorsqu'on 
     121     * change de langue. 
     122     * 
     123     * @param request 
     124     * @return 
     125     */ 
     126    public static String getRelativePageURI( HttpServletRequest request ) 
     127    { 
     128        String pageUri = getPageURI( request ); 
     129        if( pageUri.indexOf( '/' ) != -1 ) 
     130        { 
     131            pageUri = pageUri.substring( pageUri.indexOf( '/' ) ); 
    118132        } 
    119                 return pageUri; 
    120         } 
     133        return pageUri; 
     134    } 
    121135 
     136    /** 
     137     * This method returns the name of the context 
     138     * 
     139     * @param request 
     140     * @return 
     141     */ 
     142    public static String getContextPath( final HttpServletRequest request ) 
     143    { 
     144        return request.getContextPath(); 
     145    } 
    122146 
    123         public static String getRelativePath(HttpServletRequest request) { 
    124                 String uri = getPageURI(request); 
    125                 if (uri.indexOf('/') != -1) { 
    126                     uri = uri.substring(uri.indexOf('/'),uri.lastIndexOf('/')); 
    127                 } 
    128                 return uri; 
    129         } 
    130          
    131         public static String getAnInternationalizeString(String bundle, String key) { 
    132                 ResourceBundle resourceBundle = null; 
    133                 String lang = Constantes.lang; 
    134                 String message = null; 
    135                 if (lang.trim().equals("en")) { 
    136                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.ENGLISH); 
    137                         message = resourceBundle.getString(key); 
    138                 } else { 
    139                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.FRENCH); 
    140                         message = resourceBundle.getString(key); 
    141                 } 
    142                 if (message == null) { 
    143                         resourceBundle = ResourceBundle.getBundle(bundle, Locale.FRENCH); 
    144                         message = resourceBundle.getString(key); 
    145                 } 
    146                 return message; 
    147         } 
    148          
    149         public static String getString(String bundle, String key) { 
    150                 ResourceBundle resourceBundle = ResourceBundle.getBundle(bundle); 
    151                 String message = resourceBundle.getString(key); 
    152                 return message; 
    153         } 
     147    public static String getRelativePath( HttpServletRequest request ) 
     148    { 
     149        String uri = getPageURI( request ); 
     150        if( uri.indexOf( '/' ) != -1 ) 
     151        { 
     152            uri = uri.substring( uri.indexOf( '/' ), uri.lastIndexOf( '/' ) ); 
     153        } 
     154        return uri; 
     155    } 
     156 
     157    public static String getAnInternationalizeString( String bundle, String key ) 
     158    { 
     159        ResourceBundle resourceBundle = null; 
     160        String lang = Constantes.lang; 
     161        String message = null; 
     162        if( lang.trim().equals( "en" ) ) 
     163        { 
     164            resourceBundle = ResourceBundle.getBundle( bundle, Locale.ENGLISH ); 
     165            message = resourceBundle.getString( key ); 
     166        } 
     167        else 
     168        { 
     169            resourceBundle = ResourceBundle.getBundle( bundle, Locale.FRENCH ); 
     170            message = resourceBundle.getString( key ); 
     171        } 
     172        if( message == null ) 
     173        { 
     174            resourceBundle = ResourceBundle.getBundle( bundle, Locale.FRENCH ); 
     175            message = resourceBundle.getString( key ); 
     176        } 
     177        return message; 
     178    } 
     179 
     180    public static String getString( String bundle, String key ) 
     181    { 
     182        ResourceBundle resourceBundle = ResourceBundle.getBundle( bundle ); 
     183        String message = resourceBundle.getString( key ); 
     184        return message; 
     185    } 
    154186} 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java

    r197 r213  
    8080        final double yend = ysize - ystart; 
    8181 
    82         final Pair<List, List> listPairOfPIdPIdForTwoAxes = extractListPairForAxes( megapoliPlot.getpIdPIdList() ); 
     82        final Pair<List, List> listPairOfPIdPIdForTwoAxes = extractListPairForAxes( megapoliPlot.getPfIdPIdList() ); 
    8383        final List<Pair> pIdPIdListForFirstAxis = listPairOfPIdPIdForTwoAxes.getFirstValue(); 
    8484        final List<Pair> pIdPIdListForSecondAxis = listPairOfPIdPIdForTwoAxes.getSecondValue(); 
     
    206206 
    207207        // Create the legend 
    208         final Pair<Integer, Integer> pIdPId = (Pair<Integer, Integer>) megapoliPlot.getpIdPIdList().get( 0 ); 
     208        final Pair<Integer, Integer> pIdPId = (Pair<Integer, Integer>) megapoliPlot.getPfIdPIdList().get( 0 ); 
    209209        final Integer parameterId = pIdPId.getSecondValue(); 
    210210 
     
    459459     * The second list can be empty, in this case, only one axis is needed 
    460460     * 
    461      * @param pIdPIdList 
    462      * @return 
    463      */ 
    464     @NotNull 
    465     private Pair<List, List> extractListPairForAxes( @NotNull final List<Pair> pIdPIdList ) 
     461     * @param pfIdPIdList 
     462     * @return 
     463     */ 
     464    @NotNull 
     465    private Pair<List, List> extractListPairForAxes( @NotNull final List<Pair<Integer, Integer>> pfIdPIdList ) 
    466466    { 
    467467        final List<Pair<Integer, Integer>> pIdPIdListForFirstAxis = new ArrayList<Pair<Integer, Integer>>(); 
    468468        final List<Pair<Integer, Integer>> pIdPIdListForSecondAxis = new ArrayList<Pair<Integer, Integer>>(); 
    469469 
    470         for( final Pair pIdPId : pIdPIdList ) 
     470        for( final Pair pIdPId : pfIdPIdList ) 
    471471        { 
    472472            final List<Integer> secondValuesForFirstAxis = EtherHelper.getSecondValues( pIdPIdListForFirstAxis ); 
     
    597597    protected static final int MAX_WIDTH = 800; 
    598598    protected static final int MAX_HEIGHT = 700; 
     599    protected static final int MAX_HEIGHT_TOP = 100; 
    599600    protected static final int MARGIN_LEFT_RIGHT = 50; 
    600601    protected static final int LEGEND_2D_HEIGHT = 150; 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java

    r196 r213  
    6868        jPane.add( jPaneTop, BorderLayout.NORTH ); 
    6969 
    70         final Integer valuesNumber = ( null != megapoliPlot.getValuesNumber() ) ? megapoliPlot.getValuesNumber() : getEtherService().getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.getpIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
     70        final Integer valuesNumber = ( null != megapoliPlot.getValuesNumber() ) ? megapoliPlot.getValuesNumber() : getEtherService().getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.getPfIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 
    7171 
    7272        // Bottom Pane 
     
    127127 
    128128        // Max height 
    129         final Integer maxHeights = Math.max( logoMegapoli.getIconHeight(), logoEther.getIconHeight() ); 
     129        final Integer maxHeights = Math.max( Math.max( logoMegapoli.getIconHeight(), logoEther.getIconHeight() ), MAX_HEIGHT_TOP ); 
    130130 
    131131        // jPane 
  • ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java

    r194 r213  
    134134    @NotNull 
    135135    @Transactional(readOnly = true) 
    136     public Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 
     136    public Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair<Integer, Integer>> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 
    137137            throws ServiceException 
    138138    { 
  • ether_megapoli/trunk/service/implementation/com/ether/MegapoliPlot.java

    r186 r213  
    101101 
    102102    @Nullable 
    103     public List<Pair> getpIdPIdList() 
     103    public List<Pair<Integer, Integer>> getPfIdPIdList() 
    104104    { 
    105         return _pIdPIdList; 
     105        return _pfIdPIdList; 
    106106    } 
    107107 
    108     public void setpIdPIdList( @Nullable final List<Pair> pIdPIdList ) 
     108    public void setPfIdPIdList( @Nullable final List<Pair<Integer, Integer>> pfIdPIdList ) 
    109109    { 
    110         _pIdPIdList = pIdPIdList; 
     110        _pfIdPIdList = pfIdPIdList; 
    111111    } 
    112112 
     
    153153    // List of <plateformId, parameterId> to display 
    154154    @Nullable 
    155     private List<Pair> _pIdPIdList; 
     155    private List<Pair<Integer, Integer>> _pfIdPIdList; 
    156156    @Nullable 
    157157    private Date _beginDate; 
  • ether_megapoli/trunk/service/interface/com/ether/EtherService.java

    r194 r213  
    4545 
    4646    @NotNull 
    47     Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 
     47    Integer getNumberValuesByPlateformByParameterByPeriod( @NotNull final List<Pair<Integer, Integer>> pairs, @Nullable final Date beginDate, @Nullable final Date endDate ) 
    4848            throws ServiceException; 
    4949} 
  • ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css

    r197 r213  
    106106 
    107107.textExamplesTD { 
     108    margin: 10px; 
    108109    color: #04155D; 
    109110    text-align: center; 
  • ether_megapoli/trunk/web/resources/templates/template2.jsp

    r200 r213  
    1515        <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 
    1616        <meta http-equiv="refresh" content="6; URL=./index.jsp"> 
    17         <link rel="stylesheet" type="text/css" href="<html:rewrite page='/styles/medias_new.css'/>"> 
    18         <link rel="stylesheet" type="text/css" href="<html:rewrite page='/styles/megapoli.css'/>"> 
    19         <link rel="shortcut icon" href="<html:rewrite page='/images/megapoli/favicon.ico'/>"> 
    20         <script src="<html:rewrite page='/scripts/maj.js'/>"></script> 
    21         <script src="<html:rewrite page='/scripts/ajax.js'/>"></script> 
    22         <script src="<html:rewrite page='/scripts/scw.js'/>"></script> 
     17        <link rel="stylesheet" type="text/css" href="<html:rewrite page='/resources/css/medias_new.css'/>"> 
     18        <link rel="stylesheet" type="text/css" href="<html:rewrite page='/resources/css/megapoli.css'/>"> 
     19        <link rel="shortcut icon" href="<html:rewrite page='/resources/images/megapoli/favicon.ico'/>"> 
     20        <script src="<html:rewrite page='/resources/js/maj.js'/>"></script> 
     21        <script src="<html:rewrite page='/resources/js/medias/ajax.js'/>"></script> 
     22        <script src="<html:rewrite page='/resources/js/medias/scw.js'/>"></script> 
    2323        <script type="text/javascript"> 
    2424        <!-- 
  • ether_megapoli/trunk/web/src/ApplicationResources.properties

    r199 r213  
    477477data.visualization.axeType.2DContour=2D (contour) 
    478478data.visualization.axeType.2DPoints=2D (points) 
     479data.authentification.text=Veuillez vous identifier en cliquant sur 'Acc\u00E8s aux donn\u00E9es' afin d'acc\u00E9der aux zones prot\u00E9g\u00E9es de ce site. 
    479480 
    480481simulation.visualization=Des simulations 
     
    488489plot.longitude=Longitude 
    489490plot.degres=Degr\u00E9s 
     491 
  • ether_megapoli/trunk/web/src/ApplicationResources_en.properties

    r199 r213  
    477477data.visualization.axeType.2DPoints=2D (dots) 
    478478 
     479data.authentification.text=Please login by click on 'Access to data' to access the protected areas of this website. 
     480 
    479481simulation.visualization=Simulations 
    480482 
  • ether_megapoli/trunk/web/src/com/ether/Controller.java

    r197 r213  
    44import com.ether.annotation.Mandatory; 
    55import com.ether.annotation.ParamName; 
     6import com.medias.annuaire.Personne; 
    67import com.medias.database.objects.Parametre; 
    78import com.medias.database.objects.Plateforme; 
     9import com.medias.megapoli.struts.forms.DatasForm; 
     10import com.medias.megapoli.utils.Requete; 
    811import net.sf.json.JSONObject; 
     12import org.apache.commons.lang.StringUtils; 
    913import org.apache.commons.logging.Log; 
    1014import org.apache.commons.logging.LogFactory; 
     15import org.jdom.Document; 
     16import org.jdom.output.XMLOutputter; 
    1117import org.jetbrains.annotations.NotNull; 
    1218import org.springframework.beans.factory.annotation.Required; 
     
    1521import javax.servlet.http.HttpServletRequest; 
    1622import javax.servlet.http.HttpServletResponse; 
     23import java.io.BufferedReader; 
     24import java.io.DataOutputStream; 
     25import java.io.InputStreamReader; 
     26import java.net.URL; 
     27import java.net.URLConnection; 
     28import java.net.URLEncoder; 
    1729import java.util.ArrayList; 
     30import java.util.Calendar; 
    1831import java.util.HashMap; 
    1932import java.util.List; 
     
    5164    { 
    5265        final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 
    53 //        final List<Plateforme> plateforms = BouchonHelper.createPlateforms(); 
    5466 
    5567        final Map<String, Object> model = new HashMap<String, Object>(); 
     
    5870        model.put( "axeTypesForMobilePlateforms", getJSONAxeTypesForMobilePlateforms() ); 
    5971        return model; 
     72    } 
     73 
     74    @ControllerMethod(view = VIEW_DOWNLOAD_OK, loginMandatory = true) 
     75    public Map<String, Object> downloadData( @ParamName(ParameterConstants.PARAMETER_DATE_BEGIN) final String dateBegin, 
     76                                             @ParamName(ParameterConstants.PARAMETER_DATE_END) final String dateEnd, 
     77                                             @ParamName(ParameterConstants.PARAMETER_PFID_PID_LIST) final String pIdPIdArrayString, 
     78                                             @NotNull final Personne personne ) 
     79            throws ServiceException, WebException 
     80    { 
     81        final List<Pair<Integer, Integer>> pfIdPIdList = EtherHelper.extractpfIdPIdListFromString( pIdPIdArrayString ); 
     82        if( null == pfIdPIdList ) 
     83            throw new WebException( WebException.WebCode.PLATEFORM_OR_PARAMETER_IS_NULL, null ); 
     84 
     85        final DatasForm datasForm = new DatasForm(); 
     86        datasForm.setOutput( FORMAT_DEFAULT ); 
     87        datasForm.setCompression( COMPRESSION_DEFAULT ); 
     88        final List<Integer> plateformIds = EtherHelper.getFirstValues( pfIdPIdList ); 
     89        final List<Integer> parameterIds = EtherHelper.getSecondValues( pfIdPIdList ); 
     90        final String plateformIdsString = StringUtils.join( plateformIds.iterator(), "," ); 
     91        final String parameterIdsString = StringUtils.join( parameterIds.iterator(), "," ); 
     92 
     93        final Calendar calendar = Calendar.getInstance(); 
     94        String formatedDateBegin = null; 
     95        String formatedDateEnd = null; 
     96        if( null != dateBegin && null != dateEnd && !"false".equals( dateBegin ) && !"false".equals( dateEnd ) ) 
     97            try 
     98            { 
     99                calendar.setTimeInMillis( Long.valueOf( dateBegin ) ); 
     100                formatedDateBegin = DateHelper.formatDate( calendar.getTime(), DateHelper.FRENCH_DATE_PATTERN_SHORT ); 
     101                calendar.setTimeInMillis( Long.valueOf( dateEnd ) ); 
     102                formatedDateEnd = DateHelper.formatDate( calendar.getTime(), DateHelper.FRENCH_DATE_PATTERN_SHORT ); 
     103            } 
     104            catch( Exception e ) 
     105            { 
     106                throw new WebException( WebException.WebCode.INVALID_DATE, e ); 
     107            } 
     108 
     109        final String datesString = StringUtils.join( new String[]{formatedDateBegin, formatedDateEnd}, "," ); 
     110 
     111        datasForm.setListePlats( plateformIdsString ); 
     112        datasForm.setListeParams( parameterIdsString ); 
     113        datasForm.setListeDates( datesString ); 
     114 
     115        final XMLOutputter outXml = new XMLOutputter(); 
     116        final Document docXml = Requete.toXml( datasForm, personne ); 
     117        final String requete = outXml.outputString( docXml ); 
     118        try 
     119        { 
     120            final String encoded = "requete=" + URLEncoder.encode( requete, "UTF-8" ); 
     121            // Configuration de l'URL 
     122            final String urlCGIStr = (String) this.getServletContext().getAttribute( "APP_CGI" ); 
     123            final URL urlCGI = new URL( urlCGIStr ); 
     124            final URLConnection conn = urlCGI.openConnection(); 
     125            conn.setDoOutput( true ); 
     126            conn.setUseCaches( false ); 
     127            conn.setRequestProperty( "content-type", "application/x-www-form-urlencoded" ); 
     128            // Envoi de la requête 
     129            final DataOutputStream out = new DataOutputStream( conn.getOutputStream() ); 
     130            out.writeBytes( encoded ); 
     131            out.flush(); 
     132            out.close(); 
     133 
     134            // Réponse du CGI 
     135            final BufferedReader in = new BufferedReader( new InputStreamReader( conn.getInputStream() ) ); 
     136            String aLine; 
     137            while( ( aLine = in.readLine() ) != null ) 
     138            { 
     139                if( aLine.length() == 0 ) continue; 
     140                if( aLine.startsWith( "1" ) ) 
     141                { 
     142                    System.err.println( "ERROR :" + aLine ); 
     143                } 
     144                else System.out.println( "REPONSE :" + aLine ); 
     145 
     146            } 
     147        } 
     148        catch( Exception e ) 
     149        { 
     150            e.printStackTrace(); 
     151        } 
     152 
     153        return new HashMap<String, Object>(); 
    60154    } 
    61155 
     
    70164    { 
    71165        final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 
    72 //        final List<Parametre> parametersByPlateform = BouchonHelper.createParameters( plateformId ); 
    73166 
    74167        final JSONObject result = new JSONObject(); 
     
    119212    private static final String VIEW_VISUALIZATION = "visualization/visu"; 
    120213    private static final String VIEW_VISUALIZATION_PARAMETER_BY_PLATEFORM = "visualization/visu_parameter_by_pf"; 
    121  
     214    private static final String VIEW_DOWNLOAD_OK = "data/access/extract3"; 
     215 
     216    private static final String FORMAT_DEFAULT = "NASA-AMES"; 
     217    private static final String COMPRESSION_DEFAULT = "None"; 
    122218    private EtherService _etherService; 
    123219} 
  • ether_megapoli/trunk/web/src/com/ether/ControllerEther.java

    r130 r213  
    55import com.ether.annotation.ParamName; 
    66import com.ether.annotation.UseJSON; 
     7import com.medias.annuaire.Personne; 
    78import net.sf.json.JSON; 
    89import net.sf.json.JSONArray; 
     
    4445        { 
    4546            if( !_initialized ) 
    46                 initialize(); 
     47            initialize(); 
    4748 
    4849            request.setCharacterEncoding( UTF8Charset.getEncoding() ); 
     
    8283            final Object[] params = buildParams( methodDescription, request ); 
    8384 
     85            if( methodDescription.isLoginMandatory() ) 
     86            { 
     87                final Personne pers = (Personne) request.getSession().getAttribute( "SES_USER" ); 
     88                params[params.length - 1] = pers; 
     89            } 
    8490            // Invoke method (go to controller) 
    8591            final Object result = methodDescription.getMethod().invoke( this, params ); 
  • ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java

    r199 r213  
    6060        try 
    6161        { 
    62             final String title = request.getParameter( "title" ); 
    63             final String axeType = request.getParameter( "axeType" ); 
     62            final String title = request.getParameter( ParameterConstants.PARAMETER_TITLE ); 
     63            final String axeType = request.getParameter( ParameterConstants.PARAMETER_AXE_TYPE ); 
    6464 
    6565            // TODO : utiliser JSON pour récupérer pIdPIdList 
    66             final String pIdPIdArrayString = request.getParameter( "pIdPIdList" ); 
    67             final List<Pair> pIdPIdList = extractpIdPIdListFromString( pIdPIdArrayString ); 
     66            final String pIdPIdArrayString = request.getParameter( ParameterConstants.PARAMETER_PFID_PID_LIST ); 
     67            final List<Pair<Integer, Integer>> pIdPIdList = EtherHelper.extractpfIdPIdListFromString( pIdPIdArrayString ); 
    6868            if( null == pIdPIdList ) 
    6969            { 
     
    7474 
    7575            // Dates 
    76             final String dateBegin = request.getParameter( "dateBegin" ); 
    77             final String dateEnd = request.getParameter( "dateEnd" ); 
     76            final String dateBegin = request.getParameter( ParameterConstants.PARAMETER_DATE_BEGIN ); 
     77            final String dateEnd = request.getParameter( ParameterConstants.PARAMETER_DATE_END ); 
    7878            final Calendar calendar = Calendar.getInstance(); 
    7979            Date formatedDateBegin = null; 
     
    9898            megapoliPlot.setTitle( title ); 
    9999            megapoliPlot.setAxeType( axeType ); 
    100             megapoliPlot.setpIdPIdList( pIdPIdList ); 
     100            megapoliPlot.setPfIdPIdList( pIdPIdList ); 
    101101            megapoliPlot.setBeginDate( formatedDateBegin ); 
    102102            megapoliPlot.setEndDate( formatedDateEnd ); 
     
    150150    } 
    151151 
    152     // TODO : supprimer cette méthode et utiliser JSON pour récupérer pIdPIdList 
    153     @Nullable 
    154     private List<Pair> extractpIdPIdListFromString( @NotNull final String pIdPIdArrayString ) 
    155     { 
    156         if( pIdPIdArrayString.isEmpty() ) 
    157             return null; 
    158  
    159         final String[] pIDPIdArray = pIdPIdArrayString.split( "," ); 
    160         final List<Pair> pIdPIdList = new ArrayList<Pair>( pIDPIdArray.length ); 
    161         for( final String pIdPId : pIDPIdArray ) 
    162         { 
    163             final String[] pIdPIdSplit = pIdPId.split( "-" ); 
    164             final Pair<Integer, Integer> pIdPIdPair = new Pair<Integer, Integer>(); 
    165             pIdPIdPair.setFirstValue( Integer.valueOf( pIdPIdSplit[0] ) ); 
    166             pIdPIdPair.setSecondValue( Integer.valueOf( pIdPIdSplit[1] ) ); 
    167             pIdPIdList.add( pIdPIdPair ); 
    168         } 
    169         return pIdPIdList; 
    170     } 
    171  
    172152    private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @Nullable final Exception e ) 
    173153            throws IOException 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp

    r200 r213  
    11<%@ page import="com.ether.EtherPlotServiceImpl" %> 
     2 
    23<script type="text/javascript"> 
    34var InterfaceVisualization = Class.create( { 
     
    193194            this.updateNumberAndListParameterToDisplay( 0 ); 
    194195 
     196        if( 1 > this.selectPlots.getSize() ) 
     197            this.numberParameterToDisplay = 0; 
     198 
    195199        this.requestParametersByPlateform(); 
    196200        this.testAllFields(); 
     
    277281    onClickVisualize: function() 
    278282    { 
    279         // TODO : utiliser JSON pour envoyer arrayPIdPId 
    280         var arrayPIdPId = new Array(); 
    281         if( 1 < this.numberParameterToDisplay ) 
    282         { 
    283             var index = 0; 
    284             this.selectPlots.arrayOptions.each( function( option ) 
    285             { 
    286                 arrayPIdPId[index] = option.itemValue; 
    287                 index++; 
    288             } ); 
    289         } 
    290         else if( this.selectedPlateform && this.selectedParameter ) 
    291             arrayPIdPId[0] = this.selectedPlateform.getId() + "-" + this.selectedParameter.getId(); 
    292  
    293         var url = "visualization/plotEther?" 
    294                 + "dateBegin=" + this.beginDate 
    295                 + "&dateEnd=" + this.endDate 
    296                 + "&title=" + encodeURIComponent( $( "textareaTitle" ).value ) 
    297                 + "&pIdPIdList=" + arrayPIdPId 
    298                 + "&axeType=" + this.selectAxes.getValue(); 
    299  
    300         this.plotWindow.getContent().innerHTML = '<img src=' + url + ' />'; 
    301         this.plotWindow.setSize( <%=EtherPlotServiceImpl.getMaxWidth()%>, <%=EtherPlotServiceImpl.getMaxHeight()%> ); 
    302         this.plotWindow.show(); 
     283        var urlObject = this.createUrl(); 
     284 
     285        if( urlObject.displayPlot ) 
     286        { 
     287            var url = "visualization/plotEther?" + urlObject.parameters; 
     288 
     289            this.plotWindow.getContent().innerHTML = '<img src=' + url + ' />'; 
     290            this.plotWindow.setSize( <%=EtherPlotServiceImpl.getMaxWidth()%>, <%=EtherPlotServiceImpl.getMaxHeight()%> ); 
     291            this.plotWindow.show(); 
     292        } 
     293        else 
     294        { 
     295            this.plotWindow.getContent().innerHTML = '<BR/><center>' + interfaceTexts["data.visualization.graph.noPlot"] + '</center>'; 
     296            this.plotWindow.setSize( 400, 50 ); 
     297            this.plotWindow.show(); 
     298        } 
    303299    }, 
    304300 
    305301    onClickDownload: function() 
    306302    { 
    307         if( this.testAllFields() ) 
    308             alert( "ok" ); 
     303        if( <%=null == request.getSession().getAttribute( "SES_USER" )%> ) 
     304        { 
     305            var loginWindow = new Window( {className: "dialog", zIndex: 100, resizable: true, draggable:true, wiredDrag: true, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff } ); 
     306            loginWindow.setTitle( interfaceTexts["data.authentification"] ); 
     307            loginWindow.getContent().innerHTML = '<div class="textExamplesTD">' + interfaceTexts["data.authentification.text"] + '</div>'; 
     308            loginWindow.setSize( 350, 50 ); 
     309            loginWindow.show(); 
     310        } 
    309311        else 
    310             alert( "non ok" ); 
     312        { 
     313            var urlObject = this.createUrl(); 
     314            window.location.href = "?methodName=downloadData&" + urlObject.parameters; 
     315        } 
    311316    }, 
    312317 
     
    340345 
    341346        this.visualizeButton.enable(); 
    342 //        this.downloadButton.enable(); 
     347        this.downloadButton.enable(); 
    343348    }, 
    344349 
     
    424429                break; 
    425430        } 
     431    }, 
     432 
     433    createUrl : function() 
     434    { 
     435        // TODO : utiliser JSON pour envoyer arrayPIdPId 
     436        var result = new Object(); 
     437 
     438        result.displayPlot = true; 
     439        var arrayPIdPId = new Array(); 
     440        if( 1 <= this.numberParameterToDisplay && 1 <= this.selectPlots.getSize() ) 
     441        { 
     442            var index = 0; 
     443            this.selectPlots.arrayOptions.each( function( option ) 
     444            { 
     445                arrayPIdPId[index] = option.itemValue; 
     446                index++; 
     447            } ); 
     448        } 
     449        else if( this.selectedPlateform && this.selectedParameter ) 
     450            arrayPIdPId[0] = this.selectedPlateform.getId() + "-" + this.selectedParameter.getId(); 
     451        else 
     452            result.displayPlot = false; 
     453 
     454        result.parameters = "dateBegin=" + this.beginDate 
     455                + "&dateEnd=" + this.endDate 
     456                + "&title=" + encodeURIComponent( $( "textareaTitle" ).value ) 
     457                + "&pfIdPIdList=" + arrayPIdPId 
     458                + "&axeType=" + this.selectAxes.getValue(); 
     459 
     460        return result; 
    426461    } 
    427462} ); 
     
    429464function onClickHelp() 
    430465{ 
    431     this.helpWindow = new Window( {className: "dialog", zIndex: 100, resizable: true, draggable:true, wiredDrag: true, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff } ); 
    432     this.helpWindow.setTitle( interfaceTexts["data.visualization.parameter.buttons.help"] ); 
    433     this.helpWindow.getContent().innerHTML = '<div class="textExamplesTD">' + interfaceTexts["data.visualization.parameter.buttons.help.text"] + '</div>'; 
    434     this.helpWindow.setSize( 350, 100 ); 
    435     this.helpWindow.show(); 
     466    var helpWindow = new Window( {className: "dialog", zIndex: 100, resizable: true, draggable:true, wiredDrag: true, showEffect:Effect.BlindDown, hideEffect: Effect.SwitchOff } ); 
     467    helpWindow.setTitle( interfaceTexts["data.visualization.parameter.buttons.help"] ); 
     468    helpWindow.getContent().innerHTML = '<div class="textExamplesTD">' + interfaceTexts["data.visualization.parameter.buttons.help.text"] + '</div>'; 
     469    helpWindow.setSize( 350, 100 ); 
     470    helpWindow.show(); 
    436471} 
    437472 
  • ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp

    r200 r213  
    140140            interfaceTexts["<%=AxeTypeForMobilePlateform.D2_POINTS%>"] = "<bean:message key="data.visualization.axeType.2DPoints"/>"; 
    141141 
     142            interfaceTexts["data.authentification"] = "<bean:message key="data.authentification"/>"; 
     143            interfaceTexts["data.authentification.text"] = "<bean:message key="data.authentification.text"/>"; 
     144 
    142145            var interfaceVisualization = new InterfaceVisualization( ${plateforms}, ${axeTypesForFixedPlateforms}, ${axeTypesForMobilePlateforms} ); 
    143146        </script> 
Note: See TracChangeset for help on using the changeset viewer.