Coser-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- 1258 discussions
r493 - trunk/coser-web/src/main/webapp/WEB-INF/content/pop
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 17:46:02 +0000 (Mon, 10 Jan 2011)
New Revision: 493
Log:
Affichage des graph a partir d'une image g?\195?\169n?\195?\169r?\195?\169e par jfreechart.
Modified:
trunk/coser-web/src/main/webapp/WEB-INF/content/pop/graph.jsp
Modified: trunk/coser-web/src/main/webapp/WEB-INF/content/pop/graph.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/pop/graph.jsp 2011-01-10 17:45:53 UTC (rev 492)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/pop/graph.jsp 2011-01-10 17:46:02 UTC (rev 493)
@@ -31,7 +31,10 @@
</head>
<body>
- <img src="<s:property value="chartUrl"/>" />
-
+ <img src="<s:url action='graph-data'>
+ <s:param name="zone" value="%{zone}" />
+ <s:param name="species" value="%{species}" />
+ <s:param name="indicator" value="%{indicator}" />
+ </s:url>" />
</body>
</html>
\ No newline at end of file
1
0
r492 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-web/src/main/java/fr/ifremer/coser/web coser-web/src/main/java/fr/ifremer/coser/web/actions/com coser-web/src/main/java/fr/ifremer/coser/web/actions/pop
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 17:45:53 +0000 (Mon, 10 Jan 2011)
New Revision: 492
Log:
Affichage des graph a partir d'une image g?\195?\169n?\195?\169r?\195?\169e par jfreechart.
Added:
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/SubzoneAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-01-10 16:08:48 UTC (rev 491)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -45,6 +45,7 @@
import java.util.TreeMap;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.collections.map.MultiKeyMap;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
@@ -60,16 +61,20 @@
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.CategoryItemRenderer;
import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.chart.renderer.category.StatisticalLineAndShapeRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
+import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.util.ShapeUtilities;
import fr.ifremer.coser.CoserBusinessConfig;
import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.bean.AbstractDataContainer;
import fr.ifremer.coser.bean.Control;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.bean.RSufiResult;
import fr.ifremer.coser.bean.Selection;
import fr.ifremer.coser.command.CategoryLineCommand;
import fr.ifremer.coser.command.Command;
@@ -78,6 +83,7 @@
import fr.ifremer.coser.control.DiffCatchLengthControlError;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Length;
+import fr.ifremer.coser.storage.DataStorage;
/**
* Publication service (charts, reports, export...)
@@ -96,9 +102,12 @@
protected ProjectService projectService;
+ protected ImportService importService;
+
public PublicationService(CoserBusinessConfig config) {
this.config = config;
projectService = new ProjectService(config);
+ importService = new ImportService(config);
}
/**
@@ -637,5 +646,136 @@
}
out.println("</ol>");
}
+
+ /**
+ * @param resultDirectory
+ * @param rsufiResult
+ * @param locale
+ * @return
+ * @throws CoserBusinessException
+ */
+ public File getRsufiResultComChart(File resultDirectory,
+ RSufiResult rsufiResult, String indicator, String locale) throws CoserBusinessException {
+
+ File result = null;
+
+ // le fichier estcomind
+ File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());
+
+ // Campagne Indicateur Liste Strate Annee Estimation EcartType CV
+ DataStorage dataStorage = importService.loadCSVFile(estPopIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
+
+ DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset();
+ Iterator<String[]> estPopIndIterator = dataStorage.iterator(true);
+ while (estPopIndIterator.hasNext()) {
+ String[] tuple = estPopIndIterator.next();
+
+ String indicatorCode = tuple[1];
+ if (indicatorCode.equals(indicator)) {
+ Double estimation = Double.parseDouble(tuple[5]);
+ //Double ecart = estimation * 0.97;
+ Double ecart = Double.parseDouble(tuple[6]);
+ String year = tuple[4];
+ statisticalDataset.add(estimation, ecart, "Serie1", year);
+ }
+ }
+
+ // configure chart
+ CategoryAxis categoryAxis = new CategoryAxis(_("coser.business.common.year"));
+ categoryAxis.setCategoryMargin(0);
+ // label horizontaux
+ //categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
+ ValueAxis valueAxis = new NumberAxis(_("coser.business.common.number"));
+ valueAxis.setUpperMargin(0.1);
+
+ CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
+
+ // n'affiche pas les nombre sur le graphique
+ //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
+ //renderer.setBaseItemLabelGenerator(itemLabelGenerator);
+ //renderer.setBaseItemLabelsVisible(true);
+
+ CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer);
+ plot.setOrientation(PlotOrientation.VERTICAL);
+ JFreeChart chart = new JFreeChart("Titre",
+ JFreeChart.DEFAULT_TITLE_FONT, plot, true);
+
+ try {
+ result = File.createTempFile("coser-", ".chart");
+ result.deleteOnExit();
+ ChartUtilities.saveChartAsPNG(result, chart, 800, 400);
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't save chart", ex);
+ }
+
+ return result;
+ }
+
+ /**
+ * @param resultDirectory
+ * @param rsufiResult
+ * @param species
+ * @param locale
+ * @return
+ * @throws CoserBusinessException
+ */
+ public File getRsufiResultPopChart(File resultDirectory,
+ RSufiResult rsufiResult, String species, String indicator, String locale) throws CoserBusinessException {
+
+ File result = null;
+
+ // le fichier estcomind
+ File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());
+
+ // Campagne Indicateur Liste Species Strate Annee Estimation EcartType CV
+ DataStorage dataStorage = importService.loadCSVFile(estPopIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
+
+ DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset();
+ Iterator<String[]> estPopIndIterator = dataStorage.iterator(true);
+ while (estPopIndIterator.hasNext()) {
+ String[] tuple = estPopIndIterator.next();
+
+ String speciesCode = tuple[3];
+ String indicatorCode = tuple[1];
+ if (speciesCode.equals(species) && indicatorCode.equals(indicator)) {
+ Double estimation = Double.parseDouble(tuple[6]);
+ //Double ecart = estimation * 0.97;
+ Double ecart = Double.parseDouble(tuple[7]);
+ String year = tuple[5];
+ statisticalDataset.add(estimation, ecart, "Serie1", year);
+ }
+ }
+
+ // configure chart
+ CategoryAxis categoryAxis = new CategoryAxis(_("coser.business.common.year"));
+ categoryAxis.setCategoryMargin(0);
+ // label horizontaux
+ //categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
+ ValueAxis valueAxis = new NumberAxis(_("coser.business.common.number"));
+ valueAxis.setUpperMargin(0.1);
+
+ CategoryItemRenderer renderer = new StatisticalLineAndShapeRenderer(false, true);
+
+ // n'affiche pas les nombre sur le graphique
+ //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
+ //renderer.setBaseItemLabelGenerator(itemLabelGenerator);
+ //renderer.setBaseItemLabelsVisible(true);
+
+ CategoryPlot plot = new CategoryPlot(statisticalDataset, categoryAxis, valueAxis, renderer);
+ plot.setOrientation(PlotOrientation.VERTICAL);
+ JFreeChart chart = new JFreeChart("Titre",
+ JFreeChart.DEFAULT_TITLE_FONT, plot, true);
+
+ try {
+ result = File.createTempFile("coser-", ".chart");
+ result.deleteOnExit();
+ ChartUtilities.saveChartAsPNG(result, chart, 800, 400);
+ } catch (IOException ex) {
+ throw new CoserBusinessException("Can't save chart", ex);
+ }
+
+ return result;
+
+ }
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 16:08:48 UTC (rev 491)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -81,6 +81,8 @@
protected ProjectService projectService;
+ protected PublicationService publicationService;
+
/** Indicator map (id, locale > translation) (etat du service). */
protected MultiKeyMap indicatorsMap;
@@ -92,6 +94,7 @@
importService = new ImportService(config);
projectService = new ProjectService(config);
+ publicationService = new PublicationService(config);
}
/**
@@ -531,7 +534,7 @@
* pour la zone et l'especes souhaitées.
*
* @param zone zone (zoneid-surveyname)
- * @param species especes
+ * @param species especes (if {@code null} look for com indicators
* @param locale locale ({@code fr} ou {@code en})
* @return la liste des indicateurs
* @throws CoserBusinessException
@@ -572,7 +575,14 @@
// data loading not necessary here
if (surveyName.equals(survey)) {
- Map<String, String> resultIndicators = getRsufiResultIndicators(resultFile, rsufiResult, species, locale);
+ Map<String, String> resultIndicators = null;
+
+ if (species == null) {
+ resultIndicators = getRsufiResultComIndicators(resultFile, rsufiResult, locale);
+ }
+ else {
+ resultIndicators = getRsufiResultPopIndicators(resultFile, rsufiResult, species, locale);
+ }
indicators.putAll(resultIndicators);
break;
}
@@ -601,7 +611,7 @@
* @return indicator for species
* @throws CoserBusinessException
*/
- protected Map<String, String> getRsufiResultIndicators(File resultDirectory, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException {
+ protected Map<String, String> getRsufiResultPopIndicators(File resultDirectory, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException {
MultiKeyMap defaultIndicators = getIndicatorsMap();
@@ -631,22 +641,63 @@
return result;
}
+
+ /**
+ * Recupere la liste de toutes les especes nom sci et nom off à partir
+ * d'un resultat.
+ *
+ * @param resultDirectory rsufi result directory
+ * @param rsufiResult result
+ * @param species to get indicator
+ * @param locale locale ({@code fr} ou {@code en})
+ * @return indicator for species
+ * @throws CoserBusinessException
+ */
+ protected Map<String, String> getRsufiResultComIndicators(File resultDirectory, RSufiResult rsufiResult, String locale) throws CoserBusinessException {
+ MultiKeyMap defaultIndicators = getIndicatorsMap();
+
+ Map<String, String> result = new HashMap<String, String>();
+
+ // le fichier estcomind
+ File estComIndFile = new File(resultDirectory, rsufiResult.getEstComIndName());
+
+ // Campagne Indicateur Liste Strate Annee Estimation EcartType CV
+ DataStorage dataStorage = importService.loadCSVFile(estComIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
+
+ Iterator<String[]> estPopIndIterator = dataStorage.iterator(true);
+ while (estPopIndIterator.hasNext()) {
+ String[] tuple = estPopIndIterator.next();
+
+ String indicatorCode = tuple[1];
+ String translations = (String)defaultIndicators.get(indicatorCode, locale.toLowerCase());
+ if (translations == null) {
+ translations = "##" + indicatorCode + "##";
+ }
+ result.put(indicatorCode, translations);
+ }
+
+ return result;
+ }
+
/**
- * Generer les données du graph et genere la liste des parametres pour
- * les generateurs de graph (eastwood ou jfreechart).
+ * Retourne les indicateurs calculés avec leurs traductions scientifique
+ * pour la zone et l'especes souhaitées.
*
- * @param zone zone
- * @param species species
+ * @param zone zone (zoneid-surveyname)
+ * @param species especes (if {@code null} look for com indicators
* @param indicator indicator
- * @return chart parameters
+ * @param locale locale ({@code fr} ou {@code en})
+ * @return la liste des indicateurs
* @throws CoserBusinessException
*/
- public String getChartParameters(String zone, String species, String indicator) throws CoserBusinessException {
+ public File getChart(String zone, String species, String indicator, String locale) throws CoserBusinessException {
+ File result = null;
- // charge du fichier EstComInd_survey.txt ou EstPopInd_survey.txt
- // suivant le type de resultat demandé (communauté/population)
+ String zoneId = zone.substring(0, zone.indexOf('-'));
+ String survey = zone.substring(zone.indexOf('-') + 1);
+ // parcours des resultats disponibles
File projectsDirectory = config.getWebProjectsDirectory();
File[] projectFiles = projectsDirectory.listFiles();
if (projectFiles != null) {
@@ -661,20 +712,31 @@
if (selectionFile.isDirectory()) {
File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
File[] resultFiles = resultsDirectory.listFiles();
-
+
// result iteration
if (resultFiles != null) {
for (File resultFile : resultFiles) {
if (resultFile.isDirectory()) {
RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
- if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) {
-
- // load project (without data to get reftax data)
- Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
- Map<String, String> resultSpecies = getRsufiResultSpecies(project, resultFile, rsufiResult);
- //result.putAll(resultSpecies);
- break;
+ // extraction des especes pour le résultat demandé
+ if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) {
+
+ // get survey name (other condition)
+ String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
+
+ // data loading not necessary here
+ if (surveyName.equals(survey)) {
+ Map<String, String> resultIndicators = null;
+
+ if (species == null) {
+ result = publicationService.getRsufiResultComChart(resultFile, rsufiResult, indicator, locale);
+ }
+ else {
+ result = publicationService.getRsufiResultPopChart(resultFile, rsufiResult, species, indicator, locale);
+ }
+ break;
+ }
}
}
}
@@ -685,8 +747,8 @@
}
}
}
-
- return null;
+
+ return result;
}
/**
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java 2011-01-10 16:08:48 UTC (rev 491)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -25,6 +25,7 @@
import org.nuiton.i18n.I18n;
import org.nuiton.util.ArgumentsParserException;
+import fr.ifremer.coser.services.PublicationService;
import fr.ifremer.coser.services.WebService;
/**
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,86 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.com;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * Affiche le graphique demandé.
+ *
+ * Parametre : zone, species, indicator.
+ *
+ * Based on eastwoood, same doc as google chart api :
+ * http://code.google.com/apis/chart/docs/making_charts.html
+ *
+ * chart?cht=<chart_type>&chd=<chart_data>&chs=<chart_size>&...additional_parameters...
+ *
+ * Dans ce cas, on va faire un graphe avec des points pour les valeurs
+ * et des traits (en dessous/au dessus) pour les ecarts types.
+ * chd=t:
+ * 12,16,16,24,26,28,41,51,66,68,13,45,81|
+ * 16,14,22,34,22,31,31,48,71,64,15,38,84|
+ * 8,6,4,5,2,13,9,8,7,6,1,8,8
+ * chm=
+ * o,0000FF,0,-1,0|
+ * h,FF0000,0,0:9:,5|
+ * h,FF0000,0,0:9:,5
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class GraphAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String zone;
+
+ protected String indicator;
+
+ protected String chartUrl;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getIndicator() {
+ return indicator;
+ }
+
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
+ }
+
+ @Override
+ public String execute() {
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,118 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.com;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Locale;
+
+import org.apache.struts2.convention.annotation.Action;
+import org.apache.struts2.convention.annotation.Result;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Affiche le graphique demandé.
+ *
+ * Parametre : zone, species, indicator.
+ *
+ * Based on eastwoood, same doc as google chart api :
+ * http://code.google.com/apis/chart/docs/making_charts.html
+ *
+ * chart?cht=<chart_type>&chd=<chart_data>&chs=<chart_size>&...additional_parameters...
+ *
+ * Dans ce cas, on va faire un graphe avec des points pour les valeurs
+ * et des traits (en dessous/au dessus) pour les ecarts types.
+ * chd=t:
+ * 12,16,16,24,26,28,41,51,66,68,13,45,81|
+ * 16,14,22,34,22,31,31,48,71,64,15,38,84|
+ * 8,6,4,5,2,13,9,8,7,6,1,8,8
+ * chm=
+ * o,0000FF,0,-1,0|
+ * h,FF0000,0,0:9:,5|
+ * h,FF0000,0,0:9:,5
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class GraphDataAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String zone;
+
+ protected String indicator;
+
+ protected String chartUrl;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getIndicator() {
+ return indicator;
+ }
+
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
+ }
+
+ @Action(results= {@Result(type="stream", params={"contentType", "image/png", "inputName", "inputStream"})})
+ public String execute() {
+ return SUCCESS;
+ }
+
+ public InputStream getInputStream() {
+ WebService webService = ServiceFactory.getWebService();
+
+ Locale locale = getLocale();
+ String localeCode = locale.getLanguage();
+
+ InputStream input = null;
+ try {
+ File mapImage = webService.getChart(zone, null, indicator, localeCode);
+ input = new FileInputStream(mapImage);
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ } catch (FileNotFoundException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ }
+
+ return input;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/GraphDataAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,90 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.com;
+
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Action index, recupere la liste des resultats.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class IndicatorAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1663244944108703571L;
+
+ private static final Log log = LogFactory.getLog(IndicatorAction.class);
+
+ protected String zone;
+
+ protected Map<String, String> indicators;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public Map<String, String> getIndicators() {
+ return indicators;
+ }
+
+ @Override
+ public String execute() {
+
+ if (log.isInfoEnabled()) {
+ log.info(String.format("Looking for com indicator for zone %s", zone));
+ }
+
+ WebService webService = ServiceFactory.getWebService();
+
+ Locale locale = getLocale();
+ String localeCode = locale.getLanguage();
+
+ try {
+ indicators = webService.getIndicators(zone, null, localeCode);
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get indicators", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/IndicatorAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/SubzoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/SubzoneAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/SubzoneAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.com;
+
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Affiche la liste des sous zones (zone).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SubzoneAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String mainZone;
+
+ public void setMainZone(String mainZone) {
+ this.mainZone = mainZone;
+ }
+
+ protected Map<String, String> zones;
+
+ public Map<String, String> getZones() {
+ return zones;
+ }
+
+ @Override
+ public String execute() {
+
+ WebService webService = ServiceFactory.getWebService();
+ try {
+
+ // renvoi la liste des id subzone-survey et leurs label
+ // associé
+ zones = webService.getSurveysForZone(mainZone);
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/SubzoneAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.com;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Action index, affiche la liste des zones majeures (main zone).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ZoneAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected Map<String, String> mainZones;
+
+ public Map<String, String> getMainZones() {
+ return mainZones;
+ }
+
+ @Override
+ public String execute() {
+
+ mainZones = new HashMap<String, String>();
+
+ WebService webService = ServiceFactory.getWebService();
+ try {
+ Map<String, String[]> zonesMap = webService.getZonesMap();
+
+ for (Map.Entry<String, String[]> zoneMapEntry : zonesMap.entrySet()) {
+ mainZones.put(zoneMapEntry.getValue()[0], zoneMapEntry.getValue()[0]);
+ }
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/com/ZoneAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java 2011-01-10 16:08:48 UTC (rev 491)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -90,16 +90,11 @@
public void setIndicator(String indicator) {
this.indicator = indicator;
}
-
- public String getChartUrl() {
- return chartUrl;
- }
-
@Override
public String execute() {
- CoserWebConfig config = ServiceFactory.getCoserConfig();
+ /*CoserWebConfig config = ServiceFactory.getCoserConfig();
chartUrl = config.getEastWoodUrl() + "/chart?";
@@ -120,7 +115,7 @@
// taille de la courbe
chartUrl += "&chls=2";
// titre du graphique
- chartUrl += "&chtt=" + zone + ";" + species + ";" + indicator;
+ chartUrl += "&chtt=" + zone + ";" + species + ";" + indicator;*/
return SUCCESS;
}
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java 2011-01-10 17:45:53 UTC (rev 492)
@@ -0,0 +1,130 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.pop;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.util.Locale;
+
+import org.apache.struts2.convention.annotation.Action;
+import org.apache.struts2.convention.annotation.Result;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.PublicationService;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebConfig;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Affiche le graphique demandé.
+ *
+ * Parametre : zone, species, indicator.
+ *
+ * Based on eastwoood, same doc as google chart api :
+ * http://code.google.com/apis/chart/docs/making_charts.html
+ *
+ * chart?cht=<chart_type>&chd=<chart_data>&chs=<chart_size>&...additional_parameters...
+ *
+ * Dans ce cas, on va faire un graphe avec des points pour les valeurs
+ * et des traits (en dessous/au dessus) pour les ecarts types.
+ * chd=t:
+ * 12,16,16,24,26,28,41,51,66,68,13,45,81|
+ * 16,14,22,34,22,31,31,48,71,64,15,38,84|
+ * 8,6,4,5,2,13,9,8,7,6,1,8,8
+ * chm=
+ * o,0000FF,0,-1,0|
+ * h,FF0000,0,0:9:,5|
+ * h,FF0000,0,0:9:,5
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class GraphDataAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String zone;
+
+ protected String species;
+
+ protected String indicator;
+
+ protected String chartUrl;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+
+ public String getIndicator() {
+ return indicator;
+ }
+
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
+ }
+
+ @Action(results= {@Result(type="stream", params={"contentType", "image/png", "inputName", "inputStream"})})
+ public String execute() {
+ return SUCCESS;
+ }
+
+ public InputStream getInputStream() {
+ WebService webService = ServiceFactory.getWebService();
+
+ Locale locale = getLocale();
+ String localeCode = locale.getLanguage();
+
+ InputStream input = null;
+ try {
+ File mapImage = webService.getChart(zone, species, indicator, localeCode);
+ input = new FileInputStream(mapImage);
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ } catch (FileNotFoundException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ }
+
+ return input;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphDataAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
r491 - in trunk/coser-web/src/main/webapp/WEB-INF/content: . map
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 16:08:48 +0000 (Mon, 10 Jan 2011)
New Revision: 491
Log:
Map action
Added:
trunk/coser-web/src/main/webapp/WEB-INF/content/map/
trunk/coser-web/src/main/webapp/WEB-INF/content/map/map.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/map/species.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/map/subzone.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/map/zone.jsp
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/map/map.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/map/map.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/map/map.jsp 2011-01-10 16:08:48 UTC (rev 491)
@@ -0,0 +1,40 @@
+<!--
+ #%L
+ Coser :: Web
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Coser</title>
+ </head>
+ <body>
+
+ <img src="<s:url action='map-data'>
+ <s:param name="zone" value="%{zone}" />
+ <s:param name="species" value="%{species}" />
+ </s:url>" />
+
+ </body>
+</html>
\ No newline at end of file
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/map/species.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/map/species.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/map/species.jsp 2011-01-10 16:08:48 UTC (rev 491)
@@ -0,0 +1,44 @@
+<!--
+ #%L
+ Coser :: Web
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%@taglib uri="/struts-tags" prefix="s" %>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Coser</title>
+ </head>
+ <body>
+
+ <img src="<s:url value='/images/zonesmap.jpg' />" />
+
+ <br />
+
+ <s:form action="map" method="get">
+ <s:select name="species" list="species" label="Select a species" />
+ <s:hidden name="zone" property="zone"/>
+ <s:submit label="Suite"/>
+ </s:form>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/map/subzone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/map/subzone.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/map/subzone.jsp 2011-01-10 16:08:48 UTC (rev 491)
@@ -0,0 +1,47 @@
+<!--
+ #%L
+ Coser :: Web
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%@taglib uri="/struts-tags" prefix="s" %>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Coser</title>
+ </head>
+ <body>
+
+ <img src="<s:url value='/images/zonesmap.jpg' />" />
+
+ <br />
+
+ <s:if test="%{zones.isEmpty()}">
+ No result founds
+ </s:if>
+ <s:else>
+ <s:form action="species" method="get">
+ <s:select name="zone" list="zones" label="Select a sub zone" />
+ <s:submit label="Suite"/>
+ </s:form>
+ </s:else>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/map/zone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/map/zone.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/map/zone.jsp 2011-01-10 16:08:48 UTC (rev 491)
@@ -0,0 +1,42 @@
+<!--
+ #%L
+ Coser :: Web
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%@taglib uri="/struts-tags" prefix="s" %>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Coser</title>
+ </head>
+ <body>
+
+ <img src="<s:url value='/images/zonesmap.jpg' />" />
+
+ <br />
+
+ <s:form action="subzone" method="get">
+ <s:select name="mainZone" list="mainZones" label="Select a zone" />
+ <s:submit label="Suite"/>
+ </s:form>
+ </body>
+</html>
\ No newline at end of file
1
0
r490 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-web/src/main/java/fr/ifremer/coser/web coser-web/src/main/java/fr/ifremer/coser/web/actions coser-web/src/main/java/fr/ifremer/coser/web/actions/map coser-web/src/main/webapp/WEB-INF
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 16:06:29 +0000 (Mon, 10 Jan 2011)
New Revision: 490
Log:
Map action
Added:
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SubzoneAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java
Removed:
trunk/coser-web/src/main/java/fr/ifremer/coser/web/pop/
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
trunk/coser-web/src/main/webapp/WEB-INF/web.xml
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:42:03 UTC (rev 489)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -52,7 +52,6 @@
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.RSufiResult;
-import fr.ifremer.coser.bean.Selection;
import fr.ifremer.coser.storage.DataStorage;
/**
@@ -558,7 +557,7 @@
if (selectionFile.isDirectory()) {
File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
File[] resultFiles = resultsDirectory.listFiles();
-
+
// result iteration
if (resultFiles != null) {
for (File resultFile : resultFiles) {
@@ -567,14 +566,16 @@
// extraction des especes pour le résultat demandé
if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) {
-
+
// get survey name (other condition)
String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
-
+
// data loading not necessary here
- Map<String, String> resultIndicators = getRsufiResultIndicators(resultFile, rsufiResult, species, locale);
- indicators.putAll(resultIndicators);
- break;
+ if (surveyName.equals(survey)) {
+ Map<String, String> resultIndicators = getRsufiResultIndicators(resultFile, rsufiResult, species, locale);
+ indicators.putAll(resultIndicators);
+ break;
+ }
}
}
}
@@ -687,4 +688,67 @@
return null;
}
+
+ /**
+ * Recupere le fichier image de la carte demandées en fonction de la zone
+ * et de l'espece.
+ *
+ * @param zone zone (zoneid-surveyname)
+ * @param species
+ * @return map file
+ * @throws CoserBusinessException
+ */
+ public File getMapFile(String zone, String species) throws CoserBusinessException {
+
+ File result = null;
+
+ String zoneId = zone.substring(0, zone.indexOf('-'));
+ String survey = zone.substring(zone.indexOf('-') + 1);
+
+ // parcours des resultats disponibles
+ File projectsDirectory = config.getWebProjectsDirectory();
+ File[] projectFiles = projectsDirectory.listFiles();
+ if (projectFiles != null) {
+ for (File projectFile : projectFiles) {
+ if (projectFile.isDirectory()) {
+ File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File[] selectionFiles = selectionsDirectory.listFiles();
+
+ // selection iteration
+ if (selectionFiles != null) {
+ for (File selectionFile : selectionFiles) {
+ if (selectionFile.isDirectory()) {
+ File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
+ File[] resultFiles = resultsDirectory.listFiles();
+
+ // result iteration
+ if (resultFiles != null) {
+ for (File resultFile : resultFiles) {
+ if (resultFile.isDirectory()) {
+ RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
+
+ // extraction des especes pour le résultat demandé
+ if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) {
+
+ // get survey name (other condition)
+ String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
+
+ if (surveyName.equals(survey)) {
+ String mapName = survey + "_" + species.toUpperCase() + ".png";
+ File mapsDirectory = new File(resultFile, CoserConstants.STORAGE_MAPS_DIRECTORY);
+ result = new File(mapsDirectory, mapName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return result;
+ }
}
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -0,0 +1,60 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ * Action index, recupere la liste des resultats.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MapAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1663244944108703571L;
+
+ protected String zone;
+
+ protected String species;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -0,0 +1,96 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.map;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.struts2.convention.annotation.Action;
+import org.apache.struts2.convention.annotation.Result;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Action index, recupere la liste des resultats.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MapDataAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1663244944108703571L;
+
+ protected String zone;
+
+ protected String species;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public String getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+
+ @Action(results= {@Result(type="stream", params={"contentType", "image/png", "inputName", "inputStream"})})
+ public String execute() {
+ return SUCCESS;
+ }
+
+ public InputStream getInputStream() {
+ WebService webService = ServiceFactory.getWebService();
+
+ InputStream input = null;
+ try {
+ File mapImage = webService.getMapFile(zone, species);
+ input = new FileInputStream(mapImage);
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ } catch (FileNotFoundException ex) {
+ throw new CoserWebException("Can't get map file", ex);
+ }
+
+ return input;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/MapDataAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -0,0 +1,90 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.map;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Action index, recupere la liste des resultats.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SpeciesAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1663244944108703571L;
+
+ private static final Log log = LogFactory.getLog(SpeciesAction.class);
+
+ protected String zone;
+
+ protected Map<String, String> species;
+
+ public String getZone() {
+ return zone;
+ }
+
+ public void setZone(String zone) {
+ this.zone = zone;
+ }
+
+ public Map<String, String> getSpecies() {
+ return species;
+ }
+
+ @Override
+ public String execute() {
+
+ if (log.isInfoEnabled()) {
+ log.info("Looking for species for zone " + zone);
+ }
+
+ WebService webService = ServiceFactory.getWebService();
+
+ try {
+ species = webService.getSpecies(zone);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Species are : " + species);
+ }
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone species", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SpeciesAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SubzoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SubzoneAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SubzoneAction.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.map;
+
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Affiche la liste des sous zones (zone).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SubzoneAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String mainZone;
+
+ public void setMainZone(String mainZone) {
+ this.mainZone = mainZone;
+ }
+
+ protected Map<String, String> zones;
+
+ public Map<String, String> getZones() {
+ return zones;
+ }
+
+ @Override
+ public String execute() {
+
+ WebService webService = ServiceFactory.getWebService();
+ try {
+
+ // renvoi la liste des id subzone-survey et leurs label
+ // associé
+ zones = webService.getSurveysForZone(mainZone);
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/SubzoneAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java 2011-01-10 16:06:29 UTC (rev 490)
@@ -0,0 +1,74 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.map;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Action index, affiche la liste des zones majeures (main zone).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ZoneAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected Map<String, String> mainZones;
+
+ public Map<String, String> getMainZones() {
+ return mainZones;
+ }
+
+ @Override
+ public String execute() {
+
+ mainZones = new HashMap<String, String>();
+
+ WebService webService = ServiceFactory.getWebService();
+ try {
+ Map<String, String[]> zonesMap = webService.getZonesMap();
+
+ for (Map.Entry<String, String[]> zoneMapEntry : zonesMap.entrySet()) {
+ mainZones.put(zoneMapEntry.getValue()[0], zoneMapEntry.getValue()[0]);
+ }
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/map/ZoneAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-web/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/web.xml 2011-01-10 14:42:03 UTC (rev 489)
+++ trunk/coser-web/src/main/webapp/WEB-INF/web.xml 2011-01-10 16:06:29 UTC (rev 490)
@@ -6,7 +6,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
@@ -42,27 +42,27 @@
<param-value>true</param-value>
</init-param>
</filter>
-
+
<filter>
<filter-name>struts-execute</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsExecuteFilter</filter-class>
</filter>
-
+
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class>
</filter>
-
+
<filter-mapping>
<filter-name>struts-prepare</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-
+
<filter-mapping>
<filter-name>struts-execute</filter-name>
<url-pattern>/*</url-pattern>
@@ -71,5 +71,4 @@
<listener>
<listener-class>org.apache.struts2.dispatcher.ng.listener.StrutsListener</listener-class>
</listener>
-
</web-app>
1
0
r489 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 14:42:03 +0000 (Mon, 10 Jan 2011)
New Revision: 489
Log:
Gestion des zones / sous zones (indicateurs)
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:33:20 UTC (rev 488)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:42:03 UTC (rev 489)
@@ -531,7 +531,7 @@
* Retourne les indicateurs calculés avec leurs traductions scientifique
* pour la zone et l'especes souhaitées.
*
- * @param zone zone
+ * @param zone zone (zoneid-surveyname)
* @param species especes
* @param locale locale ({@code fr} ou {@code en})
* @return la liste des indicateurs
@@ -540,32 +540,47 @@
public Map<String, String> getIndicators(String zone, String species, String locale) throws CoserBusinessException {
Map<String, String> indicators = new TreeMap<String, String>();
+ String zoneId = zone.substring(0, zone.indexOf('-'));
+ String survey = zone.substring(zone.indexOf('-') + 1);
+
// parcours des resultats disponibles
File projectsDirectory = config.getWebProjectsDirectory();
File[] projectFiles = projectsDirectory.listFiles();
if (projectFiles != null) {
for (File projectFile : projectFiles) {
if (projectFile.isDirectory()) {
- Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
+ File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File[] selectionFiles = selectionsDirectory.listFiles();
- for (Selection selection : project.getSelections().values()) {
- boolean resultFound = false;
+ // selection iteration
+ if (selectionFiles != null) {
+ for (File selectionFile : selectionFiles) {
+ if (selectionFile.isDirectory()) {
+ File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
+ File[] resultFiles = resultsDirectory.listFiles();
+
+ // result iteration
+ if (resultFiles != null) {
+ for (File resultFile : resultFiles) {
+ if (resultFile.isDirectory()) {
+ RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
- for (RSufiResult rsufiResult : selection.getRsufiResults()) {
-
- // extraction des especes pour le résultat demandé
- if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) {
- // data loading not necessary here
- Map<String, String> resultIndicators = getRsufiResultIndicators(project, selection, rsufiResult, species, locale);
- indicators.putAll(resultIndicators);
- resultFound = true;
- break;
+ // extraction des especes pour le résultat demandé
+ if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) {
+
+ // get survey name (other condition)
+ String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
+
+ // data loading not necessary here
+ Map<String, String> resultIndicators = getRsufiResultIndicators(resultFile, rsufiResult, species, locale);
+ indicators.putAll(resultIndicators);
+ break;
+ }
+ }
+ }
+ }
}
}
-
- if (resultFound) {
- break;
- }
}
}
}
@@ -578,29 +593,19 @@
* Recupere la liste de toutes les especes nom sci et nom off à partir
* d'un resultat.
*
- * @param project project
- * @param selection selection
+ * @param resultDirectory rsufi result directory
* @param rsufiResult result
* @param species to get indicator
* @param locale locale ({@code fr} ou {@code en})
* @return indicator for species
* @throws CoserBusinessException
*/
- protected Map<String, String> getRsufiResultIndicators(Project project,
- Selection selection, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException {
+ protected Map<String, String> getRsufiResultIndicators(File resultDirectory, RSufiResult rsufiResult, String species, String locale) throws CoserBusinessException {
MultiKeyMap defaultIndicators = getIndicatorsMap();
Map<String, String> result = new HashMap<String, String>();
- // on peu lours mais reconstruit le path jusqu'au fichier estcomind
- File projectsDirectory = config.getWebProjectsDirectory();
- File projectDirectory = new File(projectsDirectory, project.getName());
- File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY);
- File selectionDirectory = new File(selectionsDirectory, selection.getName());
- File resultsDirectory = new File(selectionDirectory, CoserConstants.STORAGE_RESULTS_DIRECTORY);
- File resultDirectory = new File(resultsDirectory, rsufiResult.getName());
-
// le fichier estcomind
File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());
1
0
r488 - in trunk: coser-business/src/main/java/fr/ifremer/coser coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/test/java/fr/ifremer/coser/services coser-business/src/test/resources coser-web/src/main/java/fr/ifremer/coser/web/actions/pop coser-web/src/main/webapp/WEB-INF/content/pop
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
by chatellier@users.labs.libre-entreprise.org 10 Jan '11
10 Jan '11
Author: chatellier
Date: 2011-01-10 14:33:20 +0000 (Mon, 10 Jan 2011)
New Revision: 488
Log:
Gestion des zones / sous zones
Added:
trunk/coser-business/src/test/resources/webindicators.csv
trunk/coser-business/src/test/resources/webzones.csv
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SubzoneAction.java
trunk/coser-web/src/main/webapp/WEB-INF/content/pop/subzone.jsp
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java
trunk/coser-web/src/main/webapp/WEB-INF/content/pop/zone.jsp
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -146,11 +146,19 @@
File result = getOptionAsFile(CoserBusinessOption.WEB_INDICATORS.key);
return result;
}
+
+ public void setWebIndicatorsFile(String indicatorsFile) {
+ setOption(CoserBusinessOption.WEB_INDICATORS.key, indicatorsFile);
+ }
public File getWebZonesFile() {
File result = getOptionAsFile(CoserBusinessOption.WEB_ZONES.key);
return result;
}
+
+ public void setWebZonesFile(String zoneFile) {
+ setOption(CoserBusinessOption.WEB_ZONES.key, zoneFile);
+ }
public List<String> getNewResultNotificationList() {
// la liste est vide si l'option est null
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -2840,6 +2840,31 @@
}
/**
+ * Look for project survey name in rsufi result.
+ * Read estcomind file to known that.
+ *
+ * @param resultDirectory result directory
+ * @param rSufiResult rsufi result
+ * @return survey name
+ * @throws CoserBusinessException
+ */
+ public String getProjectSurveyName(File resultDirectory, RSufiResult rSufiResult) throws CoserBusinessException {
+ String result = null;
+
+ // le fichier estcomind est moins gros que l'autre
+ String estComIndName = rSufiResult.getEstComIndName();
+ File estComIndFile = new File(resultDirectory, estComIndName);
+ DataStorage dataStorage = importService.loadCSVFile(estComIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
+ // Campagne Indicateur Liste Strate Annee Estimation EcartType CV
+ Iterator<String[]> itEstComIndData = dataStorage.iterator(true);
+ while (StringUtils.isEmpty(result) && itEstComIndData.hasNext()) {
+ result = itEstComIndData.next()[0];
+ }
+
+ return result;
+ }
+
+ /**
* Retourne tous les projets qui ont des résultats.
*
* De la forme d'une liste de de path (à la tree path) :
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -30,6 +30,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -61,6 +62,10 @@
* chargées persistent apres chargement, car elle ne peuvent pas changer
* tant que l'application est en cours d'utilisation.
*
+ * Il faut garder à l'esprit que les projets n'ont pas forcement
+ * de resultat, donc le chargement du projet est possible, mais
+ * pas les données de control et les données de selection.
+ *
* @author chatellier
* @version $Revision$
*
@@ -158,9 +163,9 @@
* <ul>
* <li>dezipage dans un fichier temporaire
* <li>recuperation des noms zone/souszone-campagne des nouveau fichiers
- * <li>suppression dans l'ancien répertoire des resultat deja present dans le nouveau (pour les conlfits)
- * <li>suppression des selections vide
- * <li>suppression des projets vide
+ * <li>suppression dans l'ancien répertoire des resultats deja presents dans le nouveau (pour les conflits)
+ * <li>suppression des selections vides
+ * <li>suppression des projets vides
* <li>copie (avec ecrasement) des nouveaux fichiers dans l'ancien répertoire
* </ul>
*
@@ -341,42 +346,131 @@
}
/**
- * Recuperer la liste des populations pour une zone données.
+ * Pour une zone principale, recupere la liste des couples sous-zone /
+ * campagne qui sont disponible dans cette zone principale.
*
- * @param zone zone
+ * @param mainZone main zone (le nom de la zone principale)
+ * @return couple subzoneid/sub
+ * @throws CoserBusinessException
+ */
+ public Map<String, String> getSurveysForZone(String mainZone) throws CoserBusinessException {
+ Map<String, String> surveyForZone = new HashMap<String, String>();
+
+ // get subzone for main zone
+ Collection<String> subZones = new ArrayList<String>();
+ for (Map.Entry<String, String[]> zoneEntry : getZonesMap().entrySet()) {
+ String[] zoneAndSubZone = zoneEntry.getValue();
+ if (zoneAndSubZone[0].equals(mainZone)) {
+ subZones.add(zoneEntry.getKey());
+ }
+ }
+
+ // get survey names in subZones collection
+ File[] projectFiles = config.getWebProjectsDirectory().listFiles();
+
+ // project iteration
+ if (projectFiles != null) {
+ for (File projectFile : projectFiles) {
+ if (projectFile.isDirectory()) {
+ File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File[] selectionFiles = selectionsDirectory.listFiles();
+
+ // selection iteration
+ if (selectionFiles != null) {
+ for (File selectionFile : selectionFiles) {
+ if (selectionFile.isDirectory()) {
+ File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
+ File[] resultFiles = resultsDirectory.listFiles();
+
+ // result iteration
+ if (resultFiles != null) {
+ for (File resultFile : resultFiles) {
+ if (resultFile.isDirectory()) {
+ RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
+ String resultZoneId = rsufiResult.getZone();
+ if (subZones.contains(resultZoneId)) {
+ String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
+ String zoneid = resultZoneId + "-" + surveyName;
+
+ // get zone name
+ String zoneName = "";
+ for (Map.Entry<String, String[]> zoneEntry : getZonesMap().entrySet()) {
+ if (zoneEntry.getKey().equals(resultZoneId)) {
+ zoneName = zoneEntry.getValue()[1];
+ }
+ }
+
+ zoneName += " - " + surveyName;
+ surveyForZone.put(zoneid, zoneName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return surveyForZone;
+ }
+
+ /**
+ * Recuperer la liste des populations pour une zone donnée.
+ *
+ * @param zone zone (zoneid-surveyname)
* @return map species nom info>nom officiel
* @throws CoserBusinessException
*/
public Map<String, String> getSpecies(String zone) throws CoserBusinessException {
-
+
Map<String, String> result = new TreeMap<String, String>();
-
+ String zoneId = zone.substring(0, zone.indexOf('-'));
+ String survey = zone.substring(zone.indexOf('-') + 1);
+
// parcours des resultats disponibles
File projectsDirectory = config.getWebProjectsDirectory();
File[] projectFiles = projectsDirectory.listFiles();
if (projectFiles != null) {
for (File projectFile : projectFiles) {
if (projectFile.isDirectory()) {
- Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
+ File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File[] selectionFiles = selectionsDirectory.listFiles();
- for (Selection selection : project.getSelections().values()) {
- boolean resultFound = false;
-
- for (RSufiResult rsufiResult : selection.getRsufiResults()) {
+ // selection iteration
+ if (selectionFiles != null) {
+ for (File selectionFile : selectionFiles) {
+ if (selectionFile.isDirectory()) {
+ File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
+ File[] resultFiles = resultsDirectory.listFiles();
+
+ // result iteration
+ if (resultFiles != null) {
+ for (File resultFile : resultFiles) {
+ if (resultFile.isDirectory()) {
+ RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
- // extraction des especes pour le résultat demandé
- if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) {
- Map<String, String> resultSpecies = getRsufiResultSpecies(project, selection, rsufiResult);
- result.putAll(resultSpecies);
- resultFound = true;
- break;
+ // extraction des especes pour le résultat demandé
+ if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zoneId)) {
+
+ // load project (without data to get reftax data)
+ Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
+
+ // get survey name (other condition)
+ String surveyName = projectService.getProjectSurveyName(resultFile, rsufiResult);
+ if (surveyName.equals(survey)) {
+ Map<String, String> resultSpecies = getRsufiResultSpecies(project, resultFile, rsufiResult);
+ result.putAll(resultSpecies);
+ break;
+ }
+ }
+ }
+ }
+ }
}
}
-
- if (resultFound) {
- break;
- }
}
}
}
@@ -390,13 +484,12 @@
* d'un resultat.
*
* @param project project
- * @param selection selection
- * @param rsufiResult rsufi result
+ * @param resultDirectory rsufi result directory
+ * @param rSUfiResult rsufi result
* @return map with each species code/species name
* @throws CoserBusinessException
*/
- protected Map<String, String> getRsufiResultSpecies(Project project,
- Selection selection, RSufiResult rsufiResult) throws CoserBusinessException {
+ protected Map<String, String> getRsufiResultSpecies(Project project, File resultDirectory, RSufiResult rsufiResult) throws CoserBusinessException {
Map<String, String> result = new HashMap<String, String>();
// load reftax in memory
@@ -412,16 +505,8 @@
speciesNames.put(speciesCode, speciesName);
}
-
- // get this selection data
// un peu lourd mais reconstruit le path jusqu'au fichier estcomind
- File projectsDirectory = config.getWebProjectsDirectory();
- File projectDirectory = new File(projectsDirectory, project.getName());
- File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY);
- File selectionDirectory = new File(selectionsDirectory, selection.getName());
- File resultsDirectory = new File(selectionDirectory, CoserConstants.STORAGE_RESULTS_DIRECTORY);
- File resultDirectory = new File(resultsDirectory, rsufiResult.getName());
File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());
// Campagne Indicateur Liste Espece Strate Annee Estimation EcartType CV
@@ -561,24 +646,35 @@
if (projectFiles != null) {
for (File projectFile : projectFiles) {
if (projectFile.isDirectory()) {
- Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
-
- for (Selection selection : project.getSelections().values()) {
- boolean resultFound = false;
-
- for (RSufiResult rsufiResult : selection.getRsufiResults()) {
- if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) {
- projectService.loadSelectionData(project, selection);
- Map<String, String> resultSpecies = getRsufiResultSpecies(project, selection, rsufiResult);
- //result.putAll(resultSpecies);
- resultFound = true;
- break;
+ File selectionsDirectory = new File(projectFile, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+ File[] selectionFiles = selectionsDirectory.listFiles();
+
+ // selection iteration
+ if (selectionFiles != null) {
+ for (File selectionFile : selectionFiles) {
+ if (selectionFile.isDirectory()) {
+ File resultsDirectory = new File(selectionFile, CoserConstants.STORAGE_RESULTS_DIRECTORY);
+ File[] resultFiles = resultsDirectory.listFiles();
+
+ // result iteration
+ if (resultFiles != null) {
+ for (File resultFile : resultFiles) {
+ if (resultFile.isDirectory()) {
+ RSufiResult rsufiResult = projectService.getRSufiResult(resultFile);
+ if (rsufiResult.getZone() != null && rsufiResult.getZone().equals(zone)) {
+
+ // load project (without data to get reftax data)
+ Project project = projectService.openProject(projectFile.getName(), projectsDirectory);
+
+ Map<String, String> resultSpecies = getRsufiResultSpecies(project, resultFile, rsufiResult);
+ //result.putAll(resultSpecies);
+ break;
+ }
+ }
+ }
+ }
}
}
-
- if (resultFound) {
- break;
- }
}
}
}
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -97,6 +97,9 @@
return result;
}
});
+
+ config.setWebIndicatorsFile(CoserTestAbstract.class.getResource("/webindicators.csv").getFile());
+ config.setWebZonesFile(CoserTestAbstract.class.getResource("/webzones.csv").getFile());
}
@AfterClass
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/WebServiceTest.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -27,8 +27,11 @@
import java.io.File;
import java.net.URL;
+import java.util.Map;
+import org.apache.commons.collections.map.MultiKeyMap;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import fr.ifremer.coser.CoserBusinessException;
@@ -44,19 +47,46 @@
*/
public class WebServiceTest extends CoserTestAbstract {
+ protected WebService webService;
+
+ @Before
+ public void initServices() {
+ webService = new WebService(config);
+ }
+
protected void assertFileExists(String filepath) {
File file = new File(filepath.replace('/', File.separatorChar));
- System.out.println("testing file " + file);
Assert.assertTrue(file.exists());
}
protected void assertFileNotExists(String filepath) {
File file = new File(filepath.replace('/', File.separatorChar));
- System.out.println("testing file " + file);
Assert.assertFalse(file.exists());
}
/**
+ * Test de lecture du fichier des indicateurs des resources de test.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testGetIndicators() throws CoserBusinessException {
+ MultiKeyMap indicators = webService.getIndicatorsMap();
+ Assert.assertEquals(62, indicators.size());
+ }
+
+ /**
+ * Test de lecture du fichier de zones de resources de test.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testGetZones() throws CoserBusinessException {
+ Map<String, String[]> zones = webService.getZonesMap();
+ Assert.assertEquals(16, zones.size());
+ }
+
+ /**
* Test que les upload successible merge bien les resultats en fonction
* des idenfiants des zones auquels ils sont affectés et que les resulats
* en conflit sont bien supprimé (avec si besoins leurs selections et projets).
@@ -64,8 +94,6 @@
*/
@Test
public void testUploadDirectoyMerge() throws CoserBusinessException {
- WebService webService = new WebService(config);
-
URL firstUpload = WebServiceTest.class.getResource("/web/upload1.zip");
File firstUploadFile = new File(firstUpload.getFile());
webService.registerNewUploadedResults(firstUploadFile);
Added: trunk/coser-business/src/test/resources/webindicators.csv
===================================================================
--- trunk/coser-business/src/test/resources/webindicators.csv (rev 0)
+++ trunk/coser-business/src/test/resources/webindicators.csv 2011-01-10 14:33:20 UTC (rev 488)
@@ -0,0 +1,33 @@
+"id";"label_fr";"label_en"
+"Abundance";"Abondance totale dans la zone (valeur relative)";"Total abundance in the area (relative value)"
+"Biomass";"Biomasse totale dans la zone (valeur relative)";"Total biomass in the area (relative value)"
+"Dbar";"Densité relative dans la zone";"Relative density in the area"
+"l0.05";"Longueur au 5ème percentile de la distribution de longueur";"Length at the fifth percentile of the length distribution"
+"l0.25";"Longueur au 25ème percentile de la distribution de longueur";"Length at the twenty-fifth percentile of the length distribution"
+"l0.75";"Longueur au 75ème percentile de la distribution de longueur";"Length at the seventy-fifth percentile of the length distribution"
+"l0.95";"Longueur au 95ème percentile de la distribution de longueur";"Length at the ninety- fifth percentile of the length distribution"
+"L50";"Taille à 50 % de maturité";"Size at 50 % maturity"
+"Lbar";"Longueur moyenne dans la population";"Mean length in the population"
+"lnN";"Logarithme naturel de l'abondance";"Natural Logarithm of abundance"
+"lvar";"Variance de la longueur dans l'échantillon";"Sample variance of length measurements"
+"PropMat";"Proportion de matures";"Proportion of mature individuals"
+"sexRatio";"Sexe ratio (males/femelles)";"Sex ratio (males/females)"
+"Wbar";"Poids individuel moyen dans la population";"Average individual weight in the population"
+"biomBig";"Biomasse des grandes espèces (valeur relative)";"Biomass of the large species (relative value)"
+"biomSmall";"Biomasse des petites espèces (valeur relative)";"Biomass of the small species (relative value)"
+"Btot";"Biomasse totale dans la zone (valeur relative)";"Total biomass in the area (relative value)"
+"Delta";"Indice de diversité \u0394";"Diversity index \u0394"
+"Gtot";"Moyenne géométrique du nombre par espèce";"Geometric mean of species abundances"
+"Lbcomm";"Taille moyenne dans communauté";"Average length in community"
+"meanQuant0.95";"Moyenne des l0;95 des espèces";"Average across species of l0;95"
+"meanWbar";"Moyenne des Wbar par espèce";"Average of species Wbar "
+"Ntot";"Abondance totale dans la zone (valeur relative)";"Total abundance in the area (relative value)"
+"propL15";"Proportion des grands individus en nombre (taille seuil 15 cm)";"Proportion of large individuals in numbers (threshold size 15 cm)"
+"propL20";"Proportion des grands individus en nombre (taille seuil 20 cm)";"Proportion of large individuals in numbers (threshold size 20 cm)"
+"propL25";"Proportion des grands individus en nombre (taille seuil 25 cm)";"Proportion of large individuals in numbers (threshold size 25 cm)"
+"propL30";"Proportion des grands individus en nombre (taille seuil 30 cm)";"Proportion of large individuals in numbers (threshold size 30 cm)"
+"propLW";"Proportion des grands individus en poids (/ taille seuil spécifique à la zone)";"Proportion of large individuals in weight (/ threshold length area specific)"
+"Shannonmod";"Indice de Shannon normalisé / première année";"Shannon index normalized wrt the first year"
+"Wbcomm";"Poids moyen d'un individu";"Average weight of an individual"
+"Wtot";"Biomasse totale dans la zone (valeur relative)";"Total biomass in the area (relative value)"
+
Added: trunk/coser-business/src/test/resources/webzones.csv
===================================================================
--- trunk/coser-business/src/test/resources/webzones.csv (rev 0)
+++ trunk/coser-business/src/test/resources/webzones.csv 2011-01-10 14:33:20 UTC (rev 488)
@@ -0,0 +1,19 @@
+"id";"zone";"subzone";"periode";"serie";"comment";"map"
+"ciem4b4c";"Mer du Nord";"CIEM 4b - 4c";"1983";"IBTS";"D'après données internationales extraites de la base Datras du CIEM";"C_Ciem-4b-4c.jpg"
+"ciem4c";"Mer du Nord";"CIEM 4c";"1983";"IBTS";"D'après données internationales extraites de la base Datras du CIEM";"C_Ciem-4c.jpg"
+"ciem4ce7d";"Mer du Nord";"CIEM 4c - Est 7d";"2007";"IBTS";"D'après données internationales extraites de la base Datras du CIEM";"C_Ciem-4c-E7d.jpg"
+"ciem4c4e7d";"Mer du Nord";"CIEM 4c4 - Est 7d";"2007";"IBTS";"- Détroit du Pas-de-Calais\n- D'après données internationales extraites de la base Datras du CIEM";"C_Ciem-4c4-E7d.jpg"
+"cieme7d";"Manche orientale";"Est de 1° 15' O";"1988 ";"CGFS";;"C_Ciem-E7d.jpg"
+"ciem7d";"Manche orientale";"Ensemble Manche orientale";"1990";"CGFS";"Correspond à l'ensemble de la zone VIId du CIEM";"C_Ciem-7d.jpg"
+"noursom";"Manche orientale";"Baie de Somme";"1994";"Noursom";;"C_Noursom.jpg"
+"noursein";"Manche orientale";"Baie de Seine";"1995 - 2010";"Noursein";"Série arrêtée en 2010";"C_Noursein.jpg"
+"crustaflam";"Manche occidentale";"Abords du cap de Flamanville";"1986";"Crustaflam";;"C_Crustaflam.jpg"
+"gdgmc";"Atlantique";"Golfe de Gascogne + mer Celtique";"1997";"Evhoe";"Ensemble de la couverture Evhoe";"C_GdG-MC.jpg"
+"mcech";"Atlantique";"Mer Celtique (strates d'échantillonnage)";"1997";"Evhoe";;"C_MC-Ech.jpg"
+"mcciem7";"Atlantique";"Mer Celtique (zone VII du CIEM)";"1997";"Evhoe";"La limite sud de la zone VII du CIEM (48 °N) constitue aussi une limite de régions de la DCSMM";"C_MC-Ciem-7.jpg"
+"gdgech";"Atlantique";"Golfe de Gascogne (strates d'échantillonnage)";"1987";"Evhoe";;"C_GdG-Ech.jpg"
+"gdgciem7";"Atlantique";"Golfe de Gascogne (zone VIII du CIEM)";"1987";"Evhoe";"La limite nord de la zone VIII du CIEM (48 °N) constitue aussi une limite de régions de la DCSMM";"C_GdG-Ciem-7.jpg"
+"gdl";"Méditerranée";"Golfe du Lion";"1994";"Medits";;"C_GdL.jpg"
+"ecorse";"Méditerranée";"Est-Corse";"1994";"Medits";"1997 exclue (couverture incomplète)";"C_E-Corse.jpg"
+
+
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/GraphAction.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/IndicatorAction.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SpeciesAction.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
Added: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SubzoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SubzoneAction.java (rev 0)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SubzoneAction.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -0,0 +1,76 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ * #L%
+ */
+
+package fr.ifremer.coser.web.actions.pop;
+
+import java.util.Map;
+
+import com.opensymphony.xwork2.ActionSupport;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
+/**
+ * Affiche la liste des sous zones (zone).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SubzoneAction extends ActionSupport {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3385467755357775199L;
+
+ protected String mainZone;
+
+ public void setMainZone(String mainZone) {
+ this.mainZone = mainZone;
+ }
+
+ protected Map<String, String> zones;
+
+ public Map<String, String> getZones() {
+ return zones;
+ }
+
+ @Override
+ public String execute() {
+
+ WebService webService = ServiceFactory.getWebService();
+ try {
+
+ // renvoi la liste des id subzone-survey et leurs label
+ // associé
+ zones = webService.getSurveysForZone(mainZone);
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
+ return SUCCESS;
+ }
+}
Property changes on: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/SubzoneAction.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/pop/ZoneAction.java 2011-01-10 14:33:20 UTC (rev 488)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
@@ -27,8 +27,13 @@
import com.opensymphony.xwork2.ActionSupport;
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.services.WebService;
+import fr.ifremer.coser.web.CoserWebException;
+import fr.ifremer.coser.web.ServiceFactory;
+
/**
- * Action index, affiche une liste fixe de 10 zones.
+ * Action index, affiche la liste des zones majeures (main zone).
*
* @author chatellier
* @version $Revision$
@@ -41,30 +46,29 @@
/** serialVersionUID. */
private static final long serialVersionUID = 3385467755357775199L;
- protected Map<String, String> zones;
-
- public Map<String, String> getZones() {
- return zones;
+ protected Map<String, String> mainZones;
+
+ public Map<String, String> getMainZones() {
+ return mainZones;
}
@Override
public String execute() {
- zones = new HashMap<String, String>();
- zones.put("manchecgfs", "Plateau - Manche CGFS");
- zones.put("celtiqueevhoe", "Plateau - Celtique EVHOE");
- zones.put("gascogneevhoe", "Plateau - Gascogne EVHOE");
- zones.put("gascogneressgasc01", "Plateau - Gascogne RESSGASC_01");
- zones.put("gascogneressgasc02", "Plateau - Gascogne RESSGASC_02");
- zones.put("gascogneressgasc03", "Plateau - Gascogne RESSGASC_03");
- zones.put("gascogneressgasc04", "Plateau - Gascogne RESSGASC_04");
- zones.put("lionmedtis", "Plateau - Lion MEDITS");
- zones.put("estcorsemedits", "Plateau - Est-Corse MEDITS");
- zones.put("sommenoursom", "Baie - Somme NOURSOM");
- zones.put("seinenoursei", "Baie - Seine NOURSEI");
- zones.put("vilainenourvil", "Baie - Vilaine NOURVIL");
- zones.put("crustaflamjuin", "Cap - Flamanville CRUSTAFLAM Juin");
+ mainZones = new HashMap<String, String>();
+ WebService webService = ServiceFactory.getWebService();
+ try {
+ Map<String, String[]> zonesMap = webService.getZonesMap();
+
+ for (Map.Entry<String, String[]> zoneMapEntry : zonesMap.entrySet()) {
+ mainZones.put(zoneMapEntry.getValue()[0], zoneMapEntry.getValue()[0]);
+ }
+
+ } catch (CoserBusinessException ex) {
+ throw new CoserWebException("Can't get zone map", ex);
+ }
+
return SUCCESS;
}
}
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/pop/subzone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/pop/subzone.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/pop/subzone.jsp 2011-01-10 14:33:20 UTC (rev 488)
@@ -0,0 +1,47 @@
+<!--
+ #%L
+ Coser :: Web
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ #L%
+ -->
+<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<%@taglib uri="/struts-tags" prefix="s" %>
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>Coser</title>
+ </head>
+ <body>
+
+ <img src="<s:url value='/images/zonesmap.jpg' />" />
+
+ <br />
+
+ <s:if test="%{zones.isEmpty()}">
+ No result founds
+ </s:if>
+ <s:else>
+ <s:form action="species" method="get">
+ <s:select name="zone" list="zones" label="Select a sub zone" />
+ <s:submit label="Suite"/>
+ </s:form>
+ </s:else>
+ </body>
+</html>
\ No newline at end of file
Modified: trunk/coser-web/src/main/webapp/WEB-INF/content/pop/zone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/pop/zone.jsp 2011-01-07 12:45:07 UTC (rev 487)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/pop/zone.jsp 2011-01-10 14:33:20 UTC (rev 488)
@@ -34,8 +34,8 @@
<br />
- <s:form action="species" method="get">
- <s:select name="zone" list="zones" label="Select a zone" />
+ <s:form action="subzone" method="get">
+ <s:select name="mainZone" list="mainZones" label="Select a zone" />
<s:submit label="Suite"/>
</s:form>
</body>
1
0
r487 - trunk/coser-business/src/main/java/fr/ifremer/coser
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
07 Jan '11
Author: chatellier
Date: 2011-01-07 12:45:07 +0000 (Fri, 07 Jan 2011)
New Revision: 487
Log:
Fix setter
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 12:43:39 UTC (rev 486)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 12:45:07 UTC (rev 487)
@@ -74,7 +74,7 @@
return result;
}
- public void setsmtpHost(String smtpHost) {
+ public void setSmtpHost(String smtpHost) {
setOption(CoserBusinessOption.SMTP_HOST.key, smtpHost);
}
1
0
r486 - in trunk: coser-business coser-business/src/main/java/fr/ifremer/coser coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-ui/src/main/java/fr/ifremer/coser coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/resources/i18n coser-web/src/main/java/fr/ifremer/coser/web
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
07 Jan '11
Author: chatellier
Date: 2011-01-07 12:43:39 +0000 (Fri, 07 Jan 2011)
New Revision: 486
Log:
Envoi d'un mail apres la publication des resultats
Modified:
trunk/coser-business/pom.xml
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java
Modified: trunk/coser-business/pom.xml
===================================================================
--- trunk/coser-business/pom.xml 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/pom.xml 2011-01-07 12:43:39 UTC (rev 486)
@@ -56,6 +56,10 @@
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
+ <artifactId>commons-email</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
<artifactId>commons-math</artifactId>
</dependency>
<dependency>
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -28,6 +28,7 @@
import static org.nuiton.i18n.I18n._;
import java.io.File;
+import java.util.List;
import java.util.Locale;
import org.nuiton.util.ApplicationConfig;
@@ -73,6 +74,15 @@
return result;
}
+ public void setsmtpHost(String smtpHost) {
+ setOption(CoserBusinessOption.SMTP_HOST.key, smtpHost);
+ }
+
+ public String getSmtpHost() {
+ String result = getOption(CoserBusinessOption.SMTP_HOST.key);
+ return result;
+ }
+
public Locale getLocale() {
Locale result = getOption(Locale.class, CoserBusinessOption.LOCALE.key);
return result;
@@ -142,12 +152,19 @@
return result;
}
+ public List<String> getNewResultNotificationList() {
+ // la liste est vide si l'option est null
+ List<String> emails = getOptionAsList(CoserBusinessOption.WEB_PUBLICATION_EMAIL.key).getOption();
+ return emails;
+ }
+
public static enum CoserBusinessOption implements OptionDef {
DATABASE_DIRECTORY("coser.database.directory", _("coser.config.database.directory.description"), "${user.home}" + File.separator + "coser", String.class, false, false),
PROJECTS_DIRECTORY("coser.projects.directory", _("coser.config.projects.directory.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "projects", String.class, false, false),
VALIDATOR_DIRECTORY("coser.validator.directory", _("coser.config.validator.directory.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "validators", String.class, false, false),
+ SMTP_HOST("coser.smtp.host", _("coser.config.smtp.host.description"), "smtp", String.class, false, false),
LOCALE("coser.locale", _("coser.config.locale.description"), Locale.FRANCE.toString(), Locale.class, false, false),
REFERENCE_SPECIES("coser.reference.species", _("coser.config.reference.species.description"), "", String.class, false, false),
@@ -167,7 +184,8 @@
WEB_PROPERTIES_FILE("coser.web.properties.file", _("coser.config.web.properties.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "web.properties", String.class, false, false),
WEB_PROJECTS_DIRECTORY("coser.web.projects.directory", _("coser.config.web.projects.directory.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webprojects", String.class, false, false),
WEB_INDICATORS("coser.web.indicators.file", _("coser.config.web.indicators.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webindicators.csv", String.class, false, false),
- WEB_ZONES("coser.web.zones.file", _("coser.config.web.zones.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webzones.csv", String.class, false, false);
+ WEB_ZONES("coser.web.zones.file", _("coser.config.web.zones.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webzones.csv", String.class, false, false),
+ WEB_PUBLICATION_EMAIL("coser.web.newresult.emails", _("coser.config.web.newresult.emails.description"), null, String.class, false, false);
protected String key;
protected String description;
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -80,7 +80,6 @@
import org.nuiton.math.matrix.MatrixND;
import org.nuiton.math.matrix.MatrixProvider;
import org.nuiton.util.FileUtil;
-import org.nuiton.util.StringUtil;
import org.nuiton.util.ZipUtil;
import fr.ifremer.coser.CoserBusinessConfig;
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -25,6 +25,8 @@
package fr.ifremer.coser.services;
+import static org.nuiton.i18n.I18n._;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,6 +41,8 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.MultiPartEmail;
import org.nuiton.util.FileUtil;
import org.nuiton.util.ZipUtil;
@@ -187,6 +191,9 @@
log.info("Unzipping file " + archiveFile + " to " + projectsDirectory);
}
+ // send notification mails
+ sendNewResultNotifications();
+
} catch (IOException ex) {
throw new CoserBusinessException("Can't uncompress file", ex);
}
@@ -308,6 +315,32 @@
}
/**
+ * Envoi un mail de notification apres la publication des resultat à la
+ * liste des adresses email renseignées dans la configuration.
+ */
+ protected void sendNewResultNotifications() {
+ List<String> emails = config.getNewResultNotificationList();
+
+ for (String email : emails) {
+ try {
+ MultiPartEmail emailPart = new MultiPartEmail();
+ emailPart.setHostName(config.getSmtpHost());
+ emailPart.addTo(email);
+ emailPart.setFrom("noreply-coser at ifremer.fr", "Coser");
+ emailPart.setSubject(_("coser.business.notificationmail.subject"));
+ emailPart.setContent(_("coser.business.notificationmail.body"), "text/plain; charset=ISO-8859-9");
+
+ // send mail
+ emailPart.send();
+ } catch (EmailException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't send mail", ex);
+ }
+ }
+ }
+ }
+
+ /**
* Recuperer la liste des populations pour une zone données.
*
* @param zone zone
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-01-07 12:43:39 UTC (rev 486)
@@ -71,6 +71,8 @@
coser.business.matrix.lengthstructure=Length structures
coser.business.matrix.occurrence=Occurrence
coser.business.matrix.samplingeffort=Sampling effort
+coser.business.notificationmail.body=New results has been published.\n\n--\nCoser.
+coser.business.notificationmail.subject=Coser \: New results published
coser.business.publication.author=Author
coser.business.publication.catchfilename=Catch file name
coser.business.publication.comment=Comment
@@ -102,9 +104,11 @@
coser.config.reference.typeSpecies.description=Code type species file location
coser.config.selection.densityFilter.description=Default density filter value
coser.config.selection.occurrenceFilter.description=Default occurrence filter value
+coser.config.smtp.host.description=SMTP host address
coser.config.validator.directory.description=Validation files directory location
coser.config.web.frontend.description=Coser server url
coser.config.web.indicators.file.description=Indicators match file
+coser.config.web.newresult.emails.description=New results notification receivers
coser.config.web.projects.directory.description=Web projects storage directory
coser.config.web.properties.file.description=Web informations properties file
coser.config.web.uploadurl.description=Coser server upload result url
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-01-07 12:43:39 UTC (rev 486)
@@ -71,6 +71,8 @@
coser.business.matrix.lengthstructure=Structures en taille
coser.business.matrix.occurrence=Occurrence
coser.business.matrix.samplingeffort=Effort d'\u00E9chantillonnage
+coser.business.notificationmail.body=De nouveaux r\u00E9sultats viennent d'\u00EAtre publi\u00E9s.\n\n--\nCoser.
+coser.business.notificationmail.subject=Coser \: Nouveaux r\u00E9sultats publi\u00E9s
coser.business.publication.author=Auteur
coser.business.publication.catchfilename=Nom du fichier captures
coser.business.publication.comment=Commentaire
@@ -102,9 +104,11 @@
coser.config.reference.typeSpecies.description=Emplacement du fichier de code type des esp\u00E8ces
coser.config.selection.densityFilter.description=Filtre par d\u00E9faut sur la moyenne des densit\u00E9s
coser.config.selection.occurrenceFilter.description=Filtre par d\u00E9faut sur la moyenne des occurrences
+coser.config.smtp.host.description=Adresse du serveur SMTP pour envoyer les mails
coser.config.validator.directory.description=Emplacement des fichiers de validations
coser.config.web.frontend.description=Adresse du serveur web coser
coser.config.web.indicators.file.description=Fichier de correspondance des indicateurs
+coser.config.web.newresult.emails.description=Liste des destinataires des notifications de nouveaux r\u00E9sultats
coser.config.web.projects.directory.description=Dossier de stockage des projets pour le Web
coser.config.web.properties.file.description=Fichier d'enregistrement des informations serveur
coser.config.web.uploadurl.description=Adresse d'envoi des r\u00E9sultats
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -62,15 +62,6 @@
return result;
}
- public void setsmtpHost(String smtpHost) {
- setOption(CoserOption.SMTP_HOST.key, smtpHost);
- }
-
- public String getSmtpHost() {
- String result = getOption(CoserOption.SMTP_HOST.key);
- return result;
- }
-
public void setSupportEmail(String supportEmail) {
setOption(CoserOption.SUPPORT_EMAIL.key, supportEmail);
}
@@ -90,7 +81,6 @@
CONFIG_FILE(CONFIG_FILE_NAME, _("coser.config.config.file.description"), "coser.properties", String.class, true, true),
LOOKANDFEEL("coser.lookandfeel", _("coser.config.lookandfeel.description"), null, String.class, false, false),
APPLICATION_VERSION("coser.application.version", _("coser.config.application.version.description"), null, String.class, false, false),
- SMTP_HOST("coser.smtp.host", _("coser.config.smtp.host.description"), "smtp", String.class, false, false),
SUPPORT_EMAIL("coser.support.email", _("coser.config.support.email.description"), "support at codelutin.com", String.class, false, false),
WEBSITE_URL("coser.website", _("coser.config.website.description"), "http://coser.labs.libre-entreprise.org/", String.class, false, false);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -194,7 +194,7 @@
// category misc
modelBuilder.addCategory(_("coser.config.category.misc"), _("coser.config.category.misc.description"));
- modelBuilder.addOption(CoserConfig.CoserOption.SMTP_HOST);
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SMTP_HOST);
modelBuilder.addOption(CoserConfig.CoserOption.SUPPORT_EMAIL);
ConfigUI configUI = modelBuilder.buildUI(view, _("coser.config.category.path"));
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2011-01-07 12:43:39 UTC (rev 486)
@@ -7,7 +7,6 @@
coser.config.category.path.description=File and directory configuration
coser.config.config.file.description=Coser configuration file
coser.config.lookandfeel.description=Application's swing theme
-coser.config.smtp.host.description=SMTP host address
coser.config.support.email.description=Support email address
coser.config.website.description=Coser website
coser.ui.common.cancel=Cancel
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2011-01-07 12:43:39 UTC (rev 486)
@@ -7,7 +7,6 @@
coser.config.category.path.description=Configuration des fichiers et r\u00E9pertoires
coser.config.config.file.description=Fichier de configuration de Coser
coser.config.lookandfeel.description=Themes graphique Swing de l'application
-coser.config.smtp.host.description=Adresse du serveur SMTP pour envoyer les mails
coser.config.support.email.description=Adresse de support pour l'envoi des erreurs
coser.config.website.description=Site internet de Coser
coser.ui.common.cancel=Annuler
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java 2011-01-07 10:27:40 UTC (rev 485)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/ServiceFactory.java 2011-01-07 12:43:39 UTC (rev 486)
@@ -22,6 +22,7 @@
package fr.ifremer.coser.web;
+import org.nuiton.i18n.I18n;
import org.nuiton.util.ArgumentsParserException;
import fr.ifremer.coser.services.WebService;
@@ -41,6 +42,11 @@
protected static WebService webService;
+ static {
+ // on a pas trop de locale là :(
+ I18n.init();
+ }
+
/**
* Get application config configuration.
*
1
0
r485 - in trunk: coser-business/src/main/java/fr/ifremer/coser coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-ui/src/main/java/fr/ifremer/coser/ui coser-web/src/main/java/fr/ifremer/coser/web coser-web/src/main/java/fr/ifremer/coser/web/actions
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
07 Jan '11
Author: chatellier
Date: 2011-01-07 10:27:40 +0000 (Fri, 07 Jan 2011)
New Revision: 485
Log:
Modification de la configuration pour la partie web.
Le fichier zone est maintenant optionnel.
Removed:
trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConstants.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java
trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -122,23 +122,23 @@
return result;
}
- public File getWebServerDirectory() {
- File result = getOptionAsFile(CoserBusinessOption.WEB_SERVER_DIRECTORY.key);
+ public File getWebPropertiesFile() {
+ File result = getOptionAsFile(CoserBusinessOption.WEB_PROPERTIES_FILE.key);
return result;
}
-
+
public File getWebProjectsDirectory() {
File result = getOptionAsFile(CoserBusinessOption.WEB_PROJECTS_DIRECTORY.key);
return result;
}
-
- public File getMatchIndicatorsFile() {
- File result = getOptionAsFile(CoserBusinessOption.WEB_MATCH_INDICATORS.key);
+
+ public File getWebIndicatorsFile() {
+ File result = getOptionAsFile(CoserBusinessOption.WEB_INDICATORS.key);
return result;
}
- public File getMatchZonesFile() {
- File result = getOptionAsFile(CoserBusinessOption.WEB_MATCH_ZONES.key);
+ public File getWebZonesFile() {
+ File result = getOptionAsFile(CoserBusinessOption.WEB_ZONES.key);
return result;
}
@@ -164,10 +164,10 @@
WEB_UPLOAD_URL("coser.web.uploadurl", _("coser.config.web.uploadurl.description"), "${" + WEB_FRONT_END.key + "}/upload-result.action", String.class, false, false),
/** Server side. */
- WEB_SERVER_DIRECTORY("coser.web.server.directory", _("coser.config.web.server.directory.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "web", String.class, false, false),
- WEB_PROJECTS_DIRECTORY("coser.web.projects.directory", _("coser.config.web.projects.directory.description"), "${" + WEB_SERVER_DIRECTORY.key + "}" + File.separator + "projects", String.class, false, false),
- WEB_MATCH_INDICATORS("coser.web.matchindicators.file", _("coser.config.web.matchindicators.file.description"), "${" + WEB_SERVER_DIRECTORY.key + "}" + File.separator + "matchindicators.csv", String.class, false, false),
- WEB_MATCH_ZONES("coser.web.matchzones.file", _("coser.config.web.matchzones.file.description"), "${" + WEB_SERVER_DIRECTORY.key + "}" + File.separator + "matchzones.csv", String.class, false, false);
+ WEB_PROPERTIES_FILE("coser.web.properties.file", _("coser.config.web.properties.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "web.properties", String.class, false, false),
+ WEB_PROJECTS_DIRECTORY("coser.web.projects.directory", _("coser.config.web.projects.directory.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webprojects", String.class, false, false),
+ WEB_INDICATORS("coser.web.indicators.file", _("coser.config.web.indicators.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webindicators.csv", String.class, false, false),
+ WEB_ZONES("coser.web.zones.file", _("coser.config.web.zones.file.description"), "${" + DATABASE_DIRECTORY.key + "}" + File.separator + "webzones.csv", String.class, false, false);
protected String key;
protected String description;
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -97,7 +97,7 @@
if (indicatorsMap == null) {
indicatorsMap = new MultiKeyMap();
- File indicatorsFile = config.getMatchIndicatorsFile();
+ File indicatorsFile = config.getWebIndicatorsFile();
DataStorage indicatorsStorage = importService.loadCSVFile(indicatorsFile);
Iterator<String[]> iteratorInd = indicatorsStorage.iterator(true);
while (iteratorInd.hasNext()) {
@@ -121,15 +121,26 @@
public Map<String, String[]> getZonesMap() throws CoserBusinessException {
if (zonesMap == null) {
- zonesMap = new HashMap<String, String[]>();
- File zoneFile = config.getMatchZonesFile();
- DataStorage zonesStorage = importService.loadCSVFile(zoneFile);
- Iterator<String[]> iteratorZones = zonesStorage.iterator(true);
- while (iteratorZones.hasNext()) {
- // "id";"zone";"subzone";"periode";"serie";"comment";"map"
- String[] zone = iteratorZones.next();
- zonesMap.put(zone[0], new String[]{zone[1], zone[2]});
+ File zoneFile = config.getWebZonesFile();
+
+ // l'operation n'est pas obligatoire pour tous les clients
+ // lourd, le fichier peut donc ne pas exister
+ if (zoneFile.isFile()) {
+ zonesMap = new HashMap<String, String[]>();
+
+ DataStorage zonesStorage = importService.loadCSVFile(zoneFile);
+ Iterator<String[]> iteratorZones = zonesStorage.iterator(true);
+ while (iteratorZones.hasNext()) {
+ // "id";"zone";"subzone";"periode";"serie";"comment";"map"
+ String[] zone = iteratorZones.next();
+ zonesMap.put(zone[0], new String[]{zone[1], zone[2]});
+ }
}
+ else {
+ // fait volontairement un return new, n'affecte pas l'etat du
+ // service
+ return new HashMap<String, String[]>();
+ }
}
return zonesMap;
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-01-07 10:27:40 UTC (rev 485)
@@ -104,11 +104,11 @@
coser.config.selection.occurrenceFilter.description=Default occurrence filter value
coser.config.validator.directory.description=Validation files directory location
coser.config.web.frontend.description=Coser server url
-coser.config.web.matchindicators.file.description=Indicators match file
-coser.config.web.matchzones.file.description=Zones match file
+coser.config.web.indicators.file.description=Indicators match file
coser.config.web.projects.directory.description=Web projects storage directory
-coser.config.web.server.directory.description=Coser server storage directory
+coser.config.web.properties.file.description=Web informations properties file
coser.config.web.uploadurl.description=Coser server upload result url
+coser.config.web.zones.file.description=Zones match file
depth\ attribute\ is\ not\ a\ valid\ double=
haul\ name\ is\ not\ valid=
lat\ attribute\ is\ not\ a\ valid\ double=
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-01-07 10:27:40 UTC (rev 485)
@@ -104,11 +104,11 @@
coser.config.selection.occurrenceFilter.description=Filtre par d\u00E9faut sur la moyenne des occurrences
coser.config.validator.directory.description=Emplacement des fichiers de validations
coser.config.web.frontend.description=Adresse du serveur web coser
-coser.config.web.matchindicators.file.description=Fichier de correspondance des indicateurs
-coser.config.web.matchzones.file.description=Fichier de correspondance des zones
+coser.config.web.indicators.file.description=Fichier de correspondance des indicateurs
coser.config.web.projects.directory.description=Dossier de stockage des projets pour le Web
-coser.config.web.server.directory.description=Dossier de stockage des projets sur le serveur
+coser.config.web.properties.file.description=Fichier d'enregistrement des informations serveur
coser.config.web.uploadurl.description=Adresse d'envoi des r\u00E9sultats
+coser.config.web.zones.file.description=Fichier de correspondance des zones
depth\ attribute\ is\ not\ a\ valid\ double=L'attribut ProfMoy n'est pas un r\u00E9el valide
haul\ name\ is\ not\ valid=L'attribut Trait n'est pas valide
lat\ attribute\ is\ not\ a\ valid\ double=L'attribut Lat n'est pas un r\u00E9el valide
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -182,6 +182,7 @@
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_SPECIES);
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_TYPE_ESPECES);
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.WEB_FRONT_END);
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.WEB_ZONES);
// category control
modelBuilder.addCategory(_("coser.config.category.configuration"), _("coser.config.category.configuration.description"));
Deleted: trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConstants.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConstants.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/CoserWebConstants.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -1,38 +0,0 @@
-/*
- * #%L
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- * #L%
- */
-
-package fr.ifremer.coser.web;
-
-/**
- * Constantes cote web.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class CoserWebConstants {
-
- /** Nom du fichier de proprietes du serveur. */
- public static final String WEB_PROPERTIES_NAME = "web.properties";
-}
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/IndexAction.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -37,7 +37,6 @@
import com.opensymphony.xwork2.ActionSupport;
import fr.ifremer.coser.web.CoserWebConfig;
-import fr.ifremer.coser.web.CoserWebConstants;
import fr.ifremer.coser.web.CoserWebException;
import fr.ifremer.coser.web.ServiceFactory;
@@ -82,7 +81,7 @@
public String execute() {
CoserWebConfig config = ServiceFactory.getCoserConfig();
- File webProperties = new File(config.getWebServerDirectory(), CoserWebConstants.WEB_PROPERTIES_NAME);
+ File webProperties = config.getWebPropertiesFile();
if (webProperties.isFile()) {
// get update date
Modified: trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java
===================================================================
--- trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java 2011-01-07 09:09:33 UTC (rev 484)
+++ trunk/coser-web/src/main/java/fr/ifremer/coser/web/actions/UploadResultAction.java 2011-01-07 10:27:40 UTC (rev 485)
@@ -40,7 +40,6 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.services.WebService;
import fr.ifremer.coser.web.CoserWebConfig;
-import fr.ifremer.coser.web.CoserWebConstants;
import fr.ifremer.coser.web.CoserWebException;
import fr.ifremer.coser.web.ServiceFactory;
@@ -127,7 +126,7 @@
protected void updateDataProperties() {
CoserWebConfig config = ServiceFactory.getCoserConfig();
- File webProperties = new File(config.getWebServerDirectory(), CoserWebConstants.WEB_PROPERTIES_NAME);
+ File webProperties = config.getWebPropertiesFile();
Properties props = new Properties();
InputStream iStream = null;
1
0
r484 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
by chatellier@users.labs.libre-entreprise.org 07 Jan '11
07 Jan '11
Author: chatellier
Date: 2011-01-07 09:09:33 +0000 (Fri, 07 Jan 2011)
New Revision: 484
Log:
Ajout du nom de la campagne dans la liste des zones
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx 2011-01-07 09:01:34 UTC (rev 483)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/SelectionAddResultDialog.jaxx 2011-01-07 09:09:33 UTC (rev 484)
@@ -5,7 +5,7 @@
$Id$
$HeadURL$
%%
- Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ Copyright (C) 2010 - 2011 Ifremer, Codelutin, Chatellier Eric
%%
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as
@@ -67,7 +67,7 @@
</cell>
<cell fill="horizontal" columns="2">
<JComboBox id="resultZoneCombo" model="{new ZoneComboBoxModel(this)}"
- renderer="{new ZoneComboBoxRenderer()}"
+ renderer="{new ZoneComboBoxRenderer(this)}"
onActionPerformed='getRsufiResult().setZone((String)resultZoneCombo.getSelectedItem())'/>
</cell>
</row>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java 2011-01-07 09:01:34 UTC (rev 483)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/result/ZoneComboBoxRenderer.java 2011-01-07 09:09:33 UTC (rev 484)
@@ -30,6 +30,9 @@
import javax.swing.DefaultListCellRenderer;
import javax.swing.JList;
+import fr.ifremer.coser.bean.Selection;
+import fr.ifremer.coser.services.ProjectService;
+
/**
* Zone list combo renderer (display zone name for zone id).
*
@@ -44,6 +47,14 @@
/** serialVersionUID. */
private static final long serialVersionUID = -8231189755539976714L;
+ protected String surveyName;
+
+ public ZoneComboBoxRenderer(SelectionAddResultDialog view) {
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+ Selection selection = view.getContextValue(Selection.class);
+ surveyName = projectService.getProjectSurveyName(selection);
+ }
+
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
@@ -53,7 +64,10 @@
String[] zoneInfo = model.getZone(zoneId);
String zoneName = null;
if (zoneInfo != null) {
- zoneName = zoneInfo[0] + " - " + zoneInfo[1];
+ // le surveyName ne sert à rien
+ // mais est la a titre d'information par rapport
+ // à l'affichage cote web
+ zoneName = zoneInfo[0] + " - " + zoneInfo[1] + " - " + surveyName;
}
else {
zoneName = zoneId;
1
0