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
- 1259 discussions
r104 - 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/command coser-business/src/main/java/fr/ifremer/coser/data 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 coser-ui/src/main/java/fr/ifremer/coser/ui/control
by chatellier@users.labs.libre-entreprise.org 26 Oct '10
by chatellier@users.labs.libre-entreprise.org 26 Oct '10
26 Oct '10
Author: chatellier
Date: 2010-10-26 14:08:45 +0000 (Tue, 26 Oct 2010)
New Revision: 104
Log:
Move data beans to their own data package
Added:
trunk/coser-business/src/main/java/fr/ifremer/coser/data/
trunk/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java
trunk/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java
trunk/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java
trunk/coser-business/src/main/java/fr/ifremer/coser/data/Length.java
trunk/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java
trunk/coser-business/src/main/java/fr/ifremer/coser/data/package-info.java
Removed:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.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/test/java/fr/ifremer/coser/services/ValidationServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -1,66 +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.bean;
-
-import static org.nuiton.i18n.I18n.n_;
-
-/**
- * Abstract entity to add all common data array code.
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public abstract class AbstractDataEntity extends AbstractEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 4188448448464323807L;
-
- public static final int INDEX_LINE = 0;
- public static final String PROPERTY_LINE = n_("coser.business.line");
-
- protected String[] data;
-
- public String[] getData() {
- return data;
- }
-
- public void setData(String[] data) {
- this.data = data;
- }
-
- public void setLine(String value) {
- String oldValue = data[INDEX_LINE];
- data[INDEX_LINE] = value;
- getPropertyChangeSupport().firePropertyChange(PROPERTY_LINE, oldValue, value);
- }
-
- public String getLine() {
- return data[INDEX_LINE];
- }
-}
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -1,120 +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.bean;
-
-
-/**
- * Catch entity delegating to ordered array.
- *
- * "Campagne","Annee","Trait","Espece","Nombre","Poids"
- * "Survey","Year","Haul","Species","Number","Weight"
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class Catch extends AbstractDataEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = -3868116128268974801L;
-
- public static final String[] FR_HEADERS = {
- "Campagne","Annee","Trait","Espece","Nombre","Poids"
- };
-
- public static final String[] EN_HEADERS = {
- "Survey","Year","Haul","Species","Number","Weight"
- };
-
- public static final int INDEX_SURVEY = 1;
- public static final int INDEX_YEAR = 2;
- public static final int INDEX_HAUL = 3;
- public static final int INDEX_SPECIES = 4;
- public static final int INDEX_NUMBER = 5;
- public static final int INDEX_WEIGHT = 6;
-
- public void setSurvey(String value) {
- String oldValue = data[INDEX_SURVEY];
- data[INDEX_SURVEY] = value;
- getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
- }
-
- public String getSurvey() {
- return data[INDEX_SURVEY];
- }
-
- public void setYear(String value) {
- String oldValue = data[INDEX_YEAR];
- data[INDEX_YEAR] = value;
- getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
- }
-
- public String getYear() {
- return data[INDEX_YEAR];
- }
-
- public void setHaul(String value) {
- String oldValue = data[INDEX_HAUL];
- data[INDEX_HAUL] = value;
- getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
- }
-
- public String getHaul() {
- return data[INDEX_HAUL];
- }
-
- public void setSpecies(String value) {
- String oldValue = data[INDEX_SPECIES];
- data[INDEX_SPECIES] = value;
- getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
- }
-
- public String getSpecies() {
- return data[INDEX_SPECIES];
- }
-
- public void setNumber(String value) {
- String oldValue = data[INDEX_NUMBER];
- data[INDEX_NUMBER] = String.valueOf(value);
- getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
- }
-
- public String getNumber() {
- return data[INDEX_NUMBER];
- }
-
- public void setWeight(String value) {
- String oldValue = data[INDEX_WEIGHT];
- data[INDEX_WEIGHT] = value;
- getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
- }
-
- public String getWeight() {
- return data[INDEX_WEIGHT];
- }
-}
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -1,153 +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.bean;
-
-
-/**
- * Haul entity delegating to ordered array.
- *
- * "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy"
- * "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth"
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class Haul extends AbstractDataEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3931599935237369209L;
-
- public static final String[] FR_HEADERS = {
- "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy"
- };
-
- public static final String[] EN_HEADERS = {
- "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth"
- };
-
- public static final int INDEX_SURVEY = 1;
- public static final int INDEX_YEAR = 2;
- public static final int INDEX_HAUL = 3;
- public static final int INDEX_MONTH = 4;
- public static final int INDEX_STRATUM = 5;
- public static final int INDEX_SWEPT_SURFACE = 6;
- public static final int INDEX_LAT = 7;
- public static final int INDEX_LONG = 8;
- public static final int INDEX_DEPTH = 9;
-
- public void setSurvey(String value) {
- String oldValue = data[INDEX_SURVEY];
- data[INDEX_SURVEY] = value;
- getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
- }
-
- public String getSurvey() {
- return data[INDEX_SURVEY];
- }
-
- public void setYear(String value) {
- String oldValue = data[INDEX_YEAR];
- data[INDEX_YEAR] = value;
- getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
- }
-
- public String getYear() {
- return data[INDEX_YEAR];
- }
-
- public void setHaul(String value) {
- String oldValue = data[INDEX_HAUL];
- data[INDEX_HAUL] = value;
- getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
- }
-
- public String getHaul() {
- return data[INDEX_HAUL];
- }
-
- public void setMonth(String value) {
- String oldValue = data[INDEX_MONTH];
- data[INDEX_MONTH] = value;
- getPropertyChangeSupport().firePropertyChange("month", oldValue, value);
- }
-
- public String getMonth() {
- return data[INDEX_MONTH];
- }
-
- public void setStratum(String value) {
- String oldValue = data[INDEX_STRATUM];
- data[INDEX_STRATUM] = value;
- getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
- }
-
- public String getStratum() {
- return data[INDEX_STRATUM];
- }
-
- public void setSweptSurface(String value) {
- String oldValue = data[INDEX_SWEPT_SURFACE];
- data[INDEX_SWEPT_SURFACE] = value;
- getPropertyChangeSupport().firePropertyChange("sweptSurface", oldValue, value);
- }
-
- public String getSweptSurface() {
- return data[INDEX_SWEPT_SURFACE];
- }
-
- public void setLat(String value) {
- String oldValue = data[INDEX_LAT];
- data[INDEX_LAT] = value;
- getPropertyChangeSupport().firePropertyChange("lat", oldValue, value);
- }
-
- public String getLat() {
- return data[INDEX_LAT];
- }
-
- public void setLong(String value) {
- String oldValue = data[INDEX_LONG];
- data[INDEX_LONG] = value;
- getPropertyChangeSupport().firePropertyChange("long", oldValue, value);
- }
-
- public String getLong() {
- return data[INDEX_LONG];
- }
-
- public void setDepth(String value) {
- String oldValue = data[INDEX_DEPTH];
- data[INDEX_DEPTH] = value;
- getPropertyChangeSupport().firePropertyChange("depth", oldValue, value);
- }
-
- public String getDepth() {
- return data[INDEX_DEPTH];
- }
-}
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -1,173 +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.bean;
-
-/**
- * Length entity delegating to ordered array.
- *
- * "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age"
- * "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age"
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class Length extends AbstractDataEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 1283486477462355761L;
-
- public static final String[] FR_HEADERS = {
- "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age"
- };
-
- public static final String[] EN_HEADERS = {
- "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age"
- };
-
- public static final int INDEX_SURVEY = 1;
- public static final int INDEX_YEAR = 2;
- public static final int INDEX_HAUL = 3;
- public static final int INDEX_SPECIES = 4;
- public static final int INDEX_SEX = 5;
- public static final int INDEX_MATURITY = 6;
- public static final int INDEX_LENGTH = 7;
- public static final int INDEX_NUMBER = 8;
- public static final int INDEX_WEIGHT = 9;
- public static final int INDEX_AGE = 10;
-
- public void setSurvey(String value) {
- String oldValue = data[INDEX_SURVEY];
- data[INDEX_SURVEY] = value;
- getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
- }
-
- public String getSurvey() {
- return data[INDEX_SURVEY];
- }
-
- public void setYear(String value) {
- String oldValue = data[INDEX_YEAR];
- data[INDEX_YEAR] = value;
- getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
- }
-
- public String getYear() {
- return data[INDEX_YEAR];
- }
-
- public void setHaul(String value) {
- String oldValue = data[INDEX_HAUL];
- data[INDEX_HAUL] = value;
- getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
- }
-
- public String getHaul() {
- return data[INDEX_HAUL];
- }
-
- public void setSpecies(String value) {
- String oldValue = data[INDEX_SPECIES];
- data[INDEX_SPECIES] = value;
- getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
- }
-
- public String getSpecies() {
- return data[INDEX_SPECIES];
- }
-
- public void setSex(String value) {
- String oldValue = data[INDEX_SEX];
- data[INDEX_SEX] = value;
- getPropertyChangeSupport().firePropertyChange("sex", oldValue, value);
- }
-
- public String getSex() {
- return data[INDEX_SEX];
- }
-
- public void setMaturity(String value) {
- String oldValue = data[INDEX_MATURITY];
- data[INDEX_MATURITY] = value;
- getPropertyChangeSupport().firePropertyChange("maturity", oldValue, value);
- }
-
- public String getMaturity() {
- return data[INDEX_MATURITY];
- }
-
- public void setLength(String value) {
- String oldValue = data[INDEX_LENGTH];
- data[INDEX_LENGTH] = value;
- getPropertyChangeSupport().firePropertyChange("length", oldValue, value);
- }
-
- public String getLength() {
- return data[INDEX_LENGTH];
- }
-
- public void setNumber(String value) {
- String oldValue = data[INDEX_NUMBER];
- data[INDEX_NUMBER] = value;
- getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
- }
-
- public String getNumber() {
- return data[INDEX_NUMBER];
- }
-
- public void setWeight(String value) {
- String oldValue = data[INDEX_WEIGHT];
- data[INDEX_WEIGHT] = value;
- getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
- }
-
- public String getWeight() {
- return data[INDEX_WEIGHT];
- }
-
- /**
- * Age field.
- *
- * @param value new value to set
- */
- public void setAge(String value) {
- String oldValue = data[INDEX_AGE];
- data[INDEX_AGE] = value;
- getPropertyChangeSupport().firePropertyChange("age", oldValue, value);
- }
-
- /**
- * Age field.
- *
- * @return age
- */
- public String getAge() {
- return data[INDEX_AGE];
- }
-}
Deleted: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -1,88 +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.bean;
-
-
-/**
- * Strata entity delegating to ordered array.
- *
- * "Campagne","Strate","Surface"
- * "Survey","Stratum","Surface"
- *
- * @author chatellier
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class Strata extends AbstractDataEntity {
-
- /** serialVersionUID. */
- private static final long serialVersionUID = 3176546952537796549L;
-
- public static final String[] FR_HEADERS = {
- "Campagne","Strate","Surface"
- };
-
- public static final String[] EN_HEADERS = {
- "Survey","Stratum","Surface"
- };
-
- public static final int INDEX_SURVEY = 1;
- public static final int INDEX_STRATUM = 2;
- public static final int INDEX_SURFACE = 3;
-
- public void setSurvey(String value) {
- String oldValue = data[INDEX_SURVEY];
- data[INDEX_SURVEY] = value;
- getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
- }
-
- public String getSurvey() {
- return data[INDEX_SURVEY];
- }
-
- public void setStratum(String value) {
- String oldValue = data[INDEX_STRATUM];
- data[INDEX_STRATUM] = value;
- getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
- }
-
- public String getStratum() {
- return data[INDEX_STRATUM];
- }
-
- public void setSurface(String value) {
- String oldValue = data[INDEX_SURFACE];
- data[INDEX_SURFACE] = value;
- getPropertyChangeSupport().firePropertyChange("surface", oldValue, value);
- }
-
- public String getSurface() {
- return data[INDEX_SURFACE];
- }
-
-}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -34,8 +34,8 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.bean.AbstractDataEntity;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.data.AbstractDataEntity;
import fr.ifremer.coser.storage.DataStorage;
/**
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -32,8 +32,8 @@
import org.apache.commons.logging.LogFactory;
import fr.ifremer.coser.CoserBusinessException;
-import fr.ifremer.coser.bean.Catch;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.data.Catch;
/**
* Merge species command.
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -27,11 +27,11 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.bean.Catch;
-import fr.ifremer.coser.bean.Haul;
-import fr.ifremer.coser.bean.Length;
import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.bean.Strata;
+import fr.ifremer.coser.data.Catch;
+import fr.ifremer.coser.data.Haul;
+import fr.ifremer.coser.data.Length;
+import fr.ifremer.coser.data.Strata;
/**
* Command pattern object.
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java (from rev 97, trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/AbstractDataEntity.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,67 @@
+/*
+ * #%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.data;
+
+import static org.nuiton.i18n.I18n.n_;
+import fr.ifremer.coser.bean.AbstractEntity;
+
+/**
+ * Abstract entity to add all common data array code.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public abstract class AbstractDataEntity extends AbstractEntity {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 4188448448464323807L;
+
+ public static final int INDEX_LINE = 0;
+ public static final String PROPERTY_LINE = n_("coser.business.line");
+
+ protected String[] data;
+
+ public String[] getData() {
+ return data;
+ }
+
+ public void setData(String[] data) {
+ this.data = data;
+ }
+
+ public void setLine(String value) {
+ String oldValue = data[INDEX_LINE];
+ data[INDEX_LINE] = value;
+ getPropertyChangeSupport().firePropertyChange(PROPERTY_LINE, oldValue, value);
+ }
+
+ public String getLine() {
+ return data[INDEX_LINE];
+ }
+}
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java (from rev 97, trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/Catch.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,119 @@
+/*
+ * #%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.data;
+
+/**
+ * Catch entity delegating to ordered array.
+ *
+ * "Campagne","Annee","Trait","Espece","Nombre","Poids"
+ * "Survey","Year","Haul","Species","Number","Weight"
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Catch extends AbstractDataEntity {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -3868116128268974801L;
+
+ public static final String[] FR_HEADERS = {
+ "Campagne","Annee","Trait","Espece","Nombre","Poids"
+ };
+
+ public static final String[] EN_HEADERS = {
+ "Survey","Year","Haul","Species","Number","Weight"
+ };
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_SPECIES = 4;
+ public static final int INDEX_NUMBER = 5;
+ public static final int INDEX_WEIGHT = 6;
+
+ public void setSurvey(String value) {
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
+ getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
+ }
+
+ public String getSurvey() {
+ return data[INDEX_SURVEY];
+ }
+
+ public void setYear(String value) {
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
+ getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
+ }
+
+ public String getYear() {
+ return data[INDEX_YEAR];
+ }
+
+ public void setHaul(String value) {
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
+ getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
+ }
+
+ public String getHaul() {
+ return data[INDEX_HAUL];
+ }
+
+ public void setSpecies(String value) {
+ String oldValue = data[INDEX_SPECIES];
+ data[INDEX_SPECIES] = value;
+ getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
+ }
+
+ public String getSpecies() {
+ return data[INDEX_SPECIES];
+ }
+
+ public void setNumber(String value) {
+ String oldValue = data[INDEX_NUMBER];
+ data[INDEX_NUMBER] = String.valueOf(value);
+ getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
+ }
+
+ public String getNumber() {
+ return data[INDEX_NUMBER];
+ }
+
+ public void setWeight(String value) {
+ String oldValue = data[INDEX_WEIGHT];
+ data[INDEX_WEIGHT] = value;
+ getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
+ }
+
+ public String getWeight() {
+ return data[INDEX_WEIGHT];
+ }
+}
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java (from rev 97, trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/Haul.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,152 @@
+/*
+ * #%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.data;
+
+/**
+ * Haul entity delegating to ordered array.
+ *
+ * "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy"
+ * "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth"
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Haul extends AbstractDataEntity {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3931599935237369209L;
+
+ public static final String[] FR_HEADERS = {
+ "Campagne","Annee","Trait","Mois","Strate","SurfaceBalayee","Lat","Long","ProfMoy"
+ };
+
+ public static final String[] EN_HEADERS = {
+ "Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth"
+ };
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_MONTH = 4;
+ public static final int INDEX_STRATUM = 5;
+ public static final int INDEX_SWEPT_SURFACE = 6;
+ public static final int INDEX_LAT = 7;
+ public static final int INDEX_LONG = 8;
+ public static final int INDEX_DEPTH = 9;
+
+ public void setSurvey(String value) {
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
+ getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
+ }
+
+ public String getSurvey() {
+ return data[INDEX_SURVEY];
+ }
+
+ public void setYear(String value) {
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
+ getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
+ }
+
+ public String getYear() {
+ return data[INDEX_YEAR];
+ }
+
+ public void setHaul(String value) {
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
+ getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
+ }
+
+ public String getHaul() {
+ return data[INDEX_HAUL];
+ }
+
+ public void setMonth(String value) {
+ String oldValue = data[INDEX_MONTH];
+ data[INDEX_MONTH] = value;
+ getPropertyChangeSupport().firePropertyChange("month", oldValue, value);
+ }
+
+ public String getMonth() {
+ return data[INDEX_MONTH];
+ }
+
+ public void setStratum(String value) {
+ String oldValue = data[INDEX_STRATUM];
+ data[INDEX_STRATUM] = value;
+ getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
+ }
+
+ public String getStratum() {
+ return data[INDEX_STRATUM];
+ }
+
+ public void setSweptSurface(String value) {
+ String oldValue = data[INDEX_SWEPT_SURFACE];
+ data[INDEX_SWEPT_SURFACE] = value;
+ getPropertyChangeSupport().firePropertyChange("sweptSurface", oldValue, value);
+ }
+
+ public String getSweptSurface() {
+ return data[INDEX_SWEPT_SURFACE];
+ }
+
+ public void setLat(String value) {
+ String oldValue = data[INDEX_LAT];
+ data[INDEX_LAT] = value;
+ getPropertyChangeSupport().firePropertyChange("lat", oldValue, value);
+ }
+
+ public String getLat() {
+ return data[INDEX_LAT];
+ }
+
+ public void setLong(String value) {
+ String oldValue = data[INDEX_LONG];
+ data[INDEX_LONG] = value;
+ getPropertyChangeSupport().firePropertyChange("long", oldValue, value);
+ }
+
+ public String getLong() {
+ return data[INDEX_LONG];
+ }
+
+ public void setDepth(String value) {
+ String oldValue = data[INDEX_DEPTH];
+ data[INDEX_DEPTH] = value;
+ getPropertyChangeSupport().firePropertyChange("depth", oldValue, value);
+ }
+
+ public String getDepth() {
+ return data[INDEX_DEPTH];
+ }
+}
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/data/Length.java (from rev 97, trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/Length.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/Length.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,173 @@
+/*
+ * #%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.data;
+
+/**
+ * Length entity delegating to ordered array.
+ *
+ * "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age"
+ * "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age"
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Length extends AbstractDataEntity {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 1283486477462355761L;
+
+ public static final String[] FR_HEADERS = {
+ "Campagne","Annee","Trait","Espece","Sexe","Maturite","Longueur","Nombre","Poids","Age"
+ };
+
+ public static final String[] EN_HEADERS = {
+ "Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age"
+ };
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_SPECIES = 4;
+ public static final int INDEX_SEX = 5;
+ public static final int INDEX_MATURITY = 6;
+ public static final int INDEX_LENGTH = 7;
+ public static final int INDEX_NUMBER = 8;
+ public static final int INDEX_WEIGHT = 9;
+ public static final int INDEX_AGE = 10;
+
+ public void setSurvey(String value) {
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
+ getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
+ }
+
+ public String getSurvey() {
+ return data[INDEX_SURVEY];
+ }
+
+ public void setYear(String value) {
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
+ getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
+ }
+
+ public String getYear() {
+ return data[INDEX_YEAR];
+ }
+
+ public void setHaul(String value) {
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
+ getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
+ }
+
+ public String getHaul() {
+ return data[INDEX_HAUL];
+ }
+
+ public void setSpecies(String value) {
+ String oldValue = data[INDEX_SPECIES];
+ data[INDEX_SPECIES] = value;
+ getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
+ }
+
+ public String getSpecies() {
+ return data[INDEX_SPECIES];
+ }
+
+ public void setSex(String value) {
+ String oldValue = data[INDEX_SEX];
+ data[INDEX_SEX] = value;
+ getPropertyChangeSupport().firePropertyChange("sex", oldValue, value);
+ }
+
+ public String getSex() {
+ return data[INDEX_SEX];
+ }
+
+ public void setMaturity(String value) {
+ String oldValue = data[INDEX_MATURITY];
+ data[INDEX_MATURITY] = value;
+ getPropertyChangeSupport().firePropertyChange("maturity", oldValue, value);
+ }
+
+ public String getMaturity() {
+ return data[INDEX_MATURITY];
+ }
+
+ public void setLength(String value) {
+ String oldValue = data[INDEX_LENGTH];
+ data[INDEX_LENGTH] = value;
+ getPropertyChangeSupport().firePropertyChange("length", oldValue, value);
+ }
+
+ public String getLength() {
+ return data[INDEX_LENGTH];
+ }
+
+ public void setNumber(String value) {
+ String oldValue = data[INDEX_NUMBER];
+ data[INDEX_NUMBER] = value;
+ getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
+ }
+
+ public String getNumber() {
+ return data[INDEX_NUMBER];
+ }
+
+ public void setWeight(String value) {
+ String oldValue = data[INDEX_WEIGHT];
+ data[INDEX_WEIGHT] = value;
+ getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
+ }
+
+ public String getWeight() {
+ return data[INDEX_WEIGHT];
+ }
+
+ /**
+ * Age field.
+ *
+ * @param value new value to set
+ */
+ public void setAge(String value) {
+ String oldValue = data[INDEX_AGE];
+ data[INDEX_AGE] = value;
+ getPropertyChangeSupport().firePropertyChange("age", oldValue, value);
+ }
+
+ /**
+ * Age field.
+ *
+ * @return age
+ */
+ public String getAge() {
+ return data[INDEX_AGE];
+ }
+}
Copied: trunk/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java (from rev 97, trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java)
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/Strata.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,87 @@
+/*
+ * #%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.data;
+
+/**
+ * Strata entity delegating to ordered array.
+ *
+ * "Campagne","Strate","Surface"
+ * "Survey","Stratum","Surface"
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Strata extends AbstractDataEntity {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 3176546952537796549L;
+
+ public static final String[] FR_HEADERS = {
+ "Campagne","Strate","Surface"
+ };
+
+ public static final String[] EN_HEADERS = {
+ "Survey","Stratum","Surface"
+ };
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_STRATUM = 2;
+ public static final int INDEX_SURFACE = 3;
+
+ public void setSurvey(String value) {
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
+ getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
+ }
+
+ public String getSurvey() {
+ return data[INDEX_SURVEY];
+ }
+
+ public void setStratum(String value) {
+ String oldValue = data[INDEX_STRATUM];
+ data[INDEX_STRATUM] = value;
+ getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
+ }
+
+ public String getStratum() {
+ return data[INDEX_STRATUM];
+ }
+
+ public void setSurface(String value) {
+ String oldValue = data[INDEX_SURFACE];
+ data[INDEX_SURFACE] = value;
+ getPropertyChangeSupport().firePropertyChange("surface", oldValue, value);
+ }
+
+ public String getSurface() {
+ return data[INDEX_SURFACE];
+ }
+
+}
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/data/package-info.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/data/package-info.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/data/package-info.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -0,0 +1,28 @@
+/*
+ * #%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%
+ */
+/**
+ * Data entities classes.
+ */
+package fr.ifremer.coser.data;
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/data/package-info.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -51,12 +51,12 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.bean.AbstractDataEntity;
-import fr.ifremer.coser.bean.Catch;
-import fr.ifremer.coser.bean.Haul;
-import fr.ifremer.coser.bean.Length;
import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.bean.Strata;
+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.storage.DataStorage;
import fr.ifremer.coser.storage.MemoryListStorage;
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-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -46,13 +46,13 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
-import fr.ifremer.coser.bean.Catch;
-import fr.ifremer.coser.bean.Haul;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Specy;
import fr.ifremer.coser.command.Command;
import fr.ifremer.coser.command.DeleteLineCommand;
import fr.ifremer.coser.command.MergeSpeciesCommand;
+import fr.ifremer.coser.data.Catch;
+import fr.ifremer.coser.data.Haul;
import fr.ifremer.coser.storage.DataStorage;
/**
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-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -49,13 +49,13 @@
import fr.ifremer.coser.CoserBusinessConfig;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserConstants.ValidationLevel;
-import fr.ifremer.coser.bean.Catch;
-import fr.ifremer.coser.bean.Haul;
-import fr.ifremer.coser.bean.Length;
import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.bean.Strata;
import fr.ifremer.coser.control.ProgressMonitor;
import fr.ifremer.coser.control.ValidationError;
+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.storage.DataStorage;
/**
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-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -32,8 +32,8 @@
import org.junit.Assert;
import org.junit.Test;
-import fr.ifremer.coser.bean.Catch;
import fr.ifremer.coser.control.ValidationError;
+import fr.ifremer.coser.data.Catch;
/**
* Test abour validation.
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-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -56,8 +56,8 @@
import fr.ifremer.coser.CoserConfig;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserException;
-import fr.ifremer.coser.bean.Catch;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.data.Catch;
import fr.ifremer.coser.services.ProjectService;
import fr.ifremer.coser.ui.control.ControlHandler;
import fr.ifremer.coser.ui.control.ControlView;
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-10-26 13:59:58 UTC (rev 103)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-10-26 14:08:45 UTC (rev 104)
@@ -61,13 +61,13 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.CoserException;
-import fr.ifremer.coser.bean.AbstractDataEntity;
-import fr.ifremer.coser.bean.Catch;
-import fr.ifremer.coser.bean.Haul;
-import fr.ifremer.coser.bean.Length;
import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.bean.Strata;
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.ProjectService;
import fr.ifremer.coser.services.ValidationService;
1
0
r103 - 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/command coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/java/fr/ifremer/coser/storage coser-business/src/test/java/fr/ifremer/coser/services 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 Oct '10
by chatellier@users.labs.libre-entreprise.org 26 Oct '10
26 Oct '10
Author: chatellier
Date: 2010-10-26 13:59:58 +0000 (Tue, 26 Oct 2010)
New Revision: 103
Log:
Implementation du pattern command pour les operations sur les donn?\195?\169es.
Added:
trunk/coser-business/src/main/java/fr/ifremer/coser/command/
trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java
trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryListStorage.java
trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.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/ControlView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionResultView.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/CoserConstants.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -58,12 +58,18 @@
/** Suffix des nom de fichiers data apres control. */
public static final String STORAGE_CONTROL_SUFFIX = "_co";
+
+ /** Suffix des nom de fichiers data contenant les données supprimées. */
+ public static final String STORAGE_DELECTED_SUFFIX = "_del";
/** Suffix des nom de fichiers data apres selection. */
public static final String STORAGE_SELECTION_SUFFIX = "_se";
/** Extension des fichiers CSV. */
public static final String STORAGE_CSV_EXTENSION = ".csv";
+
+ /** Nom du fichier des historiques de modification */
+ public static final String HISTORY_FILENAME = "history.csv";
/** Categories des données manipulées. */
public static enum Category {
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -25,6 +25,9 @@
package fr.ifremer.coser.bean;
+import java.util.List;
+
+import fr.ifremer.coser.command.Command;
import fr.ifremer.coser.storage.DataStorage;
/**
@@ -54,15 +57,26 @@
protected DataStorage dataCatch;
+ protected DataStorage deletedDataCatch;
+
protected DataStorage dataStrata;
+ protected DataStorage deletedDataStrata;
+
protected DataStorage dataHaul;
+ protected DataStorage deletedDataHaul;
+
protected DataStorage dataLength;
+
+ protected DataStorage deletedDataLength;
/** Reftax SIH. */
protected DataStorage refTaxSpecies;
+ /** L'historique des commandes do/undo .*/
+ protected List<Command> historyCommand;
+
public DataStorage getCatch() {
return dataCatch;
}
@@ -105,6 +119,38 @@
this.dataLength = dataLength;
}
+ public DataStorage getDeletedCatch() {
+ return deletedDataCatch;
+ }
+
+ public void setDeletedCatch(DataStorage deletedDataCatch) {
+ this.deletedDataCatch = deletedDataCatch;
+ }
+
+ public DataStorage getDeletedStrata() {
+ return deletedDataStrata;
+ }
+
+ public void setDeletedStrata(DataStorage deletedDataStrata) {
+ this.deletedDataStrata = deletedDataStrata;
+ }
+
+ public DataStorage getDeletedHaul() {
+ return deletedDataHaul;
+ }
+
+ public void setDeletedHaul(DataStorage deletedDataHaul) {
+ this.deletedDataHaul = deletedDataHaul;
+ }
+
+ public DataStorage getDeletedLength() {
+ return deletedDataLength;
+ }
+
+ public void setDeletedLength(DataStorage deletedDataLength) {
+ this.deletedDataLength = deletedDataLength;
+ }
+
public DataStorage getRefTaxSpecies() {
return refTaxSpecies;
}
@@ -112,4 +158,12 @@
public void setRefTaxSpecies(DataStorage refTaxSpecies) {
this.refTaxSpecies = refTaxSpecies;
}
+
+ public List<Command> getHistoryCommand() {
+ return historyCommand;
+ }
+
+ public void setHistoryCommand(List<Command> historyCommand) {
+ this.historyCommand = historyCommand;
+ }
}
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,87 @@
+/*
+ * #%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.command;
+
+import java.util.UUID;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.bean.Project;
+
+/**
+ * Command interface.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public abstract class Command {
+
+ /**
+ * UUID de la commande. Les commandes ayant un UUID commun font partie
+ * du même groupe de commandes.
+ */
+ protected String commandUUID;
+
+ /**
+ * UUID de la commande. Les commandes ayant un UUID commun font partie
+ * du même groupe de commandes.
+ *
+ * @return command UUID
+ * @see UUID
+ */
+ public String getCommandUUID() {
+ return commandUUID;
+ }
+
+ /**
+ * UUID de la commande. Les commandes ayant un UUID commun font partie
+ * du même groupe de commandes.
+ *
+ * @param commandUUID new uuid
+ * @see UUID
+ */
+ public void setCommandUUID(String commandUUID) {
+ this.commandUUID = commandUUID;
+ }
+
+ /**
+ * Do command on project.
+ *
+ * @param project project
+ * @throws CoserBusinessException
+ */
+ public abstract void doCommand(Project project) throws CoserBusinessException;
+
+ /**
+ * Undo command on project.
+ *
+ * @param project project
+ * @throws CoserBusinessException
+ */
+ public abstract void undoCommand(Project project) throws CoserBusinessException;
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,197 @@
+/*
+ * #%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.command;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Iterator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.AbstractDataEntity;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.storage.DataStorage;
+
+/**
+ * Command pattern object.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class DeleteLineCommand extends Command {
+
+ private static final Log log = LogFactory.getLog(DeleteLineCommand.class);
+
+ /** Category de données sur lequel porte l'action. */
+ protected Category category;
+
+ /** Line index of object to do command to. */
+ protected String lineIndex;
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public String getLineIndex() {
+ return lineIndex;
+ }
+
+ public void setLineIndex(String lineIndex) {
+ this.lineIndex = lineIndex;
+ }
+
+ @Override
+ public void doCommand(Project project) throws CoserBusinessException {
+
+ DataStorage dataStorage = null;
+ DataStorage deletedDataStorage = null;
+
+ // get data storage depending on category
+ switch(category) {
+ case CATCH:
+ dataStorage = project.getCatch();
+ deletedDataStorage = project.getDeletedCatch();
+ break;
+ case HAUL:
+ dataStorage = project.getHaul();
+ deletedDataStorage = project.getDeletedHaul();
+ break;
+ case LENGTH:
+ dataStorage = project.getLength();
+ deletedDataStorage = project.getDeletedLength();
+ break;
+ case STRATA:
+ dataStorage = project.getStrata();
+ deletedDataStorage = project.getDeletedStrata();
+ break;
+ }
+
+ // parcourt des lignes
+ boolean dataLineFound = false;
+ Iterator<String[]> itDataStorage = dataStorage.iterator();
+ itDataStorage.next(); // skip header
+ while (itDataStorage.hasNext()) {
+ String[] dataLine = itDataStorage.next();
+ String dataLineIndex = dataLine[AbstractDataEntity.INDEX_LINE];
+ if (dataLineIndex.equals(lineIndex)) {
+ if (log.isDebugEnabled()) {
+ log.debug("Removing line " + dataLineIndex);
+ }
+ dataLineFound = true;
+ deletedDataStorage.add(dataLine);
+ itDataStorage.remove();
+ }
+ }
+
+ // if not found, throw business exception
+ if (!dataLineFound) {
+ throw new CoserBusinessException(_("Can't find line %s for deletion", lineIndex));
+ }
+ }
+
+ @Override
+ public void undoCommand(Project project) throws CoserBusinessException {
+ DataStorage dataStorage = null;
+ DataStorage deletedDataStorage = null;
+
+ // get data storage depending on category
+ switch(category) {
+ case CATCH:
+ dataStorage = project.getCatch();
+ deletedDataStorage = project.getDeletedCatch();
+ break;
+ case HAUL:
+ dataStorage = project.getHaul();
+ deletedDataStorage = project.getDeletedHaul();
+ break;
+ case LENGTH:
+ dataStorage = project.getLength();
+ deletedDataStorage = project.getDeletedLength();
+ break;
+ case STRATA:
+ dataStorage = project.getStrata();
+ deletedDataStorage = project.getDeletedStrata();
+ break;
+ }
+
+ // parcourt des lignes
+ boolean dataLineFound = false;
+ Iterator<String[]> itDeletedDataStorage = deletedDataStorage.iterator();
+ itDeletedDataStorage.next(); //skip header
+ while (itDeletedDataStorage.hasNext()) {
+ String[] deletedDataLine = itDeletedDataStorage.next();
+ String deletedDataLineIndex = deletedDataLine[AbstractDataEntity.INDEX_LINE];
+ if (deletedDataLineIndex.equals(lineIndex)) {
+ dataLineFound = true;
+ itDeletedDataStorage.remove();
+
+ // search new insert point
+ int originalDataLine = Integer.parseInt(deletedDataLineIndex);
+ Iterator<String[]> itDataStorage = dataStorage.iterator();
+ itDataStorage.next(); //skip header
+ int index = 1; // due to header
+ while (itDataStorage.hasNext()) {
+ String[] dataLine = itDataStorage.next();
+ String dataLineIndex = dataLine[AbstractDataEntity.INDEX_LINE];
+ int dataLineInt = Integer.parseInt(dataLineIndex);
+ if (dataLineInt == originalDataLine) {
+ throw new CoserBusinessException(_("Original line already exists!"));
+ }
+ else if (dataLineInt > originalDataLine) {
+ break;
+ }
+ index++;
+ }
+
+ // insert line at specified index
+ dataStorage.add(index, deletedDataLine);
+ if (log.isDebugEnabled()) {
+ log.debug("Restore line " + index);
+ }
+ }
+ }
+
+ // if not found, throw business exception
+ if (!dataLineFound) {
+ throw new CoserBusinessException(_("Can't find line %s for undeletion", lineIndex));
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "Delete line " + lineIndex + " on " + category;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,213 @@
+/*
+ * #%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.command;
+
+import java.util.Iterator;
+
+import org.apache.commons.lang.NotImplementedException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.bean.Catch;
+import fr.ifremer.coser.bean.Project;
+
+/**
+ * Merge species command.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class MergeSpeciesCommand extends Command {
+
+ private static final Log log = LogFactory.getLog(MergeSpeciesCommand.class);
+
+ protected String newSpecyName;
+
+ protected String[] speciesNames;
+
+ public String getNewSpecyName() {
+ return newSpecyName;
+ }
+
+ public void setNewSpecyName(String newSpecyName) {
+ this.newSpecyName = newSpecyName;
+ }
+
+ public String[] getSpeciesNames() {
+ return speciesNames;
+ }
+
+ public void setSpeciesNames(String[] speciesNames) {
+ this.speciesNames = speciesNames;
+ }
+
+ /*
+ * @see fr.ifremer.coser.command.Command#doCommand(fr.ifremer.coser.bean.Project)
+ */
+ @Override
+ public void doCommand(Project project) throws CoserBusinessException {
+
+ project = mergeCatch(project, newSpecyName, speciesNames);
+ project = mergeLength(project, newSpecyName, speciesNames);
+
+ }
+
+ /*
+ * @see fr.ifremer.coser.command.Command#undoCommand(fr.ifremer.coser.bean.Project)
+ */
+ @Override
+ public void undoCommand(Project project) throws CoserBusinessException {
+ throw new NotImplementedException("Merge operation can't be undone");
+
+ }
+
+ /**
+ * Fusion d'espece dans les données de captures.
+ *
+ * @param project project
+ * @param newSpecyName new specy name (after merge)
+ * @param speciesNames species name to merge
+ * @return project
+ */
+ protected Project mergeLength(Project project, String newSpecyName,
+ String... speciesNames) {
+ return project;
+ }
+
+ /**
+ * Fusion d'especes dans les données de taille.
+ *
+ * @param project project
+ * @param newSpecyName new specy name (after merge)
+ * @param speciesNames species name to merge
+ * @return project
+ */
+ protected Project mergeCatch(Project project, String newSpecyName,
+ String... speciesNames) {
+
+ // "Campagne","Annee","Trait","Espece","Nombre","Poids"
+
+ // regroupement par campagne/annee/trait
+ String lastCampagne = null;
+ String lastAnnee = null;
+ String lastTraits = null;
+ String[] tupleFound = null;
+ int tupleIndex = -1;
+
+ // parcours des elements
+ Iterator<String[]> itTuple = project.getCatch().iterator();
+ itTuple.next(); // skip header
+ int index = 1; // skip header
+ while (itTuple.hasNext()) {
+ String[] tuple = itTuple.next();
+
+ // si les valeurs servant au bornes de regroupement
+ // on changer, on reset les données du merge
+ String currentCampagne = tuple[Catch.INDEX_SURVEY];
+ String currentAnnee = tuple[Catch.INDEX_YEAR];
+ String currentTraits = tuple[Catch.INDEX_HAUL];
+ if (!currentCampagne.equals(lastCampagne) ||
+ !currentAnnee.equals(lastAnnee) ||
+ !currentTraits.equals(lastTraits)) {
+
+ tupleFound = null;
+ lastCampagne = currentCampagne;
+ lastAnnee = currentAnnee;
+ lastTraits = currentTraits;
+ }
+
+ // test si l'espece en cours fait partie de celle a merger
+ String species = tuple[Catch.INDEX_SPECIES];
+ boolean specyFound = false;
+ for (String specy : speciesNames) {
+ if (specy.equals(species)) {
+ specyFound = true;
+ }
+ }
+
+ // si l'espece est a merger, on se souvient du tuple
+ // principale a merge, ou on merge avec le tuple
+ // principal si on a deja un tuple principal
+ if (specyFound) {
+ if (tupleFound == null) {
+ tupleFound = tuple;
+ tupleFound[3] = newSpecyName;
+ tupleIndex = index;
+ }
+ else {
+ tupleFound = mergeCatches(tupleFound, tuple);
+ // et on supprime le tuple
+ // qui a ete merge
+ itTuple.remove();
+ // bidouille le remove decalle les index suivants
+ index--;
+ }
+
+ project.getCatch().set(tupleIndex, tupleFound);
+ }
+
+ index++;
+ }
+
+ return project;
+ }
+
+ /**
+ * Merge deux lines des catch.
+ *
+ * Le resultat est mergé dans {@code tuple1} et retourné.
+ *
+ * Somme les "Nombre" et "Poids"
+ *
+ * @param tuple1 tuple1
+ * @param tuple2 tuple2
+ * @return tuple1
+ */
+ protected String[] mergeCatches(String[] tuple1, String[] tuple2) {
+
+ // "Campagne","Annee","Trait","Espece","Nombre","Poids"
+
+ try {
+ double nombre1 = Double.parseDouble(tuple1[Catch.INDEX_NUMBER]);
+ double nombre2 = Double.parseDouble(tuple2[Catch.INDEX_NUMBER]);
+ double poids1 = Double.parseDouble(tuple1[Catch.INDEX_WEIGHT]);
+ double poids2 = Double.parseDouble(tuple2[Catch.INDEX_WEIGHT]);
+
+ tuple1[Catch.INDEX_NUMBER] = String.valueOf(nombre1 + nombre2);
+ tuple1[Catch.INDEX_WEIGHT] = String.valueOf(poids1 + poids2);
+ }
+ catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert data as double for merge", ex);
+ }
+ }
+ return tuple1;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,132 @@
+/*
+ * #%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.command;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.Catch;
+import fr.ifremer.coser.bean.Haul;
+import fr.ifremer.coser.bean.Length;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.bean.Strata;
+
+/**
+ * Command pattern object.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ModifyFieldCommand extends Command {
+
+ /** Category de données sur lequel porte l'action. */
+ protected Category category;
+
+ /** Line index of object to do command to. */
+ protected int line;
+
+ /** Field index to to command. */
+ protected int fieldIndex;
+
+ /** Field actual value. */
+ protected Object currentValue;
+
+ /** Field new value. */
+ protected Object newValue;
+
+ public Category getCategory() {
+ return category;
+ }
+
+ public void setCategory(Category category) {
+ this.category = category;
+ }
+
+ public int getLine() {
+ return line;
+ }
+
+ public void setLine(int line) {
+ this.line = line;
+ }
+
+ public int getFieldIndex() {
+ return fieldIndex;
+ }
+
+ public void setFieldIndex(int fieldIndex) {
+ this.fieldIndex = fieldIndex;
+ }
+
+ public Object getCurrentValue() {
+ return currentValue;
+ }
+
+ public void setCurrentValue(Object currentValue) {
+ this.currentValue = currentValue;
+ }
+
+ public Object getNewValue() {
+ return newValue;
+ }
+
+ public void setNewValue(Object newValue) {
+ this.newValue = newValue;
+ }
+
+ @Override
+ public void doCommand(Project project) throws CoserBusinessException {
+
+ }
+
+ @Override
+ public void undoCommand(Project project) throws CoserBusinessException {
+
+ }
+
+ @Override
+ public String toString() {
+ String toString = "Modify field ";
+ switch (category) {
+ case CATCH:
+ toString += Catch.EN_HEADERS[fieldIndex];
+ break;
+ case HAUL:
+ toString += Haul.EN_HEADERS[fieldIndex];
+ break;
+ case LENGTH:
+ toString += Length.EN_HEADERS[fieldIndex];
+ break;
+ case STRATA:
+ toString += Strata.EN_HEADERS[fieldIndex];
+ break;
+ }
+ toString += " on line " + line;
+ return toString;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,112 @@
+/*
+ * #%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 java.util.ListIterator;
+import java.util.UUID;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.coser.CoserBusinessConfig;
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.command.Command;
+
+/**
+ * Command service.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class CommandService {
+
+ private static final Log log = LogFactory.getLog(CommandService.class);
+
+ protected CoserBusinessConfig config;
+
+ public CommandService(CoserBusinessConfig config) {
+ this.config = config;
+ }
+
+ /**
+ * Generate new unique command UUID.
+ *
+ * @return unique command uuid
+ */
+ public String getUniqueCommandUUID() {
+ return UUID.randomUUID().toString();
+ }
+
+ /**
+ * Perform command on project. Save action on project history file.
+ *
+ * @param command command to perform
+ * @param project project
+ * @throws CoserBusinessException
+ */
+ public void doAction(Command command, Project project) throws CoserBusinessException {
+ if (log.isDebugEnabled()) {
+ log.debug("Do action " + command);
+ }
+
+ // si la commande n'a pas de UUID
+ if (command.getCommandUUID() == null) {
+ command.setCommandUUID(getUniqueCommandUUID());
+ }
+
+ command.doCommand(project);
+ project.getHistoryCommand().add(command);
+ }
+
+ /**
+ * Undo last command on project.
+ *
+ * @param project project
+ * @throws CoserBusinessException
+ */
+ public void undoAction(Project project) throws CoserBusinessException {
+
+ ListIterator<Command> itCommand = project.getHistoryCommand().listIterator(project.getHistoryCommand().size());
+
+ String lastUUID = null;
+ while (itCommand.hasPrevious()) {
+ Command command = itCommand.previous();
+
+ if (lastUUID != null && !lastUUID.equals(command.getCommandUUID())) {
+ break;
+ }
+ else {
+ command.undoCommand(project);
+ lastUUID = command.getCommandUUID();
+ itCommand.remove();
+ }
+ }
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -88,7 +88,7 @@
* @return project
* @throws CoserBusinessException
*/
- public Project loadCSVFile(Project project, Category category, File file, boolean originalLoading) throws CoserBusinessException {
+ public DataStorage loadCSVFile(Project project, Category category, File file, boolean originalLoading) throws CoserBusinessException {
DataStorage content = new MemoryListStorage();
@@ -127,8 +127,6 @@
content.add(line);
}
}
-
- addProjectContent(project, category, content);
} catch (FileNotFoundException ex) {
throw new CoserBusinessException("Can't read file", ex);
} catch (IOException ex) {
@@ -139,39 +137,10 @@
IOUtils.closeQuietly(reader);
}
- return project;
+ return content;
}
/**
- * Set content into project depending on category type.
- *
- * @param project project
- * @param category category
- * @param content content to set
- */
- protected void addProjectContent(Project project, Category category,
- DataStorage content) {
-
- switch (category) {
- case CATCH:
- project.setCatch(content);
- break;
- case HAUL:
- project.setHaul(content);
- break;
- case LENGTH:
- project.setLength(content);
- break;
- case STRATA:
- project.setStrata(content);
- break;
- case REFTAX_SPECIES:
- project.setRefTaxSpecies(content);
- break;
- }
- }
-
- /**
* Check csv file header names and order depending on file category.
*
* @param category
@@ -223,32 +192,43 @@
}
/**
- * Store project category data in specified file as csv.
+ * Get empty storage for category (filled with just header)
*
- * @param project project containing data
- * @param category category to save
- * @param file file to save to
- * @throws CoserBusinessException
+ * @param project project
+ * @param category category
+ * @return initialized storage
*/
- public void storeData(Project project, Category category, File file) throws CoserBusinessException {
+ public DataStorage getEmptyStorage(Project project, Category category) {
- // get project category content
- DataStorage content = null;
+ DataStorage dataStorage = new MemoryListStorage();
switch (category) {
case CATCH:
- content = project.getCatch();
+ dataStorage.add(Catch.EN_HEADERS);
break;
case HAUL:
- content = project.getHaul();
+ dataStorage.add(Haul.EN_HEADERS);
break;
case LENGTH:
- content = project.getLength();
+ dataStorage.add(Length.EN_HEADERS);
break;
case STRATA:
- content = project.getStrata();
+ dataStorage.add(Strata.EN_HEADERS);
break;
}
+ return dataStorage;
+ }
+
+ /**
+ * Store project category data in specified file as csv.
+ *
+ * @param project project containing data
+ * @param content content to save
+ * @param file file to save to
+ * @throws CoserBusinessException
+ */
+ public void storeData(Project project, DataStorage content, File file) throws CoserBusinessException {
+
// save content
Writer writer = null;
CSVWriter csvWriter = null;
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -50,6 +50,10 @@
import fr.ifremer.coser.bean.Haul;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Specy;
+import fr.ifremer.coser.command.Command;
+import fr.ifremer.coser.command.DeleteLineCommand;
+import fr.ifremer.coser.command.MergeSpeciesCommand;
+import fr.ifremer.coser.storage.DataStorage;
/**
* Service business method relative to project.
@@ -67,10 +71,13 @@
protected CoserBusinessConfig config;
protected ImportService importService;
+
+ protected CommandService commandService;
public ProjectService(CoserBusinessConfig config) {
this.config = config;
importService = new ImportService(config);
+ commandService = new CommandService(config);
}
/**
@@ -97,7 +104,7 @@
* @throws CoserBusinessException
*/
public Project loadProject(String projectName) throws CoserBusinessException {
-
+
// check project existence
File projectsDirectory = config.getProjectsDirectory();
File projectDirectory = new File(projectsDirectory, projectName);
@@ -112,15 +119,14 @@
int fileLoaded = 0;
for (Category category : Category.values()) {
- // les fichiers de data sont dans le dossier "original"
+ // seulement les category de données ici
if (category.isDataCategory()) {
- File inputFile = new File(controlDirectory,
- category.getStorageFileName() +
- CoserConstants.STORAGE_CONTROL_SUFFIX +
- CoserConstants.STORAGE_CSV_EXTENSION);
+ File inputFile = new File(controlDirectory, category.getStorageFileName() +
+ CoserConstants.STORAGE_CONTROL_SUFFIX + CoserConstants.STORAGE_CSV_EXTENSION);
if (inputFile.isFile()) {
- project = importService.loadCSVFile(project, category, inputFile, false);
+ DataStorage dataStorage = importService.loadCSVFile(project, category, inputFile, false);
+ addProjectContent(project, category, dataStorage, false);
fileLoaded++;
}
else {
@@ -128,6 +134,21 @@
log.debug("Can't find file " + inputFile);
}
}
+
+ // load deleted file if exists
+ inputFile = new File(controlDirectory, category.getStorageFileName() +
+ CoserConstants.STORAGE_DELECTED_SUFFIX + CoserConstants.STORAGE_CSV_EXTENSION);
+ DataStorage dataStorage = null;
+ if (inputFile.isFile()) {
+ dataStorage = importService.loadCSVFile(project, category, inputFile, false);
+ }
+ else {
+ dataStorage = importService.getEmptyStorage(project, category);
+ if (log.isDebugEnabled()) {
+ log.debug("Can't find file " + inputFile);
+ }
+ }
+ addProjectContent(project, category, dataStorage, true);
}
}
@@ -139,15 +160,21 @@
if (category.isDataCategory()) {
File storageDataFile = new File(originalDirectory,
category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION);
-
+
+ // main data
if (storageDataFile.isFile()) {
- project = importService.loadCSVFile(project, category, storageDataFile, true);
+ DataStorage dataStorage = importService.loadCSVFile(project, category, storageDataFile, true);
+ addProjectContent(project, category, dataStorage, false);
}
else {
// si on arrive ici et qu'un fichier original
// n'existe pas, c'est grave
throw new CoserBusinessException(_("Missing file %s", storageDataFile));
}
+
+ // deleted data
+ DataStorage dataStorage = importService.getEmptyStorage(project, category);
+ addProjectContent(project, category, dataStorage, true);
}
}
}
@@ -158,7 +185,8 @@
CoserConstants.STORAGE_CSV_EXTENSION);
if (inputFile.isFile()) {
- project = importService.loadCSVFile(project, Category.REFTAX_SPECIES, inputFile, true);
+ DataStorage dataStorage = importService.loadCSVFile(project, Category.REFTAX_SPECIES, inputFile, true);
+ addProjectContent(project, Category.REFTAX_SPECIES, dataStorage, false);
}
else {
// si on arrive ici et qu'un fichier original
@@ -166,10 +194,63 @@
throw new CoserBusinessException(_("Missing file %s", inputFile));
}
+ // init des autres resources du projet
+ project.setHistoryCommand(new ArrayList<Command>());
+
return project;
}
/**
+ * Set content into project depending on category type.
+ *
+ * @param project project
+ * @param category category
+ * @param content content to set
+ * @param deletedContent if content means deleted objects for {@code category}
+ */
+ protected void addProjectContent(Project project, Category category,
+ DataStorage content, boolean deletedContent) {
+
+ switch (category) {
+ case CATCH:
+ if (!deletedContent) {
+ project.setCatch(content);
+ }
+ else {
+ project.setDeletedCatch(content);
+ }
+ break;
+ case HAUL:
+ if (!deletedContent) {
+ project.setHaul(content);
+ }
+ else {
+ project.setDeletedHaul(content);
+ }
+ break;
+ case LENGTH:
+ if (!deletedContent) {
+ project.setLength(content);
+ }
+ else {
+ project.setDeletedLength(content);
+ }
+ break;
+ case STRATA:
+ if (!deletedContent) {
+ project.setStrata(content);
+ }
+ else {
+ project.setDeletedStrata(content);
+ }
+ break;
+ case REFTAX_SPECIES:
+ project.setRefTaxSpecies(content);
+ break;
+ }
+ }
+
+ /**
* Create new project.
*
* Do (ordered):
@@ -202,7 +283,14 @@
for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) {
Category category = categoryAndFile.getKey();
File dataFile = categoryAndFile.getValue();
- project = importService.loadCSVFile(project, category, dataFile, true);
+ DataStorage dataStorage = importService.loadCSVFile(project, category, dataFile, true);
+ addProjectContent(project, category, dataStorage, false);
+
+ if (category.isDataCategory()) {
+ // deleted data
+ DataStorage dataStorage2 = importService.getEmptyStorage(project, category);
+ addProjectContent(project, category, dataStorage2, true);
+ }
}
// create new project directory
@@ -242,6 +330,9 @@
}
}
+ // init des autres resources du projet
+ project.setHistoryCommand(new ArrayList<Command>());
+
return project;
}
@@ -263,6 +354,8 @@
controlDirectory.mkdirs();
for (Category category : Category.values()) {
if (category.isDataCategory()) {
+
+ // save main content
File controlFile = new File(controlDirectory,
category.getStorageFileName() +
CoserConstants.STORAGE_CONTROL_SUFFIX +
@@ -270,12 +363,77 @@
if (log.isDebugEnabled()) {
log.debug("Saving control file : " + controlFile);
}
- importService.storeData(project, category, controlFile);
+ DataStorage content = getProjectContent(project, category, false);
+ importService.storeData(project, content, controlFile);
+
+ // save deleted content (if needed)
+ DataStorage contentDeleted = getProjectContent(project, category, true);
+ // if more content than header
+ if (contentDeleted.size() > 1) {
+ File deletedDataFile = new File(controlDirectory,
+ category.getStorageFileName() +
+ CoserConstants.STORAGE_DELECTED_SUFFIX +
+ CoserConstants.STORAGE_CSV_EXTENSION);
+ importService.storeData(project, contentDeleted, deletedDataFile);
+ }
}
}
}
/**
+ * Set content into project depending on category type.
+ *
+ * @param project project
+ * @param category category
+ * @param content content to set
+ * @param deletedContent if content means deleted objects for {@code category}
+ */
+ protected DataStorage getProjectContent(Project project, Category category, boolean deletedContent) {
+
+ DataStorage content = null;
+
+ switch (category) {
+ case CATCH:
+ if (!deletedContent) {
+ content = project.getCatch();
+ }
+ else {
+ content = project.getDeletedCatch();
+ }
+ break;
+ case HAUL:
+ if (!deletedContent) {
+ content = project.getHaul();
+ }
+ else {
+ content = project.getDeletedHaul();
+ }
+ break;
+ case LENGTH:
+ if (!deletedContent) {
+ content = project.getLength();
+ }
+ else {
+ content = project.getDeletedLength();
+ }
+ break;
+ case STRATA:
+ if (!deletedContent) {
+ content = project.getStrata();
+ }
+ else {
+ content = project.getDeletedStrata();
+ }
+ break;
+ case REFTAX_SPECIES:
+ project.setRefTaxSpecies(content);
+ break;
+ }
+
+ return content;
+ }
+
+ /**
* Save project selection.
*
* @param project project to save selection
@@ -304,7 +462,9 @@
if (log.isDebugEnabled()) {
log.debug("Saving selection file : " + controlFile);
}
- importService.storeData(project, category, controlFile);
+
+ DataStorage content = getProjectContent(project, category, false);
+ importService.storeData(project, content, controlFile);
}
}
@@ -457,131 +617,28 @@
throw new CoserBusinessException(_("Specy %s doesn't exist in referential", newSpecyName));
}
- project = mergeCatch(project, newSpecyName, speciesNames);
- project = mergeLength(project, newSpecyName, speciesNames);
- return project;
- }
+ MergeSpeciesCommand command = new MergeSpeciesCommand();
+ command.setNewSpecyName(newSpecyName);
+ command.setSpeciesNames(speciesNames);
+ commandService.doAction(command, project);
- /**
- * Fusion d'espece dans les données de captures.
- *
- * @param project project
- * @param newSpecyName new specy name (after merge)
- * @param speciesNames species name to merge
- * @return project
- */
- protected Project mergeLength(Project project, String newSpecyName,
- String... speciesNames) {
return project;
}
/**
- * Fusion d'especes dans les données de taille.
+ * Supprime une données via son index.
*
* @param project project
- * @param newSpecyName new specy name (after merge)
- * @param speciesNames species name to merge
- * @return project
+ * @param category category
+ * @param index index to delete
+ * @throws CoserBusinessException
*/
- protected Project mergeCatch(Project project, String newSpecyName,
- String... speciesNames) {
-
- // "Campagne","Annee","Trait","Espece","Nombre","Poids"
+ public void deleteData(Project project, Category category, String index) throws CoserBusinessException {
- // regroupement par campagne/annee/trait
- String lastCampagne = null;
- String lastAnnee = null;
- String lastTraits = null;
- String[] tupleFound = null;
- int tupleIndex = -1;
-
- // parcours des elements
- Iterator<String[]> itTuple = project.getCatch().iterator();
- itTuple.next(); // skip header
- int index = 1; // skip header
- while (itTuple.hasNext()) {
- String[] tuple = itTuple.next();
-
- // si les valeurs servant au bornes de regroupement
- // on changer, on reset les données du merge
- String currentCampagne = tuple[Catch.INDEX_SURVEY];
- String currentAnnee = tuple[Catch.INDEX_YEAR];
- String currentTraits = tuple[Catch.INDEX_HAUL];
- if (!currentCampagne.equals(lastCampagne) ||
- !currentAnnee.equals(lastAnnee) ||
- !currentTraits.equals(lastTraits)) {
-
- tupleFound = null;
- lastCampagne = currentCampagne;
- lastAnnee = currentAnnee;
- lastTraits = currentTraits;
- }
-
- // test si l'espece en cours fait partie de celle a merger
- String species = tuple[Catch.INDEX_SPECIES];
- boolean specyFound = false;
- for (String specy : speciesNames) {
- if (specy.equals(species)) {
- specyFound = true;
- }
- }
-
- // si l'espece est a merger, on se souvient du tuple
- // principale a merge, ou on merge avec le tuple
- // principal si on a deja un tuple principal
- if (specyFound) {
- if (tupleFound == null) {
- tupleFound = tuple;
- tupleFound[3] = newSpecyName;
- tupleIndex = index;
- }
- else {
- tupleFound = mergeCatches(tupleFound, tuple);
- // et on supprime le tuple
- // qui a ete merge
- itTuple.remove();
- // bidouille le remove decalle les index suivants
- index--;
- }
-
- project.getCatch().set(tupleIndex, tupleFound);
- }
-
- index++;
- }
-
- return project;
+ // create new delete action
+ DeleteLineCommand command = new DeleteLineCommand();
+ command.setCategory(category);
+ command.setLineIndex(index);
+ commandService.doAction(command, project);
}
-
- /**
- * Merge deux lines des catch.
- *
- * Le resultat est mergé dans {@code tuple1} et retourné.
- *
- * Somme les "Nombre" et "Poids"
- *
- * @param tuple1 tuple1
- * @param tuple2 tuple2
- * @return tuple1
- */
- protected String[] mergeCatches(String[] tuple1, String[] tuple2) {
-
- // "Campagne","Annee","Trait","Espece","Nombre","Poids"
-
- try {
- double nombre1 = Double.parseDouble(tuple1[Catch.INDEX_NUMBER]);
- double nombre2 = Double.parseDouble(tuple2[Catch.INDEX_NUMBER]);
- double poids1 = Double.parseDouble(tuple1[Catch.INDEX_WEIGHT]);
- double poids2 = Double.parseDouble(tuple2[Catch.INDEX_WEIGHT]);
-
- tuple1[Catch.INDEX_NUMBER] = String.valueOf(nombre1 + nombre2);
- tuple1[Catch.INDEX_WEIGHT] = String.valueOf(poids1 + poids2);
- }
- catch (NumberFormatException ex) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert data as double for merge", ex);
- }
- }
- return tuple1;
- }
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/storage/DataStorage.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -47,6 +47,14 @@
* @param data data to add
*/
void add(String[] data);
+
+ /**
+ * Add new data into storage.
+ *
+ * @param index index to insert data
+ * @param data data to add
+ */
+ void add(int index, String[] data);
/**
* Get data at specified index.
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryListStorage.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryListStorage.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryListStorage.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -109,6 +109,16 @@
String stringData = arrayToString(data);
internalStorage.add(stringData);
}
+
+ /*
+ * @see fr.ifremer.coser.storage.DataStorage#addData(java.lang.String[])
+ */
+ @Override
+ public void add(int index, String[] data) {
+
+ String stringData = arrayToString(data);
+ internalStorage.add(index, stringData);
+ }
protected String arrayToString(String[] data) {
StringWriter writer = new StringWriter();
@@ -164,4 +174,9 @@
String[] oldArray = stringToArray(old);
return oldArray;
}
+
+ @Override
+ public String toString() {
+ return internalStorage.toString();
+ }
}
Added: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
===================================================================
--- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java (rev 0)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,114 @@
+/*
+ * #%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 junit.framework.Assert;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import fr.ifremer.coser.CoserBusinessException;
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.command.DeleteLineCommand;
+
+/**
+ * CommandService tests
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class CommandServiceTest extends CoserTestAbstract {
+
+ protected CommandService commandService;
+ protected ProjectService projectService;
+
+ @Before
+ public void initService() {
+ projectService = new ProjectService(config);
+ commandService = new CommandService(config);
+ }
+
+ /**
+ * Test la suppression correcte d'une ligne.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testDeleteLine() throws CoserBusinessException {
+ Project project = createTestProject(projectService);
+ Assert.assertEquals(29, project.getLength().size());
+
+ DeleteLineCommand command = new DeleteLineCommand();
+ command.setLineIndex("2");
+ command.setCategory(Category.LENGTH);
+
+ commandService.doAction(command, project);
+ Assert.assertEquals(28, project.getLength().size());
+ }
+
+ /**
+ * Test la suppression incorrecte d'une ligne.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test(expected=CoserBusinessException.class)
+ public void testDeleteLineWrong() throws CoserBusinessException {
+ Project project = createTestProject(projectService);
+ DeleteLineCommand command = new DeleteLineCommand();
+ command.setLineIndex("2");
+ command.setCategory(Category.LENGTH);
+ commandService.doAction(command, project);
+ commandService.doAction(command, project);
+ }
+
+ /**
+ * Test la suppression correcte d'une ligne puis le rétablissement
+ * de la ligne supprimée.
+ *
+ * @throws CoserBusinessException
+ */
+ @Test
+ public void testDeleteLineUndo() throws CoserBusinessException {
+ Project project = createTestProject(projectService);
+ Assert.assertEquals("3", project.getLength().get(4)[0]);
+
+ DeleteLineCommand command = new DeleteLineCommand();
+ command.setLineIndex("3");
+ command.setCategory(Category.LENGTH);
+
+ commandService.doAction(command, project);
+ System.out.println(project.getLength());
+ Assert.assertEquals("4", project.getLength().get(4)[0]);
+ commandService.undoAction(project);
+ System.out.println("\n" + project.getLength());
+ Assert.assertEquals("3", project.getLength().get(4)[0]);
+
+ }
+}
Property changes on: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
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-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -31,6 +31,8 @@
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;
import org.junit.BeforeClass;
@@ -50,6 +52,8 @@
*/
public abstract class CoserTestAbstract {
+ private static final Log log = LogFactory.getLog(CoserTestAbstract.class);
+
protected static CoserBusinessConfig config;
protected static File testDirectory;
@@ -67,7 +71,7 @@
@AfterClass
public static void cleanDirectory() throws IOException {
- FileUtils.deleteDirectory(testDirectory);
+ //FileUtils.deleteDirectory(testDirectory);
}
protected Project createTestProject(ProjectService service) throws CoserBusinessException {
@@ -89,6 +93,10 @@
categoriesAndFile.put(Category.REFTAX_SPECIES, testReftax);
project = service.createProject(project, categoriesAndFile);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Created project : " + project.getName());
+ }
return project;
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -103,15 +103,12 @@
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
- Object result = null;
+ Object result = getDataAt(rowIndex)[columnIndex];
- if (columnIndex == 0) {
- result = rowIndex + 1;
- }
- else {
- result = data.get(rowIndex + 1)[columnIndex];
- }
-
return result;
}
+
+ public String[] getDataAt(int rowIndex) {
+ return data.get(rowIndex + 1);
+ }
}
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlFindReplaceDialog.jaxx 2010-10-26 13:59:58 UTC (rev 103)
@@ -0,0 +1,53 @@
+<!--
+ #%L
+ Coser :: UI
+
+ $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%
+ -->
+<JDialog title="coser.ui.control.replace.title" modal="true">
+ <ControlHandler id="handler" javaBean="null" />
+ <Table>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="coser.ui.control.replace.find" />
+ </cell>
+ <cell weightx="1" fill="horizontal">
+ <JTextField id="replaceFindField" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="coser.ui.control.replace.replace" />
+ </cell>
+ <cell weightx="2" weighty="1" fill="both" columns="3">
+ <JTextField id="replaceReplaceField" />
+ </cell>
+ </row>
+ <row>
+ <cell columns="4" anchor="east" insets="0">
+ <JPanel>
+ <JButton text="coser.ui.common.cancel" onActionPerformed="dispose()"/>
+ <JButton text="coser.ui.common.valid" onActionPerformed="getHandler().performFindAndReplace(this)" />
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
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-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-10-26 13:59:58 UTC (rev 103)
@@ -30,13 +30,17 @@
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
import java.io.File;
import java.io.IOException;
import java.util.List;
import javax.swing.JLabel;
+import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
+import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.JViewport;
@@ -44,6 +48,7 @@
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
+import javax.swing.table.TableColumnModel;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.validator.swing.SwingValidator;
@@ -91,6 +96,51 @@
}
/**
+ * Affiche le menu contextuel de la table qui contient les données.
+ *
+ * @param view view
+ * @param event mouse event
+ */
+ public void showDataTableContextMenu(final ControlView view, MouseEvent event) {
+
+ // clic contextuel
+ if (event.getButton() == MouseEvent.BUTTON3) {
+ int[] dataSelectedRows = view.getControlDataTable().getSelectedRows();
+ int columnIndex = view.getControlDataTable().getColumnModel().getColumnIndexAtX(event.getX());
+
+ // plusieurs lignes selectionnées et pas la premiere colonne (Line index)
+ if (dataSelectedRows.length > 0 && columnIndex > 0) {
+ String columnName = view.getControlDataTable().getColumnName(columnIndex);
+ JPopupMenu popupMenu = new JPopupMenu(_("coser.ui.control.dataMenuLabel"));
+ JMenuItem replaceMenu = new JMenuItem(_("coser.ui.control.dataMenuReplace", columnName));
+ replaceMenu.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ ControlFindReplaceDialog viewDialog = new ControlFindReplaceDialog(view);
+ viewDialog.setLocationRelativeTo(view);
+ viewDialog.setVisible(true);
+ }
+ });
+ popupMenu.add(replaceMenu);
+ popupMenu.show(view.getControlDataTable(), event.getX(), event.getY());
+ }
+ }
+ }
+
+ /**
+ * Perform find and replace.
+ *
+ * @param view parent view
+ */
+ public void performFindAndReplace(ControlFindReplaceDialog view) {
+ String find = view.getReplaceFindField().getText();
+ String replace = view.getReplaceReplaceField().getText();
+ if (log.isWarnEnabled()) {
+ log.warn("Perform : " + find + " replace with " + replace);
+ }
+ }
+
+ /**
* Check project.
*
* @param view
@@ -323,7 +373,16 @@
validator.installUIs();
validator.reloadBean();
+
+ view.getControlDataValidButton().setEnabled(true);
+ view.getControlDataCancelButton().setEnabled(true);
+ view.getControlDataDeleteButton().setEnabled(true);
}
+ else {
+ view.getControlDataValidButton().setEnabled(false);
+ view.getControlDataCancelButton().setEnabled(false);
+ view.getControlDataDeleteButton().setEnabled(false);
+ }
view.getEditionScrollPane().repaint();
view.getEditionScrollPane().validate();
}
@@ -423,33 +482,25 @@
public void deleteData(ControlView view) {
int response = JOptionPane.showConfirmDialog(view, _("coser.ui.control.confirmDeletionMessage"),
_("coser.ui.control.confirmDeletionTitle"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
-
+
if (response == JOptionPane.YES_OPTION) {
Project project = view.getContextValue(Project.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+
+ // get selected row, and selected csv line index
JTable controlDataTable = view.getControlDataTable();
ControlDataTableModel model = (ControlDataTableModel)controlDataTable.getModel();
int selectedLine = controlDataTable.getSelectedRow();
Category category = (Category)view.getCategoryComboBox().getSelectedItem();
-
- // get data
- switch (category) {
- case CATCH:
- project.getCatch().remove(selectedLine + 1); // csv header
+ String[] data = model.getDataAt(selectedLine);
+
+ try {
+ projectService.deleteData(project, category, data[AbstractDataEntity.INDEX_LINE]);
model.fireTableRowsDeleted(selectedLine, selectedLine);
- break;
- case HAUL:
- project.getHaul().remove(selectedLine + 1); // csv header
- model.fireTableRowsDeleted(selectedLine, selectedLine);
- break;
- case LENGTH:
- project.getLength().remove(selectedLine + 1); // csv header
- model.fireTableRowsDeleted(selectedLine, selectedLine);
- break;
- case STRATA:
- project.getCatch().remove(selectedLine + 1); // csv header
- model.fireTableRowsDeleted(selectedLine, selectedLine);
- break;
}
+ catch (CoserBusinessException ex) {
+ throw new CoserException("Can't delete data", ex);
+ }
}
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-10-26 13:59:58 UTC (rev 103)
@@ -46,7 +46,8 @@
<row>
<cell fill="both" weightx="1" weighty="2" columns="2">
<JScrollPane>
- <JTable id='controlDataTable' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this)}" />
+ <JTable id='controlDataTable' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this)}"
+ onMouseClicked="getHandler().showDataTableContextMenu(this, event)"/>
<ListSelectionModel id="controlDataTableSelectionModel" javaBean="controlDataTable.getSelectionModel()"
onValueChanged="getHandler().controlDataTableSelectionChanged(this, event)" />
</JScrollPane>
@@ -63,16 +64,19 @@
</row>
<row>
<cell weightx="1" anchor="east">
- <JButton text="coser.ui.common.valid"
- onActionPerformed="getHandler().validDataModification(this)" />
+ <JButton id="controlDataValidButton" text="coser.ui.common.valid"
+ onActionPerformed="getHandler().validDataModification(this)"
+ enabled="false" />
</cell>
<cell>
- <JButton text="coser.ui.common.cancel"
- onActionPerformed="getHandler().cancelDataModification(this)" />
+ <JButton id="controlDataCancelButton" text="coser.ui.common.cancel"
+ onActionPerformed="getHandler().cancelDataModification(this)"
+ enabled="false" />
</cell>
<cell>
- <JButton text="coser.ui.common.delete"
- onActionPerformed="getHandler().deleteData(this)" />
+ <JButton id="controlDataDeleteButton" text="coser.ui.common.delete"
+ onActionPerformed="getHandler().deleteData(this)"
+ enabled="false" />
</cell>
</row>
</Table>
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-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-10-26 13:59:58 UTC (rev 103)
@@ -57,7 +57,7 @@
<row>
<cell />
<cell />
- <cell fill="horizontal" insets="0" columns="2">
+ <cell fill="horizontal" insets="0" columns="2" anchor="west">
<JPanel>
<JLabel text="coser.ui.selection.filter.occurrence" />
<JTextField id="selectionFilterOccurrenceField" columns="3" text="5" />
@@ -66,7 +66,12 @@
<JButton text="coser.ui.selection.filter.filter" />
</JPanel>
</cell>
- <cell columns="4"/>
+ <cell columns="2">
+ <JButton icon="chart_bar.png" />
+ </cell>
+ <cell columns="2">
+ <JButton icon="chart_bar.png" />
+ </cell>
</row>
<row>
<cell weighty="1" weightx="1" fill="both" columns="2">
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionResultView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionResultView.jaxx 2010-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionResultView.jaxx 2010-10-26 13:59:58 UTC (rev 103)
@@ -24,12 +24,44 @@
-->
<Table>
<SelectionHandler id="handler" javaBean="null" />
-
<row>
- <cell weightx="1" weighty="1" fill="both">
- <JScrollPane>
- <JTable model="{new fr.ifremer.coser.ui.result.ResultTableModel()}"/>
- </JScrollPane>
+ <cell weightx="1" fill="horizontal">
+ <Table border='{BorderFactory.createTitledBorder(_("coser.ui.result.extractDataTitle"))}'>
+ <row>
+ <cell>
+ <JLabel text="coser.ui.result.extractDataLabel" />
+ </cell>
+ <cell weightx="1" fill="horizontal">
+ <JTextField id="resultExtractDataField" />
+ </cell>
+ <cell>
+ <JButton text="coser.ui.common.selectFile" />
+ </cell>
+ </row>
+ <row>
+ <cell columns="3">
+ <JButton text="coser.ui.result.extractDataButton" />
+ </cell>
+ </row>
+ </Table>
</cell>
</row>
+ <row>
+ <cell weightx="1" weighty="2" fill="both">
+ <Table border='{BorderFactory.createTitledBorder(_("coser.ui.result.availableDataTitle"))}'>
+ <row>
+ <cell weightx="1" weighty="1" fill="both">
+ <JScrollPane>
+ <JTable model="{new fr.ifremer.coser.ui.result.ResultTableModel()}"/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row>
+ <cell>
+
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
</Table>
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-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-10-26 13:59:58 UTC (rev 103)
@@ -1,7 +1,3 @@
-Name=
-Selection\ 1=
-Selection\ 2=
-Selection\ 3=
coser.config.application.version.description=Application's version
coser.config.category.main=
coser.config.category.main.description=
@@ -13,7 +9,7 @@
coser.config.reference.zones.description=
coser.config.support.email.description=Support email address
coser.config.validator.directory.description=
-coser.ui.common.cancel=
+coser.ui.common.cancel=Cancel
coser.ui.common.comment=Comment
coser.ui.common.delete=
coser.ui.common.selectAll=
@@ -23,10 +19,15 @@
coser.ui.config.title=
coser.ui.control.confirmDeletionMessage=
coser.ui.control.confirmDeletionTitle=
+coser.ui.control.dataMenuLabel=
+coser.ui.control.dataMenuReplace=
coser.ui.control.global.field=
coser.ui.control.global.level=
coser.ui.control.global.message=
coser.ui.control.graphtitle=Graph
+coser.ui.control.replace.find=
+coser.ui.control.replace.replace=
+coser.ui.control.replace.title=
coser.ui.control.save=
coser.ui.error.htmlmessage=An error occurs \: %s
coser.ui.error.title=Global application error
@@ -62,6 +63,9 @@
coser.ui.project.traitsFile=Traits file \:
coser.ui.project.useCustomReferenceSpeciesFile=
coser.ui.project.usedReferenceSpeciesFile=
+coser.ui.result.extractDataButton=
+coser.ui.result.extractDataLabel=
+coser.ui.result.extractDataTitle=
coser.ui.selection.allSpecies=All species
coser.ui.selection.details.beginDate=
coser.ui.selection.details.createSelection=
@@ -74,9 +78,9 @@
coser.ui.selection.details.species=
coser.ui.selection.details.technicalComment=
coser.ui.selection.details.zone=
-coser.ui.selection.filter.density=X\:
+coser.ui.selection.filter.density=Density \:
coser.ui.selection.filter.filter=Filter
-coser.ui.selection.filter.occurrence=Y\:
+coser.ui.selection.filter.occurrence=Occurrence \:
coser.ui.selection.fusion.comment=
coser.ui.selection.fusion.description=
coser.ui.selection.fusion.name=
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-10-26 08:53:49 UTC (rev 102)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui-fr_FR.properties 2010-10-26 13:59:58 UTC (rev 103)
@@ -1,7 +1,3 @@
-Name=
-Selection\ 1=
-Selection\ 2=
-Selection\ 3=
coser.config.application.version.description=Version de l'application
coser.config.category.main=Coser
coser.config.category.main.description=Configuration principale
@@ -19,12 +15,17 @@
coser.ui.config.title=Configuration
coser.ui.control.confirmDeletionMessage=\u00CAtes vous s\u00FBr de vouloir supprimer cette donn\u00E9e ?
coser.ui.control.confirmDeletionTitle=Confirmation de suppression
+coser.ui.control.dataMenuLabel=Menu table des donn\u00E9es
+coser.ui.control.dataMenuReplace=Remplacer dans %s
coser.ui.control.global.field=Champ
coser.ui.control.global.level=Type
coser.ui.control.global.message=Message
coser.ui.control.graphtitle=Graphique
+coser.ui.control.replace.find=Chercher \:
+coser.ui.control.replace.replace=Remplacer \:
+coser.ui.control.replace.title=Chercher et remplacer
coser.ui.control.save=Sauvegarder
-coser.ui.error.htmlmessage=Une erreur s'est produite\u2009\:\u2009%s
+coser.ui.error.htmlmessage=Une erreur s'est produite \: %s
coser.ui.error.title=Erreur globale
coser.ui.mainframe.menu.configuration=Configuration
coser.ui.mainframe.menu.file=Fichier
@@ -42,38 +43,42 @@
coser.ui.mainframe.menu.window.selection=S\u00E9lection
coser.ui.mainframe.menu.window.validation=Validation
coser.ui.mainview.title=Contr\u00F4le et S\u00E9lection RSufi
-coser.ui.project.captureFile=Fichier de captures\u2009\:
+coser.ui.project.captureFile=Fichier de captures \:
coser.ui.project.createProject=Cr\u00E9er le projet
coser.ui.project.creationError=Erreur de cr\u00E9ation
-coser.ui.project.customReferenceSpeciesFile=Nouveau fichier de r\u00E9f\u00E9rence\u2009\:
-coser.ui.project.lengthFile=Fichiers des tailles\u2009\:
+coser.ui.project.customReferenceSpeciesFile=Nouveau fichier de r\u00E9f\u00E9rence \:
+coser.ui.project.lengthFile=Fichiers des tailles \:
coser.ui.project.newProject=Nouveau projet
coser.ui.project.openError=Erreur d'ouverture
coser.ui.project.openProject=Ouvrir
coser.ui.project.openProjectTitle=Ouvrir un projet existant
-coser.ui.project.project=Projet\u2009\:
-coser.ui.project.projectname=Nom du projet\u2009\:
-coser.ui.project.stratesFile=Fichiers des strates\u2009\:
-coser.ui.project.traitsFile=Fichiers des traits\u2009\:
+coser.ui.project.project=Projet \:
+coser.ui.project.projectname=Nom du projet \:
+coser.ui.project.stratesFile=Fichiers des strates \:
+coser.ui.project.traitsFile=Fichiers des traits \:
coser.ui.project.useCustomReferenceSpeciesFile=Utiliser un autre fichier de r\u00E9f\u00E9rence
-coser.ui.project.usedReferenceSpeciesFile=Fichier de r\u00E9f\u00E9rence utilis\u00E9\u2009\:
+coser.ui.project.usedReferenceSpeciesFile=Fichier de r\u00E9f\u00E9rence utilis\u00E9 \:
+coser.ui.result.availableDataTitle=R\u00E9sultats disponibles \:
+coser.ui.result.extractDataButton=Extraire
+coser.ui.result.extractDataLabel=Dossier d'extraction \:
+coser.ui.result.extractDataTitle=Extraction des donn\u00E9es d'entr\u00E9e de RSufi
coser.ui.selection.allSpecies=Toutes les esp\u00E8ces
-coser.ui.selection.details.beginDate=Date de d\u00E9but\u2009\:
-coser.ui.selection.details.endDate=Date de fin\u2009\:
-coser.ui.selection.details.family=Filtrer par famille\u2009\:
-coser.ui.selection.details.gender=Filtrer par genre\u2009\:
-coser.ui.selection.details.name=Nom de la s\u00E9lection\u2009\:
+coser.ui.selection.details.beginDate=Date de d\u00E9but \:
+coser.ui.selection.details.endDate=Date de fin \:
+coser.ui.selection.details.family=Filtrer par famille \:
+coser.ui.selection.details.gender=Filtrer par genre \:
+coser.ui.selection.details.name=Nom de la s\u00E9lection \:
coser.ui.selection.details.otherComment=Autre commentaire
coser.ui.selection.details.saveSelection=Sauvegarder la s\u00E9lection
-coser.ui.selection.details.species=Esp\u00E8ces\u2009\:
+coser.ui.selection.details.species=Esp\u00E8ces \:
coser.ui.selection.details.technicalComment=Commentaire technique
-coser.ui.selection.details.zone=Zone\u2009\:
-coser.ui.selection.filter.density=Densit\u00E9\u2009\:
+coser.ui.selection.details.zone=Zone \:
+coser.ui.selection.filter.density=Densit\u00E9 \:
coser.ui.selection.filter.filter=Filtrer
-coser.ui.selection.filter.occurrence=Occurence\u2009\:
+coser.ui.selection.filter.occurrence=Occurence \:
coser.ui.selection.fusion.comment=Commentaire
coser.ui.selection.fusion.description=Fusion de deux esp\u00E8ces. Veuillez renseigner un nouveau nom pr\u00E9sent dans le r\u00E9f\u00E9rentiel.
-coser.ui.selection.fusion.name=Nouveau nom\u2009\:
+coser.ui.selection.fusion.name=Nouveau nom \:
coser.ui.selection.fusion.title=Fusion
coser.ui.selection.fusionError=Erreur de fusion
coser.ui.selection.invalidFusionName=Le nom de fusion choisit n'est pas pr\u00E9sent de le r\u00E9f\u00E9rentiel \!
@@ -94,4 +99,4 @@
coser.ui.validators.newValidator=Nouveau validateur
coser.ui.validators.title=Validateurs
coser.ui.validators.valid=Valider
-coser.ui.validators.validators=Validateurs\u2009\:
+coser.ui.validators.validators=Validateurs \:
1
0
r102 - trunk/coser-business/src/main/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 26 Oct '10
by chatellier@users.labs.libre-entreprise.org 26 Oct '10
26 Oct '10
Author: chatellier
Date: 2010-10-26 08:53:49 +0000 (Tue, 26 Oct 2010)
New Revision: 102
Log:
Use close (closeable) from commons-io 2.0
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-25 16:22:54 UTC (rev 101)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-26 08:53:49 UTC (rev 102)
@@ -135,13 +135,7 @@
throw new CoserBusinessException("Can't read file", ex);
}
finally {
- if (csvReader != null) {
- try {
- csvReader.close();
- } catch (IOException ex) {
- throw new CoserBusinessException("Can't close file", ex);
- }
- }
+ IOUtils.closeQuietly(csvReader);
IOUtils.closeQuietly(reader);
}
@@ -270,13 +264,7 @@
throw new CoserBusinessException("Can't save data", ex);
}
finally {
- if (csvWriter != null) {
- try {
- csvWriter.close();
- } catch (IOException ex) {
- throw new CoserBusinessException("Can't close file", ex);
- }
- }
+ IOUtils.closeQuietly(csvWriter);
IOUtils.closeQuietly(writer);
}
}
1
0
r101 - in trunk/coser-business/src: main/java/fr/ifremer/coser/validators main/resources/fr/ifremer/coser/bean test/java/fr/ifremer/coser/services
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
25 Oct '10
Author: chatellier
Date: 2010-10-25 16:22:54 +0000 (Mon, 25 Oct 2010)
New Revision: 101
Log:
Manage NA as valid double value
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java
trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Catch-error-validation.xml
trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Length-error-validation.xml
trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java 2010-10-25 15:44:33 UTC (rev 100)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/validators/CoserCheckDoubleValidator.java 2010-10-25 16:22:54 UTC (rev 101)
@@ -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
@@ -29,7 +29,7 @@
import com.opensymphony.xwork2.validator.validators.FieldValidatorSupport;
/**
- * TODO add comment here.
+ * Validateur de double de coser.
*
* @author chatellier
* @version $Revision$
@@ -39,25 +39,16 @@
*/
public class CoserCheckDoubleValidator extends FieldValidatorSupport {
- protected Double max = null;
- protected Double min = null;
+ protected String notAvailable;
- public void setMax(Double max) {
- this.max = max;
+ public String getNotAvailable() {
+ return notAvailable;
}
- public Double getMax() {
- return max;
+ public void setNotAvailable(String notAvailable) {
+ this.notAvailable = notAvailable;
}
- public void setMin(Double min) {
- this.min = min;
- }
-
- public Double getMin() {
- return min;
- }
-
public void validate(Object object) throws ValidationException {
Object obj = getFieldValue(getFieldName(), object);
String value = (String) obj;
@@ -68,22 +59,16 @@
return;
}
- double doubleValue = 0;
+ // If NA value = object it's ok too
+ if (notAvailable != null && notAvailable.equals(value)) {
+ return;
+ }
+
try {
- doubleValue = Double.parseDouble(value);
+ Double.parseDouble(value);
}
catch (NumberFormatException ex) {
addFieldError(getFieldName(), object);
}
-
- // only check for a minimum value if the min parameter is set
- if (min != null && doubleValue < min) {
- addFieldError(getFieldName(), object);
- }
-
- // only check for a maximum value if the max parameter is set
- if (max != null && doubleValue > max) {
- addFieldError(getFieldName(), object);
- }
}
}
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Catch-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Catch-error-validation.xml 2010-10-25 15:44:33 UTC (rev 100)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Catch-error-validation.xml 2010-10-25 16:22:54 UTC (rev 101)
@@ -52,11 +52,13 @@
</field>
<field name="number">
<field-validator type="checkDouble" short-circuit="true">
+ <param name="notAvailable">NA</param>
<message>Number attribute is not a valid double</message>
</field-validator>
</field>
<field name="weight">
<field-validator type="checkDouble" short-circuit="true">
+ <param name="notAvailable">NA</param>
<message>Weight attribute is not a valid double</message>
</field-validator>
</field>
Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Length-error-validation.xml
===================================================================
--- trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Length-error-validation.xml 2010-10-25 15:44:33 UTC (rev 100)
+++ trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Length-error-validation.xml 2010-10-25 16:22:54 UTC (rev 101)
@@ -67,11 +67,13 @@
</field>
<field name="number">
<field-validator type="checkDouble" short-circuit="true">
+ <param name="notAvailable">NA</param>
<message>number attribute is not a valid double</message>
</field-validator>
</field>
<field name="weight">
<field-validator type="checkDouble" short-circuit="true">
+ <param name="notAvailable">NA</param>
<message>Weight attribute is not a valid double</message>
</field-validator>
</field>
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-10-25 15:44:33 UTC (rev 100)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ValidationServiceTest.java 2010-10-25 16:22:54 UTC (rev 101)
@@ -36,7 +36,7 @@
import fr.ifremer.coser.control.ValidationError;
/**
- * TODO add comment here.
+ * Test abour validation.
*
* @author chatellier
* @version $Revision$
@@ -50,25 +50,42 @@
protected ValidationService validationService = new ValidationService(config);
+ /**
+ * Test les validations sur les champs vide.
+ */
@Test
public void testCatchValidation() {
Catch myCatch = new Catch();
- myCatch.setData(new String[]{"","","","","",""});
+ myCatch.setData(new String[]{"1", "","","","","",""});
List<ValidationError> errors = validationService.validate(myCatch);
+ if (log.isDebugEnabled()) {
+ log.debug("Validation errors = " + errors);
+ }
Assert.assertNotNull(errors);
Assert.assertFalse(errors.isEmpty());
+
+ myCatch.setData(new String[]{"1", "Toto","","","","999",""});
+ errors = validationService.validate(myCatch);
if (log.isDebugEnabled()) {
log.debug("Validation errors = " + errors);
}
-
- myCatch.setData(new String[]{"Toto","","","","999",""});
- errors = validationService.validate(myCatch);
Assert.assertNotNull(errors);
Assert.assertFalse(errors.isEmpty());
+ }
+
+ /**
+ * Test la validation des valeurs NA pour les doubles.
+ */
+ @Test
+ public void testDoubleValidation() {
+ Catch myCatch = new Catch();
+ myCatch.setData(new String[]{"1", "Test survey","1999","Test trait","Test sp","NA","12"});
+ List<ValidationError> errors = validationService.validate(myCatch);
if (log.isDebugEnabled()) {
log.debug("Validation errors = " + errors);
}
+ Assert.assertNull(errors);
}
}
1
0
Author: chatellier
Date: 2010-10-25 15:44:33 +0000 (Mon, 25 Oct 2010)
New Revision: 100
Log:
Update project layout doc
Modified:
trunk/src/site/site_en.xml
trunk/src/site/site_fr.xml
Modified: trunk/src/site/site_en.xml
===================================================================
--- trunk/src/site/site_en.xml 2010-10-25 15:43:40 UTC (rev 99)
+++ trunk/src/site/site_en.xml 2010-10-25 15:44:33 UTC (rev 100)
@@ -59,7 +59,7 @@
</item>
<item name="Developer" href="developer.html">
-
+ <item name="Coser Project layout" href="directory.html" />
</item>
</menu>
Modified: trunk/src/site/site_fr.xml
===================================================================
--- trunk/src/site/site_fr.xml 2010-10-25 15:43:40 UTC (rev 99)
+++ trunk/src/site/site_fr.xml 2010-10-25 15:44:33 UTC (rev 100)
@@ -61,7 +61,7 @@
</item>
<item name="Développeur" href="developer.html">
-
+ <item name="Coser Project layout" href="directory.html" />
</item>
</menu>
1
0
Author: chatellier
Date: 2010-10-25 15:43:40 +0000 (Mon, 25 Oct 2010)
New Revision: 99
Log:
Update project layout doc
Added:
trunk/src/site/rst/directory.rst
Added: trunk/src/site/rst/directory.rst
===================================================================
--- trunk/src/site/rst/directory.rst (rev 0)
+++ trunk/src/site/rst/directory.rst 2010-10-25 15:43:40 UTC (rev 99)
@@ -0,0 +1,80 @@
+.. -
+.. * #%L
+.. * Coser
+.. *
+.. * $Id$
+.. * $HeadURL$
+.. * %%
+.. * Copyright (C) 2010 Ifremer, Codelutin
+.. * %%
+.. * 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%
+.. -
+Organisation des dossiers des projets Coser
+-------------------------------------------
+
+Structure de répertoires ::
+
+ testProject/
+ ├── project.properties
+ ├── modification.properties
+ ├── reftaxSpecies.csv
+ ├── original/
+ │ ├── catch.csv
+ │ ├── haul.csv
+ │ ├── length.csv
+ │ └── strata.csv
+ ├── control/
+ │ ├── catch_co.csv
+ │ ├── haul_co.csv
+ │ ├── length_co.csv
+ │ └── strata_co.csv
+ └── selections/
+ ├── selection1/
+ │ ├── catch_se.csv
+ │ ├── haul_se.csv
+ │ ├── length_se.csv
+ │ ├── strata_se.csv
+ │ ├── lists.properties
+ │ ├── runrufi1/
+ │ └── runrufi2/
+ └── selection2/
+ ├── catch_se.csv
+ ├── haul_se.csv
+ ├── length_se.csv
+ ├── strata_se.csv
+ ├── lists.properties
+ └── runrufi1/
+
++-------------------------+---------------------------------------------------+
+| Nom | Description |
++=========================+===================================================+
+| project.properties | Configuration générale du projet |
++-------------------------+---------------------------------------------------+
+| modification.properties | Configuration générale du projet |
++-------------------------+---------------------------------------------------+
+| reftaxSpecies.csv | Configuration générale du projet |
++-------------------------+---------------------------------------------------+
+| original/ | Dossier contenant les fichiers données originaux |
++-------------------------+---------------------------------------------------+
+| | Dossier contenant les fichiers données après |
+| control/ | validation |
++-------------------------+---------------------------------------------------+
+| selections/ | Contient un dossier par selection |
++-------------------------+---------------------------------------------------+
+| lists.properties | Contient les information de la sélection (4listes)|
++-------------------------+---------------------------------------------------+
+| runrufi1/ | Dossier contenant les resultat d'un run RSufi |
++-------------------------+---------------------------------------------------+
\ No newline at end of file
1
0
r98 - trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
25 Oct '10
Author: chatellier
Date: 2010-10-25 14:46:27 +0000 (Mon, 25 Oct 2010)
New Revision: 98
Log:
Default filter to 5%
Modified:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx
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-10-25 13:29:14 UTC (rev 97)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionListsView.jaxx 2010-10-25 14:46:27 UTC (rev 98)
@@ -60,9 +60,9 @@
<cell fill="horizontal" insets="0" columns="2">
<JPanel>
<JLabel text="coser.ui.selection.filter.occurrence" />
- <JTextField id="selectionFilterOccurrenceField" columns="3" />
+ <JTextField id="selectionFilterOccurrenceField" columns="3" text="5" />
<JLabel text="coser.ui.selection.filter.density" />
- <JTextField id="selectionFilterDensityField" columns="3" />
+ <JTextField id="selectionFilterDensityField" columns="3" text="5" />
<JButton text="coser.ui.selection.filter.filter" />
</JPanel>
</cell>
1
0
r97 - in trunk: 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-business/src/test/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/control
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
25 Oct '10
Author: chatellier
Date: 2010-10-25 13:29:14 +0000 (Mon, 25 Oct 2010)
New Revision: 97
Log:
Ajout du support de la sauvegarde des index dans les sauvegarde interm?\195?\169diaires de coser
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java
trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.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-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataEntity.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -25,6 +25,8 @@
package fr.ifremer.coser.bean;
+import static org.nuiton.i18n.I18n.n_;
+
/**
* Abstract entity to add all common data array code.
*
@@ -38,7 +40,10 @@
/** serialVersionUID. */
private static final long serialVersionUID = 4188448448464323807L;
-
+
+ public static final int INDEX_LINE = 0;
+ public static final String PROPERTY_LINE = n_("coser.business.line");
+
protected String[] data;
public String[] getData() {
@@ -48,4 +53,14 @@
public void setData(String[] data) {
this.data = data;
}
+
+ public void setLine(String value) {
+ String oldValue = data[INDEX_LINE];
+ data[INDEX_LINE] = value;
+ getPropertyChangeSupport().firePropertyChange(PROPERTY_LINE, oldValue, value);
+ }
+
+ public String getLine() {
+ return data[INDEX_LINE];
+ }
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Catch.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -50,64 +50,71 @@
public static final String[] EN_HEADERS = {
"Survey","Year","Haul","Species","Number","Weight"
};
-
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_SPECIES = 4;
+ public static final int INDEX_NUMBER = 5;
+ public static final int INDEX_WEIGHT = 6;
+
public void setSurvey(String value) {
- String oldValue = data[0];
- data[0] = value;
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
}
public String getSurvey() {
- return data[0];
+ return data[INDEX_SURVEY];
}
-
+
public void setYear(String value) {
- String oldValue = data[1];
- data[1] = value;
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
}
public String getYear() {
- return data[1];
+ return data[INDEX_YEAR];
}
public void setHaul(String value) {
- String oldValue = data[2];
- data[2] = value;
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
}
public String getHaul() {
- return data[2];
+ return data[INDEX_HAUL];
}
public void setSpecies(String value) {
- String oldValue = data[3];
- data[3] = value;
+ String oldValue = data[INDEX_SPECIES];
+ data[INDEX_SPECIES] = value;
getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
}
public String getSpecies() {
- return data[3];
+ return data[INDEX_SPECIES];
}
public void setNumber(String value) {
- String oldValue = data[4];
- data[4] = String.valueOf(value);
+ String oldValue = data[INDEX_NUMBER];
+ data[INDEX_NUMBER] = String.valueOf(value);
getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
}
public String getNumber() {
- return data[4];
+ return data[INDEX_NUMBER];
}
public void setWeight(String value) {
- String oldValue = data[5];
- data[5] = value;
+ String oldValue = data[INDEX_WEIGHT];
+ data[INDEX_WEIGHT] = value;
getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
}
public String getWeight() {
- return data[5];
+ return data[INDEX_WEIGHT];
}
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Haul.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -50,94 +50,104 @@
public static final String[] EN_HEADERS = {
"Survey","Year","Haul","Month","Stratum","SweptSurface","Lat","Long","Depth"
};
-
+
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_MONTH = 4;
+ public static final int INDEX_STRATUM = 5;
+ public static final int INDEX_SWEPT_SURFACE = 6;
+ public static final int INDEX_LAT = 7;
+ public static final int INDEX_LONG = 8;
+ public static final int INDEX_DEPTH = 9;
+
public void setSurvey(String value) {
- String oldValue = data[0];
- data[0] = value;
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
}
public String getSurvey() {
- return data[0];
+ return data[INDEX_SURVEY];
}
public void setYear(String value) {
- String oldValue = data[1];
- data[1] = value;
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
}
public String getYear() {
- return data[1];
+ return data[INDEX_YEAR];
}
public void setHaul(String value) {
- String oldValue = data[2];
- data[2] = value;
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
}
public String getHaul() {
- return data[2];
+ return data[INDEX_HAUL];
}
public void setMonth(String value) {
- String oldValue = data[3];
- data[3] = value;
+ String oldValue = data[INDEX_MONTH];
+ data[INDEX_MONTH] = value;
getPropertyChangeSupport().firePropertyChange("month", oldValue, value);
}
public String getMonth() {
- return data[3];
+ return data[INDEX_MONTH];
}
public void setStratum(String value) {
- String oldValue = data[4];
- data[4] = value;
+ String oldValue = data[INDEX_STRATUM];
+ data[INDEX_STRATUM] = value;
getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
}
public String getStratum() {
- return data[4];
+ return data[INDEX_STRATUM];
}
public void setSweptSurface(String value) {
- String oldValue = data[5];
- data[5] = value;
+ String oldValue = data[INDEX_SWEPT_SURFACE];
+ data[INDEX_SWEPT_SURFACE] = value;
getPropertyChangeSupport().firePropertyChange("sweptSurface", oldValue, value);
}
public String getSweptSurface() {
- return data[5];
+ return data[INDEX_SWEPT_SURFACE];
}
public void setLat(String value) {
- String oldValue = data[6];
- data[6] = value;
+ String oldValue = data[INDEX_LAT];
+ data[INDEX_LAT] = value;
getPropertyChangeSupport().firePropertyChange("lat", oldValue, value);
}
public String getLat() {
- return data[6];
+ return data[INDEX_LAT];
}
public void setLong(String value) {
- String oldValue = data[7];
- data[7] = value;
+ String oldValue = data[INDEX_LONG];
+ data[INDEX_LONG] = value;
getPropertyChangeSupport().firePropertyChange("long", oldValue, value);
}
public String getLong() {
- return data[7];
+ return data[INDEX_LONG];
}
public void setDepth(String value) {
- String oldValue = data[8];
- data[8] = value;
+ String oldValue = data[INDEX_DEPTH];
+ data[INDEX_DEPTH] = value;
getPropertyChangeSupport().firePropertyChange("depth", oldValue, value);
}
public String getDepth() {
- return data[8];
+ return data[INDEX_DEPTH];
}
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Length.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -49,105 +49,106 @@
public static final String[] EN_HEADERS = {
"Survey","Year","Haul","Species","Sex","Maturity","Length","Number","Weight","Age"
};
-
- protected String[] data;
- public String[] getData() {
- return data;
- }
-
- public void setData(String[] data) {
- this.data = data;
- }
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_YEAR = 2;
+ public static final int INDEX_HAUL = 3;
+ public static final int INDEX_SPECIES = 4;
+ public static final int INDEX_SEX = 5;
+ public static final int INDEX_MATURITY = 6;
+ public static final int INDEX_LENGTH = 7;
+ public static final int INDEX_NUMBER = 8;
+ public static final int INDEX_WEIGHT = 9;
+ public static final int INDEX_AGE = 10;
public void setSurvey(String value) {
- String oldValue = data[0];
- data[0] = value;
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
}
public String getSurvey() {
- return data[0];
+ return data[INDEX_SURVEY];
}
public void setYear(String value) {
- String oldValue = data[1];
- data[1] = value;
+ String oldValue = data[INDEX_YEAR];
+ data[INDEX_YEAR] = value;
getPropertyChangeSupport().firePropertyChange("year", oldValue, value);
}
public String getYear() {
- return data[1];
+ return data[INDEX_YEAR];
}
public void setHaul(String value) {
- String oldValue = data[2];
- data[2] = value;
+ String oldValue = data[INDEX_HAUL];
+ data[INDEX_HAUL] = value;
getPropertyChangeSupport().firePropertyChange("haul", oldValue, value);
}
public String getHaul() {
- return data[2];
+ return data[INDEX_HAUL];
}
public void setSpecies(String value) {
- String oldValue = data[3];
- data[3] = value;
+ String oldValue = data[INDEX_SPECIES];
+ data[INDEX_SPECIES] = value;
getPropertyChangeSupport().firePropertyChange("species", oldValue, value);
}
public String getSpecies() {
- return data[3];
+ return data[INDEX_SPECIES];
}
public void setSex(String value) {
- String oldValue = data[4];
- data[4] = value;
+ String oldValue = data[INDEX_SEX];
+ data[INDEX_SEX] = value;
getPropertyChangeSupport().firePropertyChange("sex", oldValue, value);
}
public String getSex() {
- return data[4];
+ return data[INDEX_SEX];
}
public void setMaturity(String value) {
- String oldValue = data[5];
- data[5] = value;
+ String oldValue = data[INDEX_MATURITY];
+ data[INDEX_MATURITY] = value;
getPropertyChangeSupport().firePropertyChange("maturity", oldValue, value);
}
public String getMaturity() {
- return data[5];
+ return data[INDEX_MATURITY];
}
public void setLength(String value) {
- String oldValue = data[6];
- data[6] = value;
+ String oldValue = data[INDEX_LENGTH];
+ data[INDEX_LENGTH] = value;
getPropertyChangeSupport().firePropertyChange("length", oldValue, value);
}
public String getLength() {
- return data[6];
+ return data[INDEX_LENGTH];
}
public void setNumber(String value) {
- String oldValue = data[7];
- data[7] = value;
+ String oldValue = data[INDEX_NUMBER];
+ data[INDEX_NUMBER] = value;
getPropertyChangeSupport().firePropertyChange("number", oldValue, value);
}
public String getNumber() {
- return data[7];
+ return data[INDEX_NUMBER];
}
public void setWeight(String value) {
- String oldValue = data[8];
- data[8] = value;
+ String oldValue = data[INDEX_WEIGHT];
+ data[INDEX_WEIGHT] = value;
getPropertyChangeSupport().firePropertyChange("weight", oldValue, value);
}
public String getWeight() {
- return data[8];
+ return data[INDEX_WEIGHT];
}
/**
@@ -156,8 +157,8 @@
* @param value new value to set
*/
public void setAge(String value) {
- String oldValue = data[9];
- data[9] = value;
+ String oldValue = data[INDEX_AGE];
+ data[INDEX_AGE] = value;
getPropertyChangeSupport().firePropertyChange("age", oldValue, value);
}
@@ -167,6 +168,6 @@
* @return age
*/
public String getAge() {
- return data[9];
+ return data[INDEX_AGE];
}
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Strata.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -51,44 +51,38 @@
"Survey","Stratum","Surface"
};
- protected String[] data;
+ public static final int INDEX_SURVEY = 1;
+ public static final int INDEX_STRATUM = 2;
+ public static final int INDEX_SURFACE = 3;
- public String[] getData() {
- return data;
- }
-
- public void setData(String[] data) {
- this.data = data;
- }
-
public void setSurvey(String value) {
- String oldValue = data[0];
- data[0] = value;
+ String oldValue = data[INDEX_SURVEY];
+ data[INDEX_SURVEY] = value;
getPropertyChangeSupport().firePropertyChange("survey", oldValue, value);
}
public String getSurvey() {
- return data[0];
+ return data[INDEX_SURVEY];
}
public void setStratum(String value) {
- String oldValue = data[1];
- data[1] = value;
+ String oldValue = data[INDEX_STRATUM];
+ data[INDEX_STRATUM] = value;
getPropertyChangeSupport().firePropertyChange("stratum", oldValue, value);
}
public String getStratum() {
- return data[1];
+ return data[INDEX_STRATUM];
}
public void setSurface(String value) {
- String oldValue = data[2];
- data[2] = value;
+ String oldValue = data[INDEX_SURFACE];
+ data[INDEX_SURFACE] = value;
getPropertyChangeSupport().firePropertyChange("surface", oldValue, value);
}
public String getSurface() {
- return data[2];
+ return data[INDEX_SURFACE];
}
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ImportService.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -43,6 +43,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
+import org.nuiton.util.ArrayUtil;
import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsv.CSVWriter;
@@ -50,6 +51,7 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.AbstractDataEntity;
import fr.ifremer.coser.bean.Catch;
import fr.ifremer.coser.bean.Haul;
import fr.ifremer.coser.bean.Length;
@@ -81,17 +83,19 @@
* @param project project
* @param category category
* @param file file to load
+ * @param originalLoading dans le cas d'un reload, la colonne "line" est a prendre en compte
+ * pour les data (elle est absente dans les jeux de données originaux)
* @return project
* @throws CoserBusinessException
*/
- public Project loadCSVFile(Project project, Category category, File file) throws CoserBusinessException {
-
+ public Project loadCSVFile(Project project, Category category, File file, boolean originalLoading) throws CoserBusinessException {
+
DataStorage content = new MemoryListStorage();
-
+
Reader reader = null;
CSVReader csvReader = null;
try {
-
+
reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), CoserConstants.CSV_FILE_ENCODING));
csvReader = new CSVReader(reader, CoserConstants.CSV_SEPARATOR_CHAR);
@@ -102,12 +106,24 @@
file.getAbsolutePath(), CoserConstants.CSV_SEPARATOR_CHAR));
}
else {
- checkFileHeader(category, line);
+ if (originalLoading) {
+ checkFileHeader(category, line);
+ if (category.isDataCategory()) {
+ line = (String[])ArrayUtil.concat(new String[]{AbstractDataEntity.PROPERTY_LINE}, line);
+ }
+ }
content.add(line);
}
-
+
+ // pour alimenter la line index (si non reloading)
+ int lineIndex = 0;
while ((line = csvReader.readNext()) != null) {
if (line.length>1) {
+ if (originalLoading && category.isDataCategory()) {
+ // ajout de la colonne "line" en debut (seulement pour les data)
+ line = (String[])ArrayUtil.concat(new String[]{String.valueOf(lineIndex)}, line);
+ lineIndex++;
+ }
content.add(line);
}
}
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-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -46,6 +46,8 @@
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConstants;
import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.bean.Catch;
+import fr.ifremer.coser.bean.Haul;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.bean.Specy;
@@ -118,7 +120,7 @@
CoserConstants.STORAGE_CSV_EXTENSION);
if (inputFile.isFile()) {
- project = importService.loadCSVFile(project, category, inputFile);
+ project = importService.loadCSVFile(project, category, inputFile, false);
fileLoaded++;
}
else {
@@ -139,7 +141,7 @@
category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION);
if (storageDataFile.isFile()) {
- project = importService.loadCSVFile(project, category, storageDataFile);
+ project = importService.loadCSVFile(project, category, storageDataFile, true);
}
else {
// si on arrive ici et qu'un fichier original
@@ -156,7 +158,7 @@
CoserConstants.STORAGE_CSV_EXTENSION);
if (inputFile.isFile()) {
- project = importService.loadCSVFile(project, Category.REFTAX_SPECIES, inputFile);
+ project = importService.loadCSVFile(project, Category.REFTAX_SPECIES, inputFile, true);
}
else {
// si on arrive ici et qu'un fichier original
@@ -200,7 +202,7 @@
for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) {
Category category = categoryAndFile.getKey();
File dataFile = categoryAndFile.getValue();
- project = importService.loadCSVFile(project, category, dataFile);
+ project = importService.loadCSVFile(project, category, dataFile, true);
}
// create new project directory
@@ -325,11 +327,11 @@
while (itTuple.hasNext()) {
String[] tuple = itTuple.next();
// Campagne;Annee;Trait;Mois;Strate;SurfaceBalayee;Lat;Long;ProfMoy
- String annee = tuple[1];
+ String annee = tuple[Haul.INDEX_YEAR];
int intAnnee = Integer.parseInt(annee);
if (intAnnee >= beginYear && intAnnee <= endYear) {
- String strates = tuple[4];
+ String strates = tuple[Haul.INDEX_STRATUM];
if (!result.contains(strates)) {
result.add(strates);
}
@@ -356,7 +358,7 @@
itTuple.next(); // header
while (itTuple.hasNext()) {
String[] tuple = itTuple.next();
- String year = tuple[1];
+ String year = tuple[Haul.INDEX_YEAR];
try {
Integer integerYear = Integer.valueOf(year);
years.add(integerYear);
@@ -391,12 +393,12 @@
while (itTuple.hasNext()) {
String[] tuple = itTuple.next();
// "Campagne","Annee","Trait","Espece","Nombre","Poids"
- String annee = tuple[1];
+ String annee = tuple[Catch.INDEX_YEAR];
try {
int intAnnee = Integer.parseInt(annee);
if (intAnnee >= beginYear && intAnnee <= endYear) {
- String species = tuple[3];
+ String species = tuple[Catch.INDEX_SPECIES];
if (!result.containsKey(species)) {
Specy specy = new Specy();
specy.setName(species);
@@ -502,9 +504,9 @@
// si les valeurs servant au bornes de regroupement
// on changer, on reset les données du merge
- String currentCampagne = tuple[0];
- String currentAnnee = tuple[1];
- String currentTraits = tuple[2];
+ String currentCampagne = tuple[Catch.INDEX_SURVEY];
+ String currentAnnee = tuple[Catch.INDEX_YEAR];
+ String currentTraits = tuple[Catch.INDEX_HAUL];
if (!currentCampagne.equals(lastCampagne) ||
!currentAnnee.equals(lastAnnee) ||
!currentTraits.equals(lastTraits)) {
@@ -516,7 +518,7 @@
}
// test si l'espece en cours fait partie de celle a merger
- String species = tuple[3];
+ String species = tuple[Catch.INDEX_SPECIES];
boolean specyFound = false;
for (String specy : speciesNames) {
if (specy.equals(species)) {
@@ -567,13 +569,13 @@
// "Campagne","Annee","Trait","Espece","Nombre","Poids"
try {
- double nombre1 = Double.parseDouble(tuple1[4]);
- double nombre2 = Double.parseDouble(tuple2[4]);
- double poids1 = Double.parseDouble(tuple1[5]);
- double poids2 = Double.parseDouble(tuple2[5]);
+ double nombre1 = Double.parseDouble(tuple1[Catch.INDEX_NUMBER]);
+ double nombre2 = Double.parseDouble(tuple2[Catch.INDEX_NUMBER]);
+ double poids1 = Double.parseDouble(tuple1[Catch.INDEX_WEIGHT]);
+ double poids2 = Double.parseDouble(tuple2[Catch.INDEX_WEIGHT]);
- tuple1[4] = String.valueOf(nombre1 + nombre2);
- tuple1[5] = String.valueOf(poids1 + poids2);
+ tuple1[Catch.INDEX_NUMBER] = String.valueOf(nombre1 + nombre2);
+ tuple1[Catch.INDEX_WEIGHT] = String.valueOf(poids1 + poids2);
}
catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
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-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-en_GB.properties 2010-10-25 13:29:14 UTC (rev 97)
@@ -11,6 +11,7 @@
coser.business.category.length=Length
coser.business.category.reftax.species=
coser.business.category.strata=Stata
+coser.business.line=Line
coser.config.database.directory.description=
coser.config.projects.directory.description=
coser.config.reference.species.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-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/main/resources/i18n/coser-business-fr_FR.properties 2010-10-25 13:29:14 UTC (rev 97)
@@ -11,6 +11,7 @@
coser.business.category.length=Tailles
coser.business.category.reftax.species=Reftax (esp\u00E8ce)
coser.business.category.strata=Strates
+coser.business.line=Ligne
coser.config.database.directory.description=Emplacement de la base de campagnes de coser
coser.config.projects.directory.description=Emplacement des projets Coser
coser.config.reference.species.description=Emplacement du fichier de r\u00E9f\u00E9rence des esp\u00E8ces
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-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ImportServiceTest.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -59,7 +59,7 @@
URL url = ImportServiceTest.class.getResource("/csv/badformat/capturesbadseparator.csv");
File file = new File(url.getFile());
- service.loadCSVFile(p, Category.CATCH, file);
+ service.loadCSVFile(p, Category.CATCH, file, true);
}
@Test(expected=CoserBusinessException.class)
@@ -68,7 +68,7 @@
URL url = ImportServiceTest.class.getResource("/csv/badformat/stratesheadername.csv");
File file = new File(url.getFile());
- service.loadCSVFile(p, Category.STRATA, file);
+ service.loadCSVFile(p, Category.STRATA, file, true);
}
@Test(expected=CoserBusinessException.class)
@@ -77,6 +77,6 @@
URL url = ImportServiceTest.class.getResource("/csv/badformat/traitsheaderorder.csv");
File file = new File(url.getFile());
- service.loadCSVFile(p, Category.HAUL, file);
+ service.loadCSVFile(p, Category.HAUL, file, true);
}
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2010-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -49,9 +49,6 @@
protected String[] header;
public ControlDataTableModel(ControlView controlView) {
- /*Project project = controlView.getContextValue(Project.class);
- data = project.getTailles();
- header = data.get(0).split(CoserConstants.CSV_SEPARATOR);*/
updateData(controlView);
}
@@ -87,20 +84,16 @@
*/
@Override
public int getColumnCount() {
- return header.length + 1;
+ return header.length;
}
-
@Override
public String getColumnName(int column) {
- String name = null;
-
- if ( column == 0) {
- name = _("coser.ui.validation.data.index");
+ String name = header[column];
+ // only for column 0 (line index)
+ if (column == 0) {
+ name = _(name);
}
- else {
- name = header[column - 1];
- }
return name;
}
@@ -116,7 +109,7 @@
result = rowIndex + 1;
}
else {
- result = data.get(rowIndex + 1)[columnIndex - 1];
+ result = data.get(rowIndex + 1)[columnIndex];
}
return result;
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-10-25 09:28:35 UTC (rev 96)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-10-25 13:29:14 UTC (rev 97)
@@ -275,11 +275,12 @@
final AbstractDataEntity finalBean = bean;
// add to panel
- for (int fieldIndex = 0 ; fieldIndex < header.length ; fieldIndex++) {
+ // start at 1 (0 = line index)
+ for (int fieldIndex = 1 ; fieldIndex < header.length ; fieldIndex++) {
String headerValue = header[fieldIndex];
String fieldValue = line[fieldIndex];
- final String beanFieldName = StringUtils.uncapitalize(enHeaders[fieldIndex]);
+ final String beanFieldName = StringUtils.uncapitalize(enHeaders[fieldIndex - 1]);
JLabel label = new JLabel(headerValue + "\u2009:");
final JTextField fieldTextField = new JTextField(fieldValue);
1
0
r96 - trunk/coser-business/src/main/java/fr/ifremer/coser
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
25 Oct '10
Author: chatellier
Date: 2010-10-25 09:28:35 +0000 (Mon, 25 Oct 2010)
New Revision: 96
Log:
Begin selection saving
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2010-10-25 09:28:13 UTC (rev 95)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserConstants.java 2010-10-25 09:28:35 UTC (rev 96)
@@ -52,6 +52,9 @@
/** Nom du dossier de sauvegarde des fichiers apres control. */
public static final String STORAGE_CONTROL_DIRECTORY = "control";
+
+ /** Nom du dossier de sauvegarde des selections. */
+ public static final String STORAGE_SELECTION_DIRECTORY = "selections";
/** Suffix des nom de fichiers data apres control. */
public static final String STORAGE_CONTROL_SUFFIX = "_co";
@@ -72,6 +75,8 @@
protected String translationKey;
protected String storageFileName;
+
+ /** Data category (par opposition reftax n'est pas un fichier de data). */
protected boolean dataCategory;
private Category(String translationKey, String storageFileName, boolean dataCategory) {
@@ -92,6 +97,11 @@
return storageFileName;
}
+ /**
+ * Data category (par opposition reftax n'est pas un fichier de data).
+ *
+ * @return {@code true} si la category correspond a des data
+ */
public boolean isDataCategory() {
return dataCategory;
}
1
0
r95 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
by chatellier@users.labs.libre-entreprise.org 25 Oct '10
25 Oct '10
Author: chatellier
Date: 2010-10-25 09:28:13 +0000 (Mon, 25 Oct 2010)
New Revision: 95
Log:
Begin selection saving
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.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/SelectionView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.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-10-25 09:27:33 UTC (rev 94)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-25 09:28:13 UTC (rev 95)
@@ -274,6 +274,41 @@
}
/**
+ * Save project selection.
+ *
+ * @param project project to save selection
+ * @throws CoserBusinessException
+ */
+ public void saveProjectSelection(Project project, String selectionName) throws CoserBusinessException {
+
+ // tout ce qui suit doit exister à ce stade
+ File projectsDirectory = config.getProjectsDirectory();
+ String projectName = project.getName();
+ File projectDirectory = new File(projectsDirectory, projectName);
+
+ // creation du dossier de selections (peut deja exister)
+ File selectionsDirectory = new File(projectDirectory, CoserConstants.STORAGE_SELECTION_DIRECTORY);
+
+ // creation du dossier de la selection courante
+ File selectionDirectory = new File(selectionsDirectory, selectionName);
+ selectionDirectory.mkdirs();
+
+ for (Category category : Category.values()) {
+ if (category.isDataCategory()) {
+ File controlFile = new File(selectionDirectory,
+ category.getStorageFileName() +
+ CoserConstants.STORAGE_SELECTION_SUFFIX +
+ CoserConstants.STORAGE_CSV_EXTENSION);
+ if (log.isDebugEnabled()) {
+ log.debug("Saving selection file : " + controlFile);
+ }
+ importService.storeData(project, category, controlFile);
+ }
+ }
+
+ }
+
+ /**
* Get zones name in project with data in [{@code beginYear}-{@code endYear}].
*
* @param project project
@@ -330,7 +365,7 @@
// can't happen after control
// data must be all ok
if (log.isWarnEnabled()) {
- log.warn("Can't convert year to integer, but data must be correct after control :(");
+ log.warn("Can't convert year '" + year + "' to integer, but data must be correct after control :(");
}
}
}
@@ -371,7 +406,7 @@
}
catch (NumberFormatException ex) {
if (log.isWarnEnabled()) {
- log.warn("Can't parse year " + annee + " as int, can't happen with controled data");
+ log.warn("Can't parse year '" + annee + "' as int, can't happen with controled data");
}
}
}
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-10-25 09:27:33 UTC (rev 94)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-10-25 09:28:13 UTC (rev 95)
@@ -37,8 +37,6 @@
import javax.swing.event.ListSelectionEvent;
import jaxx.runtime.JAXXUtil;
-import jaxx.runtime.context.DefaultJAXXContext;
-import jaxx.runtime.context.JAXXInitialContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -159,10 +157,37 @@
}
}
+ /**
+ * Sauvegarde (ou creer) la sélection.
+ *
+ * @param view parent view
+ */
public void saveSelection(SelectionDetailsView view) {
+ String selectionName = view.getSelectionDetailsSelecionNameField().getText().trim();
+ // TODO test de nom valid ?
+
+ Project project = view.getContextValue(Project.class);
+ ProjectService service = view.getContextValue(ProjectService.class);
+
+ try {
+ service.saveProjectSelection(project, selectionName);
+ }
+ catch (CoserBusinessException ex) {
+ throw new CoserException("Can't save selection", ex);
+ }
+
+ // enable tabs
+ SelectionView selectionView = view.getParentContainer(SelectionView.class);
+ selectionView.setEnabledAt(1, true); // selection lists
+ selectionView.setEnabledAt(2, true); // rsufi
}
-
+
+ /**
+ * Sauvegarde des listes des selectino d'especes.
+ *
+ * @param view view
+ */
public void saveSelectionLists(SelectionListsView view) {
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx 2010-10-25 09:27:33 UTC (rev 94)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx 2010-10-25 09:28:13 UTC (rev 95)
@@ -37,10 +37,10 @@
<tab title="coser.ui.selection.tab.details">
<SelectionDetailsView id="selectionDetailsTab" constructorParams="this" handler="{getHandler()}" />
</tab>
- <tab title="coser.ui.selection.tab.lists">
+ <tab title="coser.ui.selection.tab.lists" enabled="false">
<SelectionListsView id="selectionListsView" constructorParams="this" handler="{getHandler()}" />
</tab>
- <tab title="coser.ui.selection.tab.result">
+ <tab title="coser.ui.selection.tab.result" enabled="false">
<SelectionResultView id="selectionResultView" constructorParams="this" handler="{getHandler()}" />
</tab>
</JTabbedPane>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-10-25 09:27:33 UTC (rev 94)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SpecyListCheckBoxRenderer.java 2010-10-25 09:28:13 UTC (rev 95)
@@ -27,10 +27,7 @@
import java.awt.Component;
-import javax.swing.DefaultListSelectionModel;
-import javax.swing.JCheckBox;
import javax.swing.JList;
-import javax.swing.ListCellRenderer;
import org.jdesktop.swingx.renderer.DefaultListRenderer;
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-10-25 09:27:33 UTC (rev 94)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-10-25 09:28:13 UTC (rev 95)
@@ -29,11 +29,8 @@
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
-import javax.swing.JList;
-import javax.swing.event.ListSelectionEvent;
import fr.ifremer.coser.bean.Project;
-import fr.ifremer.coser.bean.Specy;
import fr.ifremer.coser.services.ProjectService;
/**
1
0