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
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
participants (1)
-
chatellier@users.labs.libre-entreprise.org