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
November 2010
- 2 participants
- 175 discussions
r284 - in trunk: coser-business/src/main/java/fr/ifremer/coser/control coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser coser-ui/src/main/java/fr/ifremer/coser/ui/control coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
26 Nov '10
Author: chatellier
Date: 2010-11-26 09:36:00 +0000 (Fri, 26 Nov 2010)
New Revision: 284
Log:
Add errors tree export as html
Added:
trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthValidationError.java
trunk/coser-business/src/main/java/fr/ifremer/coser/control/GlobalValidationGroup.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java
Removed:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java
Modified:
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthValidationError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthValidationError.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthValidationError.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -0,0 +1,53 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.control;
+
+/**
+ * Erreur de controle specifique pour les différences des nombres entre
+ * les captures et les tailles pour utilisation typée de cette erreur
+ * (export html) et information supplémentaires (especes).
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class DiffCatchLengthValidationError extends ValidationError {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -3254763296138201677L;
+
+ protected String species;
+
+ public String getSpecies() {
+ return species;
+ }
+
+ public void setSpecies(String species) {
+ this.species = species;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthValidationError.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/control/GlobalValidationGroup.java (from rev 222, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/GlobalValidationGroup.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/GlobalValidationGroup.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -0,0 +1,119 @@
+/*
+ * #%L
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU 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 General Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/gpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.control;
+
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.CoserConstants.ValidationLevel;
+
+/**
+ * Global validation group node.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class GlobalValidationGroup implements Comparable<GlobalValidationGroup> {
+
+ protected final Category category;
+
+ protected final ValidationLevel validationLevel;
+
+ protected final String message;
+
+ /**
+ * @param category
+ * @param validationLevel
+ * @param message
+ */
+ public GlobalValidationGroup(Category category, ValidationLevel validationLevel, String message) {
+ super();
+ this.category = category;
+ this.validationLevel = validationLevel;
+ this.message = message;
+ }
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public ValidationLevel getValidationLevel() {
+ return validationLevel;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ /*
+ * @see java.lang.Comparable#compareTo(java.lang.Object)
+ */
+ @Override
+ public int compareTo(GlobalValidationGroup o) {
+ int compare = o.getValidationLevel().compareTo(validationLevel);
+ if (compare == 0) {
+ compare = o.getMessage().compareTo(message);
+ }
+ return compare;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((category == null) ? 0 : category.hashCode());
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((validationLevel == null) ? 0 : validationLevel.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ GlobalValidationGroup other = (GlobalValidationGroup) obj;
+ if (message == null) {
+ if (other.message != null) {
+ return false;
+ }
+ } else if (!message.equals(other.message)) {
+ return false;
+ }
+ if (validationLevel != other.validationLevel) {
+ return false;
+ }
+ if (category != other.category) {
+ return false;
+ }
+ return true;
+ }
+}
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -1,248 +0,0 @@
-/*
- * #%L
- *
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 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
- * 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.services;
-
-import static org.nuiton.i18n.I18n._;
-
-import java.text.NumberFormat;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.CategoryAxis;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.labels.CategoryToolTipGenerator;
-import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
-import org.jfree.chart.plot.CategoryPlot;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.renderer.category.CategoryItemRenderer;
-import org.jfree.chart.renderer.category.LineAndShapeRenderer;
-import org.jfree.data.category.CategoryDataset;
-import org.jfree.data.category.DefaultCategoryDataset;
-
-import fr.ifremer.coser.CoserBusinessConfig;
-import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.bean.AbstractDataContainer;
-import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.data.Catch;
-import fr.ifremer.coser.data.Length;
-
-/**
- * Validation service.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class ChartService {
-
- private static final Log log = LogFactory.getLog(ChartService.class);
-
- protected CoserBusinessConfig config;
-
- public ChartService(CoserBusinessConfig config) {
- this.config = config;
- }
-
- /**
- * Retourne les graphiques de comparaison entre le nombre de capture et
- * le nombre dans les tailles pour toutes les especes.
- *
- * @param project project
- * @param container data container
- * @param speciesCollection utilisé pour n'avoir qu'une partie des especes (can be null)
- * @return chart
- */
- public Map<String, JFreeChart> getCompareCatchLengthGraph(Project project, AbstractDataContainer container, Collection<String> speciesCollection) {
-
- int minYear = Integer.MAX_VALUE;
- int maxYear = Integer.MIN_VALUE;
-
- // look for data (data summed over catch)
- Map<String, Map<String, Double>> catchForSpeciesYears = new HashMap<String, Map<String, Double>>();
- Iterator<String[]> itCatchData = container.getCatch().iterator();
- itCatchData.next(); // header
- while (itCatchData.hasNext()) {
- String[] tuple = itCatchData.next();
- String species = tuple[Catch.INDEX_SPECIES];
-
- Map<String, Double> speciesCatchForYears = catchForSpeciesYears.get(species);
- if (speciesCatchForYears == null) {
- speciesCatchForYears = new HashMap<String, Double>();
- catchForSpeciesYears.put(species, speciesCatchForYears);
- }
-
- String year = tuple[Catch.INDEX_YEAR];
- try {
- int intYear = Integer.parseInt(year);
- minYear = Math.min(minYear, intYear);
- maxYear = Math.max(maxYear, intYear);
- }
- catch (NumberFormatException ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse " + year + "as int");
- }
- }
- String nombreValue = tuple[Catch.INDEX_NUMBER];
- try {
- Double nombreDouble = Double.valueOf(nombreValue);
-
- if (speciesCatchForYears.containsKey(year)) {
- Double oldValue = speciesCatchForYears.get(year);
- Double newValue = oldValue + nombreDouble;
- speciesCatchForYears.put(year, newValue);
- }
- else {
- speciesCatchForYears.put(year, nombreDouble);
- }
- }
- catch (NumberFormatException ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse " + nombreValue + " as double");
- }
- }
- }
-
- // look for data (data summed over length)
- Map<String, Map<String, Double>> lengthForSpeciesYears = new HashMap<String, Map<String, Double>>();
- Iterator<String[]> itLengthData = container.getLength().iterator();
- itLengthData.next(); // header
- while (itLengthData.hasNext()) {
- String[] tuple = itLengthData.next();
- String species = tuple[Length.INDEX_SPECIES];
-
- Map<String, Double> speciesLengthForYears = lengthForSpeciesYears.get(species);
- if (speciesLengthForYears == null) {
- speciesLengthForYears = new HashMap<String, Double>();
- lengthForSpeciesYears.put(species, speciesLengthForYears);
- }
-
- String year = tuple[Length.INDEX_YEAR];
- String nombreValue = tuple[Length.INDEX_NUMBER];
- try {
- Double nombreDouble = Double.valueOf(nombreValue);
-
- if (speciesLengthForYears.containsKey(year)) {
- Double oldValue = speciesLengthForYears.get(year);
- Double newValue = oldValue + nombreDouble;
- speciesLengthForYears.put(year, newValue);
- }
- else {
- speciesLengthForYears.put(year, nombreDouble);
- }
- }
- catch (NumberFormatException ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't parse " + nombreValue + " as double");
- }
- }
- }
-
- // generation des graphes pour chaques especes
- Map<String, JFreeChart> charts = new TreeMap<String, JFreeChart>();
- for (Map.Entry<String, Map<String, Double>> catchEntries : catchForSpeciesYears.entrySet()) {
-
- String species = catchEntries.getKey();
-
- // filtage des especes
- if (speciesCollection != null && !speciesCollection.contains(species)) {
- continue;
- }
-
- Map<String, Double> catchNumbers = catchEntries.getValue();
- Map<String, Double> lengthNumbers = lengthForSpeciesYears.get(species);
-
-
- //SortedMap<String, Double> catchForYears = new TreeMap<String, Double>();
- //SortedMap<String, Double> lengthForYears = new TreeMap<String, Double>();
- DefaultCategoryDataset dataset = new DefaultCategoryDataset();
- for (int year = minYear ; year <= maxYear ; ++year) {
- Double catchNumber = catchNumbers.get(String.valueOf(year));
- if (catchNumber == null) {
- catchNumber = 0.0;
- }
- dataset.setValue(catchNumber, _(Category.CATCH.getTranslationKey()), (Integer)year);
-
- if (lengthNumbers != null) {
- Double lengthNumber = lengthNumbers.get(String.valueOf(year));
- if (lengthNumber == null) {
- lengthNumber = 0.0;
- }
- dataset.setValue(lengthNumber, _(Category.LENGTH.getTranslationKey()), (Integer)year);
- }
- }
-
- JFreeChart chart = displayGraph(dataset, _("coser.business.chart.compareCatchLengthNumberTitle", species));
- charts.put(species, chart);
- }
-
- return charts;
- }
-
- protected JFreeChart displayGraph(CategoryDataset categoryDataSet, String title) {
-
- // create a chart with the dataset
- //DefaultCategoryDataset dataset = new DefaultCategoryDataset();
-
- /*for (Map.Entry<String, SortedMap<String, Double>> resultSerie : resultSeries.entrySet()) {
- for (Map.Entry<String, Double> data : resultSerie.getValue().entrySet()) {
- dataset.setValue(data.getValue(), resultSerie.getKey(), data.getKey());
- }
- }*/
-
- 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 LineAndShapeRenderer();
-
- // n'affiche pas les nombre sur le graphique
- //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
- //renderer.setBaseItemLabelGenerator(itemLabelGenerator);
- //renderer.setBaseItemLabelsVisible(true);
-
- CategoryToolTipGenerator cttg = new StandardCategoryToolTipGenerator("{0}: {2}", NumberFormat.getInstance());
- renderer.setBaseToolTipGenerator(cttg);
-
- CategoryPlot plot = new CategoryPlot(categoryDataSet, categoryAxis, valueAxis, renderer);
- plot.setOrientation(PlotOrientation.VERTICAL);
- JFreeChart chart = new JFreeChart(title,
- JFreeChart.DEFAULT_TITLE_FONT, plot, true);
-
- return chart;
- }
-}
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java (from rev 243, trunk/coser-business/src/main/java/fr/ifremer/coser/services/ChartService.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -0,0 +1,393 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 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
+ * 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.services;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.text.NumberFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.JFreeChart;
+import org.jfree.chart.axis.CategoryAxis;
+import org.jfree.chart.axis.NumberAxis;
+import org.jfree.chart.axis.ValueAxis;
+import org.jfree.chart.labels.CategoryToolTipGenerator;
+import org.jfree.chart.labels.StandardCategoryToolTipGenerator;
+import org.jfree.chart.plot.CategoryPlot;
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.chart.renderer.category.CategoryItemRenderer;
+import org.jfree.chart.renderer.category.LineAndShapeRenderer;
+import org.jfree.data.category.CategoryDataset;
+import org.jfree.data.category.DefaultCategoryDataset;
+
+import fr.ifremer.coser.CoserBusinessConfig;
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.AbstractDataContainer;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.control.DiffCatchLengthValidationError;
+import fr.ifremer.coser.control.GlobalValidationGroup;
+import fr.ifremer.coser.control.ValidationError;
+import fr.ifremer.coser.data.Catch;
+import fr.ifremer.coser.data.Length;
+
+/**
+ * Publication service (charts, reports, export...)
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class PublicationService {
+
+ private static final Log log = LogFactory.getLog(PublicationService.class);
+
+ protected CoserBusinessConfig config;
+
+ public PublicationService(CoserBusinessConfig config) {
+ this.config = config;
+ }
+
+ /**
+ * Retourne les graphiques de comparaison entre le nombre de capture et
+ * le nombre dans les tailles pour toutes les especes.
+ *
+ * @param project project
+ * @param container data container
+ * @param speciesCollection utilisé pour n'avoir qu'une partie des especes (can be null)
+ * @return chart
+ */
+ public Map<String, JFreeChart> getCompareCatchLengthGraph(Project project, AbstractDataContainer container, Collection<String> speciesCollection) {
+
+ int minYear = Integer.MAX_VALUE;
+ int maxYear = Integer.MIN_VALUE;
+
+ // look for data (data summed over catch)
+ Map<String, Map<String, Double>> catchForSpeciesYears = new HashMap<String, Map<String, Double>>();
+ Iterator<String[]> itCatchData = container.getCatch().iterator();
+ itCatchData.next(); // header
+ while (itCatchData.hasNext()) {
+ String[] tuple = itCatchData.next();
+ String species = tuple[Catch.INDEX_SPECIES];
+
+ Map<String, Double> speciesCatchForYears = catchForSpeciesYears.get(species);
+ if (speciesCatchForYears == null) {
+ speciesCatchForYears = new HashMap<String, Double>();
+ catchForSpeciesYears.put(species, speciesCatchForYears);
+ }
+
+ String year = tuple[Catch.INDEX_YEAR];
+ try {
+ int intYear = Integer.parseInt(year);
+ minYear = Math.min(minYear, intYear);
+ maxYear = Math.max(maxYear, intYear);
+ }
+ catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + year + "as int");
+ }
+ }
+ String nombreValue = tuple[Catch.INDEX_NUMBER];
+ try {
+ Double nombreDouble = Double.valueOf(nombreValue);
+
+ if (speciesCatchForYears.containsKey(year)) {
+ Double oldValue = speciesCatchForYears.get(year);
+ Double newValue = oldValue + nombreDouble;
+ speciesCatchForYears.put(year, newValue);
+ }
+ else {
+ speciesCatchForYears.put(year, nombreDouble);
+ }
+ }
+ catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + nombreValue + " as double");
+ }
+ }
+ }
+
+ // look for data (data summed over length)
+ Map<String, Map<String, Double>> lengthForSpeciesYears = new HashMap<String, Map<String, Double>>();
+ Iterator<String[]> itLengthData = container.getLength().iterator();
+ itLengthData.next(); // header
+ while (itLengthData.hasNext()) {
+ String[] tuple = itLengthData.next();
+ String species = tuple[Length.INDEX_SPECIES];
+
+ Map<String, Double> speciesLengthForYears = lengthForSpeciesYears.get(species);
+ if (speciesLengthForYears == null) {
+ speciesLengthForYears = new HashMap<String, Double>();
+ lengthForSpeciesYears.put(species, speciesLengthForYears);
+ }
+
+ String year = tuple[Length.INDEX_YEAR];
+ String nombreValue = tuple[Length.INDEX_NUMBER];
+ try {
+ Double nombreDouble = Double.valueOf(nombreValue);
+
+ if (speciesLengthForYears.containsKey(year)) {
+ Double oldValue = speciesLengthForYears.get(year);
+ Double newValue = oldValue + nombreDouble;
+ speciesLengthForYears.put(year, newValue);
+ }
+ else {
+ speciesLengthForYears.put(year, nombreDouble);
+ }
+ }
+ catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse " + nombreValue + " as double");
+ }
+ }
+ }
+
+ // generation des graphes pour chaques especes
+ Map<String, JFreeChart> charts = new TreeMap<String, JFreeChart>();
+ for (Map.Entry<String, Map<String, Double>> catchEntries : catchForSpeciesYears.entrySet()) {
+
+ String species = catchEntries.getKey();
+
+ // filtage des especes
+ if (speciesCollection != null && !speciesCollection.contains(species)) {
+ continue;
+ }
+
+ Map<String, Double> catchNumbers = catchEntries.getValue();
+ Map<String, Double> lengthNumbers = lengthForSpeciesYears.get(species);
+
+
+ //SortedMap<String, Double> catchForYears = new TreeMap<String, Double>();
+ //SortedMap<String, Double> lengthForYears = new TreeMap<String, Double>();
+ DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+ for (int year = minYear ; year <= maxYear ; ++year) {
+ Double catchNumber = catchNumbers.get(String.valueOf(year));
+ if (catchNumber == null) {
+ catchNumber = 0.0;
+ }
+ dataset.setValue(catchNumber, _(Category.CATCH.getTranslationKey()), (Integer)year);
+
+ if (lengthNumbers != null) {
+ Double lengthNumber = lengthNumbers.get(String.valueOf(year));
+ if (lengthNumber == null) {
+ lengthNumber = 0.0;
+ }
+ dataset.setValue(lengthNumber, _(Category.LENGTH.getTranslationKey()), (Integer)year);
+ }
+ }
+
+ JFreeChart chart = displayGraph(dataset, _("coser.business.chart.compareCatchLengthNumberTitle", species));
+ charts.put(species, chart);
+ }
+
+ return charts;
+ }
+
+ protected JFreeChart displayGraph(CategoryDataset categoryDataSet, String title) {
+
+ // create a chart with the dataset
+ //DefaultCategoryDataset dataset = new DefaultCategoryDataset();
+
+ /*for (Map.Entry<String, SortedMap<String, Double>> resultSerie : resultSeries.entrySet()) {
+ for (Map.Entry<String, Double> data : resultSerie.getValue().entrySet()) {
+ dataset.setValue(data.getValue(), resultSerie.getKey(), data.getKey());
+ }
+ }*/
+
+ 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 LineAndShapeRenderer();
+
+ // n'affiche pas les nombre sur le graphique
+ //StandardCategoryItemLabelGenerator itemLabelGenerator = new StandardCategoryItemLabelGenerator();
+ //renderer.setBaseItemLabelGenerator(itemLabelGenerator);
+ //renderer.setBaseItemLabelsVisible(true);
+
+ CategoryToolTipGenerator cttg = new StandardCategoryToolTipGenerator("{0}: {2}", NumberFormat.getInstance());
+ renderer.setBaseToolTipGenerator(cttg);
+
+ CategoryPlot plot = new CategoryPlot(categoryDataSet, categoryAxis, valueAxis, renderer);
+ plot.setOrientation(PlotOrientation.VERTICAL);
+ JFreeChart chart = new JFreeChart(title,
+ JFreeChart.DEFAULT_TITLE_FONT, plot, true);
+
+ return chart;
+ }
+
+ /**
+ * Export la liste d'erreurs dans un fichier html avec la liste des graphes
+ * si necessaire.
+ *
+ * @param project project
+ * @param container data container
+ * @param validationErrors errors list
+ * @throws CoserBusinessException
+ */
+ public File exportErrorsAsHTML(Project project, AbstractDataContainer container, List<ValidationError> validationErrors) throws CoserBusinessException {
+
+ File exportHtmlFile = null;
+ PrintStream out = null;
+ try {
+ exportHtmlFile = File.createTempFile("errors-", ".html");
+ if (log.isInfoEnabled()) {
+ log.info("Generating HTML report to " + exportHtmlFile.getAbsolutePath());
+ }
+ List<String> speciesGraph = new ArrayList<String>();
+ File imageDirectory = new File(exportHtmlFile.getParentFile(), "images");
+ imageDirectory.mkdirs();
+ out = new PrintStream(exportHtmlFile);
+
+ out.println("<html><head>");
+ out.println("<title>" + _("coser.business.publication.htmlexporttitle", project.getName())+ "</title>");
+ out.println("<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
+ out.println("</head><body>");
+
+ // convert all errors as tree (code duplicated from ui tree model)
+ Map<String, List<GlobalValidationGroup>> validationCategoryChild = new HashMap<String, List<GlobalValidationGroup>>();
+ Map<GlobalValidationGroup, List<ValidationError>> validationErrorsChilds = new HashMap<GlobalValidationGroup, List<ValidationError>>();
+ for (ValidationError validationError : validationErrors) {
+
+ String category = validationError.getCategory() == null ? _("coser.business.control.error.allCategories") : _(validationError.getCategory().getTranslationKey());
+ List<GlobalValidationGroup> errorGroup = validationCategoryChild.get(category);
+ if (errorGroup == null) {
+ errorGroup = new ArrayList<GlobalValidationGroup>();
+ validationCategoryChild.put(category, errorGroup);
+ }
+ GlobalValidationGroup group = new GlobalValidationGroup(validationError.getCategory(), validationError.getLevel(), validationError.getMessage());
+ List<ValidationError> childErrors = validationErrorsChilds.get(group);
+ if (childErrors == null) {
+ childErrors = new ArrayList<ValidationError>();
+ validationErrorsChilds.put(group, childErrors);
+ errorGroup.add(group);
+ }
+
+ if (validationError instanceof DiffCatchLengthValidationError) {
+ DiffCatchLengthValidationError diffError = (DiffCatchLengthValidationError)validationError;
+ speciesGraph.add(diffError.getSpecies());
+ }
+ childErrors.add(validationError);
+ }
+
+ Map<String, JFreeChart> charts = getCompareCatchLengthGraph(project, container, speciesGraph);
+
+ // render output html
+ out.println("<h1 style='text-align:center'>" + _("coser.business.publication.htmlexporttitle", project.getName()) + "</h1>");
+ for (Map.Entry<String, List<GlobalValidationGroup>> categoriesEntry : validationCategoryChild.entrySet()) {
+ out.println("<h2>" + categoriesEntry.getKey() + "</h2>");
+
+ out.println("<ul>");
+ for (GlobalValidationGroup group : categoriesEntry.getValue()) {
+
+ out.println("<li style='margin-bottom:20px'><span style='color:");
+ switch (group.getValidationLevel()) {
+ case FATAL:
+ out.print("rgb(88,0,0)");
+ break;
+ case ERROR:
+ out.print("red");
+ break;
+ case WARNING:
+ out.print("orange");
+ break;
+ case INFO:
+ out.print("green");
+ break;
+ }
+ out.print(";font-weight:bold'>" + _(group.getMessage()));
+ out.println("</span>");
+
+ out.println("<ul>");
+ for (ValidationError error : validationErrorsChilds.get(group)) {
+ out.println("<li type='circle'>");
+ out.print(_(error.getDetailMessage()));
+ Set<String> lineNumbers = error.getLineNumbers();
+ if (CollectionUtils.isNotEmpty(lineNumbers)) {
+ out.print(" (" + _("coser.business.publication.htmlexportlines") + " : ");
+ Iterator<String> itLineNumbers = lineNumbers.iterator();
+ while (itLineNumbers.hasNext()) {
+ out.print(itLineNumbers.next());
+ if (itLineNumbers.hasNext()) {
+ out.print(", ");
+ }
+ }
+ out.println(")");
+ }
+ String tipMessage = _(error.getTipMessage());
+ if (StringUtils.isNotEmpty(error.getTipMessage())) {
+ out.println("<p style='font-style:italic'>" + tipMessage + "</p>");
+ }
+ // ajout d'un graph si necessaire
+ if (error instanceof DiffCatchLengthValidationError) {
+ DiffCatchLengthValidationError diffError = (DiffCatchLengthValidationError)error;
+ JFreeChart chart = charts.get(diffError.getSpecies());
+ File tmpChartImage = File.createTempFile("chart-", ".jpg", imageDirectory);
+ ChartUtilities.saveChartAsJPEG(tmpChartImage, chart, 800, 400);
+ out.println("<div><img src='images/" + tmpChartImage.getName() + "' /></div>");
+ }
+
+ out.println("</li>");
+ }
+ out.println("</ul>");
+ out.println("</li>");
+ }
+ out.println("</ul>");
+ }
+
+ out.println("</body></html>");
+ }
+ catch (IOException ex) {
+ throw new CoserBusinessException("Can't export errors", ex);
+ }
+ finally {
+ IOUtils.closeQuietly(out);
+ }
+ return exportHtmlFile;
+ }
+}
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-26 09:36:00 UTC (rev 284)
@@ -27,6 +27,7 @@
coser.business.chart.compareCatchLengthNumberTitle=
coser.business.common.number=
coser.business.common.year=
+coser.business.control.error.allCategories=
coser.business.control.error.diffCatchLength=
coser.business.control.error.diffCatchLengthDetail=
coser.business.control.error.duplicatedLine=
@@ -53,6 +54,8 @@
coser.business.control.step.observation=
coser.business.control.step.xworks=
coser.business.line=Line
+coser.business.publication.htmlexportlines=
+coser.business.publication.htmlexporttitle=
coser.business.result.rsufiResultAlreadyExists=
coser.business.selection.notValidatedControl=
coser.config.control.diffcatchlength.description=
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-26 09:36:00 UTC (rev 284)
@@ -27,6 +27,7 @@
coser.business.chart.compareCatchLengthNumberTitle=Comparaison des nombres dans Capture et Taille (%s)
coser.business.common.number=Nombre
coser.business.common.year=Ann\u00E9e
+coser.business.control.error.allCategories=Toutes les cat\u00E9gories
coser.business.control.error.diffCatchLength=Diff\u00E9rence entre les captures et taille
coser.business.control.error.diffCatchLengthDetail=Diff\u00E9rence entre les captures et taille pour l'esp\u00E8ce %s (ann\u00E9e %s)
coser.business.control.error.duplicatedLine=Ligne en doublon
@@ -53,6 +54,8 @@
coser.business.control.step.observation=V\u00E9rification du nombre d'observation (%d%%)
coser.business.control.step.xworks=Validation par lignes (%d%%)
coser.business.line=Ligne
+coser.business.publication.htmlexportlines=Lignes
+coser.business.publication.htmlexporttitle=Rapport d'erreur pour le projet %s
coser.business.result.rsufiResultAlreadyExists=Le r\u00E9sultat %D existe d\u00E9j\u00E0 \!
coser.business.selection.notValidatedControl=Contr\u00F4le non valid\u00E9 \!
coser.config.control.diffcatchlength.description=Pourcentage d'\u00E9cart tol\u00E9r\u00E9 entre les captures et les tailles (en pourcent, par exemple pour 5% mettre 5.0)
Deleted: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -1,73 +0,0 @@
-/*
- * #%L
- *
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.services;
-
-import java.util.Map;
-
-import javax.swing.JDialog;
-
-import org.jfree.chart.ChartPanel;
-import org.jfree.chart.JFreeChart;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import fr.ifremer.coser.CoserBusinessException;
-import fr.ifremer.coser.bean.Project;
-
-/**
- * CommandService tests
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
- at Ignore
-public class ChartServiceTest extends CoserTestAbstract {
-
- protected ProjectService projectService;
- protected ChartService chartService;
-
- @Before
- public void initService() {
- projectService = new ProjectService(config);
- chartService = new ChartService(config);
- }
-
- @Test
- public void testCatchChart() throws CoserBusinessException {
- Project project = createTestProject(projectService, false);
- Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl(), null);
- JFreeChart chart = charts.get("COSER_SPECIES1");
- JDialog f = new JDialog();
- f.setModal(true);
- f.add(new ChartPanel(chart));
- f.pack();
- f.setVisible(true);
- }
-}
Copied: trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java (from rev 279, trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java)
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java (rev 0)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/PublicationServiceTest.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -0,0 +1,135 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.services;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.swing.JDialog;
+
+import org.apache.commons.io.FileUtils;
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.JFreeChart;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.CoserConstants.ValidationLevel;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.control.DiffCatchLengthValidationError;
+import fr.ifremer.coser.control.ValidationError;
+
+/**
+ * Publication service tests
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class PublicationServiceTest extends CoserTestAbstract {;
+
+ protected ProjectService projectService;
+ protected PublicationService publicationService;
+
+ @Before
+ public void initService() {
+ projectService = new ProjectService(config);
+ publicationService = new PublicationService(config);
+ }
+
+ @Ignore
+ public void testCatchChart() throws CoserBusinessException {
+ Project project = createTestProject(projectService, false);
+ Map<String, JFreeChart> charts = publicationService.getCompareCatchLengthGraph(project, project.getControl(), null);
+ JFreeChart chart = charts.get("COSER_SPECIES1");
+ JDialog f = new JDialog();
+ f.setModal(true);
+ f.add(new ChartPanel(chart));
+ f.pack();
+ f.setVisible(true);
+ }
+
+ /**
+ * Test la géneration des rapports html.
+ *
+ * @throws CoserBusinessException
+ * @throws IOException
+ */
+ @Test
+ public void testExportHtml() throws CoserBusinessException, IOException {
+ Project project = createTestProject(projectService, false);
+
+ List<ValidationError> validationErrors = new ArrayList<ValidationError>();
+
+ // error 1 :
+ ValidationError error1 = new ValidationError();
+ error1.setLevel(ValidationLevel.FATAL);
+ error1.setMessage("Test fatal");
+ error1.addLineNumber("15");
+ error1.setCategory(Category.CATCH);
+ validationErrors.add(error1);
+
+ DiffCatchLengthValidationError error2 = new DiffCatchLengthValidationError();
+ error2.setLevel(ValidationLevel.WARNING);
+ error2.setMessage("Test warning and graph");
+ error2.setSpecies("COSER_SPECIES1");
+ error2.setTipMessage("Explication sur l'erreur");
+ validationErrors.add(error2);
+
+ ValidationError error3 = new ValidationError();
+ error3.setLevel(ValidationLevel.ERROR);
+ error3.setMessage("Test error");
+ error3.addLineNumber("12");
+ error3.addLineNumber("9999");
+ error3.setCategory(Category.CATCH);
+ validationErrors.add(error3);
+
+ File htmlExport = publicationService.exportErrorsAsHTML(project, project.getControl(), validationErrors);
+ String fileContent = FileUtils.readFileToString(htmlExport);
+ Assert.assertTrue(fileContent.indexOf("9999") > 0);
+ Assert.assertTrue(fileContent.indexOf("<img src=") > 0); // one chart
+ Assert.assertTrue(fileContent.indexOf("Test fatal") > 0);
+ Assert.assertTrue(fileContent.indexOf("Test warning and graph") > 0);
+ Assert.assertTrue(fileContent.indexOf("Test error") > 0);
+ Assert.assertTrue(fileContent.indexOf(_("coser.business.control.error.allCategories")) > 0);
+
+ // clean all
+ File imagesDir = new File(htmlExport.getParentFile(), "images");
+ Assert.assertTrue(imagesDir.isDirectory());
+ FileUtils.deleteDirectory(imagesDir);
+ htmlExport.delete();
+ }
+}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -38,7 +38,7 @@
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.widget.SwingSession;
-import fr.ifremer.coser.services.ChartService;
+import fr.ifremer.coser.services.PublicationService;
import fr.ifremer.coser.services.ImportService;
import fr.ifremer.coser.services.ProjectService;
import fr.ifremer.coser.services.ValidationService;
@@ -139,7 +139,7 @@
context.setContextValue(new ProjectService(coserConfig));
context.setContextValue(new ImportService(coserConfig));
context.setContextValue(new ValidationService(coserConfig));
- context.setContextValue(new ChartService(coserConfig));
+ context.setContextValue(new PublicationService(coserConfig));
// init frame with session reloading
CoserFrame frame = new CoserFrame(context);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -26,6 +26,7 @@
import static org.nuiton.i18n.I18n._;
import java.awt.BorderLayout;
+import java.awt.Desktop;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Point;
@@ -34,6 +35,8 @@
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.beans.Introspector;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -46,6 +49,7 @@
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
+import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JViewport;
@@ -72,14 +76,15 @@
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.CoserException;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.control.GlobalValidationGroup;
import fr.ifremer.coser.control.ValidationError;
import fr.ifremer.coser.data.AbstractDataEntity;
import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.data.Haul;
import fr.ifremer.coser.data.Length;
import fr.ifremer.coser.data.Strata;
-import fr.ifremer.coser.services.ChartService;
import fr.ifremer.coser.services.ProjectService;
+import fr.ifremer.coser.services.PublicationService;
import fr.ifremer.coser.services.ValidationService;
/**
@@ -478,6 +483,8 @@
if (event.getButton() == MouseEvent.BUTTON3) {
TreePath selectedError = controlView.getValidationGlobalErrorsTable().getTreeSelectionModel().getSelectionPath();
+ JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.globalErrorMenuLabel"));
+
// plusieurs lignes selectionnées et pas la premiere colonne (Line index)
if (selectedError != null) {
Object[] pathWay = selectedError.getPath();
@@ -487,7 +494,7 @@
if (pathWay[1] instanceof Category) {
final Category category = (Category)pathWay[1];
final GlobalValidationGroup validationGroup = (GlobalValidationGroup)pathWay[2];
- JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.globalErrorMenuLabel"));
+
JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuSelectAll"));
replaceMenu.addActionListener(new ActionListener() {
@Override
@@ -496,10 +503,21 @@
}
});
popupMenu.add(replaceMenu);
- popupMenu.show(controlView.getValidationGlobalErrorsTable(), event.getX(), event.getY());
+ popupMenu.add(new JSeparator());
}
}
}
+
+ JMenuItem generateHtmlMenu = new JMenuItem(_("coser.ui.control.globalErrorMenuGenerateHTML"));
+ generateHtmlMenu.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ generateHTMLReport(controlView);
+ }
+ });
+ popupMenu.add(generateHtmlMenu);
+
+ popupMenu.show(controlView.getValidationGlobalErrorsTable(), event.getX(), event.getY());
}
}
@@ -562,6 +580,36 @@
viewport.scrollRectToVisible(rect);
}
+ /**
+ * Generate global error table model data as html report.
+ *
+ * @param controlView
+ */
+ protected void generateHTMLReport(ControlView controlView) {
+
+ PublicationService publicationService = controlView.getContextValue(PublicationService.class);
+ Project project = controlView.getContextValue(Project.class);
+
+ // get error list from table model
+ List<ValidationError> validationErrors = controlView.getGlobalValidationModel().getValidationErrors();
+ File htmlFile = null;
+ try {
+ htmlFile = publicationService.exportErrorsAsHTML(project, project.getControl(), validationErrors);
+
+ Desktop.getDesktop().browse(htmlFile.toURI());
+ } catch (CoserBusinessException ex) {
+ throw new CoserException("Can't generate html report", ex);
+ } catch (IOException ex) {
+ if (htmlFile != null) {
+ JOptionPane.showMessageDialog(controlView, _("coser.ui.control.htmlReportCantBeOpened", htmlFile.getAbsolutePath()),
+ _("coser.ui.control.htmlReportError"), JOptionPane.WARNING_MESSAGE);
+ }
+ else {
+ throw new CoserException("Can't open html report", ex);
+ }
+ }
+ }
+
protected void updateEditionPanel(ControlView view, Category category, String[] header, String[] line) {
JPanel panel = view.getEditionPanel();
@@ -722,16 +770,15 @@
*/
public void displayCompareNumberCatchGraph(ControlView view) {
Project project = view.getContextValue(Project.class);
- ChartService chartService = view.getContextValue(ChartService.class);
+ PublicationService publicationService = view.getContextValue(PublicationService.class);
- Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl(), null);
+ Map<String, JFreeChart> charts = publicationService.getCompareCatchLengthGraph(project, project.getControl(), null);
List<String> species = new ArrayList<String>(charts.keySet());
ControlGraphDialog dialog = new ControlGraphDialog(view);
dialog.setHandler(this);
dialog.setContextValue(charts);
dialog.getSpecyComboModel().setSpecy(species);
- //updateCompareNumberCatchGraph(dialog);
dialog.pack();
dialog.setLocationRelativeTo(view);
dialog.setVisible(true);
@@ -758,8 +805,6 @@
JFreeChart chart = charts.get(specyName);
view.getControlGraphPanel().removeAll();
ChartPanel chartPanel = new ChartPanel(chart);
- //chartPanel.setMinimumDrawWidth(1000);
- //chartPanel.setMinimumDrawHeight(800);
view.getControlGraphPanel().add(chartPanel, BorderLayout.CENTER);
view.getControlGraphPanel().validate();
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlValidationRenderer.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -35,6 +35,7 @@
import jaxx.runtime.validator.swing.SwingValidatorUtil;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
+import fr.ifremer.coser.control.GlobalValidationGroup;
import fr.ifremer.coser.control.ValidationError;
/**
Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationGroup.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -1,119 +0,0 @@
-/*
- * #%L
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-3.0.html>.
- * #L%
- */
-
-package fr.ifremer.coser.ui.control;
-
-import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.CoserConstants.ValidationLevel;
-
-/**
- * Global validation group node.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class GlobalValidationGroup implements Comparable<GlobalValidationGroup> {
-
- protected final Category category;
-
- protected final ValidationLevel validationLevel;
-
- protected final String message;
-
- /**
- * @param category
- * @param validationLevel
- * @param message
- */
- public GlobalValidationGroup(Category category, ValidationLevel validationLevel, String message) {
- super();
- this.category = category;
- this.validationLevel = validationLevel;
- this.message = message;
- }
-
- public Category getCategory() {
- return category;
- }
-
- public ValidationLevel getValidationLevel() {
- return validationLevel;
- }
-
- public String getMessage() {
- return message;
- }
-
- /*
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- @Override
- public int compareTo(GlobalValidationGroup o) {
- int compare = o.getValidationLevel().compareTo(validationLevel);
- if (compare == 0) {
- compare = o.getMessage().compareTo(message);
- }
- return compare;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((category == null) ? 0 : category.hashCode());
- result = prime * result + ((message == null) ? 0 : message.hashCode());
- result = prime * result + ((validationLevel == null) ? 0 : validationLevel.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- GlobalValidationGroup other = (GlobalValidationGroup) obj;
- if (message == null) {
- if (other.message != null) {
- return false;
- }
- } else if (!message.equals(other.message)) {
- return false;
- }
- if (validationLevel != other.validationLevel) {
- return false;
- }
- if (category != other.category) {
- return false;
- }
- return true;
- }
-}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/GlobalValidationModel.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -39,6 +39,7 @@
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
+import fr.ifremer.coser.control.GlobalValidationGroup;
import fr.ifremer.coser.control.ValidationError;
/**
@@ -55,6 +56,7 @@
/** serialVersionUID. */
private static final long serialVersionUID = -32286733264427664L;
+ protected List<ValidationError> validationErrors;
protected List<Object> validationErrorCategory;
protected Map<Object, List<GlobalValidationGroup>> validationCategoryChild;
protected Map<GlobalValidationGroup, List<ValidationError>> validationErrorsChilds;
@@ -63,12 +65,17 @@
public GlobalValidationModel() {
super(1);
}
-
+
public void setValidationErrors(List<ValidationError> validationErrors) {
+ this.validationErrors = validationErrors;
getValidationErrorAsMaps(validationErrors);
modelSupport.fireNewRoot();
}
+ public List<ValidationError> getValidationErrors() {
+ return validationErrors;
+ }
+
/**
* Convert error list to tree structure.
*
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-26 09:36:00 UTC (rev 284)
@@ -59,7 +59,7 @@
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.RSufiResult;
import fr.ifremer.coser.bean.Selection;
-import fr.ifremer.coser.services.ChartService;
+import fr.ifremer.coser.services.PublicationService;
import fr.ifremer.coser.services.ProjectService;
import fr.ifremer.coser.ui.result.SelectionAddResultDialog;
import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpecyListModel;
@@ -585,7 +585,7 @@
*/
public void showSelectedSpeciesGraph(SelectionDetailsView view, String cardLayoutContraints) {
- ChartService chartService = view.getContextValue(ChartService.class);
+ PublicationService publicationService = view.getContextValue(PublicationService.class);
Project project = view.getContextValue(Project.class);
Selection selection = view.getContextValue(Selection.class);
@@ -595,7 +595,7 @@
graphSpecies.add((String)selectedFilteredSpecy);
}
- Map<String, JFreeChart> chartsMap = chartService.getCompareCatchLengthGraph(project, selection, graphSpecies);
+ Map<String, JFreeChart> chartsMap = publicationService.getCompareCatchLengthGraph(project, selection, graphSpecies);
Collection<JFreeChart> charts = chartsMap.values();
view.getSpeciesGraphPanel().removeAll();
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-26 09:36:00 UTC (rev 284)
@@ -30,10 +30,13 @@
coser.ui.control.error.allCategories=
coser.ui.control.global.done=\u2026
coser.ui.control.global.message=Message
+coser.ui.control.globalErrorMenuGenerateHTML=
coser.ui.control.globalErrorMenuLabel=Error menu
coser.ui.control.globalErrorMenuSelectAll=Select all lines
coser.ui.control.graph.specy=Specy \:
coser.ui.control.graphtitle=Graph
+coser.ui.control.htmlReportCantBeOpened=
+coser.ui.control.htmlReportError=
coser.ui.control.project.requiredauthor=
coser.ui.control.project.requiredcatchFile=
coser.ui.control.project.requiredhaulFile=
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-26 09:30:27 UTC (rev 283)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-26 09:36:00 UTC (rev 284)
@@ -30,10 +30,13 @@
coser.ui.control.error.allCategories=Toutes les cat\u00E9gories
coser.ui.control.global.done=\u2026
coser.ui.control.global.message=Message
+coser.ui.control.globalErrorMenuGenerateHTML=Exporter en HTML
coser.ui.control.globalErrorMenuLabel=Menu des erreurs
coser.ui.control.globalErrorMenuSelectAll=S\u00E9lectionner toutes les lignes
coser.ui.control.graph.specy=Esp\u00E8ces \:
coser.ui.control.graphtitle=Graphique
+coser.ui.control.htmlReportCantBeOpened=Le rapport HTML a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9 dans le fichier \:\n%s\nmais ne peut pas \u00EAtre ouvert automatiquement car le navigateur\npar d\u00E9faut du syst\u00E8me n'est pas d\u00E9fini \!
+coser.ui.control.htmlReportError=Erreur d'ouverture
coser.ui.control.project.requiredauthor=Le champ 'auteur' est requis
coser.ui.control.project.requiredcatchFile=Le fichier 'capture' est requis
coser.ui.control.project.requiredhaulFile=Le fichier 'traits' est requis
1
0
r283 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
26 Nov '10
Author: chatellier
Date: 2010-11-26 09:30:27 +0000 (Fri, 26 Nov 2010)
New Revision: 283
Log:
Inverse la condition de test (si c'est sup a 0)
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-26 09:02:31 UTC (rev 282)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-26 09:30:27 UTC (rev 283)
@@ -60,6 +60,7 @@
import fr.ifremer.coser.CoserConstants.ValidationLevel;
import fr.ifremer.coser.bean.Control;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.control.DiffCatchLengthValidationError;
import fr.ifremer.coser.control.ProgressMonitor;
import fr.ifremer.coser.control.ValidationError;
import fr.ifremer.coser.data.AbstractDataEntity;
@@ -544,7 +545,7 @@
* Detecte des différences entre les nombres dans captures
* et les nombres dand taille.
*
- * @see ChartService#getCompareCatchLengthGraph(Project, Control, String) for details
+ * @see PublicationService#getCompareCatchLengthGraph(Project, Control, String) for details
* @see CoserBusinessConfig#getControlDiffCatchLength() for option
*
* @return errors
@@ -653,12 +654,13 @@
// diff entre 4 et 5 = (5-4) * 100 / 5
double min = Math.min(catchNumber, lengthNumber);
// si c'est 0, ou absence de catures, ce n'est pas une erreur
- if (min <= 0) {
+ if (min > 0) {
double max = Math.max(catchNumber, lengthNumber);
double diff = (max - min) * 100 / max;
if (diff > config.getControlDiffCatchLength()) {
- ValidationError error = new ValidationError();
+ DiffCatchLengthValidationError error = new DiffCatchLengthValidationError();
+ error.setSpecies(species);
error.setLevel(ValidationLevel.WARNING);
error.setMessage(_("coser.business.control.error.diffCatchLength"));
error.setDetailMessage(_("coser.business.control.error.diffCatchLengthDetail", species, year));
1
0
r282 - trunk/coser-business/src/test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
by chatellier@users.labs.libre-entreprise.org 26 Nov '10
26 Nov '10
Author: chatellier
Date: 2010-11-26 09:02:31 +0000 (Fri, 26 Nov 2010)
New Revision: 282
Log:
Delete temp directory after tests
Modified:
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
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 2010-11-25 16:13:26 UTC (rev 281)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-11-26 09:02:31 UTC (rev 282)
@@ -31,6 +31,7 @@
import java.util.Locale;
import java.util.Map;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.AfterClass;
@@ -74,7 +75,7 @@
@AfterClass
public static void cleanDirectory() throws IOException {
- //FileUtils.deleteDirectory(testDirectory);
+ FileUtils.deleteDirectory(testDirectory);
}
/**
1
0
r281 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 16:13:26 +0000 (Thu, 25 Nov 2010)
New Revision: 281
Log:
Dans le controle de diff?\195?\169rence catch/length, les cas 0 n'est pas une erreur
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-25 15:29:23 UTC (rev 280)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-25 16:13:26 UTC (rev 281)
@@ -475,7 +475,7 @@
int lineIndex = 1; // skip header
while (itTuple.hasNext()) {
String[] tuple = itTuple.next();
-
+
// update progress
if (progress != null) {
int progressPercent = (int)((double)lineIndex / (double)total * 100.0);
@@ -483,7 +483,7 @@
progress.setCurrent(lineIndex);
++lineIndex;
}
-
+
// compute key
StringBuffer sb = new StringBuffer();
for (int tupleIndex = 0 ; tupleIndex < tuple.length; ++tupleIndex) {
@@ -517,8 +517,6 @@
log.warn("Can't parse '" + nombreValue + "' as double");
}
}
-
-
}
// now look for invalid data
@@ -653,15 +651,19 @@
}
// diff entre 4 et 5 = (5-4) * 100 / 5
- double diff = (Math.max(catchNumber, lengthNumber) -
- Math.min(catchNumber, lengthNumber)) * 100 / Math.max(catchNumber, lengthNumber);
-
- if (diff > config.getControlDiffCatchLength()) {
- ValidationError error = new ValidationError();
- error.setLevel(ValidationLevel.WARNING);
- error.setMessage(_("coser.business.control.error.diffCatchLength"));
- error.setDetailMessage(_("coser.business.control.error.diffCatchLengthDetail", species, year));
- validationErrors.add(error);
+ double min = Math.min(catchNumber, lengthNumber);
+ // si c'est 0, ou absence de catures, ce n'est pas une erreur
+ if (min <= 0) {
+ double max = Math.max(catchNumber, lengthNumber);
+ double diff = (max - min) * 100 / max;
+
+ if (diff > config.getControlDiffCatchLength()) {
+ ValidationError error = new ValidationError();
+ error.setLevel(ValidationLevel.WARNING);
+ error.setMessage(_("coser.business.control.error.diffCatchLength"));
+ error.setDetailMessage(_("coser.business.control.error.diffCatchLengthDetail", species, year));
+ validationErrors.add(error);
+ }
}
}
}
1
0
r280 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 15:29:23 +0000 (Thu, 25 Nov 2010)
New Revision: 280
Log:
Fix years data filtering that need data reload when new years are bigger set than previous filtered data years
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
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 2010-11-25 14:59:24 UTC (rev 279)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-25 15:29:23 UTC (rev 280)
@@ -669,8 +669,26 @@
localProject = loadControlData(localProject);
}
+ Selection selection = new Selection();
+ copyControlDataToSelection(localProject, selection);
+
+ selection.setRsufiResults(new ArrayList<RSufiResult>());
+
+ // init filter values with configuration
+ selection.setDensityFilter(config.getSelectionDensityFilter());
+ selection.setOccurrenceFilter(config.getSelectionOccurrenceFilter());
+
+ return selection;
+ }
+
+ /**
+ * Copy loaded control data to new created selection.
+ *
+ * @return selection initialized with
+ */
+ protected Selection copyControlDataToSelection(Project project, Selection selection) {
// create new selection
- Control control = localProject.getControl();
+ Control control = project.getControl();
DataStorage dataCatch = control.getCatch();
DataStorage dataHaul = control.getHaul();
DataStorage dataLength = control.getLength();
@@ -678,19 +696,14 @@
project.clearData();
- Selection selection = new Selection();
selection.setCatch(dataCatch);
selection.setHaul(dataHaul);
selection.setLength(dataLength);
selection.setStrata(dataStrata);
+
+ // data reloaded from control, so modification are empty
selection.setHistoryCommand(new ArrayList<Command>());
- selection.setRsufiResults(new ArrayList<RSufiResult>());
-
- // init filter values with configuration
- selection.setDensityFilter(config.getSelectionDensityFilter());
- selection.setOccurrenceFilter(config.getSelectionOccurrenceFilter());
-
return selection;
}
@@ -1244,14 +1257,28 @@
/**
* Get zones name in project with data in [{@code beginYear}-{@code endYear}].
*
+ * This methods set {@link Selection#setSelectedYears(List)}, and use
+ * it to known if control data need to be reloaded (don't set it yourself).
+ *
* Used in selection ui.
*
+ * @param project project
* @param selection selection
* @param years selected years
* @return zones
+ * @throws CoserBusinessException
*/
- public List<String> filterDataYearsAndGetStrata(Selection selection, Collection<String> years) {
+ public List<String> filterDataYearsAndGetStrata(Project project, Selection selection, List<String> years) throws CoserBusinessException {
+ List<String> currentSelectionYears = selection.getSelectedYears();
+ if (currentSelectionYears == null || !currentSelectionYears.containsAll(years)) {
+ // la liste des nouvelles année est plus grande que la liste
+ // actuelle des données de la selection
+ // les données doivent être rechargée
+ project = loadControlData(project);
+ copyControlDataToSelection(project, selection);
+ }
+
List<String> result = new ArrayList<String>();
// manage haul
@@ -1308,6 +1335,9 @@
log.debug("Length data filtered by " + years);
}
+ // the only place to set this value
+ selection.setSelectedYears(years);
+
return result;
}
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 15:29:23 UTC (rev 280)
@@ -200,30 +200,30 @@
}
/**
- * Test l'obtention de la liste des zones d'un projet.
+ * Test l'obtention de la liste des strates d'un projet.
*
* @throws CoserBusinessException
*/
@Test
- public void testProjectZone() throws CoserBusinessException {
+ public void testProjectStrata() throws CoserBusinessException {
Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
List<String> years = new ArrayList<String>();
years.add("2010");
years.add("2011");
- List<String> strata = projectService.filterDataYearsAndGetStrata(selection, years);
+ List<String> strata = projectService.filterDataYearsAndGetStrata(project, selection, years);
Assert.assertEquals(6, strata.size());
List<String> years2 = new ArrayList<String>();
years2.add("2009");
- strata = projectService.filterDataYearsAndGetStrata(selection, years2);
+ strata = projectService.filterDataYearsAndGetStrata(project, selection, years2);
Assert.assertEquals(0, strata.size());
List<String> years3 = new ArrayList<String>();
years3.add("2011");
// doit recharger les données pour être correct
- strata = projectService.filterDataYearsAndGetStrata(selection, years3);
+ strata = projectService.filterDataYearsAndGetStrata(project, selection, years3);
Assert.assertEquals(3, strata.size());
@@ -239,30 +239,39 @@
Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
- List<String> allStrata = new ArrayList<String>();
- allStrata.add("STR1");
- allStrata.add("STR2");
- allStrata.add("STR3");
- allStrata.add("STR4");
- allStrata.add("STR5");
- allStrata.add("STR6");
+ List<String> years20102011 = new ArrayList<String>();
+ years20102011.add("2010");
+ years20102011.add("2011");
+ List<String> years2011 = new ArrayList<String>();
+ years2011.add("2011");
+ List<String> years2009 = new ArrayList<String>();
+ years2009.add("2009");
+ // all data
+ List<String> allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
List<String> species = projectService.getProjectSpecies(project, selection, allStrata, null);
Assert.assertEquals(4, species.size());
-
+
+ // data in 2011
+ allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years2011);
species = projectService.getProjectSpecies(project, selection, allStrata, null);
Assert.assertEquals(4, species.size());
+ // all strata but no data for years
+ allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years2009);
species = projectService.getProjectSpecies(project, selection, allStrata, null);
Assert.assertEquals(0, species.size());
// test with no strata
+ allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
species = projectService.getProjectSpecies(project, selection, new ArrayList<String>(), null);
Assert.assertEquals(0, species.size());
// test with only one stratum
+ allStrata = projectService.filterDataYearsAndGetStrata(project, selection, years20102011);
species = projectService.getProjectSpecies(project, selection, Collections.singletonList("STR6"), null);
Assert.assertEquals(4, species.size());
+
}
/**
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-25 14:59:24 UTC (rev 279)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-25 15:29:23 UTC (rev 280)
@@ -215,6 +215,7 @@
* @param view view
*/
public void updateSelectionDateData(SelectionDetailsView view) {
+ Project project = view.getContextValue(Project.class);
Selection selection = view.getContextValue(Selection.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
@@ -224,15 +225,22 @@
for (Object selectedDate : selectedDates) {
years.add((String)selectedDate);
}
- selection.setSelectedYears(years);
-
+
if (log.isDebugEnabled()) {
log.debug("Refreshing strata list");
}
- List<String> strata = projectService.filterDataYearsAndGetStrata(selection, years);
- view.getStrataListModel().setStrata(strata);
- if (log.isDebugEnabled()) {
- log.debug("Strata list refreshed");
+
+ try {
+ // filterDataYearsAndGetStrata do selection.setSelectedYears(years);
+ // don't set yourself
+ List<String> strata = projectService.filterDataYearsAndGetStrata(project, selection, years);
+ view.getStrataListModel().setStrata(strata);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Strata list refreshed");
+ }
+ } catch (CoserBusinessException ex) {
+ throw new CoserException("Can't filters data with specified years", ex);
}
}
1
0
r279 - trunk/coser-business/src/test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 14:59:24 +0000 (Thu, 25 Nov 2010)
New Revision: 279
Log:
Fix copyrigth
Modified:
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
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 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-11-25 14:59:24 UTC (rev 279)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Codelutin, Chatellier Eric
+ * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
1
0
r278 - trunk/coser-business/src/test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 14:51:55 +0000 (Thu, 25 Nov 2010)
New Revision: 278
Log:
La cr?\195?\169ation de selection requiere un controle valid?\195?\169 (modification des tests en cons?\195?\169quences)
Modified:
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-25 14:38:57 UTC (rev 277)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ChartServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
@@ -61,7 +61,7 @@
@Test
public void testCatchChart() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
Map<String, JFreeChart> charts = chartService.getCompareCatchLengthGraph(project, project.getControl(), null);
JFreeChart chart = charts.get("COSER_SPECIES1");
JDialog f = new JDialog();
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-11-25 14:38:57 UTC (rev 277)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
@@ -63,7 +63,7 @@
*/
@Test
public void testDeleteLine() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
Assert.assertEquals(30, project.getControl().getLength().size());
DeleteLineCommand command = new DeleteLineCommand();
@@ -81,7 +81,7 @@
*/
@Test(expected=CoserBusinessException.class)
public void testDeleteLineWrong() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
DeleteLineCommand command = new DeleteLineCommand();
command.setLineNumber("2");
command.setCategory(Category.LENGTH);
@@ -97,7 +97,7 @@
*/
@Test
public void testDeleteLineUndo() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
Assert.assertEquals("4", project.getControl().getLength().get(4)[Length.INDEX_LINE]);
DeleteLineCommand command = new DeleteLineCommand();
@@ -118,7 +118,7 @@
*/
@Test(expected=CoserBusinessException.class)
public void testDeleteLineUndoAlreadyExists() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
DeleteLineCommand command = new DeleteLineCommand();
command.setLineNumber("3");
command.setCategory(Category.LENGTH);
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 2010-11-25 14:38:57 UTC (rev 277)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-11-25 14:51:55 UTC (rev 278)
@@ -82,11 +82,12 @@
*
* Project is filled with control data (not selections).
*
- * @param projectService
+ * @param projectService project service
+ * @param controlValidated if {@code true} mark loaded control as {@code validated}
* @return
* @throws CoserBusinessException
*/
- protected Project createTestProject(ProjectService projectService) throws CoserBusinessException {
+ protected Project createTestProject(ProjectService projectService, boolean controlValidated) throws CoserBusinessException {
Project project = new Project();
project.setName("Project-" + System.nanoTime());
@@ -112,6 +113,8 @@
// sans la sauvegarde des données de control, on ne pas creer de
// selection
projectService.saveProjectControl(project);
+
+ project.getControl().setValidated(controlValidated);
if (log.isDebugEnabled()) {
log.debug("Created project : " + project.getName());
Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 14:38:57 UTC (rev 277)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-11-25 14:51:55 UTC (rev 278)
@@ -90,7 +90,7 @@
*/
@Test
public void testCreateProject() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
Assert.assertTrue(new File(config.getProjectsDirectory(),
project.getName() + File.separator + "original" + File.separator + "catch.csv").exists());
@@ -112,13 +112,13 @@
*/
@Test
public void testSaveProject() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
projectService.saveProjectControl(project);
Assert.assertTrue(new File(config.getProjectsDirectory(),
project.getName() + File.separator + "control" + File.separator + "catch_co.csv").exists());
}
-
+
/**
* Test que les selections sont bien creer.
*
@@ -126,7 +126,7 @@
*/
@Test
public void testCreateSelection() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("titi");
projectService.createProjectSelection(project, selection);
@@ -143,7 +143,7 @@
*/
@Test
public void testSelectionReloading() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Assert.assertEquals(25, project.getControl().getCatch().size());
Selection selection = projectService.initProjectSelection(project);
@@ -163,7 +163,7 @@
*/
@Test(expected=CoserBusinessException.class)
public void testCreateSelectionError() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("titi");
projectService.createProjectSelection(project, selection);
@@ -177,7 +177,7 @@
*/
@Test
public void testSpeciesExistence() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
Assert.assertFalse(projectService.isSpecyNameExist(project, "Coser_invalid"));
Assert.assertTrue(projectService.isSpecyNameExist(project, "COSER_SPECIES1"));
Assert.assertTrue(projectService.isSpecyNameExist(project, "COSER_SPECIES2"));
@@ -190,7 +190,7 @@
*/
@Test
public void testProjectYear() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
List<String> years = projectService.getProjectYears(selection);
@@ -206,7 +206,7 @@
*/
@Test
public void testProjectZone() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
List<String> years = new ArrayList<String>();
@@ -236,7 +236,7 @@
*/
@Test
public void testProjectSpecies() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
List<String> allStrata = new ArrayList<String>();
@@ -272,7 +272,7 @@
*/
@Test
public void testMergeSpecies() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("test");
@@ -297,7 +297,7 @@
*/
@Test
public void testCommandStoreAndReloading() throws CoserBusinessException, IOException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, false);
DeleteLineCommand command = new DeleteLineCommand();
command.setLineNumber("2");
@@ -373,7 +373,7 @@
*/
@Test
public void testSamplingEffort() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("test");
MatrixND matrix = projectService.getSamplingEffort(project, selection);
@@ -387,7 +387,7 @@
*/
@Test
public void getOccurence() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("test");
MatrixND matrix = projectService.getOccurrence(project, selection);
@@ -401,7 +401,7 @@
*/
@Test
public void getDensity() throws CoserBusinessException {
- Project project = createTestProject(projectService);
+ Project project = createTestProject(projectService, true);
Selection selection = projectService.initProjectSelection(project);
selection.setName("test");
MatrixND matrix = projectService.getDensity(project, selection);
1
0
r277 - trunk/coser-business/src/main/resources/fr/ifremer/coser/data
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 14:38:57 +0000 (Thu, 25 Nov 2010)
New Revision: 277
Log:
Wrong character in expresion (strange space)
Modified:
trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml 2010-11-25 14:34:00 UTC (rev 276)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/data/Length-error-validation.xml 2010-11-25 14:38:57 UTC (rev 277)
@@ -66,7 +66,7 @@
</field-validator>
</field>
<validator type="coserExpression">
- <param name="expression"><![CDATA[lengthAsString.endsWith(".00") || lengthAsString.endsWith(".0") || lengthAsString.endsWith(".50") || lengthAsString.endsWith(".5")]]></param>
+ <param name="expression"><![CDATA[lengthAsString.endsWith(".00") || lengthAsString.endsWith(".0") || lengthAsString.endsWith(".50") || lengthAsString.endsWith(".5")]]></param>
<message>coser.business.control.error.invalidLengthLengthStep</message>
</validator>
<field name="numberAsString">
1
0
r276 - trunk/coser-business/src/main/java/fr/ifremer/coser/bean
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 14:34:00 +0000 (Thu, 25 Nov 2010)
New Revision: 276
Log:
Imports
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java
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 2010-11-25 14:31:31 UTC (rev 275)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2010-11-25 14:34:00 UTC (rev 276)
@@ -31,9 +31,6 @@
import org.apache.commons.lang.StringUtils;
-import fr.ifremer.coser.CoserBusinessConfig;
-import fr.ifremer.coser.CoserConstants;
-
/**
* Project selection.
*
1
0
r275 - in trunk: coser-business/src/main/java/fr/ifremer/coser coser-business/src/main/java/fr/ifremer/coser/bean coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/java/fr/ifremer/coser/ui/selection coser-ui/src/main/resources/i18n
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
by chatellier@users.labs.libre-entreprise.org 25 Nov '10
25 Nov '10
Author: chatellier
Date: 2010-11-25 14:31:31 +0000 (Thu, 25 Nov 2010)
New Revision: 275
Log:
Save occurrence and density filter.
Ass occurrence and density configuration
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -82,16 +82,26 @@
return result;
}
- public double getObervationNobsmin() {
- double result = getOptionAsDouble(CoserBusinessOption.OBSERVATION_NOBSMIN.key);
+ public double getControlNobsmin() {
+ double result = getOptionAsDouble(CoserBusinessOption.CONTROL_NOBSMIN.key);
return result;
}
public double getControlDiffCatchLength() {
- double result = getOptionAsDouble(CoserBusinessOption.CONTROL_DIFF_CACTH_LENGTH.key);
+ double result = getOptionAsDouble(CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.key);
return result;
}
+ public double getSelectionOccurrenceFilter() {
+ double result = getOptionAsDouble(CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.key);
+ return result;
+ }
+
+ public double getSelectionDensityFilter() {
+ double result = getOptionAsDouble(CoserBusinessOption.SELECTION_FILTER_DENSITY.key);
+ return result;
+ }
+
public static enum CoserBusinessOption implements OptionDef {
DATABASE_DIRECTORY("coser.database.directory", _("coser.config.database.directory.description"), "${user.home}" + File.separator + "coser", String.class, false, false),
@@ -101,8 +111,10 @@
REFERENCE_SPECIES("coser.reference.species", _("coser.config.reference.species.description"), "", String.class, false, false),
REFERENCE_TYPE_ESPECES("coser.reference.typeEspeces", _("coser.config.reference.typeEspeces.description"), "", String.class, false, false),
- OBSERVATION_NOBSMIN("coser.observation.nobsmin", _("coser.config.observation.nobsmin.description"), "1.0", Double.class, false, false),
- CONTROL_DIFF_CACTH_LENGTH("coser.control.diffcatchlength", _("coser.config.control.diffcatchlength.description"), "5.0", Double.class, false, false);
+ CONTROL_NOBSMIN("coser.control.nobsmin", _("coser.config.control.nobsmin.description"), "1.0", Double.class, false, false),
+ CONTROL_DIFF_CATCH_LENGTH("coser.control.diffcatchlength", _("coser.config.control.diffcatchlength.description"), "5.0", Double.class, false, false),
+ SELECTION_FILTER_OCCURRENCE("coser.selection.occurrenceFilter", _("coser.config.selection.occurrenceFilter.description"), "5.0", Double.class, false, false),
+ SELECTION_FILTER_DENSITY("coser.selection.densityFilter", _("coser.config.selection.densityFilter.description"), "5.0", Double.class, false, false);
protected String key;
protected String description;
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 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -31,6 +31,9 @@
import org.apache.commons.lang.StringUtils;
+import fr.ifremer.coser.CoserBusinessConfig;
+import fr.ifremer.coser.CoserConstants;
+
/**
* Project selection.
*
@@ -61,6 +64,10 @@
protected String comment;
+ protected double occurrenceFilter;
+
+ protected double densityFilter;
+
/** L1 : liste des especes. */
protected List<String> selectedSpecies;
@@ -143,6 +150,26 @@
getPropertyChangeSupport().firePropertyChange("comment", oldValue, comment);
}
+ public double getOccurrenceFilter() {
+ return occurrenceFilter;
+ }
+
+ public void setOccurrenceFilter(double occurrenceFilter) {
+ double oldValue = this.occurrenceFilter;
+ this.occurrenceFilter = occurrenceFilter;
+ getPropertyChangeSupport().firePropertyChange("occurrenceFilter", oldValue, occurrenceFilter);
+ }
+
+ public double getDensityFilter() {
+ return densityFilter;
+ }
+
+ public void setDensityFilter(double densityFilter) {
+ double oldValue = this.densityFilter;
+ this.densityFilter = densityFilter;
+ getPropertyChangeSupport().firePropertyChange("densityFilter", oldValue, densityFilter);
+ }
+
public List<String> getSelectedSpecies() {
return selectedSpecies;
}
@@ -255,6 +282,8 @@
if (comment != null) {
props.setProperty("selection.comment", comment);
}
+ props.setProperty("selection.occurrenceFilter", String.valueOf(occurrenceFilter));
+ props.setProperty("selection.densityFilter", String.valueOf(densityFilter));
if (getSelectedSpecies() != null) {
props.setProperty("selection.selectedSpecies", StringUtils.join(getSelectedSpecies(),','));
}
@@ -300,6 +329,12 @@
if (props.containsKey("selection.comment")) {
setComment(props.getProperty("selection.comment"));
}
+ if (props.containsKey("selection.occurrenceFilter")) {
+ setOccurrenceFilter(Double.parseDouble(props.getProperty("selection.occurrenceFilter")));
+ }
+ if (props.containsKey("selection.densityFilter")) {
+ setDensityFilter(Double.parseDouble(props.getProperty("selection.densityFilter")));
+ }
if (props.containsKey("selection.selectedSpecies")) {
setSelectedSpecies(splitAsList(props.getProperty("selection.selectedSpecies")));
}
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 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -686,6 +686,10 @@
selection.setHistoryCommand(new ArrayList<Command>());
selection.setRsufiResults(new ArrayList<RSufiResult>());
+
+ // init filter values with configuration
+ selection.setDensityFilter(config.getSelectionDensityFilter());
+ selection.setOccurrenceFilter(config.getSelectionOccurrenceFilter());
return selection;
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -525,7 +525,7 @@
for (Map.Entry<String, Double> sumObservation : nombreForKey.entrySet()) {
String key = sumObservation.getKey();
Double value = sumObservation.getValue();
- if (value < config.getObervationNobsmin()) {
+ if (value < config.getControlNobsmin()) {
String lineNumber = firstLineForKey.get(key);
@@ -745,7 +745,7 @@
for (Map.Entry<String, Double> sumObservation : nombreForKey.entrySet()) {
String key = sumObservation.getKey();
Double value = sumObservation.getValue();
- if (value < config.getObervationNobsmin()) {
+ if (value < config.getControlNobsmin()) {
String lineNumber = firstLineForKey.get(key);
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2010-11-25 14:31:31 UTC (rev 275)
@@ -56,11 +56,13 @@
coser.business.result.rsufiResultAlreadyExists=
coser.business.selection.notValidatedControl=
coser.config.control.diffcatchlength.description=
+coser.config.control.nobsmin.description=
coser.config.database.directory.description=
-coser.config.observation.nobsmin.description=
coser.config.projects.directory.description=
coser.config.reference.species.description=
coser.config.reference.typeEspeces.description=
+coser.config.selection.densityFilter.description=
+coser.config.selection.occurrenceFilter.description=
coser.config.validator.directory.description=
depth\ attribute\ is\ not\ a\ valid\ double=
lat\ attribute\ is\ not\ a\ valid\ double=
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2010-11-25 14:31:31 UTC (rev 275)
@@ -56,11 +56,13 @@
coser.business.result.rsufiResultAlreadyExists=Le r\u00E9sultat %D existe d\u00E9j\u00E0 \!
coser.business.selection.notValidatedControl=Contr\u00F4le non valid\u00E9 \!
coser.config.control.diffcatchlength.description=Pourcentage d'\u00E9cart tol\u00E9r\u00E9 entre les captures et les tailles (en pourcent, par exemple pour 5% mettre 5.0)
+coser.config.control.nobsmin.description=Nombre minimal d'observation
coser.config.database.directory.description=Emplacement du dossier de toutes les donn\u00E9es relatives \u00E0 Coser
-coser.config.observation.nobsmin.description=Nombre minimal d'observation
coser.config.projects.directory.description=Emplacement du dossier de sauvegarde des projets
coser.config.reference.species.description=Emplacement du fichier de r\u00E9f\u00E9rence des esp\u00E8ces (Reftax)
coser.config.reference.typeEspeces.description=Emplacement du fichier de code type des esp\u00E8ces
+coser.config.selection.densityFilter.description=Filtre par d\u00E9faut sur la moyenne des densit\u00E9s
+coser.config.selection.occurrenceFilter.description=Filtre par d\u00E9faut sur la moyenne des occurrences
coser.config.validator.directory.description=Emplacement des fichiers de validations
depth\ attribute\ is\ not\ a\ valid\ double=L'attribut ProfMoy n'est pas un r\u00E9el valide
lat\ attribute\ is\ not\ a\ valid\ double=L'attribut Lat n'est pas un r\u00E9el valide
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -150,18 +150,20 @@
ConfigUIHelper modelBuilder = new ConfigUIHelper(config);
// category main
- modelBuilder.addCategory(_("coser.config.category.main"), _("coser.config.category.main.description"));
+ modelBuilder.addCategory(_("coser.config.category.path"), _("coser.config.category.path.description"));
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.DATABASE_DIRECTORY);
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.PROJECTS_DIRECTORY);
-
- // category control
- modelBuilder.addCategory(_("coser.config.category.control"), _("coser.config.category.control.description"));
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_SPECIES);
modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_TYPE_ESPECES);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.OBSERVATION_NOBSMIN);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_DIFF_CACTH_LENGTH);
- ConfigUI configUI = modelBuilder.buildUI(view, _("coser.config.category.main"));
+ // category control
+ modelBuilder.addCategory(_("coser.config.category.configuration"), _("coser.config.category.configuration.description"));
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_NOBSMIN);
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH);
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SELECTION_FILTER_OCCURRENCE);
+ modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SELECTION_FILTER_DENSITY);
+
+ ConfigUI configUI = modelBuilder.buildUI(view, _("coser.config.category.path"));
JDialog dialogUI = new JDialog(view, _("coser.ui.config.title"));
dialogUI.add(configUI);
dialogUI.pack();
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-11-25 14:31:31 UTC (rev 275)
@@ -426,6 +426,9 @@
* @param view selection list view
*/
public void updateOccurrenceDensityFilter(SelectionListsView view) {
+
+ Selection selection = view.getContextValue(Selection.class);
+
String stringOccurrence = view.getSelectionFilterOccurrenceField().getText().trim();
String stringDensity = view.getSelectionFilterDensityField().getText().trim();
@@ -433,6 +436,9 @@
double occurrence = Double.valueOf(stringOccurrence);
double density = Double.valueOf(stringDensity);
+ selection.setOccurrenceFilter(occurrence);
+ selection.setDensityFilter(density);
+
// construction de la liste de selection des especes
OccurrenceDensitySpecyListModel model = view.getSelectionOccurrenceDensityListModel();
int speciesCount = model.getSize();
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-11-25 14:31:31 UTC (rev 275)
@@ -77,10 +77,17 @@
<cell fill="horizontal" insets="0" columns="2" anchor="west">
<JPanel>
<JLabel text="coser.ui.selection.filter.occurrence" />
- <JTextField id="selectionFilterOccurrenceField" columns="3" text="5" />
+ <JTextField id="selectionFilterOccurrenceField" columns="3" text="{String.valueOf(getSelection().getOccurrenceFilter())}" />
+ <javax.swing.text.Document javaBean="selectionFilterOccurrenceField.getDocument()"
+ onInsertUpdate='applyOccDensFilter.setEnabled(true)'
+ onRemoveUpdate='applyOccDensFilter.setEnabled(true)' />
<JLabel text="coser.ui.selection.filter.density" />
- <JTextField id="selectionFilterDensityField" columns="3" text="5" />
- <JButton text="coser.ui.selection.filter.filter" onActionPerformed="getHandler().updateOccurrenceDensityFilter(this)" />
+ <JTextField id="selectionFilterDensityField" columns="3" text="{String.valueOf(getSelection().getDensityFilter())}" />
+ <javax.swing.text.Document javaBean="selectionFilterDensityField.getDocument()"
+ onInsertUpdate='applyOccDensFilter.setEnabled(true)'
+ onRemoveUpdate='applyOccDensFilter.setEnabled(true)' />
+ <JButton id="applyOccDensFilter" text="coser.ui.selection.filter.filter" enabled="false"
+ onActionPerformed="getHandler().updateOccurrenceDensityFilter(this);applyOccDensFilter.setEnabled(false)" />
</JPanel>
</cell>
<cell columns="2">
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-11-25 14:31:31 UTC (rev 275)
@@ -1,8 +1,8 @@
coser.config.application.version.description=Application's version
-coser.config.category.control=Control
-coser.config.category.control.description=Control
-coser.config.category.main=Coser
-coser.config.category.main.description=Main configuration
+coser.config.category.configuration=
+coser.config.category.configuration.description=
+coser.config.category.path=
+coser.config.category.path.description=
coser.config.config.file.description=Coser configuration file
coser.config.locale.description=Application's locale
coser.config.lookandfeel.description=Application's swing theme
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-25 13:38:11 UTC (rev 274)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-11-25 14:31:31 UTC (rev 275)
@@ -1,8 +1,8 @@
coser.config.application.version.description=Version de l'application
-coser.config.category.control=Contr\u00F4le
-coser.config.category.control.description=Contr\u00F4le
-coser.config.category.main=Coser
-coser.config.category.main.description=Configuration principale
+coser.config.category.configuration=Configuration
+coser.config.category.configuration.description=Configuration (donn\u00E9es num\u00E9riques)
+coser.config.category.path=Chemins
+coser.config.category.path.description=Configuration des fichiers et r\u00E9pertoires
coser.config.config.file.description=Fichier de configuration de Coser
coser.config.locale.description=Langue de l'application
coser.config.lookandfeel.description=Themes graphique Swing de l'application
1
0