Isis-fish-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
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- 3175 discussions
r1299 - branches/isis-fish-3.1.4/src/resources
by bpoussin@users.labs.libre-entreprise.org 14 Aug '08
by bpoussin@users.labs.libre-entreprise.org 14 Aug '08
14 Aug '08
Author: bpoussin
Date: 2008-08-14 14:58:23 +0000 (Thu, 14 Aug 2008)
New Revision: 1299
Modified:
branches/isis-fish-3.1.4/src/resources/IsisFish_init.properties
Log:
montre par defaut toutes les simulations terminees
Modified: branches/isis-fish-3.1.4/src/resources/IsisFish_init.properties
===================================================================
--- branches/isis-fish-3.1.4/src/resources/IsisFish_init.properties 2008-08-14 14:55:00 UTC (rev 1298)
+++ branches/isis-fish-3.1.4/src/resources/IsisFish_init.properties 2008-08-14 14:58:23 UTC (rev 1299)
@@ -21,7 +21,7 @@
###
-### les propriétés de la configuration principal obligatoires pour commandline
+### les propri\u00E9t\u00E9s de la configuration principal obligatoires pour commandline
###
#main.config.definition.configFileName=java.io.File:.isis-config-3
@@ -40,7 +40,7 @@
#main.config.modifiers.version=final,static,mandatory
###
-### les propriétés de la configuration principal
+### les propri\u00E9t\u00E9s de la configuration principal
###
main.config.definition.compileDirectory=java.io.File:isis-build
@@ -103,10 +103,10 @@
main.config.definition.simulationServer=java.net.URL:http://simulateur.ifremer.fr:9090
main.config.modifiers.simulationServer=mandatory
-main.config.definition.simulationShowOnlyError=java.lang.Boolean:true
+main.config.definition.simulationShowOnlyError=java.lang.Boolean:false
main.config.modifiers.simulationShowOnlyError=
-main.config.definition.simulationShowOnlyQueue=java.lang.Boolean:true
+main.config.definition.simulationShowOnlyQueue=java.lang.Boolean:false
main.config.modifiers.simulationShowOnlyQueue=
main.config.definition.smtpServer=java.lang.String:smtp
@@ -120,7 +120,7 @@
###
-### les propriétés de la configuration vcs
+### les propri\u00E9t\u00E9s de la configuration vcs
###
vcs.config.definition.localDatabasePath=java.io.File:isis-database-3
vcs.config.modifiers.localDatabasePath=mandatory
@@ -168,7 +168,7 @@
vcs.config.modifiers.userName=mandatory
###
-### les propriétés de la configuration h2
+### les propri\u00E9t\u00E9s de la configuration h2
###
# On utilise pas cglib pour eviter les OutOfMemory: PermGen
h2.config.definition.h2BytecodeProvider=java.lang.String:javassist
@@ -258,5 +258,5 @@
h2.config.definition.storageData=java.lang.String:data
h2.config.modifiers.storageData=final,mandatory,static,transient
-h2.config.definition.updateschemaDatabase=java.lang.Boolean:false
+h2.config.definition.updateschemaDatabase=java.lang.Boolean:true
h2.config.modifiers.updateschemaDatabase=final,mandatory,static,transient
1
0
r1298 - in trunk/isis-fish/src/java/fr/ifremer/isisfish: . actions datastore ui vcs
by bpoussin@users.labs.libre-entreprise.org 14 Aug '08
by bpoussin@users.labs.libre-entreprise.org 14 Aug '08
14 Aug '08
Author: bpoussin
Date: 2008-08-14 14:55:00 +0000 (Thu, 14 Aug 2008)
New Revision: 1298
Added:
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ExportAction.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ImportAction.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/SimulationAction.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/VCSAction.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java
Modified:
trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/ui/Welcome.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java
trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/package.html
Log:
refactoring du vcs en cours
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -27,7 +27,7 @@
import fr.ifremer.isisfish.actions.SimulationAction;
import fr.ifremer.isisfish.actions.VCSAction;
import fr.ifremer.isisfish.simulator.SimulationContext;
-import fr.ifremer.isisfish.vcs.VCS;
+import fr.ifremer.isisfish.vcs.VCSNone;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
@@ -186,7 +186,7 @@
// public boolean isUseVCS() {
// String value = getOption(Option.VCS_TYPE.key);
-// boolean result = !VCS.TYPE_NONE.equals(value);
+// boolean result = !VCSNone.TYPE_NONE.equals(value);
// return result;
// }
@@ -439,14 +439,14 @@
SSH_PASSPHRASE("ssh.passphrase", _("isisfish.config.vcs.passphrase.description"), ""),
// can be None, CVS or SVN. only None or SVN work
- VCS_TYPE(VCS.VCS_TYPE, _("isisfish.config.vcs.type.description"), VCS.TYPE_SVN),
+ VCS_TYPE(VCSNone.VCS_TYPE, _("isisfish.config.vcs.type.description"), VCSNone.TYPE_SVN),
// depend of VCS_TYPE, for SVN can be http or ssh
- VCS_CONNECTION(VCS.VCS_CONNECTION, _("isisfish.config.vcs.useSshConnexion.description"), "http"),
+ VCS_CONNECTION(VCSNone.VCS_CONNECTION, _("isisfish.config.vcs.useSshConnexion.description"), "http"),
// user login to access vcs
- VCS_USER_NAME(VCS.VCS_USER_NAME, _("isisfish.config.vcs.userName.description"), "anonymous"),
- VCS_HOST_NAME(VCS.VCS_HOST_NAME, _("isisfish.config.vcs.hostName.description"), "labs.libre-entreprise.org"),
- VCS_PATH(VCS.VCS_PATH, _("isisfish.config.vcs.remotePath.description"), "svnroot/isis-fish-data"),
- VCS_TAG(VCS.VCS_TAG, _("isisfish.config.vcs.remoteDatabase.description"), "tag/" + VERSION_DATABASE),
+ VCS_USER_NAME(VCSNone.VCS_USER_NAME, _("isisfish.config.vcs.userName.description"), "anonymous"),
+ VCS_HOST_NAME(VCSNone.VCS_HOST_NAME, _("isisfish.config.vcs.hostName.description"), "labs.libre-entreprise.org"),
+ VCS_PATH(VCSNone.VCS_PATH, _("isisfish.config.vcs.remotePath.description"), "svnroot/isis-fish-data"),
+ VCS_TAG(VCSNone.VCS_TAG, _("isisfish.config.vcs.remoteDatabase.description"), "tag/" + VERSION_DATABASE),
// TYPE_REPO_PROPERTY_KEY = newConfigPropertyKey("typeRepo", VCSTypeRepo.class, 9, n_("isisfish.config.vcs.typeRepo.description"), "TAG"),
// PROJECT_NAME_PROPERTY_KEY = newConfigPropertyKey("projectName", String.class, 11, n_("isisfish.config.main.projectName.description"), "Isis-Fish"),
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -49,7 +49,7 @@
import fr.ifremer.isisfish.util.RangeOfValuesConverter;
import fr.ifremer.isisfish.util.StringConverter;
import fr.ifremer.isisfish.util.TimeUnitConverter;
-import fr.ifremer.isisfish.vcs.VCS;
+import fr.ifremer.isisfish.vcs.VCSNone;
import java.io.File;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.logging.LogFactory;
@@ -92,7 +92,7 @@
static public IsisConfig config = null;
static public int step = 0; // action step
- static public VCS vcs = null;
+ static public VCSNone vcs = null;
static public Context uiContext = null;
static protected boolean quit = false;
@@ -250,12 +250,12 @@
}
/**
- * Initialise le VCS et check s'il y a des mises a jour pour prevenir
+ * Initialise le VCSNone et check s'il y a des mises a jour pour prevenir
* l'utilisateur
*/
static public void initVCS() {
// init vcs
- vcs = VCS.createVCS(config);
+ vcs = VCSNone.createVCS(config);
// check connection status
vcs.checkConnection();
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ExportAction.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ExportAction.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ExportAction.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,248 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.actions;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
+import fr.ifremer.isisfish.datastore.DataStorage;
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+import fr.ifremer.isisfish.ui.ScriptActionHelper;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Pattern;
+import static org.codelutin.i18n.I18nf._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.FileUtil;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ExportAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ExportAction.class);
+
+ protected IsisConfig config = null;
+
+ public ExportAction(IsisConfig config) {
+ this.config = config;
+ }
+
+ public void applyFilter(String filter, List<String> names) {
+ if (filter != null && !"*".equals(filter)) {
+ Pattern p = Pattern.compile(filter);
+ // apply filter on names found
+ for (Iterator<String> i=names.iterator(); i.hasNext();) {
+ String name = i.next();
+ if (!p.matcher(name).matches()) {
+ i.remove();
+ }
+ }
+ }
+ }
+
+ public void display(String filter, List<String> names) {
+ StringBuilder sb = new StringBuilder();
+ sb.append(" found ").append(names.size());
+ sb.append(" with filter ").append(filter);
+ sb.append(" in IsisFish");
+ for (String name : names) {
+ sb.append("\n").append(name);
+ }
+ System.out.println(sb.toString());
+ }
+
+ public void listAnalysePlan(String filter) throws Exception {
+ List<String> names = AnalysePlanStorage.getAnalysePlanNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listExport(String filter) throws Exception {
+ List<String> names = ExportStorage.getExportNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listRule(String filter) throws Exception {
+ List<String> names = RuleStorage.getRuleNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listScript(String filter) throws Exception {
+ List<String> names = ScriptStorage.getScriptNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listRegion(String filter) throws Exception {
+ List<String> names = RegionStorage.getRegionNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listSimulation(String filter) throws Exception {
+ List<String> names = SimulationStorage.getSimulationNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listSimulator(String filter) throws Exception {
+ List<String> names = SimulatorStorage.getSimulatorNames();
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ public void listFormula(String filter) throws Exception {
+ List<String> names = new ArrayList<String>();
+ for (String name : FormuleStorage.getCategories()) {
+ names.addAll(FormuleStorage.getFormuleNames(name));
+ }
+ applyFilter(filter, names);
+ display(filter, names);
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ //
+ // E X P O R T
+ //
+ //////////////////////////////////////////////////////////////////////////
+
+ public void exportRegion(File file, String name, boolean force) throws Exception {
+ log.info("file:" + file + ", name:" + name);
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+
+ if (!RegionStorage.exists(name)) {
+ // fatal error
+ throw new IllegalArgumentException(_("could not found region %s", name));
+ }
+ DataStorage data = RegionStorage.getRegion(name);
+ if (data != null) {
+ data.createZip(file);
+ }
+ }
+
+ public void exportSimulation(File file, String name, boolean force) throws Exception {
+ log.info("file:" + file + ", name:" + name);
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+
+ if (!SimulationStorage.exists(name)) {
+ // fatal error
+ throw new IllegalArgumentException(_("could not found simulation %s", name));
+ }
+ DataStorage data = SimulationStorage.getSimulation(name);
+ if (data != null) {
+ data.createZip(file);
+ }
+ }
+
+ public void exportAnalysePlan(File file, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ AnalysePlanStorage storage = AnalysePlanStorage.getAnalysePlan(name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+ public void exportRule(File file, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ RuleStorage storage = RuleStorage.getRule(name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+ public void exportScript(File file, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ ScriptStorage storage = ScriptStorage.getScript(name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+ public void exportExport(File file, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ ExportStorage storage = ExportStorage.getExport(name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+ public void exportSimulator(File file, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ SimulatorStorage storage = SimulatorStorage.getSimulator(name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+ public void exportFormula(File file, String category, String name, boolean force) throws Exception {
+ if (!force && file.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use 'force' argument to force overwrite", file));
+ }
+ FormuleStorage storage = FormuleStorage.getFormule(category, name);
+ if (!storage.exists()) {
+ throw new IllegalArgumentException(_("could not found %s", name));
+ }
+ String content = storage.getContent();
+ FileUtil.writeString(file, content);
+ }
+
+}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ImportAction.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ImportAction.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/ImportAction.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,169 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.actions;
+
+import static org.codelutin.i18n.I18nf._;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
+import fr.ifremer.isisfish.datastore.ExportStorage;
+import fr.ifremer.isisfish.datastore.FormuleStorage;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.datastore.SimulatorStorage;
+import fr.ifremer.isisfish.ui.ScriptActionHelper;
+import java.io.File;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.FileUtil;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class ImportAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ImportAction.class);
+
+ protected IsisConfig config = null;
+
+ public ImportAction(IsisConfig config) {
+ this.config = config;
+ }
+
+ public void importAnalysePlan(boolean force, File file) throws Exception {
+ String name = file.getName();
+ AnalysePlanStorage storage = AnalysePlanStorage.getAnalysePlan(name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ public void importExport(boolean force, File file) throws Exception {
+ String name = file.getName();
+ ExportStorage storage = ExportStorage.getExport(name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ public void importRule(boolean force, File file) throws Exception {
+ String name = file.getName();
+ RuleStorage storage = RuleStorage.getRule(name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ public void importScript(boolean force, File file) throws Exception {
+ String name = file.getName();
+ ScriptStorage storage = ScriptStorage.getScript(name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ public void importSimulator(boolean force, File file) throws Exception {
+ String name = file.getName();
+ SimulatorStorage storage = SimulatorStorage.getSimulator(name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ public void importFormula(boolean force, String formulaType, File file) throws Exception {
+ if (!FormuleStorage.getCategories().contains(formulaType)) {
+ throw new IllegalArgumentException(_("Could not found formule type %s autorised type are %s", formulaType, FormuleStorage.getCategories()));
+ }
+ String name = file.getName();
+ FormuleStorage storage = FormuleStorage.getFormule(formulaType, name);
+ if(!force && storage.exists()) {
+ throw new IllegalArgumentException(_("destination already exists %s use \'force\' argument to force overwrite", storage.getFile()));
+ }
+ String content = FileUtil.readAsString(file);
+ storage.setContent(content);
+ }
+
+ /**
+ *
+ * @param file zip file containing data
+ * @param force
+ * @throws java.lang.Exception
+ */
+ public void importRegion(boolean force, File file) throws Exception {
+ //TODO test if region exists
+ RegionStorage.importZip(file);
+ }
+
+ /**
+ *
+ * @param file zip file containing data
+ * @param name new region name
+ * @param force
+ * @throws java.lang.Exception
+ */
+ public void importRegionAndRename(boolean force, File file, String name) throws Exception {
+ if (RegionStorage.exists(name) && !force) {
+ // fatal error
+ throw new IllegalArgumentException(_("region already exists %s use 'force' argument to force overwrite", name));
+ }
+ RegionStorage.importAndRenameZip(file, name);
+ }
+
+ /**
+ *
+ * @param file zip file containing data
+ * @param force
+ * @throws java.lang.Exception
+ */
+ public void importSimulation(boolean force, File file) throws Exception {
+ //TODO test if simulation exists
+ SimulationStorage.importZip(file);
+ }
+
+ /**
+ * Import zipped file containing all directory structure
+ *
+ * @param file zip file containing data
+ * @param force
+ * @throws java.lang.Exception
+ */
+ public void importScriptModule(boolean force, File file) throws Exception {
+ ScriptActionHelper.importScript(file, force, false, null);
+ }
+
+}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/OtherAction.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,62 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.actions;
+
+import static org.codelutin.i18n.I18nf._;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.vcs.VCSNone;
+import java.io.File;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class OtherAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(OtherAction.class);
+
+ protected IsisConfig config = null;
+
+ public OtherAction(IsisConfig config) {
+ this.config = config;
+ }
+
+ static public void help() {
+ System.out.println("Usage: isis-fish [-h]");
+ }
+
+ public void chekoutMavenFile() throws Exception {
+ VCSNone vcs = config.getVCS();
+ File dest = config.getDatabaseDirectory();
+ File file = new File(dest, "pom.xml");
+ log.info(_("Checkout pom.xml to %s", file));
+ vcs.update(file);
+ }
+
+
+}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/SimulationAction.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/SimulationAction.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/SimulationAction.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,112 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.actions;
+
+import static org.codelutin.i18n.I18nf._;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationHelper;
+import fr.ifremer.isisfish.simulator.SimulationParameter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Properties;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class SimulationAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(SimulationAction.class);
+
+ protected IsisConfig config = null;
+
+ public SimulationAction(IsisConfig config) {
+ this.config = config;
+ }
+
+ public static void simulateWithRegion(String simulId, File parameterFile, File region) throws Exception {
+ Properties props = new Properties();
+ FileInputStream inStream = new FileInputStream(parameterFile);
+ props.load(inStream);
+ inStream.close();
+
+ SimulationParameter params = new SimulationParameter();
+ params.fromProperties(props);
+
+ // try to import region if needed
+ String regionName = params.getRegionName();
+ if (region != null) {
+ if (!RegionStorage.exists(regionName)) {
+ RegionStorage.importAndRenameZip(region, regionName);
+ } else {
+ log.warn(_("Region %s allready exist in repository. Cant import", regionName));
+ }
+ }
+
+ SimulationHelper.simulate(simulId, params, false);
+ }
+
+ /**
+ *
+ * @param simulId id de simulation
+ * @param zip Zip de la simulation
+ * @param parameterFile parametre optionnel pour la simulation
+ */
+ public static void simulateWithSimulation(String simulId, File parameterFile, File simulationZip) throws Exception {
+ SimulationParameter params = null;
+ if (parameterFile != null && parameterFile.exists()) {
+ Properties props = new Properties();
+ FileInputStream inStream = new FileInputStream(parameterFile);
+ props.load(inStream);
+ inStream.close();
+
+ params = new SimulationParameter();
+ params.fromProperties(props);
+ }
+ log.info("id:" + simulId + ", zip:" + simulationZip + (params!=null?" with parameters":""));
+
+ // import de cette simulation
+ String name = simulId + " " + new SimpleDateFormat("yyyy-MM-dd-HH-mm").format(new Date());
+
+ // import de la simulation avec un autre nom
+ SimulationStorage sim = SimulationStorage.importAndRenameZip(simulationZip, name);
+ if (params != null) {
+ sim.setParameter(params);
+ }
+ // lancement de la simulation
+ SimulationHelper.simulate(null, sim);
+
+ sim.getStorage().closeContext();
+
+ }
+
+}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/VCSAction.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/VCSAction.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/actions/VCSAction.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,97 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.actions;
+
+
+import com.sshtools.j2ssh.transport.publickey.OpenSSHPublicKeyFormat;
+import com.sshtools.j2ssh.transport.publickey.SshKeyGenerator;
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.ui.Welcome;
+import java.io.File;
+import java.util.Arrays;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.FileUtil;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class VCSAction {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(VCSAction.class);
+
+ protected IsisConfig config = null;
+
+ public VCSAction(IsisConfig config) {
+ this.config = config;
+ }
+
+ public void sshCreateKey(boolean force) throws Exception {
+ File f = config.getOptionAsFile(IsisConfig.Option.SSH_KEY_FILE.key);
+
+ if (f.exists() && !force) {
+ log.error("the private key already exist " + f + ", use option [force] to overwrite");
+ return;
+ }
+ File publicKeyFile = new File(f.getAbsolutePath() + ".pub");
+
+ log.info("Generate ssh key to " + f);
+ SshKeyGenerator.main(new String[]{"-b", "1024", "-t", "rsa", f.getAbsolutePath()});
+
+ log.info("public key before OpenSsh : " + FileUtil.readAsString(publicKeyFile));
+ String openSshPublicKey =
+ SshKeyGenerator.convertPublicKeyFile(publicKeyFile,
+ new OpenSSHPublicKeyFormat(
+ config.getOption(IsisConfig.Option.USER_NAME.key) +
+ "@forIsisFish 1024-bit rsa"));
+
+ log.info("public key OpenSsh : " + openSshPublicKey);
+ FileUtil.writeString(new File(publicKeyFile.getAbsolutePath()), openSshPublicKey);
+ }
+
+ public void vcsUpdate() throws Exception {
+ // ATTENTION: il est inutil de d'accepter cette option au premier
+ // lancement! car on a effectue soit un checkout, soit
+ // une migration // !IsisContext.get().isFirstLaunch()
+ Welcome.updateVCS(null);
+ }
+
+ public void vcsAdd(File ... file) throws Exception {
+ log.info("file*:" + Arrays.toString(file));
+ throw new UnsupportedOperationException("to be done...");
+ }
+
+ public void vcsRemove(File ... file) throws Exception {
+ log.info("file*:" + Arrays.toString(file));
+ throw new UnsupportedOperationException("to be done...");
+ }
+
+ public void vcsCommit(File ... file) throws Exception {
+ log.info("file*:" + Arrays.toString(file));
+ throw new UnsupportedOperationException("to be done...");
+ }
+
+}
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -33,7 +33,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.vcs.VCSException;
-import fr.ifremer.isisfish.vcs.VCS;
+import fr.ifremer.isisfish.vcs.VCSNone;
import static org.codelutin.i18n.I18n._;
import org.codelutin.util.FileUtil;
@@ -56,7 +56,7 @@
/** Logger for this class */
private static final Log log = LogFactory.getLog(VersionStorage.class);
- static protected VCS getVCS() {
+ static protected VCSNone getVCS() {
return IsisFish.vcs;
}
@@ -68,7 +68,7 @@
* Par exemple si on a /home/poussin/isis-database comme root
* il faut que file soit un fichier ou un sous fichiers dans root
*
- * @param root le repertoire racine de mise en VCS (HOME VCS)
+ * @param root le repertoire racine de mise en VCSNone (HOME VCSNone)
* @param file le fichier a gérer.
*/
protected VersionStorage(File root, File file) {
@@ -78,7 +78,7 @@
/**
* Permet de demander la preparation des fichiers pour etre envoyé
- * vers le VCS
+ * vers le VCSNone
*
*/
abstract protected void prepare();
@@ -100,9 +100,9 @@
/**
* Indique s'il a deja ete ajouté au cvs. Si file est un repertoire
* (ex pour Region) alors vrai meme si tous les fichiers du repertoire
- * ne sont pas sur le VCS
+ * ne sont pas sur le VCSNone
*
- * @return vrai si deja dans le VCS
+ * @return vrai si deja dans le VCSNone
*/
public boolean isOnRemote() throws VCSException {
return getVCS().isOnRemote(getFile());
@@ -110,7 +110,7 @@
/**
* Permet de savoir si un fichier doit etre géré par le vcs ou non.
- * L'implantation par defaut exclus les répertoires VCS, il faut
+ * L'implantation par defaut exclus les répertoires VCSNone, il faut
* toujours appeler le super si on surcharge la methode.
*
* @param file le fichier a tester
@@ -121,7 +121,7 @@
}
/**
- * Donne la liste de tous les fichiers que le VCS doit gérer.
+ * Donne la liste de tous les fichiers que le VCSNone doit gérer.
* Par defaut parcours tous les repertoires et ajouter tous les fichiers
* et repertoire trouvé. Il est possible d'exclure des fichiers et/ou
* repertoire en surchargeant {@link #isVersionnableAbleFile(File)}
@@ -144,9 +144,9 @@
}
/**
- * Donne la liste de tous les fichiers à gérer par le VCS.
+ * Donne la liste de tous les fichiers à gérer par le VCSNone.
* Ceci inclu la liste des répertoires pour aller de ce storage
- * jusqu'a la racine VCS si withParent est vrai
+ * jusqu'a la racine VCSNone si withParent est vrai
*
* @param withParent si vrai inclu les parents
* @return la liste des fichiers trouvés
@@ -167,7 +167,7 @@
}
/**
- * Permet d'ajouter ce storage dans le VCS. Cela prend effet immediatement
+ * Permet d'ajouter ce storage dans le VCSNone. Cela prend effet immediatement
* (un commit est fait).
*
* @param msg le message indiquant le but du fichier
@@ -209,7 +209,7 @@
}
/**
- * Permet d'envoyer des modifications faite en local sur le VCS
+ * Permet d'envoyer des modifications faite en local sur le VCSNone
*
* @param msg le message indiquant le type des modifications
* @throws VCSException si pb pendant l'op
@@ -217,13 +217,13 @@
*/
public void commit(String msg) throws VCSException {
// on appelle en fait add, car il y a peut-etre des nouveaux fichiers
- // a ajouter au VCS et ca doit etre fait automatiquement
+ // a ajouter au VCSNone et ca doit etre fait automatiquement
add(msg);
}
/**
* Permet de mettre a jour le fichier local en fonction de ce qu'il y
- * a sur le VCS
+ * a sur le VCSNone
*
* @throws VCSException si pb pendant l'op
*
@@ -239,7 +239,7 @@
}
/**
- * Permet de ramener tout un répertoire du VCS. Utile seulement pour le
+ * Permet de ramener tout un répertoire du VCSNone. Utile seulement pour le
* premier lancement pour scipts et exports.
*
* @param destDir le repertoire parent
@@ -275,12 +275,12 @@
/**
* Retourne la liste des noms de tous les storages disponibles sur le
- * serveur VCS
+ * serveur VCSNone
*
- * @param directory le répertoire sur le VCS ou doivent se trouver
+ * @param directory le répertoire sur le VCSNone ou doivent se trouver
* les storages (regions, simulations)
* @return la liste des noms de tous les storages disponibles sur le
- * serveur VCS. Si le serveur n'est pas disponible la liste retournée
+ * serveur VCSNone. Si le serveur n'est pas disponible la liste retournée
* est vide.
*/
static public List<String> getRemoteStorageNames(File directory) {
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/ui/Welcome.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/ui/Welcome.java 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/ui/Welcome.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -49,7 +49,7 @@
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
import fr.ifremer.isisfish.datastore.SimulatorStorage;
-import fr.ifremer.isisfish.vcs.VCS;
+import fr.ifremer.isisfish.vcs.VCSNone;
import org.swixat.framework.AbstractFrame;
import org.swixat.framework.OutputView;
import org.swixat.model.GenericContext;
@@ -74,7 +74,7 @@
/** to use log facility, just put in your code: log.info(\"...\"); */
static private Log log = LogFactory.getLog(Welcome.class);
- static protected VCS getVCS() {
+ static protected VCSNone getVCS() {
return IsisFish.config.getVCS();
}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/AbstractVCS.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,56 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.vcs;
+
+
+import java.io.File;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ApplicationConfig;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public abstract class AbstractVCS implements VCS {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(AbstractVCS.class);
+
+ protected ApplicationConfig config;
+
+ public AbstractVCS(ApplicationConfig config) {
+ this.config = config;
+ }
+
+ public boolean accept(File pathname) {
+ return isVersionnableAbleFile(pathname);
+ }
+
+ public boolean isVersionnableAbleFile(File file) {
+ String filename = file.getName();
+ return !".svn".equals(filename) && !"CVS".equals(filename) && !filename.endsWith("~");
+ }
+
+}
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -1,4 +1,4 @@
-/* *##%
+/*
* Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
*
* This program is free software; you can redistribute it and/or
@@ -15,149 +15,188 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
* USA.
- *##%*/
+ */
package fr.ifremer.isisfish.vcs;
import java.io.File;
import java.io.FileFilter;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
-import static org.codelutin.i18n.I18nf._;
+import org.codelutin.util.VersionNumber;
-import org.apache.commons.beanutils.ConstructorUtils;
-import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.util.ApplicationConfig;
-
/**
- * VCS (svn or vcs) must extends this class. This class can be used as dummy
- * VCS if not valid VCS found.
- *
+ *
* @author poussin
* @version $Revision$
*
* Last update: $Date$
* by : $Author$
*/
-public class VCS implements FileFilter {
+public interface VCS extends FileFilter {
+ public static final String TYPE_CVS = "cvs";
+ public static final String TYPE_NONE = "none";
+ public static final String TYPE_SVN = "svn";
+ /**
+ * can be http, ssh, pserver, ...
+ */
+ public static final String VCS_PROTOCOLE = "vcs.protocole";
+ /**
+ * remote server adresse (ip or serveur name) ex: labs.libre-entreprise.org
+ */
+ public static final String VCS_HOST_NAME = "vcs.hostName";
+ /**
+ * remote repository path ex: /svnroot/isis-fish-data
+ */
+ public static final String VCS_PATH = "vcs.path";
+ /**
+ * repository tag to used ex: "3.2" or "" for no tag
+ */
+ public static final String VCS_TAG = "vcs.tag";
+ /**
+ * can be None, CVS or SVN. only None or SVN work
+ */
+ public static final String VCS_TYPE = "vcs.type";
+ /**
+ * user login to access vcs ex: bpoussin
+ */
+ public static final String VCS_USER_NAME = "vcs.username";
+ /**
+ * user passwd or passphrase to access vcs ex: xxxxxxxx
+ */
+ public static final String VCS_USER_PASSWORD = "vcs.password";
- static final public String TYPE_NONE = "none";
- static final public String TYPE_SVN = "svn";
- static final public String TYPE_CVS = "cvs";
-
- // can be None, CVS or SVN. only None or SVN work
- static final public String VCS_TYPE = "vcs.type";
- static final public String VCS_CONNECTION = "vcs.connection";
- // user login to access vcs
- static final public String VCS_USER_NAME = "vcs.username";
- static final public String VCS_HOST_NAME = "vcs.hostName";
- static final public String VCS_PATH = "vcs.path";
- static final public String VCS_TAG = "vcs.tag";
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(VCS.class);
+ /**
+ * Usefull to permit to use VCSNone as filter
+ * @param pathname
+ * @return
+ */
+ public boolean accept(File pathname);
- protected ApplicationConfig config;
+ /**
+ * Add and commit file in server repository
+ * @param files list of file to add
+ * @param msg message for commit
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void add(List<File> files, String msg) throws VCSException;
+
+ /**
+ * get repository module on server and put it in destDir
+ * @param destDir destination directory
+ * @param module module name
+ * @param b // FIXME
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void checkout(File destDir, String module, boolean b) throws VCSException;
+
+ /**
+ * Change repository tag, used when we use some tag and we want to go to
+ * trunk.
+ * @param version version to go, if null trunk is used, otherwize
+ * tags/version is used
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void switchTag(VersionNumber version) throws VCSException;
/**
- * VCS factory, looking for vcs.type key in config to find vcs class to used
- * If no vcs.type found or is not valid class, use {@link VCS}.
- * @param config
- * @return usable VCS
+ * switch to new protocole, can be used to switch between anonymous and
+ * authenticate protocole
+ * @param protocoleType
+ * @throws fr.ifremer.isisfish.vcs.VCSException
*/
- static public VCS createVCS(ApplicationConfig config) {
- Properties aliases = new Properties();
- aliases.setProperty("", VCS.class.getName());
- aliases.setProperty(TYPE_NONE, VCS.class.getName());
-// aliases.setProperty(TYPE_SVN, VCSSVN.class.getName());
-// aliases.setProperty(TYPE_CVS, VCSCVS.class.getName());
-
- VCS result = null;
- String type = config.getOption(VCS_TYPE);
- // try to convert if type is not class name but an alias
- String classname = aliases.getProperty(type, type);
- try {
- Class clazz = (Class)ConvertUtils.convert(classname, Class.class);
- result = (VCS) ConstructorUtils.invokeConstructor(clazz, config);
- } catch (Exception eee) {
- log.error(_("Can't instanciate wanted VCS (%s), use default",
- config.getOption(VCS_TYPE)), eee);
- result = new VCS(config);
- }
- return result;
- }
+ public void switchProtocole(String protocoleType) throws VCSException;
- protected VCS(ApplicationConfig config) {
- this.config = config;
- }
+ /**
+ * Delete and commit files in server repository
+ * @param files file to delete
+ * @param msg message for commit
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void delete(List<File> files, String msg) throws VCSException;
- public void add(List<File> files, String msg) throws VCSException {
- throw new VCSException("Can't add file with dummy VCS");
- }
+ /**
+ * Return all changelog between local file version and remote repository
+ * file version
+ * @param files
+ * @return changelog for each file
+ */
+ public Map<File, String> getChanglog(List<File> files);
- public void checkout(File destDir, String module, boolean b) throws VCSException {
- throw new VCSException("Can't checkout with dummy VCS");
- }
+ /**
+ * show diff between local file and repository file
+ * @param file
+ * @return
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public String getDiff(File file) throws VCSException;
- public void delete(List<File> files, String msg) throws VCSException {
- // do nothing
- }
-
- public String getDiff(File file) throws VCSException {
- throw new VCSException("Can't diff with dummy VCS");
- }
-
/**
* Return list of all file on directory on remote server
* @param directory
* @return
*/
- public List<String> getFileList(File directory) throws VCSException {
- List<String> result = new ArrayList<String>();
- return result;
- }
+ public List<String> getFileList(File directory) throws VCSException;
- public boolean isConnected() {
- return false;
- }
-
- public boolean isOnRemote(File file) throws VCSException {
- return false;
- }
+ /**
+ * get list of new or modified files on server
+ * @return list of modified or new files
+ */
+ public List<File> getUpdatedFile();
- public boolean isUpToDate(File file) throws VCSException {
- return true;
- }
+ /**
+ * Ask if there are some new or modified files on server
+ * @return true if new file available
+ */
+ public boolean haveUpdate();
/**
+ * Get connection state.
+ * @return true if server is connectable
+ */
+ public boolean isConnected();
+
+ /**
+ * Check if file is available on server
+ * @param file file to check
+ * @return true if file available
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public boolean isOnRemote(File file) throws VCSException;
+
+ /**
+ * look on server if version is tag repository
+ * @param version version number like 3.2
+ * @return true if tag found with this name
+ */
+ public boolean isTag(VersionNumber version);
+
+ /**
+ * Check if file is uptodate
+ * @param file file to check
+ * @return true if file is in last version
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public boolean isUpToDate(File file) throws VCSException;
+
+ /**
* Must be overwriten, this default implementation return true.
* Check if file can be put in vcs repository, for example when you used
* CVS, you must not put CVS file.
- *
+ * <p>
+ * default refused .svn, CVS and ~ filename
+ *
* @param file
* @return
*/
- public boolean isVersionnableAbleFile(File file) {
- return true;
- }
+ public boolean isVersionnableAbleFile(File file);
- public void update(File file) throws VCSException {
- throw new VCSException("Can't update file with dummy VCS");
- }
-
/**
- * Usefull to permit to use VCS as filter
- * @param pathname
- * @return
+ * Update file
+ * @param file file to update
+ * @return true if there are some merging conflict, false otherwize
+ * @throws fr.ifremer.isisfish.vcs.VCSException
*/
- public boolean accept(File pathname) {
- return isVersionnableAbleFile(pathname);
- }
+ public boolean update(File file) throws VCSException;
-
}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSFactory.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,76 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.vcs;
+
+import static org.codelutin.i18n.I18nf._;
+
+import java.util.Properties;
+import org.apache.commons.beanutils.ConstructorUtils;
+import org.apache.commons.beanutils.ConvertUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ApplicationConfig;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class VCSFactory {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(VCSFactory.class);
+
+ private VCSFactory() {}
+
+ /**
+ * VCSNone factory, looking for vcs.type key in config to find vcs class to used
+ * If no vcs.type found or is not valid class, use {@link VCSNone}.
+ * @param config
+ * @return usable VCSNone
+ */
+ static public VCSNone createVCS(ApplicationConfig config) {
+ Properties aliases = new Properties();
+ // for empty and TYPE_NONE we used this class
+ aliases.setProperty("", VCSNone.class.getName());
+ aliases.setProperty(VCS.TYPE_NONE, VCSNone.class.getName());
+ aliases.setProperty(VCS.TYPE_SVN, VCSSVN.class.getName());
+ // FIXME active this line when svn and CVS are implemented
+// aliases.setProperty(TYPE_CVS, VCSCVS.class.getName());
+
+ VCSNone result = null;
+ String type = config.getOption(VCS.VCS_TYPE);
+ // try to convert if type is not class name but an alias
+ String classname = aliases.getProperty(type, type);
+ try {
+ Class clazz = (Class)ConvertUtils.convert(classname, Class.class);
+ result = (VCSNone) ConstructorUtils.invokeConstructor(clazz, config);
+ } catch (Exception eee) {
+ log.error(_("Can't instanciate wanted VCS (%s), use default",
+ config.getOption(VCS.VCS_TYPE)), eee);
+ result = new VCSNone(config);
+ }
+ return result;
+ }
+
+}
Copied: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java (from rev 1283, trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCS.java)
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSNone.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,186 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.vcs;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import static org.codelutin.i18n.I18nf._;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ApplicationConfig;
+import org.codelutin.util.VersionNumber;
+
+/**
+ * VCSNone (svn or vcs) must extends this class. This class can be used as dummy
+ * VCSNone if not valid VCSNone found.
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class VCSNone extends AbstractVCS {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(VCSNone.class);
+
+ public VCSNone(ApplicationConfig config) {
+ super(config);
+ }
+
+ /**
+ * look on server if version is tag repository
+ * @param version version number like 3.2
+ * @return true if tag found with this name
+ */
+ public boolean isTag(VersionNumber version) {
+ return false;
+ }
+
+ /**
+ * Ask if there are some new or modified files on server
+ * @return true if new file available
+ */
+ public boolean haveUpdate() {
+ return false;
+ }
+
+ /**
+ * get list of new or modified files on server
+ * @return list of modified or new files
+ */
+ public List<File> getUpdatedFile() {
+ return new ArrayList<File>();
+ }
+
+ /**
+ * Return all changelog between local file version and remote repository
+ * file version
+ * @param files
+ * @return changelog for each file
+ */
+ public Map<File, String> getChanglog(List<File> files) {
+ return new HashMap<File, String>();
+ }
+
+ /**
+ * Add and commit file in server repository
+ * @param files list of file to add
+ * @param msg message for commit
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void add(List<File> files, String msg) throws VCSException {
+ throw new VCSException("Can't add file with dummy VCS");
+ }
+
+ /**
+ * get repository module on server and put it in destDir
+ * @param destDir destination directory
+ * @param module module name
+ * @param b // FIXME
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void checkout(File destDir, String module, boolean b) throws VCSException {
+ throw new VCSException("Can't checkout with dummy VCS");
+ }
+
+ /**
+ * Delete and commit files in server repository
+ * @param files file to delete
+ * @param msg message for commit
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public void delete(List<File> files, String msg) throws VCSException {
+ // do nothing
+ }
+
+ /**
+ * show diff between local file and repository file
+ * @param file
+ * @return
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public String getDiff(File file) throws VCSException {
+ throw new VCSException("Can't diff with dummy VCS");
+ }
+
+ /**
+ * Return list of all file on directory on remote server
+ * @param directory
+ * @return
+ */
+ public List<String> getFileList(File directory) throws VCSException {
+ List<String> result = new ArrayList<String>();
+ return result;
+ }
+
+ /**
+ * Get connection state.
+ * @return true if server is connectable
+ */
+ public boolean isConnected() {
+ return false;
+ }
+
+ /**
+ * Check if file is available on server
+ * @param file file to check
+ * @return true if file available
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public boolean isOnRemote(File file) throws VCSException {
+ return false;
+ }
+
+ /**
+ * Check if file is uptodate
+ * @param file file to check
+ * @return true if file is in last version
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public boolean isUpToDate(File file) throws VCSException {
+ return true;
+ }
+
+ /**
+ * Update file
+ * @param file file to update
+ * @return true if there are some merging conflict, false otherwize
+ * @throws fr.ifremer.isisfish.vcs.VCSException
+ */
+ public boolean update(File file) throws VCSException {
+ throw new VCSException("Can't update file with dummy VCS");
+ }
+
+ public void switchTag(VersionNumber version) throws VCSException {
+ // do nothing
+ }
+
+ public void switchProtocole(String protocoleType) throws VCSException {
+ // do nothing
+ }
+
+
+}
Added: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java (rev 0)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2008-08-14 14:55:00 UTC (rev 1298)
@@ -0,0 +1,109 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.vcs;
+
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.util.ApplicationConfig;
+import org.codelutin.util.VersionNumber;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class VCSSVN extends AbstractVCS {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(VCSSVN.class);
+
+ public VCSSVN(ApplicationConfig config) {
+ super(config);
+ }
+
+ public void add(List<File> files, String msg) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void checkout(File destDir, String module, boolean b) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void delete(List<File> files, String msg) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public Map<File, String> getChanglog(List<File> files) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getDiff(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public List<String> getFileList(File directory) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public List<File> getUpdatedFile() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean haveUpdate() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isConnected() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isOnRemote(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isTag(VersionNumber version) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isUpToDate(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean update(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void switchTag(VersionNumber version) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void switchProtocole(String protocoleType) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+
+}
Modified: trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/package.html
===================================================================
--- trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/package.html 2008-08-13 18:24:19 UTC (rev 1297)
+++ trunk/isis-fish/src/java/fr/ifremer/isisfish/vcs/package.html 2008-08-14 14:55:00 UTC (rev 1298)
@@ -1,4 +1,4 @@
-Try to keep this class agnostic about IsisFish specific objet. This permit
+Try to keep this classes agnostic about IsisFish specific objects. This permit
library creation in near futur.
<h1>Politique d'utilisation du VCS pour les datas</h1>
@@ -29,9 +29,9 @@
<ul>
<li>Sur le trunk en ecriture</li>
<li>Sur le trunk en lecture (anonymous)</li>
- <li>Sur le trunk en lecture (car release obsolete)</li>
+ <li>Sur le trunk en lecture (car release obsolete, sans mise a jour))</li>
<li>Sur un tag car ancienne release</li>
<li>Sur une branch (en developpement)</li>
<li>En lecture (trunk, tag, branch) car reseau indisponible</li>
</ul>
-</p>
\ No newline at end of file
+</p>
1
0
r1297 - branches/isis-fish-3.1.4/src/resources/i18n
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
13 Aug '08
Author: bpoussin
Date: 2008-08-13 18:24:19 +0000 (Wed, 13 Aug 2008)
New Revision: 1297
Modified:
branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-en_GB.properties
branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-fr_FR.properties
Log:
Reprise de fichier valide depuis le svn
Modified: branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-en_GB.properties
===================================================================
--- branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-en_GB.properties 2008-08-13 18:15:25 UTC (rev 1296)
+++ branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-en_GB.properties 2008-08-13 18:24:19 UTC (rev 1297)
@@ -1,4 +1,190 @@
-Can''t\ add\ result\ ''{0}''\ at\ date\ {1}=Can''t add result ''{0}'' at date {1}
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="fr ">
+
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title>Labs: Isis-fish: dépôt de sources</title>
+ <link rel="alternate" title="Labs - Project News Highlights RSS" href="/export/rss_sfnews.php" type="application/rss+xml"/>
+ <link rel="alternate" title="Labs - New Projects RSS" href="/export/rss_sfprojects.php" type="application/rss+xml"/>
+
+ <script language="JavaScript" type="text/javascript">
+ <!--
+
+ function admin_window(adminurl) {
+ AdminWin = window.open( adminurl, 'AdminWindow','scrollbars=yes,resizable=yes, toolbar=yes, height=400, width=400, top=2, left=2');
+ AdminWin.focus();
+ }
+ function help_window(helpurl) {
+ HelpWin = window.open( helpurl,'HelpWindow','scrollbars=yes,resizable=yes,toolbar=no,height=400,width=400');
+ }
+ // -->
+ </script>
+
+<style type="text/css">
+ <!--
+ BODY {
+ margin-top: 3;
+ margin-left: 3;
+ margin-right: 3;
+ margin-bottom: 3;
+ background-image: url("/themes/le/images/theme-top-blue.png");
+ }
+ ol,ul,p,body,td,tr,th,form { font-family: verdana,arial,helvetica,sans-serif; font-size:small;
+ color: #333333; }
+
+ h1 { font-size: x-large; font-family: verdana,arial,helvetica,sans-serif; }
+ h2 { font-size: large; font-family: verdana,arial,helvetica,sans-serif; }
+ h3 { font-size: medium; font-family: verdana,arial,helvetica,sans-serif; }
+ h4 { font-size: small; font-family: verdana,arial,helvetica,sans-serif; }
+ h5 { font-size: x-small; font-family: verdana,arial,helvetica,sans-serif; }
+ h6 { font-size: xx-small; font-family: verdana,arial,helvetica,sans-serif; }
+
+ pre,tt { font-family: courier,sans-serif }
+
+ a:link { text-decoration:none; color: #0000be }
+ a:visited { text-decoration:none; color: #0000be }
+ a:active { text-decoration:none }
+ a:hover { text-decoration:underline; color:red }
+
+ .titlebar { color: black; text-decoration: none; font-weight: bold; }
+ a.tablink { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tablink:visited { color: black; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tablink:hover { text-decoration: none; color: black; font-weight: bold; font-size: x-small; }
+ a.tabsellink { color: #0000be; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tabsellink:visited { color: #0000be; text-decoration: none; font-weight: bold; font-size: x-small; }
+ a.tabsellink:hover { text-decoration: none; color: #0000be; font-weight: bold; font-size: x-small; }
+ -->
+</style>
+<link rel="stylesheet" type="text/css" href="/plugins/scmcvs/cvsweb/css/cvsweb.css" /><link rel="stylesheet" type="text/css" href="/plugins/scmsvn/viewcvs/styles.css" /></head>
+
+<body>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="0">
+
+ <tr>
+ <!--<td><a href="/"><img src="http://labs.libre-entreprise.org//themes/le/images/logo.png" border="0" alt="" width="81" height="62" /></a></td>-->
+ <td style="color: #FFFFFF; font-size: large; font-weight: bold;" valign="middle">Labs.libre-entreprise.org</td>
+ <td>
+ <form action="/search/" method="get">
+ <table border="0" cellpadding="0" cellspacing="0">
+ <tr><td>
+ <div align="center" style="font-size:smaller"><select name="type_of_search"><option value="soft">Logiciel/Groupe</option>
+<option value="people">Personne</option>
+</select></div></td><td> </td><td><input type="text" size="12" name="words" value="" /></td><td> </td><td><input type="submit" name="Search" value="Rechercher" /></td></tr></table></form></td>
+ <td align="right"> <b><a style="color: #FFFFFF" href="/account/login.php">S'identifier</a></b><br />
+ <b><a style="color: #FFFFFF" href="/account/register.php">Nouveau compte</a></b>
+ </td>
+ <td> </td>
+ </tr>
+
+</table>
+
+<table border="0" width="100%" cellspacing="0" cellpadding="0">
+
+ <tr>
+ <td> </td>
+ <td colspan="3">
+
+
+
+ <!-- start tabs -->
+
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td valign="top" width="10" background="/themes/le/images/theme-toptab-end-notselected.png"><img src="/themes/le/images/clear.png" height="25" width="10" alt="" /></td><td background="/themes/le/images/theme-toptab-notselected-bg.png" width="20%" align="center"><a class="tablink" href="/">Accueil</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-toptab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-toptab-notselected-bg.png" width="20%" align="center"><a class="tablink" href="/my/">Ma page</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-toptab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-toptab-notselected-bg.png" width="20%" align="center"><a class="tablink" href="/softwaremap/">Arbre des projets</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-toptab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-toptab-notselected-bg.png" width="20%" align="center"><a class="tablink" href="/snippet/">Boite à outils</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-toptab-notselected-selected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-toptab-selected-bg.png" width="20%" align="center"><a class="tabsellink" href="/projects/isis-fish/">Isis-fish</a></td>
+ <td valign="top" width="10" background="/themes/le/images/theme-toptab-selected-end.png"><img src="/themes/le/images/clear.png" height="2" width="10" alt="" /></td></tr><tr><td colspan="12" height="1" bgcolor="#909090"><img src="/themes/le/images/clear.png" height="1" width="10" /></td><td colspan="3" height="1" bgcolor="#e0e0e0"><img src="/themes/le/images/clear.png" height="1" width="10" /></td></tr>
+ </table>
+
+ <!-- end tabs -->
+
+ </td>
+ <td> </td>
+ </tr>
+
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/topleft.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#E0E0E0" width="30"><img src="/themes/le/images/clear.png" width="30" height="1" alt="" /></td>
+ <td bgcolor="#E0E0E0"><img src="/themes/le/images/clear.png" width="1" height="1" alt="" /></td>
+ <td bgcolor="#E0E0E0" width="30"><img src="/themes/le/images/clear.png" width="30" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/topright.png" height="9" width="9" alt="" /></td>
+ </tr>
+
+ <tr>
+
+ <!-- Outer body row -->
+
+ <td bgcolor="#E0E0E0"><img src="/themes/le/images/clear.png" width="10" height="1" alt="" /></td>
+ <td valign="top" width="99%" bgcolor="#E0E0E0" colspan="3">
+
+ <!-- Inner Tabs / Shell -->
+
+ <table border="0" width="100%" cellspacing="0" cellpadding="0">
+ <tr>
+ <td> </td>
+ <td>
+
+
+ <!-- start tabs -->
+
+ <table border="0" cellpadding="0" cellspacing="0" width="100%">
+ <tr>
+ <td valign="top" width="10" background="/themes/le/images/theme-bottomtab-end-notselected.png"><img src="/themes/le/images/clear.png" height="25" width="10" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/projects/isis-fish/">En bref</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/tracker/?group_id=8">Suivi</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/mail/?group_id=8">Listes</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/pm/?group_id=8">Tâches</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/docman/?group_id=8">Documents</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/survey/?group_id=8">Sondages</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/news/?group_id=8">Annonces</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-selected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-selected-bg.png" width="10%" align="center"><a class="tabsellink" href="/scm/?group_id=8">Sources</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-selected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/frs/?group_id=8">Fichiers</a></td>
+ <td colspan="2" valign="top" width="20" background="/themes/le/images/theme-bottomtab-notselected-notselected.png"><img src="/themes/le/images/clear.png" height="2" width="20" alt="" /></td><td background="/themes/le/images/theme-bottomtab-notselected-bg.png" width="10%" align="center"><a class="tablink" href="/plugins/wiki/index.php?id=8&type=g">Wiki</a></td>
+ <td valign="top" width="10" background="/themes/le/images/theme-bottomtab-notselected-end.png"><img src="/themes/le/images/clear.png" height="2" width="10" alt="" /></td></tr><tr><td colspan="21" height="1" bgcolor="#909090"><img src="/themes/le/images/clear.png" height="1" width="10" /></td><td colspan="3" height="1" bgcolor="white"><img src="/themes/le/images/clear.png" height="1" width="10" /></td><td colspan="6" height="1" bgcolor="#909090"><img src="/themes/le/images/clear.png" height="1" width="10" /></td></tr>
+ </table>
+
+ <!-- end tabs -->
+ </td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td align="left" bgcolor="#ffffff" width="9"><img src="/themes/le/images/tabs/topleft-inner.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#ffffff"><img src="/themes/le/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#ffffff" width="9"><img src="/themes/le/images/tabs/topright-inner.png" height="9" width="9" alt="" /></td>
+ </tr>
+
+ <tr>
+ <td bgcolor="#ffffff"><img src="/themes/le/images/clear.png" width="10" height="1" alt="" /></td>
+ <td valign="top" width="99%" bgcolor="white">
+
+ <link href="/plugins/scmsvn/styles.css" rel="stylesheet" TYPE="text/css"><h1>isis-fish: trunk/isis-fish/src/resources/i18n/isis-fish-en_GB.properties</h1>
+
+<div class="vc_summary">
+File: <a href="/plugins/scmsvn/viewcvs.php/?rev=1246&root=isis-fish#dirlist">[isis-fish]</a> / <a href="/plugins/scmsvn/viewcvs.php/trunk/?rev=1246&root=isis-fish#dirlist">trunk</a> / <a href="/plugins/scmsvn/viewcvs.php/trunk/isis-fish/?rev=1246&root=isis-fish#dirlist">isis-fish</a> / <a href="/plugins/scmsvn/viewcvs.php/trunk/isis-fish/src/?rev=1246&root=isis-fish#dirlist">src</a> / <a href="/plugins/scmsvn/viewcvs.php/trunk/isis-fish/src/resources/?rev=1246&root=isis-fish#dirlist">resources</a> / <a href="/plugins/scmsvn/viewcvs.php/trunk/isis-fish/src/resources/i18n/?rev=1246&root=isis-fish#dirlist">i18n</a> / isis-fish-en_GB.properties
+(<a href="/plugins/scmsvn/viewcvs.php/*checkout*/trunk/isis-fish/src/resources/i18n/isis-fish-en_GB.properties?rev=1246&root=isis-fish"><b>download</b></a>)
+
+<br>
+
+Revision: <b>1246</b>,
+<i>Fri Jul 11 19:12:55 2008 UTC</i> (4 weeks, 4 days ago) by <i>tchemit</i>
+
+
+
+
+
+<br>File size: 59512 byte(s)
+
+
+<pre class="vc_log">i18n ? use key</pre>
+
+</div>
+<pre>Can''t\ add\ result\ ''{0}''\ at\ date\ {1}=Can''t add result ''{0}'' at date {1}
Can''t\ evaluate\ simulation\ prescript=Can''t evaluate simulation prescript
Can''t\ get\ result\:\ {0}=Can''t get result\: {0}
Can't\ create\ simulation\ logger=Can't create simulation logger
@@ -176,7 +362,7 @@
isisfish.error.acceptable.population=New value isn't acceptable value for this population
isisfish.error.add.card=Error while adding of result to the map.
isisfish.error.add.file=Can't add file {0}
-isisfish.error.add.logger.simulation\ =isisfish.error.add.logger.simulation
+isisfish.error.add.logger.simulation\ =isisfish.error.add.logger.simulation
isisfish.error.add.result.data=Error while adding result ot data.
isisfish.error.add.result.graph=Error while adding result to graph
isisfish.error.add.tray=Can''t add system tray icon
@@ -232,7 +418,7 @@
isisfish.error.init.remove.button=could not init remove button (button
isisfish.error.instanciate=Can't instanciate {0}
isisfish.error.instanciate.export=Can't instanciate export {0}
-isisfish.error.integer.positif=Your input must be a positif integer (>1)
+isisfish.error.integer.positif=Your input must be a positif integer (>1)
isisfish.error.invalid.category.name=The category's name {0} is not valid.
isisfish.error.invalid.configuration=Configuration is not full, could not launch IsisFish, try again ?
isisfish.error.invalid.configuration.title=Error while loading IsisFish
@@ -263,7 +449,7 @@
isisfish.error.log.foundAppender=\=could not found log appender {0} for category {1}
isisfish.error.matrix.more.2d=Matrice de plus de 2 dimensions\!\!\\nSelectionnez moins d'\u00E9l\u00E9ments ou utilisez l'op\u00E9rateur somme.
isisfish.error.migration.negative=Migration negative
-isisfish.error.no.matrix=No matrix for\:
+isisfish.error.no.matrix=No matrix for\:
isisfish.error.no.null.time.step=Error, the time step should not be null
isisfish.error.no.sector=No sector defined
isisfish.error.no.select.simulation=could not select simulation
@@ -271,7 +457,7 @@
isisfish.error.no.target.species=no target species in {0} for {1}
isisfish.error.not.connected=Error \: not connected
isisfish.error.not.find.status=could not find status for file {0} for reason {1}
-isisfish.error.not.found.class=this class does not
+isisfish.error.not.found.class=this class does not
isisfish.error.not.found.code=could not found codeclass for {0}
isisfish.error.not.found.description=could not found description for {0}
isisfish.error.not.found.field=could not found field {0} doc for {0}
@@ -282,7 +468,7 @@
isisfish.error.not.null.natiral.death=natural mortality null
isisfish.error.not.possible.metier=Pas de m\u00E9tier possible
isisfish.error.not.species.node.population.container=Population container not in Species node
-isisfish.error.not.support.class=this class does not support
+isisfish.error.not.support.class=this class does not support
isisfish.error.number.classes.upper.zero=Error, the number of classes must be upper than 0
isisfish.error.obtain.analyseplan=Can''t obtain description of AnalysePlan
isisfish.error.obtain.doc.export=Can''t obtain @Doc on class export
@@ -512,7 +698,7 @@
isisfish.log.addAppender=add appender [{0}]
isisfish.log.body=Message to add
isisfish.log.closeAppender=closing appender {0} for category {1}
-isisfish.log.mail.failed=Can't send report by mail. Is your mail server up ? (I'm trying to contact the < {0} > smtp server)
+isisfish.log.mail.failed=Can't send report by mail. Is your mail server up ? (I'm trying to contact the < {0} > smtp server)
isisfish.log.mail.send=A report has been sent to {0}
isisfish.log.mail.send.title=Send simulation {0} by email
isisfish.log.mailTo=Destination adress
@@ -543,7 +729,7 @@
isisfish.message.commit.finished=commit finished
isisfish.message.commit.region.canceled=Commit region canceled
isisfish.message.commiting.region=Commiting region {0} ...
-isisfish.message.compilation.time=Compilation time {0}s
+isisfish.message.compilation.time=Compilation time {0}s
isisfish.message.confirm.delete.object=Do you really want delete object {0}
isisfish.message.confirm.remove.region=Do you really want to remove the region {0} ?
isisfish.message.confirm.remove.script=Do you want to remove script ? ''{0}''
@@ -577,10 +763,10 @@
isisfish.message.import.region.zipped=Zipped Region
isisfish.message.import.scripts.file=Import scripts from file {0}
isisfish.message.import.scripts.file.cancelled=Import scripts cancelled
-isisfish.message.import.scripts.file.done=Import scripts done
+isisfish.message.import.scripts.file.done=Import scripts done
isisfish.message.import.scripts.zipped=Zipped Scripts
-isisfish.message.import.xml.v2.file\ =Import xml v2 file
-isisfish.message.import.zip=Import zip file
+isisfish.message.import.xml.v2.file\ =Import xml v2 file
+isisfish.message.import.zip=Import zip file
isisfish.message.load.finished=load finished
isisfish.message.load.map=Try to load map file\: {0} ({1}, {2})
isisfish.message.load.region.canceled=load region canceled
@@ -685,7 +871,7 @@
isisfish.params.toString.number.years=Number of years\: {0}\\n\\n
isisfish.params.toString.plan=Plan\: {0}
isisfish.params.toString.plan.number=Analyse plan sequence number\: {0}\\n\\n
-isisfish.params.toString.populations=Populations\:
+isisfish.params.toString.populations=Populations\:
isisfish.params.toString.rule=Rule\: {0}
isisfish.params.toString.script.logger.level=Level of scripts' logger {0}
isisfish.params.toString.script.presimulation=Script de presimulation
@@ -792,15 +978,15 @@
isisfish.queue.title=Queue
isisfish.result.abundance=Abondance
isisfish.result.add=Add a result
-isisfish.result.begin.simulation=En debut de Simulation\:
+isisfish.result.begin.simulation=En debut de Simulation\:
isisfish.result.capture=Capture
isisfish.result.capture.metier=Capture par metier
isisfish.result.choose.simulation=Choose a Simulation
isisfish.result.datas=Datas
isisfish.result.datasRadioButton=defaultToolTip-fr.ifremer.resultat.ResultatEdit.donneeRadioButton
isisfish.result.desktopPane=defaultToolTip-fr.ifremer.resultat.ResultatView.desktopPane
-isisfish.result.dimension\ =Dimension
-isisfish.result.end.simulation=En fin de Simulation\:
+isisfish.result.dimension\ =Dimension
+isisfish.result.end.simulation=En fin de Simulation\:
isisfish.result.export=Export
isisfish.result.export.file=Export text file
isisfish.result.file=File
@@ -960,8 +1146,8 @@
isisfish.strategyMonthInfo.toString={0} {1}
isisfish.timeUnit.day=Day
isisfish.timeUnit.hours=Hours
-isisfish.tray.simulation=<b>Isis-fish<b><p>{0} - {1}/{2}
-isisfish.tray.simulation.no=<b>Isis-fish<b><p><i>No simulation<i>
+isisfish.tray.simulation=<b>Isis-fish<b><p>{0} - {1}/{2}
+isisfish.tray.simulation.no=<b>Isis-fish<b><p><i>No simulation<i>
isisfish.tripType.comments=Comments
isisfish.tripType.duration=Duration
isisfish.tripType.minTime=Minimum time between trips
@@ -975,7 +1161,7 @@
isisfish.vcs.commit.ok=vcs.commit.ok
isisfish.vcs.config.title=Vcs configuration Modifier
isisfish.vcs.configuration.title=VCS server configuration
-isisfish.vcs.migrate.end=Migration done in {0}s.<br/>New database in is located at [{1}]
+isisfish.vcs.migrate.end=Migration done in {0}s.<br/>New database in is located at [{1}]
isisfish.vcs.update=vcs.update
isisfish.vcs.update.cancel=cancel
isisfish.vcs.update.checkAll=checkAll
@@ -1079,3 +1265,57 @@
the\ property\ {0}\ is\ mandatory\ but\ missed.=the property {0} is mandatory but missed.
to\ use\ ssh\ authentication\ mode,\ you\ must\ have\ a\ username.\ {0}.=to use ssh authentication mode, you must have a username. {0}.
to\ use\ ssh\ authentication\ mode,\ you\ must\ have\ an\ existing\ private\ key\ {0}\ \:\ {1}.=to use ssh authentication mode, you must have an existing private key {0} \: {1}.
+</pre>
+
+<hr noshade>
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr>
+<td align="left">
+<address><a href="mailto:webmaster at labs.libre-entreprise.org">CVS/SVN Admin</a></address><br />
+Powered by <a href="http://viewcvs.sourceforge.net/">ViewCVS 1.0-dev</a>
+</td>
+<td align="right">
+<img src="/doc/viewcvs/images/logo.png" alt="(Powered by ViewCVS)" border="0"
+width="128" height="48" /><br />
+<h3><a target="_blank" href="/plugins/scmsvn/viewcvs/help_rootview.html">ViewCVS and CVS/SVN Help</a></h3>
+</td>
+</tr>
+</table>
+<!--
+</body>
+</html>
+-->
+ <!-- end main body row -->
+
+
+ </td>
+ <td width="10" bgcolor="#ffffff"><img src="/themes/le/images/clear.png" width="2" height="1" alt="" /></td>
+ </tr>
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/bottomleft-inner.png" height="11" width="11" alt="" /></td>
+ <td bgcolor="#ffffff"><img src="/themes/le/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/bottomright-inner.png" height="11" width="11" alt="" /></td>
+ </tr>
+ </table>
+
+ <!-- end inner body row -->
+
+ </td>
+ <td width="10" bgcolor="#E0E0E0"><img src="/themes/le/images/clear.png" width="2" height="1" alt="" /></td>
+ </tr>
+ <tr>
+ <td align="left" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/bottomleft.png" height="9" width="9" alt="" /></td>
+ <td bgcolor="#E0E0E0" colspan="3"><img src="/themes/le/images/clear.png" width="1" height="1" alt="" /></td>
+ <td align="right" bgcolor="#E0E0E0" width="9"><img src="/themes/le/images/tabs/bottomright.png" height="9" width="9" alt="" /></td>
+ </tr>
+</table>
+
+<!-- PLEASE LEAVE "Powered By GForge" on your site -->
+<br />
+<center>
+<a href="http://gforge.org/"><img src="/images/pow-gforge.png" alt="Powered By GForge Collaborative Development Environment" border="0" /></a>
+</center>
+
+
+</body>
+</html>
Modified: branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-fr_FR.properties
===================================================================
--- branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-fr_FR.properties 2008-08-13 18:15:25 UTC (rev 1296)
+++ branches/isis-fish-3.1.4/src/resources/i18n/isis-fish-fr_FR.properties 2008-08-13 18:24:19 UTC (rev 1297)
@@ -176,7 +176,7 @@
isisfish.error.acceptable.population=New value isn't acceptable value for this population
isisfish.error.add.card=Erreur lors de l'ajout du r\u00E9sultat \u00E0 la carte.
isisfish.error.add.file=Can't add file {0}
-isisfish.error.add.logger.simulation\ =isisfish.error.add.logger.simulation
+isisfish.error.add.logger.simulation\ =isisfish.error.add.logger.simulation
isisfish.error.add.result.data=Erreur lors de l'ajout du r\u00E9sultat au data.
isisfish.error.add.result.graph=Erreur lors de l'ajout du r\u00E9sultat au graph.
isisfish.error.add.tray=Can't add system tray icon
@@ -263,7 +263,7 @@
isisfish.error.log.foundAppender=n''a pas trouve l''appender {0} pour la categorie {1}
isisfish.error.matrix.more.2d=Matrice de plus de 2 dimensions\!\!\\nSelectionnez moins d'\u00E9l\u00E9ments ou utilisez l'op\u00E9rateur somme.
isisfish.error.migration.negative=Migration negative
-isisfish.error.no.matrix=No matrix for\:
+isisfish.error.no.matrix=No matrix for\:
isisfish.error.no.null.time.step=Error, the time step should not be null
isisfish.error.no.sector=il n'y a pas de secteur de d\u00E9finit
isisfish.error.no.select.simulation=could not select simulation
@@ -271,7 +271,7 @@
isisfish.error.no.target.species=no target species in {0} for {1}
isisfish.error.not.connected=Erreur \u00E0 la connexion...
isisfish.error.not.find.status=n''a pas pu trouver le status du fichier {0} pour la raison suivante \: {1}
-isisfish.error.not.found.class=this class does not
+isisfish.error.not.found.class=this class does not
isisfish.error.not.found.code=could not found codeclass for {0}
isisfish.error.not.found.description=could not found description for {0}
isisfish.error.not.found.field=could not found field {0} doc for {0}
@@ -282,9 +282,9 @@
isisfish.error.not.null.natiral.death=mortalite naturelle nulle
isisfish.error.not.possible.metier=Pas de m\u00E9tier possible
isisfish.error.not.species.node.population.container=Population container not in Species node
-isisfish.error.not.support.class=this class does not support
+isisfish.error.not.support.class=this class does not support
isisfish.error.number.classes.upper.zero=Error, the number of classes must be upper than 0
-isisfish.error.obtain.analyseplan=Can''t obtain description of AnalysePlan
+isisfish.error.obtain.analyseplan=Can''t obtain description of AnalysePlan
isisfish.error.obtain.doc.export=Can't obtain @Doc on class Export
isisfish.error.obtain.doc.resultName=Can't obtain @Doc on ResultName
isisfish.error.obtain.doc.rule=Can't obtain description for a Rule class
@@ -485,7 +485,7 @@
isisfish.launch.find.public.key=Clef publique ssh (*.pub) associ\u00E9e \u00E0 la clef priv\u00E9e
isisfish.launch.first=Premier d\u00E9marrage type vcs {0} - version {1}
isisfish.launch.firstname=nom
-isisfish.launch.howto.save.key=Comment enregister sa clef publique ssh aupr\u00E8s du labs
+isisfish.launch.howto.save.key=Comment enregister sa clef publique ssh aupr\u00E8s du labs
isisfish.launch.init.done=init done in {0}.
isisfish.launch.lasstname=pr\u00E9nom
isisfish.launch.save.key=Acc\u00E9der au labs pour enregister votre clef publique ssh
@@ -500,7 +500,7 @@
isisfish.launch.server.ssh.key.generate.error=La clef {0} n''a pas \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9e.
isisfish.launch.server.ssh.key.generate.succes=Votre clef ssh {0} a \u00E9t\u00E9 g\u00E9n\u00E9r\u00E9e,il faut d\u00E9sormais l''enregistrer aupr\u00E8s du serveur lab.
isisfish.launch.server.ssh.key.no.key=Pas de clef ssh connu ou vous n'avez pas s\u00E9lectionn\u00E9 le mode SSH, voulez-vous quand meme continuer ?
-isisfish.launch.server.ssh.key.register=Enregister votre clef publique ssh sur le serveur du labs
+isisfish.launch.server.ssh.key.register=Enregister votre clef publique ssh sur le serveur du labs
isisfish.launch.server.ssh.no.passphrase=pas de passphrase
isisfish.launch.server.ssh.passphrase=passphrase
isisfish.launch.server.ssh.privateKeyFile=clef priv\u00E9e ssh
@@ -543,10 +543,10 @@
isisfish.message.commit.finished=commit termin\u00E9
isisfish.message.commit.region.canceled=Commit de la r\u00E9gion annul\u00E9
isisfish.message.commiting.region=En train de commiter la r\u00E9gion {0} ...
-isisfish.message.compilation.time=Temps de compilation {0}s
+isisfish.message.compilation.time=Temps de compilation {0}s
isisfish.message.confirm.delete.object=Voulez-vous vraiment supprimer l'objet {0}
isisfish.message.confirm.remove.region=Voulez-vous vraiement supprimer la r\u00E9gion {0} ?
-isisfish.message.confirm.remove.script=Voulez-vous vraiment supprimer le script ? ''{0}''
+isisfish.message.confirm.remove.script=Voulez-vous vraiment supprimer le script ? ''{0}''
isisfish.message.copy.finished=Copie termin\u00E9e
isisfish.message.copy.region=Copier la r\u00E9gion vers {0}
isisfish.message.copy.revision=Working copy initialize fine... Revision \: [ {0} - {1} ]
@@ -579,8 +579,8 @@
isisfish.message.import.scripts.file.cancelled=Importation des scripts annul\u00E9
isisfish.message.import.scripts.file.done=Importation des scripts termin\u00E9
isisfish.message.import.scripts.zipped=Zipped Scripts
-isisfish.message.import.xml.v2.file\ =Import xml v2 file
-isisfish.message.import.zip=Import zip file
+isisfish.message.import.xml.v2.file\ =Import xml v2 file
+isisfish.message.import.zip=Import zip file
isisfish.message.load.finished=Chargement termin\u00E9
isisfish.message.load.map=Chargement de la carte \: {0} ({1}, {2})
isisfish.message.load.region.canceled=chargement de r\u00E9gion annul\u00E9
@@ -685,7 +685,7 @@
isisfish.params.toString.number.years=Nombre d'ann\u00E9\u00E9s \: {0}\\n\\n
isisfish.params.toString.plan=Plan\: {0}
isisfish.params.toString.plan.number=Analyse plan sequence number\: {0}\\n\\n
-isisfish.params.toString.populations=Populations\:
+isisfish.params.toString.populations=Populations\:
isisfish.params.toString.rule=Rule\: {0}
isisfish.params.toString.script.logger.level=niveau du logger de scripts {0}
isisfish.params.toString.script.presimulation=Script de presimulation
@@ -792,15 +792,15 @@
isisfish.queue.title=Queue
isisfish.result.abundance=Abondance
isisfish.result.add=Ajouter un r\u00E9sultat\=
-isisfish.result.begin.simulation=En debut de Simulation\:
+isisfish.result.begin.simulation=En debut de Simulation\:
isisfish.result.capture=Capturer
isisfish.result.capture.metier=Capturer par metier
isisfish.result.choose.simulation=Choisir une simulation
isisfish.result.datas=Donn\u00E9es
isisfish.result.datasRadioButton=defaultToolTip-fr.ifremer.resultat.ResultatEdit.donneeRadioButton
isisfish.result.desktopPane=defaultToolTip-fr.ifremer.resultat.ResultatView.desktopPane
-isisfish.result.dimension\ =Dimension
-isisfish.result.end.simulation=En fin de Simulation\:
+isisfish.result.dimension\ =Dimension
+isisfish.result.end.simulation=En fin de Simulation\:
isisfish.result.export=Export
isisfish.result.export.file=Exporter text file
isisfish.result.file=Fichier
1
0
r1296 - in branches/isis-fish-3.1.4/src: java/fr/ifremer/isisfish/entities uimodel/fr/ifremer/isisfish/ui/input uimodel/fr/ifremer/isisfish/ui/simulator
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
13 Aug '08
Author: bpoussin
Date: 2008-08-13 18:15:25 +0000 (Wed, 13 Aug 2008)
New Revision: 1296
Modified:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/PopulationMigration.xgl
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xgl
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xml
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xgl
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xml
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xgl
branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xml
Log:
- ajout des composants graphiques pour l'edition des equations (inactivity, technicalEfficiency)
- ajout de la possibilite de lancer les simulations en batch (sous process)
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2008-08-13 18:15:25 UTC (rev 1296)
@@ -84,7 +84,7 @@
EquationDAO dao = IsisFishDAOHelper.getEquationDAO(getTopiaContext());
// create Growth equation
eq = dao.create();
- eq.setCategory("Inactivity");
+ eq.setCategory("TechnicalEfficiency");
eq.setJavaInterface(SoVTechnicalEfficiencyEquation.class);
eq.setLanguage(Language.JAVA);
setTechnicalEfficiencyEquation(eq);
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/PopulationMigration.xgl
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/PopulationMigration.xgl 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/PopulationMigration.xgl 2008-08-13 18:15:25 UTC (rev 1296)
@@ -33,7 +33,7 @@
</tr>
</table>
-<table Zonespacing="5">
+<table cellspacing="5">
<tr>
<td fill="Both" width="100%">buttonPopulationMigrationSave</td>
<td fill="Both" width="100%">buttonPopulationMigrationCancel</td>
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xgl
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xgl 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xgl 2008-08-13 18:15:25 UTC (rev 1296)
@@ -26,11 +26,25 @@
<td class="label">labelSetOfVesselsFixedCosts</td>
<td class="field">fieldSetOfVesselsFixedCosts</td>
</tr>
+
<tr>
- <td class="label" rowspan="3">labelSetOfVesselsComment</td>
- <td class="field" height="20%" rowspan="3">fieldSetOfVesselsComment</td>
+ <td class="label">labelSetOfVesselsTechnicalEfficiency</td>
+ <td class="field">fieldSetOfVesselsTechnicalEfficiency</td>
</tr>
+ <tr>
+ <td class="label">buttonSetOfVesselsTechnicalEfficiencySaveAsModel</td>
+ <td class="field" height="30%" rowspan="3">fieldScriptSetOfVesselsTechnicalEfficiency</td>
+ </tr>
+ <tr>
+ <td class="label">buttonSetOfVesselsTechnicalEfficiencyEquationEditor</td>
+ </tr>
<tr></tr>
+
+
+ <tr>
+ <td class="label" rowspan="2">labelSetOfVesselsComment</td>
+ <td class="field" height="20%" rowspan="2">fieldSetOfVesselsComment</td>
+ </tr>
<tr></tr>
<tr>
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xml
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xml 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/SetOfVessels.xml 2008-08-13 18:15:25 UTC (rev 1296)
@@ -36,6 +36,31 @@
<DocumentEvents onModified="Update($fieldSetOfVesselsFixedCosts/text)"/>
</textfield>
+
+ <label constraints="labelSetOfVesselsTechnicalEfficiency" text="isisfish.setOfVessels.technicalEfficiency"/>
+ <combobox constraints="fieldSetOfVesselsTechnicalEfficiency" id="fieldSetOfVesselsTechnicalEfficiency"
+ origin="$SetOfVessels/technicalEfficiencyEquation" renderer="name" firstNull="true"
+ actionCommand="Update($fieldSetOfVesselsTechnicalEfficiency/selectedItem/content, $fieldScriptSetOfVesselsTechnicalEfficiency/text)">
+ <ComboBoxModel origin='fr.ifremer.isisfish.datastore.FormuleStorage.getFormules($TopiaContext, "TechnicalEfficiency")'/>
+ </combobox>
+
+ <button constraints="buttonSetOfVesselsTechnicalEfficiencySaveAsModel" text="isisfish.common.saveModel"
+ actionCommand='input.Input.saveEquationAsModel($SetOfVessels/technicalEfficiencyEquation);refreshView($fieldSetOfVesselsTechnicalEfficiency)'/>
+
+ <button constraints="buttonSetOfVesselsTechnicalEfficiencyEquationEditor" text="isisfish.common.openEditor"
+ actionCommand='input.Input.openEditor($SetOfVessels/technicalEfficiencyEquation/category,$SetOfVessels/technicalEfficiencyEquation/name,$SetOfVessels/technicalEfficiencyEquation/javaInterface,$SetOfVessels/technicalEfficiencyEquation/content,$fieldScriptSetOfVesselsTechnicalEfficiency)'/>
+
+ <editor constraints="fieldScriptSetOfVesselsTechnicalEfficiency" askIfNotSaved="false"
+ id="fieldScriptSetOfVesselsTechnicalEfficiency"
+ origin="org.codelutin.util.FileUtil.getTempFile($SetOfVessels/technicalEfficiencyEquation/content, '.java')">
+ <DocumentEvents onModified="Update">
+ <UpdateOrigin
+ target="setEquationTechnicalEfficiency($SetOfVessels, $fieldScriptSetOfVesselsTechnicalEfficiency/text)"/>
+ </DocumentEvents>
+ </editor>
+
+
+
<label constraints="labelSetOfVesselsComment" text="isisfish.setOfVessels.comments"/>
<scrollPane constraints="fieldSetOfVesselsComment">
<textarea id="fieldSetOfVesselsComment" origin="$SetOfVessels/comment">
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xgl
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xgl 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xgl 2008-08-13 18:15:25 UTC (rev 1296)
@@ -18,9 +18,18 @@
<td class="label">labelStrategyProportionSetOfVessels</td>
<td class="field">fieldStrategyProportionSetOfVessels</td>
</tr>
+
+ <tr>
+ <td></td>
+ <td class="field">fieldUseEquationInactivity</td>
+ </tr>
+ <tr>
+ <td class="labelTitle" fill="Both" height="100%" width="100%" colspan="2">hideablePanelInactivityEquation</td>
+ </tr>
+
<tr>
- <td class="label" rowspan="3">labelStrategyComment</td>
- <td class="field" height="20%" rowspan="3">fieldStrategyComment</td>
+ <td class="label" rowspan="2">labelStrategyComment</td>
+ <td class="field" height="20%" rowspan="2">fieldStrategyComment</td>
</tr>
<tr></tr>
<tr></tr>
@@ -30,5 +39,26 @@
</tr>
</table>
+ <table>
+ <tr>
+ <td fill="Both" height="100%" width="100%">fieldUseEquation</td>
+ </tr>
+ </table>
+
+ <table cellspacing="2">
+ <tr>
+ <td class="label">labelStrategyInactivity</td>
+ <td class="field">fieldStrategyInactivity</td>
+ </tr>
+ <tr>
+ <td class="label">buttonStrategyInactivitySaveAsModel</td>
+ <td class="field" height="30%" rowspan="3">fieldScriptStrategyInactivity</td>
+ </tr>
+ <tr>
+ <td class="label">buttonStrategyInactivityEquationEditor</td>
+ </tr>
+ <tr></tr>
+ </table>
+
</layout>
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xml
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xml 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/input/Strategy.xml 2008-08-13 18:15:25 UTC (rev 1296)
@@ -22,6 +22,42 @@
<DocumentEvents onModified="Update($fieldStrategyProportionSetOfVessels/text)"/>
</textfield>
+ <checkbox constraints="fieldUseEquationInactivity" id="fieldUseEquationInactivity"
+ origin="$Strategy/inactivityEquationUsed" text="isisfish.strategy.inactivityEquationUsed">
+ <ItemEvents onStateChanged="Update($fieldUseEquationInactivity/selected, $Strategy/inactivityEquationUsed, refreshView($hideablePanelInactivityEquation))"/>
+ </checkbox>
+
+
+ <panel id="hideablePanelInactivityEquation" constraints="hideablePanelInactivityEquation" layout="XMLGridLayout(fr/ifremer/isisfish/ui/input/Strategy.xgl)">
+
+ <hidablePanel constraints="fieldUseEquation"
+ origin="getInactivityEquationUsed($Strategy)"
+ layout="XMLGridLayout(fr/ifremer/isisfish/ui/input/Strategy.xgl)">
+ <label constraints="labelStrategyInactivity" text="isisfish.strategy.inactivity"/>
+ <combobox constraints="fieldStrategyInactivity" id="fieldStrategyInactivity"
+ origin="$Strategy/inactivityEquation" renderer="name" firstNull="true"
+ actionCommand="Update($fieldStrategyInactivity/selectedItem/content, $fieldScriptStrategyInactivity/text)">
+ <ComboBoxModel origin='fr.ifremer.isisfish.datastore.FormuleStorage.getFormules($TopiaContext, "Inactivity")'/>
+ </combobox>
+
+ <button constraints="buttonStrategyInactivitySaveAsModel" text="isisfish.common.saveModel"
+ actionCommand='input.Input.saveEquationAsModel($Strategy/inactivityEquation);refreshView($fieldStrategyInactivity)'/>
+
+ <button constraints="buttonStrategyInactivityEquationEditor" text="isisfish.common.openEditor"
+ actionCommand='input.Input.openEditor($Strategy/inactivityEquation/category,$Strategy/inactivityEquation/name,$Strategy/inactivityEquation/javaInterface,$Strategy/inactivityEquation/content,$fieldScriptStrategyInactivity)'/>
+
+ <editor constraints="fieldScriptStrategyInactivity" askIfNotSaved="false"
+ id="fieldScriptStrategyInactivity"
+ origin="org.codelutin.util.FileUtil.getTempFile($Strategy/inactivityEquation/content, '.java')">
+ <DocumentEvents onModified="Update">
+ <UpdateOrigin
+ target="setEquationInactivity($Strategy, $fieldScriptStrategyInactivity/text)"/>
+ </DocumentEvents>
+ </editor>
+
+ </hidablePanel>
+ </panel>
+
<label constraints="labelStrategyComment" text="isisfish.strategy.comments"/>
<scrollPane constraints="fieldStrategyComment">
<textarea id="fieldStrategyComment" origin="$Strategy/comment">
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xgl
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xgl 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xgl 2008-08-13 18:15:25 UTC (rev 1296)
@@ -20,7 +20,8 @@
<td width="99%" colspan="3" fill="Horizontal">fieldSimulAdvParamsSimulatorSelect</td>
</tr>
<tr>
- <td fill="Horizontal" colspan="2" width="33%">fieldSimulAdvParamsSimulatorLocal</td>
+ <td fill="Horizontal" width="33%">fieldSimulAdvParamsSimulatorLocal</td>
+ <td fill="Horizontal" width="33%">fieldSimulAdvParamsSimulatorSubProcess</td>
<td fill="Horizontal" width="33%">fieldSimulationStatistique</td>
<td fill="Horizontal" width="33%">fieldSimulationCache</td>
</tr>
Modified: branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xml
===================================================================
--- branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xml 2008-08-13 13:17:17 UTC (rev 1295)
+++ branches/isis-fish-3.1.4/src/uimodel/fr/ifremer/isisfish/ui/simulator/AdvancedParams.xml 2008-08-13 18:15:25 UTC (rev 1296)
@@ -33,6 +33,12 @@
origin="$SimulationParameter/local"
actionCommand="Update($fieldSimulAdvParamsSimulatorLocal/selected)"/>
+ <checkbox text="isisfish.advancedParams.subProcessSimulation"
+ constraints="fieldSimulAdvParamsSimulatorSubProcess"
+ id="fieldSimulAdvParamsSimulatorSubProcess"
+ origin="$SimulationParameter/subProcess"
+ actionCommand="Update($fieldSimulAdvParamsSimulatorSubProcess/selected)"/>
+
<!--
|
| Trace/Cache option
1
0
r1295 - in branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish: datastore/migration simulator
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
by bpoussin@users.labs.libre-entreprise.org 13 Aug '08
13 Aug '08
Author: bpoussin
Date: 2008-08-13 13:17:17 +0000 (Wed, 13 Aug 2008)
New Revision: 1295
Modified:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
Log:
SimulationManager
- utilisation de execute et non submit sur les executors pour forcer l'execution
- lors de la demande du control si on ne le trouve pas dans les simulations actives, recherche dans les simulations ternimees
Migration
- la migration fonctionne
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-12 15:23:29 UTC (rev 1294)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-13 13:17:17 UTC (rev 1295)
@@ -98,7 +98,7 @@
}
}
- return MigrationChoice.NO_MIGRATION; // force false during test // result;
+ return result;
}
private void migrateTo3_2(Connection conn) throws SQLException {
@@ -112,8 +112,10 @@
"alter table STRATEGY add column INACTIVITYEQUATION VARCHAR(255);",
};
for (String sql : sqls) {
+ log.info("try " + sql);
PreparedStatement sta = conn.prepareStatement(sql);
sta.executeUpdate();
+ log.info("done " + sql);
}
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-12 15:23:29 UTC (rev 1294)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-13 13:17:17 UTC (rev 1295)
@@ -36,8 +36,6 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.types.Date;
import java.beans.PropertyChangeEvent;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18nf._;
@@ -67,7 +65,10 @@
static protected SimulationManager instance = null;
- protected boolean autoLaunch = false;
+ // FIXME pouvoir configurer ceci en fichier de config
+ // FIXME ainsi que la mise a false, lors de la simulation de la derniere
+ // (sans doute ajoute un boolean, simulationListAsQueue = true|false)
+ protected boolean autoLaunch = true;
protected ListenerSet<SimulationQueueListener> listeners = new ListenerSet<SimulationQueueListener>();
protected PropertyChangeSupport propertyListeners = new PropertyChangeSupport(this);
@@ -163,6 +164,7 @@
synchronized(this) {
while (!isAutoLaunch()) {
try {
+ log.info("autoLaunch is false waiting queue start");
this.wait();
} catch (InterruptedException eee) {
log.warn("Error during wait autoLaunch flag", eee);
@@ -193,19 +195,22 @@
// on construit le bon type de SimulationItem pour le job
SimulationItem item = null;
if (param.getUseAnalysePlan()) {
+ // c un plan d'analyse, il peut etre independant ou dependant
if (!param.isIndependentPlan()) {
item = new SimulationItemPlan(id, param);
- executor.submit(new SimulationJob(this, item));
+ executor.execute(new SimulationJob(this, item));
} else {
// on met dans la queue local le process de generation de toutes
// les simus
item = new SimulationItemPlanIndependent(id, param);
- localExecutor.submit(
+ localExecutor.execute(
new PrepareIndependentSimulationJob(this, executor, item));
}
} else {
+ // une simulation normal
item = new SimulationItem(id, param);
- executor.submit(new SimulationJob(this, item));
+ log.info("Simulation added to executor: " + executor.isShutdown() + ", " + executor.isTerminated());
+ executor.execute(new SimulationJob(this, item));
}
fireAddEvent(id, item); // must be before thread notification because thread look in map
}
@@ -338,6 +343,10 @@
public SimulationControl getControl(String id) {
SimulationControl result = null;
SimulationItem item = map.get(id);
+ if (item == null) {
+ // try to find it in done simulation
+ item = mapDones.get(id);
+ }
if (item != null) {
result = item.control;
}
@@ -360,6 +369,7 @@
// on ne met jamais dans la queue done les simulations de plan
// sauf si elle echoue
result = false;
+// FIXME a revoir la condition avec showOnly error et showOnly queue (qui ne sert plus)
} else if (!(config.isSimulationShowOnlyError() &&
!(item instanceof SimulationItemPlan) &&
item.getSimulation().getInformation().hasError())) {
@@ -655,7 +665,7 @@
// plus celles en cours d'affichees
while (item.hasNext()) {
try {
- executor.submit(new SimulationJob(simulationManager, item.next()));
+ executor.execute(new SimulationJob(simulationManager, item.next()));
} catch (Exception eee) {
log.error("Can't add simulation: " + item, eee);
}
@@ -689,6 +699,7 @@
}
public void run() {
+ log.info("Start simulation : " + simItem.id);
simulationManager.waitAutoLaunch();
try {
// si l'simItem exist encore (que l'utilisateur ne la pas retire)
1
0
r1294 - in branches/isis-fish-3.1.4/src: java/fr/ifremer/isisfish java/fr/ifremer/isisfish/datastore/migration java/fr/ifremer/isisfish/entities java/fr/ifremer/isisfish/equation java/fr/ifremer/isisfish/simulator java/fr/ifremer/isisfish/ui/simulator xmi
by bpoussin@users.labs.libre-entreprise.org 12 Aug '08
by bpoussin@users.labs.libre-entreprise.org 12 Aug '08
12 Aug '08
Author: bpoussin
Date: 2008-08-12 15:23:29 +0000 (Tue, 12 Aug 2008)
New Revision: 1294
Added:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/SoVTechnicalEfficiencyEquation.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/StrategyInactivityEquation.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
Removed:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java
Modified:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyImpl.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java
branches/isis-fish-3.1.4/src/xmi/isis-fish.zargo
Log:
- Implantation dans le modele des nouvelles equations
- passage de version en 3.2.0
- ajout du code pour upgrader les tables (alter table)
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -42,10 +42,9 @@
*/
public class IsisConfig extends IsisAbstractConfigMain {
- protected final static VersionNumber version = new VersionNumber(3, 1, 4);
+ protected final static VersionNumber version = new VersionNumber(3, 2, 0);
protected final static VersionNumber databaseVersion = new VersionNumber(
- 0);
-// FIXME a remettre apres les tests de simu version.getNumber(0), version.getNumber(1));
+ version.getNumber(0), version.getNumber(1));
public static VersionNumber getVersionNumber() {
return version;
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -19,6 +19,8 @@
package fr.ifremer.isisfish.datastore.migration;
import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
import javax.swing.JOptionPane;
import org.apache.commons.logging.Log;
@@ -99,19 +101,20 @@
return MigrationChoice.NO_MIGRATION; // force false during test // result;
}
- private void migrateTo3_2(Connection conn) {
+ private void migrateTo3_2(Connection conn) throws SQLException {
log.info("Migrate to version 3.2");
//alteration du schema
// nouvelles equations dans les tables
-
- // creation de valeur par defaut pour les equations
-
-
- // recuperation des valeurs de ???
-
- // creation de l'equation avec ces valeurs
-
- // sauvegarde de l'equation
+
+ String [] sqls = new String[]{
+ "alter table SETOFVESSELS add column TECHNICALEFFICIENCYEQUATION VARCHAR(255);",
+ "alter table STRATEGY add column INACTIVITYEQUATIONUSED BIT default false;",
+ "alter table STRATEGY add column INACTIVITYEQUATION VARCHAR(255);",
+ };
+ for (String sql : sqls) {
+ PreparedStatement sta = conn.prepareStatement(sql);
+ sta.executeUpdate();
+ }
}
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -1,10 +1,19 @@
package fr.ifremer.isisfish.entities;
+import static org.codelutin.i18n.I18n._;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import java.io.Serializable;
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.StorageException;
+import fr.ifremer.isisfish.equation.Language;
+import fr.ifremer.isisfish.equation.SoVTechnicalEfficiencyEquation;
+import fr.ifremer.isisfish.types.Date;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.TopiaException;
/**
* Implantation des operations pour l'entité SetOfVessels.
@@ -13,6 +22,11 @@
private static final long serialVersionUID = 1L;
+ /**
+ * Logger for this class
+ */
+ private static final Log log = LogFactory.getLog(SetOfVesselsImpl.class);
+
public FisheryRegion getFisheryRegion() {
try {
FisheryRegion result = RegionStorage.getFisheryRegion(getTopiaContext());
@@ -22,6 +36,68 @@
}
}
+ /**
+ * override to change name of equation
+ * @see fr.ifremer.isisfish.entities.SetOfVesselsAbstract#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String value) {
+ super.setName(value);
+ Equation eq = getTechnicalEfficiencyEquation();
+ if (eq != null) {
+ eq.setName(getName());
+ }
+ }
+
+ /**
+ * Compute or return inactivity days
+ * @param length length of group
+ * @param group group
+ * @return age in month
+ */
+ @Override
+ public double getTechnicalEfficiency(Date date, Metier metier) {
+ double result = 0;
+
+ try {
+ Gear gear = metier.getGear();
+ Equation eq = getTechnicalEfficiencyEquation();
+ if (eq != null) {
+ result = eq.evaluate("date", date, "metier", metier, "gear", gear);
+ }
+ } catch (Exception eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Error in technical efficiency equation");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("StackTrace", eee);
+ }
+ }
+ return result;
+ }
+
+ public void setEquationTechnicalEfficiency(String content) {
+ try {
+ Equation eq = getTechnicalEfficiencyEquation();
+
+ if (eq == null) {
+ EquationDAO dao = IsisFishDAOHelper.getEquationDAO(getTopiaContext());
+ // create Growth equation
+ eq = dao.create();
+ eq.setCategory("Inactivity");
+ eq.setJavaInterface(SoVTechnicalEfficiencyEquation.class);
+ eq.setLanguage(Language.JAVA);
+ setTechnicalEfficiencyEquation(eq);
+ }
+
+ eq.setName(getName());
+ eq.setContent(content);
+ eq.update();
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException(_("isisfish.change.equation"), eee);
+ }
+ }
+
/* (non-Javadoc)
* @see fr.ifremer.isisfish.entities.FisheryRegionAbstract#toString()
*/
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyImpl.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -14,6 +14,8 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.StorageException;
+import fr.ifremer.isisfish.equation.Language;
+import fr.ifremer.isisfish.equation.StrategyInactivityEquation;
import fr.ifremer.isisfish.types.Month;
/**
@@ -34,6 +36,19 @@
throw new IsisFishRuntimeException(eee);
}
}
+
+ /**
+ * override to change name of equation
+ * @see fr.ifremer.isisfish.entities.StrategyAbstract#setName(java.lang.String)
+ */
+ @Override
+ public void setName(String value) {
+ super.setName(value);
+ Equation eq = getInactivityEquation();
+ if (eq != null) {
+ eq.setName(getName());
+ }
+ }
/* (non-Javadoc)
* @see fr.ifremer.isisfish.entities.StrategyAbstract#getStrategyMonthInfo()
@@ -88,6 +103,55 @@
return result;
}
+ /**
+ * Compute or return inactivity days
+ * @param length length of group
+ * @param group group
+ * @return age in month
+ */
+ public double getInactivityDays(Month month) {
+ double result = 0;
+
+ StrategyMonthInfo info = getStrategyMonthInfo(month);
+ if (!getInactivityEquationUsed()) {
+ result = info.getMinInactivityDays();
+ } else {
+ try {
+ Equation eq = getInactivityEquation();
+ result = eq.evaluate("month", month, "info", info);
+ } catch (Exception eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Error in inactivityDays equation");
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("StackTrace", eee);
+ }
+ }
+ }
+ return result;
+ }
+ public void setEquationInactivity(String content) {
+ try {
+ Equation eq = getInactivityEquation();
+
+ if (eq == null) {
+ EquationDAO dao = IsisFishDAOHelper.getEquationDAO(getTopiaContext());
+ // create Growth equation
+ eq = dao.create();
+ eq.setCategory("Inactivity");
+ eq.setJavaInterface(StrategyInactivityEquation.class);
+ eq.setLanguage(Language.JAVA);
+ setInactivityEquation(eq);
+ }
+
+ eq.setName(getName());
+ eq.setContent(content);
+ eq.update();
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException(_("isisfish.change.equation"), eee);
+ }
+ }
+
/* (non-Javadoc)
* @see fr.ifremer.isisfish.entities.StrategyAbstract#toString()
*/
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/StrategyMonthInfoImpl.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -152,7 +152,10 @@
public void computeNumberOfTrips() {
TripType tripType = getTripType();
- int inactivity = getMinInactivityDays();
+ // remplace un simple getMinInactivityDays(), pour pouvoir utiliser une
+ // equation si besoin (tout est pret, il ne manque que l'interface
+ // graphique pour saisir l'equation dans strategie
+ double inactivity = getStrategy().getInactivityDays(getMonth());
if(tripType != null && tripType.getTripDuration() != null && inactivity >= 0){
int nbDayMonth = getMonth().getNumbersOfDays();
double result = (int)((nbDayMonth - inactivity) / tripType.getTripDuration().getDay());
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/SoVTechnicalEfficiencyEquation.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/SoVTechnicalEfficiencyEquation.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/SoVTechnicalEfficiencyEquation.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+package fr.ifremer.isisfish.equation;
+
+import fr.ifremer.isisfish.entities.Gear;
+import fr.ifremer.isisfish.entities.Metier;
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.util.Args;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public interface SoVTechnicalEfficiencyEquation {
+
+ /**
+ * @param context
+ * @param metier le metier pour lequel on demande le calcul
+ * @param gear l'engin utilise par le metier
+ * @return
+ */
+ @Args({"context", "metier", "gear"})
+ public double compute(SimulationContext context, Metier metier, Gear gear) throws Exception;
+
+}
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/StrategyInactivityEquation.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/StrategyInactivityEquation.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/equation/StrategyInactivityEquation.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+package fr.ifremer.isisfish.equation;
+
+import fr.ifremer.isisfish.entities.StrategyMonthInfo;
+import fr.ifremer.isisfish.simulator.SimulationContext;
+import fr.ifremer.isisfish.types.Month;
+import fr.ifremer.isisfish.util.Args;
+
+/**
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public interface StrategyInactivityEquation {
+
+ /**
+ *
+ * @param context
+ * @param month le mois courant de simulation
+ * @param info l'objet associe a la strategie pour le mois courant
+ * @return
+ */
+ @Args({"context", "month", "info"})
+ public double compute(SimulationContext context, Month month, StrategyMonthInfo info) throws Exception;
+
+}
Deleted: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -1,372 +0,0 @@
-/* *##%
- * Copyright (C) 2006
- * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
- *
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * PopulationMonitor.java
- *
- * Created: 21 août 2006 15:41:18
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package fr.ifremer.isisfish.simulator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.collections.MapIterator;
-import org.apache.commons.collections.keyvalue.MultiKey;
-import org.apache.commons.collections.map.MultiKeyMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
-import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.types.Month;
-
-
-/**
- * Classe permettant le suivi des populations de la simulation.
- *
- * FIXME: certain calcul sont les memes que ceux implanter dans les scripts
- * a cause du groupe des juveniles qui n'est pas un vrai groupe de population.
- * Il serait bon que ce groupe deviennent un vrai groupe et que ce code specifique
- * puisse etre supprimer.
- *
- *
- * @author poussin
- */
-public class PopulationMonitor {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(PopulationMonitor.class);
-
- /** current number of fish by Pop */
- protected Map<Population, MatrixND> Ns = new HashMap<Population, MatrixND>();
- /** reproduction key: <date, pop> value:<MatrixND> */
- protected MultiKeyMap reproductions = new MultiKeyMap();
- /** discard key: <date, pop> value:<MatrixND> */
- protected MultiKeyMap discards = new MultiKeyMap();
- /** catch per population, only last catch is remaining */
- protected Map<Population, MatrixND> catchs = new HashMap<Population, MatrixND>();
- /** catch per population, only last catch is remaining */
- protected Map<Population, MatrixND> holdCatchs = new HashMap<Population, MatrixND>();
- protected double totalHoldCatch = 0;
-
- /**
- * Return all population actualy in PopulationMonitor
- * @return new list of Population
- */
- public List<Population> getPopulations() {
- ArrayList<Population> result = new ArrayList<Population>(Ns.keySet());
- return result;
- }
-
- /**
- * Return current biomass for species
- * @param species
- * @return
- */
- public double getBiomass(Species species) {
- double result = 0;
-
- for (Population pop : species.getPopulation()) {
- result += getBiomass(pop);
- }
-
- return result;
- }
-
- /**
- * Return current biomass for population
- * @param pop
- * @return
- */
- public double getBiomass(Population pop) {
- double result = 0;
-
- MatrixND n = getN(pop);
- if (n != null) {
- n = n.sumOverDim(1);
- for (MatrixIterator i=n.iterator(); i.next();){
- Object [] coord = i.getSemanticsCoordinates();
- PopulationGroup group = (PopulationGroup)coord[0];
- result += i.getValue() * group.getMeanWeight();
- }
- }
-
- return result;
- }
-
- /**
- * Return current numbers for population
- * @param pop
- * @return
- */
- public MatrixND getN(Population pop) {
- MatrixND result = Ns.get(pop);
-
- if (result != null) {
- // change semantics with list from argument to ensure that
- // semantics don't used too old context
- result.setSemantics(0, pop.getPopulationGroup());
- result.setSemantics(1, pop.getPopulationZone());
- }
-
- return result;
- }
-
- public void setN(Population pop, MatrixND mat) {
- Ns.put(pop, mat);
- }
-
- /**
- * @return Returns the reproduction.
- */
- public MatrixND getReproduction(Date date, Population pop) {
- return (MatrixND)this.reproductions.get(date, pop);
- }
-
- /**
- * @param reproduction The reproduction to set.
- */
- public void setReproduction(Date date, Population pop, MatrixND repro) {
- this.reproductions.put(date, pop, repro);
- }
-
- /**
- * Applique de la mortalite naturelle aux poissons qui sont pas encore
- * dans les classes de populations. (Reproduction)
- * @param pop
- */
- public void applyReproductionMortality(Population pop) {
- for (MapIterator i=reproductions.mapIterator(); i.hasNext();) {
- i.next();
- MultiKey key = (MultiKey)i.getKey();
- if (pop.equals(key.getKey(1))) {
- MatrixND reproduction = (MatrixND)i.getValue();
- if (log.isTraceEnabled()) {
- log.trace("Matrix repro before mortality: " + reproduction);
- }
- for(MatrixIterator mi=reproduction.iterator(); mi.next();){
- Object[] sems = mi.getSemanticsCoordinates();
- Zone z = (Zone)sems[0];
- double coeff = pop.getNaturalDeathBirth(z);
- if (log.isTraceEnabled()) {
- log.trace("NaturalDeath zone " + z + "=" + coeff);
- }
- mi.setValue(mi.getValue() * Math.exp(-coeff/Month.NUMBER_OF_MONTH));
- }
- if (log.isTraceEnabled()) {
- log.trace("Matrix repro after mortality: " + reproduction);
- }
- }
- }
- }
-
- /**
- * @todo les reproductions qui sont trop veille pour encore servir
- * doivent être supprimées. c-a-d date < currentDate - etalement - gap between repro recru
- * Une autre facon de faire est de supprimer les repro == 0 car normalement
- * toute la repro doit etre utilisé au bout d'un certain temps
- *
- * @param date
- * @param pop
- * @return
- */
- public MatrixND getRecruitment(Date date, Population pop) {
- MatrixND matEtalement = pop.getRecruitmentDistribution();
- int etalement = matEtalement.getDim(0);
-
- MatrixND result = MatrixFactory.getInstance().create(
- new List[]{pop.getPopulationGroup(), pop.getPopulationZone()});
-
- // pour chaque
- for(int e=0; e<etalement; e++){
- // recuperation de la reproduction stucture en zone repro
- Date d = new Date(date.getDate() - e -
- pop.getMonthGapBetweenReproRecrutement());
- MatrixND repro = (MatrixND)reproductions.get(d, pop);
-
- if(repro != null){ // si une repro existe pour le mois
-
- // on fait la correspondance entre les zones repro et
- // recrutement
-
- PopulationGroup classe;
- int indiceClasse = 0;
- // si on a change d'annee le recrutement ne se fait pas en
- // classe 0 mais en classe 1, si on a change 2 fois d'annee
- // le recrutement se fait en age 2, etc.
- classe = pop.getPopulationGroup().get(indiceClasse);
-
- List<Zone> zoneRepros = pop.getReproductionZone();
-
- // on multiplie la repro par le coeff de recrutement
- double coeff = matEtalement.getValue(e);
-
- MatrixND matRepro = repro.copy();
- matRepro = matRepro.mults(coeff);
-
- matRepro.setSemantics(0, zoneRepros);
-
- MatrixND mapping = pop.getMappingZoneReproZoneRecru();
- for(Zone zoneRepro : zoneRepros){
- MatrixND submapping = mapping.getSubMatrix(0, new Object[]{zoneRepro});
- for (MatrixIterator i=submapping.iterator(); i.hasNext();) {
- i.next();
- Object[] sem = i.getSemanticsCoordinates();
- Zone zoneRecru = (Zone)sem[1];
- double c = i.getValue();
- result.setValue(classe, zoneRecru, c*matRepro.getValue(zoneRepro)
- +result.getValue(classe, zoneRecru));
- }
- }
- }
- }
-
- if(pop.getSpecies().getAgeGroupType()){
- // conversion et retour de la matrice en vecteur
- MatrixND N = pop.N2DToN1D(result);
- // on applique les migrations et le changement d'age sur le resultat
- // on suppose que la reproduction est toujours dans une seul saison
- Date dateRepro = new Date(date.getDate() -
- pop.getMonthGapBetweenReproRecrutement());
-
- // recherche les saisons des differents mois entre les deux dates
- List<PopulationSeasonInfo> infos = pop.getPopulationSeasonInfo();
- List<PopulationSeasonInfo> usedSeasons = new ArrayList<PopulationSeasonInfo>();
-
- while (date.after(dateRepro)) {
- dateRepro = dateRepro.next();
- Month month = dateRepro.getMonth();
- for (PopulationSeasonInfo info : infos) {
- if (month.equals(info.getFirstMonth())) {
- usedSeasons.add(info);
- dateRepro = new Date(dateRepro.getDate() + info.getMonths().size() - 1); // -1 because, for have next()
- break;
- }
- }
- }
-
- for(PopulationSeasonInfo info : usedSeasons){
- Month month = info.getFirstMonth();
- MatrixND CA = info.getGroupChangeMatrix(month);
- MatrixND MI = info.getMigrationMatrix(month, result);
- MatrixND tmp0 = N.mult(CA);
- MatrixND tmp2 = tmp0.mult(MI);
- N = tmp2;
- }
- result = pop.split2D(N);
- }
- return result;
- }
-
- /**
- * @param catchPerStrategyMet
- */
- public void holdCatch(Population pop, MatrixND catchPerStrategyMet) {
- catchs.put(pop, catchPerStrategyMet);
-
- MatrixND holdCatch = holdCatchs.get(pop);
- if (holdCatch == null) {
- holdCatch = MatrixFactory.getInstance().create(catchPerStrategyMet);
- holdCatchs.put(pop, holdCatch);
- } else {
- holdCatch.add(catchPerStrategyMet);
- }
-
- // compute total
- for(MatrixIterator i=catchPerStrategyMet.iterator(); i.next();){
- this.totalHoldCatch += i.getValue();
- }
-
- }
-
- /**
- * @param pop
- * @return
- */
- public MatrixND getCatch(Population pop) {
- MatrixND result = catchs.get(pop);
- return result;
- }
-
- /**
- * @param pop
- * @return
- */
- public MatrixND getHoldCatch(Population pop) {
- MatrixND result = holdCatchs.get(pop);
- return result;
- }
-
- /**
- * @param pop
- * @return
- */
- public double getTotalHoldCatch(Population pop) {
- double result = totalHoldCatch;
- return result;
- }
-
- /**
- * raz capture cumulée de toutes les pops
- */
- public void clearCatch() {
- catchs.clear();
- holdCatchs.clear();
- totalHoldCatch = 0;
- }
-
- /**
- * @param date
- * @param pop
- * @return
- */
- public MatrixND getDiscard(Date date, Population pop) {
- MatrixND result = (MatrixND)discards.get(date, pop);
- return result;
- }
-
- public void addDiscard(Date date, Population pop, MatrixND discard) {
- MatrixND tmp = (MatrixND)discards.get(date, pop);
- if (tmp == null) {
- tmp = discard.copy();
- discards.put(date, pop, tmp);
- } else {
- tmp.add(discard);
- }
- }
-}
-
-
Copied: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java (from rev 1292, branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java)
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -0,0 +1,399 @@
+/* *##%
+ * Copyright (C) 2006
+ * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/* *
+ * PopulationMonitor.java
+ *
+ * Created: 21 août 2006 15:41:18
+ *
+ * @author poussin
+ * @version $Revision: 428 $
+ *
+ * Last update: $Date: 2007-10-15 14:56:13 +0200 (lun, 15 oct 2007) $
+ * by : $Author: bpoussin $
+ */
+
+package fr.ifremer.isisfish.simulator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.types.Month;
+import java.util.Collections;
+
+
+/**
+ * Classe permettant le suivi des populations de la simulation.
+ * <p>
+ * Cette classe est normalement multi-thread safe
+ * <p>
+ * FIXME: certain calcul sont les memes que ceux implanter dans les scripts
+ * a cause du groupe des juveniles qui n'est pas un vrai groupe de population.
+ * Il serait bon que ce groupe deviennent un vrai groupe et que ce code specifique
+ * puisse etre supprimer.
+ *
+ *
+ * @author poussin
+ */
+public class PopulationMonitor {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(PopulationMonitor.class);
+
+ /** La liste des pops monitorer par cette instance */
+ protected List<Population> pops = null;
+ /** current number of fish by Pop */
+ protected Map<Population, MatrixND> Ns = new HashMap<Population, MatrixND>();
+ /** reproduction key: <date, pop> value:<MatrixND> */
+ protected Map<Population, Map<Date, MatrixND>> reproductions = new HashMap<Population, Map<Date, MatrixND>>();
+ /** discard key: <date, pop> value:<MatrixND> */
+ protected Map<Population, Map<Date, MatrixND>> discards = new HashMap<Population, Map<Date, MatrixND>>();
+ /** catch per population, only last catch is remaining */
+ protected Map<Population, MatrixND> catchs = new HashMap<Population, MatrixND>();
+ /** catch per population, only last catch is remaining */
+ protected Map<Population, MatrixND> holdCatchs = new HashMap<Population, MatrixND>();
+ protected double totalHoldCatch = 0;
+
+ /**
+ * Initialise le monitor pour l'ensemble de pop passe en parametre.
+ * Normalement cet init est fait dans le thread principale de la simulation
+ * et il n'y a pas de besoin de le synchroniser.
+ *
+ * Cet init permet d'avoir ensuite le maxime de variable en lecture, et donc
+ * de permettre le multithreading de facon legere (pas de synchronise) et
+ * sur (pas de concurent modification exception)
+ *
+ * @param pops
+ */
+ public void init(List<Population> pops) {
+ this.pops = Collections.unmodifiableList(new ArrayList<Population>(pops));
+ for (Population pop : this.pops) {
+ reproductions.put(pop, new HashMap<Date, MatrixND>());
+ discards.put(pop, new HashMap<Date, MatrixND>());
+ }
+ }
+
+ /**
+ * Return all population actualy in PopulationMonitor
+ * @return new list of Population
+ */
+ public List<Population> getPopulations() {
+ return pops;
+ }
+
+ /**
+ * Return current biomass for species
+ * @param species
+ * @return
+ */
+ public double getBiomass(Species species) {
+ double result = 0;
+
+ for (Population pop : species.getPopulation()) {
+ result += getBiomass(pop);
+ }
+
+ return result;
+ }
+
+ /**
+ * Return current biomass for population
+ * @param pop
+ * @return
+ */
+ public double getBiomass(Population pop) {
+ double result = 0;
+
+ MatrixND n = getN(pop);
+ if (n != null) {
+ n = n.sumOverDim(1);
+ for (MatrixIterator i=n.iterator(); i.next();){
+ Object [] coord = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup)coord[0];
+ result += i.getValue() * group.getMeanWeight();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Return current numbers for population
+ * @param pop
+ * @return
+ */
+ public MatrixND getN(Population pop) {
+ MatrixND result = Ns.get(pop);
+
+ if (result != null) {
+ // change semantics with list from argument to ensure that
+ // semantics don't used too old context
+ result.setSemantics(0, pop.getPopulationGroup());
+ result.setSemantics(1, pop.getPopulationZone());
+ }
+
+ return result;
+ }
+
+ public void setN(Population pop, MatrixND mat) {
+ Ns.put(pop, mat);
+ }
+
+ /**
+ * @return Returns the reproduction.
+ */
+ public MatrixND getReproduction(Date date, Population pop) {
+ return this.reproductions.get(pop).get(date);
+ }
+
+ /**
+ * @param reproduction The reproduction to set.
+ */
+ public void setReproduction(Date date, Population pop, MatrixND repro) {
+ reproductions.get(pop).put(date, repro);
+ }
+
+ /**
+ * Applique de la mortalite naturelle aux poissons qui sont pas encore
+ * dans les classes de populations. (Reproduction)
+ * @param pop
+ */
+ public void applyReproductionMortality(Population pop) {
+ for (MatrixND reproduction : reproductions.get(pop).values()) {
+ if (log.isTraceEnabled()) {
+ log.trace("Matrix repro before mortality: " + reproduction);
+ }
+
+ for (MatrixIterator mi = reproduction.iterator(); mi.next();) {
+ Object[] sems = mi.getSemanticsCoordinates();
+ Zone z = (Zone) sems[0];
+ double coeff = pop.getNaturalDeathBirth(z);
+ if (log.isTraceEnabled()) {
+ log.trace("NaturalDeath zone " + z + "=" + coeff);
+ }
+ mi.setValue(mi.getValue() * Math.exp(-coeff / Month.NUMBER_OF_MONTH));
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Matrix repro after mortality: " + reproduction);
+ }
+ }
+ }
+
+ /**
+ * @todo les reproductions qui sont trop veille pour encore servir
+ * doivent être supprimées. c-a-d date < currentDate - etalement - gap between repro recru
+ * Une autre facon de faire est de supprimer les repro == 0 car normalement
+ * toute la repro doit etre utilisé au bout d'un certain temps
+ *
+ * @param date
+ * @param pop
+ * @return
+ */
+ public MatrixND getRecruitment(Date date, Population pop) {
+ MatrixND matEtalement = pop.getRecruitmentDistribution();
+ int etalement = matEtalement.getDim(0);
+
+ MatrixND result = MatrixFactory.getInstance().create(
+ new List[]{pop.getPopulationGroup(), pop.getPopulationZone()});
+
+ // pour chaque
+ for(int e=0; e<etalement; e++){
+ // recuperation de la reproduction stucture en zone repro
+ Date d = new Date(date.getDate() - e -
+ pop.getMonthGapBetweenReproRecrutement());
+ MatrixND repro = (MatrixND)reproductions.get(pop).get(d);
+
+ if(repro != null){ // si une repro existe pour le mois
+
+ // on fait la correspondance entre les zones repro et
+ // recrutement
+
+ PopulationGroup classe;
+ int indiceClasse = 0;
+ // si on a change d'annee le recrutement ne se fait pas en
+ // classe 0 mais en classe 1, si on a change 2 fois d'annee
+ // le recrutement se fait en age 2, etc.
+ classe = pop.getPopulationGroup().get(indiceClasse);
+
+ List<Zone> zoneRepros = pop.getReproductionZone();
+
+ // on multiplie la repro par le coeff de recrutement
+ double coeff = matEtalement.getValue(e);
+
+ MatrixND matRepro = repro.copy();
+ matRepro = matRepro.mults(coeff);
+
+ matRepro.setSemantics(0, zoneRepros);
+
+ MatrixND mapping = pop.getMappingZoneReproZoneRecru();
+ for(Zone zoneRepro : zoneRepros){
+ MatrixND submapping = mapping.getSubMatrix(0, new Object[]{zoneRepro});
+ for (MatrixIterator i=submapping.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sem = i.getSemanticsCoordinates();
+ Zone zoneRecru = (Zone)sem[1];
+ double c = i.getValue();
+ result.setValue(classe, zoneRecru, c*matRepro.getValue(zoneRepro)
+ +result.getValue(classe, zoneRecru));
+ }
+ }
+ }
+ }
+
+ if(pop.getSpecies().getAgeGroupType()){
+ // conversion et retour de la matrice en vecteur
+ MatrixND N = pop.N2DToN1D(result);
+ // on applique les migrations et le changement d'age sur le resultat
+ // on suppose que la reproduction est toujours dans une seul saison
+ Date dateRepro = new Date(date.getDate() -
+ pop.getMonthGapBetweenReproRecrutement());
+
+ // recherche les saisons des differents mois entre les deux dates
+ List<PopulationSeasonInfo> infos = pop.getPopulationSeasonInfo();
+ List<PopulationSeasonInfo> usedSeasons = new ArrayList<PopulationSeasonInfo>();
+
+ while (date.after(dateRepro)) {
+ dateRepro = dateRepro.next();
+ Month month = dateRepro.getMonth();
+ for (PopulationSeasonInfo info : infos) {
+ if (month.equals(info.getFirstMonth())) {
+ usedSeasons.add(info);
+ dateRepro = new Date(dateRepro.getDate() + info.getMonths().size() - 1); // -1 because, for have next()
+ break;
+ }
+ }
+ }
+
+ for(PopulationSeasonInfo info : usedSeasons){
+ Month month = info.getFirstMonth();
+ MatrixND CA = info.getGroupChangeMatrix(month);
+ MatrixND MI = info.getMigrationMatrix(month, result);
+ MatrixND tmp0 = N.mult(CA);
+ MatrixND tmp2 = tmp0.mult(MI);
+ N = tmp2;
+ }
+ result = pop.split2D(N);
+ }
+ return result;
+ }
+
+ /**
+ * @param catchPerStrategyMet
+ */
+ public void holdCatch(Population pop, MatrixND catchPerStrategyMet) {
+ catchs.put(pop, catchPerStrategyMet);
+
+ MatrixND holdCatch = holdCatchs.get(pop);
+ if (holdCatch == null) {
+ holdCatch = MatrixFactory.getInstance().create(catchPerStrategyMet);
+ holdCatchs.put(pop, holdCatch);
+ } else {
+ holdCatch.add(catchPerStrategyMet);
+ }
+
+ // compute total
+ for(MatrixIterator i=catchPerStrategyMet.iterator(); i.next();){
+ this.totalHoldCatch += i.getValue();
+ }
+
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public MatrixND getCatch(Population pop) {
+ MatrixND result = catchs.get(pop);
+ return result;
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public MatrixND getHoldCatch(Population pop) {
+ MatrixND result = holdCatchs.get(pop);
+ return result;
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public double getTotalHoldCatch(Population pop) {
+ double result = totalHoldCatch;
+ return result;
+ }
+
+ /**
+ * raz capture cumulée de toutes les pops
+ */
+ public void clearCatch() {
+ catchs.clear();
+ holdCatchs.clear();
+ totalHoldCatch = 0;
+ }
+
+ /**
+ * @param date
+ * @param pop
+ * @return
+ */
+ public MatrixND getDiscard(Date date, Population pop) {
+ MatrixND result = discards.get(pop).get(date);
+ return result;
+ }
+
+ /**
+ * FIXME: discards n'est jamais vider, on le conserve pour toutes les annees
+ * il serait bon de faire un peu le menage de temps en temps.
+ *
+ * @param date
+ * @param pop
+ * @param discard
+ */
+ public void addDiscard(Date date, Population pop, MatrixND discard) {
+ Map<Date, MatrixND> oneDiscard = discards.get(pop);
+ synchronized(oneDiscard) {
+ MatrixND tmp = oneDiscard.get(date);
+ if (tmp == null) {
+ tmp = discard.copy();
+ discards.get(pop).put(date, tmp);
+ } else {
+ tmp.add(discard);
+ }
+ }
+ }
+}
+
+
Deleted: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -1,399 +0,0 @@
-/* *##%
- * Copyright (C) 2006
- * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
- *
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * PopulationMonitor.java
- *
- * Created: 21 août 2006 15:41:18
- *
- * @author poussin
- * @version $Revision: 428 $
- *
- * Last update: $Date: 2007-10-15 14:56:13 +0200 (lun, 15 oct 2007) $
- * by : $Author: bpoussin $
- */
-
-package fr.ifremer.isisfish.simulator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.codelutin.math.matrix.MatrixFactory;
-import org.codelutin.math.matrix.MatrixIterator;
-import org.codelutin.math.matrix.MatrixND;
-
-import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationGroup;
-import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
-import fr.ifremer.isisfish.entities.Species;
-import fr.ifremer.isisfish.entities.Zone;
-import fr.ifremer.isisfish.types.Date;
-import fr.ifremer.isisfish.types.Month;
-import java.util.Collections;
-
-
-/**
- * Classe permettant le suivi des populations de la simulation.
- * <p>
- * Cette classe est normalement multi-thread safe
- * <p>
- * FIXME: certain calcul sont les memes que ceux implanter dans les scripts
- * a cause du groupe des juveniles qui n'est pas un vrai groupe de population.
- * Il serait bon que ce groupe deviennent un vrai groupe et que ce code specifique
- * puisse etre supprimer.
- *
- *
- * @author poussin
- */
-public class PopulationMonitorMultiThread {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(PopulationMonitorMultiThread.class);
-
- /** La liste des pops monitorer par cette instance */
- protected List<Population> pops = null;
- /** current number of fish by Pop */
- protected Map<Population, MatrixND> Ns = new HashMap<Population, MatrixND>();
- /** reproduction key: <date, pop> value:<MatrixND> */
- protected Map<Population, Map<Date, MatrixND>> reproductions = new HashMap<Population, Map<Date, MatrixND>>();
- /** discard key: <date, pop> value:<MatrixND> */
- protected Map<Population, Map<Date, MatrixND>> discards = new HashMap<Population, Map<Date, MatrixND>>();
- /** catch per population, only last catch is remaining */
- protected Map<Population, MatrixND> catchs = new HashMap<Population, MatrixND>();
- /** catch per population, only last catch is remaining */
- protected Map<Population, MatrixND> holdCatchs = new HashMap<Population, MatrixND>();
- protected double totalHoldCatch = 0;
-
- /**
- * Initialise le monitor pour l'ensemble de pop passe en parametre.
- * Normalement cet init est fait dans le thread principale de la simulation
- * et il n'y a pas de besoin de le synchroniser.
- *
- * Cet init permet d'avoir ensuite le maxime de variable en lecture, et donc
- * de permettre le multithreading de facon legere (pas de synchronise) et
- * sur (pas de concurent modification exception)
- *
- * @param pops
- */
- public void init(List<Population> pops) {
- this.pops = Collections.unmodifiableList(new ArrayList<Population>(pops));
- for (Population pop : this.pops) {
- reproductions.put(pop, new HashMap<Date, MatrixND>());
- discards.put(pop, new HashMap<Date, MatrixND>());
- }
- }
-
- /**
- * Return all population actualy in PopulationMonitor
- * @return new list of Population
- */
- public List<Population> getPopulations() {
- return pops;
- }
-
- /**
- * Return current biomass for species
- * @param species
- * @return
- */
- public double getBiomass(Species species) {
- double result = 0;
-
- for (Population pop : species.getPopulation()) {
- result += getBiomass(pop);
- }
-
- return result;
- }
-
- /**
- * Return current biomass for population
- * @param pop
- * @return
- */
- public double getBiomass(Population pop) {
- double result = 0;
-
- MatrixND n = getN(pop);
- if (n != null) {
- n = n.sumOverDim(1);
- for (MatrixIterator i=n.iterator(); i.next();){
- Object [] coord = i.getSemanticsCoordinates();
- PopulationGroup group = (PopulationGroup)coord[0];
- result += i.getValue() * group.getMeanWeight();
- }
- }
-
- return result;
- }
-
- /**
- * Return current numbers for population
- * @param pop
- * @return
- */
- public MatrixND getN(Population pop) {
- MatrixND result = Ns.get(pop);
-
- if (result != null) {
- // change semantics with list from argument to ensure that
- // semantics don't used too old context
- result.setSemantics(0, pop.getPopulationGroup());
- result.setSemantics(1, pop.getPopulationZone());
- }
-
- return result;
- }
-
- public void setN(Population pop, MatrixND mat) {
- Ns.put(pop, mat);
- }
-
- /**
- * @return Returns the reproduction.
- */
- public MatrixND getReproduction(Date date, Population pop) {
- return this.reproductions.get(pop).get(date);
- }
-
- /**
- * @param reproduction The reproduction to set.
- */
- public void setReproduction(Date date, Population pop, MatrixND repro) {
- reproductions.get(pop).put(date, repro);
- }
-
- /**
- * Applique de la mortalite naturelle aux poissons qui sont pas encore
- * dans les classes de populations. (Reproduction)
- * @param pop
- */
- public void applyReproductionMortality(Population pop) {
- for (MatrixND reproduction : reproductions.get(pop).values()) {
- if (log.isTraceEnabled()) {
- log.trace("Matrix repro before mortality: " + reproduction);
- }
-
- for (MatrixIterator mi = reproduction.iterator(); mi.next();) {
- Object[] sems = mi.getSemanticsCoordinates();
- Zone z = (Zone) sems[0];
- double coeff = pop.getNaturalDeathBirth(z);
- if (log.isTraceEnabled()) {
- log.trace("NaturalDeath zone " + z + "=" + coeff);
- }
- mi.setValue(mi.getValue() * Math.exp(-coeff / Month.NUMBER_OF_MONTH));
- }
- if (log.isTraceEnabled()) {
- log.trace("Matrix repro after mortality: " + reproduction);
- }
- }
- }
-
- /**
- * @todo les reproductions qui sont trop veille pour encore servir
- * doivent être supprimées. c-a-d date < currentDate - etalement - gap between repro recru
- * Une autre facon de faire est de supprimer les repro == 0 car normalement
- * toute la repro doit etre utilisé au bout d'un certain temps
- *
- * @param date
- * @param pop
- * @return
- */
- public MatrixND getRecruitment(Date date, Population pop) {
- MatrixND matEtalement = pop.getRecruitmentDistribution();
- int etalement = matEtalement.getDim(0);
-
- MatrixND result = MatrixFactory.getInstance().create(
- new List[]{pop.getPopulationGroup(), pop.getPopulationZone()});
-
- // pour chaque
- for(int e=0; e<etalement; e++){
- // recuperation de la reproduction stucture en zone repro
- Date d = new Date(date.getDate() - e -
- pop.getMonthGapBetweenReproRecrutement());
- MatrixND repro = (MatrixND)reproductions.get(pop).get(d);
-
- if(repro != null){ // si une repro existe pour le mois
-
- // on fait la correspondance entre les zones repro et
- // recrutement
-
- PopulationGroup classe;
- int indiceClasse = 0;
- // si on a change d'annee le recrutement ne se fait pas en
- // classe 0 mais en classe 1, si on a change 2 fois d'annee
- // le recrutement se fait en age 2, etc.
- classe = pop.getPopulationGroup().get(indiceClasse);
-
- List<Zone> zoneRepros = pop.getReproductionZone();
-
- // on multiplie la repro par le coeff de recrutement
- double coeff = matEtalement.getValue(e);
-
- MatrixND matRepro = repro.copy();
- matRepro = matRepro.mults(coeff);
-
- matRepro.setSemantics(0, zoneRepros);
-
- MatrixND mapping = pop.getMappingZoneReproZoneRecru();
- for(Zone zoneRepro : zoneRepros){
- MatrixND submapping = mapping.getSubMatrix(0, new Object[]{zoneRepro});
- for (MatrixIterator i=submapping.iterator(); i.hasNext();) {
- i.next();
- Object[] sem = i.getSemanticsCoordinates();
- Zone zoneRecru = (Zone)sem[1];
- double c = i.getValue();
- result.setValue(classe, zoneRecru, c*matRepro.getValue(zoneRepro)
- +result.getValue(classe, zoneRecru));
- }
- }
- }
- }
-
- if(pop.getSpecies().getAgeGroupType()){
- // conversion et retour de la matrice en vecteur
- MatrixND N = pop.N2DToN1D(result);
- // on applique les migrations et le changement d'age sur le resultat
- // on suppose que la reproduction est toujours dans une seul saison
- Date dateRepro = new Date(date.getDate() -
- pop.getMonthGapBetweenReproRecrutement());
-
- // recherche les saisons des differents mois entre les deux dates
- List<PopulationSeasonInfo> infos = pop.getPopulationSeasonInfo();
- List<PopulationSeasonInfo> usedSeasons = new ArrayList<PopulationSeasonInfo>();
-
- while (date.after(dateRepro)) {
- dateRepro = dateRepro.next();
- Month month = dateRepro.getMonth();
- for (PopulationSeasonInfo info : infos) {
- if (month.equals(info.getFirstMonth())) {
- usedSeasons.add(info);
- dateRepro = new Date(dateRepro.getDate() + info.getMonths().size() - 1); // -1 because, for have next()
- break;
- }
- }
- }
-
- for(PopulationSeasonInfo info : usedSeasons){
- Month month = info.getFirstMonth();
- MatrixND CA = info.getGroupChangeMatrix(month);
- MatrixND MI = info.getMigrationMatrix(month, result);
- MatrixND tmp0 = N.mult(CA);
- MatrixND tmp2 = tmp0.mult(MI);
- N = tmp2;
- }
- result = pop.split2D(N);
- }
- return result;
- }
-
- /**
- * @param catchPerStrategyMet
- */
- public void holdCatch(Population pop, MatrixND catchPerStrategyMet) {
- catchs.put(pop, catchPerStrategyMet);
-
- MatrixND holdCatch = holdCatchs.get(pop);
- if (holdCatch == null) {
- holdCatch = MatrixFactory.getInstance().create(catchPerStrategyMet);
- holdCatchs.put(pop, holdCatch);
- } else {
- holdCatch.add(catchPerStrategyMet);
- }
-
- // compute total
- for(MatrixIterator i=catchPerStrategyMet.iterator(); i.next();){
- this.totalHoldCatch += i.getValue();
- }
-
- }
-
- /**
- * @param pop
- * @return
- */
- public MatrixND getCatch(Population pop) {
- MatrixND result = catchs.get(pop);
- return result;
- }
-
- /**
- * @param pop
- * @return
- */
- public MatrixND getHoldCatch(Population pop) {
- MatrixND result = holdCatchs.get(pop);
- return result;
- }
-
- /**
- * @param pop
- * @return
- */
- public double getTotalHoldCatch(Population pop) {
- double result = totalHoldCatch;
- return result;
- }
-
- /**
- * raz capture cumulée de toutes les pops
- */
- public void clearCatch() {
- catchs.clear();
- holdCatchs.clear();
- totalHoldCatch = 0;
- }
-
- /**
- * @param date
- * @param pop
- * @return
- */
- public MatrixND getDiscard(Date date, Population pop) {
- MatrixND result = discards.get(pop).get(date);
- return result;
- }
-
- /**
- * FIXME: discards n'est jamais vider, on le conserve pour toutes les annees
- * il serait bon de faire un peu le menage de temps en temps.
- *
- * @param date
- * @param pop
- * @param discard
- */
- public void addDiscard(Date date, Population pop, MatrixND discard) {
- Map<Date, MatrixND> oneDiscard = discards.get(pop);
- synchronized(oneDiscard) {
- MatrixND tmp = oneDiscard.get(date);
- if (tmp == null) {
- tmp = discard.copy();
- discards.get(pop).put(date, tmp);
- } else {
- tmp.add(discard);
- }
- }
- }
-}
-
-
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -67,7 +67,7 @@
static protected SimulationManager instance = null;
-// protected boolean autoLaunch = false;
+ protected boolean autoLaunch = false;
protected ListenerSet<SimulationQueueListener> listeners = new ListenerSet<SimulationQueueListener>();
protected PropertyChangeSupport propertyListeners = new PropertyChangeSupport(this);
@@ -122,12 +122,12 @@
}
-// /**
-// * @return Returns the autoLaunch.
-// */
-// public boolean isAutoLaunch() {
-// return this.autoLaunch;
-// }
+ /**
+ * @return Returns the autoLaunch.
+ */
+ public boolean isAutoLaunch() {
+ return this.autoLaunch;
+ }
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyListeners.addPropertyChangeListener(listener);
@@ -145,15 +145,32 @@
propertyListeners.removePropertyChangeListener(propertyName, listener);
}
-// /**
-// * @param autoLaunch The autoLaunch to set.
-// */
-// public void setAutoLaunch(boolean autoLaunch) {
-// boolean oldValue = this.autoLaunch;
-// this.autoLaunch = autoLaunch;
-// propertyListeners.firePropertyChange("autoLaunch", oldValue, autoLaunch);
-// }
+ /**
+ * @param autoLaunch The autoLaunch to set.
+ */
+ public void setAutoLaunch(boolean autoLaunch) {
+ synchronized (this) {
+ boolean oldValue = this.autoLaunch;
+ this.autoLaunch = autoLaunch;
+ if (this.autoLaunch) {
+ this.notifyAll();
+ }
+ propertyListeners.firePropertyChange("autoLaunch", oldValue, autoLaunch);
+ }
+ }
+ public void waitAutoLaunch() {
+ synchronized(this) {
+ while (!isAutoLaunch()) {
+ try {
+ this.wait();
+ } catch (InterruptedException eee) {
+ log.warn("Error during wait autoLaunch flag", eee);
+ }
+ }
+ }
+ }
+
/**
* Cree l'objet de gestion de la simulation en interne et le place dans la
* bonne queue de simulation (local/remote). Appel le
@@ -632,6 +649,7 @@
}
public void run() {
+ simulationManager.waitAutoLaunch();
// l'item est independant, on ajoute toutes ces simulations en plus
// mais pas dans la map pour qu'il n'y ait bien que l'initiale
// plus celles en cours d'affichees
@@ -671,6 +689,7 @@
}
public void run() {
+ simulationManager.waitAutoLaunch();
try {
// si l'simItem exist encore (que l'utilisateur ne la pas retire)
while (simulationManager.exists(simItem.getPlanIdOrId()) &&
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java 2008-08-12 15:23:26 UTC (rev 1293)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java 2008-08-12 15:23:29 UTC (rev 1294)
@@ -115,10 +115,8 @@
* <code>false</code> otherwise
*/
public static boolean isSimulStartButtonEnabled(JTable table) {
- return false;
- // L'auto launche a disparu maintenant
-// return !SimulationManager.getInstance().isAutoLaunch() &&
-// (table.getRowCount() > 0);
+ return !SimulationManager.getInstance().isAutoLaunch() &&
+ (table.getRowCount() > 0);
}
/**
Modified: branches/isis-fish-3.1.4/src/xmi/isis-fish.zargo
===================================================================
(Binary files differ)
1
0
r1293 - branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities
by bpoussin@users.labs.libre-entreprise.org 12 Aug '08
by bpoussin@users.labs.libre-entreprise.org 12 Aug '08
12 Aug '08
Author: bpoussin
Date: 2008-08-12 15:23:26 +0000 (Tue, 12 Aug 2008)
New Revision: 1293
Removed:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/entities/migration/
Log:
- Implantation dans le modele des nouvelles equations
- passage de version en 3.2.0
- ajout du code pour upgrader les tables (alter table)
1
0
r1292 - in branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish: . datastore logging simulator versionning
by bpoussin@users.labs.libre-entreprise.org 11 Aug '08
by bpoussin@users.labs.libre-entreprise.org 11 Aug '08
11 Aug '08
Author: bpoussin
Date: 2008-08-11 14:36:27 +0000 (Mon, 11 Aug 2008)
New Revision: 1292
Added:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/versionning/DummyVCSHandler.java
Modified:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisContext.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisFish.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java
Log:
debut de debbugage de la refonte du lanceur de simulation.
- SimulationLogUtil ne semble pas multi-thread support (plusieurs simulation simultanement)
- ajout d'un DummyVCSHandler si le reseau est unreacheable
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -44,16 +44,22 @@
protected final static VersionNumber version = new VersionNumber(3, 1, 4);
protected final static VersionNumber databaseVersion = new VersionNumber(
- version.getNumber(0), version.getNumber(1));
+ 0);
+// FIXME a remettre apres les tests de simu version.getNumber(0), version.getNumber(1));
+ public static VersionNumber getVersionNumber() {
+ return version;
+ }
+
static public String getVERSION() {
- String result = getVersion().toString();
+ String result = version.toString();
return result;
}
- static public VersionNumber getVersion() {
- return version;
- }
+// @Override
+// public VersionNumber getVersion() {
+// return version;
+// }
public static VersionNumber getDatabaseVersion() {
return databaseVersion;
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisContext.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisContext.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisContext.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -21,6 +21,7 @@
import fr.ifremer.isisfish.commandline.IsisAbstractContext;
import fr.ifremer.isisfish.commandline.IsisOptionParser;
import fr.ifremer.isisfish.datastore.IsisH2Config;
+import fr.ifremer.isisfish.versionning.DummyVCSHandler;
import fr.ifremer.isisfish.versionning.IsisVcsConfig;
import org.codelutin.i18n.I18n;
import org.codelutin.option.OptionKey;
@@ -209,6 +210,10 @@
}
public VCSHandler getVCSHanler() {
+ if (handler == null) {
+ // handler not initializer, we used dummy handler
+ handler = new DummyVCSHandler();
+ }
return handler;
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisFish.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -105,7 +105,7 @@
StringBuilder builder = new StringBuilder();
builder.append(java.text.SimpleDateFormat.getInstance().format(new java.util.Date()));
builder.append(" Java version: ").append(System.getProperty("java.runtime.version"));
- builder.append(" Isis-fish version: ").append(IsisConfig.VERSION_PROPERTY_KEY.getDefaultValue().toString());
+ builder.append(" Isis-fish version: ").append(IsisConfig.getVERSION());
log.info(builder.toString());
log.debug(_("isisfish.launch.debugMode"));
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -75,7 +75,7 @@
* @param directory le repertoire ou devrait se trouver la classe. Ce
* répertoire doit etre un sous répertoire de rootSrc
* @param name le nom de la classe
- * @param suffix TODO
+ * @param suffix l'extension des fichiers
*/
protected CodeSourceStorage(File rootSrc, File directory, String name, String suffix) {
// if name end with suffix we don't add suffix to filename
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -42,6 +42,7 @@
import org.apache.commons.logging.LogFactory;
import java.io.File;
+import java.io.FilenameFilter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -260,10 +261,15 @@
static public List<String> getStorageNames(File directory) {
List<String> result = new ArrayList<String>();
- if (directory.exists()) {
- Collections.addAll(result, directory.list(getVCSHanler().getVersionnableFilenameFilter()));
+ try {
+ if (directory.exists()) {
+ FilenameFilter filter = getVCSHanler().getVersionnableFilenameFilter();
+ String[] list = directory.list(filter);
+ Collections.addAll(result, list);
+ }
+ } catch (Exception eee) {
+ log.error("Can't get list file for " + directory, eee);
}
-
Collections.sort(result);
return result;
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -39,6 +39,10 @@
import java.util.Map;
/**
+ * FIXME poussin, a priori cette classe ne supporte pas plusieurs simulation
+ * en meme temps, ce qui est le cas si on a plusieurs processeurs de dispo :(
+ *
+ *
* Usefull class for dealing with hot configuration of log4J. this is temporary
* we must find a way to abstract this layer.
* <p/>
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -55,6 +55,13 @@
/**
+ * Classe permettant le suivi des populations de la simulation.
+ *
+ * FIXME: certain calcul sont les memes que ceux implanter dans les scripts
+ * a cause du groupe des juveniles qui n'est pas un vrai groupe de population.
+ * Il serait bon que ce groupe deviennent un vrai groupe et que ce code specifique
+ * puisse etre supprimer.
+ *
*
* @author poussin
*/
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/PopulationMonitorMultiThread.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -0,0 +1,399 @@
+/* *##%
+ * Copyright (C) 2006
+ * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/* *
+ * PopulationMonitor.java
+ *
+ * Created: 21 août 2006 15:41:18
+ *
+ * @author poussin
+ * @version $Revision: 428 $
+ *
+ * Last update: $Date: 2007-10-15 14:56:13 +0200 (lun, 15 oct 2007) $
+ * by : $Author: bpoussin $
+ */
+
+package fr.ifremer.isisfish.simulator;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.math.matrix.MatrixFactory;
+import org.codelutin.math.matrix.MatrixIterator;
+import org.codelutin.math.matrix.MatrixND;
+
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationGroup;
+import fr.ifremer.isisfish.entities.PopulationSeasonInfo;
+import fr.ifremer.isisfish.entities.Species;
+import fr.ifremer.isisfish.entities.Zone;
+import fr.ifremer.isisfish.types.Date;
+import fr.ifremer.isisfish.types.Month;
+import java.util.Collections;
+
+
+/**
+ * Classe permettant le suivi des populations de la simulation.
+ * <p>
+ * Cette classe est normalement multi-thread safe
+ * <p>
+ * FIXME: certain calcul sont les memes que ceux implanter dans les scripts
+ * a cause du groupe des juveniles qui n'est pas un vrai groupe de population.
+ * Il serait bon que ce groupe deviennent un vrai groupe et que ce code specifique
+ * puisse etre supprimer.
+ *
+ *
+ * @author poussin
+ */
+public class PopulationMonitorMultiThread {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(PopulationMonitorMultiThread.class);
+
+ /** La liste des pops monitorer par cette instance */
+ protected List<Population> pops = null;
+ /** current number of fish by Pop */
+ protected Map<Population, MatrixND> Ns = new HashMap<Population, MatrixND>();
+ /** reproduction key: <date, pop> value:<MatrixND> */
+ protected Map<Population, Map<Date, MatrixND>> reproductions = new HashMap<Population, Map<Date, MatrixND>>();
+ /** discard key: <date, pop> value:<MatrixND> */
+ protected Map<Population, Map<Date, MatrixND>> discards = new HashMap<Population, Map<Date, MatrixND>>();
+ /** catch per population, only last catch is remaining */
+ protected Map<Population, MatrixND> catchs = new HashMap<Population, MatrixND>();
+ /** catch per population, only last catch is remaining */
+ protected Map<Population, MatrixND> holdCatchs = new HashMap<Population, MatrixND>();
+ protected double totalHoldCatch = 0;
+
+ /**
+ * Initialise le monitor pour l'ensemble de pop passe en parametre.
+ * Normalement cet init est fait dans le thread principale de la simulation
+ * et il n'y a pas de besoin de le synchroniser.
+ *
+ * Cet init permet d'avoir ensuite le maxime de variable en lecture, et donc
+ * de permettre le multithreading de facon legere (pas de synchronise) et
+ * sur (pas de concurent modification exception)
+ *
+ * @param pops
+ */
+ public void init(List<Population> pops) {
+ this.pops = Collections.unmodifiableList(new ArrayList<Population>(pops));
+ for (Population pop : this.pops) {
+ reproductions.put(pop, new HashMap<Date, MatrixND>());
+ discards.put(pop, new HashMap<Date, MatrixND>());
+ }
+ }
+
+ /**
+ * Return all population actualy in PopulationMonitor
+ * @return new list of Population
+ */
+ public List<Population> getPopulations() {
+ return pops;
+ }
+
+ /**
+ * Return current biomass for species
+ * @param species
+ * @return
+ */
+ public double getBiomass(Species species) {
+ double result = 0;
+
+ for (Population pop : species.getPopulation()) {
+ result += getBiomass(pop);
+ }
+
+ return result;
+ }
+
+ /**
+ * Return current biomass for population
+ * @param pop
+ * @return
+ */
+ public double getBiomass(Population pop) {
+ double result = 0;
+
+ MatrixND n = getN(pop);
+ if (n != null) {
+ n = n.sumOverDim(1);
+ for (MatrixIterator i=n.iterator(); i.next();){
+ Object [] coord = i.getSemanticsCoordinates();
+ PopulationGroup group = (PopulationGroup)coord[0];
+ result += i.getValue() * group.getMeanWeight();
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Return current numbers for population
+ * @param pop
+ * @return
+ */
+ public MatrixND getN(Population pop) {
+ MatrixND result = Ns.get(pop);
+
+ if (result != null) {
+ // change semantics with list from argument to ensure that
+ // semantics don't used too old context
+ result.setSemantics(0, pop.getPopulationGroup());
+ result.setSemantics(1, pop.getPopulationZone());
+ }
+
+ return result;
+ }
+
+ public void setN(Population pop, MatrixND mat) {
+ Ns.put(pop, mat);
+ }
+
+ /**
+ * @return Returns the reproduction.
+ */
+ public MatrixND getReproduction(Date date, Population pop) {
+ return this.reproductions.get(pop).get(date);
+ }
+
+ /**
+ * @param reproduction The reproduction to set.
+ */
+ public void setReproduction(Date date, Population pop, MatrixND repro) {
+ reproductions.get(pop).put(date, repro);
+ }
+
+ /**
+ * Applique de la mortalite naturelle aux poissons qui sont pas encore
+ * dans les classes de populations. (Reproduction)
+ * @param pop
+ */
+ public void applyReproductionMortality(Population pop) {
+ for (MatrixND reproduction : reproductions.get(pop).values()) {
+ if (log.isTraceEnabled()) {
+ log.trace("Matrix repro before mortality: " + reproduction);
+ }
+
+ for (MatrixIterator mi = reproduction.iterator(); mi.next();) {
+ Object[] sems = mi.getSemanticsCoordinates();
+ Zone z = (Zone) sems[0];
+ double coeff = pop.getNaturalDeathBirth(z);
+ if (log.isTraceEnabled()) {
+ log.trace("NaturalDeath zone " + z + "=" + coeff);
+ }
+ mi.setValue(mi.getValue() * Math.exp(-coeff / Month.NUMBER_OF_MONTH));
+ }
+ if (log.isTraceEnabled()) {
+ log.trace("Matrix repro after mortality: " + reproduction);
+ }
+ }
+ }
+
+ /**
+ * @todo les reproductions qui sont trop veille pour encore servir
+ * doivent être supprimées. c-a-d date < currentDate - etalement - gap between repro recru
+ * Une autre facon de faire est de supprimer les repro == 0 car normalement
+ * toute la repro doit etre utilisé au bout d'un certain temps
+ *
+ * @param date
+ * @param pop
+ * @return
+ */
+ public MatrixND getRecruitment(Date date, Population pop) {
+ MatrixND matEtalement = pop.getRecruitmentDistribution();
+ int etalement = matEtalement.getDim(0);
+
+ MatrixND result = MatrixFactory.getInstance().create(
+ new List[]{pop.getPopulationGroup(), pop.getPopulationZone()});
+
+ // pour chaque
+ for(int e=0; e<etalement; e++){
+ // recuperation de la reproduction stucture en zone repro
+ Date d = new Date(date.getDate() - e -
+ pop.getMonthGapBetweenReproRecrutement());
+ MatrixND repro = (MatrixND)reproductions.get(pop).get(d);
+
+ if(repro != null){ // si une repro existe pour le mois
+
+ // on fait la correspondance entre les zones repro et
+ // recrutement
+
+ PopulationGroup classe;
+ int indiceClasse = 0;
+ // si on a change d'annee le recrutement ne se fait pas en
+ // classe 0 mais en classe 1, si on a change 2 fois d'annee
+ // le recrutement se fait en age 2, etc.
+ classe = pop.getPopulationGroup().get(indiceClasse);
+
+ List<Zone> zoneRepros = pop.getReproductionZone();
+
+ // on multiplie la repro par le coeff de recrutement
+ double coeff = matEtalement.getValue(e);
+
+ MatrixND matRepro = repro.copy();
+ matRepro = matRepro.mults(coeff);
+
+ matRepro.setSemantics(0, zoneRepros);
+
+ MatrixND mapping = pop.getMappingZoneReproZoneRecru();
+ for(Zone zoneRepro : zoneRepros){
+ MatrixND submapping = mapping.getSubMatrix(0, new Object[]{zoneRepro});
+ for (MatrixIterator i=submapping.iterator(); i.hasNext();) {
+ i.next();
+ Object[] sem = i.getSemanticsCoordinates();
+ Zone zoneRecru = (Zone)sem[1];
+ double c = i.getValue();
+ result.setValue(classe, zoneRecru, c*matRepro.getValue(zoneRepro)
+ +result.getValue(classe, zoneRecru));
+ }
+ }
+ }
+ }
+
+ if(pop.getSpecies().getAgeGroupType()){
+ // conversion et retour de la matrice en vecteur
+ MatrixND N = pop.N2DToN1D(result);
+ // on applique les migrations et le changement d'age sur le resultat
+ // on suppose que la reproduction est toujours dans une seul saison
+ Date dateRepro = new Date(date.getDate() -
+ pop.getMonthGapBetweenReproRecrutement());
+
+ // recherche les saisons des differents mois entre les deux dates
+ List<PopulationSeasonInfo> infos = pop.getPopulationSeasonInfo();
+ List<PopulationSeasonInfo> usedSeasons = new ArrayList<PopulationSeasonInfo>();
+
+ while (date.after(dateRepro)) {
+ dateRepro = dateRepro.next();
+ Month month = dateRepro.getMonth();
+ for (PopulationSeasonInfo info : infos) {
+ if (month.equals(info.getFirstMonth())) {
+ usedSeasons.add(info);
+ dateRepro = new Date(dateRepro.getDate() + info.getMonths().size() - 1); // -1 because, for have next()
+ break;
+ }
+ }
+ }
+
+ for(PopulationSeasonInfo info : usedSeasons){
+ Month month = info.getFirstMonth();
+ MatrixND CA = info.getGroupChangeMatrix(month);
+ MatrixND MI = info.getMigrationMatrix(month, result);
+ MatrixND tmp0 = N.mult(CA);
+ MatrixND tmp2 = tmp0.mult(MI);
+ N = tmp2;
+ }
+ result = pop.split2D(N);
+ }
+ return result;
+ }
+
+ /**
+ * @param catchPerStrategyMet
+ */
+ public void holdCatch(Population pop, MatrixND catchPerStrategyMet) {
+ catchs.put(pop, catchPerStrategyMet);
+
+ MatrixND holdCatch = holdCatchs.get(pop);
+ if (holdCatch == null) {
+ holdCatch = MatrixFactory.getInstance().create(catchPerStrategyMet);
+ holdCatchs.put(pop, holdCatch);
+ } else {
+ holdCatch.add(catchPerStrategyMet);
+ }
+
+ // compute total
+ for(MatrixIterator i=catchPerStrategyMet.iterator(); i.next();){
+ this.totalHoldCatch += i.getValue();
+ }
+
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public MatrixND getCatch(Population pop) {
+ MatrixND result = catchs.get(pop);
+ return result;
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public MatrixND getHoldCatch(Population pop) {
+ MatrixND result = holdCatchs.get(pop);
+ return result;
+ }
+
+ /**
+ * @param pop
+ * @return
+ */
+ public double getTotalHoldCatch(Population pop) {
+ double result = totalHoldCatch;
+ return result;
+ }
+
+ /**
+ * raz capture cumulée de toutes les pops
+ */
+ public void clearCatch() {
+ catchs.clear();
+ holdCatchs.clear();
+ totalHoldCatch = 0;
+ }
+
+ /**
+ * @param date
+ * @param pop
+ * @return
+ */
+ public MatrixND getDiscard(Date date, Population pop) {
+ MatrixND result = discards.get(pop).get(date);
+ return result;
+ }
+
+ /**
+ * FIXME: discards n'est jamais vider, on le conserve pour toutes les annees
+ * il serait bon de faire un peu le menage de temps en temps.
+ *
+ * @param date
+ * @param pop
+ * @param discard
+ */
+ public void addDiscard(Date date, Population pop, MatrixND discard) {
+ Map<Date, MatrixND> oneDiscard = discards.get(pop);
+ synchronized(oneDiscard) {
+ MatrixND tmp = oneDiscard.get(date);
+ if (tmp == null) {
+ tmp = discard.copy();
+ discards.get(pop).put(date, tmp);
+ } else {
+ tmp.add(discard);
+ }
+ }
+ }
+}
+
+
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -30,6 +30,8 @@
package fr.ifremer.isisfish.simulator;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import static org.codelutin.i18n.I18n._;
import java.io.File;
@@ -291,22 +293,20 @@
*/
static public void simulate(String simulId, SimulationParameter param,
boolean inQueue) throws SimulationException {
- // Ajout automatiquement de la date+heure a la fin de l'identifiant
- // comme demandé par Steph 20070227
- simulId += " " + dateFormat.format(new java.util.Date());
+ try {
+ simulId += " " + dateFormat.format(new java.util.Date());
- if (simulId == null ||
- "".equals(simulId) ||
- SimulationStorage.localyExists(simulId) ||
- SimulationManager.getInstance().exists(simulId)) {
- log.error("Can't start simulation, bad id: " + simulId);
- throw new SimulationException(_("isisfish.error.start" +
- " simulation, bad id: {0}", "" + simulId));
+ if (simulId == null || "".equals(simulId) || SimulationStorage.localyExists(simulId) || SimulationManager.getInstance().exists(simulId)) {
+ log.error("Can't start simulation, bad id: " + simulId);
+ throw new SimulationException(_("isisfish.error.start" + " simulation, bad id: {0}", "" + simulId));
+ }
+ SimulationParameter p = param.copy();
+ p.setInQueue(inQueue);
+
+ SimulationManager.getInstance().addSimulation(simulId, p);
+ } catch (Exception eee) {
+ throw new SimulationException("Can't add simulation", eee);
}
- SimulationParameter p = param.copy();
- p.setInQueue(inQueue);
-
- SimulationManager.getInstance().addSimulation(simulId, p);
}
static public SimulationStorage simulate(SimulationControl control, SimulationStorage simulation) throws Exception {
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -36,9 +36,11 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.types.Date;
import java.beans.PropertyChangeEvent;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import static org.codelutin.i18n.I18n._;
+import static org.codelutin.i18n.I18nf._;
import org.codelutin.util.FileUtil;
import org.codelutin.util.ListenerSet;
@@ -46,16 +48,11 @@
import java.beans.PropertyChangeSupport;
import java.io.File;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.LinkedHashMap;
-import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.concurrent.PriorityBlockingQueue;
/**
@@ -118,7 +115,8 @@
// TODO passer ces valeurs en valeur configurable
int cpus = Runtime.getRuntime().availableProcessors();
int MAX_REMOTE_SIMULATION = 1;
-
+ log.info(_("Launch Simulation executor with %s cpu(s) for local, and %s" +
+ " process for remote", cpus, MAX_REMOTE_SIMULATION));
localExecutor = Executors.newFixedThreadPool(cpus);
remoteExecutor = Executors.newFixedThreadPool(MAX_REMOTE_SIMULATION);
}
@@ -173,26 +171,26 @@
log.debug(_("isisfish.message.add.queue.remote", id));
}
+
+
// on construit le bon type de SimulationItem pour le job
SimulationItem item = null;
if (param.getUseAnalysePlan()) {
if (!param.isIndependentPlan()) {
item = new SimulationItemPlan(id, param);
+ executor.submit(new SimulationJob(this, item));
} else {
+ // on met dans la queue local le process de generation de toutes
+ // les simus
item = new SimulationItemPlanIndependent(id, param);
- // l'item est independant, on ajoute toutes ces simulations en plus
- // mais pas dans la map pour qu'il n'y ait bien que l'initiale
- // plus celles en cours d'affichees
- while(item.hasNext()) {
- executor.submit(new SimulationJob(this, item.next()));
- }
+ localExecutor.submit(
+ new PrepareIndependentSimulationJob(this, executor, item));
}
} else {
item = new SimulationItem(id, param);
+ executor.submit(new SimulationJob(this, item));
}
fireAddEvent(id, item); // must be before thread notification because thread look in map
-
- executor.submit(new SimulationJob(this, item));
}
/**
@@ -619,10 +617,40 @@
//
// }
+ class PrepareIndependentSimulationJob implements Runnable {
+
+ protected SimulationManager simulationManager;
+ protected ExecutorService executor;
+ protected SimulationItem item;
+
+ public PrepareIndependentSimulationJob(SimulationManager simulationManager,
+ ExecutorService executor,
+ SimulationItem item) {
+ this.simulationManager = simulationManager;
+ this.executor = executor;
+ this.item = item;
+ }
+
+ public void run() {
+ // l'item est independant, on ajoute toutes ces simulations en plus
+ // mais pas dans la map pour qu'il n'y ait bien que l'initiale
+ // plus celles en cours d'affichees
+ while (item.hasNext()) {
+ try {
+ executor.submit(new SimulationJob(simulationManager, item.next()));
+ } catch (Exception eee) {
+ log.error("Can't add simulation: " + item, eee);
+ }
+ }
+
+ }
+
+ }
+
/**
* Utilise pour les simulations sans plan d'analyse ou des plans independant
*/
- static class SimulationJob implements Runnable {
+ class SimulationJob implements Runnable {
protected SimulationManager simulationManager;
protected SimulationItem simItem;
@@ -739,6 +767,7 @@
* Une simulation a faire sans plan d'experience
*/
public class SimulationItem {
+
protected String id;
protected SimulationParameter param;
protected SimulationItemPlan planItem = null;
@@ -877,7 +906,8 @@
/**
* Une simulation a faire qui contient un plan d'experience dependant
*/
- public class SimulationItemPlan extends SimulationItem implements PropertyChangeListener {
+ public class SimulationItemPlan extends SimulationItem
+ implements PropertyChangeListener {
// FIXME a mettre en config MAX_SIMULATION_PLAN
// nombre maximal de simulation de plan par simulation
// (pour eviter les plans qui ne retroune jamais faux
@@ -971,12 +1001,26 @@
}
public void propertyChange(PropertyChangeEvent evt) {
+ // Attention il faut bien que toutes les simultions soit
+ // genere (ou qu'il en reste au moins une en cours
+ // sinon, la condition est tout de suite vrai et la simulation
+ // s'arrete. Ce qui est normalement le cas ici, car on utilise
+ // le meme executor pour genere les simultions que pour les faire
+ // et les generes est mis en premier dans l'executor, mais si
+ // on est multi cpu, et que le temps de simulation est inferieur
+ // au temps de generation des simulations, on pourrai finir par
+ // avoir un probleme.
+
if (Boolean.FALSE.equals(evt.getNewValue())) {
simulationFinished++;
control.setProgress(simulationFinished);
control.setText(simulationFinished + " / " + simulationNumber);
if (simulationFinished >= simulationNumber) {
+ log.info("All simulations have been executed: " + simulationFinished);
control.stopSimulation();
+ String id = control.getId();
+ SimulationManager.this.fireStopEvent(id);
+ SimulationManager.this.fireRemoveEvent(id);
}
}
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java 2008-08-07 19:38:45 UTC (rev 1291)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -73,7 +73,11 @@
int row = getRowCount();
fireTableRowsInserted(row, row);
SimulationControl control = getSimulationControl(e.getId());
- control.addPropertyChangeListener(this);
+ if (control != null) {
+ control.addPropertyChangeListener(this);
+ } else {
+ log.warn("Simulation without controler: " + e.getId());
+ }
}
/* (non-Javadoc)
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/versionning/DummyVCSHandler.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/versionning/DummyVCSHandler.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/versionning/DummyVCSHandler.java 2008-08-11 14:36:27 UTC (rev 1292)
@@ -0,0 +1,209 @@
+/* *##%
+ * Copyright (C) 2002-2008 Code Lutin, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ *##%*/
+
+package fr.ifremer.isisfish.versionning;
+
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.vcs.VCSConfig;
+import org.codelutin.vcs.VCSException;
+import org.codelutin.vcs.VCSHandler;
+import org.codelutin.vcs.VCSState;
+
+/**
+ * Class utilisee lorsqu'aucun handler n'a ete initialise
+ *
+ *
+ * @author poussin
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * by : $Author$
+ */
+public class DummyVCSHandler implements VCSHandler {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(DummyVCSHandler.class);
+
+ protected final FilenameFilter versionnableFilenameFilter;
+ protected final FileFilter versionnableFileFilter;
+
+ public DummyVCSHandler() {
+ this.versionnableFilenameFilter = new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return !".svn".equals(name) && !"CVS".equals(name);
+ }
+ };
+ this.versionnableFileFilter = new FileFilter() {
+ public boolean accept(File dir) {
+ return !".svn".equals(dir.getName()) && !"CVS".equals(dir.getName());
+ }
+ };
+}
+
+
+
+ public File getLocalDatabasePath() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void initWorkingCopy() throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void reinitWorkingCopy() throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void deleteWorkingCopy() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getRemoteUrl() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public VCSConfig getConfig() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public FilenameFilter getVersionnableFilenameFilter() {
+ return versionnableFilenameFilter;
+ }
+
+ public FileFilter getVersionnableFileFilter() {
+ return versionnableFileFilter;
+ }
+
+ public String getConfLocalDirname() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getConfLocalEntriesFilename() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public VCSState getState(File fileState, Collection tmp) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public VCSState getState(File file, Collection tmp, boolean noremote) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isOnRemote(File file) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isUpToDate(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public boolean isVersionnableFile(File file) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void makeRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void deleteRemoteDir(String commitMessage, String... dirNames) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public long add(List<File> files, String msg) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void delete(List<File> files, String msg) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void revert(List<File> files) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public long commit(List<File> files, String msg) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void update(File file, Object revision) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void update(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void checkout(File destDir, String module, boolean recurse) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void checkoutFile(File destDir, String module) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public long checkoutOnlyTheDirectory(File root, Object revision) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public List<String> getRemoteStorageNames(File directory) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public List<String> getLocalStorageNames(File directory) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public Object getRevision(File f) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public List getLog(Object startRevision, Object endRevision, File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getFileContent(File file, Object revision) throws VCSException, IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getChangeLog(File file) throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getDiff(File file) throws VCSException, IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public String getDiff(File file, Object againstRevision) throws VCSException, IOException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void testConnection() throws VCSException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
1
0
r1291 - in branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish: . commandline/actions datastore datastore/migration simulator ui/simulator
by bpoussin@users.labs.libre-entreprise.org 07 Aug '08
by bpoussin@users.labs.libre-entreprise.org 07 Aug '08
07 Aug '08
Author: bpoussin
Date: 2008-08-07 19:38:45 +0000 (Thu, 07 Aug 2008)
New Revision: 1291
Added:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AnalysePlanIndependent.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointExternalProcessThread.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointRemoteThread.java
Removed:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointThread.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModelOld.java
Modified:
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/commandline/actions/IsisOptionActionSimulate.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/IsisH2Config.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationInformation.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AbstractSimulationQueueModel.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationControl.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationDoneQueueModel.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java
branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java
Log:
refonte complete du SimulationManager, on utilise maintenant 2 executors, un local (batch ou non) et l'autre distant.
Les executors utlisent un nombre de thread predefinit au maximun (default: cpu number)
Ajout du mode batch pour lancer les simulations dans un sous process systeme
Ajout du support de la migration de base, tout est pret pour ecrire les changements necessaires entre version
pas encore test tout ca, mais commiter c jamais mauvais pour ne rien perdre
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/IsisConfig.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -33,6 +33,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.codelutin.util.VersionNumber;
/**
* L'implantation concrete de la configuration principale d'Isis
@@ -41,16 +42,23 @@
*/
public class IsisConfig extends IsisAbstractConfigMain {
- /** la version (ne peut pas être final car la configuration doit être chargée) */
- static private String VERSION;
-
+ protected final static VersionNumber version = new VersionNumber(3, 1, 4);
+ protected final static VersionNumber databaseVersion = new VersionNumber(
+ version.getNumber(0), version.getNumber(1));
+
static public String getVERSION() {
- if (VERSION == null) {
- VERSION = IsisContext.get().getMainConfig().getVersion().toString();
- }
- return VERSION;
+ String result = getVersion().toString();
+ return result;
}
+
+ static public VersionNumber getVersion() {
+ return version;
+ }
+ public static VersionNumber getDatabaseVersion() {
+ return databaseVersion;
+ }
+
/** le copyright (ne peut pas être final car la configuration doit être chargée) */
static private String COPYRIGHT_TEXT;
@@ -591,8 +599,6 @@
@Override
protected void loadFromSource() throws IOException {
super.loadFromSource();
- // alwyas used the java program version, should even never stored...
- setVersion(VERSION_PROPERTY_KEY.getDefaultValue());
// we do not deal with inter-config properties
clearUnsafeData();
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/commandline/actions/IsisOptionActionSimulate.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/commandline/actions/IsisOptionActionSimulate.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/commandline/actions/IsisOptionActionSimulate.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -16,6 +16,7 @@
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationHelper;
import fr.ifremer.isisfish.simulator.SimulationParameter;
@@ -37,16 +38,22 @@
@Override
public void run() throws Exception {
- Thread.currentThread().dumpStack();
- String simulId = getSimulationId();
- File parameters = getSimulationParameter();
- File region = this.getRegion();
- File simulation = getSimulation();
+ String simulId = getSimulationId();
+ File parameters = getSimulationParameter();
+ File region = this.getRegion();
+ File simulation = getSimulation();
- if (parameters != null && simulation == null) {
+ if (parameters == null && region == null && simulation == null) {
+ // juste l'id, donc la simulation exist deja en local et ne demande
+ // qu'a etre executee
+ log.info(getOption().getUsedAlias() + ", id:" + simulId);
+ simulationWithId(simulId);
+ } else if (parameters != null && simulation == null) {
+ // Si on a des parametre, on a peut etre aussi une region
log.info(getOption().getUsedAlias() + ", id:" + simulId + ", parameters:" + parameters);
simulateWithParams(simulId, parameters, region);
} else {
+ // si on a une simulation, on a peut-etre des paramtres
log.info(getOption().getUsedAlias() + ", id:" + simulId + ", zip:" + simulation);
simulateWithSimulation(simulId, simulation, parameters);
}
@@ -101,11 +108,22 @@
if (params != null) {
sim.setParameter(params);
}
+
+ SimulationControl control = new SimulationControl(simulId);
+
// lancement de la simulation
- SimulationHelper.simulate(null, sim);
+ SimulationHelper.simulate(control, sim);
- sim.getStorage().closeContext();
+ sim.closeStorage();
+ }
+
+ public static void simulationWithId(String simulId) throws Exception {
+ SimulationStorage sim = SimulationStorage.getSimulation(simulId);
+ SimulationControl control = new SimulationControl(simulId);
+ // lancement de la simulation
+ SimulationHelper.simulate(control, sim);
+
+ sim.closeStorage();
}
-
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/IsisH2Config.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/IsisH2Config.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/IsisH2Config.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -18,6 +18,7 @@
* ##% */
package fr.ifremer.isisfish.datastore;
+import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.commandline.configs.IsisAbstractConfigH2;
import fr.ifremer.isisfish.IsisContext;
import fr.ifremer.isisfish.IsisFishRuntimeException;
@@ -148,7 +149,7 @@
// migrate database
if (conf.isUpdateschemaDatabase()) {
// migration configuration
- config.put(TopiaMigrationServiceImpl.MIGRATION_APPLICATION_VERSION, conf.getMigrationApplicationVersion());
+ config.put(TopiaMigrationServiceImpl.MIGRATION_APPLICATION_VERSION, IsisConfig.getDatabaseVersion().toString());
config.put(TopiaMigrationServiceImpl.MIGRATION_PREVIOUS_MAPPING_DIRECTORY, conf.getMigrationPreviousMappingDirectory());
config.put(TopiaMigrationServiceImpl.MIGRATION_MODEL_NAMES, conf.getMigrationModelNames());
config.put(TopiaMigrationServiceImpl.MIGRATION_CALLBACKHANDLERS, conf.getMigrationCallBackhandlers());
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationInformation.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationInformation.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationInformation.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -275,6 +275,10 @@
setInfo(SIMULATION_EXCEPTION, v);
}
+ public boolean hasError() {
+ boolean result = getException() != null && getException().length() > 0;
+ return result;
+ }
public String getInfomation() {
String result = info.getProperty(OTHER_INFO);
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -57,6 +57,7 @@
import fr.ifremer.isisfish.entities.FisheryRegion;
import fr.ifremer.isisfish.entities.FisheryRegionDAO;
import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
+import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
import org.codelutin.vcs.VCSException;
@@ -99,6 +100,50 @@
//return new File(getDirectory(), IsisConfig.SIMULATION_PARAMETERS);
}
+ protected transient File simulationControlFile = null;
+ protected File getSimulationControlFile() {
+ if (simulationControlFile == null) {
+ simulationControlFile = new File(getDirectory(), "control");
+ }
+ return simulationControlFile;
+ }
+
+ public void saveControl(SimulationControl control) {
+ try {
+ Properties prop = control.getProperties();
+ File file = getSimulationControlFile();
+ FileOutputStream out = new FileOutputStream(file);
+ prop.store(out, "Control");
+ out.close();
+ } catch (Exception eee) {
+ // juste un log, car la sauvegarde d'un control ne doit jamais echouer
+ // car simplement utilise pour indique l'etat de simulation
+ log.warn("Can't save control", eee);
+ }
+ }
+
+ /**
+ * Reli le fichier contenant les infos de SimulationControl, en excluant
+ * certain champs
+ * @param control
+ * @param exclude
+ */
+ public void readControl(SimulationControl control, String ... exclude) {
+ try {
+ Properties prop = new Properties();
+ File file = getSimulationControlFile();
+ FileInputStream in = new FileInputStream(file);
+ prop.load(in);
+ in.close();
+ for (String e : exclude) {
+ prop.remove(e);
+ }
+ control.updateFromProperties(prop);
+ } catch (Exception eee) {
+ log.warn("Can't read control", eee);
+ }
+ }
+
public void setParameter(SimulationParameter parameter) {
this.parameter = parameter;
if (parameter != null) {
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/datastore/migration/SwingMigrationCallbackHandler.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -18,12 +18,17 @@
package fr.ifremer.isisfish.datastore.migration;
+import java.sql.Connection;
import javax.swing.JOptionPane;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.codelutin.topia.migration.DatabaseManager;
import org.codelutin.topia.migration.callback.MigrationCallbackHandler;
+import org.codelutin.topia.migration.callback.MigrationCallbackHandler.MigrationChoice;
+import org.codelutin.util.VersionNumberUtil;
-
/**
* MigrationCallbackHandler
*
@@ -35,11 +40,15 @@
*/
public class SwingMigrationCallbackHandler implements MigrationCallbackHandler {
+ /** to use log facility, just put in your code: log.info("..."); */
+ static private Log log = LogFactory.getLog(SwingMigrationCallbackHandler.class);
+
/* (non-Javadoc)
* @see org.codelutin.topia.migration.callback.MigrationCallbackHandler#doMigration(java.lang.String, java.lang.String)
*/
@Override
- public boolean doMigration(String dbVersion, String applicationVersion) {
+ public MigrationChoice doMigration(DatabaseManager dbManager,
+ String dbVersion, String applicationVersion) {
int answer = JOptionPane
.showConfirmDialog(
@@ -52,9 +61,57 @@
JOptionPane.QUESTION_MESSAGE
);
- boolean result = ( answer == JOptionPane.YES_OPTION );
+ MigrationChoice result = ( answer == JOptionPane.YES_OPTION ) ? MigrationChoice.MIGRATION : MigrationChoice.NO_MIGRATION;
+ if (result == MigrationChoice.MIGRATION) {
+ // migration manuel sans l'aide de topia-service
+ // tant que c pas fait on dit non
+ result = MigrationChoice.NO_MIGRATION;
+ // ouverture d'une connexion direct JDBC sur la base
+ try {
+ Connection conn = dbManager.getConnection();
+ try {
+ conn.setAutoCommit(false);
+ if (VersionNumberUtil.smallerThan(dbVersion, "3.2")) {
+ // on fait une migration vers 3.2
+ migrateTo3_2(conn);
+ }
+
+ // do same thing for other version
+
+ // commit des modifs
+ conn.commit();
+ // la migration a reussi, on dit que c fait
+ result = MigrationChoice.CUSTOM_MIGRATION;
+ } catch (Exception eee) {
+ // en cas d'erreur
+ log.error("Migration impossible de la base", eee);
+ // rollback du travail en cours
+ conn.rollback();
+ } finally {
+ // close database connexion
+ conn.close();
+ }
+ } catch (Exception eee) {
+ log.error("Error lors de la tentative de migration", eee);
+ }
+ }
- return result;
+ return MigrationChoice.NO_MIGRATION; // force false during test // result;
}
+ private void migrateTo3_2(Connection conn) {
+ log.info("Migrate to version 3.2");
+ //alteration du schema
+ // nouvelles equations dans les tables
+
+ // creation de valeur par defaut pour les equations
+
+
+ // recuperation des valeurs de ???
+
+ // creation de l'equation avec ces valeurs
+
+ // sauvegarde de l'equation
+ }
+
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AbstractSimulationQueueModel.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AbstractSimulationQueueModel.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AbstractSimulationQueueModel.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -15,6 +15,7 @@
import java.awt.Component;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -29,13 +30,14 @@
*
* @author chemit
*/
-public abstract class AbstractSimulationQueueModel extends JComponent implements TableModel, SimulationQueueListener, PropertyChangeListener {
+public abstract class AbstractSimulationQueueModel extends JComponent
+ implements TableModel, SimulationQueueListener, PropertyChangeListener {
/** @return list of ids of simulations contained in this model */
protected abstract List<String> getSimulationIds();
/** @return map of QueueItems (indexed by id) */
- protected abstract Map<String, SimulationManager.QueueItem> getQueueItemsAsMap();
+ protected abstract Map<String, SimulationManager.SimulationItem> getQueueItemsAsMap();
/** to use log facility, just put in your code: log.info("..."); */
protected static LutinLog log = LutinLogFactory.getLutinLog(AbstractSimulationQueueModel.class);
@@ -50,7 +52,14 @@
protected String[] header = new String[]{_("isisfish.queue.id"), _("isisfish.queue.plan"), _("isisfish.queue.name"), _("isisfish.queue.local"), _("isisfish.queue.status"), _("isisfish.queue.progression")};
/** columns types */
- protected Class[] columnClass = new Class[]{String.class, String.class, Boolean.class, Boolean.class, String.class, JProgressBar.class};
+ protected Class[] columnClass = new Class[]{
+ String.class, // id
+ String.class, // analyse plan number
+ Boolean.class, // in queue
+ String.class, // local, remote, batch
+ String.class, // text
+ JProgressBar.class // progress
+ };
/** progress bar (one for each row) */
protected Map<String, JProgressBar> progress = new HashMap<String, JProgressBar>();
@@ -116,7 +125,7 @@
* @param id id of the QueueItem to find
* @return the queueItem found via his id
*/
- protected SimulationManager.QueueItem getItem(String id) {
+ protected SimulationManager.SimulationItem getItem(String id) {
return getQueueItemsAsMap().get(id);
}
@@ -124,7 +133,7 @@
* @param rowIndex rowIndex of the QueueItem to find
* @return the queueItem found via his rowIndex
*/
- protected SimulationManager.QueueItem getItem(int rowIndex) {
+ protected SimulationManager.SimulationItem getItem(int rowIndex) {
String id = getSimulationId(rowIndex);
return id == null ? null : getQueueItemsAsMap().get(id);
}
@@ -134,24 +143,16 @@
* @return the SimulationControl of the given simulation
*/
protected SimulationControl getSimulationControl(String id) {
- SimulationControl result = null;
- SimulationManager.QueueItem item = getItem(id);
- if (item != null) {
- result = item.control;
- } else {
+ SimulationControl result = queue.getControl(id);
+ if (result == null) {
log.user(_("isisfish.error.invalid.simulation.id", id, getSimulationIds()));
}
return result;
}
public SimulationControl getSimulationControl(int rowIndex) {
- SimulationControl result = null;
- SimulationManager.QueueItem item = getItem(rowIndex);
- if (item != null) {
- result = item.control;
- } else {
- log.user(_("isisfish.error.invalid.simulation.index", rowIndex));
- }
+ String id = getSimulationId(rowIndex);
+ SimulationControl result = getSimulationControl(id);
return result;
}
/**
@@ -160,7 +161,7 @@
*/
protected SimulationParameter getSimulationParameter(String id) {
SimulationParameter result = null;
- SimulationManager.QueueItem item = getItem(id);
+ SimulationManager.SimulationItem item = getItem(id);
if (item != null) {
result = item.param;
} else {
@@ -189,6 +190,24 @@
}
/////////////////////////////////////////////
+ // SimulationQueueListener implementation
+ /////////////////////////////////////////////
+
+ /* (non-Javadoc)
+ * @see SimulationQueueListener#simulationStart(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
+ */
+ public void simulationStart(SimulationQueueEvent e) {
+ // nothing to do
+ }
+
+ /* (non-Javadoc)
+ * @see SimulationQueueListener#simulationStop(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
+ */
+ public void simulationStop(SimulationQueueEvent e) {
+ // nothing to do
+ }
+
+ /////////////////////////////////////////////
// TableModel implementation
/////////////////////////////////////////////
@@ -260,7 +279,15 @@
result = param.getInQueue();
break;
case 3:
- result = param.getLocal();
+ if (param.getLocal()) {
+ if (param.isSubProcess()) {
+ result = "batch";
+ } else {
+ result = "local";
+ }
+ } else {
+ result = "remote";
+ }
break;
case 4:
if (control != null) {
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AnalysePlanIndependent.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AnalysePlanIndependent.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/AnalysePlanIndependent.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -0,0 +1,46 @@
+/* *##%
+ * Copyright (C) 2007
+ * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ *
+ * 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 2
+ * 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+
+/* *
+ * AnalysePlan.java
+ *
+ * Created: 1 mars 07 20:27:28
+ *
+ * @author poussin
+ * @version $Revision: 336 $
+ *
+ * Last update: $Date: 2007-03-09 15:10:40 +0100 (ven, 09 mar 2007) $
+ * by : $Author: bpoussin $
+ */
+
+package fr.ifremer.isisfish.simulator;
+
+/**
+ * Use for Analyse plan that don't need previous simulation to do next
+ * simulation. When Simulation use this plan type, Isis can do more than one
+ * simulation in same time.
+ *
+ * author poussin
+ */
+public interface AnalysePlanIndependent extends AnalysePlan {
+
+
+}
+
+
Added: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointExternalProcessThread.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointExternalProcessThread.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointExternalProcessThread.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -0,0 +1,89 @@
+/**
+* SimulationCheckpointThread.java
+*
+* Created: Wed Aug 28 2002
+*
+* @author <poussin at codelutin.com>
+* Copyright Code Lutin
+* @version $Revision: 1187 $
+*
+* Mise a jour: $Date: 2008-03-19 01:26:10 +0100 (mer, 19 mar 2008) $
+* par : $Author: tchemit $
+*/
+
+package fr.ifremer.isisfish.simulator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.xmlrpc.XmlRpcClient;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.IsisContext;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
+import java.io.BufferedInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+/**
+ * This thread is responsable to synchronized SimulationControl used localy with
+ * remote simulation control for remote simulation.
+ *
+ * This thread dead when {@link SimulationControl#isRunning()} is false
+ *
+ * @author poussin
+ */
+public class SimulationCheckpointExternalProcessThread extends Thread { // SimulationCheckpointThread
+
+ /**
+ * Logger for this class
+ */
+ private static final Log log = LogFactory
+ .getLog(SimulationCheckpointExternalProcessThread.class);
+
+ protected SimulationControl control = null;
+ protected SimulationStorage simulation = null;
+ protected Process process = null;
+ // on l'appel plutot out que in, car c le output du process lance
+ protected InputStream out = null;
+
+ public SimulationCheckpointExternalProcessThread(SimulationControl control,
+ SimulationStorage simulation, Process process) {
+ this.control = control;
+ this.simulation = simulation;
+ this.process = process;
+ out = process.getInputStream();
+
+ }
+
+ public void run(){
+ int sleepTime = 2000;
+ int error = 0;
+ while(true){
+ try{
+ out.skip(out.available());
+ Thread.sleep(sleepTime);
+ // on ne lit pas le stop, car le stop ne peut-etre appeler
+ // que par l'utilisateur qui est de ce cote de la machine
+ simulation.readControl(control, "stop");
+
+ if (control.isStopSimulationRequest()) {
+ // FIXME, un destroy du process est peut-etre un peu violent ?
+ process.destroy();
+ // passe artificiellement le control a fini
+ control.stopSimulation();
+ }
+ if (!control.isRunning()) {
+ return;
+ }
+ } catch (Exception eee) {
+ log.debug("Can't update control for " + control.getId(), eee);
+ }
+ }
+
+ }
+
+} // SimulationCheckpointThread
Copied: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointRemoteThread.java (from rev 1289, branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointThread.java)
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointRemoteThread.java (rev 0)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointRemoteThread.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -0,0 +1,92 @@
+/**
+* SimulationCheckpointRemoteThread.java
+*
+* Created: Wed Aug 28 2002
+*
+* @author <poussin at codelutin.com>
+* Copyright Code Lutin
+* @version $Revision$
+*
+* Mise a jour: $Date$
+* par : $Author$
+*/
+
+package fr.ifremer.isisfish.simulator;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.Hashtable;
+import java.util.Vector;
+
+import org.apache.xmlrpc.XmlRpcClient;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.IsisContext;
+
+/**
+ * This thread is responsable to synchronized SimulationControl used localy with
+ * remote simulation control for remote simulation.
+ *
+ * This thread dead when {@link SimulationControl#isRunning()} is false
+ *
+ * @author poussin
+ */
+public class SimulationCheckpointRemoteThread extends Thread { // SimulationCheckpointRemoteThread
+
+ /**
+ * Logger for this class
+ */
+ private static final Log log = LogFactory
+ .getLog(SimulationCheckpointRemoteThread.class);
+
+ protected SimulationControl control = null;
+ int badId = 0;
+
+ public SimulationCheckpointRemoteThread(SimulationControl control) {
+ this.control = control;
+ }
+
+ public void run(){
+ int sleepTime = 2000;
+ while(true){
+ try{
+ Thread.sleep(sleepTime);
+
+ updateControl(control);
+ // on remet de le temps normal, vu que la connexion a reussi
+ sleepTime = 2000;
+
+ if (!control.isRunning()) {
+ return;
+ }
+
+ } catch (Exception eee) {
+ // on supporte 10 erreurs puis ensuite on quitte le thread.
+ if ( badId++ > 10){
+ log.error("Error !!! ", eee);
+ break;
+ }else{
+ // on a echouer sur une tentative, on allonge un
+ // peu le temps
+ sleepTime += 2000;
+ }
+ }
+ }
+
+ }
+
+ public void updateControl(SimulationControl control) throws Exception {
+ // essai l'ancienne etait en dur: "http://localhost:9090"
+ IsisConfig config = IsisContext.get().getMainConfig();
+ XmlRpcClient c = new XmlRpcClient(config.getSimulationServer());
+ c.setBasicAuthentication(config.getLogin(), config.getPassword());
+
+ Vector a = new Vector();
+ a.add(control.getUpdateHashtable());
+ Hashtable<String, Object> result = (Hashtable<String, Object>)c.execute("checkPoint", a);
+ // on remet de le temps normal, vu que la connexion a reussi
+ control.updateFromHashtable(result);
+ }
+
+} // SimulationCheckpointRemoteThread
Deleted: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointThread.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointThread.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationCheckpointThread.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -1,92 +0,0 @@
-/**
-* SimulationCheckpointThread.java
-*
-* Created: Wed Aug 28 2002
-*
-* @author <poussin at codelutin.com>
-* Copyright Code Lutin
-* @version $Revision$
-*
-* Mise a jour: $Date$
-* par : $Author$
-*/
-
-package fr.ifremer.isisfish.simulator;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.apache.xmlrpc.XmlRpcClient;
-
-import fr.ifremer.isisfish.IsisConfig;
-import fr.ifremer.isisfish.IsisContext;
-
-/**
- * This thread is responsable to synchronized SimulationControl used localy with
- * remote simulation control for remote simulation.
- *
- * This thread dead when {@link SimulationControl#isRunning()} is false
- *
- * @author poussin
- */
-public class SimulationCheckpointThread extends Thread { // SimulationCheckpointThread
-
- /**
- * Logger for this class
- */
- private static final Log log = LogFactory
- .getLog(SimulationCheckpointThread.class);
-
- protected SimulationControl control = null;
- int badId = 0;
-
- public SimulationCheckpointThread(SimulationControl control) {
- this.control = control;
- }
-
- public void run(){
- int sleepTime = 2000;
- while(true){
- try{
- Thread.sleep(sleepTime);
-
- updateControl(control);
- // on remet de le temps normal, vu que la connexion a reussi
- sleepTime = 2000;
-
- if (!control.isRunning()) {
- return;
- }
-
- } catch (Exception eee) {
- // on supporte 10 erreurs puis ensuite on quitte le thread.
- if ( badId++ > 10){
- log.error("Error !!! ", eee);
- break;
- }else{
- // on a echouer sur une tentative, on allonge un
- // peu le temps
- sleepTime += 2000;
- }
- }
- }
-
- }
-
- public void updateControl(SimulationControl control) throws Exception {
- // essai l'ancienne etait en dur: "http://localhost:9090"
- IsisConfig config = IsisContext.get().getMainConfig();
- XmlRpcClient c = new XmlRpcClient(config.getSimulationServer());
- c.setBasicAuthentication(config.getLogin(), config.getPassword());
-
- Vector a = new Vector();
- a.add(control.getUpdateHashtable());
- Hashtable<String, Object> result = (Hashtable<String, Object>)c.execute("checkPoint", a);
- // on remet de le temps normal, vu que la connexion a reussi
- control.updateFromHashtable(result);
- }
-
-} // SimulationCheckpointThread
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationControl.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationControl.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationControl.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -31,6 +31,7 @@
package fr.ifremer.isisfish.simulator;
+import fr.ifremer.isisfish.datastore.SimulationStorage;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
@@ -40,6 +41,7 @@
import org.apache.commons.logging.LogFactory;
import fr.ifremer.isisfish.types.Date;
+import java.util.Properties;
/**
* Permit to communicate with user interface from simulation thread
@@ -52,8 +54,12 @@
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
protected boolean inUpdateFromHashtable = false;
+ protected transient SimulationStorage simulation = null;
+ /** si vrai des qu'une propriete change, sauvegarde sont etat */
+ protected transient boolean autoSaveState = false;
protected String id = null;
+ protected boolean started = false;
protected boolean running = true;
protected boolean stop = false;
protected Date date = new Date();
@@ -70,16 +76,60 @@
this.id = id;
addPropertyChangeListener(this);
}
+
+ public void setAutoSaveState(boolean autoSaveState) {
+ this.autoSaveState = autoSaveState;
+ }
+
+ public boolean isAutoSaveState() {
+ return autoSaveState;
+ }
+ /**
+ * Retourne la simulation associe a ce control
+ * @return retourne null si la simulation n'existe pas encore
+ */
+ public SimulationStorage getSimulation() {
+ if (simulation == null) {
+ simulation = SimulationStorage.getSimulation(id);
+ }
+ return simulation;
+ }
+
+
+
+ public void addPropertyChangeListener(String propName, PropertyChangeListener l) {
+ listeners.addPropertyChangeListener(propName, l);
+ }
+
public void addPropertyChangeListener(PropertyChangeListener l) {
listeners.addPropertyChangeListener(l);
}
+ public void removePropertyChangeListener(String propName, PropertyChangeListener l) {
+ listeners.removePropertyChangeListener(propName, l);
+ }
+
public void removePropertyChangeListener(PropertyChangeListener l) {
listeners.removePropertyChangeListener(l);
}
+ public boolean isStarted() {
+ return started;
+ }
+
/**
+ * appelee juste avant de reellement demarrer le thread de simulation
+ * indique que cette simulation est en cours et qu'il ne faut plus la lancer
+ * @param running The running to set.
+ */
+ public void setStarted(boolean started) {
+ boolean oldValue = this.started;
+ this.started = started;
+ listeners.firePropertyChange("started", oldValue, this.started);
+ }
+
+ /**
* Method running
*
* @return faux une fois que stopSimulation a ete appele.
@@ -221,12 +271,75 @@
}
/**
+ * Met dans un Properties tous les champs
+ * @return un Properties avec tous les champs
+ */
+ public Properties getProperties() {
+ Properties result = new Properties();
+ result.setProperty("id", id);
+ result.setProperty("started", String.valueOf(started));
+ result.setProperty("running", String.valueOf(running));
+ result.setProperty("stop", String.valueOf(stop));
+ result.setProperty("date", String.valueOf(date.getDate()));
+ result.setProperty("progressMax", String.valueOf(progressMax));
+ result.setProperty("progress", String.valueOf(progress));
+ result.setProperty("text", text);
+
+ return result;
+ }
+
+ /**
+ * update current object from Properties representation
+ *
+ */
+ public void updateFromProperties(Properties h) {
+ inUpdateFromHashtable = true;
+ try {
+ if (h.contains("started")) {
+ boolean started = "true".equalsIgnoreCase(h.getProperty("started"));
+ setStarted(started);
+ }
+ if (h.contains("running")) {
+ boolean running = "true".equalsIgnoreCase(h.getProperty("running"));
+ setRunning(running);
+ }
+ if (h.contains("stop")) {
+ boolean stop = "true".equalsIgnoreCase(h.getProperty("stop"));
+ setStopSimulationRequest(stop);
+ }
+ if (h.contains("date")) {
+ Date date = new Date(Integer.parseInt(h.getProperty("date")));
+ setDate(date);
+ }
+ if (h.contains("progressMax")) {
+ int progressMax = Integer.parseInt(h.getProperty("progressMax"));
+ setProgressMax(progressMax);
+ }
+ if (h.contains("progress")) {
+ int progress = Integer.parseInt(h.getProperty("progress"));
+ setProgress(progress);
+ }
+ if (h.contains("text")) {
+ String text = h.getProperty("text");
+ setText(text);
+ }
+ } finally {
+ inUpdateFromHashtable = false;
+ }
+ }
+
+
+ /**
* update current object from hashtable representation
*
*/
public void updateFromHashtable(Hashtable h) {
inUpdateFromHashtable = true;
try {
+ if (h.contains("started")) {
+ boolean started = (Boolean)h.get("started");
+ setStarted(started);
+ }
if (h.contains("running")) {
boolean running = (Boolean)h.get("running");
setRunning(running);
@@ -266,6 +379,9 @@
} else {
Object value = e.getNewValue();
update.put(property, value);
+ if (isAutoSaveState() && getSimulation() != null) {
+ getSimulation().saveControl(this);
+ }
}
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationDoneQueueModel.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationDoneQueueModel.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationDoneQueueModel.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -62,13 +62,13 @@
* @see AbstractSimulationQueueModel at getSimulationIds()
*/
protected java.util.List<String> getSimulationIds() {
- return getQueue().idDones;
+ return getQueue().getDoneIds();
}
/* (non-Javadoc)
* @see AbstractSimulationQueueModel at getQueueItemsAsMap()
*/
- protected java.util.Map<String, SimulationManager.QueueItem> getQueueItemsAsMap() {
+ protected java.util.Map<String, SimulationManager.SimulationItem> getQueueItemsAsMap() {
return getQueue().mapDones;
}
@@ -89,57 +89,32 @@
// IsisConfig.SIMULATION_SHOW_ONLY_XXX properties)
int pos = getSimulationIndex(e.getId());
if (isRowIndexValid(pos)) {
- log.info(" in done model for " + e.getId() + " pos " + getSimulationIndex(e.getId()));
+ log.info(" in done model for " + e.getId() + " pos " + pos);
fireTableRowsInserted(pos, pos);
+
+ // on indique si la simulation a ete annulee
SimulationControl control = getSimulationControl(e.getId());
log.info("isStopSimulationRequest : "+control.isStopSimulationRequest());
if (control.isStopSimulationRequest()) {
control.setText(I18n._("isisfish.queue.cancelled"));
}
- SimulationManager.QueueItem item = getQueueItemsAsMap().get(e.getId());
- try {
- //TODO I don't known if this is good ?
- SimulationStorage lastSim = item.lastSimulation;
- SimulationParameter simulationParameter = getSimulationParameter(e.getId());
- if (lastSim != null) {
- if (simulationParameter.getUseAnalysePlan()) {
- //TODO Is the lastSimulation is the good one ???
- SimulationInformation infos = getItem(e.getId()).lastSimulation.getInformation();
- if (infos != null && infos.getException() != null) {
- // should deal with error
- log.error(I18n._("isisfish.error.while.simulation", infos.getException()));
- control.setText(I18n._("isisfish.message.stop.with.error"));
- }
- } else if (lastSim.getName().equals(e.getId())) {
- SimulationInformation infos = getItem(e.getId()).lastSimulation.getInformation();
- if (infos != null && infos.getException() != null) {
- // should deal with error
- log.error(I18n._("isisfish.error.while.simulation", infos.getException()));
- control.setText(I18n._("isisfish.message.stop.with.error",infos.getException()));
- }
+ // on change le message pour dire qu'il y a eu une erreur
+ try {
+ SimulationManager.SimulationItem item = getQueueItemsAsMap().get(e.getId());
+ if (!item.hasSimulation()) {
+ SimulationInformation infos = item.getSimulation().getInformation();
+ if (infos.hasError()) {
+ log.error(I18n._("isisfish.error.while.simulation", infos.getException()));
+ control.setText(I18n._("isisfish.message.stop.with.error"));
}
}
- // I don't known if you can come here with no previous simulation ?
- } catch (Exception e1) {
- log.warn(I18n._("isisfish.error.obtain.information.file", e.getId()));
+ } catch (Exception eee) {
+ log.warn(I18n._("isisfish.error.obtain.information.file", e.getId()), eee);
}
control.addPropertyChangeListener(this);
}
}
- /* (non-Javadoc)
- * @see SimulationQueueListener#simulationStart(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStart(SimulationQueueEvent e) {
- // nothing to do
- }
-
- /* (non-Javadoc)
- * @see SimulationQueueListener#simulationStop(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStop(SimulationQueueEvent e) {
- // nothing to do
- }
}// SimulationDoneQueueModel
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationHelper.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -63,6 +63,7 @@
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.IsisContext;
+import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.aspect.AspectClassLoader;
import fr.ifremer.isisfish.aspect.Cache;
import fr.ifremer.isisfish.aspect.Trace;
@@ -311,7 +312,11 @@
static public SimulationStorage simulate(SimulationControl control, SimulationStorage simulation) throws Exception {
SimulationStorage result;
if (simulation.getParameter().getLocal()) {
- result = localSimulate(control, simulation);
+ if (simulation.getParameter().isSubProcess()) {
+ result = subProcessSimulate(control, simulation);
+ } else {
+ result = localSimulate(control, simulation);
+ }
} else {
result = remoteSimulate(control, simulation);
}
@@ -328,14 +333,15 @@
* @return le storage après simulation
* @throws Exception pour toute erreur
*/
- static public SimulationStorage remoteSimulate(SimulationControl control, SimulationStorage simulation) throws Exception {
+ static public SimulationStorage remoteSimulate(SimulationControl control,
+ SimulationStorage simulation) throws Exception {
// export en zip du storage
File zip = simulation.createZip();
if (control != null) {
// creation du thread de surveillance de la simulation distante
// qui sert a mettre a jour les valeurs de control
- new SimulationCheckpointThread(control).start();
+ new SimulationCheckpointRemoteThread(control).start();
}
// envoie le zip au serveur de simulation
@@ -362,7 +368,41 @@
result = SimulationStorage.importAndRenameZip(tmpzip, control.getId());
return result;
}
-
+
+ static public SimulationStorage subProcessSimulate(SimulationControl control,
+ SimulationStorage simulation) throws Exception {
+
+ String simulationId = simulation.getName();
+
+ // on ferme le SimulationStorage pour ne pas interferer avec le process
+ simulation.closeStorage();
+
+ String java = System.getProperty("java.home") +
+ File.separator + "bin" + File.separator + "java";
+ String classpath = System.getProperty("java.class.path");
+
+ // prepare le process
+ ProcessBuilder processBuilder = new ProcessBuilder(java, "-classpath", classpath,
+ IsisFish.class.getName(),
+ "--simulate", simulationId);
+ processBuilder.redirectErrorStream(true);
+
+ // demarrage du process
+ Process process = processBuilder.start();
+
+ if (control != null) {
+ // prepare de thread de surveillance du process si control n'est pas null
+ Thread monitor = new SimulationCheckpointExternalProcessThread(control, simulation, process);
+ }
+
+ // on attend que la simulation soit fini
+ process.waitFor();
+
+ // on retourne directement le simulation storage passe en argument
+ // car la simulation a ete faite avec
+ return simulation;
+ }
+
/**
* fait la simulation en local dans un nouveau thread, cela permet
* pour chaque simulation d'avoir les bons scripts dans le classloader
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationManager.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -35,6 +35,7 @@
import fr.ifremer.isisfish.IsisContext;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.types.Date;
+import java.beans.PropertyChangeEvent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.codelutin.i18n.I18n._;
@@ -46,9 +47,14 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
import java.util.concurrent.PriorityBlockingQueue;
@@ -64,30 +70,33 @@
static protected SimulationManager instance = null;
- protected boolean autoLaunch = false;
+// protected boolean autoLaunch = false;
protected ListenerSet<SimulationQueueListener> listeners = new ListenerSet<SimulationQueueListener>();
protected PropertyChangeSupport propertyListeners = new PropertyChangeSupport(this);
- protected SimulationThread localThread;
- protected SimulationThread remoteThread;
+// protected SimulationThread localThread;
+// protected SimulationThread remoteThread;
- /** La queue, bloquante lorsqu'elle est vide, utilisé par le thread de simulation local*/
- protected PriorityBlockingQueue<QueueItem> localQueue = new PriorityBlockingQueue<QueueItem>();
- /** La queue, bloquante lorsqu'elle est vide, utilisé par le thread de simulation remote*/
- protected PriorityBlockingQueue<QueueItem> remoteQueue = new PriorityBlockingQueue<QueueItem>();
- /** La liste des simulations terminées */
- protected LinkedHashSet<QueueItem> dones = new LinkedHashSet<QueueItem>();
+ protected ExecutorService localExecutor;
+ protected ExecutorService remoteExecutor;
+
+// /** La queue, bloquante lorsqu'elle est vide, utilisé par le thread de simulation local*/
+// protected PriorityBlockingQueue<QueueItem> localQueue = new PriorityBlockingQueue<QueueItem>();
+// /** La queue, bloquante lorsqu'elle est vide, utilisé par le thread de simulation remote*/
+// protected PriorityBlockingQueue<QueueItem> remoteQueue = new PriorityBlockingQueue<QueueItem>();
+// /** La liste des simulations terminées */
+// protected LinkedHashSet<SimulationItem> dones = new LinkedHashSet<SimulationItem>();
- /** une liste des id (local et remote) */
- protected ArrayList<String> ids = new ArrayList<String>();
- /** une map id->item pour accelerer les acces */
- protected Map<String, QueueItem> map = new HashMap<String, QueueItem>();
+// /** une liste des id (local et remote) */
+// protected ArrayList<String> ids = new ArrayList<String>();
+ /** une map id->simItem pour accelerer les acces */
+ protected Map<String, SimulationItem> map = new LinkedHashMap<String, SimulationItem>();
- /** une liste des id des simulations terminées */
- protected ArrayList<String> idDones = new ArrayList<String>();
- /** une map id->item pour accelerer les acces aux simulation terminées */
- protected Map<String, QueueItem> mapDones = new HashMap<String, QueueItem>();
+// /** une liste des id des simulations terminées */
+// protected ArrayList<String> idDones = new ArrayList<String>();
+ /** une map id->simItem pour accelerer les acces aux simulation terminées */
+ protected Map<String, SimulationItem> mapDones = new LinkedHashMap<String, SimulationItem>();
static public SimulationManager getInstance() {
if (instance == null) {
@@ -100,20 +109,27 @@
* Cree l'objet et lance les deux threads de simulation (local/remote)
*/
protected SimulationManager() {
- localThread = new SimulationThread("local", this, localQueue);
- remoteThread = new SimulationThread("remote", this, remoteQueue);
+// localThread = new SimulationThread("local", this, localQueue);
+// remoteThread = new SimulationThread("remote", this, remoteQueue);
+//
+// localThread.start();
+// remoteThread.start();
- localThread.start();
- remoteThread.start();
+ // TODO passer ces valeurs en valeur configurable
+ int cpus = Runtime.getRuntime().availableProcessors();
+ int MAX_REMOTE_SIMULATION = 1;
+
+ localExecutor = Executors.newFixedThreadPool(cpus);
+ remoteExecutor = Executors.newFixedThreadPool(MAX_REMOTE_SIMULATION);
}
- /**
- * @return Returns the autoLaunch.
- */
- public boolean isAutoLaunch() {
- return this.autoLaunch;
- }
+// /**
+// * @return Returns the autoLaunch.
+// */
+// public boolean isAutoLaunch() {
+// return this.autoLaunch;
+// }
public void addPropertyChangeListener(PropertyChangeListener listener) {
propertyListeners.addPropertyChangeListener(listener);
@@ -131,32 +147,52 @@
propertyListeners.removePropertyChangeListener(propertyName, listener);
}
- /**
- * @param autoLaunch The autoLaunch to set.
- */
- public void setAutoLaunch(boolean autoLaunch) {
- boolean oldValue = this.autoLaunch;
- this.autoLaunch = autoLaunch;
- propertyListeners.firePropertyChange("autoLaunch", oldValue, autoLaunch);
- }
+// /**
+// * @param autoLaunch The autoLaunch to set.
+// */
+// public void setAutoLaunch(boolean autoLaunch) {
+// boolean oldValue = this.autoLaunch;
+// this.autoLaunch = autoLaunch;
+// propertyListeners.firePropertyChange("autoLaunch", oldValue, autoLaunch);
+// }
/**
* Cree l'objet de gestion de la simulation en interne et le place dans la
* bonne queue de simulation (local/remote). Appel le
- * {@link #fireAddEvent(String, QueueItem)}
+ * {@link #fireAddEvent(String, SimulationItem)}
* @param id l'id de simulation
* @param param les paramètres de la simulation
*/
- public void addSimulation(String id, SimulationParameter param) {
- QueueItem item = new QueueItem(id, param);
- fireAddEvent(id, item); // must be before thread notification because thread look in map
+ public void addSimulation(String id, SimulationParameter param) throws Exception {
+ ExecutorService executor = null;
if (param.getLocal()) {
- localQueue.add(item);
+ executor = localExecutor;
log.debug(_("isisfish.message.add.queue", id));
} else {
- remoteQueue.add(item);
+ executor = remoteExecutor;
log.debug(_("isisfish.message.add.queue.remote", id));
}
+
+ // on construit le bon type de SimulationItem pour le job
+ SimulationItem item = null;
+ if (param.getUseAnalysePlan()) {
+ if (!param.isIndependentPlan()) {
+ item = new SimulationItemPlan(id, param);
+ } else {
+ item = new SimulationItemPlanIndependent(id, param);
+ // l'item est independant, on ajoute toutes ces simulations en plus
+ // mais pas dans la map pour qu'il n'y ait bien que l'initiale
+ // plus celles en cours d'affichees
+ while(item.hasNext()) {
+ executor.submit(new SimulationJob(this, item.next()));
+ }
+ }
+ } else {
+ item = new SimulationItem(id, param);
+ }
+ fireAddEvent(id, item); // must be before thread notification because thread look in map
+
+ executor.submit(new SimulationJob(this, item));
}
/**
@@ -166,7 +202,7 @@
* @param id l'id de simulation
*/
public void removeSimulation(String id) {
- QueueItem item = map.get(id);
+ SimulationItem item = map.get(id);
if (item != null) {
item.control.setStopSimulationRequest(true);
}
@@ -174,6 +210,26 @@
}
/**
+ * Retourne une liste toujours dans le meme ordre des ids de simulation
+ * a faire
+ * @return
+ */
+ public List<String> getIds() {
+ List<String> result = new ArrayList<String>(map.keySet());
+ return result;
+ }
+
+ /**
+ * Retourne une liste toujours dans le meme ordre des ids de simulation
+ * a faire
+ * @return
+ */
+ public List<String> getDoneIds() {
+ List<String> result = new ArrayList<String>(mapDones.keySet());
+ return result;
+ }
+
+ /**
* @param id l'id de simulation
* @return <code>true</code> si un identifiant est utilisé pour une simulation
*/
@@ -202,8 +258,8 @@
listeners.remove(l);
}
- protected void fireAddEvent(String id, QueueItem item) {
- ids.add(id);
+ protected void fireAddEvent(String id, SimulationItem item) {
+// ids.add(id);
map.put(id, item);
SimulationQueueEvent e = new SimulationQueueEvent(this, id);
for (SimulationQueueListener l : listeners) {
@@ -216,21 +272,29 @@
// add the simulation in done model
// check if we should keep the simulation in done model
if (mustShowSimulationDone(id)) {
- idDones.add(id);
- SimulationManager.QueueItem queueItem = map.get(id);
- dones.add(queueItem);
+// idDones.add(id);
+ SimulationItem queueItem = map.get(id);
+// dones.add(queueItem);
mapDones.put(id, queueItem);
}
SimulationQueueEvent e = new SimulationQueueEvent(this, id);
for (SimulationQueueListener l : listeners) {
l.simulationWillBeRemoved(e);
}
- ids.remove(id);
+// ids.remove(id);
map.remove(id);
}
}
- protected void fireStartEvent(String id) {
+ protected void fireStartEvent(String id, SimulationItem item) {
+ if (!exists(id) && item.isIndependent()) {
+ // la simulation qui vient d'etre lancee n'existe pas, c parce qu'il
+ // s'agit d'une simulation de plan, on l'ajoute a la liste pour que
+ // l'utilisateur puisse la visualiser. On ne le fait pas pour les
+ // plan dependant car, il partage le meme controleur, donc
+ // l'utilisateur voit deja ce qui se passe
+ fireAddEvent(id, item);
+ }
SimulationQueueEvent e = new SimulationQueueEvent(this, id);
for (SimulationQueueListener l : listeners) {
l.simulationStart(e);
@@ -258,7 +322,7 @@
*/
public SimulationControl getControl(String id) {
SimulationControl result = null;
- QueueItem item = map.get(id);
+ SimulationItem item = map.get(id);
if (item != null) {
result = item.control;
}
@@ -273,233 +337,597 @@
protected boolean mustShowSimulationDone(String id) {
boolean result = true;
- QueueItem item = map.get(id);
- SimulationParameter simulationParameter = getParameter(id);
- IsisConfig config = IsisContext.get().getMainConfig();
- if (config.isSimulationShowOnlyQueue() && !simulationParameter.getLocal()) {
- return false;
- }
+ try {
+ IsisConfig config = IsisContext.get().getMainConfig();
- try {
- //TODO cela ne fonctionne pas, le fichier existe-il à ce moment ?
- if (config.isSimulationShowOnlyError() && item.lastSimulation.getInformation().getException() != null) {
- return true;
+ SimulationItem item = map.get(id);
+ if (item.hasPlanItem() && !item.getSimulation().getInformation().hasError()) {
+ // on ne met jamais dans la queue done les simulations de plan
+ // sauf si elle echoue
+ result = false;
+ } else if (!(config.isSimulationShowOnlyError() &&
+ !(item instanceof SimulationItemPlan) &&
+ item.getSimulation().getInformation().hasError())) {
+ result = false;
}
- } catch (Exception e) {
+ } catch (Exception eee) {
+ log.debug("Ne devrait pas arriver", eee);
// I don't known how it could appear, but in doubt, show it!
- return true;
}
return result;
}
+// /**
+// * Thread permettant de faire les simulations se trouvant dans la queue
+// * passée en parametre.
+// * <p>
+// * Si la simulation prise dans la queue n'existe plus, au moment ou on
+// * souhaite l'utiliser dans le {@link SimulationManager} alors elle est
+// * passée et on en recherche une autre.
+// *
+// * @author poussin
+// */
+// static class SimulationThread extends Thread {
+// protected SimulationManager simulationManager;
+// protected BlockingQueue<QueueItem> queue;
+//
+// /**
+// *
+// * @param name just small name to differenciate thread (local/remote)
+// * @param simulationManager le manager de simulation
+// * @param queue la queue de simulations
+// */
+// public SimulationThread(String name, SimulationManager simulationManager, BlockingQueue<QueueItem> queue) {
+// super("Simulation Thread " + name);
+// this.simulationManager = simulationManager;
+// this.queue = queue;
+// }
+//
+// /* (non-Javadoc)
+// * @see java.lang.Thread#run()
+// */
+// @Override
+// public void run() {
+// log.info("Start simulation thread");
+// while (true) {
+// // simItem qui sert a faire la simulation courante
+// QueueItem simItem = null;
+// try {
+// //
+// // recheche d'une simulation
+// //
+// while (simItem == null) {
+// log.debug("try to take simulation");
+// simItem = queue.take();
+// log.debug("Just take " + simItem.id);
+// if (!simulationManager.exists(simItem.id)) {
+// // on ne le retrouve pas dans la map, la simulation
+// // a donc ete supprimée par l'utilisateur on passe a la
+// // suivante
+// simItem = null;
+// } else if (!simulationManager.isAutoLaunch() && simItem.param.getInQueue()) {
+// // don't use simItem, because is queue and queue is not launched
+// queue.add(simItem);
+// simItem = null;
+// // sleep 1s. Because all other simItem is in queue too
+// // this sleep permit to user to put not queue simItem,
+// // with out eat cpu
+// sleep(1000);
+// }
+// }
+//
+// log.debug("use if has next simulation: " + simItem.id);
+// if (simItem.hasNext()) {
+// SimulationStorage sim = simItem.getSimulation();
+// String simId = sim.getName();
+// log.debug("Start simulation: " + simId);
+// SimulationControl control = simItem.control;
+// // set date to 0 at beginning of simulation
+// control.setDate(new Date());
+// control.setProgress(0);
+// control.setStarted(true);
+//
+// simulationManager.fireStartEvent(simItem.id);
+// try {
+// sim = SimulationHelper.simulate(control, sim);
+// simItem.setLastSimulation(sim);
+// } finally {
+// simulationManager.fireStopEvent(simItem.id);
+// }
+// // copie les exports de simulation dans le repertoire
+// // souhaiter par l'utilisateur
+// SimulationParameter param = sim.getParameter();
+// if (param.getExportNames() != null && param.getExportNames().size() > 0) {
+// File exportDir = IsisConfig.getResultExportDirectory(sim.getDirectory());
+// FileUtil.copyAndRenameRecursively(
+// exportDir,
+// new File(param.getExportDirectory()),
+// exportDir.getName(), simItem.id);
+//// FileUtil.copyAndRenameRecursively(
+//// exportDir,
+//// new File(sim.getDirectory(), IsisConfig.RESULT_EXPORT),
+//// IsisConfig.RESULT_EXPORT, simItem.id);
+// }
+//
+// if (simItem.hasNext() && simulationManager.exists(simItem.id)) {
+// // il y a encore des simulations a faire pour cet simItem
+// // on le remet dans la queue (on ne fait pas les autres
+// // simulations de cet simItem
+// // tout de suite car l'simItem peut-etre un simItem de queue
+// // moins prioritaire que les autres simulations
+// // il faut donc qu'il reprenne sa place dans l'ordre)
+//
+// queue.add(simItem);
+// } else {
+// // Si l'utilisateur souhaite seulement les exports
+// // on supprimer la/les simulations. Il faut le faire
+// // lorsqu'il n'y a plus de next car le calcul des plans
+// // peut avoir besoin des simulations precedentes
+// if (param.getOnlyExport()) {
+// if (param.getUseAnalysePlan()) {
+// for(File file : FileUtil.find(
+// IsisConfig.getSimulationDirectory(),
+// simItem.id + "_[0-9]+$", false)) {
+// log.debug("Delete simulation " + file);
+// FileUtil.deleteRecursively(file);
+// }
+// } else {
+// sim.delete(false);
+// }
+// }
+// simulationManager.fireRemoveEvent(simItem.id);
+//
+// if (simulationManager.isAutoLaunch() && simItem.param.getInQueue()) {
+// // if simItem is last in queue, stop the queue after that
+// QueueItem [] items = queue.toArray(new QueueItem[queue.size()]);
+// if (items.length > 0) {
+// QueueItem last = items[items.length-1];
+// if (!last.param.getInQueue()) {
+// // la derniere n'est pas en queue, donc plus de simulation en queue
+// simulationManager.setAutoLaunch(false);
+// }
+// } else {
+// // aucun simulation, donc forcement plus en queue non plus
+// simulationManager.setAutoLaunch(false);
+// }
+// }
+// }
+// }
+//
+//// } catch (Exception eee) {
+// } catch (Throwable eee) {
+// try {
+// // on sauvegarde l'erreur rencontrée, elle sera traité lors
+// // du fireRemoveEvent
+// simItem.lastSimulation.getInformation().setException(eee);
+// } catch (Exception e) {
+// if (log.isWarnEnabled()) {
+// log.warn(_("isisfish.error.during.simulation.information.file", simItem.id), eee);
+// }
+// } finally {
+// // error during simulation, remove bad simulation
+// simulationManager.fireRemoveEvent(simItem.id);
+// if (log.isWarnEnabled()) {
+// log.warn(_("isisfish.error.during.simulation", simItem.id), eee);
+// }
+// }
+//
+// } finally {
+// simItem = null;
+// }
+// }
+// }
+// }
+
+// /**
+// * Utilise pour les simulations avec plan d'analyse dependant
+// */
+// static class SimulationPlanJob implements Runnable {
+//
+// protected SimulationManager simulationManager;
+// protected SimulationItemPlan item;
+//
+// public SimulationPlanJob(SimulationManager simulationManager, SimulationItemPlan item) {
+// this.simulationManager = simulationManager;
+// this.item = item;
+// }
+//
+// public void run() {
+// try {
+// log.debug("use if has next simulation: " + item.id);
+// // on traite tout l'simItem dans le meme thread
+// while (simulationManager.exists(item.id) && item.hasNext()) {
+// SimulationStorage sim = item.getSimulation();
+// String simId = sim.getName();
+// log.debug("Start simulation: " + simId);
+// SimulationControl control = item.control;
+// // set date to 0 at beginning of simulation
+// control.setDate(new Date());
+// control.setProgress(0);
+// control.setStarted(true);
+//
+// simulationManager.fireStartEvent(item.id);
+// try {
+// sim = SimulationHelper.simulate(control, sim);
+// item.setLastSimulation(sim);
+// } finally {
+// simulationManager.fireStopEvent(item.id);
+// }
+// // copie les exports de simulation dans le repertoire
+// // souhaiter par l'utilisateur
+// SimulationParameter param = sim.getParameter();
+// if (param.getExportNames() != null &&
+// param.getExportNames().size() > 0) {
+// File exportDir = IsisConfig.getResultExportDirectory(
+// sim.getDirectory());
+// FileUtil.copyAndRenameRecursively(
+//
+// exportDir,
+// new File(param.getExportDirectory()),
+// exportDir.getName(), item.id);
+//// FileUtil.copyAndRenameRecursively(
+//// exportDir,
+//// new File(sim.getDirectory(), IsisConfig.RESULT_EXPORT),
+//// IsisConfig.RESULT_EXPORT, simItem.id);
+// }
+// }
+//
+// if (item.lastSimulation != null) {
+// SimulationParameter param = item.param;
+// // Si l'utilisateur souhaite seulement les exports
+// // on supprimer la/les simulations. Il faut le faire
+// // lorsqu'il n'y a plus de next car le calcul des plans
+// // peut avoir besoin des simulations precedentes
+// if (param.getOnlyExport()) {
+// if (param.getUseAnalysePlan()) {
+// for (File file : FileUtil.find(
+// IsisConfig.getSimulationDirectory(),
+// item.id + "_[0-9]+$", false)) {
+// log.debug("Delete simulation " + file);
+// FileUtil.deleteRecursively(file);
+// }
+// } else {
+// item.lastSimulation.delete(false);
+// }
+// }
+// }
+// // on previent que c la fin de la simulation
+// simulationManager.fireRemoveEvent(item.id);
+// } catch (Throwable eee) {
+// try {
+// // on sauvegarde l'erreur rencontrée, elle sera traité lors
+// // du fireRemoveEvent
+// if (item.lastSimulation != null) {
+// item.lastSimulation.getInformation().setException(eee);
+// }
+// } catch (Exception e) {
+// if (log.isWarnEnabled()) {
+// log.warn(_("isisfish.error.during.simulation.information.file", item.id), eee);
+// }
+// } finally {
+// // error during simulation, remove bad simulation
+// simulationManager.fireRemoveEvent(item.id);
+// if (log.isWarnEnabled()) {
+// log.warn(_("isisfish.error.during.simulation", item.id), eee);
+// }
+// }
+//
+// } finally {
+// item = null;
+// }
+// }
+//
+// }
+
/**
- * Thread permettant de faire les simulations se trouvant dans la queue
- * passée en parametre.
- * <p>
- * Si la simulation prise dans la queue n'existe plus, au moment ou on
- * souhaite l'utiliser dans le {@link SimulationManager} alors elle est
- * passée et on en recherche une autre.
- *
- * @author poussin
+ * Utilise pour les simulations sans plan d'analyse ou des plans independant
*/
- static class SimulationThread extends Thread {
+ static class SimulationJob implements Runnable {
+
protected SimulationManager simulationManager;
- protected BlockingQueue<QueueItem> queue;
+ protected SimulationItem simItem;
/**
- *
- * @param name just small name to differenciate thread (local/remote)
- * @param simulationManager le manager de simulation
- * @param queue la queue de simulations
+ *
+ * @param simulationManager
+ * @param parentId si ce job est le resulat d'un plan d'analyse
+ * independant, sinon null ou la meme valeur que id
+ * @param id l'identifiant de la simulation (avec _N pour ceux qui
+ * proviennent d'un plan d'analyse)
+ * @param zip le zip contenant la simulation
*/
- public SimulationThread(String name, SimulationManager simulationManager, BlockingQueue<QueueItem> queue) {
- super("Simulation Thread " + name);
+ public SimulationJob(SimulationManager simulationManager,
+ SimulationItem item) {
this.simulationManager = simulationManager;
- this.queue = queue;
+ this.simItem = item;
}
-
- /* (non-Javadoc)
- * @see java.lang.Thread#run()
- */
- @Override
+
public void run() {
- log.info("Start simulation thread");
- while (true) {
- // item qui sert a faire la simulation courante
- QueueItem item = null;
- try {
- //
- // recheche d'une simulation
- //
- while (item == null) {
- log.debug("try to take simulation");
- item = queue.take();
- log.debug("Just take " + item.id);
- if (!simulationManager.exists(item.id)) {
- // on ne le retrouve pas dans la map, la simulation
- // a donc ete supprimée par l'utilisateur on passe a la
- // suivante
- item = null;
- } else if (!simulationManager.isAutoLaunch() && item.param.getInQueue()) {
- // don't use item, because is queue and queue is not launched
- queue.add(item);
- item = null;
- // sleep 1s. Because all other item is in queue too
- // this sleep permit to user to put not queue item,
- // with out eat cpu
- sleep(1000);
- }
- }
+ try {
+ // si l'simItem exist encore (que l'utilisateur ne la pas retire)
+ while (simulationManager.exists(simItem.getPlanIdOrId()) &&
+ simItem.hasNext()) {
+ SimulationItem item = simItem.next();
+ try {
+ String id = item.id;
- log.debug("use if has next simulation: " + item.id);
- if (item.hasNext()) {
- SimulationStorage sim = item.getSimulation();
- String simId = sim.getName();
- log.debug("Start simulation: " + simId);
+ log.debug("Start simulation: " + id);
+ SimulationStorage simulation = item.getSimulation();
SimulationControl control = item.control;
// set date to 0 at beginning of simulation
control.setDate(new Date());
control.setProgress(0);
+ control.setStarted(true);
- simulationManager.fireStartEvent(item.id);
+ simulationManager.fireStartEvent(id, item);
try {
- sim = SimulationHelper.simulate(control, sim);
- item.setLastSimulation(sim);
+ simulation = SimulationHelper.simulate(control, simulation);
+ item.setLastSimulation(simulation);
} finally {
- simulationManager.fireStopEvent(item.id);
+ simulationManager.fireStopEvent(id);
}
// copie les exports de simulation dans le repertoire
// souhaiter par l'utilisateur
- SimulationParameter param = sim.getParameter();
- if (param.getExportNames() != null && param.getExportNames().size() > 0) {
- File exportDir = IsisConfig.getResultExportDirectory(sim.getDirectory());
+ SimulationParameter param = simulation.getParameter();
+ if (param.getExportNames() != null &&
+ param.getExportNames().size() > 0) {
+ File exportDir = IsisConfig.getResultExportDirectory(
+ simulation.getDirectory());
FileUtil.copyAndRenameRecursively(
exportDir,
new File(param.getExportDirectory()),
- exportDir.getName(), item.id);
+ // FIXME, est-ce bien parentId et pas id ?
+ exportDir.getName(), id);
// FileUtil.copyAndRenameRecursively(
// exportDir,
// new File(sim.getDirectory(), IsisConfig.RESULT_EXPORT),
-// IsisConfig.RESULT_EXPORT, item.id);
+// IsisConfig.RESULT_EXPORT, simItem.id);
}
-
- if (item.hasNext() && simulationManager.exists(item.id)) {
- // il y a encore des simulations a faire pour cet item
- // on le remet dans la queue (on ne fait pas les autres
- // simulations de cet item
- // tout de suite car l'item peut-etre un item de queue
- // moins prioritaire que les autres simulations
- // il faut donc qu'il reprenne sa place dans l'ordre)
-
- queue.add(item);
- } else {
- // Si l'utilisateur souhaite seulement les exports
- // on supprimer la/les simulations. Il faut le faire
- // lorsqu'il n'y a plus de next car le calcul des plans
- // peut avoir besoin des simulations precedentes
- if (param.getOnlyExport()) {
- if (param.getUseAnalysePlan()) {
- for(File file : FileUtil.find(
- IsisConfig.getSimulationDirectory(),
- item.id + "_[0-9]+$", false)) {
- log.debug("Delete simulation " + file);
- FileUtil.deleteRecursively(file);
- }
- } else {
- sim.delete(false);
- }
+ // Si l'utilisateur souhaite seulement les exports
+ // on supprimer la/les simulations.
+ // pour les plan dependant il faut le faire apres toutes
+ // les simulations
+ if (simItem.isIndependent() && param.getOnlyExport()) {
+ simulation.delete(false);
+ }
+ // on previent que c la fin de la simulation
+ simulationManager.fireRemoveEvent(id);
+ } catch (Throwable eee) {
+ try {
+ // on sauvegarde l'erreur rencontrée, elle sera traité lors
+ // du fireRemoveEvent
+ item.getSimulation().getInformation().setException(eee);
+ } catch (Exception e) {
+ if (log.isWarnEnabled()) {
+ log.warn(_("isisfish.error.during.simulation.information.file", item.id), eee);
}
+ } finally {
+ // error during simulation, remove bad simulation
simulationManager.fireRemoveEvent(item.id);
-
- if (simulationManager.isAutoLaunch() && item.param.getInQueue()) {
- // if item is last in queue, stop the queue after that
- QueueItem [] items = queue.toArray(new QueueItem[queue.size()]);
- if (items.length > 0) {
- QueueItem last = items[items.length-1];
- if (!last.param.getInQueue()) {
- // la derniere n'est pas en queue, donc plus de simulation en queue
- simulationManager.setAutoLaunch(false);
- }
- } else {
- // aucun simulation, donc forcement plus en queue non plus
- simulationManager.setAutoLaunch(false);
- }
+ if (log.isWarnEnabled()) {
+ log.warn(_("isisfish.error.during.simulation", item.id), eee);
}
}
}
-
-// } catch (Exception eee) {
- } catch (Throwable eee) {
- try {
- // on sauvegarde l'erreur rencontrée, elle sera traité lors
- // du fireRemoveEvent
- item.lastSimulation.getInformation().setException(eee);
- } catch (Exception e) {
- if (log.isWarnEnabled()) {
- log.warn(_("isisfish.error.during.simulation.information.file", item.id), eee);
- }
- } finally {
- // error during simulation, remove bad simulation
- simulationManager.fireRemoveEvent(item.id);
- if (log.isWarnEnabled()) {
- log.warn(_("isisfish.error.during.simulation", item.id), eee);
- }
- }
-
- } finally {
- item = null;
}
+ } catch (Exception eee) {
+ log.error("Can't take next simulation: " + simItem.id, eee);
}
- }
+ // suppression des simulations pour les plans dependants
+ // Si l'utilisateur souhaite seulement les exports
+ // on supprimer la/les simulations. Il faut le faire
+ // lorsqu'il n'y a plus de next car le calcul des plans
+ // peut avoir besoin des simulations precedentes
+ if (!simItem.isIndependent() && simItem.param.getOnlyExport()) {
+ for (File file : FileUtil.find(
+ IsisConfig.getSimulationDirectory(),
+ simItem.id + "_[0-9]+$", false)) {
+ log.debug("Delete simulation " + file);
+ FileUtil.deleteRecursively(file);
+ }
+ }
+
+ if (!simItem.control.isRunning() && simItem.hasSimulation()) {
+ // c'etait la derniere simulation du plan, on arrete le plan
+ simulationManager.fireStopEvent(simItem.id);
+ simulationManager.fireRemoveEvent(simItem.id);
+ }
+ }
}
/**
- * Permet de comparer les simulations pour les ordonner.
- * Les simulations de queue soit moins prioritaire que les autres, ensuite
- * l'ordre se fait sur la date d'arrivé dans la queue de simulation
- *
- * @author poussin
+ * Une simulation a faire sans plan d'experience
*/
- public class QueueItem implements Comparable<QueueItem> {
-
- protected long time;
+ public class SimulationItem {
protected String id;
protected SimulationParameter param;
- protected PlanGenerator plan = null;
+ protected SimulationItemPlan planItem = null;
protected File zip;
protected SimulationControl control;
protected SimulationStorage lastSimulation = null;
- public QueueItem(String id, SimulationParameter param) {
- this.time = System.nanoTime();
+ protected SimulationItem() {
+ }
+
+ public boolean isIndependent() {
+ return true;
+ }
+
+ /**
+ * Utilise pour servir sous simItem pour les items de plan d'experience
+ * @param id
+ * @param control
+ * @param sim
+ */
+ public SimulationItem(SimulationItemPlan planItem, SimulationControl control,
+ SimulationStorage sim) {
+ this.planItem = planItem;
+ this.id = sim.getName();
+ param = sim.getParameter();
+ this.control = control;
+ lastSimulation = sim;
+ }
+
+ /**
+ * Retourne l'id du plan qui a genere cet item, si cet item n'est
+ * pas genere par un plan, retourne directement l'id
+ * @return
+ */
+ public String getPlanIdOrId() {
+ String result = id;
+ if (hasPlanItem()) {
+ result = getPlanItem().id;
+ }
+ return result;
+ }
+
+ public SimulationItemPlan getPlanItem() {
+ return planItem;
+ }
+
+ public boolean hasPlanItem() {
+ boolean result = planItem != null;
+ return result;
+ }
+
+ /**
+ * creer un simItem de simulation et prepare le zip
+ * @param id
+ * @param param
+ */
+ public SimulationItem(String id, SimulationParameter param) {
this.id = id;
this.param = param;
this.control = new SimulationControl(id);
+ zip = SimulationHelper.prepareSimulationZipFile(control, param, true);
+ }
+
+ public boolean hasSimulation() {
+ boolean result = lastSimulation != null;
+ return result;
+ }
+
+ /**
+ * Retourne la simulation qu'il faut faire
+ * @return le storage de simulation
+ * @throws Exception si problème pendant l'import de la simulation
+ */
+ public SimulationStorage getSimulation() throws Exception {
+ if (lastSimulation == null) {
+ lastSimulation = SimulationStorage.importAndRenameZip(zip, id);
+ }
+ return lastSimulation;
+ }
+
+ /**
+ * Appelé apres que la simulation est vraiment eu lieu. On en a besoin
+ * car pour une simulation distante apres la simulation le storage
+ * a ete changé par rapport au storage initialement cree pour la
+ * simulation
+ *
+ * @param lastSimulation The lastSimulation to set.
+ */
+ public void setLastSimulation(SimulationStorage lastSimulation) {
+ this.lastSimulation = lastSimulation;
+ if (hasPlanItem()) {
+ getPlanItem().setLastSimulation(lastSimulation);
+ }
+ }
+
+ /**
+ * @return <code>true</code> s'il y a encore une simulation si on
+ * utilise un plan et qu'il dit qu'il y en a encore, ou si la simulation
+ * n'a pas encore ete faite.
+ */
+ public boolean hasNext() {
+ boolean result;
+ result = !control.isStarted();
+ return result;
+ }
+
+ /**
+ * Ce retourne lui meme, car il n'y a pas de plan
+ * @return
+ */
+ public SimulationItem next() throws Exception {
+ return this;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ boolean result = false;
+ if (obj instanceof SimulationItem) {
+ result = param.equals(((SimulationItem)obj).param);
+ }
+ return result;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 53 * hash + (this.param != null ? this.param.hashCode() : 0);
+ return hash;
+ }
+
+ }
+
+ /**
+ * Une simulation a faire qui contient un plan d'experience dependant
+ */
+ public class SimulationItemPlan extends SimulationItem implements PropertyChangeListener {
+ // FIXME a mettre en config MAX_SIMULATION_PLAN
+ // nombre maximal de simulation de plan par simulation
+ // (pour eviter les plans qui ne retroune jamais faux
+ protected static final int MAX_SIMULATION_PLAN = 10000;
+
+ protected int simulationNumber = 0;
+ protected int simulationFinished = 0;
+ protected PlanGenerator plan = null;
+
+ public SimulationItemPlan(String id, SimulationParameter param) {
+ this.id = id;
+ this.param = param;
+ this.control = new SimulationControl(id);
// ne pas inverser la creation de PlanGenerator et du zip.
// car le init des plans est fait dans le constructeur de
// PlanGenerator, et le init peut modifier les parametres
// de simulation
- if (param.getUseAnalysePlan()) {
- plan = new PlanGenerator(id, control, param);
+ if (!param.getUseAnalysePlan()) {
+ throw new SimulationException("Your simulation is not a plan:" + id);
}
+
+ plan = new PlanGenerator(id, control, param);
zip = SimulationHelper.prepareSimulationZipFile(control, param, true);
- if (plan != null) {
- plan.setZip(zip);
- }
+ plan.setZip(zip);
}
+ @Override
+ public boolean isIndependent() {
+ return false;
+ }
+
/**
* Retourne la simulation qu'il faut faire
* @return le storage de simulation
* @throws Exception si problème pendant l'import de la simulation
*/
+ @Override
public SimulationStorage getSimulation() throws Exception {
+ throw new UnsupportedOperationException("Plan item don't have simulation");
+ }
+
+ /**
+ * Retourne la simulation qu'il faut faire
+ * @return le storage de simulation
+ * @throws Exception si problème pendant l'import de la simulation
+ */
+ public SimulationStorage getNextSimulation() throws Exception {
SimulationStorage result;
- if (plan != null) {
- result = plan.next();
- } else {
- result = SimulationStorage.importAndRenameZip(zip, id);
- }
+ result = plan.next();
+ simulationNumber++;
lastSimulation = result;
return result;
}
@@ -512,11 +940,10 @@
*
* @param lastSimulation The lastSimulation to set.
*/
+ @Override
public void setLastSimulation(SimulationStorage lastSimulation) {
this.lastSimulation = lastSimulation;
- if (plan != null) {
- plan.setLastSimulation(lastSimulation);
- }
+ plan.setLastSimulation(lastSimulation);
}
/**
@@ -524,47 +951,66 @@
* utilise un plan et qu'il dit qu'il y en a encore, ou si la simulation
* n'a pas encore ete faite.
*/
+ @Override
public boolean hasNext() {
boolean result;
- result = (plan != null && plan.hasNext()) || lastSimulation == null;
+ result = simulationNumber < MAX_SIMULATION_PLAN &&
+ ((plan != null && plan.hasNext()) || lastSimulation == null);
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
+ /**
+ * On utilise le meme control pour les plans dependants
+ * @return
*/
@Override
- public boolean equals(Object obj) {
- boolean result = false;
- if (obj instanceof QueueItem) {
- result = param.equals(((QueueItem)obj).param);
- }
+ public SimulationItem next() throws Exception {
+ SimulationStorage sim = getNextSimulation();
+ SimulationItem result = new SimulationItem(this, control, sim);
return result;
}
- /* (non-Javadoc)
- * @see java.lang.Comparable#compareTo(java.lang.Object)
- */
- public int compareTo(QueueItem o) {
- int result;
-
- boolean inQueue1 = param.getInQueue();
- boolean inQueue2 = o.param.getInQueue();
- if (inQueue1 == inQueue2) {
- // this et o ont la meme valeur, on compare les temps
- // le plus vieux devant (donc le plus petit)
- result = time<o.time ? -1 : (time==o.time ? 0 : 1);
- } else if (inQueue1) {
- // this est dans la queue donc moins prioritaire
- // on le met donc a la fin
- result = 1;
- } else {
- // o est dans la queue donc moins prioritaire
- result = -1;
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (Boolean.FALSE.equals(evt.getNewValue())) {
+ simulationFinished++;
+ control.setProgress(simulationFinished);
+ control.setText(simulationFinished + " / " + simulationNumber);
+ if (simulationFinished >= simulationNumber) {
+ control.stopSimulation();
+ }
}
+ }
+ }
+
+ /**
+ * Une simulation a faire qui contient un plan d'experience independant
+ */
+ public class SimulationItemPlanIndependent extends SimulationItemPlan {
+
+ public SimulationItemPlanIndependent(String id, SimulationParameter param) {
+ super(id, param);
+ }
+
+ @Override
+ public boolean isIndependent() {
+ return true;
+ }
+
+ /**
+ * On utilise un nouveau control pour les plans independants
+ * @return
+ */
+ @Override
+ public SimulationItem next() throws Exception {
+ SimulationStorage sim = getNextSimulation();
+ control.setProgressMax(simulationNumber);
+ SimulationControl control = new SimulationControl(sim.getName());
+ control.addPropertyChangeListener("running", this);
+ SimulationItem result = new SimulationItem(this, control, sim);
return result;
}
+
}
}
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -127,6 +127,9 @@
/** La simulation doit etre faite en local */
protected boolean local = true;
+ /** La simulation doit etre faite dans un sous process */
+ protected boolean subProcess = false;
+
/** La simulation doit etre lancé dans la queue de simulation (non prioritaire)*/
protected boolean inQueue = false;
@@ -273,6 +276,7 @@
result.setProperty("exports", exportList);
result.setProperty("local", String.valueOf(local));
+ result.setProperty("subProcess", String.valueOf(subProcess));
result.setProperty("inQueue", String.valueOf(inQueue));
result.setProperty("usePreScript", String.valueOf(usePreScript));
result.setProperty("preScript", preScript);
@@ -415,6 +419,7 @@
}
local = Boolean.parseBoolean(props.getProperty("local", "true"));
+ subProcess = Boolean.parseBoolean(props.getProperty("subProcess", "false"));
inQueue = Boolean.parseBoolean(props.getProperty("inQueue", "false"));
usePreScript = Boolean.parseBoolean(props.getProperty("usePreScript",
"false"));
@@ -680,7 +685,14 @@
this.local = local;
}
+ public void setSubProcess(boolean subProcess) {
+ this.subProcess = subProcess;
+ }
+ public boolean isSubProcess() {
+ return subProcess;
+ }
+
/**
* @return Returns the inQueue.
*/
@@ -715,6 +727,17 @@
public boolean getUseStatistic() {
return this.useStatistic;
}
+
+ public boolean isIndependentPlan() {
+ boolean result = true;
+ for (AnalysePlan plan : getAnalysePlans()) {
+ if (!(plan instanceof AnalysePlanIndependent)) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
/**
* @param useStatistic The useStatistic to set.
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModel.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -31,6 +31,9 @@
package fr.ifremer.isisfish.simulator;
+import java.util.ArrayList;
+import java.util.List;
+
/** @author poussin */
public class SimulationQueueModel extends AbstractSimulationQueueModel {
@@ -53,13 +56,13 @@
* @see AbstractSimulationQueueModel at getSimulationIds()
*/
protected java.util.List<String> getSimulationIds() {
- return getQueue().ids;
+ return getQueue().getIds();
}
/* (non-Javadoc)
* @see AbstractSimulationQueueModel at getQueueItemsAsMap()
*/
- protected java.util.Map<String, SimulationManager.QueueItem> getQueueItemsAsMap() {
+ protected java.util.Map<String, SimulationManager.SimulationItem> getQueueItemsAsMap() {
return getQueue().map;
}
@@ -89,18 +92,4 @@
progress.remove(id);
}
- /* (non-Javadoc)
- * @see SimulationQueueListener#simulationStart(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStart(SimulationQueueEvent e) {
- // nothing to do
- }
-
- /* (non-Javadoc)
- * @see SimulationQueueListener#simulationStop(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStop(SimulationQueueEvent e) {
- // nothing to do
- }
-
} // SimulationQueueModel
\ No newline at end of file
Deleted: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModelOld.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModelOld.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/simulator/SimulationQueueModelOld.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -1,409 +0,0 @@
-/* *##%
- * Copyright (C) 2006
- * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
- *
- * 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 2
- * 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, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-
-/* *
- * SimulationQueueModel.java
- *
- * Created: 18 août 2006 00:05:41
- *
- * @author poussin
- * @version $Revision$
- *
- * Last update: $Date$
- * by : $Author$
- */
-
-package fr.ifremer.isisfish.simulator;
-
-import static org.codelutin.i18n.I18n._;
-
-import java.awt.Component;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.swing.JComponent;
-import javax.swing.JProgressBar;
-import javax.swing.JTable;
-import javax.swing.event.EventListenerList;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableModel;
-
-import org.codelutin.log.LutinLog;
-import org.codelutin.log.LutinLogFactory;
-
-
-/**
- * @author poussin
- *
- */
-
-public class SimulationQueueModelOld extends JComponent implements TableModel, SimulationQueueListener, PropertyChangeListener {
-
- /** to use log facility, just put in your code: log.info("..."); */
- static private LutinLog log = LutinLogFactory.getLutinLog(SimulationQueueModel.class);
-
- /** List of listeners */
- protected EventListenerList listenerList = new EventListenerList();
-
- protected SimulationManager queue;
- protected String [] header = new String[]{_("isisfish.queue.id"),_("isisfish.queue.plan"),_("isisfish.queue.name"),_("isisfish.queue.local"),_("isisfish.queue.status"),_("isisfish.queue.progression")};
- protected Class [] columnClass = new Class[]{String.class, String.class, Boolean.class, Boolean.class, String.class, JProgressBar.class};
-
- protected Map<String, JProgressBar> progress = new HashMap<String, JProgressBar>();
-
- /**
- * use SimulationQueue.getInstance() as queue
- */
- public SimulationQueueModelOld() {
- this(SimulationManager.getInstance());
- }
-
- /**
- * if queue is null, then the model used SimulationQueue.getInstance() as queue
- */
- public SimulationQueueModelOld(SimulationManager queue) {
- this.queue = queue;
- if (queue == null) {
- this.queue = SimulationManager.getInstance();
- }
- this.queue.addSimulationQueueListener(this);
-
- // add this model as listener on all already launched simulation
- for (String id : this.queue.ids) {
- SimulationControl control = this.queue.getControl(id);
- if (control != null) {
- control.addPropertyChangeListener(this);
- }
- }
- }
-
- /**
- * @param queue The queue to set.
- */
- public void setQueue(SimulationManager queue) {
- this.queue = queue;
- fireTableDataChanged();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getRowCount()
- */
- public int getRowCount() {
- int result = queue.ids.size();
- return result;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getColumnCount()
- */
- public int getColumnCount() {
- return header.length;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.AbstractTableModel#getColumnName(int)
- */
- public String getColumnName(int column) {
- return header[column];
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.AbstractTableModel#getColumnClass(int)
- */
- public Class<?> getColumnClass(int columnIndex) {
- return columnClass[columnIndex];
- }
-
- public SimulationControl getSimulationControl(int rowIndex) {
- SimulationControl result = null;
- if (rowIndex >= 0) {
- String id = queue.ids.get(rowIndex);
- result = queue.getControl(id);
- } else {
- log.user(_("isisfish.error.invalide.simulation.index"));
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#getValueAt(int, int)
- */
- public Object getValueAt(int rowIndex, int columnIndex) {
- Object result = "";
- if (rowIndex >= queue.ids.size()) {
- return "error";
- }
- String id = queue.ids.get(rowIndex);
- SimulationControl control = queue.getControl(id);
- switch (columnIndex) {
- case 0:
- result = id;
- break;
- case 1:
- int number = queue.getParameter(id).getAnalysePlanNumber();
- if (number >= 0) {
- result = number;
- } else {
- result = _("isisfish.common.no");
- }
- break;
- case 2:
- result = queue.getParameter(id).getInQueue();
- break;
- case 3:
- result = queue.getParameter(id).getLocal();
- break;
- case 4:
- if (control != null) {
- if (control.isStopSimulationRequest()) {
- result = _("isisfish.launch.stop");
- } else {
- result = control.getText();
- }
- }
- break;
- case 5:
- JProgressBar pb = getProgressBar(id);
- if (control != null) {
- pb.setMaximum(control.getProgressMax());
- pb.setValue(control.getProgress());
- pb.setString(control.date.getMonth() + "/" + control.date.getYear());
- }
- result = pb;
- break;
- }
- return result;
- }
-
- protected JProgressBar getProgressBar(String id) {
- JProgressBar result = progress.get(id);
- if (result == null) {
- result = new JProgressBar(JProgressBar.HORIZONTAL, 0, 100);
- result.setStringPainted(true);
- progress.put(id, result);
- }
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent evt) {
- SimulationControl control = (SimulationControl)evt.getSource();
- int row = queue.ids.indexOf(control.getId());
- fireTableRowsUpdated(row, row);
- }
-
- /* (non-Javadoc)
- * @see fr.ifremer.isisfish.simulator.SimulationQueueListener#simulationAdded(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationAdded(SimulationQueueEvent e) {
- int row = getRowCount();
- fireTableRowsInserted(row, row);
- SimulationControl control = queue.getControl(e.getId());
- control.addPropertyChangeListener(this);
- }
-
- /* (non-Javadoc)
- * @see fr.ifremer.isisfish.simulator.SimulationQueueListener#simulationRemoved(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationWillBeRemoved(SimulationQueueEvent e) {
- String id = e.getId();
-
- SimulationControl control = queue.getControl(id);
- if (control != null) {
- control.removePropertyChangeListener(this);
- }
-
- int row = queue.ids.indexOf(id);
- fireTableRowsDeleted(row, row);
- progress.remove(id);
- }
-
- /* (non-Javadoc)
- * @see fr.ifremer.isisfish.simulator.SimulationQueueListener#simulationStart(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStart(SimulationQueueEvent e) {
- // nothing to do
- }
- /* (non-Javadoc)
- * @see fr.ifremer.isisfish.simulator.SimulationQueueListener#simulationStop(fr.ifremer.isisfish.simulator.SimulationQueueEvent)
- */
- public void simulationStop(SimulationQueueEvent e) {
- // nothing to do
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#isCellEditable(int, int)
- */
- public boolean isCellEditable(int rowIndex, int columnIndex) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
- */
- public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#addTableModelListener(javax.swing.event.TableModelListener)
- */
- public void addTableModelListener(TableModelListener l) {
- listenerList.add(TableModelListener.class, l);
- if (l instanceof JTable) {
- ((JTable)l).setDefaultRenderer(JProgressBar.class, new JProgressBarTableCellRenderer());
- }
-
- }
-
- /* (non-Javadoc)
- * @see javax.swing.table.TableModel#removeTableModelListener(javax.swing.event.TableModelListener)
- */
- public void removeTableModelListener(TableModelListener l) {
- listenerList.remove(TableModelListener.class, l);
- }
-
- /**
- * Notifies all listeners that all cell values in the table's
- * rows may have changed. The number of rows may also have changed
- * and the <code>JTable</code> should redraw the
- * table from scratch. The structure of the table (as in the order of the
- * columns) is assumed to be the same.
- *
- * @see TableModelEvent
- * @see EventListenerList
- * @see JTable#tableChanged(TableModelEvent)
- */
- public void fireTableDataChanged() {
- fireTableChanged(new TableModelEvent(this));
- }
-
- /**
- * Notifies all listeners that the table's structure has changed.
- * The number of columns in the table, and the names and types of
- * the new columns may be different from the previous state.
- * If the <code>JTable</code> receives this event and its
- * <code>autoCreateColumnsFromModel</code>
- * flag is set it discards any table columns that it had and reallocates
- * default columns in the order they appear in the model. This is the
- * same as calling <code>setModel(TableModel)</code> on the
- * <code>JTable</code>.
- *
- * @see TableModelEvent
- * @see EventListenerList
- */
- public void fireTableStructureChanged() {
- fireTableChanged(new TableModelEvent(this, TableModelEvent.HEADER_ROW));
- }
-
- /**
- * Notifies all listeners that rows in the range
- * <code>[firstRow, lastRow]</code>, inclusive, have been inserted.
- *
- * @param firstRow the first row
- * @param lastRow the last row
- *
- * @see TableModelEvent
- * @see EventListenerList
- *
- */
- public void fireTableRowsInserted(int firstRow, int lastRow) {
- fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
- }
-
- /**
- * Notifies all listeners that rows in the range
- * <code>[firstRow, lastRow]</code>, inclusive, have been updated.
- *
- * @param firstRow the first row
- * @param lastRow the last row
- *
- * @see TableModelEvent
- * @see EventListenerList
- */
- public void fireTableRowsUpdated(int firstRow, int lastRow) {
- fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE));
- }
-
- /**
- * Notifies all listeners that rows in the range
- * <code>[firstRow, lastRow]</code>, inclusive, have been deleted.
- *
- * @param firstRow the first row
- * @param lastRow the last row
- *
- * @see TableModelEvent
- * @see EventListenerList
- */
- public void fireTableRowsDeleted(int firstRow, int lastRow) {
- fireTableChanged(new TableModelEvent(this, firstRow, lastRow,
- TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
- }
-
- /**
- * Notifies all listeners that the value of the cell at
- * <code>[row, column]</code> has been updated.
- *
- * @param row row of cell which has been updated
- * @param column column of cell which has been updated
- * @see TableModelEvent
- * @see EventListenerList
- */
- public void fireTableCellUpdated(int row, int column) {
- fireTableChanged(new TableModelEvent(this, row, row, column));
- }
-
- /**
- * Forwards the given notification event to all
- * <code>TableModelListeners</code> that registered
- * themselves as listeners for this table model.
- *
- * @param e the event to be forwarded
- *
- * @see #addTableModelListener
- * @see TableModelEvent
- * @see EventListenerList
- */
- public void fireTableChanged(TableModelEvent e) {
- // Guaranteed to return a non-null array
- Object[] listeners = listenerList.getListenerList();
- // Process the listeners last to first, notifying
- // those that are interested in this event
- for (int i = listeners.length-2; i>=0; i-=2) {
- if (listeners[i]==TableModelListener.class) {
- ((TableModelListener)listeners[i+1]).tableChanged(e);
- }
- }
- }
-
-
- public class JProgressBarTableCellRenderer implements TableCellRenderer {
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- return (JProgressBar)value;
- }
- }// JProgressBarTableCellRenderer
-
-}
\ No newline at end of file
Modified: branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java
===================================================================
--- branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java 2008-08-07 17:05:40 UTC (rev 1290)
+++ branches/isis-fish-3.1.4/src/java/fr/ifremer/isisfish/ui/simulator/SimulatorListeners.java 2008-08-07 19:38:45 UTC (rev 1291)
@@ -115,8 +115,10 @@
* <code>false</code> otherwise
*/
public static boolean isSimulStartButtonEnabled(JTable table) {
- return !SimulationManager.getInstance().isAutoLaunch() &&
- (table.getRowCount() > 0);
+ return false;
+ // L'auto launche a disparu maintenant
+// return !SimulationManager.getInstance().isAutoLaunch() &&
+// (table.getRowCount() > 0);
}
/**
1
0
Author: bpoussin
Date: 2008-08-07 17:05:40 +0000 (Thu, 07 Aug 2008)
New Revision: 1290
Added:
branches/isis-fish-3.1.3/
Log:
sauvegarde de la version 3.1.3 avant
de casser le mecanisme de simulation
Copied: branches/isis-fish-3.1.3 (from rev 1289, branches/isis-fish-3.1.4)
1
0