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
April 2010
- 1 participants
- 27 discussions
r3039 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 30 Apr '10
by chatellier@users.labs.libre-entreprise.org 30 Apr '10
30 Apr '10
Author: chatellier
Date: 2010-04-30 12:09:05 +0000 (Fri, 30 Apr 2010)
New Revision: 3039
Log:
Fix duplicated preScript storage (just deprecated, still used when simulating from comand line)
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationJob.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-30 07:41:38 UTC (rev 3038)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-30 12:09:05 UTC (rev 3039)
@@ -98,13 +98,15 @@
* Constructor.
*
* @param control le control pour la simulation.
- * @param param les parametres de simulation.
+ * @param param les parametres de simulation (can be null)
*/
public SimulationItem(SimulationControl control, SimulationParameter param) {
this.control = control;
// use soft reference to improve minimum memory usage
- this.parameter = new SimulationParameterCache(param);
+ if (param != null) {
+ this.parameter = new SimulationParameterCache(param);
+ }
}
/**
@@ -171,7 +173,20 @@
* @deprecated use cached simulation parameter instead
*/
public String getSimulationPrescriptContent() {
- return simulationPrescriptContent;
+
+ String preScript = simulationPrescriptContent;
+
+ // simulationPrescriptContent is not null when isis is lauched with
+ // simulation on comand line
+ // If preScript but params is not null, simulation has been launched by
+ // UI, use cached simulation parameters
+ if (preScript == null && parameter != null) {
+ if (parameter.getUsePreScript()) {
+ preScript = parameter.getPreScript();
+ }
+ }
+
+ return preScript;
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationJob.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationJob.java 2010-04-30 07:41:38 UTC (rev 3038)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationJob.java 2010-04-30 12:09:05 UTC (rev 3039)
@@ -255,11 +255,12 @@
//File zip = item.getSimulationZip();
// get prescript content, only if UsePreScript is set to true
- String simulationPrescript = null;
+ // FIXME EC-20100410 use prescriot already present in params
+ /*String simulationPrescript = null;
if(param.getUsePreScript()) {
simulationPrescript = param.getPreScript();
item.setSimulationPrescriptContent(simulationPrescript);
- }
+ }*/
launcher.simulate(simulationService, item);
}
1
0
r3038 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 30 Apr '10
by chatellier@users.labs.libre-entreprise.org 30 Apr '10
30 Apr '10
Author: chatellier
Date: 2010-04-30 07:41:38 +0000 (Fri, 30 Apr 2010)
New Revision: 3038
Log:
Simulation prescript is still reference without caching
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-29 16:37:33 UTC (rev 3037)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-30 07:41:38 UTC (rev 3038)
@@ -167,6 +167,8 @@
* Get simulation prescript.
*
* @return the simulationPrescriptPath
+ *
+ * @deprecated use cached simulation parameter instead
*/
public String getSimulationPrescriptContent() {
return simulationPrescriptContent;
@@ -176,6 +178,8 @@
* Set simulation prescript.
*
* @param simulationPrescriptContent the simulationPrescriptContent to set
+ *
+ * @deprecated use cached simulation parameter instead
*/
public void setSimulationPrescriptContent(String simulationPrescriptContent) {
this.simulationPrescriptContent = simulationPrescriptContent;
1
0
Author: chatellier
Date: 2010-04-29 16:37:33 +0000 (Thu, 29 Apr 2010)
New Revision: 3037
Log:
Update changelog
Modified:
isis-fish/trunk/changelog.txt
Modified: isis-fish/trunk/changelog.txt
===================================================================
--- isis-fish/trunk/changelog.txt 2010-04-29 16:36:24 UTC (rev 3036)
+++ isis-fish/trunk/changelog.txt 2010-04-29 16:37:33 UTC (rev 3037)
@@ -1,3 +1,9 @@
+isis-fish (3.3.0.4) stable; urgency=low
+
+ * Add simulation parameter cache to not keep simulation prescript on memory
+
+ -- jeu. avril 29 18:47:58 CEST 2010
+
isis-fish (3.3.0.3) stable; urgency=low
* Add new option to customize qsub options
1
0
r3036 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator: . launcher
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
29 Apr '10
Author: chatellier
Date: 2010-04-29 16:36:24 +0000 (Thu, 29 Apr 2010)
New Revision: 3036
Log:
Add documentation for previous commit (SimulationParameter cache)
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2010-04-29 16:19:05 UTC (rev 3035)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2010-04-29 16:36:24 UTC (rev 3036)
@@ -18,7 +18,6 @@
package fr.ifremer.isisfish.simulator;
-import java.io.File;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -36,12 +35,25 @@
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
/**
- * TODO add comment here.
+ * Contains all parameters for one simulation.
+ *
+ * {@link SimulationParameter} must now be loaded from a {@link Properties}
+ * object.
+ * {@link #toProperties()} method, now return a new {@link Properties} object
+ * filled with :
+ * <ul>
+ * <li>non modified original properties
+ * <li>new properties if some objects has been instantiated by getters().
+ * </ul>
*
+ * Created: 10 janv. 2006 17:03:37
+ *
+ * @author poussin
* @author chatellier
+ *
* @version $Revision$
- *
- * Last update : $Date$
+ *
+ * Last update: $Date$
* By : $Author$
*/
public interface SimulationParameter {
@@ -52,23 +64,23 @@
*
* @return la liste d'erreur
*/
- public abstract List<String> check();
+ public List<String> check();
/**
* Get isis fish version for the simulation.
*
- * Defaut value to : {@link IsisConfig#getVersion()}.
+ * Default value to : {@link IsisConfig#getVersion()}.
*
* @return the isisFishVersion.
*/
- public abstract String getIsisFishVersion();
+ public String getIsisFishVersion();
/**
* Set isis fish Version.
*
* @param isisFishVersion The isisFishVersion to set.
*/
- public abstract void setIsisFishVersion(String isisFishVersion);
+ public void setIsisFishVersion(String isisFishVersion);
/**
* Get description property.
@@ -87,7 +99,7 @@
public abstract void setDescription(String description);
/**
- * Load region conresponding to {@link #regionName}.
+ * Load region corresponding to {@link #getRegionName()}.
*
* @return the region
*/
@@ -552,7 +564,7 @@
* </ul>
*
* @return L'objet Properties representant les parametres
- * @see #fromProperties(File, Properties)
+ * @see #fromProperties(Properties)
*/
public abstract Properties toProperties();
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java 2010-04-29 16:19:05 UTC (rev 3035)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java 2010-04-29 16:36:24 UTC (rev 3036)
@@ -45,8 +45,17 @@
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
/**
- * TODO add comment here.
+ * SimulationParameter soft reference implementation.
*
+ * Store simulation file on disk, and a soft reference of delegate real
+ * SimulationParameter.
+ *
+ * If soft reference has been cleared by garbage collector, reload it from
+ * disk.
+ *
+ * Warning, use only this class for parameter reading. Using setters cause
+ * parameters to be written on disk. Use with caution.
+ *
* @author chatellier
* @version $Revision$
*
@@ -54,8 +63,11 @@
* By : $Author$
*/
public class SimulationParameterCache implements SimulationParameter {
-
+
+ /** Parameter file (disk storage). */
protected File paramFile;
+
+ /** Parameter memory reference. */
protected SoftReference<SimulationParameter> ref;
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2010-04-29 16:19:05 UTC (rev 3035)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2010-04-29 16:36:24 UTC (rev 3036)
@@ -20,7 +20,6 @@
import static org.nuiton.i18n.I18n._;
-import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@@ -66,25 +65,12 @@
import fr.ifremer.isisfish.util.ConverterUtil;
/**
- * Contains all parameters for one simulation.
- *
- * {@link SimulationParameter} must now be loaded from a {@link Properties}
- * object.
- * {@link #toProperties()} method, now return a new {@link Properties} object
- * filled with :
- * <ul>
- * <li>non modified original properties
- * <li>new properties if some objects has been instantiated by getters().
- * </ul>
+ * Real {@link SimulationParameter} implementation.
*
- * Created: 10 janv. 2006 17:03:37
- *
- * @author poussin
* @author chatellier
- *
* @version $Revision$
- *
- * Last update: $Date$
+ *
+ * Last update : $Date$
* By : $Author$
*/
public class SimulationParameterImpl implements SimulationParameter {
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-29 16:19:05 UTC (rev 3035)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-29 16:36:24 UTC (rev 3036)
@@ -102,6 +102,8 @@
*/
public SimulationItem(SimulationControl control, SimulationParameter param) {
this.control = control;
+
+ // use soft reference to improve minimum memory usage
this.parameter = new SimulationParameterCache(param);
}
1
0
r3035 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
29 Apr '10
Author: chatellier
Date: 2010-04-29 16:19:05 +0000 (Thu, 29 Apr 2010)
New Revision: 3035
Log:
Add simulation cache to not keep all simulation huge prescript in memory.
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2010-04-29 16:14:25 UTC (rev 3034)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2010-04-29 16:19:05 UTC (rev 3035)
@@ -1,211 +1,58 @@
/* *##%
- * Copyright (C) 2006 - 2010 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. ##%
- */
+ * Copyright (C) 2010 Code Lutin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 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.simulator;
-import static org.nuiton.i18n.I18n._;
-
import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import org.apache.commons.beanutils.ConvertUtilsBean;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.nuiton.math.matrix.MatrixFactory;
-import org.nuiton.math.matrix.MatrixHelper;
import org.nuiton.math.matrix.MatrixND;
-import org.nuiton.topia.TopiaContext;
import org.nuiton.topia.TopiaException;
-import org.nuiton.topia.persistence.TopiaEntity;
-import org.nuiton.util.SortedProperties;
-import org.nuiton.util.StringUtil;
import fr.ifremer.isisfish.IsisConfig;
-import fr.ifremer.isisfish.IsisFishDAOHelper;
-import fr.ifremer.isisfish.IsisFishException;
-import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.RuleStorage;
-import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
-import fr.ifremer.isisfish.datastore.SensitivityStorage;
import fr.ifremer.isisfish.entities.Population;
-import fr.ifremer.isisfish.entities.PopulationDAO;
import fr.ifremer.isisfish.entities.Strategy;
-import fr.ifremer.isisfish.entities.StrategyDAO;
-import fr.ifremer.isisfish.export.ExportHelper;
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.rule.Rule;
-import fr.ifremer.isisfish.rule.RuleHelper;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
-import fr.ifremer.isisfish.util.ConverterUtil;
/**
- * Contains all parameters for one simulation.
- *
- * {@link SimulationParameter} must now be loaded from a {@link Properties}
- * object.
- * {@link #toProperties()} method, now return a new {@link Properties} object
- * filled with :
- * <ul>
- * <li>non modified original properties
- * <li>new properties if some objects has been instantiated by getters().
- * </ul>
+ * TODO add comment here.
*
- * Created: 10 janv. 2006 17:03:37
- *
- * @author poussin
* @author chatellier
- *
* @version $Revision$
- *
- * Last update: $Date$
+ *
+ * Last update : $Date$
* By : $Author$
*/
-public class SimulationParameter {
+public interface SimulationParameter {
- /** Logger for this class. */
- private static Log log = LogFactory.getLog(SimulationParameter.class);
-
- /** Remember last read properties. */
- protected Properties propertiesParameters;
-
/**
- * Isis-fish version that permit to do the simulation.
- * Must be set just before simulation by simulator.
- */
- protected String isisFishVersion;
-
- /** Description de la simulation. */
- protected String description;
-
- /** Nom de la region sur lequel on simule. */
- protected String regionName;
-
- /** Nombre d'année sur lequel on souhaite simuler. */
- protected Integer numberOfYear;
-
- /** Le nom de l'objet script a utiliser pour faire la simulation. */
- protected String simulatorName;
-
- /** Utilisation ou non des optimisations. */
- protected Boolean useOptimization;
-
- /** Utilisation ou non des statistiques. */
- protected Boolean useStatistic;
-
- /** La liste des strategies a utiliser pour la simulation. */
- protected List<Strategy> strategies;
-
- /** La liste des populations a utiliser pour la simulation. */
- protected List<Population> populations;
-
- /** Les effectifs initiaux des différentes population. */
- protected Map<Population, MatrixND> numbers;
-
- /** La liste des regles de gestions a utiliser pour la simulation. */
- protected List<Rule> rules;
-
- /** La liste des regles potentiellement ajoutée par les plans d'analyse. */
- protected List<String> extraRules;
-
- /** La liste des plans a utiliser pour la simulation. */
- protected List<AnalysePlan> analysePlans;
-
- /** Ma liste des exports automatique a faire en fin de simulation. */
- protected List<String> exportNames;
-
- /** Utilisation du script de pre simulation. */
- protected Boolean usePreScript;
-
- /** Le script de pre simulation a utiliser. */
- protected String preScript;
-
- /** Utilisation du plan d'analyse. */
- protected Boolean useAnalysePlan;
-
- /**
- * Le numero de sequence de la liste des plans d'analyse. Le premier
- * élement du plan doit etre 0. Si la simulation ne fait pas partie d'un
- * plan la valeur est -1. */
- protected Integer analysePlanNumber;
-
- /** Export utilisés pour les analyses de sensibilités. */
- protected List<SensitivityExport> sensitivityExports;
-
- /**
- * Nombre de simulation constituant l'analyse de sensibilité.
- *
- * FIXME ce parametre ne devrait pas ce trouver à cet endroit.
- * Ce n'est pas un parametres, mais une infos de simulation.
- * Cela permet de savoir combien de simulation il y a au total
- * pour savoir quand elle sont terminées.
- */
- protected Integer numberOfSensitivitySimulation;
-
- /** Export utilisés pour les analyses de sensibilités. */
- protected SensitivityCalculator sensitivityCalculator;
-
- /** La liste des resultats qui nous interesse. */
- protected Collection<String> resultEnabled;
-
- /** Autre parametre defini par l'utilisateur. */
- protected Map<String, String> tagValue;
-
- /**
- * Si vrai seul les exports automatiques ne sont souhaiter, la simulation
- * pourrait etre supprimée a la fin.
- */
- protected Boolean onlyExport;
-
- /** Le niveau de log du simulateur à utiliser pendant la simulation. Par defaut info. */
- protected String simulLogLevel = "info";
- /** Le niveau de log des scripts à utiliser pendant la simulation. Par defaut info. */
- protected String scriptLogLevel = "info";
- /** Le niveau de log des librairies à utiliser pendant la simulation. Par defaut error. */
- protected String libLogLevel = "error";
-
- /** La region corespondant au parametre {@link #regionName}. */
- protected transient RegionStorage region;
-
- /**
* Permet de verifier que tous les parametres sont bon. Si ce n'est pas le
* cas la liste retournée contient la liste des messages d'erreur.
*
* @return la liste d'erreur
*/
- public List<String> check() {
- List<String> result = new ArrayList<String>();
- // TODO faire la verif et pour chaque erreur mettre un message
- // dans la liste result (par exemple si pas d'effectif
- // pour une pop
- return result;
- }
+ public abstract List<String> check();
/**
* Get isis fish version for the simulation.
@@ -214,27 +61,14 @@
*
* @return the isisFishVersion.
*/
- public String getIsisFishVersion() {
- // if not already set
- if (isisFishVersion == null) {
- if (propertiesParameters != null) {
- isisFishVersion = propertiesParameters.getProperty("isisFishVersion", "");
- } else {
- // default value
- isisFishVersion = IsisConfig.getVersion();
- }
- }
- return isisFishVersion;
- }
+ public abstract String getIsisFishVersion();
/**
* Set isis fish Version.
*
* @param isisFishVersion The isisFishVersion to set.
*/
- public void setIsisFishVersion(String isisFishVersion) {
- this.isisFishVersion = isisFishVersion;
- }
+ public abstract void setIsisFishVersion(String isisFishVersion);
/**
* Get description property.
@@ -243,285 +77,31 @@
*
* @return Description property.
*/
- public String getDescription() {
+ public abstract String getDescription();
- if (description == null) {
- if (propertiesParameters != null) {
- description = propertiesParameters.getProperty("description", "");
- } else {
- // default value
- description = "";
- }
- }
- return this.description;
- }
-
/**
* Set simulation description.
*
* @param description the description to set.
*/
- public void setDescription(String description) {
- this.description = description;
- }
+ public abstract void setDescription(String description);
/**
* Load region conresponding to {@link #regionName}.
*
* @return the region
*/
- public RegionStorage getRegion() {
+ public abstract RegionStorage getRegion();
- if (region == null || !region.getName().equals(getRegionName())) {
- // bien faire attention ici que la bonne region est ouverte
- // - isis-database-3 dans le cas d'une region normale
- // - simulation dans le cas d'une simulation
- region = RegionStorage.getRegion(getRegionName());
- } else {
- if (log.isDebugEnabled()) {
- log.debug(_("Region %s already inited", getRegionName()));
- }
- }
- return this.region;
- }
+ public abstract MatrixND getNumberOf(Population pop);
- public MatrixND getNumberOf(Population pop) {
- if (numbers == null) {
- numbers = new LinkedHashMap<Population, MatrixND>();
- }
- MatrixND result = numbers.get(pop);
- if (result == null) {
- List groups = pop.getPopulationGroup();
- List zones = pop.getPopulationZone();
-
- if (groups.size() == 0) {
- groups.add("No group");
- }
- if (zones.size() == 0) {
- zones.add("No zone");
- }
- List[] semantics = new List[] { groups, zones };
- result = MatrixFactory.getInstance().create(semantics);
-
- numbers.put(pop, result);
- }
- return result;
- }
-
/**
- * Permet de mettre les parametres de la regle sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param ruleIndex l'index de la rule
- * @param rule La regle dont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres de la
- * regle
- */
- protected Properties ruleParametertoProperties(int ruleIndex, Rule rule) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- for (String paramName : RuleStorage.getParameterNames(rule).keySet()) {
- String paramValueString;
- try {
- Object value = RuleStorage.getParameterValue(rule, paramName);
- paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("rule." + ruleIndex + ".parameter." + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: " + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres de l'export sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param sensitivityExportIndex l'index de l'export
- * @param sensitivityExport l'export dont on souhaite mettre les parametres dans l'objet
- * Properties retourné
- * @return L'objet Properties contenant les valeurs des parametres de l'export
- */
- protected Properties sensitivityExportParametertoProperties(
- int sensitivityExportIndex, SensitivityExport sensitivityExport) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : SensitivityExportStorage.getParameterNames(sensitivityExport).keySet()) {
- try {
- Object value = SensitivityExportStorage.getParameterValue(
- sensitivityExport, paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("sensitivityexport."
- + sensitivityExportIndex + ".parameter."
- + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres du calculateur sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param sensitivityIndex l'index du calculateur de sensitivity
- * @param calculator Le calculateurdont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres du calculateur de sensibilité
- */
- protected Properties sensitivityCalculatorParametertoProperties(
- int sensitivityIndex, SensitivityCalculator calculator) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : SensitivityStorage.getParameterNames(calculator).keySet()) {
- try {
- Object value = SensitivityStorage.getParameterValue(calculator,
- paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("sensitivity." + sensitivityIndex + ".parameter." + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres du plan sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param planIndex l'index du plan
- * @param plan Le plan dont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres du plan
- */
- protected Properties planParametertoProperties(int planIndex,
- AnalysePlan plan) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : AnalysePlanStorage.getParameterNames(plan).keySet()) {
- try {
- Object value = AnalysePlanStorage.getParameterValue(plan,paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("plan." + planIndex + ".parameter."
- + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parametre value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Recupere dans prop les valeurs des champs specifique au plan et met a
- * jour les champs du plan.
- *
- * @param planIndex l'index du plan
- * @param plan le plan dont les parametres doivent etre lu depuis les
- * proprietes
- * @param props les proprietes contenant les parametre du plan
- */
- protected void populateAnalysePlan(int planIndex, AnalysePlan plan,
- Properties props) {
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- String planName = AnalysePlanStorage.getName(plan);
- String paramTag = "plan." + planIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : AnalysePlanStorage.getParameterNames(plan).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = props.getProperty(paramTag + propName);
- Object value = beanUtils.convert(valueString, type);
- try {
- AnalysePlanStorage.setParameterValue(plan, propName, value);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't reload field " + propName + " for plan "
- + planName, eee);
- }
- }
- }
- }
-
- /**
- * Recupere dans prop les valeurs des champs specifique au calculateur de
- * sensibilité et met a jour les champs du calculateur.
- *
- * @param calculatorIndex l'index du calculateur
- * @param calculator le calculateur dont les parametres doivent etre lu depuis lesproprietes
- * @param props les proprietes contenant les parametre du calculateur
- */
- protected void populateSensitivityCalculator(int calculatorIndex,
- SensitivityCalculator calculator, Properties props) {
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- String calculatorName = SensitivityStorage.getName(calculator);
- String paramTag = "sensitivity." + calculatorIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : SensitivityStorage.getParameterNames(calculator).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = props.getProperty(paramTag + propName);
- Object value = beanUtils.convert(valueString, type);
- try {
- SensitivityStorage.setParameterValue(calculator, propName, value);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't reload field " + propName
- + " for sensitivity calculator " + calculatorName,
- eee);
- }
- }
- }
- }
-
- /**
* Get extra rules list.
*
* @return Returns the extraRules.
*/
- public List<String> getExtraRules() {
+ public abstract List<String> getExtraRules();
- if (extraRules == null) {
- // no properties in config ?
- extraRules = new ArrayList<String>();
- }
- return extraRules;
- }
-
/**
* Add extra rules.
*
@@ -530,81 +110,19 @@
*
* @param extraRules extra rules to add
*/
- public void addExtraRules(String... extraRules) {
- getExtraRules().addAll(Arrays.asList(extraRules));
- }
+ public abstract void addExtraRules(String... extraRules);
/**
* Get instantiated population list.
*
* @return Returns the populations.
*/
- public List<Population> getPopulations() {
- if (populations == null) {
- populations = new ArrayList<Population>();
+ public abstract List<Population> getPopulations();
- if (propertiesParameters != null) {
-
- try {
- // On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
- // Resoud les lazy exceptions des parametres des regles
- boolean mustClose = false;
- TopiaContext tx = SimulationContext.get().getDB();
-
- if (tx == null) {
- // not in simulation, create transaction
- tx = getRegion().getStorage().beginTransaction();
- mustClose = true;
- }
-
- PopulationDAO populationDAO = IsisFishDAOHelper
- .getPopulationDAO(tx);
- String[] populationList = propertiesParameters.getProperty(
- "populations", "").split(",");
- for (String name : populationList) {
- if (name != null && !"".equals(name)) {
- try {
- Population population = populationDAO.findByName(name);
- populations.add(population);
-
- String numberAsString = propertiesParameters.getProperty("population." + name + ".number");
- List number = MatrixHelper.convertStringToList(numberAsString);
- MatrixND mat = getNumberOf(population);
- mat.fromList(number);
- } catch (TopiaException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't find population: " + name, eee);
- }
- }
- }
- }
-
- // si la transaction a été ouverte (pas dans une simulation)
- // on la referme
- if (mustClose) {
- tx.closeContext();
- }
- } catch (TopiaException eee1) {
- if (log.isWarnEnabled()) {
- log.warn("Can't get PopulationDAO", eee1);
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No last read properties, skip population reloading");
- }
- }
- }
- return populations;
- }
-
/**
* @param populations The populations to set.
*/
- public void setPopulations(List<Population> populations) {
- this.populations = populations;
- }
+ public abstract void setPopulations(List<Population> populations);
/**
* Get instantiated strategies list.
@@ -613,80 +131,21 @@
*
* @return Returns the strategies.
*/
- public List<Strategy> getStrategies() {
+ public abstract List<Strategy> getStrategies();
- if (strategies == null) {
-
- strategies = new ArrayList<Strategy>();
-
- if (propertiesParameters != null) {
- strategies = new ArrayList<Strategy>();
-
- try {
-
- // On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
- // Resoud les lazy exceptions des parametres des regles
- boolean mustClose = false;
- TopiaContext tx = SimulationContext.get().getDB();
-
- if (tx == null) {
- // not in simulation, create transaction
- tx = getRegion().getStorage().beginTransaction();
- mustClose = true;
- }
-
- StrategyDAO strategyDAO = IsisFishDAOHelper.getStrategyDAO(tx);
- String[] strategyList = propertiesParameters.getProperty("strategies", "").split(",");
- for (String name : strategyList) {
- if (name != null && !"".equals(name)) {
- try {
- Strategy str = strategyDAO.findByName(name);
- strategies.add(str);
- } catch (TopiaException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't find strategy: " + name, eee);
- }
- }
- }
- }
-
- // si la transaction a été ouverte (pas dans une simulation)
- // on la referme
- if (mustClose) {
- tx.closeContext();
- }
- } catch (TopiaException eee1) {
- if (log.isWarnEnabled()) {
- log.warn("Can't get StrategyDAO", eee1);
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No last read properties, skip strategies reloading");
- }
- }
- }
- return strategies;
- }
-
/**
* Set strategies list.
*
* @param strategies strategies list to set
*/
- public void setStrategies(List<Strategy> strategies) {
- this.strategies = strategies;
- }
+ public abstract void setStrategies(List<Strategy> strategies);
/**
* Add new analyse plan.
*
* @param plan analyse plan to add
*/
- public void addAnalysePlan(AnalysePlan plan) {
- getAnalysePlans().add(plan);
- }
+ public abstract void addAnalysePlan(AnalysePlan plan);
/**
* Remove a plan.
@@ -694,9 +153,7 @@
* @param plan
* @return {@code true} if this list contained the specified element
*/
- public boolean removeAnalysePlan(AnalysePlan plan) {
- return getAnalysePlans().remove(plan);
- }
+ public abstract boolean removeAnalysePlan(AnalysePlan plan);
/**
* Get instantiated analyse plan list.
@@ -705,81 +162,32 @@
*
* @return Returns the plans.
*/
- public List<AnalysePlan> getAnalysePlans() {
- if (analysePlans == null) {
+ public abstract List<AnalysePlan> getAnalysePlans();
- analysePlans = new ArrayList<AnalysePlan>();
-
- if (propertiesParameters != null) {
- // analyse plan
- String[] planList = propertiesParameters.getProperty("plans",
- "").split(",");
- int planIndex = 0;
- for (String name : planList) {
- if (name != null && !"".equals(name)) {
- try {
- AnalysePlan plan = AnalysePlanStorage
- .getAnalysePlan(name)
- .getNewAnalysePlanInstance();
- populateAnalysePlan(planIndex++, plan, propertiesParameters);
- analysePlans.add(plan);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't find plan: " + name, eee);
- }
- }
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No last read properties, skip plans reloading");
- }
- }
- }
- return this.analysePlans;
- }
-
/**
* Set plans list.
*
* @param plans plans to set
*/
- public void setAnalysePlans(List<AnalysePlan> plans) {
- this.analysePlans = plans;
- }
+ public abstract void setAnalysePlans(List<AnalysePlan> plans);
/**
* Retrun {@code true} if simulation is composed of independant plan only.
*
* @return {@code true} if all {@link AnalysePlan} are {@link AnalysePlanIndependent}
*/
- public boolean isIndependentPlan() {
- boolean result = true;
- for (AnalysePlan plan : getAnalysePlans()) {
- if (!(plan instanceof AnalysePlanIndependent)) {
- result = false;
- break;
- }
- }
- return result;
- }
+ public abstract boolean isIndependentPlan();
/**
* Clear plan list.
*/
- public void clearPlans() {
- if (analysePlans != null) {
- analysePlans.clear();
- }
- }
+ public abstract void clearPlans();
/**
* Add new rule to rules list.
* @param rule rule to add
*/
- public void addRule(Rule rule) {
- getRules().add(rule);
- }
+ public abstract void addRule(Rule rule);
/**
* Remove a rule.
@@ -787,86 +195,26 @@
* @param rule rule to remove
* @return {@code true} if this list contained the specified element
*/
- public boolean removeRule(Rule rule) {
- return getRules().remove(rule);
- }
+ public abstract boolean removeRule(Rule rule);
/**
* Get parameters rules list.
*
* @return the rules
*/
- public List<Rule> getRules() {
- if (rules == null) {
- rules = new ArrayList<Rule>();
+ public abstract List<Rule> getRules();
- if (propertiesParameters != null) {
- try {
- // On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
- // Resoud les lazy exceptions des parametres des regles
- boolean mustClose = false;
- TopiaContext tx = SimulationContext.get().getDB();
-
- if (tx == null) {
- // not in simulation, create transaction
- tx = getRegion().getStorage().beginTransaction();
- mustClose = true;
- }
-
- // rules
- String[] ruleList = propertiesParameters.getProperty("rules", "").split(",");
- int ruleIndex = 0;
- for (String name : ruleList) {
- if (name != null && !"".equals(name)) {
- try {
- Rule rule = RuleStorage.getRule(name).getNewRuleInstance();
- RuleHelper.populateRule(ruleIndex++, tx, rule, propertiesParameters);
- rules.add(rule);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't find rule: " + name, eee);
- }
- }
- }
- }
-
- // si la transaction a été ouverte (pas dans une simulation)
- // on la referme
- if (mustClose) {
- tx.closeContext();
- }
- } catch (TopiaException eee1) {
- if (log.isWarnEnabled()) {
- log.warn("Can't get TopiaContext", eee1);
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No last read properties, skip rule reloading");
- }
- }
- }
- return rules;
- }
-
/**
* Set simulation rules.
*
* @param rules rules to set
*/
- public void setRules(List<Rule> rules) {
- this.rules = rules;
- }
+ public abstract void setRules(List<Rule> rules);
/**
* Clear rule list.
*/
- public void clearRules() {
- if (rules != null) {
- rules.clear();
- }
- }
+ public abstract void clearRules();
/**
* Return if optimization sould be used.
@@ -875,26 +223,14 @@
*
* @return use optimization
*/
- public boolean getUseOptimization() {
+ public abstract boolean getUseOptimization();
- if (useOptimization == null) {
- if (propertiesParameters != null) {
- useOptimization = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "true"));
- } else {
- useOptimization = Boolean.TRUE;
- }
- }
- return useOptimization.booleanValue();
- }
-
/**
* Change use optimization parameter.
*
* @param useOptimization use optimization to set
*/
- public void setUseOptimization(boolean useOptimization) {
- this.useOptimization = useOptimization;
- }
+ public abstract void setUseOptimization(boolean useOptimization);
/**
* Return if statistic sould be used.
@@ -903,57 +239,28 @@
*
* @return use statistic
*/
- public boolean getUseStatistic() {
+ public abstract boolean getUseStatistic();
- if (useStatistic == null) {
- if (propertiesParameters != null) {
- useStatistic = Boolean.valueOf(propertiesParameters.getProperty("useStatistic", "false"));
- } else {
- useStatistic = Boolean.FALSE;
- }
- }
- return this.useStatistic;
- }
-
/**
* Change use statistic property.
*
* @param useStatistic use statistic to set
*/
- public void setUseStatistic(boolean useStatistic) {
- this.useStatistic = useStatistic;
- }
+ public abstract void setUseStatistic(boolean useStatistic);
/**
* Get export names list.
*
* @return export names list
*/
- public List<String> getExportNames() {
- if (exportNames == null) {
- exportNames = new ArrayList<String>();
+ public abstract List<String> getExportNames();
- if (propertiesParameters != null) {
- // exports
- String[] exportList = propertiesParameters.getProperty("exports", "").split(",");
- for (String name : exportList) {
- if (name != null && !"".equals(name)) {
- exportNames.add(name);
- }
- }
- }
- }
- return this.exportNames;
- }
-
/**
* Set export names list.
*
* @param exportNames export names list to set
*/
- public void setExportNames(List<String> exportNames) {
- this.exportNames = exportNames;
- }
+ public abstract void setExportNames(List<String> exportNames);
/**
* Get number of sensitivity simulation.
@@ -962,30 +269,15 @@
*
* @return the numberOfSensitivitySimulation
*/
- public int getNumberOfSensitivitySimulation() {
+ public abstract int getNumberOfSensitivitySimulation();
- if (numberOfSensitivitySimulation == null) {
-
- if (propertiesParameters != null) {
- numberOfSensitivitySimulation = Integer.valueOf(propertiesParameters.getProperty(
- "numberOfSensitivitySimulation", "-1"));
- } else {
- numberOfSensitivitySimulation = Integer.valueOf(-1);
- }
- }
-
- return numberOfSensitivitySimulation.intValue();
- }
-
/**
* Set number of sensitivity simulation.
*
* @param numberOfSensitivitySimulation number of sensitivity simulation to set
*/
- public void setNumberOfSensitivitySimulation(
- int numberOfSensitivitySimulation) {
- this.numberOfSensitivitySimulation = numberOfSensitivitySimulation;
- }
+ public abstract void setNumberOfSensitivitySimulation(
+ int numberOfSensitivitySimulation);
/**
* Get instanciated sensitivity calculator.
@@ -994,38 +286,13 @@
*
* @return the sensitivityCalculator
*/
- public SensitivityCalculator getSensitivityCalculator() {
+ public abstract SensitivityCalculator getSensitivityCalculator();
- if (sensitivityCalculator == null) {
- if (propertiesParameters != null) {
- String calculatorName = propertiesParameters
- .getProperty("sensitivitycalculator");
- if (!StringUtils.isEmpty(calculatorName)) {
- try {
- SensitivityStorage sensitivityStorage = SensitivityStorage.getSensitivity(calculatorName);
- sensitivityCalculator = sensitivityStorage.getNewSensitivityInstance();
- // 0 = only single sensitivity
- populateSensitivityCalculator(0, sensitivityCalculator, propertiesParameters);
- } catch (IsisFishException eee) {
- sensitivityCalculator = null;
- if (log.isWarnEnabled()) {
- log.warn("Can't find sensitivity: " + sensitivityCalculator, eee);
- }
- }
- }
- }
- }
-
- return sensitivityCalculator;
- }
-
/**
* @param sensitivityCalculator the sensitivityCalculator to set
*/
- public void setSensitivityCalculator(
- SensitivityCalculator sensitivityCalculator) {
- this.sensitivityCalculator = sensitivityCalculator;
- }
+ public abstract void setSensitivityCalculator(
+ SensitivityCalculator sensitivityCalculator);
/**
* Return loaded sensitivity export.
@@ -1034,154 +301,55 @@
*
* @return the sensitivityExportNames
*/
- public List<SensitivityExport> getSensitivityExport() {
- if (sensitivityExports == null) {
- sensitivityExports = new ArrayList<SensitivityExport>();
+ public abstract List<SensitivityExport> getSensitivityExport();
- if (propertiesParameters != null) {
- try {
- // On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
- // Resoud les lazy exceptions des parametres des regles
- boolean mustClose = false;
- TopiaContext tx = SimulationContext.get().getDbResult();
-
- if (tx == null) {
- // not in simulation, create transaction
- tx = getRegion().getStorage().beginTransaction();
- mustClose = true;
- }
-
- // sensitivity export
- String[] sensitivityExportList = propertiesParameters
- .getProperty("sensitivityexports", "").split(",");
- int sensitivityExportIndex = 0;
- for (String name : sensitivityExportList) {
- try {
- if (!StringUtils.isEmpty(name)) {
- SensitivityExport sensitivityExport = SensitivityExportStorage
- .getSensitivityExport(name)
- .getNewSensitivityExportInstance();
- ExportHelper.populateSensitivityExport(
- sensitivityExportIndex++, tx,
- sensitivityExport,
- propertiesParameters);
- sensitivityExports.add(sensitivityExport);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't find SensitivityExport: " + name, eee);
- }
- }
- }
-
- // si la transaction a été ouverte (pas dans une simulation)
- // on la referme
- if (mustClose) {
- tx.closeContext();
- }
- } catch (TopiaException eee1) {
- if (log.isWarnEnabled()) {
- log.warn("Can't get TopiaContext", eee1);
- }
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("No last read properties, skip sensitivity exports reloading");
- }
- }
- }
- return sensitivityExports;
- }
-
/**
* @param sensitivityExport the sensitivityExportNames to set
*/
- public void setSensitivityExport(List<SensitivityExport> sensitivityExport) {
- this.sensitivityExports = sensitivityExport;
- }
+ public abstract void setSensitivityExport(
+ List<SensitivityExport> sensitivityExport);
/**
* Get use analyse plans property.
*
* @return use analyse plan.
*/
- public boolean getUseAnalysePlan() {
+ public abstract boolean getUseAnalysePlan();
- if (useAnalysePlan == null) {
-
- if (propertiesParameters != null) {
- useAnalysePlan = Boolean.valueOf(propertiesParameters.getProperty("useAnalysePlan", "false"));
- } else {
- useAnalysePlan = Boolean.FALSE;
- }
- }
- return this.useAnalysePlan;
- }
-
/**
* Set use analyse plans property.
*
* @param useAnalysePlan use analyse plan to set
*/
- public void setUseAnalysePlan(boolean useAnalysePlan) {
- this.useAnalysePlan = useAnalysePlan;
- }
+ public abstract void setUseAnalysePlan(boolean useAnalysePlan);
/**
* Get simulation number in analyse plan.
*
* @return simulation number in analyse plan
*/
- public int getAnalysePlanNumber() {
+ public abstract int getAnalysePlanNumber();
- if (analysePlanNumber == null) {
-
- if (propertiesParameters != null) {
- analysePlanNumber = Integer.valueOf(propertiesParameters.getProperty("analysePlanNumber", "-1"));
- } else {
- analysePlanNumber = Integer.valueOf(-1);
- }
- }
-
- return this.analysePlanNumber.intValue();
- }
-
/**
* Set simulation number in analyse plan.
*
* @param analysePlanNumber analyse plan number to set
*/
- public void setAnalysePlanNumber(int analysePlanNumber) {
- this.analysePlanNumber = analysePlanNumber;
- }
+ public abstract void setAnalysePlanNumber(int analysePlanNumber);
/**
* Get number of year to run to simulate.
*
* @return number of year
*/
- public int getNumberOfYear() {
+ public abstract int getNumberOfYear();
- if (numberOfYear == null) {
-
- if (propertiesParameters != null) {
- numberOfYear = Integer.valueOf(propertiesParameters.getProperty("numberOfYear", "1"));
- } else {
- numberOfYear = Integer.valueOf(1);
- }
- }
- return numberOfYear.intValue();
- }
-
/**
* Set number of year to run to simulate.
*
* @param numberOfYear number of year to set
*/
- public void setNumberOfYear(int numberOfYear) {
- this.numberOfYear = numberOfYear;
- }
+ public abstract void setNumberOfYear(int numberOfYear);
/**
* Get use prescript.
@@ -1190,143 +358,70 @@
*
* @return Returns the usePreScript.
*/
- public boolean getUsePreScript() {
+ public abstract boolean getUsePreScript();
- if (usePreScript == null) {
-
- if (propertiesParameters != null) {
- usePreScript = Boolean.valueOf(propertiesParameters.getProperty("usePreScript", "false"));
- } else {
- usePreScript = Boolean.FALSE;
- }
- }
-
- return usePreScript.booleanValue();
- }
-
/**
* Set use prescript property
*
* @param usePreScript use preScript to set
*/
- public void setUsePreScript(boolean usePreScript) {
- this.usePreScript = usePreScript;
- }
+ public abstract void setUsePreScript(boolean usePreScript);
/**
* Get prescript content.
*
* @return preScript content
*/
- public String getPreScript() {
+ public abstract String getPreScript();
- if (preScript == null) {
-
- if (propertiesParameters != null) {
- preScript = propertiesParameters.getProperty("preScript", "");
- } else {
- preScript = "";
- }
- }
-
- return preScript;
- }
-
/**
* Set pre script content.
*
* @param preScript prescript content
*/
- public void setPreScript(String preScript) {
- this.preScript = preScript;
- }
+ public abstract void setPreScript(String preScript);
/**
* Get region name.
*
* @return region name
*/
- public String getRegionName() {
+ public abstract String getRegionName();
- if (regionName == null) {
- if (propertiesParameters != null) {
- regionName = propertiesParameters.getProperty("regionName", "");
- } else {
- // defaut value
- regionName = "";
- }
- }
-
- return regionName;
- }
-
/**
* Set region name.
*
* @param regionName region name to set
*/
- public void setRegionName(String regionName) {
- this.regionName = regionName;
- }
+ public abstract void setRegionName(String regionName);
/**
* Set simulator name.
*
* @return simulator name.
*/
- public String getSimulatorName() {
+ public abstract String getSimulatorName();
- if (simulatorName == null) {
- if (propertiesParameters != null) {
- simulatorName = propertiesParameters.getProperty(
- "simulatorName", "DefaultSimulator.java");
- } else {
- simulatorName = "DefaultSimulator.java";
- }
- }
- return simulatorName;
- }
-
/**
* Set simulator name.
*
* @param simulatorName simulator name to set
*/
- public void setSimulatorName(String simulatorName) {
- this.simulatorName = simulatorName;
- }
+ public abstract void setSimulatorName(String simulatorName);
/**
* Get enabled result names list.
*
* @return enabled result names list
*/
- public Collection<String> getResultEnabled() {
+ public abstract Collection<String> getResultEnabled();
- if (resultEnabled == null) {
-
- resultEnabled = new LinkedList<String>();
-
- if (propertiesParameters != null) {
- String[] resultList = propertiesParameters.getProperty("resultNames", "").split(",");
- for (String name : resultList) {
- if (name != null && !"".equals(name)) {
- resultEnabled.add(name);
- }
- }
- }
- }
- return resultEnabled;
- }
-
/**
* Set enabled result names list.
*
* @param resultEnabled enabled result names list
*/
- public void setResultEnabled(Collection<String> resultEnabled) {
- this.resultEnabled = resultEnabled;
- }
+ public abstract void setResultEnabled(Collection<String> resultEnabled);
/**
* Get tag values.
@@ -1335,33 +430,14 @@
*
* @return Returns the tagValue.
*/
- public Map<String, String> getTagValue() {
+ public abstract Map<String, String> getTagValue();
- if (tagValue == null) {
- tagValue = new LinkedHashMap<String, String>();
-
- if (propertiesParameters != null) {
- for (Object k : propertiesParameters.keySet()) {
- if (k.toString().startsWith("tagValue.")) {
- String key = k.toString().substring("tagValue.".length());
- String value = propertiesParameters.getProperty(k.toString());
- getTagValue().put(key, value);
- }
- }
- }
- }
-
- return tagValue;
- }
-
/**
* Set tag values.
*
* @param tagValue tagValues to set.
*/
- public void setTagValue(Map<String, String> tagValue) {
- this.tagValue = tagValue;
- }
+ public abstract void setTagValue(Map<String, String> tagValue);
/**
* Get simulator log level.
@@ -1370,32 +446,14 @@
*
* @return simualtor log level
*/
- public String getSimulLogLevel() {
+ public abstract String getSimulLogLevel();
- if (simulLogLevel == null) {
-
- if (propertiesParameters != null) {
- simulLogLevel = propertiesParameters.getProperty("simulLogLevel", "info");
- } else {
- simulLogLevel = "info";
- }
- }
-
- return simulLogLevel;
- }
-
/**
* Set simulator log level.
*
* @param logLevel simulator log level
*/
- public void setSimulLogLevel(String logLevel) {
- if (log.isDebugEnabled()) {
- log.debug(_("isisfish.params.changeLogLev", simulLogLevel,
- logLevel));
- }
- this.simulLogLevel = logLevel;
- }
+ public abstract void setSimulLogLevel(String logLevel);
/**
* Get script log level.
@@ -1404,32 +462,14 @@
*
* @return script log level
*/
- public String getScriptLogLevel() {
+ public abstract String getScriptLogLevel();
- if (scriptLogLevel == null) {
- if (propertiesParameters != null) {
- scriptLogLevel = propertiesParameters.getProperty(
- "scriptLogLevel", "info");
- } else {
- scriptLogLevel = "info";
- }
- }
-
- return scriptLogLevel;
- }
-
/**
* Set script log level.
*
* @param logLevel script log level
*/
- public void setScriptLogLevel(String logLevel) {
- if (log.isDebugEnabled()) {
- log.debug(_("isisfish.params.changeLogLev", scriptLogLevel,
- logLevel));
- }
- this.scriptLogLevel = logLevel;
- }
+ public abstract void setScriptLogLevel(String logLevel);
/**
* Get librairies log level.
@@ -1438,78 +478,38 @@
*
* @return librairies log level
*/
- public String getLibLogLevel() {
- if (libLogLevel == null) {
- if (propertiesParameters != null) {
- libLogLevel = propertiesParameters.getProperty("libLogLevel",
- "error");
- } else {
- libLogLevel = "info";
- }
- }
+ public abstract String getLibLogLevel();
- return libLogLevel;
- }
-
/**
* Set lib log level.
*
* @param logLevel
*/
- public void setLibLogLevel(String logLevel) {
- if (log.isDebugEnabled()) {
- log.debug(_("isisfish.params.changeLogLev", libLogLevel, logLevel));
- }
- this.libLogLevel = logLevel;
- }
+ public abstract void setLibLogLevel(String logLevel);
- public boolean isSimulErrorLevel() {
- return "error".equals(simulLogLevel);
- }
+ public abstract boolean isSimulErrorLevel();
- public boolean isSimulWarnLevel() {
- return "warn".equals(simulLogLevel);
- }
+ public abstract boolean isSimulWarnLevel();
- public boolean isSimulInfoLevel() {
- return "info".equals(simulLogLevel);
- }
+ public abstract boolean isSimulInfoLevel();
- public boolean isSimulDebugLevel() {
- return "debug".equals(simulLogLevel);
- }
+ public abstract boolean isSimulDebugLevel();
- public boolean isScriptErrorLevel() {
- return "error".equals(scriptLogLevel);
- }
+ public abstract boolean isScriptErrorLevel();
- public boolean isScriptWarnLevel() {
- return "warn".equals(scriptLogLevel);
- }
+ public abstract boolean isScriptWarnLevel();
- public boolean isScriptInfoLevel() {
- return "info".equals(scriptLogLevel);
- }
+ public abstract boolean isScriptInfoLevel();
- public boolean isScriptDebugLevel() {
- return "debug".equals(scriptLogLevel);
- }
+ public abstract boolean isScriptDebugLevel();
- public boolean isLibErrorLevel() {
- return "error".equals(libLogLevel);
- }
+ public abstract boolean isLibErrorLevel();
- public boolean isLibWarnLevel() {
- return "warn".equals(libLogLevel);
- }
+ public abstract boolean isLibWarnLevel();
- public boolean isLibInfoLevel() {
- return "info".equals(libLogLevel);
- }
+ public abstract boolean isLibInfoLevel();
- public boolean isLibDebugLevel() {
- return "debug".equals(libLogLevel);
- }
+ public abstract boolean isLibDebugLevel();
/**
* A copy instance of SimulationParameter.
@@ -1519,63 +519,8 @@
*
* @return a copy of this instance
*/
- public SimulationParameter copy() {
- SimulationParameter result = new SimulationParameter();
+ public abstract SimulationParameter copy();
- if (propertiesParameters != null) {
- result.propertiesParameters = new SortedProperties();
- // I think that iteration work better than parameters in contructor
- result.propertiesParameters.putAll(propertiesParameters);
- }
-
- // still needed to be copied, if there is no propertiesParameters
- result.isisFishVersion = getIsisFishVersion();
- result.description = getDescription();
- result.regionName = getRegionName();
- result.numberOfYear = getNumberOfYear();
- result.simulatorName = getSimulatorName();
- result.useOptimization = getUseOptimization();
- result.useStatistic = getUseStatistic();
- result.usePreScript = getUsePreScript();
- result.preScript = getPreScript();
- result.useAnalysePlan = getUseAnalysePlan();
- result.analysePlanNumber = getAnalysePlanNumber();
- if (exportNames != null) {
- result.exportNames = new LinkedList<String>(exportNames);
- }
- if (strategies != null) {
- result.strategies = new LinkedList<Strategy>(strategies);
- }
- if (populations != null) {
- result.populations = new LinkedList<Population>(populations);
- }
- if (rules != null) {
- result.rules = new LinkedList<Rule>(rules);
- }
- if (analysePlans != null) {
- result.analysePlans = new LinkedList<AnalysePlan>(analysePlans);
- }
- if (resultEnabled != null) {
- result.resultEnabled = new LinkedList<String>(resultEnabled);
- }
- if (numbers != null) {
- result.numbers = new HashMap<Population, MatrixND>(numbers);
- }
- if (tagValue != null) {
- result.tagValue = new HashMap<String, String>(tagValue);
- }
- result.simulLogLevel = getSimulLogLevel();
- result.scriptLogLevel = getScriptLogLevel();
- result.libLogLevel = getLibLogLevel();
- result.numberOfSensitivitySimulation = getNumberOfSensitivitySimulation();
- if (sensitivityExports != null) {
- result.sensitivityExports = new LinkedList<SensitivityExport>(sensitivityExports);
- }
- result.sensitivityCalculator = sensitivityCalculator;
-
- return result;
- }
-
/**
* Make a deep copy of current parameters.
*
@@ -1584,112 +529,15 @@
*
* @return new parameters instance
*/
- public SimulationParameter deepCopy() {
- Properties props = toProperties();
- SimulationParameter newInstance = new SimulationParameter();
- newInstance.fromProperties(props);
- return newInstance;
- }
+ public abstract SimulationParameter deepCopy();
/**
* The toString() method call getters.
*
* So make instances of rules/export/plans...
*/
- @Override
- public String toString() {
- StringBuffer result = new StringBuffer();
- result.append(
- _("isisfish.params.toString.simulation.done",
- getIsisFishVersion())).append('\n');
- result.append("--------------------\n");
- result.append(getDescription()).append('\n');
- result.append("--------------------\n");
+ public abstract String toString();
- if (getUseAnalysePlan()) {
- result.append(_("isisfish.params.toString.plan.number",
- getAnalysePlanNumber()));
- }
-
- RegionStorage region = getRegion();
- result.append(_("isisfish.params.toString.fishery", region.getName()));
- result.append(_("isisfish.params.toString.number.years",
- getNumberOfYear()));
-
- // startegies
- List<Strategy> strs = getStrategies();
- result.append(_("isisfish.params.toString.strategies"));
- String sep = "";
- for (Strategy str : strs) {
- result.append(sep).append(str.getName());
- sep = ",";
- }
- result.append("\n\n");
-
- // populations
- result.append(_("isisfish.params.toString.populations"));
- sep = "";
- for (Population pop : getPopulations()) {
- result.append(sep).append(pop.getName());
- sep = ",";
- }
- result.append("\n\n");
-
- // rules
- for (Rule rule : getRules()) {
- String name = RuleStorage.getName(rule);
- String param = "";
- try {
- param = RuleStorage.getParamAsString(rule);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert rule parameter to string for "
- + name, eee);
- }
- }
- result.append(_("isisfish.params.toString.rule", name));
- result.append('\n');
- result.append(param);
- result.append("\n");
-
- }
- result.append("\n\n");
-
- // analyse plans
- for (AnalysePlan plan : getAnalysePlans()) {
- String name = RuleStorage.getName(plan);
- String param = "";
- try {
- param = AnalysePlanStorage.getParamAsString(plan);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert plan parameter to string for "
- + name, eee);
- }
- }
- result.append(_("isisfish.params.toString.plan", name));
- result.append('\n');
- result.append(param);
- result.append('\n');
-
- }
- result.append('\n');
- result.append(_("isisfish.params.toString.script.presimulation"))
- .append(":\n");
- result.append(getPreScript());
- result.append('\n');
- result.append(_("isisfish.params.toString.simul.logger.level",
- simulLogLevel));
- result.append('\n');
- result.append(_("isisfish.params.toString.script.logger.level",
- scriptLogLevel));
- result.append('\n');
- result.append(_("isisfish.params.toString.lib.logger.level",
- libLogLevel));
- result.append('\n');
- return result.toString();
- }
-
/**
* Permet de convertir l'objet SimulationParameter en un objet Properties
* Cela permet de le stocker facilement sur le disque.
@@ -1706,195 +554,15 @@
* @return L'objet Properties representant les parametres
* @see #fromProperties(File, Properties)
*/
- public Properties toProperties() {
- Properties result = new SortedProperties();
+ public abstract Properties toProperties();
- result.setProperty("isisFishVersion", getIsisFishVersion());
- result.setProperty("description", getDescription());
- result.setProperty("regionName", getRegionName());
- result.setProperty("numberOfYear", String.valueOf(getNumberOfYear()));
- result.setProperty("simulatorName", getSimulatorName());
- result.setProperty("useOptimization", String.valueOf(getUseOptimization()));
- result.setProperty("useStatistic", String.valueOf(getUseStatistic()));
-
- // strategies
- if (strategies != null) {
- String strategyList = "";
- for (Strategy str : getStrategies()) {
- strategyList += str.getName() + ",";
- }
- result.setProperty("strategies", StringUtil.substring(strategyList, 0, -1));
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("strategies")) {
- result.setProperty("strategies", propertiesParameters.getProperty("strategies"));
- }
- }
-
- // populations
- if (populations != null) {
- String populationList = "";
- for (Population pop : getPopulations()) {
- populationList += pop.getName() + ",";
- MatrixND number = getNumberOf(pop);
- String numberAsString = String.valueOf(number.toList());
- result.setProperty("population." + pop.getName() + ".number", numberAsString);
- }
- result.setProperty("populations", StringUtil.substring(
- populationList, 0, -1));
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("populations")) {
- result.setProperty("populations", propertiesParameters.getProperty("populations"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("population.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
- }
- }
-
- // rules
- if (rules != null) {
- String ruleList = "";
- int ruleIndex = 0;
- for (Rule rule : getRules()) {
- ruleList += RuleStorage.getName(rule) + ",";
- Properties ruleProp = ruleParametertoProperties(ruleIndex++, rule);
- result.putAll(ruleProp);
- }
- result.setProperty("rules", ruleList);
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("rules")) {
- result.setProperty("rules", propertiesParameters
- .getProperty("rules"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("rule.")) {
- result.setProperty(key, propertiesParameters
- .getProperty(key));
- }
- }
- }
- }
-
- // anaylyse plans
- if (analysePlans != null) {
- String planList = "";
- int planIndex = 0;
- for (AnalysePlan plan : getAnalysePlans()) {
- planList += AnalysePlanStorage.getName(plan) + ",";
- Properties planProp = planParametertoProperties(planIndex++, plan);
- result.putAll(planProp);
- }
- result.setProperty("plans", planList);
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("plans")) {
- result.setProperty("plans", propertiesParameters
- .getProperty("plans"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("plan.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
- }
- }
-
- // export names
- String exportList = "";
- for (String export : getExportNames()) {
- exportList += export + ",";
-
- }
- result.setProperty("exports", exportList);
-
- // number of sensitivity simulation
- result.setProperty("numberOfSensitivitySimulation", String
- .valueOf(getNumberOfSensitivitySimulation()));
-
- // calculator name
- if (sensitivityCalculator != null) {
- String calculatorName = SensitivityStorage
- .getName(getSensitivityCalculator());
- result.setProperty("sensitivitycalculator", calculatorName);
-
- // calculator parameter
- Properties calculatorParams = sensitivityCalculatorParametertoProperties(
- 0, getSensitivityCalculator());
- result.putAll(calculatorParams);
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivitycalculator")) {
- result.setProperty("sensitivitycalculator",
- propertiesParameters.getProperty("sensitivitycalculator"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivity.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
- }
- }
-
- // sensitivity exports
- if (sensitivityExports != null) {
- String sensitivityExportList = "";
- int sensitivityExportIndex = 0;
- for (SensitivityExport sensitivityExport : getSensitivityExport()) {
- sensitivityExportList += SensitivityExportStorage
- .getName(sensitivityExport) + ",";
- Properties exportProp = sensitivityExportParametertoProperties(
- sensitivityExportIndex++, sensitivityExport);
- result.putAll(exportProp);
- }
- result.setProperty("sensitivityexports", sensitivityExportList);
- } else {
- if (propertiesParameters != null
- && propertiesParameters.containsKey("sensitivityexports")) {
- result.setProperty("sensitivityexports", propertiesParameters
- .getProperty("sensitivityexports"));
- for (String key : propertiesParameters.stringPropertyNames()) {
- if (key.startsWith("sensitivityexport.")) {
- result.setProperty(key, propertiesParameters.getProperty(key));
- }
- }
- }
- }
-
- result.setProperty("usePreScript", String.valueOf(getUsePreScript()));
- result.setProperty("preScript", getPreScript());
- result.setProperty("useAnalysePlan", String.valueOf(getUseAnalysePlan()));
- result.setProperty("analysePlanNumber", String.valueOf(getAnalysePlanNumber()));
-
- String resultList = "";
- for (String r : getResultEnabled()) {
- resultList += r + ",";
- }
- result.setProperty("resultNames", resultList);
-
- for (Map.Entry<String, String> e : getTagValue().entrySet()) {
- result.setProperty("tagValue." + e.getKey(), e.getValue());
- }
-
- result.setProperty("simulLogLevel", getSimulLogLevel());
- result.setProperty("scriptLogLevel", getScriptLogLevel());
- result.setProperty("libLogLevel", getLibLogLevel());
- return result;
- }
-
/**
* Load properties from file.
*
* @param props property to read
*/
- public void fromProperties(Properties props) {
+ public abstract void fromProperties(Properties props);
- // save properties (use full to read again parameter)
- // for exports, or rules....
- this.propertiesParameters = props;
-
- }
-
/**
* Reload parameters du to context change.
*
@@ -1904,59 +572,6 @@
*
* @throws TopiaException
*/
- public void reloadContextParameters() throws TopiaException {
+ public abstract void reloadContextParameters() throws TopiaException;
- // On verifie tout d'abord que l'on ai pas dans une simulation
- // si on y es, on utilise le context static non null du thread local
- // Resoud les lazy exceptions des parametres des regles
- boolean mustClose = false;
- TopiaContext tx = SimulationContext.get().getDB();
-
- if (tx == null) {
- // not in simulation, create transaction
- tx = getRegion().getStorage().beginTransaction();
- mustClose = true;
- }
-
- // reload rules
- if (log.isDebugEnabled()) {
- log.debug("Reloading rules");
- }
- for (Rule rule : getRules()) {
- try {
- for (Field field : rule.getClass().getFields()) {
- // le champ ne doit pas être privé
- if (Modifier.isPublic(field.getModifiers())) {
- // si le type est topia entity (ou sous classe)
- if (TopiaEntity.class.isAssignableFrom(field.getType())) {
- TopiaEntity entity = (TopiaEntity) field.get(rule);
- // il est possible que les parametres soient null
- // dans ce cas, il ne faut pas essayer de les recharger
- if (entity != null) {
- // reloading
- TopiaEntity newEntity = tx.findByTopiaId(entity
- .getTopiaId());
- field.set(rule, newEntity);
- }
- }
- }
- }
- } catch (IllegalArgumentException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't refresh rule field", e);
- }
- } catch (IllegalAccessException e) {
- if (log.isErrorEnabled()) {
- log.error("Can't access rule field", e);
- }
- }
- }
-
- // si la transaction a été ouverte (pas dans une simulation)
- // on la referme
- if (mustClose) {
- tx.commitTransaction();
- tx.closeContext();
- }
- }
-}
+}
\ No newline at end of file
1
0
r3034 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/actions main/java/fr/ifremer/isisfish/datastore main/java/fr/ifremer/isisfish/simulator main/java/fr/ifremer/isisfish/simulator/launcher main/java/fr/ifremer/isisfish/ui/simulator test/java/fr/ifremer/isisfish/simulator test/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
29 Apr '10
Author: chatellier
Date: 2010-04-29 16:14:25 +0000 (Thu, 29 Apr 2010)
New Revision: 3034
Log:
Add simulation cache to not keep all simulation huge prescript in memory.
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/SimulationAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitorTest.java
isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/SimulationAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/SimulationAction.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/actions/SimulationAction.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -27,9 +27,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.nuiton.util.ApplicationConfig.Action.Step;
import org.nuiton.util.FileUtil;
import org.nuiton.util.ZipUtil;
-import org.nuiton.util.ApplicationConfig.Action.Step;
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFish;
@@ -37,6 +37,7 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
import fr.ifremer.isisfish.simulator.launcher.InProcessSimulatorLauncher;
import fr.ifremer.isisfish.simulator.launcher.SimulationItem;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
@@ -80,7 +81,7 @@
inStream.close();
}
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
params.fromProperties(props);
// try to import region if needed
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -46,6 +46,7 @@
import fr.ifremer.isisfish.logging.SimulationLoggerUtil;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
import fr.ifremer.isisfish.vcs.VCSException;
/**
@@ -352,7 +353,7 @@
FileInputStream in = new FileInputStream(file);
prop.load(in);
in.close();
- parameter = new SimulationParameter();
+ parameter = new SimulationParameterImpl();
parameter.fromProperties(prop);
} catch (IOException eee) {
throw new IsisFishRuntimeException(_(
@@ -382,7 +383,7 @@
FileInputStream in = new FileInputStream(file);
prop.load(in);
in.close();
- parameter = new SimulationParameter();
+ parameter = new SimulationParameterImpl();
parameter.fromProperties(prop);
} catch (IOException eee) {
throw new IsisFishRuntimeException(_(
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -0,0 +1,876 @@
+/* *##%
+ * Copyright (C) 2010 Code Lutin, Benjamin Poussin, Chatellier Eric
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 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.simulator;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+import java.lang.ref.SoftReference;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.io.IOUtils;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaException;
+
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
+
+/**
+ * TODO add comment here.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class SimulationParameterCache implements SimulationParameter {
+
+ protected File paramFile;
+ protected SoftReference<SimulationParameter> ref;
+
+ /**
+ *
+ * @param param param to cache
+ */
+ public SimulationParameterCache(SimulationParameter param) {
+
+ try {
+ paramFile = File.createTempFile("isis-fish-param", ".properties");
+ paramFile.deleteOnExit();
+ store(param);
+ }
+ catch (IOException eee) {
+ throw new IsisFishRuntimeException("Can't cache param to disk", eee);
+ }
+
+ ref = new SoftReference<SimulationParameter>(param);
+ }
+
+ protected void store(SimulationParameter param) {
+ Properties prop = param.toProperties();
+ Writer writer = null;
+ try {
+ writer = new BufferedWriter(new FileWriter(paramFile));
+ prop.store(writer, "Parameter cache");
+ }
+ catch (IOException eee) {
+ throw new IsisFishRuntimeException("Can't cache param to disk", eee);
+ }
+ finally {
+ IOUtils.closeQuietly(writer);
+ }
+ }
+
+ protected SimulationParameter getParam() {
+ SimulationParameter result = ref.get();
+ if (result == null) {
+
+ Reader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(paramFile));
+ Properties prop = new Properties();
+ prop.load(reader);
+ result = new SimulationParameterImpl();
+ result.fromProperties(prop);
+ ref = new SoftReference<SimulationParameter>(result);
+ }
+ catch (IOException eee) {
+ throw new IsisFishRuntimeException("Can't cache param to disk", eee);
+ }
+ finally {
+ IOUtils.closeQuietly(reader);
+ }
+
+ }
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#check()
+ */
+ @Override
+ public List<String> check() {
+ SimulationParameter param = getParam();
+ return param.check();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getIsisFishVersion()
+ */
+ @Override
+ public String getIsisFishVersion() {
+ SimulationParameter param = getParam();
+ return param.getIsisFishVersion();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setIsisFishVersion(java.lang.String)
+ */
+ @Override
+ public void setIsisFishVersion(String isisFishVersion) {
+ SimulationParameter param = getParam();
+ param.setIsisFishVersion(isisFishVersion);
+ store(param);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getDescription()
+ */
+ @Override
+ public String getDescription() {
+ SimulationParameter param = getParam();
+ return param.getDescription();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setDescription(java.lang.String)
+ */
+ @Override
+ public void setDescription(String description) {
+ SimulationParameter param = getParam();
+ param.setDescription(description);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getRegion()
+ */
+ @Override
+ public RegionStorage getRegion() {
+ SimulationParameter param = getParam();
+ return param.getRegion();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getNumberOf(fr.ifremer.isisfish.entities.Population)
+ */
+ @Override
+ public MatrixND getNumberOf(Population pop) {
+ SimulationParameter param = getParam();
+ return param.getNumberOf(pop);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getExtraRules()
+ */
+ @Override
+ public List<String> getExtraRules() {
+ SimulationParameter param = getParam();
+ return param.getExtraRules();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#addExtraRules(java.lang.String[])
+ */
+ @Override
+ public void addExtraRules(String... extraRules) {
+ SimulationParameter param = getParam();
+ param.addExtraRules(extraRules);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getPopulations()
+ */
+ @Override
+ public List<Population> getPopulations() {
+ SimulationParameter param = getParam();
+ return param.getPopulations();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setPopulations(java.util.List)
+ */
+ @Override
+ public void setPopulations(List<Population> populations) {
+ SimulationParameter param = getParam();
+ param.setPopulations(populations);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getStrategies()
+ */
+ @Override
+ public List<Strategy> getStrategies() {
+ SimulationParameter param = getParam();
+ return param.getStrategies();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setStrategies(java.util.List)
+ */
+ @Override
+ public void setStrategies(List<Strategy> strategies) {
+ SimulationParameter param = getParam();
+ param.setStrategies(strategies);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#addAnalysePlan(fr.ifremer.isisfish.simulator.AnalysePlan)
+ */
+ @Override
+ public void addAnalysePlan(AnalysePlan plan) {
+ SimulationParameter param = getParam();
+ param.addAnalysePlan(plan);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#removeAnalysePlan(fr.ifremer.isisfish.simulator.AnalysePlan)
+ */
+ @Override
+ public boolean removeAnalysePlan(AnalysePlan plan) {
+ SimulationParameter param = getParam();
+ boolean result = param.removeAnalysePlan(plan);
+ store(param);
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getAnalysePlans()
+ */
+ @Override
+ public List<AnalysePlan> getAnalysePlans() {
+ SimulationParameter param = getParam();
+ return param.getAnalysePlans();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setAnalysePlans(java.util.List)
+ */
+ @Override
+ public void setAnalysePlans(List<AnalysePlan> plans) {
+ SimulationParameter param = getParam();
+ param.setAnalysePlans(plans);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isIndependentPlan()
+ */
+ @Override
+ public boolean isIndependentPlan() {
+ SimulationParameter param = getParam();
+ return param.isIndependentPlan();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#clearPlans()
+ */
+ @Override
+ public void clearPlans() {
+ SimulationParameter param = getParam();
+ param.clearPlans();
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#addRule(fr.ifremer.isisfish.rule.Rule)
+ */
+ @Override
+ public void addRule(Rule rule) {
+ SimulationParameter param = getParam();
+ param.addRule(rule);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#removeRule(fr.ifremer.isisfish.rule.Rule)
+ */
+ @Override
+ public boolean removeRule(Rule rule) {
+ SimulationParameter param = getParam();
+ boolean result = param.removeRule(rule);
+ store(param);
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getRules()
+ */
+ @Override
+ public List<Rule> getRules() {
+ SimulationParameter param = getParam();
+ return param.getRules();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setRules(java.util.List)
+ */
+ @Override
+ public void setRules(List<Rule> rules) {
+ SimulationParameter param = getParam();
+ param.setRules(rules);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#clearRules()
+ */
+ @Override
+ public void clearRules() {
+ SimulationParameter param = getParam();
+ param.clearRules();
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getUseOptimization()
+ */
+ @Override
+ public boolean getUseOptimization() {
+ SimulationParameter param = getParam();
+ return param.getUseOptimization();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setUseOptimization(boolean)
+ */
+ @Override
+ public void setUseOptimization(boolean useOptimization) {
+ SimulationParameter param = getParam();
+ param.setUseOptimization(useOptimization);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getUseStatistic()
+ */
+ @Override
+ public boolean getUseStatistic() {
+ SimulationParameter param = getParam();
+ return param.getUseStatistic();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setUseStatistic(boolean)
+ */
+ @Override
+ public void setUseStatistic(boolean useStatistic) {
+ SimulationParameter param = getParam();
+ param.setUseStatistic(useStatistic);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getExportNames()
+ */
+ @Override
+ public List<String> getExportNames() {
+ SimulationParameter param = getParam();
+ return param.getExportNames();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setExportNames(java.util.List)
+ */
+ @Override
+ public void setExportNames(List<String> exportNames) {
+ SimulationParameter param = getParam();
+ param.setExportNames(exportNames);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getNumberOfSensitivitySimulation()
+ */
+ @Override
+ public int getNumberOfSensitivitySimulation() {
+ SimulationParameter param = getParam();
+ return param.getNumberOfSensitivitySimulation();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setNumberOfSensitivitySimulation(int)
+ */
+ @Override
+ public void setNumberOfSensitivitySimulation(
+ int numberOfSensitivitySimulation) {
+ SimulationParameter param = getParam();
+ param.setNumberOfSensitivitySimulation(numberOfSensitivitySimulation);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getSensitivityCalculator()
+ */
+ @Override
+ public SensitivityCalculator getSensitivityCalculator() {
+ SimulationParameter param = getParam();
+ return param.getSensitivityCalculator();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setSensitivityCalculator(fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator)
+ */
+ @Override
+ public void setSensitivityCalculator(
+ SensitivityCalculator sensitivityCalculator) {
+ SimulationParameter param = getParam();
+ param.setSensitivityCalculator(sensitivityCalculator);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getSensitivityExport()
+ */
+ @Override
+ public List<SensitivityExport> getSensitivityExport() {
+ SimulationParameter param = getParam();
+ return param.getSensitivityExport();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setSensitivityExport(java.util.List)
+ */
+ @Override
+ public void setSensitivityExport(List<SensitivityExport> sensitivityExport) {
+ SimulationParameter param = getParam();
+ param.setSensitivityExport(sensitivityExport);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getUseAnalysePlan()
+ */
+ @Override
+ public boolean getUseAnalysePlan() {
+ SimulationParameter param = getParam();
+ return param.getUseAnalysePlan();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setUseAnalysePlan(boolean)
+ */
+ @Override
+ public void setUseAnalysePlan(boolean useAnalysePlan) {
+ SimulationParameter param = getParam();
+ param.setUseAnalysePlan(useAnalysePlan);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getAnalysePlanNumber()
+ */
+ @Override
+ public int getAnalysePlanNumber() {
+ SimulationParameter param = getParam();
+ return param.getAnalysePlanNumber();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setAnalysePlanNumber(int)
+ */
+ @Override
+ public void setAnalysePlanNumber(int analysePlanNumber) {
+ SimulationParameter param = getParam();
+ param.setAnalysePlanNumber(analysePlanNumber);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getNumberOfYear()
+ */
+ @Override
+ public int getNumberOfYear() {
+ SimulationParameter param = getParam();
+ return param.getNumberOfYear();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setNumberOfYear(int)
+ */
+ @Override
+ public void setNumberOfYear(int numberOfYear) {
+ SimulationParameter param = getParam();
+ param.setNumberOfYear(numberOfYear);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getUsePreScript()
+ */
+ @Override
+ public boolean getUsePreScript() {
+ SimulationParameter param = getParam();
+ return param.getUsePreScript();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setUsePreScript(boolean)
+ */
+ @Override
+ public void setUsePreScript(boolean usePreScript) {
+ SimulationParameter param = getParam();
+ param.setUsePreScript(usePreScript);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getPreScript()
+ */
+ @Override
+ public String getPreScript() {
+ SimulationParameter param = getParam();
+ return param.getPreScript();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setPreScript(java.lang.String)
+ */
+ @Override
+ public void setPreScript(String preScript) {
+ SimulationParameter param = getParam();
+ param.setPreScript(preScript);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getRegionName()
+ */
+ @Override
+ public String getRegionName() {
+ SimulationParameter param = getParam();
+ return param.getRegionName();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setRegionName(java.lang.String)
+ */
+ @Override
+ public void setRegionName(String regionName) {
+ SimulationParameter param = getParam();
+ param.setRegionName(regionName);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getSimulatorName()
+ */
+ @Override
+ public String getSimulatorName() {
+ SimulationParameter param = getParam();
+ return param.getSimulatorName();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setSimulatorName(java.lang.String)
+ */
+ @Override
+ public void setSimulatorName(String simulatorName) {
+ SimulationParameter param = getParam();
+ param.setSimulatorName(simulatorName);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getResultEnabled()
+ */
+ @Override
+ public Collection<String> getResultEnabled() {
+ SimulationParameter param = getParam();
+ return param.getResultEnabled();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setResultEnabled(java.util.Collection)
+ */
+ @Override
+ public void setResultEnabled(Collection<String> resultEnabled) {
+ SimulationParameter param = getParam();
+ param.setResultEnabled(resultEnabled);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getTagValue()
+ */
+ @Override
+ public Map<String, String> getTagValue() {
+ SimulationParameter param = getParam();
+ return param.getTagValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setTagValue(java.util.Map)
+ */
+ @Override
+ public void setTagValue(Map<String, String> tagValue) {
+ SimulationParameter param = getParam();
+ param.setTagValue(tagValue);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getSimulLogLevel()
+ */
+ @Override
+ public String getSimulLogLevel() {
+ SimulationParameter param = getParam();
+ return param.getSimulLogLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setSimulLogLevel(java.lang.String)
+ */
+ @Override
+ public void setSimulLogLevel(String logLevel) {
+ SimulationParameter param = getParam();
+ param.setSimulLogLevel(logLevel);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getScriptLogLevel()
+ */
+ @Override
+ public String getScriptLogLevel() {
+ SimulationParameter param = getParam();
+ return param.getScriptLogLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setScriptLogLevel(java.lang.String)
+ */
+ @Override
+ public void setScriptLogLevel(String logLevel) {
+ SimulationParameter param = getParam();
+ param.setScriptLogLevel(logLevel);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#getLibLogLevel()
+ */
+ @Override
+ public String getLibLogLevel() {
+ SimulationParameter param = getParam();
+ return param.getLibLogLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#setLibLogLevel(java.lang.String)
+ */
+ @Override
+ public void setLibLogLevel(String logLevel) {
+ SimulationParameter param = getParam();
+ param.setLibLogLevel(logLevel);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isSimulErrorLevel()
+ */
+ @Override
+ public boolean isSimulErrorLevel() {
+ SimulationParameter param = getParam();
+ return param.isSimulErrorLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isSimulWarnLevel()
+ */
+ @Override
+ public boolean isSimulWarnLevel() {
+ SimulationParameter param = getParam();
+ return param.isSimulErrorLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isSimulInfoLevel()
+ */
+ @Override
+ public boolean isSimulInfoLevel() {
+ SimulationParameter param = getParam();
+ return param.isScriptInfoLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isSimulDebugLevel()
+ */
+ @Override
+ public boolean isSimulDebugLevel() {
+ SimulationParameter param = getParam();
+ return param.isSimulDebugLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isScriptErrorLevel()
+ */
+ @Override
+ public boolean isScriptErrorLevel() {
+ SimulationParameter param = getParam();
+ return param.isScriptErrorLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isScriptWarnLevel()
+ */
+ @Override
+ public boolean isScriptWarnLevel() {
+ SimulationParameter param = getParam();
+ return param.isScriptWarnLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isScriptInfoLevel()
+ */
+ @Override
+ public boolean isScriptInfoLevel() {
+ SimulationParameter param = getParam();
+ return param.isScriptInfoLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isScriptDebugLevel()
+ */
+ @Override
+ public boolean isScriptDebugLevel() {
+ SimulationParameter param = getParam();
+ return param.isScriptDebugLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isLibErrorLevel()
+ */
+ @Override
+ public boolean isLibErrorLevel() {
+ SimulationParameter param = getParam();
+ return param.isLibErrorLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isLibWarnLevel()
+ */
+ @Override
+ public boolean isLibWarnLevel() {
+ SimulationParameter param = getParam();
+ return param.isLibWarnLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isLibInfoLevel()
+ */
+ @Override
+ public boolean isLibInfoLevel() {
+ SimulationParameter param = getParam();
+ return param.isLibInfoLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#isLibDebugLevel()
+ */
+ @Override
+ public boolean isLibDebugLevel() {
+ SimulationParameter param = getParam();
+ return param.isLibDebugLevel();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#copy()
+ */
+ @Override
+ public SimulationParameter copy() {
+ SimulationParameter param = getParam();
+ return param.copy();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#deepCopy()
+ */
+ @Override
+ public SimulationParameter deepCopy() {
+ SimulationParameter param = getParam();
+ return param.deepCopy();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#toProperties()
+ */
+ @Override
+ public Properties toProperties() {
+ SimulationParameter param = getParam();
+ return param.toProperties();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#fromProperties(java.util.Properties)
+ */
+ @Override
+ public void fromProperties(Properties props) {
+ SimulationParameter param = getParam();
+ param.fromProperties(props);
+ store(param);
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter#reloadContextParameters()
+ */
+ @Override
+ public void reloadContextParameters() throws TopiaException {
+ SimulationParameter param = getParam();
+ param.reloadContextParameters();
+ store(param);
+ }
+}
Property changes on: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterCache.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java (from rev 3019, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java)
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -0,0 +1,1904 @@
+/* *##%
+ * Copyright (C) 2006 - 2010 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. ##%
+ */
+
+package fr.ifremer.isisfish.simulator;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.beanutils.ConvertUtilsBean;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.math.matrix.MatrixFactory;
+import org.nuiton.math.matrix.MatrixHelper;
+import org.nuiton.math.matrix.MatrixND;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
+import org.nuiton.util.SortedProperties;
+import org.nuiton.util.StringUtil;
+
+import fr.ifremer.isisfish.IsisConfig;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.AnalysePlanStorage;
+import fr.ifremer.isisfish.datastore.RegionStorage;
+import fr.ifremer.isisfish.datastore.RuleStorage;
+import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.SensitivityStorage;
+import fr.ifremer.isisfish.entities.Population;
+import fr.ifremer.isisfish.entities.PopulationDAO;
+import fr.ifremer.isisfish.entities.Strategy;
+import fr.ifremer.isisfish.entities.StrategyDAO;
+import fr.ifremer.isisfish.export.ExportHelper;
+import fr.ifremer.isisfish.export.SensitivityExport;
+import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.rule.RuleHelper;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
+import fr.ifremer.isisfish.util.ConverterUtil;
+
+/**
+ * Contains all parameters for one simulation.
+ *
+ * {@link SimulationParameter} must now be loaded from a {@link Properties}
+ * object.
+ * {@link #toProperties()} method, now return a new {@link Properties} object
+ * filled with :
+ * <ul>
+ * <li>non modified original properties
+ * <li>new properties if some objects has been instantiated by getters().
+ * </ul>
+ *
+ * Created: 10 janv. 2006 17:03:37
+ *
+ * @author poussin
+ * @author chatellier
+ *
+ * @version $Revision$
+ *
+ * Last update: $Date$
+ * By : $Author$
+ */
+public class SimulationParameterImpl implements SimulationParameter {
+
+ /** Logger for this class. */
+ private static Log log = LogFactory.getLog(SimulationParameter.class);
+
+ /** Remember last read properties. */
+ protected Properties propertiesParameters;
+
+ /**
+ * Isis-fish version that permit to do the simulation.
+ * Must be set just before simulation by simulator.
+ */
+ protected String isisFishVersion;
+
+ /** Description de la simulation. */
+ protected String description;
+
+ /** Nom de la region sur lequel on simule. */
+ protected String regionName;
+
+ /** Nombre d'année sur lequel on souhaite simuler. */
+ protected Integer numberOfYear;
+
+ /** Le nom de l'objet script a utiliser pour faire la simulation. */
+ protected String simulatorName;
+
+ /** Utilisation ou non des optimisations. */
+ protected Boolean useOptimization;
+
+ /** Utilisation ou non des statistiques. */
+ protected Boolean useStatistic;
+
+ /** La liste des strategies a utiliser pour la simulation. */
+ protected List<Strategy> strategies;
+
+ /** La liste des populations a utiliser pour la simulation. */
+ protected List<Population> populations;
+
+ /** Les effectifs initiaux des différentes population. */
+ protected Map<Population, MatrixND> numbers;
+
+ /** La liste des regles de gestions a utiliser pour la simulation. */
+ protected List<Rule> rules;
+
+ /** La liste des regles potentiellement ajoutée par les plans d'analyse. */
+ protected List<String> extraRules;
+
+ /** La liste des plans a utiliser pour la simulation. */
+ protected List<AnalysePlan> analysePlans;
+
+ /** Ma liste des exports automatique a faire en fin de simulation. */
+ protected List<String> exportNames;
+
+ /** Utilisation du script de pre simulation. */
+ protected Boolean usePreScript;
+
+ /** Le script de pre simulation a utiliser. */
+ protected String preScript;
+
+ /** Utilisation du plan d'analyse. */
+ protected Boolean useAnalysePlan;
+
+ /**
+ * Le numero de sequence de la liste des plans d'analyse. Le premier
+ * élement du plan doit etre 0. Si la simulation ne fait pas partie d'un
+ * plan la valeur est -1. */
+ protected Integer analysePlanNumber;
+
+ /** Export utilisés pour les analyses de sensibilités. */
+ protected List<SensitivityExport> sensitivityExports;
+
+ /**
+ * Nombre de simulation constituant l'analyse de sensibilité.
+ *
+ * FIXME ce parametre ne devrait pas ce trouver à cet endroit.
+ * Ce n'est pas un parametres, mais une infos de simulation.
+ * Cela permet de savoir combien de simulation il y a au total
+ * pour savoir quand elle sont terminées.
+ */
+ protected Integer numberOfSensitivitySimulation;
+
+ /** Export utilisés pour les analyses de sensibilités. */
+ protected SensitivityCalculator sensitivityCalculator;
+
+ /** La liste des resultats qui nous interesse. */
+ protected Collection<String> resultEnabled;
+
+ /** Autre parametre defini par l'utilisateur. */
+ protected Map<String, String> tagValue;
+
+ /**
+ * Si vrai seul les exports automatiques ne sont souhaiter, la simulation
+ * pourrait etre supprimée a la fin.
+ */
+ protected Boolean onlyExport;
+
+ /** Le niveau de log du simulateur à utiliser pendant la simulation. Par defaut info. */
+ protected String simulLogLevel = "info";
+ /** Le niveau de log des scripts à utiliser pendant la simulation. Par defaut info. */
+ protected String scriptLogLevel = "info";
+ /** Le niveau de log des librairies à utiliser pendant la simulation. Par defaut error. */
+ protected String libLogLevel = "error";
+
+ /** La region corespondant au parametre {@link #regionName}. */
+ protected transient RegionStorage region;
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#check()
+ */
+ @Override
+ public List<String> check() {
+ List<String> result = new ArrayList<String>();
+ // TODO faire la verif et pour chaque erreur mettre un message
+ // dans la liste result (par exemple si pas d'effectif
+ // pour une pop
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getIsisFishVersion()
+ */
+ @Override
+ public String getIsisFishVersion() {
+ // if not already set
+ if (isisFishVersion == null) {
+ if (propertiesParameters != null) {
+ isisFishVersion = propertiesParameters.getProperty("isisFishVersion", "");
+ } else {
+ // default value
+ isisFishVersion = IsisConfig.getVersion();
+ }
+ }
+ return isisFishVersion;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setIsisFishVersion(java.lang.String)
+ */
+ @Override
+ public void setIsisFishVersion(String isisFishVersion) {
+ this.isisFishVersion = isisFishVersion;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getDescription()
+ */
+ @Override
+ public String getDescription() {
+
+ if (description == null) {
+ if (propertiesParameters != null) {
+ description = propertiesParameters.getProperty("description", "");
+ } else {
+ // default value
+ description = "";
+ }
+ }
+ return this.description;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setDescription(java.lang.String)
+ */
+ @Override
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getRegion()
+ */
+ @Override
+ public RegionStorage getRegion() {
+
+ if (region == null || !region.getName().equals(getRegionName())) {
+ // bien faire attention ici que la bonne region est ouverte
+ // - isis-database-3 dans le cas d'une region normale
+ // - simulation dans le cas d'une simulation
+ region = RegionStorage.getRegion(getRegionName());
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug(_("Region %s already inited", getRegionName()));
+ }
+ }
+ return this.region;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getNumberOf(fr.ifremer.isisfish.entities.Population)
+ */
+ @Override
+ public MatrixND getNumberOf(Population pop) {
+ if (numbers == null) {
+ numbers = new LinkedHashMap<Population, MatrixND>();
+ }
+ MatrixND result = numbers.get(pop);
+ if (result == null) {
+ List groups = pop.getPopulationGroup();
+ List zones = pop.getPopulationZone();
+
+ if (groups.size() == 0) {
+ groups.add("No group");
+ }
+ if (zones.size() == 0) {
+ zones.add("No zone");
+ }
+ List[] semantics = new List[] { groups, zones };
+ result = MatrixFactory.getInstance().create(semantics);
+
+ numbers.put(pop, result);
+ }
+ return result;
+ }
+
+ /**
+ * Permet de mettre les parametres de la regle sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param ruleIndex l'index de la rule
+ * @param rule La regle dont on souhaite mettre les parametres dans l'objet
+ * Properties retourne
+ * @return L'objet Properties contenant les valeurs des parametres de la
+ * regle
+ */
+ protected Properties ruleParametertoProperties(int ruleIndex, Rule rule) {
+ Properties result = new Properties();
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
+ .getStorage());
+ for (String paramName : RuleStorage.getParameterNames(rule).keySet()) {
+ String paramValueString;
+ try {
+ Object value = RuleStorage.getParameterValue(rule, paramName);
+ paramValueString = beanUtils.convert(value);
+ if (paramValueString != null) {
+ result.setProperty("rule." + ruleIndex + ".parameter." + paramName, paramValueString);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert parameter value to String: " + paramName, eee);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Permet de mettre les parametres de l'export sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param sensitivityExportIndex l'index de l'export
+ * @param sensitivityExport l'export dont on souhaite mettre les parametres dans l'objet
+ * Properties retourné
+ * @return L'objet Properties contenant les valeurs des parametres de l'export
+ */
+ protected Properties sensitivityExportParametertoProperties(
+ int sensitivityExportIndex, SensitivityExport sensitivityExport) {
+ Properties result = new Properties();
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
+ for (String paramName : SensitivityExportStorage.getParameterNames(sensitivityExport).keySet()) {
+ try {
+ Object value = SensitivityExportStorage.getParameterValue(
+ sensitivityExport, paramName);
+ String paramValueString = beanUtils.convert(value);
+ if (paramValueString != null) {
+ result.setProperty("sensitivityexport."
+ + sensitivityExportIndex + ".parameter."
+ + paramName, paramValueString);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert parameter value to String: "
+ + paramName, eee);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Permet de mettre les parametres du calculateur sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param sensitivityIndex l'index du calculateur de sensitivity
+ * @param calculator Le calculateurdont on souhaite mettre les parametres dans l'objet
+ * Properties retourne
+ * @return L'objet Properties contenant les valeurs des parametres du calculateur de sensibilité
+ */
+ protected Properties sensitivityCalculatorParametertoProperties(
+ int sensitivityIndex, SensitivityCalculator calculator) {
+ Properties result = new Properties();
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
+ for (String paramName : SensitivityStorage.getParameterNames(calculator).keySet()) {
+ try {
+ Object value = SensitivityStorage.getParameterValue(calculator,
+ paramName);
+ String paramValueString = beanUtils.convert(value);
+ if (paramValueString != null) {
+ result.setProperty("sensitivity." + sensitivityIndex + ".parameter." + paramName, paramValueString);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert parameter value to String: "
+ + paramName, eee);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Permet de mettre les parametres du plan sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param planIndex l'index du plan
+ * @param plan Le plan dont on souhaite mettre les parametres dans l'objet
+ * Properties retourne
+ * @return L'objet Properties contenant les valeurs des parametres du plan
+ */
+ protected Properties planParametertoProperties(int planIndex,
+ AnalysePlan plan) {
+ Properties result = new Properties();
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
+ for (String paramName : AnalysePlanStorage.getParameterNames(plan).keySet()) {
+ try {
+ Object value = AnalysePlanStorage.getParameterValue(plan,paramName);
+ String paramValueString = beanUtils.convert(value);
+ if (paramValueString != null) {
+ result.setProperty("plan." + planIndex + ".parameter."
+ + paramName, paramValueString);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert parametre value to String: "
+ + paramName, eee);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Recupere dans prop les valeurs des champs specifique au plan et met a
+ * jour les champs du plan.
+ *
+ * @param planIndex l'index du plan
+ * @param plan le plan dont les parametres doivent etre lu depuis les
+ * proprietes
+ * @param props les proprietes contenant les parametre du plan
+ */
+ protected void populateAnalysePlan(int planIndex, AnalysePlan plan,
+ Properties props) {
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
+ .getStorage());
+ String planName = AnalysePlanStorage.getName(plan);
+ String paramTag = "plan." + planIndex + ".parameter.";
+
+ for (Map.Entry<String, Class<?>> entry : AnalysePlanStorage.getParameterNames(plan).entrySet()) {
+ String propName = entry.getKey();
+ Class<?> type = entry.getValue();
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+ type = TopiaEntity.class;
+ }
+ String valueString = props.getProperty(paramTag + propName);
+ Object value = beanUtils.convert(valueString, type);
+ try {
+ AnalysePlanStorage.setParameterValue(plan, propName, value);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't reload field " + propName + " for plan "
+ + planName, eee);
+ }
+ }
+ }
+ }
+
+ /**
+ * Recupere dans prop les valeurs des champs specifique au calculateur de
+ * sensibilité et met a jour les champs du calculateur.
+ *
+ * @param calculatorIndex l'index du calculateur
+ * @param calculator le calculateur dont les parametres doivent etre lu depuis lesproprietes
+ * @param props les proprietes contenant les parametre du calculateur
+ */
+ protected void populateSensitivityCalculator(int calculatorIndex,
+ SensitivityCalculator calculator, Properties props) {
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
+ .getStorage());
+ String calculatorName = SensitivityStorage.getName(calculator);
+ String paramTag = "sensitivity." + calculatorIndex + ".parameter.";
+
+ for (Map.Entry<String, Class<?>> entry : SensitivityStorage.getParameterNames(calculator).entrySet()) {
+ String propName = entry.getKey();
+ Class<?> type = entry.getValue();
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+ type = TopiaEntity.class;
+ }
+ String valueString = props.getProperty(paramTag + propName);
+ Object value = beanUtils.convert(valueString, type);
+ try {
+ SensitivityStorage.setParameterValue(calculator, propName, value);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't reload field " + propName
+ + " for sensitivity calculator " + calculatorName,
+ eee);
+ }
+ }
+ }
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getExtraRules()
+ */
+ @Override
+ public List<String> getExtraRules() {
+
+ if (extraRules == null) {
+ // no properties in config ?
+ extraRules = new ArrayList<String>();
+ }
+ return extraRules;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#addExtraRules(java.lang.String)
+ */
+ @Override
+ public void addExtraRules(String... extraRules) {
+ getExtraRules().addAll(Arrays.asList(extraRules));
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getPopulations()
+ */
+ @Override
+ public List<Population> getPopulations() {
+ if (populations == null) {
+ populations = new ArrayList<Population>();
+
+ if (propertiesParameters != null) {
+
+ try {
+ // On verifie tout d'abord que l'on ai pas dans une simulation
+ // si on y es, on utilise le context static non null du thread local
+ // Resoud les lazy exceptions des parametres des regles
+ boolean mustClose = false;
+ TopiaContext tx = SimulationContext.get().getDB();
+
+ if (tx == null) {
+ // not in simulation, create transaction
+ tx = getRegion().getStorage().beginTransaction();
+ mustClose = true;
+ }
+
+ PopulationDAO populationDAO = IsisFishDAOHelper
+ .getPopulationDAO(tx);
+ String[] populationList = propertiesParameters.getProperty(
+ "populations", "").split(",");
+ for (String name : populationList) {
+ if (name != null && !"".equals(name)) {
+ try {
+ Population population = populationDAO.findByName(name);
+ populations.add(population);
+
+ String numberAsString = propertiesParameters.getProperty("population." + name + ".number");
+ List number = MatrixHelper.convertStringToList(numberAsString);
+ MatrixND mat = getNumberOf(population);
+ mat.fromList(number);
+ } catch (TopiaException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find population: " + name, eee);
+ }
+ }
+ }
+ }
+
+ // si la transaction a été ouverte (pas dans une simulation)
+ // on la referme
+ if (mustClose) {
+ tx.closeContext();
+ }
+ } catch (TopiaException eee1) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't get PopulationDAO", eee1);
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No last read properties, skip population reloading");
+ }
+ }
+ }
+ return populations;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setPopulations(java.util.List)
+ */
+ @Override
+ public void setPopulations(List<Population> populations) {
+ this.populations = populations;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getStrategies()
+ */
+ @Override
+ public List<Strategy> getStrategies() {
+
+ if (strategies == null) {
+
+ strategies = new ArrayList<Strategy>();
+
+ if (propertiesParameters != null) {
+ strategies = new ArrayList<Strategy>();
+
+ try {
+
+ // On verifie tout d'abord que l'on ai pas dans une simulation
+ // si on y es, on utilise le context static non null du thread local
+ // Resoud les lazy exceptions des parametres des regles
+ boolean mustClose = false;
+ TopiaContext tx = SimulationContext.get().getDB();
+
+ if (tx == null) {
+ // not in simulation, create transaction
+ tx = getRegion().getStorage().beginTransaction();
+ mustClose = true;
+ }
+
+ StrategyDAO strategyDAO = IsisFishDAOHelper.getStrategyDAO(tx);
+ String[] strategyList = propertiesParameters.getProperty("strategies", "").split(",");
+ for (String name : strategyList) {
+ if (name != null && !"".equals(name)) {
+ try {
+ Strategy str = strategyDAO.findByName(name);
+ strategies.add(str);
+ } catch (TopiaException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find strategy: " + name, eee);
+ }
+ }
+ }
+ }
+
+ // si la transaction a été ouverte (pas dans une simulation)
+ // on la referme
+ if (mustClose) {
+ tx.closeContext();
+ }
+ } catch (TopiaException eee1) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't get StrategyDAO", eee1);
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No last read properties, skip strategies reloading");
+ }
+ }
+ }
+ return strategies;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setStrategies(java.util.List)
+ */
+ @Override
+ public void setStrategies(List<Strategy> strategies) {
+ this.strategies = strategies;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#addAnalysePlan(fr.ifremer.isisfish.simulator.AnalysePlan)
+ */
+ @Override
+ public void addAnalysePlan(AnalysePlan plan) {
+ getAnalysePlans().add(plan);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#removeAnalysePlan(fr.ifremer.isisfish.simulator.AnalysePlan)
+ */
+ @Override
+ public boolean removeAnalysePlan(AnalysePlan plan) {
+ return getAnalysePlans().remove(plan);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getAnalysePlans()
+ */
+ @Override
+ public List<AnalysePlan> getAnalysePlans() {
+ if (analysePlans == null) {
+
+ analysePlans = new ArrayList<AnalysePlan>();
+
+ if (propertiesParameters != null) {
+ // analyse plan
+ String[] planList = propertiesParameters.getProperty("plans",
+ "").split(",");
+ int planIndex = 0;
+ for (String name : planList) {
+ if (name != null && !"".equals(name)) {
+ try {
+ AnalysePlan plan = AnalysePlanStorage
+ .getAnalysePlan(name)
+ .getNewAnalysePlanInstance();
+ populateAnalysePlan(planIndex++, plan, propertiesParameters);
+ analysePlans.add(plan);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find plan: " + name, eee);
+ }
+ }
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No last read properties, skip plans reloading");
+ }
+ }
+ }
+ return this.analysePlans;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setAnalysePlans(java.util.List)
+ */
+ @Override
+ public void setAnalysePlans(List<AnalysePlan> plans) {
+ this.analysePlans = plans;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isIndependentPlan()
+ */
+ @Override
+ public boolean isIndependentPlan() {
+ boolean result = true;
+ for (AnalysePlan plan : getAnalysePlans()) {
+ if (!(plan instanceof AnalysePlanIndependent)) {
+ result = false;
+ break;
+ }
+ }
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#clearPlans()
+ */
+ @Override
+ public void clearPlans() {
+ if (analysePlans != null) {
+ analysePlans.clear();
+ }
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#addRule(fr.ifremer.isisfish.rule.Rule)
+ */
+ @Override
+ public void addRule(Rule rule) {
+ getRules().add(rule);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#removeRule(fr.ifremer.isisfish.rule.Rule)
+ */
+ @Override
+ public boolean removeRule(Rule rule) {
+ return getRules().remove(rule);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getRules()
+ */
+ @Override
+ public List<Rule> getRules() {
+ if (rules == null) {
+ rules = new ArrayList<Rule>();
+
+ if (propertiesParameters != null) {
+ try {
+ // On verifie tout d'abord que l'on ai pas dans une simulation
+ // si on y es, on utilise le context static non null du thread local
+ // Resoud les lazy exceptions des parametres des regles
+ boolean mustClose = false;
+ TopiaContext tx = SimulationContext.get().getDB();
+
+ if (tx == null) {
+ // not in simulation, create transaction
+ tx = getRegion().getStorage().beginTransaction();
+ mustClose = true;
+ }
+
+ // rules
+ String[] ruleList = propertiesParameters.getProperty("rules", "").split(",");
+ int ruleIndex = 0;
+ for (String name : ruleList) {
+ if (name != null && !"".equals(name)) {
+ try {
+ Rule rule = RuleStorage.getRule(name).getNewRuleInstance();
+ RuleHelper.populateRule(ruleIndex++, tx, rule, propertiesParameters);
+ rules.add(rule);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find rule: " + name, eee);
+ }
+ }
+ }
+ }
+
+ // si la transaction a été ouverte (pas dans une simulation)
+ // on la referme
+ if (mustClose) {
+ tx.closeContext();
+ }
+ } catch (TopiaException eee1) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't get TopiaContext", eee1);
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No last read properties, skip rule reloading");
+ }
+ }
+ }
+ return rules;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setRules(java.util.List)
+ */
+ @Override
+ public void setRules(List<Rule> rules) {
+ this.rules = rules;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#clearRules()
+ */
+ @Override
+ public void clearRules() {
+ if (rules != null) {
+ rules.clear();
+ }
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getUseOptimization()
+ */
+ @Override
+ public boolean getUseOptimization() {
+
+ if (useOptimization == null) {
+ if (propertiesParameters != null) {
+ useOptimization = Boolean.valueOf(propertiesParameters.getProperty("useOptimization", "true"));
+ } else {
+ useOptimization = Boolean.TRUE;
+ }
+ }
+ return useOptimization.booleanValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setUseOptimization(boolean)
+ */
+ @Override
+ public void setUseOptimization(boolean useOptimization) {
+ this.useOptimization = useOptimization;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getUseStatistic()
+ */
+ @Override
+ public boolean getUseStatistic() {
+
+ if (useStatistic == null) {
+ if (propertiesParameters != null) {
+ useStatistic = Boolean.valueOf(propertiesParameters.getProperty("useStatistic", "false"));
+ } else {
+ useStatistic = Boolean.FALSE;
+ }
+ }
+ return this.useStatistic;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setUseStatistic(boolean)
+ */
+ @Override
+ public void setUseStatistic(boolean useStatistic) {
+ this.useStatistic = useStatistic;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getExportNames()
+ */
+ @Override
+ public List<String> getExportNames() {
+ if (exportNames == null) {
+ exportNames = new ArrayList<String>();
+
+ if (propertiesParameters != null) {
+ // exports
+ String[] exportList = propertiesParameters.getProperty("exports", "").split(",");
+ for (String name : exportList) {
+ if (name != null && !"".equals(name)) {
+ exportNames.add(name);
+ }
+ }
+ }
+ }
+ return this.exportNames;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setExportNames(java.util.List)
+ */
+ @Override
+ public void setExportNames(List<String> exportNames) {
+ this.exportNames = exportNames;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getNumberOfSensitivitySimulation()
+ */
+ @Override
+ public int getNumberOfSensitivitySimulation() {
+
+ if (numberOfSensitivitySimulation == null) {
+
+ if (propertiesParameters != null) {
+ numberOfSensitivitySimulation = Integer.valueOf(propertiesParameters.getProperty(
+ "numberOfSensitivitySimulation", "-1"));
+ } else {
+ numberOfSensitivitySimulation = Integer.valueOf(-1);
+ }
+ }
+
+ return numberOfSensitivitySimulation.intValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setNumberOfSensitivitySimulation(int)
+ */
+ @Override
+ public void setNumberOfSensitivitySimulation(
+ int numberOfSensitivitySimulation) {
+ this.numberOfSensitivitySimulation = numberOfSensitivitySimulation;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getSensitivityCalculator()
+ */
+ @Override
+ public SensitivityCalculator getSensitivityCalculator() {
+
+ if (sensitivityCalculator == null) {
+ if (propertiesParameters != null) {
+ String calculatorName = propertiesParameters
+ .getProperty("sensitivitycalculator");
+ if (!StringUtils.isEmpty(calculatorName)) {
+ try {
+ SensitivityStorage sensitivityStorage = SensitivityStorage.getSensitivity(calculatorName);
+ sensitivityCalculator = sensitivityStorage.getNewSensitivityInstance();
+ // 0 = only single sensitivity
+ populateSensitivityCalculator(0, sensitivityCalculator, propertiesParameters);
+ } catch (IsisFishException eee) {
+ sensitivityCalculator = null;
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find sensitivity: " + sensitivityCalculator, eee);
+ }
+ }
+ }
+ }
+ }
+
+ return sensitivityCalculator;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setSensitivityCalculator(fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator)
+ */
+ @Override
+ public void setSensitivityCalculator(
+ SensitivityCalculator sensitivityCalculator) {
+ this.sensitivityCalculator = sensitivityCalculator;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getSensitivityExport()
+ */
+ @Override
+ public List<SensitivityExport> getSensitivityExport() {
+ if (sensitivityExports == null) {
+ sensitivityExports = new ArrayList<SensitivityExport>();
+
+ if (propertiesParameters != null) {
+ try {
+ // On verifie tout d'abord que l'on ai pas dans une simulation
+ // si on y es, on utilise le context static non null du thread local
+ // Resoud les lazy exceptions des parametres des regles
+ boolean mustClose = false;
+ TopiaContext tx = SimulationContext.get().getDbResult();
+
+ if (tx == null) {
+ // not in simulation, create transaction
+ tx = getRegion().getStorage().beginTransaction();
+ mustClose = true;
+ }
+
+ // sensitivity export
+ String[] sensitivityExportList = propertiesParameters
+ .getProperty("sensitivityexports", "").split(",");
+ int sensitivityExportIndex = 0;
+ for (String name : sensitivityExportList) {
+ try {
+ if (!StringUtils.isEmpty(name)) {
+ SensitivityExport sensitivityExport = SensitivityExportStorage
+ .getSensitivityExport(name)
+ .getNewSensitivityExportInstance();
+ ExportHelper.populateSensitivityExport(
+ sensitivityExportIndex++, tx,
+ sensitivityExport,
+ propertiesParameters);
+ sensitivityExports.add(sensitivityExport);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't find SensitivityExport: " + name, eee);
+ }
+ }
+ }
+
+ // si la transaction a été ouverte (pas dans une simulation)
+ // on la referme
+ if (mustClose) {
+ tx.closeContext();
+ }
+ } catch (TopiaException eee1) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't get TopiaContext", eee1);
+ }
+ }
+ } else {
+ if (log.isDebugEnabled()) {
+ log.debug("No last read properties, skip sensitivity exports reloading");
+ }
+ }
+ }
+ return sensitivityExports;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setSensitivityExport(java.util.List)
+ */
+ @Override
+ public void setSensitivityExport(List<SensitivityExport> sensitivityExport) {
+ this.sensitivityExports = sensitivityExport;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getUseAnalysePlan()
+ */
+ @Override
+ public boolean getUseAnalysePlan() {
+
+ if (useAnalysePlan == null) {
+
+ if (propertiesParameters != null) {
+ useAnalysePlan = Boolean.valueOf(propertiesParameters.getProperty("useAnalysePlan", "false"));
+ } else {
+ useAnalysePlan = Boolean.FALSE;
+ }
+ }
+ return this.useAnalysePlan;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setUseAnalysePlan(boolean)
+ */
+ @Override
+ public void setUseAnalysePlan(boolean useAnalysePlan) {
+ this.useAnalysePlan = useAnalysePlan;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getAnalysePlanNumber()
+ */
+ @Override
+ public int getAnalysePlanNumber() {
+
+ if (analysePlanNumber == null) {
+
+ if (propertiesParameters != null) {
+ analysePlanNumber = Integer.valueOf(propertiesParameters.getProperty("analysePlanNumber", "-1"));
+ } else {
+ analysePlanNumber = Integer.valueOf(-1);
+ }
+ }
+
+ return this.analysePlanNumber.intValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setAnalysePlanNumber(int)
+ */
+ @Override
+ public void setAnalysePlanNumber(int analysePlanNumber) {
+ this.analysePlanNumber = analysePlanNumber;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getNumberOfYear()
+ */
+ @Override
+ public int getNumberOfYear() {
+
+ if (numberOfYear == null) {
+
+ if (propertiesParameters != null) {
+ numberOfYear = Integer.valueOf(propertiesParameters.getProperty("numberOfYear", "1"));
+ } else {
+ numberOfYear = Integer.valueOf(1);
+ }
+ }
+ return numberOfYear.intValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setNumberOfYear(int)
+ */
+ @Override
+ public void setNumberOfYear(int numberOfYear) {
+ this.numberOfYear = numberOfYear;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getUsePreScript()
+ */
+ @Override
+ public boolean getUsePreScript() {
+
+ if (usePreScript == null) {
+
+ if (propertiesParameters != null) {
+ usePreScript = Boolean.valueOf(propertiesParameters.getProperty("usePreScript", "false"));
+ } else {
+ usePreScript = Boolean.FALSE;
+ }
+ }
+
+ return usePreScript.booleanValue();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setUsePreScript(boolean)
+ */
+ @Override
+ public void setUsePreScript(boolean usePreScript) {
+ this.usePreScript = usePreScript;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getPreScript()
+ */
+ @Override
+ public String getPreScript() {
+
+ if (preScript == null) {
+
+ if (propertiesParameters != null) {
+ preScript = propertiesParameters.getProperty("preScript", "");
+ } else {
+ preScript = "";
+ }
+ }
+
+ return preScript;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setPreScript(java.lang.String)
+ */
+ @Override
+ public void setPreScript(String preScript) {
+ this.preScript = preScript;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getRegionName()
+ */
+ @Override
+ public String getRegionName() {
+
+ if (regionName == null) {
+ if (propertiesParameters != null) {
+ regionName = propertiesParameters.getProperty("regionName", "");
+ } else {
+ // defaut value
+ regionName = "";
+ }
+ }
+
+ return regionName;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setRegionName(java.lang.String)
+ */
+ @Override
+ public void setRegionName(String regionName) {
+ this.regionName = regionName;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getSimulatorName()
+ */
+ @Override
+ public String getSimulatorName() {
+
+ if (simulatorName == null) {
+ if (propertiesParameters != null) {
+ simulatorName = propertiesParameters.getProperty(
+ "simulatorName", "DefaultSimulator.java");
+ } else {
+ simulatorName = "DefaultSimulator.java";
+ }
+ }
+ return simulatorName;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setSimulatorName(java.lang.String)
+ */
+ @Override
+ public void setSimulatorName(String simulatorName) {
+ this.simulatorName = simulatorName;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getResultEnabled()
+ */
+ @Override
+ public Collection<String> getResultEnabled() {
+
+ if (resultEnabled == null) {
+
+ resultEnabled = new LinkedList<String>();
+
+ if (propertiesParameters != null) {
+ String[] resultList = propertiesParameters.getProperty("resultNames", "").split(",");
+ for (String name : resultList) {
+ if (name != null && !"".equals(name)) {
+ resultEnabled.add(name);
+ }
+ }
+ }
+ }
+ return resultEnabled;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setResultEnabled(java.util.Collection)
+ */
+ @Override
+ public void setResultEnabled(Collection<String> resultEnabled) {
+ this.resultEnabled = resultEnabled;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getTagValue()
+ */
+ @Override
+ public Map<String, String> getTagValue() {
+
+ if (tagValue == null) {
+ tagValue = new LinkedHashMap<String, String>();
+
+ if (propertiesParameters != null) {
+ for (Object k : propertiesParameters.keySet()) {
+ if (k.toString().startsWith("tagValue.")) {
+ String key = k.toString().substring("tagValue.".length());
+ String value = propertiesParameters.getProperty(k.toString());
+ getTagValue().put(key, value);
+ }
+ }
+ }
+ }
+
+ return tagValue;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setTagValue(java.util.Map)
+ */
+ @Override
+ public void setTagValue(Map<String, String> tagValue) {
+ this.tagValue = tagValue;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getSimulLogLevel()
+ */
+ @Override
+ public String getSimulLogLevel() {
+
+ if (simulLogLevel == null) {
+
+ if (propertiesParameters != null) {
+ simulLogLevel = propertiesParameters.getProperty("simulLogLevel", "info");
+ } else {
+ simulLogLevel = "info";
+ }
+ }
+
+ return simulLogLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setSimulLogLevel(java.lang.String)
+ */
+ @Override
+ public void setSimulLogLevel(String logLevel) {
+ if (log.isDebugEnabled()) {
+ log.debug(_("isisfish.params.changeLogLev", simulLogLevel,
+ logLevel));
+ }
+ this.simulLogLevel = logLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getScriptLogLevel()
+ */
+ @Override
+ public String getScriptLogLevel() {
+
+ if (scriptLogLevel == null) {
+ if (propertiesParameters != null) {
+ scriptLogLevel = propertiesParameters.getProperty(
+ "scriptLogLevel", "info");
+ } else {
+ scriptLogLevel = "info";
+ }
+ }
+
+ return scriptLogLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setScriptLogLevel(java.lang.String)
+ */
+ @Override
+ public void setScriptLogLevel(String logLevel) {
+ if (log.isDebugEnabled()) {
+ log.debug(_("isisfish.params.changeLogLev", scriptLogLevel,
+ logLevel));
+ }
+ this.scriptLogLevel = logLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#getLibLogLevel()
+ */
+ @Override
+ public String getLibLogLevel() {
+ if (libLogLevel == null) {
+ if (propertiesParameters != null) {
+ libLogLevel = propertiesParameters.getProperty("libLogLevel",
+ "error");
+ } else {
+ libLogLevel = "info";
+ }
+ }
+
+ return libLogLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#setLibLogLevel(java.lang.String)
+ */
+ @Override
+ public void setLibLogLevel(String logLevel) {
+ if (log.isDebugEnabled()) {
+ log.debug(_("isisfish.params.changeLogLev", libLogLevel, logLevel));
+ }
+ this.libLogLevel = logLevel;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isSimulErrorLevel()
+ */
+ @Override
+ public boolean isSimulErrorLevel() {
+ return "error".equals(simulLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isSimulWarnLevel()
+ */
+ @Override
+ public boolean isSimulWarnLevel() {
+ return "warn".equals(simulLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isSimulInfoLevel()
+ */
+ @Override
+ public boolean isSimulInfoLevel() {
+ return "info".equals(simulLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isSimulDebugLevel()
+ */
+ @Override
+ public boolean isSimulDebugLevel() {
+ return "debug".equals(simulLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isScriptErrorLevel()
+ */
+ @Override
+ public boolean isScriptErrorLevel() {
+ return "error".equals(scriptLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isScriptWarnLevel()
+ */
+ @Override
+ public boolean isScriptWarnLevel() {
+ return "warn".equals(scriptLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isScriptInfoLevel()
+ */
+ @Override
+ public boolean isScriptInfoLevel() {
+ return "info".equals(scriptLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isScriptDebugLevel()
+ */
+ @Override
+ public boolean isScriptDebugLevel() {
+ return "debug".equals(scriptLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isLibErrorLevel()
+ */
+ @Override
+ public boolean isLibErrorLevel() {
+ return "error".equals(libLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isLibWarnLevel()
+ */
+ @Override
+ public boolean isLibWarnLevel() {
+ return "warn".equals(libLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isLibInfoLevel()
+ */
+ @Override
+ public boolean isLibInfoLevel() {
+ return "info".equals(libLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#isLibDebugLevel()
+ */
+ @Override
+ public boolean isLibDebugLevel() {
+ return "debug".equals(libLogLevel);
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#copy()
+ */
+ @Override
+ public SimulationParameter copy() {
+ SimulationParameterImpl result = new SimulationParameterImpl();
+
+ if (propertiesParameters != null) {
+ result.propertiesParameters = new SortedProperties();
+ // I think that iteration work better than parameters in contructor
+ result.propertiesParameters.putAll(propertiesParameters);
+ }
+
+ // still needed to be copied, if there is no propertiesParameters
+ result.isisFishVersion = getIsisFishVersion();
+ result.description = getDescription();
+ result.regionName = getRegionName();
+ result.numberOfYear = getNumberOfYear();
+ result.simulatorName = getSimulatorName();
+ result.useOptimization = getUseOptimization();
+ result.useStatistic = getUseStatistic();
+ result.usePreScript = getUsePreScript();
+ result.preScript = getPreScript();
+ result.useAnalysePlan = getUseAnalysePlan();
+ result.analysePlanNumber = getAnalysePlanNumber();
+ if (exportNames != null) {
+ result.exportNames = new LinkedList<String>(exportNames);
+ }
+ if (strategies != null) {
+ result.strategies = new LinkedList<Strategy>(strategies);
+ }
+ if (populations != null) {
+ result.populations = new LinkedList<Population>(populations);
+ }
+ if (rules != null) {
+ result.rules = new LinkedList<Rule>(rules);
+ }
+ if (analysePlans != null) {
+ result.analysePlans = new LinkedList<AnalysePlan>(analysePlans);
+ }
+ if (resultEnabled != null) {
+ result.resultEnabled = new LinkedList<String>(resultEnabled);
+ }
+ if (numbers != null) {
+ result.numbers = new HashMap<Population, MatrixND>(numbers);
+ }
+ if (tagValue != null) {
+ result.tagValue = new HashMap<String, String>(tagValue);
+ }
+ result.simulLogLevel = getSimulLogLevel();
+ result.scriptLogLevel = getScriptLogLevel();
+ result.libLogLevel = getLibLogLevel();
+ result.numberOfSensitivitySimulation = getNumberOfSensitivitySimulation();
+ if (sensitivityExports != null) {
+ result.sensitivityExports = new LinkedList<SensitivityExport>(sensitivityExports);
+ }
+ result.sensitivityCalculator = sensitivityCalculator;
+
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#deepCopy()
+ */
+ @Override
+ public SimulationParameter deepCopy() {
+ Properties props = toProperties();
+ SimulationParameter newInstance = new SimulationParameterImpl();
+ newInstance.fromProperties(props);
+ return newInstance;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append(
+ _("isisfish.params.toString.simulation.done",
+ getIsisFishVersion())).append('\n');
+ result.append("--------------------\n");
+ result.append(getDescription()).append('\n');
+ result.append("--------------------\n");
+
+ if (getUseAnalysePlan()) {
+ result.append(_("isisfish.params.toString.plan.number",
+ getAnalysePlanNumber()));
+ }
+
+ RegionStorage region = getRegion();
+ result.append(_("isisfish.params.toString.fishery", region.getName()));
+ result.append(_("isisfish.params.toString.number.years",
+ getNumberOfYear()));
+
+ // startegies
+ List<Strategy> strs = getStrategies();
+ result.append(_("isisfish.params.toString.strategies"));
+ String sep = "";
+ for (Strategy str : strs) {
+ result.append(sep).append(str.getName());
+ sep = ",";
+ }
+ result.append("\n\n");
+
+ // populations
+ result.append(_("isisfish.params.toString.populations"));
+ sep = "";
+ for (Population pop : getPopulations()) {
+ result.append(sep).append(pop.getName());
+ sep = ",";
+ }
+ result.append("\n\n");
+
+ // rules
+ for (Rule rule : getRules()) {
+ String name = RuleStorage.getName(rule);
+ String param = "";
+ try {
+ param = RuleStorage.getParamAsString(rule);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert rule parameter to string for "
+ + name, eee);
+ }
+ }
+ result.append(_("isisfish.params.toString.rule", name));
+ result.append('\n');
+ result.append(param);
+ result.append("\n");
+
+ }
+ result.append("\n\n");
+
+ // analyse plans
+ for (AnalysePlan plan : getAnalysePlans()) {
+ String name = RuleStorage.getName(plan);
+ String param = "";
+ try {
+ param = AnalysePlanStorage.getParamAsString(plan);
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert plan parameter to string for "
+ + name, eee);
+ }
+ }
+ result.append(_("isisfish.params.toString.plan", name));
+ result.append('\n');
+ result.append(param);
+ result.append('\n');
+
+ }
+ result.append('\n');
+ result.append(_("isisfish.params.toString.script.presimulation"))
+ .append(":\n");
+ result.append(getPreScript());
+ result.append('\n');
+ result.append(_("isisfish.params.toString.simul.logger.level",
+ simulLogLevel));
+ result.append('\n');
+ result.append(_("isisfish.params.toString.script.logger.level",
+ scriptLogLevel));
+ result.append('\n');
+ result.append(_("isisfish.params.toString.lib.logger.level",
+ libLogLevel));
+ result.append('\n');
+ return result.toString();
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#toProperties()
+ */
+ @Override
+ public Properties toProperties() {
+ Properties result = new SortedProperties();
+
+ result.setProperty("isisFishVersion", getIsisFishVersion());
+ result.setProperty("description", getDescription());
+ result.setProperty("regionName", getRegionName());
+ result.setProperty("numberOfYear", String.valueOf(getNumberOfYear()));
+ result.setProperty("simulatorName", getSimulatorName());
+ result.setProperty("useOptimization", String.valueOf(getUseOptimization()));
+ result.setProperty("useStatistic", String.valueOf(getUseStatistic()));
+
+ // strategies
+ if (strategies != null) {
+ String strategyList = "";
+ for (Strategy str : getStrategies()) {
+ strategyList += str.getName() + ",";
+ }
+ result.setProperty("strategies", StringUtil.substring(strategyList, 0, -1));
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("strategies")) {
+ result.setProperty("strategies", propertiesParameters.getProperty("strategies"));
+ }
+ }
+
+ // populations
+ if (populations != null) {
+ String populationList = "";
+ for (Population pop : getPopulations()) {
+ populationList += pop.getName() + ",";
+ MatrixND number = getNumberOf(pop);
+ String numberAsString = String.valueOf(number.toList());
+ result.setProperty("population." + pop.getName() + ".number", numberAsString);
+ }
+ result.setProperty("populations", StringUtil.substring(
+ populationList, 0, -1));
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("populations")) {
+ result.setProperty("populations", propertiesParameters.getProperty("populations"));
+ for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith("population.")) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
+ }
+ }
+ }
+
+ // rules
+ if (rules != null) {
+ String ruleList = "";
+ int ruleIndex = 0;
+ for (Rule rule : getRules()) {
+ ruleList += RuleStorage.getName(rule) + ",";
+ Properties ruleProp = ruleParametertoProperties(ruleIndex++, rule);
+ result.putAll(ruleProp);
+ }
+ result.setProperty("rules", ruleList);
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("rules")) {
+ result.setProperty("rules", propertiesParameters
+ .getProperty("rules"));
+ for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith("rule.")) {
+ result.setProperty(key, propertiesParameters
+ .getProperty(key));
+ }
+ }
+ }
+ }
+
+ // anaylyse plans
+ if (analysePlans != null) {
+ String planList = "";
+ int planIndex = 0;
+ for (AnalysePlan plan : getAnalysePlans()) {
+ planList += AnalysePlanStorage.getName(plan) + ",";
+ Properties planProp = planParametertoProperties(planIndex++, plan);
+ result.putAll(planProp);
+ }
+ result.setProperty("plans", planList);
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("plans")) {
+ result.setProperty("plans", propertiesParameters
+ .getProperty("plans"));
+ for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith("plan.")) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
+ }
+ }
+ }
+
+ // export names
+ String exportList = "";
+ for (String export : getExportNames()) {
+ exportList += export + ",";
+
+ }
+ result.setProperty("exports", exportList);
+
+ // number of sensitivity simulation
+ result.setProperty("numberOfSensitivitySimulation", String
+ .valueOf(getNumberOfSensitivitySimulation()));
+
+ // calculator name
+ if (sensitivityCalculator != null) {
+ String calculatorName = SensitivityStorage
+ .getName(getSensitivityCalculator());
+ result.setProperty("sensitivitycalculator", calculatorName);
+
+ // calculator parameter
+ Properties calculatorParams = sensitivityCalculatorParametertoProperties(
+ 0, getSensitivityCalculator());
+ result.putAll(calculatorParams);
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("sensitivitycalculator")) {
+ result.setProperty("sensitivitycalculator",
+ propertiesParameters.getProperty("sensitivitycalculator"));
+ for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith("sensitivity.")) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
+ }
+ }
+ }
+
+ // sensitivity exports
+ if (sensitivityExports != null) {
+ String sensitivityExportList = "";
+ int sensitivityExportIndex = 0;
+ for (SensitivityExport sensitivityExport : getSensitivityExport()) {
+ sensitivityExportList += SensitivityExportStorage
+ .getName(sensitivityExport) + ",";
+ Properties exportProp = sensitivityExportParametertoProperties(
+ sensitivityExportIndex++, sensitivityExport);
+ result.putAll(exportProp);
+ }
+ result.setProperty("sensitivityexports", sensitivityExportList);
+ } else {
+ if (propertiesParameters != null
+ && propertiesParameters.containsKey("sensitivityexports")) {
+ result.setProperty("sensitivityexports", propertiesParameters
+ .getProperty("sensitivityexports"));
+ for (String key : propertiesParameters.stringPropertyNames()) {
+ if (key.startsWith("sensitivityexport.")) {
+ result.setProperty(key, propertiesParameters.getProperty(key));
+ }
+ }
+ }
+ }
+
+ result.setProperty("usePreScript", String.valueOf(getUsePreScript()));
+ result.setProperty("preScript", getPreScript());
+ result.setProperty("useAnalysePlan", String.valueOf(getUseAnalysePlan()));
+ result.setProperty("analysePlanNumber", String.valueOf(getAnalysePlanNumber()));
+
+ String resultList = "";
+ for (String r : getResultEnabled()) {
+ resultList += r + ",";
+ }
+ result.setProperty("resultNames", resultList);
+
+ for (Map.Entry<String, String> e : getTagValue().entrySet()) {
+ result.setProperty("tagValue." + e.getKey(), e.getValue());
+ }
+
+ result.setProperty("simulLogLevel", getSimulLogLevel());
+ result.setProperty("scriptLogLevel", getScriptLogLevel());
+ result.setProperty("libLogLevel", getLibLogLevel());
+ return result;
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#fromProperties(java.util.Properties)
+ */
+ @Override
+ public void fromProperties(Properties props) {
+
+ // save properties (use full to read again parameter)
+ // for exports, or rules....
+ this.propertiesParameters = props;
+
+ }
+
+ /*
+ * @see fr.ifremer.isisfish.simulator.SimulationParameter2#reloadContextParameters()
+ */
+ @Override
+ public void reloadContextParameters() throws TopiaException {
+
+ // On verifie tout d'abord que l'on ai pas dans une simulation
+ // si on y es, on utilise le context static non null du thread local
+ // Resoud les lazy exceptions des parametres des regles
+ boolean mustClose = false;
+ TopiaContext tx = SimulationContext.get().getDB();
+
+ if (tx == null) {
+ // not in simulation, create transaction
+ tx = getRegion().getStorage().beginTransaction();
+ mustClose = true;
+ }
+
+ // reload rules
+ if (log.isDebugEnabled()) {
+ log.debug("Reloading rules");
+ }
+ for (Rule rule : getRules()) {
+ try {
+ for (Field field : rule.getClass().getFields()) {
+ // le champ ne doit pas être privé
+ if (Modifier.isPublic(field.getModifiers())) {
+ // si le type est topia entity (ou sous classe)
+ if (TopiaEntity.class.isAssignableFrom(field.getType())) {
+ TopiaEntity entity = (TopiaEntity) field.get(rule);
+ // il est possible que les parametres soient null
+ // dans ce cas, il ne faut pas essayer de les recharger
+ if (entity != null) {
+ // reloading
+ TopiaEntity newEntity = tx.findByTopiaId(entity
+ .getTopiaId());
+ field.set(rule, newEntity);
+ }
+ }
+ }
+ }
+ } catch (IllegalArgumentException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't refresh rule field", e);
+ }
+ } catch (IllegalAccessException e) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't access rule field", e);
+ }
+ }
+ }
+
+ // si la transaction a été ouverte (pas dans une simulation)
+ // on la referme
+ if (mustClose) {
+ tx.commitTransaction();
+ tx.closeContext();
+ }
+ }
+}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationItem.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -23,6 +23,7 @@
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterCache;
/**
* Objet representant une simulation qui doit être faite.
@@ -101,7 +102,7 @@
*/
public SimulationItem(SimulationControl control, SimulationParameter param) {
this.control = control;
- this.parameter = param;
+ this.parameter = new SimulationParameterCache(param);
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -31,6 +31,7 @@
import java.rmi.RemoteException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
+import java.util.AbstractMap.SimpleEntry;
import java.util.Comparator;
import java.util.Date;
import java.util.LinkedList;
@@ -39,7 +40,6 @@
import java.util.SortedSet;
import java.util.Timer;
import java.util.TreeSet;
-import java.util.AbstractMap.SimpleEntry;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -52,6 +52,7 @@
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.simulator.SimulationControl;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
import fr.ifremer.isisfish.simulator.launcher.SimulationJob.PostAction;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityException;
@@ -246,7 +247,7 @@
// - un launcher
// - un zip (pour relancement)
// Et il est relance avec un parametre "checkonly"
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
SimulationControl control = new SimulationControl(simulationId);
SimulationItem item = new SimulationItem(control, params);
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/SimulAction.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -66,6 +66,7 @@
import fr.ifremer.isisfish.rule.Rule;
import fr.ifremer.isisfish.simulator.AnalysePlan;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
import fr.ifremer.isisfish.simulator.launcher.SimulatorLauncher;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
@@ -125,7 +126,7 @@
log.debug("Init ");
}
try {
- param = new SimulationParameter();
+ param = new SimulationParameterImpl();
List<String> resultNames = getResultNames();
// put default value in param
param.setSimulatorName(IsisFish.config.getSimulatorClassfile());
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationParameterTest.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -51,7 +51,7 @@
*/
@Test
public void testDefaultProperties() {
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
Assert.assertEquals(IsisConfig.getVersion(), params.getIsisFishVersion());
Assert.assertEquals("", params.getDescription());
@@ -91,14 +91,14 @@
@Test
public void testToPropertiesFromProperties() {
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
params.setIsisFishVersion("3.2.0.4");
params.setDescription("desc");
params.setResultEnabled(Collections.singleton("bakh"));
// make transform
Properties props = params.toProperties();
- SimulationParameter params2 = new SimulationParameter();
+ SimulationParameter params2 = new SimulationParameterImpl();
params2.fromProperties(props);
Assert.assertEquals("3.2.0.4", params2.getIsisFishVersion());
@@ -122,7 +122,7 @@
Properties props = new SortedProperties();
props.load(basicFileStream);
- SimulationParameter param = new SimulationParameter();
+ SimulationParameterImpl param = new SimulationParameterImpl();
param.fromProperties(props);
Assert.assertEquals("3.2.0.6", param.getIsisFishVersion());
@@ -154,11 +154,11 @@
Properties props = new SortedProperties();
props.load(basicFileStream);
- SimulationParameter param = new SimulationParameter();
+ SimulationParameterImpl param = new SimulationParameterImpl();
param.fromProperties(props);
Properties props2 = param.toProperties();
- SimulationParameter param2 = new SimulationParameter();
+ SimulationParameter param2 = new SimulationParameterImpl();
param2.fromProperties(props2);
// test rules
@@ -187,11 +187,11 @@
Properties props = new SortedProperties();
props.load(basicFileStream);
- SimulationParameter param = new SimulationParameter();
+ SimulationParameterImpl param = new SimulationParameterImpl();
param.fromProperties(props);
Properties props2 = param.toProperties();
- SimulationParameter param2 = new SimulationParameter();
+ SimulationParameterImpl param2 = new SimulationParameterImpl();
param2.fromProperties(props2);
// test analyse plans
@@ -212,7 +212,7 @@
Properties props = new SortedProperties();
props.load(basicFileStream);
- SimulationParameter param = new SimulationParameter();
+ SimulationParameter param = new SimulationParameterImpl();
param.fromProperties(props);
// force some properties instantiation
@@ -242,7 +242,7 @@
Properties props = new SortedProperties();
props.load(basicFileStream);
- SimulationParameter param = new SimulationParameter();
+ SimulationParameter param = new SimulationParameterImpl();
param.fromProperties(props);
String toString = param.toString();
@@ -256,7 +256,7 @@
*/
@Test
public void testCopyWithoutPropertiesLoad() {
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
params.setIsisFishVersion("3.2.0.4");
params.setDescription("desc");
params.setResultEnabled(Collections.singleton("bakh"));
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -116,7 +116,7 @@
// init simulation
SimulationContext context = SimulationContext.get();
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
SimulationStorage simulation = SimulationStorage.create("test_1_int", params);
TopiaContext storageContext = simulation.getStorage();
storageContext.createSchema();
@@ -216,7 +216,7 @@
// init simulation
SimulationContext context = SimulationContext.get();
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
SimulationStorage simulation = SimulationStorage.create("test_2_matrix", params);
TopiaContext storageContext = simulation.getStorage();
storageContext.createSchema();
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitorTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitorTest.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitorTest.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -18,18 +18,18 @@
package fr.ifremer.isisfish.simulator.launcher;
+import java.util.AbstractMap.SimpleEntry;
import java.util.Comparator;
import java.util.Date;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.AbstractMap.SimpleEntry;
import org.junit.Assert;
import org.junit.Test;
import fr.ifremer.isisfish.AbstractIsisFishTest;
import fr.ifremer.isisfish.simulator.SimulationControl;
-import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
/**
* Test de la class SimulationMonitor.
@@ -61,11 +61,11 @@
SimulationService service = SimulationService.getService();
SimulationControl control1 = new SimulationControl("test1");
- SimulationItem item1 = new SimulationItem(control1, new SimulationParameter());
+ SimulationItem item1 = new SimulationItem(control1, new SimulationParameterImpl());
SimulationJob job1 = new SimulationJob(service, item1, 0);
SimulationControl control2 = new SimulationControl("test2");
- SimulationItem item2 = new SimulationItem(control2, new SimulationParameter());
+ SimulationItem item2 = new SimulationItem(control2, new SimulationParameterImpl());
SimulationJob job2 = new SimulationJob(service, item2, 0);
Date d = new Date();
Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java
===================================================================
--- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2010-04-29 13:16:36 UTC (rev 3033)
+++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2010-04-29 16:14:25 UTC (rev 3034)
@@ -36,6 +36,7 @@
import fr.ifremer.isisfish.entities.StrategyImpl;
import fr.ifremer.isisfish.entities.Zone;
import fr.ifremer.isisfish.simulator.SimulationParameter;
+import fr.ifremer.isisfish.simulator.SimulationParameterImpl;
import fr.ifremer.isisfish.simulator.sensitivity.DesignPlan;
import fr.ifremer.isisfish.simulator.sensitivity.Factor;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
@@ -156,7 +157,7 @@
@Test(timeout=120 * 1000)
public void testRunSensivitySimulation() {
- SimulationParameter params = new SimulationParameter();
+ SimulationParameter params = new SimulationParameterImpl();
// set params region
params.setRegionName("DemoRegion");
// set population
1
0
r3033 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
by chatellier@users.labs.libre-entreprise.org 29 Apr '10
29 Apr '10
Author: chatellier
Date: 2010-04-29 13:16:36 +0000 (Thu, 29 Apr 2010)
New Revision: 3033
Log:
Fix javadoc
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2010-04-26 15:41:31 UTC (rev 3032)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2010-04-29 13:16:36 UTC (rev 3033)
@@ -212,8 +212,6 @@
* Recupere le TopiaContext d'une region.
*
* @param name le nom de la region a recuperer
- * @param inSimulation this is a hack to known if simulation is requested
- * from a simulation or not
* @return Le TopiaContext contenant la region, si la region n'existait null
* est retourné
*/
1
0
Author: chatellier
Date: 2010-04-26 15:41:31 +0000 (Mon, 26 Apr 2010)
New Revision: 3032
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
isis-fish/trunk/pom.xml
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2010-04-26 15:41:28 UTC (rev 3031)
+++ isis-fish/trunk/pom.xml 2010-04-26 15:41:31 UTC (rev 3032)
@@ -10,7 +10,7 @@
<groupId>ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>3.3.0.3</version>
+ <version>3.3.0.4-SNAPSHOT</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -683,9 +683,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.3.0.3</connection>
- <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.3.0.3</developerConnection>
- <url>https://labs.libre-entreprise.org/scm/viewvc.php/isis-fish/tags/isis-fish-3…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</connection>
+ <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</developerConnection>
+ <url>https://labs.libre-entreprise.org/scm/viewvc.php/isis-fish/trunk/?root=isis…</url>
</scm>
<repositories>
1
0
Author: chatellier
Date: 2010-04-26 15:41:28 +0000 (Mon, 26 Apr 2010)
New Revision: 3031
Log:
[maven-scm] copy for tag isis-fish-3.3.0.3
Added:
isis-fish/tags/isis-fish-3.3.0.3/
1
0
Author: chatellier
Date: 2010-04-26 15:41:23 +0000 (Mon, 26 Apr 2010)
New Revision: 3030
Log:
[maven-release-plugin] prepare release isis-fish-3.3.0.3
Modified:
isis-fish/trunk/pom.xml
Modified: isis-fish/trunk/pom.xml
===================================================================
--- isis-fish/trunk/pom.xml 2010-04-26 14:41:07 UTC (rev 3029)
+++ isis-fish/trunk/pom.xml 2010-04-26 15:41:23 UTC (rev 3030)
@@ -10,7 +10,7 @@
<groupId>ifremer</groupId>
<artifactId>isis-fish</artifactId>
- <version>3.3.0.3-SNAPSHOT</version>
+ <version>3.3.0.3</version>
<!-- POM Relationships : Inheritance : Dependencies -->
<dependencies>
@@ -683,9 +683,9 @@
<!-- *** Build Environment ************************************** -->
<!-- ************************************************************* -->
<scm>
- <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</connection>
- <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/trunk</developerConnection>
- <url>https://labs.libre-entreprise.org/scm/viewvc.php/isis-fish/trunk/?root=isis…</url>
+ <connection>scm:svn:svn://anonymous at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.3.0.3</connection>
+ <developerConnection>scm:svn:svn+ssh://chatellier at labs.libre-entreprise.org/svnroot/isis-fish/isis-fish/tags/isis-fish-3.3.0.3</developerConnection>
+ <url>https://labs.libre-entreprise.org/scm/viewvc.php/isis-fish/tags/isis-fish-3…</url>
</scm>
<repositories>
1
0