Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- 3175 discussions
r3621 - trunk/src/main/java/fr/ifremer/isisfish/datastore
by echatellier@users.forge.codelutin.com 29 Feb '12
by echatellier@users.forge.codelutin.com 29 Feb '12
29 Feb '12
Author: echatellier
Date: 2012-02-29 14:42:52 +0100 (Wed, 29 Feb 2012)
New Revision: 3621
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3621
Log:
Add fixme
Modified:
trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2012-02-29 13:41:12 UTC (rev 3620)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2012-02-29 13:42:52 UTC (rev 3621)
@@ -246,7 +246,7 @@
*
* @return simulation control file
*/
- protected static File getSimulationControlFile(String id) {
+ public static File getSimulationControlFile(String id) {
File result = new File(getSimulationDirectory(id), CONTROL_FILENAME);
return result;
}
@@ -462,6 +462,9 @@
* @return true si la simulation existe déjà
*/
public static boolean localyExists(String name) {
+
+ // FIXME echatellier 20120229 this method can tak huge time
+ // to replace with Directory existence
return getSimulationNames().contains(name);
}
1
0
r3620 - trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by echatellier@users.forge.codelutin.com 29 Feb '12
by echatellier@users.forge.codelutin.com 29 Feb '12
29 Feb '12
Author: echatellier
Date: 2012-02-29 14:41:12 +0100 (Wed, 29 Feb 2012)
New Revision: 3620
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3620
Log:
Improve monitoring second pass algorithm
Modified:
trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2012-02-29 13:25:04 UTC (rev 3619)
+++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationMonitor.java 2012-02-29 13:41:12 UTC (rev 3620)
@@ -732,7 +732,7 @@
// en sens inverse, il le fera carrement moins souvent
for (int simulationIndex = numberOfSimulation - 1; simulationIndex >= 0; --simulationIndex) {
String currentId = asPrefixName + "_" + simulationIndex;
- if (SimulationStorage.localyExists(currentId)) {
+ if (SimulationStorage.getSimulationControlFile(currentId).isFile()) {
SimulationControl currentSimulationControl = new SimulationControl(
currentId);
SimulationStorage.readControl(currentId,
1
0
r3619 - in branches/4.1/src/main: java/fr/ifremer/isisfish/ui/input java/fr/ifremer/isisfish/ui/input/variable resources/i18n
by echatellier@users.forge.codelutin.com 29 Feb '12
by echatellier@users.forge.codelutin.com 29 Feb '12
29 Feb '12
Author: echatellier
Date: 2012-02-29 14:25:04 +0100 (Wed, 29 Feb 2012)
New Revision: 3619
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3619
Log:
Fix variable ui
Modified:
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties
branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2012-02-28 14:25:17 UTC (rev 3618)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/ZoneUI.jaxx 2012-02-29 13:25:04 UTC (rev 3619)
@@ -57,7 +57,7 @@
]]></script>
<JPanel id="body">
<JTabbedPane constraints='BorderLayout.CENTER' id="zoneTab">
- <tab title='isisfish.gear.title'>
+ <tab title='isisfish.zone.title'>
<ZoneBasicsUI id="zoneBasicsUI" bean="{getBean()}" active="{isActive()}"
sensitivity="{isSensitivity()}" constructorParams='this' />
</tab>
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-28 14:25:17 UTC (rev 3618)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-29 13:25:04 UTC (rev 3619)
@@ -217,19 +217,20 @@
break;
} // equation already set by ui component
- try {
+ //try {
// save in db
- TopiaContext context = view.getTopiaContext();
- VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
- dao.update(variable);
- context.commitTransaction();
+ //TopiaContext context = view.getTopiaContext();
+ //VariableDAO dao = IsisFishDAOHelper.getVariableDAO(context);
+ //dao.update(variable);
+ //context.commitTransaction();
+ view.getSaveVerifier().save();
// refresh ui (name change)
TopiaEntityListModel model = (TopiaEntityListModel)view.getVariablesList().getModel();
List<Variable> variables = (List<Variable>)model.getElements();
model.setEntities(variables);
- } catch (TopiaException ex) {
+ /*} catch (TopiaException ex) {
throw new IsisFishRuntimeException("Can't save variable", ex);
- }
+ }*/
}
}
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-28 14:25:17 UTC (rev 3618)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-29 13:25:04 UTC (rev 3619)
@@ -38,6 +38,14 @@
varHandler.initView(EntityVariableUI.this);
}
});
+
+ addPropertyChangeListener(PROPERTY_VARIABLE, new java.beans.PropertyChangeListener() {
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if (evt.getNewValue() == null) {
+ matrixPanel.setMatrix(null);
+ }
+ }
+ });
}
]]></script>
@@ -51,6 +59,7 @@
<JList id="variablesList" cellRenderer="{new VariableListRenderer()}"
model="{new fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel()}"
onValueChanged="getVarHandler().showSelectedVariable(this)"
+ selectionMode="{javax.swing.ListSelectionModel.SINGLE_SELECTION}"
enabled='{isActive()}'/>
</JScrollPane>
</cell>
Modified: branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties
===================================================================
--- branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties 2012-02-28 14:25:17 UTC (rev 3618)
+++ branches/4.1/src/main/resources/i18n/isis-fish_en_GB.properties 2012-02-29 13:25:04 UTC (rev 3619)
@@ -1107,6 +1107,7 @@
isisfish.zone.cells=Zone cells
isisfish.zone.comments=Comments
isisfish.zone.name=Name
+isisfish.zone.title=Zone
matrixAbundance=
matrixCatchPerStrategyMetPerZoneMet=
matrixDiscardsPerStrMetPerZonePop=
Modified: branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties
===================================================================
--- branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2012-02-28 14:25:17 UTC (rev 3618)
+++ branches/4.1/src/main/resources/i18n/isis-fish_fr_FR.properties 2012-02-29 13:25:04 UTC (rev 3619)
@@ -1107,6 +1107,7 @@
isisfish.zone.cells=Cellules de la zone
isisfish.zone.comments=Commentaires
isisfish.zone.name=Nom
+isisfish.zone.title=Zone
matrixAbundance=
matrixCatchPerStrategyMetPerZoneMet=
matrixDiscardsPerStrMetPerZonePop=
1
0
r3618 - trunk/src/main/java/fr/ifremer/isisfish/mexico
by echatellier@users.forge.codelutin.com 28 Feb '12
by echatellier@users.forge.codelutin.com 28 Feb '12
28 Feb '12
Author: echatellier
Date: 2012-02-28 15:25:17 +0100 (Tue, 28 Feb 2012)
New Revision: 3618
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3618
Log:
Fix default charset use on windows
Modified:
trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java 2012-02-28 13:41:45 UTC (rev 3617)
+++ trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java 2012-02-28 14:25:17 UTC (rev 3618)
@@ -155,7 +155,7 @@
Source xmlSource=new SAXSource(new InputSource(new ByteArrayInputStream(unformattedXml.getBytes("UTF-8"))));
StreamResult res = new StreamResult(new ByteArrayOutputStream());
serializer.transform(xmlSource, res);
- return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray());
+ return new String(((ByteArrayOutputStream)res.getOutputStream()).toByteArray(), "UTF-8");
} catch (Exception e) {
throw new IsisFishRuntimeException("Can't format xml", e);
}
1
0
r3617 - in branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity: . distribution
by echatellier@users.forge.codelutin.com 28 Feb '12
by echatellier@users.forge.codelutin.com 28 Feb '12
28 Feb '12
Author: echatellier
Date: 2012-02-28 14:41:45 +0100 (Tue, 28 Feb 2012)
New Revision: 3617
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3617
Log:
Start distribution support
Added:
branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/
branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/Distribution.java
Added: branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/Distribution.java
===================================================================
--- branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/Distribution.java (rev 0)
+++ branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/Distribution.java 2012-02-28 13:41:45 UTC (rev 3617)
@@ -0,0 +1,87 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.simulator.sensitivity.distribution;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Distribution used in sensitivity analysis.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public enum Distribution {
+
+ DBINOM(_(""),
+ new DistibutionParams("size", _("number of trials (zero or more).")),
+ new DistibutionParams("prob", _("probability of success on each trial."))),
+ DCAUCHY(_(""),
+ new DistibutionParams("location", _("location and scale parameters. (location = 0, scale = 1)")),
+ new DistibutionParams("scale", _("location and scale parameters. (location = 0, scale = 1)"))),
+ DCHISQ(_(""),
+ new DistibutionParams("df", _("degrees of freedom (non-negative, but can be non-integer).")),
+ new DistibutionParams("ncp", _("non-centrality parameter (non-negative)."))),
+ DEXP(_(""),
+ new DistibutionParams("rate", _("vector of rates"))),
+ DF(_(""),
+ new DistibutionParams("df1", _("degrees of freedom. ‘Inf’ is allowed.")),
+ new DistibutionParams("df2", _("degrees of freedom. ‘Inf’ is allowed.")),
+ new DistibutionParams("ncp", _("non-centrality parameter. If omitted the central F is assumed."))),
+ DGAMMA(_(""),
+ new DistibutionParams("rate", _("an alternative way to specify the scale.")),
+ new DistibutionParams("shape", _("shape and scale parameters. Must be positive, ‘scale’ strictly.")),
+ new DistibutionParams("scale", _("shape and scale parameters. Must be positive, ‘scale’ strictly."))),
+ DGEOM(_(""),
+ new DistibutionParams("prob", _("probability of success in each trial. ‘0 < prob <= 1’."))),
+ DHYPER(_(""),
+ new DistibutionParams("m", _("the number of white balls in the urn.")),
+ new DistibutionParams("n", _("the number of black balls in the urn.")),
+ new DistibutionParams("k", _("the number of balls drawn from the urn."))),
+ DLNORM(_(""),
+ new DistibutionParams("meanlog", _("mean and standard deviation of the distribution on the log scale with default values of ‘0’ and ‘1’ respectively.")),
+ new DistibutionParams("sdlog", _("mean and standard deviation of the distribution on the log scale with default values of ‘0’ and ‘1’ respectively.")));
+
+ protected String description;
+
+ protected DistibutionParams[] params;
+
+ private Distribution(String description, DistibutionParams... params) {
+ this.description = description;
+ this.params = params;
+ }
+
+ public static class DistibutionParams {
+ protected String name;
+ protected String description;
+ public DistibutionParams(String name, String description) {
+
+ }
+ }
+}
+
Property changes on: branches/4.0.1/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/distribution/Distribution.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
1
0
Author: echatellier
Date: 2012-02-27 10:20:28 +0100 (Mon, 27 Feb 2012)
New Revision: 3616
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3616
Log:
New branche for distribution support
Added:
branches/4.0.1/
Property changes on: branches/4.0.1
___________________________________________________________________
Added: svn:ignore
+ maven.log
target
velocity.log
.classpath
.project
isis-fish.ipr
isis-fish.iws
isis-fish.iml
.settings
bin
nbproject
Inputs_Langoustine
Added: svn:mergeinfo
+
1
0
r3615 - in trunk/src/main/java/fr/ifremer/isisfish: . datastore ui/script util
by echatellier@users.forge.codelutin.com 24 Feb '12
by echatellier@users.forge.codelutin.com 24 Feb '12
24 Feb '12
Author: echatellier
Date: 2012-02-24 17:46:43 +0100 (Fri, 24 Feb 2012)
New Revision: 3615
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3615
Log:
#846 : Scripts comming from community repository often do not work
Modified:
trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityAnalysisStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java
trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
Modified: trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -33,6 +33,7 @@
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.File;
+import java.io.FileFilter;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
@@ -46,6 +47,7 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.i18n.I18n;
@@ -57,14 +59,14 @@
import org.nuiton.widget.SwingSession;
import fr.ifremer.isisfish.cron.CronService;
-import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.FormuleStorage;
import fr.ifremer.isisfish.datastore.RegionStorage;
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
+import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
-import fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage;
+import fr.ifremer.isisfish.datastore.SimulationPlanStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.SimulatorStorage;
import fr.ifremer.isisfish.simulator.launcher.SimulationService;
@@ -140,6 +142,7 @@
try {
initVCS();
initCommunityVCS();
+ checkDuplicatedFiles();
} catch (Exception eee) {
log.warn(_("Error during vcs initialisation"), eee);
}
@@ -530,6 +533,34 @@
}
/**
+ * Look for duplicated file name in official repository and community
+ * repository and rename duplicated in community repository.
+ */
+ protected static void checkDuplicatedFiles() {
+
+ // get official file list
+ List<File> offFiles = FileUtil.getFilteredElements(IsisFish.config.getDatabaseDirectory(), new FileFilter() {
+ @Override
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".java");
+ }
+ }, true);
+
+ // compare it with community repo
+ for (File offFile : offFiles) {
+ File comFile = new File(IsisFish.config.getCommunityDatabaseDirectory()
+ + StringUtils.removeStart(offFile.getAbsolutePath(), IsisFish.config.getDatabaseDirectory().getAbsolutePath()));
+ if (comFile.isFile()) {
+ if (log.isWarnEnabled()) {
+ log.warn("Found file collision for " + comFile.getAbsolutePath());
+ }
+ File newFile = new File(comFile.getParentFile(), "Duplicated_" + comFile.getName());
+ comFile.renameTo(newFile);
+ }
+ }
+ }
+
+ /**
* Display dialog with files list, and specifique label.
*
* @param dialogTitle dialog title
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -27,11 +27,14 @@
import java.io.File;
import java.io.IOException;
+import java.util.Arrays;
import java.util.Collections;
+import java.util.Iterator;
import java.util.List;
import org.nuiton.util.FileUtil;
+import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishRuntimeException;
/**
@@ -42,6 +45,7 @@
* {@link fr.ifremer.isisfish.datastore.ExportStorage},
* {@link fr.ifremer.isisfish.datastore.SimulationPlanStorage},
* {@link fr.ifremer.isisfish.datastore.SensitivityAnalysisStorage}
+ * {@link fr.ifremer.isisfish.datastore.SensitivityExportStorage}
*
* Created: 21 janv. 2006 15:20:24
*
@@ -54,6 +58,49 @@
public abstract class CodeSourceStorage extends VersionStorage {
/**
+ * Location enum to look for script in official repository or
+ * community directory.
+ *
+ * Implements iterable to be used in JavaFileManager.
+ */
+ public static enum Location implements Iterable<File> {
+ OFFICIAL(IsisFish.config.getDatabaseDirectory()),
+ COMMUNITY(IsisFish.config.getCommunityDatabaseDirectory()),
+ ALL(IsisFish.config.getDatabaseDirectory(), IsisFish.config.getCommunityDatabaseDirectory());
+
+ protected File[] directory;
+ private Location(File... directory) {
+ this.directory = directory;
+ }
+
+ public File[] getDirectories() {
+ return directory;
+ }
+
+ /*
+ * @see java.lang.Iterable#iterator()
+ */
+ @Override
+ public Iterator<File> iterator() {
+ List<File> files = Arrays.asList(directory);
+ return files.iterator();
+ }
+ }
+
+ /**
+ * Get non empty location.
+ *
+ * @param location current location (if empty, return {@link Location#All}.
+ */
+ protected static Location[] nonEmptyLocation(Location... location) {
+ Location[] locs = location;
+ if (locs == null || locs.length == 0) {
+ locs = Location.values();
+ }
+ return locs;
+ }
+
+ /**
* Le nom de la classe sans le package.
*/
protected String name = null;
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -37,6 +37,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.util.Doc;
import fr.ifremer.isisfish.util.Docable;
@@ -65,7 +66,7 @@
public static final String EXPORT_TEMPLATE = "templates/script/export.ftl";
@SuppressWarnings("unchecked")
- private static Map<String, ExportStorage> scriptsCache = (Map<String, ExportStorage>) new ReferenceMap();
+ private static Map<String, ExportStorage> exportCache = (Map<String, ExportStorage>) new ReferenceMap();
/**
* Constructeur.
@@ -115,34 +116,38 @@
* Retourne le storage pour l'export demandée
*
* @param name le nom de l'export souhaitée
+ * @param location location to open storage file
* @return Le storage pour l'export
*/
- public static ExportStorage getExport(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- ExportStorage result = scriptsCache.get(cacheName);
+ public static ExportStorage getExport(String name, Location... location) {
+ ExportStorage result = exportCache.get(name);
if (result == null) {
- result = new ExportStorage(getContextDatabaseDirectory(),
- getExportDirectory(), name);
- scriptsCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ ExportStorage storage = new ExportStorage(dir, new File(dir, EXPORT_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ exportCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
-
+
/**
- * Retourne le storage pour l'export demandée
- *
- * @param name le nom de l'export souhaitée
- * @return Le storage pour l'export
+ * Create new export.
+ *
+ * @param name new export to create
+ * @param location location to create storage file
+ * @return new export storage
*/
- public static ExportStorage getCommunityExport(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- ExportStorage result = scriptsCache.get(cacheName);
- if (result == null) {
- result = new ExportStorage(getCommunityDatabaseDirectory(),
- getCommunityExportDirectory(), name);
- scriptsCache.put(cacheName, result);
- }
- return result;
+ public static ExportStorage createExport(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ ExportStorage storage = new ExportStorage(dir, new File(dir, EXPORT_PATH), name);
+ return storage;
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/RegionStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -163,18 +163,16 @@
@Override
public void rename(String toName) throws StorageException {
try {
- String cacheName = getContextDatabaseCacheKey(getName());
- regions.remove(cacheName);
+ regions.remove(getName());
super.rename(toName);
TopiaContext tx = getStorage().beginTransaction();
FisheryRegion region = getFisheryRegion(tx);
region.setName(toName);
tx.commitTransaction();
tx.closeContext();
-
- cacheName = getContextDatabaseCacheKey(toName);
- regions.put(cacheName, this);
+ regions.put(toName, this);
+
// add storage modification event
fireDataChanged(new StorageChangeEvent(this));
@@ -222,8 +220,7 @@
* est retourné
*/
static public RegionStorage getRegion(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- RegionStorage result = regions.get(cacheName);
+ RegionStorage result = regions.get(name);
if (result == null) {
// recherche du repertoire de la region en fonction de la config
File directory = null;
@@ -243,7 +240,7 @@
if (directory.exists()) {
result = new RegionStorage(directory, name);
- regions.put(cacheName, result);
+ regions.put(name, result);
}
}
return result;
@@ -291,8 +288,7 @@
throw new StorageException("Can't create new Region", eee);
}
- String cacheName = getContextDatabaseCacheKey(name);
- regions.put(cacheName, result);
+ regions.put(name, result);
// add storage modification event
fireDataChanged(new StorageChangeEvent(result));
@@ -310,8 +306,7 @@
// add storage modification event
fireDataChanged(new StorageChangeEvent(this));
- String cacheName = getContextDatabaseCacheKey(getName());
- regions.remove(cacheName);
+ regions.remove(getName());
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -37,6 +37,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.rule.Rule;
import fr.ifremer.isisfish.util.Doc;
import fr.ifremer.isisfish.util.Docable;
@@ -121,34 +122,38 @@
* Retourne le storage pour la regle demandée
*
* @param name le nom de la regle souhaitée
+ * @param location location to open storage file
* @return Le storage pour la regle
*/
- static public RuleStorage getRule(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- RuleStorage result = rulesCache.get(cacheName);
+ static public RuleStorage getRule(String name, Location... location) {
+ RuleStorage result = rulesCache.get(name);
if (result == null) {
- result = new RuleStorage(getContextDatabaseDirectory(),
- getRuleDirectory(), name);
- rulesCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ RuleStorage storage = new RuleStorage(dir, new File(dir, RULE_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ rulesCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
/**
- * Retourne le storage pour la regle demandée
- *
- * @param name le nom de la regle souhaitée
- * @return Le storage pour la regle
+ * Create new rule.
+ *
+ * @param name new rule to create
+ * @param location location to rule storage file
+ * @return new rule storage
*/
- static public RuleStorage getCommunityRule(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- RuleStorage result = rulesCache.get(cacheName);
- if (result == null) {
- result = new RuleStorage(getCommunityDatabaseDirectory(),
- getCommunityRuleDirectory(), name);
- rulesCache.put(cacheName, result);
- }
- return result;
+ public static RuleStorage createRule(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ RuleStorage storage = new RuleStorage(dir, new File(dir, RULE_PATH), name);
+ return storage;
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -33,6 +33,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.vcs.VCSException;
/**
@@ -105,34 +106,38 @@
* Retourne le storage pour la regle demandée
*
* @param name le nom de la regle souhaitée
+ * @param location location to open storage file
* @return Le storage pour la regle
*/
- static public ScriptStorage getScript(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- ScriptStorage result = scriptsCache.get(cacheName);
+ static public ScriptStorage getScript(String name, Location... location) {
+ ScriptStorage result = scriptsCache.get(name);
if (result == null) {
- result = new ScriptStorage(getContextDatabaseDirectory(),
- getScriptDirectory(), name);
- scriptsCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ ScriptStorage storage = new ScriptStorage(dir, new File(dir, SCRIPT_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ scriptsCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
-
+
/**
- * Retourne le storage pour la regle demandée
+ * Create new script.
*
- * @param name le nom de la regle souhaitée
- * @return Le storage pour la regle
+ * @param name new script to create
+ * @param location location to script storage file
+ * @return new rule script
*/
- static public ScriptStorage getCommunityScript(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- ScriptStorage result = scriptsCache.get(cacheName);
- if (result == null) {
- result = new ScriptStorage(getCommunityDatabaseDirectory(),
- getCommunityScriptDirectory(), name);
- scriptsCache.put(cacheName, result);
- }
- return result;
+ public static ScriptStorage createScript(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ ScriptStorage storage = new ScriptStorage(dir, new File(dir, SCRIPT_PATH), name);
+ return storage;
}
static public void checkout() throws VCSException {
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityAnalysisStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityAnalysisStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityAnalysisStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric
+ * Copyright (C) 2009 - 2012 Ifremer, CodeLutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -37,6 +37,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.simulator.sensitivity.SensitivityAnalysis;
import fr.ifremer.isisfish.util.Doc;
import fr.ifremer.isisfish.util.Docable;
@@ -117,32 +118,38 @@
* Retourne le storage pour le calculateur demandé.
*
* @param name le nom du calculateur souhaité
+ * @param location location to open storage file
* @return Le {@link SensitivityAnalysisStorage} pour le calculateur
*/
- public static SensitivityAnalysisStorage getSensitivityAnalysis(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- SensitivityAnalysisStorage result = sensitivityCache.get(cacheName);
+ static public SensitivityAnalysisStorage getSensitivityAnalysis(String name, Location... location) {
+ SensitivityAnalysisStorage result = sensitivityCache.get(name);
if (result == null) {
- result = new SensitivityAnalysisStorage(getContextDatabaseDirectory(), getSensitivityAnalysisDirectory(), name);
- sensitivityCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ SensitivityAnalysisStorage storage = new SensitivityAnalysisStorage(dir, new File(dir, SENSITIVITY_ANALYSIS_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ sensitivityCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
-
+
/**
- * Retourne le storage pour le calculateur demandé.
- *
- * @param name le nom du calculateur souhaité
- * @return Le {@link SensitivityAnalysisStorage} pour le calculateur
+ * Create new sensitivity analysis.
+ *
+ * @param name new sensitivity analysis to create
+ * @param location location to sensitivity analysis storage file
+ * @return new sensitivity analysis storage
*/
- public static SensitivityAnalysisStorage getCommunitySensitivityAnalysis(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- SensitivityAnalysisStorage result = sensitivityCache.get(cacheName);
- if (result == null) {
- result = new SensitivityAnalysisStorage(getCommunityDatabaseDirectory(), getCommunitySensitivityAnalysisDirectory(), name);
- sensitivityCache.put(cacheName, result);
- }
- return result;
+ public static SensitivityAnalysisStorage createSensitivityAnalysis(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ SensitivityAnalysisStorage storage = new SensitivityAnalysisStorage(dir, new File(dir, SENSITIVITY_ANALYSIS_PATH), name);
+ return storage;
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -33,6 +33,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.export.SensitivityExport;
import fr.ifremer.isisfish.util.Docable;
import fr.ifremer.isisfish.vcs.VCSException;
@@ -107,34 +108,38 @@
* Retourne le storage pour l'export demandé.
*
* @param name le nom de la export souhaitée
+ * @param location location to open storage file
* @return Le storage pour l'export
*/
- public static SensitivityExportStorage getSensitivityExport(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- SensitivityExportStorage result = sensitivityExportsCache.get(cacheName);
+ public static SensitivityExportStorage getSensitivityExport(String name, Location... location) {
+ SensitivityExportStorage result = sensitivityExportsCache.get(name);
if (result == null) {
- result = new SensitivityExportStorage(getContextDatabaseDirectory(),
- getSensitivityExportDirectory(), name);
- sensitivityExportsCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ SensitivityExportStorage storage = new SensitivityExportStorage(dir, new File(dir, SENSITIVITY_EXPORT_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ sensitivityExportsCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
/**
- * Retourne le storage pour l'export demandé.
- *
- * @param name le nom de l'export souhaitée
- * @return Le storage pour l'export
+ * Create new sensitivity export.
+ *
+ * @param name new sensitivity export to create
+ * @param location location to sensitivity export storage file
+ * @return new sensitivity export storage
*/
- public static SensitivityExportStorage getCommunitySensitivityExport(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- SensitivityExportStorage result = sensitivityExportsCache.get(cacheName);
- if (result == null) {
- result = new SensitivityExportStorage(getCommunityDatabaseDirectory(),
- getCommunitySensitivityExportDirectory(), name);
- sensitivityExportsCache.put(cacheName, result);
- }
- return result;
+ public static SensitivityExportStorage createSensitivityExport(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ SensitivityExportStorage storage = new SensitivityExportStorage(dir, new File(dir, SENSITIVITY_EXPORT_PATH), name);
+ return storage;
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -37,6 +37,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.simulator.SimulationPlan;
import fr.ifremer.isisfish.util.Doc;
import fr.ifremer.isisfish.util.Docable;
@@ -118,34 +119,38 @@
* Retourne le storage pour le plan demandé.
*
* @param name le nom du plan souhaité
+ * @param location location to open storage file
* @return Le storage pour le plan
*/
- static public SimulationPlanStorage getSimulationPlan(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- SimulationPlanStorage result = plansCache.get(cacheName);
+ static public SimulationPlanStorage getSimulationPlan(String name, Location... location) {
+ SimulationPlanStorage result = plansCache.get(name);
if (result == null) {
- result = new SimulationPlanStorage(getContextDatabaseDirectory(),
- getSimulationPlanDirectory(), name);
- plansCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ SimulationPlanStorage storage = new SimulationPlanStorage(dir, new File(dir, SIMULATION_PLAN_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ plansCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
-
+
/**
- * Retourne le storage pour le plan demandé.
- *
- * @param name le nom du plan souhaité
- * @return Le storage pour le plan
+ * Create new simulation plan.
+ *
+ * @param name new simulation plan to create
+ * @param location location to simulation plan storage file
+ * @return new simulation plan storage
*/
- static public SimulationPlanStorage getCommunitySimulationPlan(String name) {
- String cacheName = getCommunityDatabaseCacheKey(name);
- SimulationPlanStorage result = plansCache.get(cacheName);
- if (result == null) {
- result = new SimulationPlanStorage(getCommunityDatabaseDirectory(),
- getCommunitySimulationPlanDirectory(), name);
- plansCache.put(cacheName, result);
- }
- return result;
+ public static SimulationPlanStorage createSimulationPlan(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ SimulationPlanStorage storage = new SimulationPlanStorage(dir, new File(dir, SIMULATION_PLAN_PATH), name);
+ return storage;
}
/**
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2005 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2005 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -33,6 +33,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.simulator.Simulator;
import fr.ifremer.isisfish.vcs.VCSException;
@@ -105,36 +106,38 @@
* {@link SimulatorStorage} is cached by name.
*
* @param name le nom de la regle souhaitée
+ * @param location location to open storage file
* @return Le storage pour la regle
*/
- static public SimulatorStorage getSimulator(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- SimulatorStorage result = simulatorsCache.get(cacheName);
+ static public SimulatorStorage getSimulator(String name, Location... location) {
+ SimulatorStorage result = simulatorsCache.get(name);
if (result == null) {
- result = new SimulatorStorage(getContextDatabaseDirectory(),
- getSimulatorDirectory(), name);
- simulatorsCache.put(cacheName, result);
+ Location[] locs = nonEmptyLocation(location);
+ for (int i = 0; i < locs.length && result == null; i++) {
+ Location loc = locs[i];
+ for (File dir : loc.getDirectories()) {
+ SimulatorStorage storage = new SimulatorStorage(dir, new File(dir, SIMULATOR_PATH), name);
+ if (storage.getFile().isFile()) {
+ result = storage;
+ simulatorsCache.put(name, result);
+ }
+ }
+ }
}
return result;
}
-
+
/**
- * Retourne le storage pour le simulateur demandée.
+ * Create new simulation plan.
*
- * {@link SimulatorStorage} is cached by name.
- *
- * @param name le nom de la regle souhaitée
- * @return Le storage pour la regle
+ * @param name new simulation plan to create
+ * @param location location to simulation plan storage file
+ * @return new simulation plan storage
*/
- static public SimulatorStorage getCommunitySimulator(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
- SimulatorStorage result = simulatorsCache.get(cacheName);
- if (result == null) {
- result = new SimulatorStorage(getCommunityDatabaseDirectory(),
- getCommunitySimulatorDirectory(), name);
- simulatorsCache.put(cacheName, result);
- }
- return result;
+ public static SimulatorStorage createSimulator(String name, Location location) {
+ File dir = location.getDirectories()[0];
+ SimulatorStorage storage = new SimulatorStorage(dir, new File(dir, SIMULATOR_PATH), name);
+ return storage;
}
static public void checkout() throws VCSException {
Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin, Chatellier Eric
+ * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -106,30 +106,6 @@
}
/**
- * Get cache storage key to use depending on context storage used.
- *
- * Two simulation must have their own cache.
- *
- * @return context cache key
- */
- protected static String getContextDatabaseCacheKey(String key) {
- String result = getContextDatabaseDirectory().getAbsolutePath() + key;
- return result;
- }
-
- /**
- * Get cache storage key to use depending on context storage used.
- *
- * Two simulation must have their own cache and community scripts too.
- *
- * @return context cache key
- */
- protected static String getCommunityDatabaseCacheKey(String key) {
- String result = getCommunityDatabaseDirectory().getAbsolutePath() + key;
- return result;
- }
-
- /**
* Get VCS instance for storage file.
*
* @return vcs instance
Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2012 Ifremer, Code Lutin, Cédric Pineau, 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
@@ -66,6 +66,7 @@
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.datastore.CodeSourceStorage;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.FormuleStorage;
import fr.ifremer.isisfish.datastore.JavaSourceStorage;
@@ -291,26 +292,26 @@
Language.JAVA);
break;
case CommunitySimulationPlan:
- script = SimulationPlanStorage.getCommunitySimulationPlan(fileName);
+ script = SimulationPlanStorage.getSimulationPlan(fileName, Location.COMMUNITY);
break;
case CommunityExport:
- script = ExportStorage.getCommunityExport(fileName);
+ script = ExportStorage.createExport(fileName, Location.COMMUNITY);
break;
case CommunityRule:
- script = RuleStorage.getCommunityRule(fileName);
+ script = RuleStorage.createRule(fileName, Location.COMMUNITY);
break;
case CommunityScript:
- script = ScriptStorage.getCommunityScript(fileName);
+ script = ScriptStorage.createScript(fileName, Location.COMMUNITY);
break;
case CommunitySimulator:
- script = SimulatorStorage.getCommunitySimulator(fileName);
+ script = SimulatorStorage.createSimulator(fileName, Location.COMMUNITY);
break;
case CommunitySensitivity:
- script = SensitivityAnalysisStorage.getCommunitySensitivityAnalysis(fileName);
+ script = SensitivityAnalysisStorage.createSensitivityAnalysis(fileName, Location.COMMUNITY);
break;
case CommunitySensitivityExport:
script = SensitivityExportStorage
- .getCommunitySensitivityExport(fileName);
+ .createSensitivityExport(fileName, Location.COMMUNITY);
break;
default:
if (log.isErrorEnabled()) {
@@ -435,46 +436,46 @@
}
break;
case Rule:
- script = RuleStorage.getRule(file.getName());
+ script = RuleStorage.getRule(file.getName(), Location.OFFICIAL);
break;
case SimulationPlan:
- script = SimulationPlanStorage.getSimulationPlan(file.getName());
+ script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.OFFICIAL);
break;
case Export:
- script = ExportStorage.getExport(file.getName());
+ script = ExportStorage.getExport(file.getName(), Location.OFFICIAL);
break;
case Script:
- script = ScriptStorage.getScript(file.getName());
+ script = ScriptStorage.getScript(file.getName(), Location.OFFICIAL);
break;
case Simulator:
- script = SimulatorStorage.getSimulator(file.getName());
+ script = SimulatorStorage.getSimulator(file.getName(), Location.OFFICIAL);
break;
case Sensitivity:
- script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName());
+ script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.OFFICIAL);
break;
case SensitivityExport:
- script = SensitivityExportStorage.getSensitivityExport(file.getName());
+ script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.OFFICIAL);
break;
case CommunityRule:
- script = RuleStorage.getCommunityRule(file.getName());
+ script = RuleStorage.getRule(file.getName(), Location.COMMUNITY);
break;
case CommunitySimulationPlan:
- script = SimulationPlanStorage.getCommunitySimulationPlan(file.getName());
+ script = SimulationPlanStorage.getSimulationPlan(file.getName(), Location.COMMUNITY);
break;
case CommunityExport:
- script = ExportStorage.getCommunityExport(file.getName());
+ script = ExportStorage.getExport(file.getName(), Location.COMMUNITY);
break;
case CommunityScript:
- script = ScriptStorage.getCommunityScript(file.getName());
+ script = ScriptStorage.getScript(file.getName(), Location.COMMUNITY);
break;
case CommunitySimulator:
- script = SimulatorStorage.getCommunitySimulator(file.getName());
+ script = SimulatorStorage.getSimulator(file.getName(), Location.COMMUNITY);
break;
case CommunitySensitivity:
- script = SensitivityAnalysisStorage.getCommunitySensitivityAnalysis(file.getName());
+ script = SensitivityAnalysisStorage.getSensitivityAnalysis(file.getName(), Location.COMMUNITY);
break;
case CommunitySensitivityExport:
- script = SensitivityExportStorage.getCommunitySensitivityExport(file.getName());
+ script = SensitivityExportStorage.getSensitivityExport(file.getName(), Location.COMMUNITY);
break;
default:
log.fatal("ScriptType unknown: " + file.getName());
Modified: trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
===================================================================
--- trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2012-02-20 12:12:45 UTC (rev 3614)
+++ trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2012-02-24 16:46:43 UTC (rev 3615)
@@ -40,6 +40,7 @@
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
import org.apache.commons.lang3.StringUtils;
@@ -50,6 +51,7 @@
import com.sun.tools.javac.api.JavacTool;
import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location;
import fr.ifremer.isisfish.datastore.JavaSourceStorage;
/**
@@ -188,12 +190,6 @@
List<File> classpath = new ArrayList<File>();
classpath.add(rootSrc.getAbsoluteFile());
- // FIXME echatellier 20110617 : hack depuis qu'il y a un
- // nouveau dossier de sources de script "communauté", mais
- // qui peu dépendre de sources du dossier "officiel"
- if (rootSrc.equals(IsisFish.config.getCommunityDatabaseDirectory())) {
- classpath.add(IsisFish.config.getDatabaseDirectory());
- }
result = compile(classpath, src, dest, out);
} catch (Exception eee) {
@@ -227,6 +223,7 @@
// JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler
.getStandardFileManager(null, null, null);
+ fileManager.setLocation(StandardLocation.SOURCE_PATH, Location.ALL);
Iterable<? extends JavaFileObject> compilationUnits = fileManager
.getJavaFileObjectsFromFiles(src);
1
0
r3614 - in branches/4.1/src/main: java/fr/ifremer/isisfish/entities java/fr/ifremer/isisfish/simulator java/fr/ifremer/isisfish/ui/input/variable xmi
by echatellier@users.forge.codelutin.com 20 Feb '12
by echatellier@users.forge.codelutin.com 20 Feb '12
20 Feb '12
Author: echatellier
Date: 2012-02-20 13:12:45 +0100 (Mon, 20 Feb 2012)
New Revision: 3614
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3614
Log:
Replace "type" string by enumeration.
Add equation and matrix output
Added:
branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableType.java
Modified:
branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java
branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java
branches/4.1/src/main/xmi/isis-fish.properties
branches/4.1/src/main/xmi/isis-fish.zargo
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -41,9 +41,13 @@
private static final long serialVersionUID = 3978428224373810278L;
/*
- private static Log log = LogFactory.getLog(VariableImpl.class);
+ private static Log log = LogFactory.getLog(VariableImpl.class); */
- @Override
+ public VariableImpl() {
+ setType(VariableType.DOUBLE);
+ }
+
+ /*@Override
public void setDoubleValue(double doubleValue) {
super.setDoubleValue(doubleValue);
super.setMatrixValue(null);
Added: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableType.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableType.java (rev 0)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableType.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -0,0 +1,41 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.entities;
+
+/**
+ * Variable type.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public enum VariableType {
+ DOUBLE,
+ EQUATION,
+ MATRIX
+}
Property changes on: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableType.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationContext.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -81,6 +81,7 @@
protected Set<SimulationListener> simulationListeners = new LinkedHashSet<SimulationListener>();
protected ClassLoader classLoader = null;
protected File scriptDirectory;
+ protected TimeStep timeStep;
/** TopiaContext must be used by rule action to modify data */
protected TopiaContext db = null;
@@ -320,6 +321,26 @@
}
/**
+ * Set simulation current time step.
+ *
+ * @param timeStep current time step
+ * @since 4.1.0.0
+ */
+ public void setTimeStep(TimeStep timeStep) {
+ this.timeStep = timeStep;
+ }
+
+ /**
+ * Get simulation current time step.
+ *
+ * @return current time step
+ * @since 4.1.0.0
+ */
+ public TimeStep getTimeStep() {
+ return timeStep;
+ }
+
+ /**
* Script directory to use.
*
* Used to chnage isis-database-3 directory in running simulation context.
@@ -392,6 +413,7 @@
*
* @param entity entity
* @return map object for this class
+ * @since 4.1.0.0
*/
public SimulationVariable get(TopiaEntity entity) {
SimulationVariable v = variablesCache.get(entity);
@@ -405,16 +427,16 @@
/**
* Save all cached context values.
*
- * @param step
+ * @since 4.1.0.0
*/
- public void saveContextValues(TimeStep step) {
+ public void saveContextValues() {
File exportFile = new File(getScriptDirectory(), "variables.txt");
Writer out = null;
try {
out = new FileWriter(exportFile, true);
- out.write("=========== Step : " + step.toString() + " ===========\n");
+ out.write("=========== Step : " + timeStep.toString() + " ===========\n");
for (Map.Entry<TopiaEntity, SimulationVariable> entry : variablesCache.entrySet()) {
TopiaEntity entity = entry.getKey();
SimulationVariable simVariable = entry.getValue();
@@ -432,13 +454,17 @@
out.write(name + " ");
out.write(variable.getName());
out.write(" = ");
-
- if ("double".equals(variable.getType())) {
+
+ switch (variable.getType()) {
+ case DOUBLE:
out.write(String.valueOf(variable.getDoubleValue()));
- } else if ("matrix".equals(variable.getType())) {
- out.write("todo matrix");
- } else if ("equation".equals(variable.getType())) {
- out.write("todo equation");
+ break;
+ case MATRIX:
+ out.write(variable.getMatrixValue().toString());
+ break;
+ case EQUATION:
+ out.write(String.valueOf(simVariable.eval(variable)));
+ break;
}
out.write("\n");
}
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -46,6 +46,7 @@
*
* @author chatellier
* @version $Revision$
+ * @since 4.1.0.0
*
* Last update : $Date$
* By : $Author$
@@ -148,15 +149,25 @@
*/
public double eval(String name) throws TopiaException {
Variable v = getVariableEntity(name);
+ return eval(v);
+ }
+
+ /**
+ * Eval current variable equation.
+ *
+ * @param v variable
+ * @return equation result
+ */
+ protected double eval(Variable v) {
Equation eq = v.getEquationValue();
Map<String, Object> args = new HashMap<String, Object>();
args.put("context", simulationContext);
args.put("entity", topiaEntity);
- args.put("step", new TimeStep()); // FIXME echatellier how to get real timestep value ?
+ args.put("step", simulationContext.getTimeStep());
Object val = EvaluatorHelper.evaluate("fr.ifremer.isisfish.equation",
- topiaEntity.getTopiaId() + "#" + name, VariableEquation.class,
+ topiaEntity.getTopiaId() + "#" + v.getName(), VariableEquation.class,
eq.getContent(), args);
double result = 0.0;
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -42,6 +42,7 @@
import fr.ifremer.isisfish.IsisFishRuntimeException;
import fr.ifremer.isisfish.entities.Variable;
import fr.ifremer.isisfish.entities.VariableDAO;
+import fr.ifremer.isisfish.entities.VariableType;
import fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel;
/**
@@ -97,8 +98,7 @@
Variable variable = dao.create(
Variable.PROPERTY_ENTITY_ID, view.getBean().getTopiaId(),
- Variable.PROPERTY_NAME, _("isisfish.variables.defaultname"),
- Variable.PROPERTY_TYPE, "double");
+ Variable.PROPERTY_NAME, _("isisfish.variables.defaultname"));
TopiaEntityListModel model = (TopiaEntityListModel)view.getVariablesList().getModel();
List<Variable> variables = (List<Variable>)model.getElements();
@@ -174,14 +174,18 @@
*/
public void showSelectedType(EntityVariableUI view) {
CardLayout cardLayout = view.getVariableTypeLayout();
- String type = (String)view.getVariableTypeCombo().getSelectedItem();
+ VariableType type = (VariableType)view.getVariableTypeCombo().getSelectedItem();
view.getVariable().setType(type);
- if ("double".equals(type)) {
+ switch (type) {
+ case DOUBLE:
cardLayout.show(view.getVariableTypePanel(), "doubletype");
- } else if ("matrix".equals(type)) {
- cardLayout.show(view.getVariableTypePanel(), "matrixtype");
- } else if ("equation".equals(type)) {
+ break;
+ case EQUATION:
cardLayout.show(view.getVariableTypePanel(), "equationtype");
+ break;
+ case MATRIX:
+ cardLayout.show(view.getVariableTypePanel(), "matrixtype");
+ break;
}
}
@@ -195,10 +199,10 @@
Variable variable = (Variable)variableList.getSelectedValue();
variable.setName(view.getVariableNameField().getText().trim());
- String type = (String)view.getVariableTypeCombo().getSelectedItem();
- //variable.setType((String)view.getVariableTypeCombo().getSelectedItem());
+ VariableType type = (VariableType)view.getVariableTypeCombo().getSelectedItem();
- if ("double".equals(type)) {
+ switch (type) {
+ case DOUBLE:
try {
double v = Double.parseDouble(view.getVariableDoubleValue().getText().trim());
variable.setDoubleValue(v);
@@ -207,16 +211,11 @@
log.warn("Can't parse double value as double", ex);
}
}
- } else if ("matrix".equals(type)) {
+ break;
+ case MATRIX:
variable.setMatrixValue(view.getMatrixPanel().getMatrix());
- } /*else if ("equation".equals(type)) {
- Equation eq = variable.getEquationValue();
- if (eq == null) {
- eq = new EquationImpl();
- }
- eq.setContent(view.getVariableDoubleValue().getText());
- variable.setEquationValue(eq);
- }*/
+ break;
+ } // equation already set by ui component
try {
// save in db
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/VariableTypeComboModel.java 2012-02-20 12:12:45 UTC (rev 3614)
@@ -30,6 +30,8 @@
import javax.swing.DefaultComboBoxModel;
+import fr.ifremer.isisfish.entities.VariableType;
+
/**
* Modele pour la liste des type possible de variable.
*
@@ -45,16 +47,13 @@
private static final long serialVersionUID = 6171850179969290032L;
/** Values list */
- protected List<String> variableTypes;
+ protected VariableType[] variableTypes;
/**
* Empty constructor.
*/
public VariableTypeComboModel() {
- variableTypes = new ArrayList<String>();
- variableTypes.add("double");
- variableTypes.add("equation");
- variableTypes.add("matrix");
+ variableTypes = VariableType.values();
}
/*
@@ -62,7 +61,7 @@
*/
@Override
public Object getElementAt(int index) {
- return variableTypes.get(index);
+ return variableTypes[index];
}
/*
@@ -73,7 +72,7 @@
int size = 0;
if (variableTypes != null) {
- size = variableTypes.size();
+ size = variableTypes.length;
}
return size;
}
Modified: branches/4.1/src/main/xmi/isis-fish.properties
===================================================================
--- branches/4.1/src/main/xmi/isis-fish.properties 2012-02-17 16:37:27 UTC (rev 3613)
+++ branches/4.1/src/main/xmi/isis-fish.properties 2012-02-20 12:12:45 UTC (rev 3614)
@@ -31,6 +31,7 @@
model.tagvalue.java.lang.String=text
model.tagvalue.hibernateProxyInterface=none
model.tagvalue.constantPrefix=PROPERTY_
+model.tagvalue.useEnumerationName=true
fr.ifremer.isisfish.entities.ActiveRule.class.tagvalue.contextable=true
fr.ifremer.isisfish.entities.Cell.class.tagvalue.contextable=true
fr.ifremer.isisfish.entities.EffortDescription.class.tagvalue.contextable=true
Modified: branches/4.1/src/main/xmi/isis-fish.zargo
===================================================================
(Binary files differ)
1
0
r3613 - in branches/4.1/src/main: java/fr/ifremer/isisfish/entities java/fr/ifremer/isisfish/ui/input/variable resources
by echatellier@users.forge.codelutin.com 17 Feb '12
by echatellier@users.forge.codelutin.com 17 Feb '12
17 Feb '12
Author: echatellier
Date: 2012-02-17 17:37:27 +0100 (Fri, 17 Feb 2012)
New Revision: 3613
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3613
Log:
Add factor support for variables.
Modified:
branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
branches/4.1/src/main/resources/sensitivity.properties
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-17 15:36:52 UTC (rev 3612)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-17 16:37:27 UTC (rev 3613)
@@ -27,7 +27,9 @@
import static org.nuiton.i18n.I18n._;
+import org.apache.commons.beanutils.BeanUtils;
import org.nuiton.topia.TopiaException;
+import org.nuiton.topia.persistence.TopiaEntity;
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.IsisFishRuntimeException;
@@ -113,4 +115,19 @@
}
}
+ @Override
+ public String toString() {
+
+ String result = null;
+ try {
+ TopiaEntity entity = getTopiaContext().findByTopiaId(getEntityId());
+ result = BeanUtils.getProperty(entity, "name");
+ } catch (Exception ex) {
+ result = entityId;
+ }
+
+ result += "." + name;
+ return result;
+ }
+
} //VariableImpl
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-17 15:36:52 UTC (rev 3612)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-17 16:37:27 UTC (rev 3613)
@@ -149,6 +149,8 @@
JList variableList = view.getVariablesList();
Variable variable = (Variable)variableList.getSelectedValue();
view.setVariable(variable);
+ view.getSaveVerifier().addCurrentEntity(variable);
+
/*if (variable != null) {
view.getVariableNameField().setText(variable.getName());
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-17 15:36:52 UTC (rev 3612)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-17 16:37:27 UTC (rev 3613)
@@ -105,7 +105,8 @@
<cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'>
<JTextField id="variableDoubleValue" decorator='boxed'
text="{String.valueOf(getVariable().getDoubleValue())}"
- enabled='{isActive() && getVariable() != null}' />
+ enabled='{isActive() && getVariable() != null}'
+ _sensitivityBean='{fr.ifremer.isisfish.entities.Variable.class}' _sensitivityMethod='"DoubleValue"' />
</cell>
</row>
</Table>
@@ -123,6 +124,7 @@
<org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanel"
enabled='{isActive() && getVariable() != null}'
matrix="{getVariable().getMatrixValue() != null ? getVariable().getMatrixValue().copy() : null}"
+ _sensitivityBean='{fr.ifremer.isisfish.entities.Variable.class}' _sensitivityMethod='"MatrixValue"'
dimensionEdit='true' decorator='boxed' />
</cell>
</row>
Modified: branches/4.1/src/main/resources/sensitivity.properties
===================================================================
--- branches/4.1/src/main/resources/sensitivity.properties 2012-02-17 15:36:52 UTC (rev 3612)
+++ branches/4.1/src/main/resources/sensitivity.properties 2012-02-17 16:37:27 UTC (rev 3613)
@@ -64,6 +64,9 @@
TargetSpecies.targetFactorEquation
TripType.minTimeBetweenTrip
TripType.tripDuration
+Variable.doubleValue
+Variable.equationValue
+Variable.matrixValue
VesselType.activityRange
VesselType.length
VesselType.maxTripDuration
1
0
r3612 - in branches/4.1/src/main: java/fr/ifremer/isisfish/entities java/fr/ifremer/isisfish/simulator java/fr/ifremer/isisfish/ui/input/variable xmi
by echatellier@users.forge.codelutin.com 17 Feb '12
by echatellier@users.forge.codelutin.com 17 Feb '12
17 Feb '12
Author: echatellier
Date: 2012-02-17 16:36:52 +0100 (Fri, 17 Feb 2012)
New Revision: 3612
Url: http://forge.codelutin.com/repositories/revision/isis-fish/3612
Log:
Add variable's equation and matrix support
Modified:
branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
branches/4.1/src/main/xmi/isis-fish.zargo
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-17 09:19:34 UTC (rev 3611)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/entities/VariableImpl.java 2012-02-17 15:36:52 UTC (rev 3612)
@@ -25,19 +25,47 @@
package fr.ifremer.isisfish.entities;
-import org.nuiton.math.matrix.MatrixND;
+import static org.nuiton.i18n.I18n._;
+import org.nuiton.topia.TopiaException;
+
+import fr.ifremer.isisfish.IsisFishDAOHelper;
+import fr.ifremer.isisfish.IsisFishRuntimeException;
+import fr.ifremer.isisfish.equation.Language;
+import fr.ifremer.isisfish.equation.VariableEquation;
+
public class VariableImpl extends VariableAbstract {
private static final long serialVersionUID = 3978428224373810278L;
+ /*
+ private static Log log = LogFactory.getLog(VariableImpl.class);
+
@Override
public void setDoubleValue(double doubleValue) {
super.setDoubleValue(doubleValue);
super.setMatrixValue(null);
+
+ deletePreviousEquation();
super.setEquationValue(null);
}
+ /*
+ * Manually delete equation since topia (or hibernate) can't delete
+ * orphan object with many-to-one relations.
+ *
+ protected void deletePreviousEquation() {
+ if (super.getEquationValue() != null) {
+ try {
+ IsisFishDAOHelper.getEquationDAO(getTopiaContext()).delete(super.getEquationValue());
+ } catch (TopiaException ex) {
+ if (log.isErrorEnabled()) {
+ log.error("Can't delete equation", ex);
+ }
+ }
+ }
+ }
+
@Override
public void setEquationValue(Equation equationValue) {
super.setEquationValue(equationValue);
@@ -49,7 +77,40 @@
public void setMatrixValue(MatrixND matrixValue) {
super.setMatrixValue(matrixValue);
super.setDoubleValue(0);
+
+ deletePreviousEquation();
super.setEquationValue(null);
+ }*/
+
+ public void setEquationValueContent(String content) {
+ try {
+ Equation eq = getEquationValue();
+
+ if (eq == null) {
+ EquationDAO dao = IsisFishDAOHelper
+ .getEquationDAO(getTopiaContext());
+ // create Growth equation
+ eq = dao.create();
+ eq.setCategory("Variable");
+ eq.setJavaInterface(VariableEquation.class);
+ eq.setLanguage(Language.JAVA);
+ setEquationValue(eq);
+ }
+
+ eq.setName(getName());
+
+ // Fire
+ String _oldValue = eq.getContent();
+ fireOnPreWrite("content", _oldValue, content);
+
+ eq.setContent(content);
+ eq.update();
+
+ fireOnPostWrite("content", _oldValue, content);
+
+ } catch (TopiaException eee) {
+ throw new IsisFishRuntimeException(_("isisfish.change.equation"), eee);
+ }
}
} //VariableImpl
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java 2012-02-17 09:19:34 UTC (rev 3611)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/simulator/SimulationVariable.java 2012-02-17 15:36:52 UTC (rev 3612)
@@ -104,6 +104,19 @@
}
/**
+ * Return variable value as matrix.
+ *
+ * @param name variable name
+ * @return value as matrix
+ * @throws TopiaException if can't restore variable from db
+ */
+ public MatrixND getAsMatrix(String name) throws TopiaException {
+ Variable v = getVariableEntity(name);
+ MatrixND result = v.getMatrixValue();
+ return result;
+ }
+
+ /**
* Set variable value.
*
* @param name variable name
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-17 09:19:34 UTC (rev 3611)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableHandler.java 2012-02-17 15:36:52 UTC (rev 3612)
@@ -40,8 +40,6 @@
import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.entities.Equation;
-import fr.ifremer.isisfish.entities.EquationImpl;
import fr.ifremer.isisfish.entities.Variable;
import fr.ifremer.isisfish.entities.VariableDAO;
import fr.ifremer.isisfish.ui.input.model.TopiaEntityListModel;
@@ -151,7 +149,7 @@
JList variableList = view.getVariablesList();
Variable variable = (Variable)variableList.getSelectedValue();
view.setVariable(variable);
- if (variable != null) {
+ /*if (variable != null) {
view.getVariableNameField().setText(variable.getName());
String type = variable.getType();
@@ -160,11 +158,11 @@
if ("double".equals(type)) {
view.getVariableDoubleValue().setText(String.valueOf(variable.getDoubleValue()));
} else if ("matrix".equals(type)) {
- //cardLayout.show(view.getVariableTypePanel(), "matrixtype");
+ //view.get
} else if ("equation".equals(type)) {
//cardLayout.show(view.getVariableTypePanel(), "equationtype");
}
- }
+ }*/
}
/**
@@ -175,6 +173,7 @@
public void showSelectedType(EntityVariableUI view) {
CardLayout cardLayout = view.getVariableTypeLayout();
String type = (String)view.getVariableTypeCombo().getSelectedItem();
+ view.getVariable().setType(type);
if ("double".equals(type)) {
cardLayout.show(view.getVariableTypePanel(), "doubletype");
} else if ("matrix".equals(type)) {
@@ -195,7 +194,7 @@
variable.setName(view.getVariableNameField().getText().trim());
String type = (String)view.getVariableTypeCombo().getSelectedItem();
- variable.setType((String)view.getVariableTypeCombo().getSelectedItem());
+ //variable.setType((String)view.getVariableTypeCombo().getSelectedItem());
if ("double".equals(type)) {
try {
@@ -208,14 +207,14 @@
}
} else if ("matrix".equals(type)) {
variable.setMatrixValue(view.getMatrixPanel().getMatrix());
- } else if ("equation".equals(type)) {
+ } /*else if ("equation".equals(type)) {
Equation eq = variable.getEquationValue();
if (eq == null) {
eq = new EquationImpl();
}
eq.setContent(view.getVariableDoubleValue().getText());
variable.setEquationValue(eq);
- }
+ }*/
try {
// save in db
Modified: branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx
===================================================================
--- branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-17 09:19:34 UTC (rev 3611)
+++ branches/4.1/src/main/java/fr/ifremer/isisfish/ui/input/variable/EntityVariableUI.jaxx 2012-02-17 15:36:52 UTC (rev 3612)
@@ -58,7 +58,7 @@
<row>
<cell fill="horizontal">
<JButton text="isisfish.variables.addvariable" onActionPerformed="getVarHandler().addNewVariable(this)"
- enabled='{isActive()}'/>
+ enabled='{isActive()}' decorator='boxed' />
</cell>
</row>
</Table>
@@ -71,8 +71,12 @@
enabled='{isActive() && getVariable() != null}'/>
</cell>
<cell fill="horizontal" weightx='1.0'>
- <JTextField id="variableNameField"
- enabled='{isActive() && getVariable() != null}'/>
+ <JTextField id="variableNameField" text="{getVariable().getName()}"
+ enabled='{isActive() && getVariable() != null}' decorator='boxed' />
+ <javax.swing.text.Document
+ initializer="variableNameField.getDocument()"
+ onInsertUpdate='getVariable().setName(variableNameField.getText())'
+ onRemoveUpdate='getVariable().setName(variableNameField.getText())' />
</cell>
</row>
<row>
@@ -82,8 +86,9 @@
</cell>
<cell fill="horizontal" weightx='1.0'>
<JComboBox id="variableTypeCombo" model="{new VariableTypeComboModel()}"
+ selectedItem="{getVariable().getType()}"
onActionPerformed="getVarHandler().showSelectedType(this)"
- enabled='{isActive() && getVariable() != null}'/>
+ enabled='{isActive() && getVariable() != null}' decorator='boxed' />
</cell>
</row>
<row>
@@ -98,7 +103,9 @@
<JLabel text="isisfish.variables.double.value" enabled='{isActive() && getVariable() != null}' />
</cell>
<cell fill="horizontal" weightx='1.0' anchor="northeast" weighty='1.0'>
- <JTextField id="variableDoubleValue" enabled='{isActive() && getVariable() != null}' />
+ <JTextField id="variableDoubleValue" decorator='boxed'
+ text="{String.valueOf(getVariable().getDoubleValue())}"
+ enabled='{isActive() && getVariable() != null}' />
</cell>
</row>
</Table>
@@ -114,7 +121,9 @@
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<org.nuiton.math.matrix.gui.MatrixPanelEditor id="matrixPanel"
- enabled='{isActive() && getVariable() != null}'/>
+ enabled='{isActive() && getVariable() != null}'
+ matrix="{getVariable().getMatrixValue() != null ? getVariable().getMatrixValue().copy() : null}"
+ dimensionEdit='true' decorator='boxed' />
</cell>
</row>
</Table>
@@ -124,7 +133,13 @@
<row>
<cell fill="both" weightx='1.0' weighty='1.0'>
<fr.ifremer.isisfish.ui.input.InputOneEquationUI id="variableEquationValue"
- active='{isActive() && getVariable() != null}'/>
+ constructorParams='this'
+ active='{isActive() && getVariable() != null}'
+ text='isisfish.common.equation' formuleCategory='Variable'
+ clazz='{fr.ifremer.isisfish.equation.VariableEquation.class}'
+ bean='{getVariable()}' beanProperty='EquationValue'
+ _sensitivityBean='{fr.ifremer.isisfish.entities.Variable.class}' _sensitivityMethod='"EquationValue"'
+ decorator='boxed' />
</cell>
</row>
</Table>
@@ -135,12 +150,14 @@
<cell anchor="west">
<JButton text="isisfish.variables.deletevariable"
onActionPerformed="getVarHandler().deleteVariable(this)"
- enabled='{isActive() && getVariable() != null}'/>
+ enabled='{isActive() && getVariable() != null}'
+ decorator='boxed' />
</cell>
<cell anchor="east" weightx='1.0'>
<JButton text="isisfish.variables.savevariable"
onActionPerformed="getVarHandler().saveVariable(this)"
- enabled='{isActive() && getVariable() != null}'/>
+ enabled='{isActive() && getVariable() != null}'
+ decorator='boxed' />
</cell>
</row>
</Table>
Modified: branches/4.1/src/main/xmi/isis-fish.zargo
===================================================================
(Binary files differ)
1
0