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
January 2011
- 1 participants
- 174 discussions
r497 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 12 Jan '11
by chatellier@users.labs.libre-entreprise.org 12 Jan '11
12 Jan '11
Author: chatellier
Date: 2011-01-12 09:21:35 +0000 (Wed, 12 Jan 2011)
New Revision: 497
Log:
Label axis verticaux
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.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-12 09:20:31 UTC (rev 496)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-01-12 09:21:35 UTC (rev 497)
@@ -45,7 +45,6 @@
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;
@@ -53,6 +52,7 @@
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.CategoryAxis;
+import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.labels.CategoryToolTipGenerator;
@@ -673,7 +673,6 @@
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);
@@ -684,7 +683,7 @@
CategoryAxis categoryAxis = new CategoryAxis(_("coser.business.common.year"));
categoryAxis.setCategoryMargin(0);
// label horizontaux
- //categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
+ categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
ValueAxis valueAxis = new NumberAxis(_("coser.business.common.number"));
valueAxis.setUpperMargin(0.1);
@@ -739,7 +738,6 @@
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);
@@ -750,7 +748,7 @@
CategoryAxis categoryAxis = new CategoryAxis(_("coser.business.common.year"));
categoryAxis.setCategoryMargin(0);
// label horizontaux
- //categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
+ categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
ValueAxis valueAxis = new NumberAxis(_("coser.business.common.number"));
valueAxis.setUpperMargin(0.1);
1
0
r496 - trunk/coser-business/src/main/java/fr/ifremer/coser/bean
by chatellier@users.labs.libre-entreprise.org 12 Jan '11
by chatellier@users.labs.libre-entreprise.org 12 Jan '11
12 Jan '11
Author: chatellier
Date: 2011-01-12 09:20:31 +0000 (Wed, 12 Jan 2011)
New Revision: 496
Log:
Add creationDate, dataAllowed, and mapsReferenceResult attribute on rsufi result
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -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 Lesser General Public License as
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractEntity.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -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 Lesser General Public License as
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -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 Lesser General Public License as
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -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 Lesser General Public License as
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/RSufiResult.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 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 Lesser General Public License as
@@ -25,6 +25,7 @@
package fr.ifremer.coser.bean;
+import java.util.Date;
import java.util.Properties;
/**
@@ -41,10 +42,14 @@
/** serialVersionUID. */
private static final long serialVersionUID = -1337710082675120199L;
+ // FIXME echatellier 20110111 compabilité avec les projets beta (a retirer pour la v1)
+ protected Date creationDate = new Date(0);
+
protected String name;
protected String rsufiVersion;
+ /** Zone d'application du resultat. */
protected String zone;
/** Utilisé seulement pour la validation (sinon, non valorisé). */
@@ -63,6 +68,20 @@
/** Result selected for web publication. */
protected boolean publishResult;
+ /** Result flaged as maps result. */
+ protected boolean mapsReferenceResult;
+
+ /** Data download allowed. */
+ protected boolean dataAllowed;
+
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
public String getName() {
return name;
}
@@ -142,7 +161,7 @@
public String getMapsPath() {
return mapsPath;
}
-
+
public void setPublishResult(boolean publishResult) {
boolean oldValue = this.publishResult;
this.publishResult = publishResult;
@@ -153,8 +172,31 @@
return publishResult;
}
+ public boolean isMapsReferenceResult() {
+ return mapsReferenceResult;
+ }
+
+ public void setMapsReferenceResult(boolean mapsReferenceResult) {
+ boolean oldValue = this.mapsReferenceResult;
+ this.mapsReferenceResult = mapsReferenceResult;
+ getPropertyChangeSupport().firePropertyChange("mapsReferenceResult", oldValue, mapsReferenceResult);
+ }
+
+ public boolean isDataAllowed() {
+ return dataAllowed;
+ }
+
+ public void setDataAllowed(boolean dataAllowed) {
+ boolean oldValue = this.dataAllowed;
+ this.dataAllowed = dataAllowed;
+ getPropertyChangeSupport().firePropertyChange("dataAllowed", oldValue, dataAllowed);
+ }
+
public Properties toProperties() {
Properties props = new Properties();
+ if (getCreationDate() != null) {
+ props.setProperty("result.creationdate", String.valueOf(creationDate.getTime()));
+ }
if (getRsufiVersion() != null) {
props.setProperty("result.rsufiversion", getRsufiVersion());
}
@@ -168,10 +210,16 @@
props.setProperty("result.estPopIndName", getEstPopIndName());
}
props.setProperty("result.publishResult", String.valueOf(isPublishResult()));
+ props.setProperty("result.dataAllowed", String.valueOf(isDataAllowed()));
+ props.setProperty("result.mapsReferenceResult", String.valueOf(isMapsReferenceResult()));
return props;
}
-
+
public void fromProperties(Properties props) {
+ if (props.containsKey("result.creationdate")) {
+ Date date = new Date(Long.parseLong(props.getProperty("result.creationdate")));
+ setCreationDate(date);
+ }
if (props.containsKey("result.rsufiversion")) {
setRsufiVersion(props.getProperty("result.rsufiversion"));
}
@@ -187,5 +235,11 @@
if (props.containsKey("result.publishResult")) {
setPublishResult(Boolean.parseBoolean(props.getProperty("result.publishResult")));
}
+ if (props.containsKey("result.dataAllowed")) {
+ setDataAllowed(Boolean.parseBoolean(props.getProperty("result.dataAllowed")));
+ }
+ if (props.containsKey("result.mapsReferenceResult")) {
+ setMapsReferenceResult(Boolean.parseBoolean(props.getProperty("result.mapsReferenceResult")));
+ }
}
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2011-01-10 17:52:00 UTC (rev 495)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2011-01-12 09:20:31 UTC (rev 496)
@@ -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 Lesser General Public License as
1
0
r495 - 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 17:52:00 +0000 (Mon, 10 Jan 2011)
New Revision: 495
Log:
Fix graphs for community
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
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 17:47:43 UTC (rev 494)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-01-10 17:52:00 UTC (rev 495)
@@ -660,10 +660,10 @@
File result = null;
// le fichier estcomind
- File estPopIndFile = new File(resultDirectory, rsufiResult.getEstPopIndName());
+ File estComIndFile = new File(resultDirectory, rsufiResult.getEstComIndName());
// Campagne Indicateur Liste Strate Annee Estimation EcartType CV
- DataStorage dataStorage = importService.loadCSVFile(estPopIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
+ DataStorage dataStorage = importService.loadCSVFile(estComIndFile, CoserConstants.CSV_RESULT_SEPARATOR_CHAR);
DefaultStatisticalCategoryDataset statisticalDataset = new DefaultStatisticalCategoryDataset();
Iterator<String[]> estPopIndIterator = dataStorage.iterator(true);
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 17:47:43 UTC (rev 494)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/WebService.java 2011-01-10 17:52:00 UTC (rev 495)
@@ -727,8 +727,6 @@
// data loading not necessary here
if (surveyName.equals(survey)) {
- Map<String, String> resultIndicators = null;
-
if (species == null) {
result = publicationService.getRsufiResultComChart(resultFile, rsufiResult, indicator, locale);
}
1
0
r494 - in trunk/coser-web/src/main/webapp/WEB-INF/content: . com
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:47:43 +0000 (Mon, 10 Jan 2011)
New Revision: 494
Log:
Added:
trunk/coser-web/src/main/webapp/WEB-INF/content/com/
trunk/coser-web/src/main/webapp/WEB-INF/content/com/graph.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/com/indicator.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/com/subzone.jsp
trunk/coser-web/src/main/webapp/WEB-INF/content/com/zone.jsp
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/com/graph.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/com/graph.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/com/graph.jsp 2011-01-10 17:47:43 UTC (rev 494)
@@ -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='graph-data'>
+ <s:param name="zone" value="%{zone}" />
+ <s:param name="indicator" value="%{indicator}" />
+ </s:url>" />
+
+ </body>
+</html>
\ No newline at end of file
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/com/indicator.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/com/indicator.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/com/indicator.jsp 2011-01-10 17:47:43 UTC (rev 494)
@@ -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="graph" method="get">
+ <s:select name="indicator" list="indicators" label="Select an indicator" />
+ <s:hidden name="zone" property="zone"/>
+ <s:hidden name="species" property="species"/>
+ <s:submit label="Suite"/>
+ </s:form>
+ </body>
+</html>
\ No newline at end of file
Added: trunk/coser-web/src/main/webapp/WEB-INF/content/com/subzone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/com/subzone.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/com/subzone.jsp 2011-01-10 17:47:43 UTC (rev 494)
@@ -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="indicator" 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/com/zone.jsp
===================================================================
--- trunk/coser-web/src/main/webapp/WEB-INF/content/com/zone.jsp (rev 0)
+++ trunk/coser-web/src/main/webapp/WEB-INF/content/com/zone.jsp 2011-01-10 17:47:43 UTC (rev 494)
@@ -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
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