Changeset 213
- Timestamp:
- 10/03/11 15:05:25 (13 years ago)
- 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 3 3 import org.apache.commons.lang.ArrayUtils; 4 4 import org.jetbrains.annotations.NotNull; 5 import org.jetbrains.annotations.Nullable; 5 6 6 7 import java.util.ArrayList; … … 14 15 public abstract class EtherHelper 15 16 { 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 16 33 /** 17 34 * This method returns the list with the second values of a list of <Pair> … … 44 61 } 45 62 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 46 84 } -
ether_megapoli/trunk/common/implementation/com/ether/MethodDescription.java
r89 r213 17 17 _view = annotation.view(); 18 18 _isJsonResult = annotation.jsonResult(); 19 _isLoginMandatory = annotation.loginMandatory(); 19 20 _params = new ArrayList<ParamDescription>(); 20 21 } … … 64 65 } 65 66 67 public Boolean isLoginMandatory() 68 { 69 return _isLoginMandatory; 70 } 71 72 public void setLoginMandatory( final Boolean loginMandatory ) 73 { 74 _isLoginMandatory = loginMandatory; 75 } 76 66 77 @NotNull 67 78 private Method _method; … … 71 82 @Nullable 72 83 private List<ParamDescription> _params; 84 private Boolean _isLoginMandatory; 73 85 } -
ether_megapoli/trunk/common/implementation/com/ether/ParameterConstants.java
r129 r213 1 1 package com.ether; 2 2 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"; 3 public 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"; 14 17 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"; 15 20 } -
ether_megapoli/trunk/common/implementation/com/ether/annotation/ControllerMethod.java
r89 r213 17 17 @NotNull 18 18 boolean jsonResult() default false; 19 20 @NotNull 21 boolean loginMandatory() default false; 19 22 } -
ether_megapoli/trunk/common/implementation/com/ether/annotation/LoginMandatory.java
r119 r213 1 1 package com.ether.annotation; 2 2 3 import java.lang.annotation.ElementType; 3 4 import java.lang.annotation.Retention; 4 5 import java.lang.annotation.RetentionPolicy; 5 6 import java.lang.annotation.Target; 6 import java.lang.annotation.ElementType;7 7 8 8 @Retention(RetentionPolicy.RUNTIME) 9 9 @Target(ElementType.PARAMETER) 10 public @interface Mandatory10 public @interface LoginMandatory 11 11 { 12 12 } -
ether_megapoli/trunk/common/implementation/com/medias/Context.java
r139 r213 16 16 * Date: 27 janv. 2005 17 17 * Time: 15:45:10 18 * 18 * <p/> 19 19 * Permet d'accéder au contexte courant pour chaque page de l'appli 20 20 */ … … 26 26 27 27 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 } 44 47 45 48 /** … … 62 65 } 63 66 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 } 70 74 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 } 80 86 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 } 97 95 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 } 106 106 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( '/' ) ); 118 132 } 119 120 133 return pageUri; 134 } 121 135 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 } 122 146 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 } 154 186 } -
ether_megapoli/trunk/service/implementation/com/ether/EtherPlotContentServiceImpl.java
r197 r213 80 80 final double yend = ysize - ystart; 81 81 82 final Pair<List, List> listPairOfPIdPIdForTwoAxes = extractListPairForAxes( megapoliPlot.get pIdPIdList() );82 final Pair<List, List> listPairOfPIdPIdForTwoAxes = extractListPairForAxes( megapoliPlot.getPfIdPIdList() ); 83 83 final List<Pair> pIdPIdListForFirstAxis = listPairOfPIdPIdForTwoAxes.getFirstValue(); 84 84 final List<Pair> pIdPIdListForSecondAxis = listPairOfPIdPIdForTwoAxes.getSecondValue(); … … 206 206 207 207 // Create the legend 208 final Pair<Integer, Integer> pIdPId = (Pair<Integer, Integer>) megapoliPlot.get pIdPIdList().get( 0 );208 final Pair<Integer, Integer> pIdPId = (Pair<Integer, Integer>) megapoliPlot.getPfIdPIdList().get( 0 ); 209 209 final Integer parameterId = pIdPId.getSecondValue(); 210 210 … … 459 459 * The second list can be empty, in this case, only one axis is needed 460 460 * 461 * @param p IdPIdList462 * @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 ) 466 466 { 467 467 final List<Pair<Integer, Integer>> pIdPIdListForFirstAxis = new ArrayList<Pair<Integer, Integer>>(); 468 468 final List<Pair<Integer, Integer>> pIdPIdListForSecondAxis = new ArrayList<Pair<Integer, Integer>>(); 469 469 470 for( final Pair pIdPId : p IdPIdList )470 for( final Pair pIdPId : pfIdPIdList ) 471 471 { 472 472 final List<Integer> secondValuesForFirstAxis = EtherHelper.getSecondValues( pIdPIdListForFirstAxis ); … … 597 597 protected static final int MAX_WIDTH = 800; 598 598 protected static final int MAX_HEIGHT = 700; 599 protected static final int MAX_HEIGHT_TOP = 100; 599 600 protected static final int MARGIN_LEFT_RIGHT = 50; 600 601 protected static final int LEGEND_2D_HEIGHT = 150; -
ether_megapoli/trunk/service/implementation/com/ether/EtherPlotServiceImpl.java
r196 r213 68 68 jPane.add( jPaneTop, BorderLayout.NORTH ); 69 69 70 final Integer valuesNumber = ( null != megapoliPlot.getValuesNumber() ) ? megapoliPlot.getValuesNumber() : getEtherService().getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.get pIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() );70 final Integer valuesNumber = ( null != megapoliPlot.getValuesNumber() ) ? megapoliPlot.getValuesNumber() : getEtherService().getNumberValuesByPlateformByParameterByPeriod( megapoliPlot.getPfIdPIdList(), megapoliPlot.getBeginDate(), megapoliPlot.getEndDate() ); 71 71 72 72 // Bottom Pane … … 127 127 128 128 // 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 ); 130 130 131 131 // jPane -
ether_megapoli/trunk/service/implementation/com/ether/EtherServiceImpl.java
r194 r213 134 134 @NotNull 135 135 @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 ) 137 137 throws ServiceException 138 138 { -
ether_megapoli/trunk/service/implementation/com/ether/MegapoliPlot.java
r186 r213 101 101 102 102 @Nullable 103 public List<Pair > getpIdPIdList()103 public List<Pair<Integer, Integer>> getPfIdPIdList() 104 104 { 105 return _p IdPIdList;105 return _pfIdPIdList; 106 106 } 107 107 108 public void set pIdPIdList( @Nullable final List<Pair> pIdPIdList )108 public void setPfIdPIdList( @Nullable final List<Pair<Integer, Integer>> pfIdPIdList ) 109 109 { 110 _p IdPIdList = pIdPIdList;110 _pfIdPIdList = pfIdPIdList; 111 111 } 112 112 … … 153 153 // List of <plateformId, parameterId> to display 154 154 @Nullable 155 private List<Pair > _pIdPIdList;155 private List<Pair<Integer, Integer>> _pfIdPIdList; 156 156 @Nullable 157 157 private Date _beginDate; -
ether_megapoli/trunk/service/interface/com/ether/EtherService.java
r194 r213 45 45 46 46 @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 ) 48 48 throws ServiceException; 49 49 } -
ether_megapoli/trunk/web/resources/css/visu_parameter_by_pf.css
r197 r213 106 106 107 107 .textExamplesTD { 108 margin: 10px; 108 109 color: #04155D; 109 110 text-align: center; -
ether_megapoli/trunk/web/resources/templates/template2.jsp
r200 r213 15 15 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"> 16 16 <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> 23 23 <script type="text/javascript"> 24 24 <!-- -
ether_megapoli/trunk/web/src/ApplicationResources.properties
r199 r213 477 477 data.visualization.axeType.2DContour=2D (contour) 478 478 data.visualization.axeType.2DPoints=2D (points) 479 data.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. 479 480 480 481 simulation.visualization=Des simulations … … 488 489 plot.longitude=Longitude 489 490 plot.degres=Degr\u00E9s 491 -
ether_megapoli/trunk/web/src/ApplicationResources_en.properties
r199 r213 477 477 data.visualization.axeType.2DPoints=2D (dots) 478 478 479 data.authentification.text=Please login by click on 'Access to data' to access the protected areas of this website. 480 479 481 simulation.visualization=Simulations 480 482 -
ether_megapoli/trunk/web/src/com/ether/Controller.java
r197 r213 4 4 import com.ether.annotation.Mandatory; 5 5 import com.ether.annotation.ParamName; 6 import com.medias.annuaire.Personne; 6 7 import com.medias.database.objects.Parametre; 7 8 import com.medias.database.objects.Plateforme; 9 import com.medias.megapoli.struts.forms.DatasForm; 10 import com.medias.megapoli.utils.Requete; 8 11 import net.sf.json.JSONObject; 12 import org.apache.commons.lang.StringUtils; 9 13 import org.apache.commons.logging.Log; 10 14 import org.apache.commons.logging.LogFactory; 15 import org.jdom.Document; 16 import org.jdom.output.XMLOutputter; 11 17 import org.jetbrains.annotations.NotNull; 12 18 import org.springframework.beans.factory.annotation.Required; … … 15 21 import javax.servlet.http.HttpServletRequest; 16 22 import javax.servlet.http.HttpServletResponse; 23 import java.io.BufferedReader; 24 import java.io.DataOutputStream; 25 import java.io.InputStreamReader; 26 import java.net.URL; 27 import java.net.URLConnection; 28 import java.net.URLEncoder; 17 29 import java.util.ArrayList; 30 import java.util.Calendar; 18 31 import java.util.HashMap; 19 32 import java.util.List; … … 51 64 { 52 65 final List<Plateforme> plateforms = _etherService.getAllPlateforms(); 53 // final List<Plateforme> plateforms = BouchonHelper.createPlateforms();54 66 55 67 final Map<String, Object> model = new HashMap<String, Object>(); … … 58 70 model.put( "axeTypesForMobilePlateforms", getJSONAxeTypesForMobilePlateforms() ); 59 71 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>(); 60 154 } 61 155 … … 70 164 { 71 165 final List<Parametre> parametersByPlateform = _etherService.getParametersByPlateformId( plateformId ); 72 // final List<Parametre> parametersByPlateform = BouchonHelper.createParameters( plateformId );73 166 74 167 final JSONObject result = new JSONObject(); … … 119 212 private static final String VIEW_VISUALIZATION = "visualization/visu"; 120 213 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"; 122 218 private EtherService _etherService; 123 219 } -
ether_megapoli/trunk/web/src/com/ether/ControllerEther.java
r130 r213 5 5 import com.ether.annotation.ParamName; 6 6 import com.ether.annotation.UseJSON; 7 import com.medias.annuaire.Personne; 7 8 import net.sf.json.JSON; 8 9 import net.sf.json.JSONArray; … … 44 45 { 45 46 if( !_initialized ) 46 47 initialize(); 47 48 48 49 request.setCharacterEncoding( UTF8Charset.getEncoding() ); … … 82 83 final Object[] params = buildParams( methodDescription, request ); 83 84 85 if( methodDescription.isLoginMandatory() ) 86 { 87 final Personne pers = (Personne) request.getSession().getAttribute( "SES_USER" ); 88 params[params.length - 1] = pers; 89 } 84 90 // Invoke method (go to controller) 85 91 final Object result = methodDescription.getMethod().invoke( this, params ); -
ether_megapoli/trunk/web/src/com/ether/ControllerPlot.java
r199 r213 60 60 try 61 61 { 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 ); 64 64 65 65 // 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 ); 68 68 if( null == pIdPIdList ) 69 69 { … … 74 74 75 75 // 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 ); 78 78 final Calendar calendar = Calendar.getInstance(); 79 79 Date formatedDateBegin = null; … … 98 98 megapoliPlot.setTitle( title ); 99 99 megapoliPlot.setAxeType( axeType ); 100 megapoliPlot.set pIdPIdList( pIdPIdList );100 megapoliPlot.setPfIdPIdList( pIdPIdList ); 101 101 megapoliPlot.setBeginDate( formatedDateBegin ); 102 102 megapoliPlot.setEndDate( formatedDateEnd ); … … 150 150 } 151 151 152 // TODO : supprimer cette méthode et utiliser JSON pour récupérer pIdPIdList153 @Nullable154 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 172 152 private void createErrorPane( final HttpServletResponse response, final HttpServletRequest request, @NotNull final String mainError, @Nullable final Exception e ) 173 153 throws IOException -
ether_megapoli/trunk/web/visualization/visu_parameter_by_pf-script.jsp
r200 r213 1 1 <%@ page import="com.ether.EtherPlotServiceImpl" %> 2 2 3 <script type="text/javascript"> 3 4 var InterfaceVisualization = Class.create( { … … 193 194 this.updateNumberAndListParameterToDisplay( 0 ); 194 195 196 if( 1 > this.selectPlots.getSize() ) 197 this.numberParameterToDisplay = 0; 198 195 199 this.requestParametersByPlateform(); 196 200 this.testAllFields(); … … 277 281 onClickVisualize: function() 278 282 { 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 } 303 299 }, 304 300 305 301 onClickDownload: function() 306 302 { 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 } 309 311 else 310 alert( "non ok" ); 312 { 313 var urlObject = this.createUrl(); 314 window.location.href = "?methodName=downloadData&" + urlObject.parameters; 315 } 311 316 }, 312 317 … … 340 345 341 346 this.visualizeButton.enable(); 342 //this.downloadButton.enable();347 this.downloadButton.enable(); 343 348 }, 344 349 … … 424 429 break; 425 430 } 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; 426 461 } 427 462 } ); … … 429 464 function onClickHelp() 430 465 { 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(); 436 471 } 437 472 -
ether_megapoli/trunk/web/visualization/visu_parameter_by_pf.jsp
r200 r213 140 140 interfaceTexts["<%=AxeTypeForMobilePlateform.D2_POINTS%>"] = "<bean:message key="data.visualization.axeType.2DPoints"/>"; 141 141 142 interfaceTexts["data.authentification"] = "<bean:message key="data.authentification"/>"; 143 interfaceTexts["data.authentification.text"] = "<bean:message key="data.authentification.text"/>"; 144 142 145 var interfaceVisualization = new InterfaceVisualization( ${plateforms}, ${axeTypesForFixedPlateforms}, ${axeTypesForMobilePlateforms} ); 143 146 </script>
Note: See TracChangeset
for help on using the changeset viewer.