Author: chatellier Date: 2010-10-27 11:47:34 +0000 (Wed, 27 Oct 2010) New Revision: 106 Log: Modify data loading time (control / selection) Added: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Selection-error-validation.xml Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 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/main/java/fr/ifremer/coser/services/ProjectService.java trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Project-error-validation.xml 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/CommandServiceTest.java trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ProjectCreationView.jaxx 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/SelectionDetailsView.jaxx 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/YearComboBoxModel.java trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties trunk/pom.xml Added: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java (rev 0) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java 2010-10-27 11:47:34 UTC (rev 106) @@ -0,0 +1,172 @@ +/* + * #%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; + +import java.util.List; + +import fr.ifremer.coser.command.Command; +import fr.ifremer.coser.storage.DataStorage; + +/** + * TODO add comment here. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class AbstractDataContainer extends AbstractEntity { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3963187480579783560L; + + protected DataStorage dataCatch; + + /** Deleted catch (can be null). */ + protected DataStorage deletedDataCatch; + + protected DataStorage dataStrata; + + /** Deleted strata (can be null). */ + protected DataStorage deletedDataStrata; + + protected DataStorage dataHaul; + + /** Deleted haul (can be null). */ + protected DataStorage deletedDataHaul; + + protected DataStorage dataLength; + + /** Deleted length (can be null). */ + protected DataStorage deletedDataLength; + + /** L'historique des commandes do/undo .*/ + protected List<Command> historyCommand; + + /** + * Clear all data to force free memory. + */ + public void clearData() { + dataCatch = null; + deletedDataCatch = null; + dataStrata = null; + deletedDataStrata = null; + dataHaul = null; + deletedDataHaul = null; + dataLength = null; + deletedDataLength = null; + historyCommand = null; + } + + public DataStorage getCatch() { + return dataCatch; + } + + public void setCatch(DataStorage dataCatch) { + this.dataCatch = dataCatch; + } + + public DataStorage getStrata() { + return dataStrata; + } + + public void setStrata(DataStorage dataStrata) { + this.dataStrata = dataStrata; + } + + public DataStorage getHaul() { + return dataHaul; + } + + public void setHaul(DataStorage dataHaul) { + this.dataHaul = dataHaul; + } + + public DataStorage getLength() { + return dataLength; + } + + public void setLength(DataStorage dataLength) { + 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 List<Command> getHistoryCommand() { + return historyCommand; + } + + public void setHistoryCommand(List<Command> historyCommand) { + this.historyCommand = historyCommand; + } + + /** + * Return {@code true} if data are loaded. + * + * If lists are non {@code null}. + * + * @return {@code true} if at least one list is not {@code null} + */ + public boolean isDataLoaded() { + boolean result = false; + result |= dataCatch != null; + result |= dataStrata != null; + result |= dataHaul != null; + result |= dataLength != null; + return result; + } +} Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/AbstractDataContainer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java (rev 0) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java 2010-10-27 11:47:34 UTC (rev 106) @@ -0,0 +1,42 @@ +/* + * #%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; + +/** + * Control entity. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class Control extends AbstractDataContainer { + + /** serialVersionUID. */ + private static final long serialVersionUID = 3693938021315541627L; + +} Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Control.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Project.java 2010-10-27 11:47:34 UTC (rev 106) @@ -25,9 +25,8 @@ package fr.ifremer.coser.bean; -import java.util.List; +import java.util.Map; -import fr.ifremer.coser.command.Command; import fr.ifremer.coser.storage.DataStorage; /** @@ -54,33 +53,14 @@ }; protected String name; - - protected DataStorage dataCatch; - - protected DataStorage deletedDataCatch; - - protected DataStorage dataStrata; - - protected DataStorage deletedDataStrata; - - protected DataStorage dataHaul; - - protected DataStorage deletedDataHaul; - - protected DataStorage dataLength; - - protected DataStorage deletedDataLength; + protected Control control; + + protected Map<String, Selection> selections; + /** Reftax SIH. */ protected DataStorage refTaxSpecies; - /** L'historique des commandes do/undo .*/ - protected List<Command> historyCommand; - - public DataStorage getCatch() { - return dataCatch; - } - public String getName() { return name; } @@ -91,66 +71,25 @@ getPropertyChangeSupport().firePropertyChange("name", oldValue, name); } - public void setCatch(DataStorage dataCatch) { - this.dataCatch = dataCatch; + public Control getControl() { + return control; } - public DataStorage getStrata() { - return dataStrata; + public void setControl(Control control) { + Control oldValue = this.control; + this.control = control; + getPropertyChangeSupport().firePropertyChange("control", oldValue, control); } - public void setStrata(DataStorage dataStrata) { - this.dataStrata = dataStrata; + public Map<String, Selection> getSelections() { + return selections; } - public DataStorage getHaul() { - return dataHaul; + public void setSelections(Map<String, Selection> selections) { + this.selections = selections; + getPropertyChangeSupport().firePropertyChange("selections", null, selections); } - public void setHaul(DataStorage dataHaul) { - this.dataHaul = dataHaul; - } - - public DataStorage getLength() { - return dataLength; - } - - public void setLength(DataStorage dataLength) { - 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; } @@ -158,12 +97,18 @@ public void setRefTaxSpecies(DataStorage refTaxSpecies) { this.refTaxSpecies = refTaxSpecies; } - - public List<Command> getHistoryCommand() { - return historyCommand; + + /** + * Force all container data clear to force free memory. + */ + public void clearData() { + if (control != null) { + control.clearData(); + } + if (selections != null) { + for (Selection selection : selections.values()) { + selection.clearData(); + } + } } - - public void setHistoryCommand(List<Command> historyCommand) { - this.historyCommand = historyCommand; - } } Added: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java (rev 0) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java 2010-10-27 11:47:34 UTC (rev 106) @@ -0,0 +1,53 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Lesser Public License for more details. + * + * You should have received a copy of the GNU General Lesser Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/lgpl-3.0.html>. + * #L% + */ + +package fr.ifremer.coser.bean; + +/** + * Project selection. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class Selection extends AbstractDataContainer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -1484104459960459854L; + + protected String name; + + public String getName() { + return name; + } + + public void setName(String name) { + String oldValue = this.name; + this.name = name; + getPropertyChangeSupport().firePropertyChange("name", oldValue, name); + } +} Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/bean/Selection.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/Command.java 2010-10-27 11:47:34 UTC (rev 106) @@ -28,6 +28,7 @@ import java.util.UUID; import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; /** @@ -73,15 +74,17 @@ * Do command on project. * * @param project project + * @param container container * @throws CoserBusinessException */ - public abstract void doCommand(Project project) throws CoserBusinessException; + public abstract void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException; /** * Undo command on project. * * @param project project + * @param container container * @throws CoserBusinessException */ - public abstract void undoCommand(Project project) throws CoserBusinessException; + public abstract void undoCommand(Project project, AbstractDataContainer container) throws CoserBusinessException; } 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/DeleteLineCommand.java 2010-10-27 11:47:34 UTC (rev 106) @@ -34,6 +34,7 @@ import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.data.AbstractDataEntity; import fr.ifremer.coser.storage.DataStorage; @@ -74,28 +75,28 @@ } @Override - public void doCommand(Project project) throws CoserBusinessException { - + public void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { + DataStorage dataStorage = null; DataStorage deletedDataStorage = null; // get data storage depending on category switch(category) { case CATCH: - dataStorage = project.getCatch(); - deletedDataStorage = project.getDeletedCatch(); + dataStorage = container.getCatch(); + deletedDataStorage = container.getDeletedCatch(); break; case HAUL: - dataStorage = project.getHaul(); - deletedDataStorage = project.getDeletedHaul(); + dataStorage = container.getHaul(); + deletedDataStorage = container.getDeletedHaul(); break; case LENGTH: - dataStorage = project.getLength(); - deletedDataStorage = project.getDeletedLength(); + dataStorage = container.getLength(); + deletedDataStorage = container.getDeletedLength(); break; case STRATA: - dataStorage = project.getStrata(); - deletedDataStorage = project.getDeletedStrata(); + dataStorage = container.getStrata(); + deletedDataStorage = container.getDeletedStrata(); break; } @@ -123,27 +124,28 @@ } @Override - public void undoCommand(Project project) throws CoserBusinessException { + public void undoCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { + DataStorage dataStorage = null; DataStorage deletedDataStorage = null; // get data storage depending on category switch(category) { case CATCH: - dataStorage = project.getCatch(); - deletedDataStorage = project.getDeletedCatch(); + dataStorage = container.getCatch(); + deletedDataStorage = container.getDeletedCatch(); break; case HAUL: - dataStorage = project.getHaul(); - deletedDataStorage = project.getDeletedHaul(); + dataStorage = container.getHaul(); + deletedDataStorage = container.getDeletedHaul(); break; case LENGTH: - dataStorage = project.getLength(); - deletedDataStorage = project.getDeletedLength(); + dataStorage = container.getLength(); + deletedDataStorage = container.getDeletedLength(); break; case STRATA: - dataStorage = project.getStrata(); - deletedDataStorage = project.getDeletedStrata(); + dataStorage = container.getStrata(); + deletedDataStorage = container.getDeletedStrata(); break; } 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/MergeSpeciesCommand.java 2010-10-27 11:47:34 UTC (rev 106) @@ -32,6 +32,8 @@ import org.apache.commons.logging.LogFactory; import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.data.Catch; @@ -72,10 +74,10 @@ * @see fr.ifremer.coser.command.Command#doCommand(fr.ifremer.coser.bean.Project) */ @Override - public void doCommand(Project project) throws CoserBusinessException { + public void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { - project = mergeCatch(project, newSpecyName, speciesNames); - project = mergeLength(project, newSpecyName, speciesNames); + project = mergeCatch(project, container, newSpecyName, speciesNames); + project = mergeLength(project, container, newSpecyName, speciesNames); } @@ -83,7 +85,7 @@ * @see fr.ifremer.coser.command.Command#undoCommand(fr.ifremer.coser.bean.Project) */ @Override - public void undoCommand(Project project) throws CoserBusinessException { + public void undoCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { throw new NotImplementedException("Merge operation can't be undone"); } @@ -92,12 +94,13 @@ * Fusion d'espece dans les données de captures. * * @param project project + * @param container data container * @param newSpecyName new specy name (after merge) * @param speciesNames species name to merge * @return project */ - protected Project mergeLength(Project project, String newSpecyName, - String... speciesNames) { + protected Project mergeLength(Project project, AbstractDataContainer container, + String newSpecyName, String... speciesNames) { return project; } @@ -105,12 +108,13 @@ * Fusion d'especes dans les données de taille. * * @param project project + * @param container data container * @param newSpecyName new specy name (after merge) * @param speciesNames species name to merge * @return project */ - protected Project mergeCatch(Project project, String newSpecyName, - String... speciesNames) { + protected Project mergeCatch(Project project, AbstractDataContainer container, + String newSpecyName, String... speciesNames) { // "Campagne","Annee","Trait","Espece","Nombre","Poids" @@ -122,7 +126,7 @@ int tupleIndex = -1; // parcours des elements - Iterator<String[]> itTuple = project.getCatch().iterator(); + Iterator<String[]> itTuple = container.getCatch().iterator(); itTuple.next(); // skip header int index = 1; // skip header while (itTuple.hasNext()) { @@ -170,7 +174,7 @@ index--; } - project.getCatch().set(tupleIndex, tupleFound); + container.getCatch().set(tupleIndex, tupleFound); } index++; 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/command/ModifyFieldCommand.java 2010-10-27 11:47:34 UTC (rev 106) @@ -27,6 +27,7 @@ import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.data.Haul; @@ -100,12 +101,12 @@ } @Override - public void doCommand(Project project) throws CoserBusinessException { + public void doCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { } @Override - public void undoCommand(Project project) throws CoserBusinessException { + public void undoCommand(Project project, AbstractDataContainer container) throws CoserBusinessException { } Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java =================================================================== --- trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/CommandService.java 2010-10-27 11:47:34 UTC (rev 106) @@ -33,6 +33,7 @@ import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserBusinessException; +import fr.ifremer.coser.bean.AbstractDataContainer; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.command.Command; @@ -69,9 +70,10 @@ * * @param command command to perform * @param project project + * @param container container * @throws CoserBusinessException */ - public void doAction(Command command, Project project) throws CoserBusinessException { + public void doAction(Command command, Project project, AbstractDataContainer container) throws CoserBusinessException { if (log.isDebugEnabled()) { log.debug("Do action " + command); } @@ -81,20 +83,21 @@ command.setCommandUUID(getUniqueCommandUUID()); } - command.doCommand(project); - project.getHistoryCommand().add(command); + command.doCommand(project, container); + container.getHistoryCommand().add(command); } /** * Undo last command on project. * * @param project project + * @param container container * @throws CoserBusinessException */ - public void undoAction(Project project) throws CoserBusinessException { + public void undoAction(Project project, AbstractDataContainer container) throws CoserBusinessException { + + ListIterator<Command> itCommand = container.getHistoryCommand().listIterator(container.getHistoryCommand().size()); - ListIterator<Command> itCommand = project.getHistoryCommand().listIterator(project.getHistoryCommand().size()); - String lastUUID = null; while (itCommand.hasPrevious()) { Command command = itCommand.previous(); @@ -103,7 +106,7 @@ break; } else { - command.undoCommand(project); + command.undoCommand(project, container); lastUUID = command.getCommandUUID(); itCommand.remove(); } 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2010-10-27 11:47:34 UTC (rev 106) @@ -46,7 +46,10 @@ import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConstants; import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.bean.AbstractDataContainer; +import fr.ifremer.coser.bean.Control; import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.bean.Specy; import fr.ifremer.coser.command.Command; import fr.ifremer.coser.command.DeleteLineCommand; @@ -97,13 +100,108 @@ } /** - * Load project. + * Create new project. * - * @param projectName project name to load + * Do (ordered): + * - project existence test + * - data loading + * - data copying (after loading check) + * + * @param project project to create + * @param categoriesAndFiles additional files to load + * @return project with filled data + * @throws CoserBusinessException if project can't be created + */ + public Project createProject(Project project, Map<Category, File> categoriesAndFiles) throws CoserBusinessException { + File projectsDirectory = config.getProjectsDirectory(); + if (!projectsDirectory.isDirectory()) { + projectsDirectory.mkdirs(); + } + + String projectName = project.getName(); + // check project existence + File[] projects = projectsDirectory.listFiles(); + for (File existingProject : projects) { + if (existingProject.getName().equalsIgnoreCase(projectName)) { + throw new CoserBusinessException(_("Project %s already exist", project.getName())); + } + } + + // first free memory, clear all data + project.clearData(); + + Control control = new Control(); + + // load each files + // loaded before any creation, to check data format + // useless loading, just to check data + for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) { + Category category = categoryAndFile.getKey(); + File dataFile = categoryAndFile.getValue(); + DataStorage dataStorage = importService.loadCSVFile(project, category, dataFile, true); + addProjectContent(project, control, category, dataStorage, false); + + // init empty deleted collection + if (category.isDataCategory()) { + // deleted data + DataStorage dataStorage2 = importService.getEmptyStorage(project, category); + addProjectContent(project, control, category, dataStorage2, true); + } + } + + // create new project directory + File projectDirectory = new File(projectsDirectory, projectName); + projectDirectory.mkdirs(); + + // sauvegarde des fichiers (tracabilité) + File originalDirectory = new File(projectDirectory, CoserConstants.STORAGE_ORIGINAL_DIRECTORY); + originalDirectory.mkdirs(); + for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) { + Category category = categoryAndFile.getKey(); + File dataFile = categoryAndFile.getValue(); + try { + + // les fichiers de donnees sont stockes dans un repertoire + // "original" + if (category.isDataCategory()) { + File storageDataFile = new File(originalDirectory, + category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION); + FileUtils.copyFile(dataFile, storageDataFile); + } + + // les fichiers autres (reftax) sont stockes a la base + else { + File storageDataFile = new File(projectDirectory, + category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION); + FileUtils.copyFile(dataFile, storageDataFile); + } + } catch (IOException ex) { + // clean creates directories + try { + FileUtils.deleteDirectory(projectDirectory); + } catch (IOException e) { + throw new CoserBusinessException(_("Can't create project"), ex); + } + throw new CoserBusinessException(_("Can't create project"), ex); + } + } + + control.setHistoryCommand(new ArrayList<Command>()); + project.setControl(control); + + return project; + } + + /** + * Open project without loading data. + * + * Just load non category data (reftax). + * + * @param projectName project name to open * @return loaded project with data * @throws CoserBusinessException */ - public Project loadProject(String projectName) throws CoserBusinessException { + public Project openProject(String projectName) throws CoserBusinessException { // check project existence File projectsDirectory = config.getProjectsDirectory(); @@ -114,6 +212,41 @@ Project project = new Project(); project.setName(projectName); + // load additional files + File inputFile = new File(projectDirectory, + Category.REFTAX_SPECIES.getStorageFileName() + + CoserConstants.STORAGE_CSV_EXTENSION); + + if (inputFile.isFile()) { + DataStorage dataStorage = importService.loadCSVFile(project, Category.REFTAX_SPECIES, inputFile, true); + addProjectContent(project, null, Category.REFTAX_SPECIES, dataStorage, false); + } + else { + // si on arrive ici et qu'un fichier original + // n'existe pas, c'est grave + throw new CoserBusinessException(_("Missing file %s", inputFile)); + } + + return project; + } + + /** + * Load control data in an initialized project. + * + * @param project project + * @return project with data + * @throws CoserBusinessException + */ + public Project loadControlData(Project project) throws CoserBusinessException { + + File projectsDirectory = config.getProjectsDirectory(); + File projectDirectory = new File(projectsDirectory, project.getName()); + + // first free memory, clear all data + project.clearData(); + + Control control = new Control(); + // try to load validated data first File controlDirectory = new File(projectDirectory, CoserConstants.STORAGE_CONTROL_DIRECTORY); int fileLoaded = 0; @@ -126,7 +259,7 @@ if (inputFile.isFile()) { DataStorage dataStorage = importService.loadCSVFile(project, category, inputFile, false); - addProjectContent(project, category, dataStorage, false); + addProjectContent(project, control, category, dataStorage, false); fileLoaded++; } else { @@ -148,7 +281,7 @@ log.debug("Can't find file " + inputFile); } } - addProjectContent(project, category, dataStorage, true); + addProjectContent(project, control, category, dataStorage, true); } } @@ -164,7 +297,7 @@ // main data if (storageDataFile.isFile()) { DataStorage dataStorage = importService.loadCSVFile(project, category, storageDataFile, true); - addProjectContent(project, category, dataStorage, false); + addProjectContent(project, control, category, dataStorage, false); } else { // si on arrive ici et qu'un fichier original @@ -174,169 +307,20 @@ // deleted data DataStorage dataStorage = importService.getEmptyStorage(project, category); - addProjectContent(project, category, dataStorage, true); + addProjectContent(project, control, category, dataStorage, true); } } } - // load additional files - File inputFile = new File(projectDirectory, - Category.REFTAX_SPECIES.getStorageFileName() + - CoserConstants.STORAGE_CSV_EXTENSION); + // TODO echatellier 20101027 need history file reloading + control.setHistoryCommand(new ArrayList<Command>()); - if (inputFile.isFile()) { - 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 - // n'existe pas, c'est grave - throw new CoserBusinessException(_("Missing file %s", inputFile)); - } + project.setControl(control); - // 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): - * - project existence test - * - data loading - * - data copying (after loading check) - * - * @param project project to create - * @param categoriesAndFiles additionals files to load - * @return project with filled data - * @throws CoserBusinessException if project can't be created - */ - public Project createProject(Project project, Map<Category, File> categoriesAndFiles) throws CoserBusinessException { - File projectsDirectory = config.getProjectsDirectory(); - if (!projectsDirectory.isDirectory()) { - projectsDirectory.mkdirs(); - } - - String projectName = project.getName(); - // check project existence - File[] projects = projectsDirectory.listFiles(); - for (File existingProject : projects) { - if (existingProject.getName().equalsIgnoreCase(projectName)) { - throw new CoserBusinessException(_("Project %s already exist", project.getName())); - } - } - - // load each files - // loaded before any creation, to check data format - for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) { - Category category = categoryAndFile.getKey(); - File dataFile = categoryAndFile.getValue(); - 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 - File projectDirectory = new File(projectsDirectory, projectName); - projectDirectory.mkdirs(); - - // sauvegarde des fichier (tracabilité) - File originalDirectory = new File(projectDirectory, CoserConstants.STORAGE_ORIGINAL_DIRECTORY); - originalDirectory.mkdirs(); - for (Map.Entry<Category, File> categoryAndFile : categoriesAndFiles.entrySet()) { - Category category = categoryAndFile.getKey(); - File dataFile = categoryAndFile.getValue(); - try { - - // les fichiers de donnees sont stockes dans un repertoire - // "original" - if (category.isDataCategory()) { - File storageDataFile = new File(originalDirectory, - category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION); - FileUtils.copyFile(dataFile, storageDataFile); - } - - // les fichiers autres (refatx) sont stockes a la base - else { - File storageDataFile = new File(projectDirectory, - category.getStorageFileName() + CoserConstants.STORAGE_CSV_EXTENSION); - FileUtils.copyFile(dataFile, storageDataFile); - } - } catch (IOException ex) { - // clean creates directories - try { - FileUtils.deleteDirectory(projectDirectory); - } catch (IOException e) { - throw new CoserBusinessException(_("Can't create project"), ex); - } - throw new CoserBusinessException(_("Can't create project"), ex); - } - } - - // init des autres resources du projet - project.setHistoryCommand(new ArrayList<Command>()); - - return project; - } - - /** * Enregistre les fichiers de données apres validation. * * @param project project to save @@ -363,11 +347,11 @@ if (log.isDebugEnabled()) { log.debug("Saving control file : " + controlFile); } - DataStorage content = getProjectContent(project, category, false); + DataStorage content = getProjectContent(project, project.getControl(), category, false); importService.storeData(project, content, controlFile); // save deleted content (if needed) - DataStorage contentDeleted = getProjectContent(project, category, true); + DataStorage contentDeleted = getProjectContent(project, project.getControl(), category, true); // if more content than header if (contentDeleted.size() > 1) { File deletedDataFile = new File(controlDirectory, @@ -381,6 +365,84 @@ } /** + * Creer une instance de selection "non sauvegardee" avec les données + * de control (validée) du projet. + * + * @param project project to create selection + * @return selection + * @throws CoserBusinessException + */ + public Selection createProjectSelection(Project project) throws CoserBusinessException { + + // TODO echatellier 20101027 voir si on force que les + // fichier de validation existe ici ou pas + + Project localProject = project; + if (!localProject.getControl().isDataLoaded()) { + localProject = loadControlData(localProject); + } + + // create new selection + Control control = localProject.getControl(); + DataStorage dataCatch = control.getCatch(); + DataStorage dataHaul = control.getHaul(); + DataStorage dataLength = control.getLength(); + DataStorage dataStrata = control.getStrata(); + + project.clearData(); + + Selection selection = new Selection(); + selection.setCatch(dataCatch); + selection.setHaul(dataHaul); + selection.setLength(dataLength); + selection.setStrata(dataStrata); + selection.setHistoryCommand(new ArrayList<Command>()); + + return selection; + } + + /** + * Save project selection. + * + * @param project project to save selection + * @param selection selection to save + * @throws CoserBusinessException + */ + public void saveProjectSelection(Project project, Selection selection) 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, selection.getName()); + 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); + } + + DataStorage content = getProjectContent(project, selection, category, false); + importService.storeData(project, content, controlFile); + + // delete data are not saved here + // can't delete data in selection + } + } + + } + + /** * Set content into project depending on category type. * * @param project project @@ -388,101 +450,134 @@ * @param content content to set * @param deletedContent if content means deleted objects for {@code category} */ - protected DataStorage getProjectContent(Project project, Category category, boolean deletedContent) { + protected void addProjectContent(Project project, AbstractDataContainer container, + Category category, DataStorage content, boolean deletedContent) { - DataStorage content = null; - switch (category) { case CATCH: if (!deletedContent) { - content = project.getCatch(); + container.setCatch(content); } else { - content = project.getDeletedCatch(); + container.setDeletedCatch(content); } break; case HAUL: if (!deletedContent) { - content = project.getHaul(); + container.setHaul(content); } else { - content = project.getDeletedHaul(); + container.setDeletedHaul(content); } break; case LENGTH: if (!deletedContent) { - content = project.getLength(); + container.setLength(content); } else { - content = project.getDeletedLength(); + container.setDeletedLength(content); } break; case STRATA: if (!deletedContent) { - content = project.getStrata(); + container.setStrata(content); } else { - content = project.getDeletedStrata(); + container.setDeletedStrata(content); } break; case REFTAX_SPECIES: project.setRefTaxSpecies(content); break; } - - return content; } /** - * Save project selection. + * Set content into project depending on category type. * - * @param project project to save selection - * @throws CoserBusinessException + * @param project project + * @param category category + * @param content content to set + * @param deletedContent if content means deleted objects for {@code category} */ - public void saveProjectSelection(Project project, String selectionName) throws CoserBusinessException { + protected DataStorage getProjectContent(Project project, AbstractDataContainer container, + Category category, boolean deletedContent) { - // tout ce qui suit doit exister à ce stade - File projectsDirectory = config.getProjectsDirectory(); - String projectName = project.getName(); - File projectDirectory = new File(projectsDirectory, projectName); + DataStorage content = null; - // 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); - } - - DataStorage content = getProjectContent(project, category, false); - importService.storeData(project, content, controlFile); + switch (category) { + case CATCH: + if (!deletedContent) { + content = container.getCatch(); } + else { + content = container.getDeletedCatch(); + } + break; + case HAUL: + if (!deletedContent) { + content = container.getHaul(); + } + else { + content = container.getDeletedHaul(); + } + break; + case LENGTH: + if (!deletedContent) { + content = container.getLength(); + } + else { + content = container.getDeletedLength(); + } + break; + case STRATA: + if (!deletedContent) { + content = container.getStrata(); + } + else { + content = container.getDeletedStrata(); + } + break; } + return content; } /** + * Supprime une données via son index. + * + * Used in control ui. + * + * @param project project + * @param control control + * @param category category + * @param index index to delete + * @throws CoserBusinessException + */ + public void deleteData(Project project, Control control, Category category, String index) throws CoserBusinessException { + + // create new delete action + DeleteLineCommand command = new DeleteLineCommand(); + command.setCategory(category); + command.setLineIndex(index); + commandService.doAction(command, project, control); + } + + /** * Get zones name in project with data in [{@code beginYear}-{@code endYear}]. * - * @param project project + * Used in selection ui. + * + * @param selection selection * @param beginYear begin year * @param endYear end year * @return zones */ - public List<String> getProjectZone(Project project, Integer beginYear, Integer endYear) { + public List<String> getProjectZone(Selection selection, Integer beginYear, Integer endYear) { List<String> result = new ArrayList<String>(); - Iterator<String[]> itTuple = project.getHaul().iterator(); + Iterator<String[]> itTuple = selection.getHaul().iterator(); itTuple.next(); // skip header while (itTuple.hasNext()) { String[] tuple = itTuple.next(); @@ -507,14 +602,16 @@ * Le parcours est fait sur le fichier "haul", c'est potentiellement * le plus petit. * - * @param project project to search into + * Used in selection ui. + * + * @param selection selection to search into * @return year list */ - public List<Integer> getProjectYears(Project project) { + public List<Integer> getProjectYears(Selection selection) { SortedSet<Integer> years = new TreeSet<Integer>(); - Iterator<String[]> itTuple = project.getHaul().iterator(); + Iterator<String[]> itTuple = selection.getHaul().iterator(); itTuple.next(); // header while (itTuple.hasNext()) { String[] tuple = itTuple.next(); @@ -539,16 +636,18 @@ /** * Get species name in project with data in [{@code beginYear}-{@code endYear}]. * - * @param project project + * Used in selection ui. + * + * @param selection selection * @param beginYear begin year * @param endYear end year * @return zones */ - public List<Specy> getProjectSpecies(Project project, Integer beginYear, Integer endYear) { + public List<Specy> getProjectSpecies(Selection selection, Integer beginYear, Integer endYear) { SortedMap<String, Specy> result = new TreeMap<String, Specy>(); - Iterator<String[]> itTuple = project.getCatch().iterator(); + Iterator<String[]> itTuple = selection.getCatch().iterator(); itTuple.next(); // skip header while (itTuple.hasNext()) { String[] tuple = itTuple.next(); @@ -581,6 +680,8 @@ * Test que le nom de la nouvelle espece existe dans le Reftax actuellement * utilisé par le projet. * + * Used in selection ui. + * * @param project project (avec reftax) * @param newSpecyName specy code to test * @return {@code true} if specy name exist @@ -605,13 +706,16 @@ /** * Fusion d'especes. * + * Used un selection ui. + * * @param project project + * @param selection selection * @param newSpecyName new specy name (after merge) * @param speciesNames species name to merge * @return project * @throws CoserBusinessException */ - public Project mergeSpecies(Project project, String newSpecyName, String... speciesNames) throws CoserBusinessException { + public Project mergeSpecies(Project project, Selection selection, String newSpecyName, String... speciesNames) throws CoserBusinessException { if (!isSpecyNameExist(project, newSpecyName)) { throw new CoserBusinessException(_("Specy %s doesn't exist in referential", newSpecyName)); @@ -620,25 +724,8 @@ MergeSpeciesCommand command = new MergeSpeciesCommand(); command.setNewSpecyName(newSpecyName); command.setSpeciesNames(speciesNames); - commandService.doAction(command, project); + commandService.doAction(command, project, selection); return project; } - - /** - * Supprime une données via son index. - * - * @param project project - * @param category category - * @param index index to delete - * @throws CoserBusinessException - */ - public void deleteData(Project project, Category category, String index) throws CoserBusinessException { - - // create new delete action - DeleteLineCommand command = new DeleteLineCommand(); - command.setCategory(category); - command.setLineIndex(index); - commandService.doAction(command, project); - } } 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ValidationService.java 2010-10-27 11:47:34 UTC (rev 106) @@ -49,7 +49,7 @@ import fr.ifremer.coser.CoserBusinessConfig; import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserConstants.ValidationLevel; -import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Control; import fr.ifremer.coser.control.ProgressMonitor; import fr.ifremer.coser.control.ValidationError; import fr.ifremer.coser.data.Catch; @@ -81,6 +81,11 @@ protected ActionContext context; + /** + * Initialise le context xworks. + * + * @param config configuration + */ public ValidationService(CoserBusinessConfig config) { this.config = config; validationSupport = new ValidationAwareSupport(); @@ -103,11 +108,18 @@ validator = container2.getInstance(ActionValidatorManager.class, "no-annotations"); } + /** + * Valide un seul bean, retourne la liste des erreurs trouvées. + * + * @param bean + * @return + */ protected List<ValidationError> validate(Object bean) { List<ValidationError> result = null; try { - // obligatoire pour les thread local + // obligatoire pour les appel dans les thread et swing EDT ActionContext.setContext(context); + for(ValidationLevel validationLevel : ValidationLevel.values()) { try { @@ -151,12 +163,12 @@ /** * Valide une category entière d'un project. * - * @param project project a valider + * @param control control a valider * @param category category a valider * @param progress progress monitor * @return les erreurs de validation */ - public List<ValidationError> validateCategory(Project project, Category category, ProgressMonitor progress) { + public List<ValidationError> validateCategory(Control control, Category category, ProgressMonitor progress) { Catch beanCatch = new Catch(); Haul beanHaul = new Haul(); @@ -166,16 +178,16 @@ DataStorage dataToCheck = null; switch (category) { case CATCH: - dataToCheck = project.getCatch(); + dataToCheck = control.getCatch(); break; case HAUL: - dataToCheck = project.getHaul(); + dataToCheck = control.getHaul(); break; case LENGTH: - dataToCheck = project.getLength(); + dataToCheck = control.getLength(); break; case STRATA: - dataToCheck = project.getStrata(); + dataToCheck = control.getStrata(); break; } Modified: trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Project-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Project-error-validation.xml 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Project-error-validation.xml 2010-10-27 11:47:34 UTC (rev 106) @@ -29,7 +29,7 @@ <field name="name"> <field-validator type="requiredstring"> <param name="trim">true</param> - <message>Project name is mandatory</message> + <message>Project name is required</message> </field-validator> </field> </validators> \ No newline at end of file Added: trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Selection-error-validation.xml =================================================================== --- trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Selection-error-validation.xml (rev 0) +++ trunk/coser-business/src/main/resources/fr/ifremer/coser/bean/Selection-error-validation.xml 2010-10-27 11:47:34 UTC (rev 106) @@ -0,0 +1,35 @@ +<!-- + #%L + Coser :: UI + + $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% + --> +<!DOCTYPE validators PUBLIC + "-//OpenSymphony Group//XWork Validator 1.0.2//EN" + "http://www.opensymphony.com/xwork/xwork-validator-1.0.2.dtd"> +<validators> + <field name="name"> + <field-validator type="requiredstring"> + <param name="trim">true</param> + <message>Selection name is required</message> + </field-validator> + </field> +</validators> \ No newline at end of file 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-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/resources/i18n/coser-business-en_GB.properties 2010-10-27 11:47:34 UTC (rev 106) @@ -1,6 +1,9 @@ Can't\ create\ project= +Can't\ find\ line\ %s\ for\ deletion= +Can't\ find\ line\ %s\ for\ undeletion= Can't\ read\ file\ '%s'.\ Check\ CSV\ file\ separator\ (%c)= Missing\ file\ %s= +Original\ line\ already\ exists\!= Project\ %s\ already\ exist= Project\ %s\ doesn't\ exists\ \!= Specy\ %s\ doesn't\ exist\ in\ referential= 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-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/main/resources/i18n/coser-business-fr_FR.properties 2010-10-27 11:47:34 UTC (rev 106) @@ -1,6 +1,9 @@ Can't\ create\ project=Impossible de cr\u00E9er le projet +Can't\ find\ line\ %s\ for\ deletion= +Can't\ find\ line\ %s\ for\ undeletion= Can't\ read\ file\ '%s'.\ Check\ CSV\ file\ separator\ (%c)=Impossible de lire le fichier '%s'.\nMerci de v\u00E9rifier le s\u00E9parateur utilis\u00E9 (%c). Missing\ file\ %s=Fichier manquant \: %s +Original\ line\ already\ exists\!= Project\ %s\ already\ exist=Le projet %s existe d\u00E9j\u00E0 \! Project\ %s\ doesn't\ exists\ \!=Le projet %s n'existe pas \! Specy\ %s\ doesn't\ exist\ in\ referential= Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CommandServiceTest.java 2010-10-27 11:47:34 UTC (rev 106) @@ -34,6 +34,7 @@ import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.bean.Project; import fr.ifremer.coser.command.DeleteLineCommand; +import fr.ifremer.coser.data.Length; /** * CommandService tests @@ -63,14 +64,14 @@ @Test public void testDeleteLine() throws CoserBusinessException { Project project = createTestProject(projectService); - Assert.assertEquals(29, project.getLength().size()); + Assert.assertEquals(29, project.getControl().getLength().size()); DeleteLineCommand command = new DeleteLineCommand(); command.setLineIndex("2"); command.setCategory(Category.LENGTH); - commandService.doAction(command, project); - Assert.assertEquals(28, project.getLength().size()); + commandService.doAction(command, project, project.getControl()); + Assert.assertEquals(28, project.getControl().getLength().size()); } /** @@ -84,8 +85,8 @@ DeleteLineCommand command = new DeleteLineCommand(); command.setLineIndex("2"); command.setCategory(Category.LENGTH); - commandService.doAction(command, project); - commandService.doAction(command, project); + commandService.doAction(command, project, project.getControl()); + commandService.doAction(command, project, project.getControl()); } /** @@ -97,18 +98,16 @@ @Test public void testDeleteLineUndo() throws CoserBusinessException { Project project = createTestProject(projectService); - Assert.assertEquals("3", project.getLength().get(4)[0]); + Assert.assertEquals("3", project.getControl().getLength().get(4)[Length.INDEX_LINE]); 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]); + commandService.doAction(command, project, project.getControl()); + Assert.assertEquals("4", project.getControl().getLength().get(4)[Length.INDEX_LINE]); + commandService.undoAction(project, project.getControl()); + Assert.assertEquals("3", project.getControl().getLength().get(4)[Length.INDEX_LINE]); } } 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 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/CoserTestAbstract.java 2010-10-27 11:47:34 UTC (rev 106) @@ -71,10 +71,10 @@ @AfterClass public static void cleanDirectory() throws IOException { - //FileUtils.deleteDirectory(testDirectory); + FileUtils.deleteDirectory(testDirectory); } - protected Project createTestProject(ProjectService service) throws CoserBusinessException { + protected Project createTestProject(ProjectService projectService) throws CoserBusinessException { Project project = new Project(); project.setName("Project-" + System.nanoTime()); @@ -92,8 +92,13 @@ categoriesAndFile.put(Category.STRATA, testStrata); categoriesAndFile.put(Category.REFTAX_SPECIES, testReftax); - project = service.createProject(project, categoriesAndFile); + project = projectService.createProject(project, categoriesAndFile); + project = projectService.loadControlData(project); + // sans la sauvegarde des données de control, on ne pas creer de + // selection + projectService.saveProjectControl(project); + if (log.isDebugEnabled()) { log.debug("Created project : " + project.getName()); } Modified: trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java =================================================================== --- trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-business/src/test/java/fr/ifremer/coser/services/ProjectServiceTest.java 2010-10-27 11:47:34 UTC (rev 106) @@ -36,6 +36,7 @@ import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserConstants; import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.bean.Specy; /** @@ -112,8 +113,9 @@ @Test public void testProjectYear() throws CoserBusinessException { Project project = createTestProject(service); - - List<Integer> years = service.getProjectYears(project); + Selection selection = service.createProjectSelection(project); + + List<Integer> years = service.getProjectYears(selection); Assert.assertEquals(2, years.size()); Assert.assertEquals(Integer.valueOf(2010), years.get(0)); Assert.assertEquals(Integer.valueOf(2011), years.get(1)); @@ -127,14 +129,15 @@ @Test public void testProjectZone() throws CoserBusinessException { Project project = createTestProject(service); - - List<String> zones = service.getProjectZone(project, 2010, 2011); + Selection selection = service.createProjectSelection(project); + + List<String> zones = service.getProjectZone(selection, 2010, 2011); Assert.assertEquals(6, zones.size()); - zones = service.getProjectZone(project, 2011, 2011); + zones = service.getProjectZone(selection, 2011, 2011); Assert.assertEquals(3, zones.size()); - zones = service.getProjectZone(project, 2009, 2009); + zones = service.getProjectZone(selection, 2009, 2009); Assert.assertEquals(0, zones.size()); } @@ -146,14 +149,15 @@ @Test public void testProjectSpecies() throws CoserBusinessException { Project project = createTestProject(service); + Selection selection = service.createProjectSelection(project); - List<Specy> species = service.getProjectSpecies(project, 2010, 2011); + List<Specy> species = service.getProjectSpecies(selection, 2010, 2011); Assert.assertEquals(4, species.size()); - species = service.getProjectSpecies(project, 2011, 2011); + species = service.getProjectSpecies(selection, 2011, 2011); Assert.assertEquals(4, species.size()); - species = service.getProjectSpecies(project, 2009, 2009); + species = service.getProjectSpecies(selection, 2009, 2009); Assert.assertEquals(0, species.size()); } @@ -165,12 +169,13 @@ @Test public void testMergeSpecies() throws CoserBusinessException { Project project = createTestProject(service); + Selection selection = service.createProjectSelection(project); Assert.assertTrue(service.isSpecyNameExist(project, "COSER_SPECIES_MERGE")); - Assert.assertEquals(25, project.getCatch().size()); + Assert.assertEquals(25, selection.getCatch().size()); - project = service.mergeSpecies(project, "COSER_SPECIES_MERGE", "COSER_SPECIES1", "COSER_SPECIES2"); + project = service.mergeSpecies(project, selection, "COSER_SPECIES_MERGE", "COSER_SPECIES1", "COSER_SPECIES2"); - Assert.assertEquals(19, project.getCatch().size()); + Assert.assertEquals(19, selection.getCatch().size()); } } Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2010-10-27 11:47:34 UTC (rev 106) @@ -120,9 +120,8 @@ } } - DefaultApplicationContext context = new DefaultApplicationContext(); - // define unique context globale values + DefaultApplicationContext context = new DefaultApplicationContext(); context.setContextValue(coserConfig); context.setContextValue(new ProjectService(coserConfig)); context.setContextValue(new ImportService(coserConfig)); Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrame.jaxx 2010-10-27 11:47:34 UTC (rev 106) @@ -40,7 +40,7 @@ </JMenu> <JMenu id='menuWindow' text="coser.ui.mainframe.menu.window"> - <JMenuItem text="coser.ui.mainframe.menu.window.validation" onActionPerformed="getHandler().showValidationView()"/> + <JMenuItem text="coser.ui.mainframe.menu.window.validation" onActionPerformed="getHandler().showControlView()"/> <SelectionsListMenuItem text="coser.ui.mainframe.menu.window.selection" constructorParams="this" /> </JMenu> 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 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-10-27 11:47:34 UTC (rev 106) @@ -57,6 +57,7 @@ import fr.ifremer.coser.CoserConstants.Category; import fr.ifremer.coser.CoserException; import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.data.Catch; import fr.ifremer.coser.services.ProjectService; import fr.ifremer.coser.ui.control.ControlHandler; @@ -261,7 +262,7 @@ Project project = get(); if (project != null) { view.setContextValue(project); - showValidationView(); + showControlView(false); } } catch (Exception ex) { throw new CoserException("Can't create project", ex); @@ -289,7 +290,7 @@ ProjectService projectService = projectView.getContextValue(ProjectService.class); Project project = null; try { - Project p = projectService.loadProject(projectName); + Project p = projectService.openProject(projectName); project = p; } catch (CoserBusinessException ex) { if (log.isErrorEnabled()) { @@ -312,7 +313,7 @@ Project project = get(); if (project != null) { view.setContextValue(project); - showValidationView(); + showControlView(); } } catch (Exception ex) { throw new CoserException("Can't create project", ex); @@ -322,29 +323,66 @@ task.execute(); } - public void showValidationView() { - ControlView controlView = new ControlView(view); - controlView.setHandler(new ControlHandler()); - setMainComponent(controlView); + /** + * Charge les données de control et affiche la vue de control. + */ + public void showControlView() { + showControlView(true); } /** + * Charge les données de control et affiche la vue de control. + * + * @param reloadData reload data (a {@code false} dans le cas d'une creation, + * les données sont deja chargées) + */ + public void showControlView(boolean reloadData) { + // load control + ProjectService projectService = view.getContextValue(ProjectService.class); + Project project = view.getContextValue(Project.class); + try { + + if (reloadData) { + project = projectService.loadControlData(project); + } + + ControlView controlView = new ControlView(view); + controlView.setHandler(new ControlHandler()); + setMainComponent(controlView); + } catch (CoserBusinessException ex) { + throw new CoserException("Can't load control data", ex); + } + } + + /** * Show selection view to create new selection. */ public void showSelectionView() { - SelectionView selectionView = new SelectionView(view); - SelectionHandler selectionHandler = new SelectionHandler(); - selectionView.setHandler(selectionHandler); - + + // create new selection + ProjectService projectService = view.getContextValue(ProjectService.class); + Project project = view.getContextValue(Project.class); try { - File file = new File("/home/chatellier/tmp/coser/zones.png"); - ImageIcon icon = new ImageIcon(file.toURI().toURL()); - selectionView.getSelectionDetailsTab().getZonesMap().setIcon(icon); + Selection selection = projectService.createProjectSelection(project); + view.setContextValue(selection); - } catch(Exception e){ - e.printStackTrace(); - }; - setMainComponent(selectionView); + SelectionView selectionView = new SelectionView(view); + selectionView.setSelection(selection); + selectionView.getSelectionDetailsTab().getValidatorSelection().setBean(selection); + selectionView.setHandler(new SelectionHandler()); + + try { + File file = new File("/home/chatellier/tmp/coser/zones.png"); + ImageIcon icon = new ImageIcon(file.toURI().toURL()); + selectionView.getSelectionDetailsTab().getZonesMap().setIcon(icon); + + } catch(Exception e){ + e.printStackTrace(); + }; + setMainComponent(selectionView); + } catch (CoserBusinessException ex) { + throw new CoserException("Can't create new selection", ex); + } } /** Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ProjectCreationView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ProjectCreationView.jaxx 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ProjectCreationView.jaxx 2010-10-27 11:47:34 UTC (rev 106) @@ -25,6 +25,7 @@ <Table> <CoserFrameHandler id="handler" javaBean="null" /> + <!-- Validation --> <fr.ifremer.coser.bean.Project id="project" /> <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' onTableChanged='createProjectButton.setEnabled(errorsTableModel.getRowCount()==0)'/> 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 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2010-10-27 11:47:34 UTC (rev 106) @@ -58,13 +58,13 @@ switch (category) { case CATCH: - data = project.getCatch(); break; + data = project.getControl().getCatch(); break; case HAUL: - data = project.getHaul(); break; + data = project.getControl().getHaul(); break; case LENGTH: - data = project.getLength(); break; + data = project.getControl().getLength(); break; case STRATA: - data = project.getStrata(); break; + data = project.getControl().getStrata(); break; } header = data.get(0); fireTableStructureChanged(); 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 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2010-10-27 11:47:34 UTC (rev 106) @@ -149,7 +149,7 @@ final ValidationService validationService = view.getContextValue(ValidationService.class); final Project project = view.getContextValue(Project.class); final Category category = (Category)view.getCategoryComboBox().getSelectedItem(); - final ControlProgressBar bar = view.getCheckProgressBar(); + final ControlProgressBar progressBar = view.getCheckProgressBar(); SwingWorker<List<ValidationError>, Void> task = new SwingWorker<List<ValidationError>, Void>() { @@ -158,7 +158,7 @@ @Override public List<ValidationError> doInBackground() { - List<ValidationError> validationErrors = validationService.validateCategory(project, category, bar); + List<ValidationError> validationErrors = validationService.validateCategory(project.getControl(), category, progressBar); return validationErrors; } @@ -191,9 +191,10 @@ } /** - * Called when selection change. + * Called when selection change to display selected bean + * in edition panel. * - * @param view + * @param view view */ public void controlDataTableSelectionChanged(ControlView view) { @@ -209,20 +210,20 @@ switch(category) { case CATCH: // warning, skip header - header = project.getCatch().get(0); - line = project.getCatch().get(selectedRow + 1); + header = project.getControl().getCatch().get(0); + line = project.getControl().getCatch().get(selectedRow + 1); break; case HAUL: - header = project.getHaul().get(0); - line = project.getHaul().get(selectedRow + 1); + header = project.getControl().getHaul().get(0); + line = project.getControl().getHaul().get(selectedRow + 1); break; case LENGTH: - header = project.getLength().get(0); - line = project.getLength().get(selectedRow + 1); + header = project.getControl().getLength().get(0); + line = project.getControl().getLength().get(selectedRow + 1); break; case STRATA: - header = project.getStrata().get(0); - line = project.getStrata().get(selectedRow + 1); + header = project.getControl().getStrata().get(0); + line = project.getControl().getStrata().get(selectedRow + 1); break; } @@ -440,25 +441,25 @@ case CATCH: Catch beanCatch = view.getValidatorCatch().getBean(); data = beanCatch.getData(); - project.getCatch().set(selectedLine + 1, data); // csv header + project.getControl().getCatch().set(selectedLine + 1, data); // csv header model.fireTableRowsUpdated(selectedLine, selectedLine); break; case HAUL: Haul beanHaul = view.getValidatorHaul().getBean(); data = beanHaul.getData(); - project.getHaul().set(selectedLine + 1, data); // csv header + project.getControl().getHaul().set(selectedLine + 1, data); // csv header model.fireTableRowsUpdated(selectedLine, selectedLine); break; case LENGTH: Length beanLength = view.getValidatorLength().getBean(); data = beanLength.getData(); - project.getLength().set(selectedLine + 1, data); // csv header + project.getControl().getLength().set(selectedLine + 1, data); // csv header model.fireTableRowsUpdated(selectedLine, selectedLine); break; case STRATA: Strata beanStrata = view.getValidatorStrata().getBean(); data = beanStrata.getData(); - project.getStrata().set(selectedLine + 1, data); // csv header + project.getControl().getStrata().set(selectedLine + 1, data); // csv header model.fireTableRowsUpdated(selectedLine, selectedLine); break; } @@ -495,7 +496,7 @@ String[] data = model.getDataAt(selectedLine); try { - projectService.deleteData(project, category, data[AbstractDataEntity.INDEX_LINE]); + projectService.deleteData(project, project.getControl(), category, data[AbstractDataEntity.INDEX_LINE]); model.fireTableRowsDeleted(selectedLine, selectedLine); } catch (CoserBusinessException 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 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2010-10-27 11:47:34 UTC (rev 106) @@ -88,10 +88,10 @@ <cell fill="both" weightx="1" weighty="2" columns="2"> <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' onTableChanged='saveButton.setEnabled(errorsTableModel.getRowCount()==0)'/> - <fr.ifremer.coser.bean.Catch id="beanCatch" javaBean="null" /> - <fr.ifremer.coser.bean.Haul id="beanHaul" javaBean="null" /> - <fr.ifremer.coser.bean.Strata id="beanStrata" javaBean="null" /> - <fr.ifremer.coser.bean.Length id="beanLength" javaBean="null" /> + <fr.ifremer.coser.data.Catch id="beanCatch" javaBean="null" /> + <fr.ifremer.coser.data.Haul id="beanHaul" javaBean="null" /> + <fr.ifremer.coser.data.Strata id="beanStrata" javaBean="null" /> + <fr.ifremer.coser.data.Length id="beanLength" javaBean="null" /> <BeanValidator id='validatorCatch' bean='beanCatch' uiClass="jaxx.runtime.validator.swing.ui.TranslucentValidationUI" errorTableModel="errorsTableModel" /> Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2010-10-27 11:47:34 UTC (rev 106) @@ -23,7 +23,19 @@ #L% --> <Table> + <SelectionHandler id="handler" javaBean="null" /> + + <!-- Validation --> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> + <jaxx.runtime.validator.swing.SwingValidatorMessageTableModel id='errorsTableModel' + onTableChanged='saveSelectionButton.setEnabled(errorsTableModel.getRowCount()==0)'/> + <BeanValidator id='validatorSelection' bean='selection' + uiClass="jaxx.runtime.validator.swing.ui.ImageValidationUI" + errorTableModel="errorsTableModel"> + <field name="name" component="selectionDetailsSelecionNameField" /> + </BeanValidator> + <row> <cell weightx="1" weighty="1" fill="both"> <Table> @@ -32,7 +44,10 @@ <JLabel text="coser.ui.selection.details.name" /> </cell> <cell weightx="1" fill="horizontal" columns="3"> - <JTextField id="selectionDetailsSelecionNameField" /> + <JTextField id="selectionDetailsSelecionNameField" text="{selection.getName()}" /> + <javax.swing.text.Document javaBean="selectionDetailsSelecionNameField.getDocument()" + onInsertUpdate='getSelection().setName(selectionDetailsSelecionNameField.getText())' + onRemoveUpdate='getSelection().setName(selectionDetailsSelecionNameField.getText())' /> </cell> </row> <row> @@ -125,7 +140,8 @@ </row> <row> <cell fill="horizontal" columns="4"> - <JButton text="coser.ui.selection.details.saveSelection" onActionPerformed="getHandler().saveSelection(this)" /> + <JButton id="saveSelectionButton" text="coser.ui.selection.details.saveSelection" + onActionPerformed="getHandler().saveSelection(this)" /> </cell> </row> </Table> 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-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2010-10-27 11:47:34 UTC (rev 106) @@ -44,6 +44,7 @@ import fr.ifremer.coser.CoserBusinessException; import fr.ifremer.coser.CoserException; import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.bean.Specy; import fr.ifremer.coser.services.ProjectService; @@ -77,7 +78,8 @@ * @param view view */ public void updateSelectionZone(SelectionDetailsView view) { - Project project = view.getContextValue(Project.class); + //Project project = view.getContextValue(Project.class); + Selection seletion = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); Integer beginYear = (Integer)view.getSelectionDetailsBeginYearField().getSelectedItem(); @@ -85,7 +87,7 @@ // il est possible que l'evenement fasse suite a une seule des selections if (beginYear != null && endYear != null) { - List<String> zone = projectService.getProjectZone(project, beginYear, endYear); + List<String> zone = projectService.getProjectZone(seletion, beginYear, endYear); view.getSelectionZoneModel().setZones(zone); } } @@ -96,7 +98,8 @@ * @param view view */ public void updateSelectionSpecies(SelectionDetailsView view) { - Project project = view.getContextValue(Project.class); + //Project project = view.getContextValue(Project.class); + Selection seletion = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); Integer beginYear = (Integer)view.getSelectionDetailsBeginYearField().getSelectedItem(); @@ -104,7 +107,7 @@ // il est possible que l'evenement fasse suite a une seule des selections if (beginYear != null && endYear != null) { - List<Specy> species = projectService.getProjectSpecies(project, beginYear, endYear); + List<Specy> species = projectService.getProjectSpecies(seletion, beginYear, endYear); view.getSpecyListModel().setSpecy(species); } } @@ -163,15 +166,15 @@ * @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); + Selection seletion = view.getContextValue(Selection.class); ProjectService service = view.getContextValue(ProjectService.class); try { - service.saveProjectSelection(project, selectionName); + service.saveProjectSelection(project, seletion); } catch (CoserBusinessException ex) { throw new CoserException("Can't save selection", ex); @@ -206,6 +209,7 @@ String newSpecyName = view.getNewSpeciesNameField().getText(); Project project = view.getContextValue(Project.class); + Selection seletion = view.getContextValue(Selection.class); ProjectService projectService = view.getContextValue(ProjectService.class); boolean newSpecyExist = projectService.isSpecyNameExist(project, newSpecyName); @@ -224,7 +228,7 @@ } try { - projectService.mergeSpecies(project, newSpecyName, specyNames); + projectService.mergeSpecies(project, seletion, newSpecyName, specyNames); } catch (CoserBusinessException ex) { throw new CoserException("Can't merge species", ex); 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-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionView.jaxx 2010-10-27 11:47:34 UTC (rev 106) @@ -23,6 +23,8 @@ #L% --> <JTabbedPane> + <fr.ifremer.coser.bean.Selection id="selection" javaBean="null" /> + <SelectionHandler id="handler" javaBean="null" /> <script><![CDATA[ void $afterCompleteSetup() { @@ -35,12 +37,15 @@ } ]]></script> <tab title="coser.ui.selection.tab.details"> - <SelectionDetailsView id="selectionDetailsTab" constructorParams="this" handler="{getHandler()}" /> + <SelectionDetailsView id="selectionDetailsTab" constructorParams="this" + handler="{getHandler()}" selection="{getSelection()}"/> </tab> <tab title="coser.ui.selection.tab.lists" enabled="false"> - <SelectionListsView id="selectionListsView" constructorParams="this" handler="{getHandler()}" /> + <SelectionListsView id="selectionListsView" constructorParams="this" + handler="{getHandler()}" /> </tab> <tab title="coser.ui.selection.tab.result" enabled="false"> - <SelectionResultView id="selectionResultView" constructorParams="this" handler="{getHandler()}" /> + <SelectionResultView id="selectionResultView" constructorParams="this" + handler="{getHandler()}" /> </tab> </JTabbedPane> 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-26 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/YearComboBoxModel.java 2010-10-27 11:47:34 UTC (rev 106) @@ -30,7 +30,7 @@ import javax.swing.AbstractListModel; import javax.swing.ComboBoxModel; -import fr.ifremer.coser.bean.Project; +import fr.ifremer.coser.bean.Selection; import fr.ifremer.coser.services.ProjectService; /** @@ -60,9 +60,9 @@ protected List<Integer> getYear() { if (years == null) { - Project project = view.getContextValue(Project.class); + Selection selection = view.getContextValue(Selection.class); ProjectService service = view.getContextValue(ProjectService.class); - years = service.getProjectYears(project); + years = service.getProjectYears(selection); } return years; } 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 14:16:24 UTC (rev 105) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui-en_GB.properties 2010-10-27 11:47:34 UTC (rev 106) @@ -63,6 +63,7 @@ coser.ui.project.traitsFile=Traits file \: coser.ui.project.useCustomReferenceSpeciesFile= coser.ui.project.usedReferenceSpeciesFile= +coser.ui.result.availableDataTitle= coser.ui.result.extractDataButton= coser.ui.result.extractDataLabel= coser.ui.result.extractDataTitle= Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-10-26 14:16:24 UTC (rev 105) +++ trunk/pom.xml 2010-10-27 11:47:34 UTC (rev 106) @@ -196,7 +196,7 @@ <license.organizationName>Ifremer, Codelutin</license.organizationName> <!-- Versions --> - <jaxx.version>2.2.3</jaxx.version> + <jaxx.version>2.2.4-SNAPSHOT</jaxx.version> <i18n.version>1.2.2</i18n.version> </properties> @@ -236,7 +236,7 @@ <artifactId>maven-javadoc-plugin</artifactId> <configuration> <links> - <link>http://java.sun.com/javase/6/docs/api/</link> + <link>http://download.oracle.com/javase/6/docs/api/</link> </links> </configuration> </plugin>