Author: kmorin Date: 2014-11-10 14:51:18 +0000 (Mon, 10 Nov 2014) New Revision: 4130 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4130 Log: merge branches Added: trunk/src/main/assembly/isisfish-log4j2.xml trunk/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java trunk/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java trunk/src/main/java/fr/ifremer/isisfish/util/RUtil.java trunk/src/main/resources/isis-config-4 trunk/src/main/resources/log4j2.xml trunk/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java Removed: trunk/src/main/assembly/isisfish-log4j.properties trunk/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationMeta.java trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/filter/ trunk/src/main/java/fr/ifremer/isisfish/ui/widget/DummyLayerUI.java trunk/src/main/java/fr/ifremer/isisfish/ui/widget/filter/ trunk/src/main/resources/log4j.properties trunk/src/test/java/fr/ifremer/isisfish/ui/widget/filter/ trunk/src/test/resources/VCSConfig-junit_CVS.properties trunk/src/test/resources/VCSConfig-junit_SVN.properties trunk/src/test/resources/isis-database-3_cvs.zip Modified: trunk/ trunk/pom.xml trunk/src/main/assembly/bin.xml trunk/src/main/assembly/isisfish.bat trunk/src/main/assembly/isisfish.sh trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java trunk/src/main/java/fr/ifremer/isisfish/aspect/AspectJUrlClassLoader.java trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageInMemory.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/SimulationStorage.java trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java trunk/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java trunk/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsoleHandler.java trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogMail.java trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java trunk/src/main/java/fr/ifremer/isisfish/mexico/export/RegionExportFactorXML.java trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationProperties.java trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityAnalysis.java trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/FactorHelper.java trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MonthType.java trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/RangeOfValuesType.java trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeUnitType.java trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/ObservationsNodeLoador.java trunk/src/main/java/fr/ifremer/isisfish/ui/logging/console/LogConsoleUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixMapRenderer.java trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorListModel.java trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnReferenceMap.java trunk/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java trunk/src/main/java/fr/ifremer/isisfish/util/ssh/ProxyCommand.java trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java trunk/src/main/resources/i18n/isis-fish_fr_FR.properties trunk/src/main/resources/sensitivity.properties trunk/src/main/xmi/isis-fish.properties trunk/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java trunk/src/test/resources/test-database/rules/TACpoids.java Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/4.0.0-svnkit:3665-3698 /branches/4.0.1:3616-3968 /branches/4.1:3601-3670 + /branches/4.0.0-svnkit:3665-3698 /branches/4.0.1:3616-3968 /branches/4.1:3601-3670 /branches/4.3.0-log4j2:4048-4129 Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/pom.xml 2014-11-10 14:51:18 UTC (rev 4130) @@ -11,7 +11,7 @@ <groupId>fr.ifremer</groupId> <artifactId>isis-fish</artifactId> - <version>4.3.1.1-SNAPSHOT</version> + <version>4.3.2.0-SNAPSHOT</version> <!-- POM Relationships : Inheritance : Dependencies --> <dependencies> @@ -20,35 +20,22 @@ <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-utils</artifactId> - <version>3.0-rc-4</version> + <version>3.0-rc-8</version> <scope>compile</scope> </dependency> - + <dependency> <groupId>org.nuiton</groupId> - <artifactId>nuiton-converter</artifactId> - <version>1.0</version> - <scope>compile</scope> - </dependency> - - <dependency> - <groupId>org.nuiton</groupId> <artifactId>nuiton-config</artifactId> - <version>3.0-alpha-3</version> + <version>3.0-rc-2</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-validator</artifactId> - <version>3.0-rc-1</version> + <version>3.0-rc-2</version> <scope>compile</scope> - <exclusions> - <exclusion> - <artifactId>javassist</artifactId> - <groupId>javassist</groupId> - </exclusion> - </exclusions> </dependency> <dependency> @@ -63,12 +50,6 @@ <artifactId>topia-persistence</artifactId> <version>${topiaVersion}</version> <scope>compile</scope> - <exclusions> - <exclusion> - <artifactId>javassist</artifactId> - <groupId>javassist</groupId> - </exclusion> - </exclusions> </dependency> <dependency> @@ -85,7 +66,22 @@ <scope>compile</scope> </dependency> + <!-- Temp update for log4j 2 detection --> <dependency> + <groupId>org.jboss.logging</groupId> + <artifactId>jboss-logging</artifactId> + <version>3.2.0.Beta1</version> + <scope>runtime</scope> + </dependency> + + <dependency> + <groupId>org.ow2.asm</groupId> + <artifactId>asm</artifactId> + <version>5.0.3</version> + <scope>compile</scope> + </dependency> + + <dependency> <groupId>org.nuiton</groupId> <artifactId>nuiton-profiling</artifactId> <version>3.0</version> @@ -220,30 +216,44 @@ </dependency> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-api</artifactId> + <version>1.7.7</version> + <scope>runtime</scope> + </dependency> + + <dependency> <groupId>commons-logging</groupId> <artifactId>commons-logging</artifactId> <version>1.2</version> </dependency> <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.17</version> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + <version>2.1</version> <scope>compile</scope> </dependency> + + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + <version>2.1</version> + <scope>compile</scope> + </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - <version>1.7.7</version> - <scope>runtime</scope> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-jcl</artifactId> + <version>2.1</version> + <scope>runtime</scope> </dependency> <dependency> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-log4j12</artifactId> - <version>1.7.7</version> - <scope>runtime</scope> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j-impl</artifactId> + <version>2.1</version> + <scope>runtime</scope> </dependency> <dependency> @@ -269,7 +279,7 @@ <dependency> <groupId>com.bbn</groupId> <artifactId>openmap</artifactId> - <version>5.0.4</version> + <version>5.1.3</version> <scope>compile</scope> </dependency> @@ -309,10 +319,16 @@ <!-- ssj pour les calculs stockastiques --> <dependency> - <groupId>ssj</groupId> + <groupId>ca.umontreal.iro</groupId> <artifactId>ssj</artifactId> <version>2.5</version> <scope>runtime</scope> + <exclusions> + <exclusion> + <groupId>dsol</groupId> + <artifactId>dsol-xml</artifactId> + </exclusion> + </exclusions> </dependency> <!-- fin ssj pour les calculs stockastiques --> @@ -322,6 +338,20 @@ <artifactId>svnkit</artifactId> <version>1.8.5</version> <scope>compile</scope> + <exclusions> + <exclusion> + <artifactId>jna</artifactId> + <groupId>net.java.dev.jna</groupId> + </exclusion> + <exclusion> + <artifactId>jsch.agentproxy.connector-factory</artifactId> + <groupId>com.jcraft</groupId> + </exclusion> + <exclusion> + <artifactId>platform</artifactId> + <groupId>net.java.dev.jna</groupId> + </exclusion> + </exclusions> </dependency> <!-- fin svnkit pour communication subversion --> @@ -341,7 +371,7 @@ <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> - <version>17.0</version> + <version>18.0</version> </dependency> <!-- Tests --> @@ -349,19 +379,12 @@ <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> - - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>1.3</version> - <scope>test</scope> - </dependency> </dependencies> <!-- ************************************************************* --> <!-- *** Project Information ************************************* --> <!-- ************************************************************* --> - <name>IsisFish</name> + <name>ISIS-Fish</name> <description>Simulateur de pecherie complexe.</description> <inceptionYear>1999</inceptionYear> @@ -490,11 +513,11 @@ <signatureVersion>1.0</signatureVersion> <!-- Dependencies version --> - <jaxxVersion>2.8.7</jaxxVersion> - <eugeneVersion>2.7.4</eugeneVersion> - <topiaVersion>2.9.1</topiaVersion> + <jaxxVersion>2.15</jaxxVersion> + <eugeneVersion>2.13</eugeneVersion> + <topiaVersion>2.9.2</topiaVersion> <hibernateVersion>4.3.7.Final</hibernateVersion> - <nuitonI18nVersion>3.2</nuitonI18nVersion> + <nuitonI18nVersion>3.3</nuitonI18nVersion> <nuitonWidgetsVersion>1.1.1</nuitonWidgetsVersion> <redmine.releaseFiles>target/isis-fish-${project.version}-bin.zip</redmine.releaseFiles> @@ -519,6 +542,23 @@ </distributionManagement> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <includes> + <include>isis-config-4</include> + </includes> + <filtering>true</filtering> + </resource> + <resource> + <directory>src/main/resources</directory> + <excludes> + <exclude>isis-config-4</exclude> + </excludes> + <filtering>false</filtering> + </resource> + </resources> + <pluginManagement> <plugins> <plugin> @@ -533,10 +573,10 @@ <version>${jaxxVersion}</version> <dependencies> <dependency> - <groupId>org.nuiton.i18n</groupId> - <artifactId>nuiton-i18n</artifactId> - <version>${nuitonI18nVersion}</version> - <scope>compile</scope> + <groupId>com.fifesoft</groupId> + <artifactId>rsyntaxtextarea</artifactId> + <version>2.5.0</version> + <scope>compile</scope> </dependency> </dependencies> </plugin> Modified: trunk/src/main/assembly/bin.xml =================================================================== --- trunk/src/main/assembly/bin.xml 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/assembly/bin.xml 2014-11-10 14:51:18 UTC (rev 4130) @@ -6,7 +6,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 1999 - 2013 Ifremer, CodeLutin, Eric Chatellier + Copyright (C) 1999 - 2014 Ifremer, CodeLutin, Eric Chatellier %% This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -60,7 +60,7 @@ <directory>src/main/assembly</directory> <outputDirectory /> <includes> - <include>isisfish-log4j.properties</include> + <include>isisfish-log4j.xml</include> </includes> </fileSet> </fileSets> Deleted: trunk/src/main/assembly/isisfish-log4j.properties =================================================================== --- trunk/src/main/assembly/isisfish-log4j.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/assembly/isisfish-log4j.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,45 +0,0 @@ -### -# #%L -# IsisFish -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2011 - 2013 Ifremer, CodeLutin, Chatellier Eric -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -# Global logging configuration -log4j.rootLogger=ERROR, stdout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n - -# Package level -log4j.logger.fr.ifremer.isisfish=INFO -log4j.logger.analyseplans=INFO -log4j.logger.exports=INFO -log4j.logger.formules=INFO -log4j.logger.rules=INFO -log4j.logger.scripts=INFO -log4j.logger.sensitivity=INFO -log4j.logger.sensitivityexports=INFO -log4j.logger.simulators=INFO - -# Add your configuration here -#log4j.logger.org.nuiton.j2r=DEBUG Copied: trunk/src/main/assembly/isisfish-log4j2.xml (from rev 4129, branches/4.3.0-log4j2/src/main/assembly/isisfish-log4j2.xml) =================================================================== --- trunk/src/main/assembly/isisfish-log4j2.xml (rev 0) +++ trunk/src/main/assembly/isisfish-log4j2.xml 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + #%L + IsisFish + %% + Copyright (C) 1999 - 2014 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% + --> + +<!-- To use this file, add "-Dlog4j.configurationFile=isisfish-log4j2.xml" on command line --> +<Configuration packages="fr.ifremer.isisfish.logging" strict="true"> + + <Filters> + <SimulationThresholdFilter onMatch="ACCEPT" onMismatch="NEUTRAL" /> + </Filters> + + <Appenders> + + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout pattern="%5p [%t] (%F:%L) %M - %m%n" /> + </Console> + + <Routing name="SimulationSpecificAppender"> + <Routes pattern="$${ctx:simulationId}"> + + <!-- This route is chosen if ThreadContext has no value for key simulationId. --> + <Route key="${ctx:simulationId}"> + <Null name="Null" /> + </Route> + + <!-- This route is chosen if ThreadContext has a value for simulationId + The value dynamically determines the name of the log file. --> + <Route> + <File name="SimulationFileAppender-${ctx:simulationId}" fileName="${ctx:simulationLogFile}"> + <PatternLayout> + <Pattern>%p|%d{ABSOLUTE}|%F|%L|%M|%m%n</Pattern> + </PatternLayout> + </File> + </Route> + </Routes> + </Routing> + </Appenders> + + <Loggers> + <Logger name="fr.ifremer.isisfish" level="info"/> + <Logger name="org.nuiton" level="warn"/> + <Logger name="exports" level="info"/> + <Logger name="formules" level="info"/> + <Logger name="objectives" level="info"/> + <Logger name="optimizations" level="info"/> + <Logger name="rules" level="info"/> + <Logger name="scripts" level="info"/> + <Logger name="sensitivityanalysis" level="info"/> + <Logger name="sensitivityexports" level="info"/> + <Logger name="simulationplans" level="info"/> + <Logger name="simulators" level="info"/> + + <Root level="error"> + <AppenderRef ref="Console" /> + <AppenderRef ref="SimulationSpecificAppender" /> + </Root> + </Loggers> +</Configuration> \ No newline at end of file Modified: trunk/src/main/assembly/isisfish.bat =================================================================== --- trunk/src/main/assembly/isisfish.bat 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/assembly/isisfish.bat 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,8 +1,8 @@ @echo off rem Uncomment following 2 lines to easy configure R for ISIS-Fish -rem SET R_HOME=C:\Program Files\R\R-3.0.0 +rem SET R_HOME=C:\Program Files\R\R-3.1.0 rem SET PATH=%PATH%;%R_HOME%\bin\i386 echo [Script] Isis starting... -java -Xmx900M -Djri.load.classpath.libs=true -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1 +java -Xmx2048M -jar ${project.build.finalName}.${project.packaging} %1 %2 %3 %4 %5 %6 %7 %8 %9 > debug.txt 2>&1 Modified: trunk/src/main/assembly/isisfish.sh =================================================================== --- trunk/src/main/assembly/isisfish.sh 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/assembly/isisfish.sh 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,5 +1,5 @@ #!/bin/bash -MEMORY="-Xmx1024M" +MEMORY="-Xmx2048M" -java $MEMORY -Djri.load.classpath.libs=true -jar ${project.build.finalName}.${project.packaging} $* &> debug.txt +java $MEMORY -jar ${project.build.finalName}.${project.packaging} $* &> debug.txt Modified: trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2012 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric + * Copyright (C) 2002 - 2014 Ifremer, 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 @@ -45,12 +45,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.config.ApplicationConfig; +import org.nuiton.config.ArgumentsParserException; import org.nuiton.config.ConfigOptionDef; -import org.nuiton.converter.ConverterUtil; import org.nuiton.math.matrix.DoubleBigVector; import org.nuiton.math.matrix.DoubleSparseHashVector; import org.nuiton.util.StringUtil; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; +import org.nuiton.util.version.Versions; import fr.ifremer.isisfish.actions.ExportAction; import fr.ifremer.isisfish.actions.ImportAction; @@ -82,6 +83,9 @@ /** Class logger. */ static private Log log = LogFactory.getLog(IsisConfig.class); + /** Numero de version majeure d'isis fish. */ + public static final int ISIS_FISH_MAJOR_VERSION = 4; + /** * Config step after init. * @@ -128,18 +132,10 @@ * migration de donnees demande automatiquement un changement de version * d'application. */ - protected final static Version version = new Version(4, 3, 1, 1); + protected static Version version; + protected static Version databaseVersion; + protected static Version apiVersion; - protected final static Version majorVersion = new Version(version.getNumber(0)); - protected final static Version databaseVersion = new Version( - version.getNumber(0), version.getNumber(1)); - protected final static Version apiVersion = new Version( - version.getNumber(0), version.getNumber(1), version.getNumber(2)); - - public static Version getVersionNumber() { - return version; - } - /** * Le nombre global ex: 3.2.0.0 * @@ -168,9 +164,6 @@ return apiVersion; } - static final public String COPYRIGHT_TEXT = "Version " + getVersion() + " IFREMER-MAERHA © 2000-2014"; - static final public String CONFIG_FILENAME = "isis-config-" + majorVersion.toString(); - /** separateur de liste */ static final public String SEP = ","; @@ -188,15 +181,6 @@ public IsisConfig() { - // fix missing converter for locale - try { - ConverterUtil.registerConverter(Locale.class); - } catch (Exception ex) { - if (log.isWarnEnabled()) { - log.warn("Can't register locale converter", ex); - } - } - for (Option o : Option.values()) { if (o.defaultValue != null) { setDefaultOption(o.key, o.defaultValue); @@ -209,6 +193,26 @@ } } } + + @Override + public ApplicationConfig parse(String... args) throws ArgumentsParserException { + ApplicationConfig config = super.parse(args); + postInitWithVersion(config.getOption("isisfish.version")); + return config; + } + + /** + * Initialize avec des valeurs par defaut des options dans la valeur dépend de la version. + * + * @param fullVersion full version (ex 4.3.1.9) + */ + protected void postInitWithVersion(String fullVersion) { + IsisConfig.version = Versions.valueOf(fullVersion); + IsisConfig.databaseVersion = Versions.extractVersion(IsisConfig.version, 0, 1); + IsisConfig.apiVersion = Versions.extractVersion(IsisConfig.version, 0, 2); + + setDefaultOption(Option.SIMULATOR_SSH_ISIS_HOME.key, "/home3/caparmor/poussin/isis-fish-" + apiVersion.toString()); + } ////////////////////////////////////////////////// // Methode d'acces aux options @@ -1015,10 +1019,10 @@ } /** - * Seuil d'uitilisation des matrices creuse + * Seuil d'utilisation des matrices creuse * * @return - * @since 4.2.0.2 + * @since 4.3.1.0 */ public int getSimulationMatrixThresholdUseSparse() { ApplicationConfig config = SimulationContext.get().getConfig(); @@ -1027,7 +1031,7 @@ } /** - * Seuil d'uitilisation des matrices creuse + * Seuil d'utilisation des matrices creuse * * @return * @since 4.3.1.0 @@ -1043,7 +1047,7 @@ * de temps. * * @return - * @since 4.2.0.2 + * @since 4.3.1.0 */ public int getSimulationStoreResultOnDisk() { ApplicationConfig config = SimulationContext.get().getConfig(); @@ -1055,7 +1059,7 @@ * Indique le nombre de pas qui doivent rester en memoire durant la simulation * * @return - * @since 4.2.0.2 + * @since 4.3.1.0 */ public int getSimulationStoreResultCacheStep() { ApplicationConfig config = SimulationContext.get().getConfig(); @@ -1087,8 +1091,8 @@ */ public static enum Option implements ConfigOptionDef { - CONFIG_FILE(CONFIG_FILE_NAME, n("isisfish.config.main.configFileName.description"), CONFIG_FILENAME), - ISIS_HOME_DIRECTORY("isis.home.directory", n("isisfish.config.main.compileDirectory.description"), getUserHome() + File.separator + "isis-fish-" + majorVersion.toString()), + CONFIG_FILE(CONFIG_FILE_NAME, n("isisfish.config.main.configFileName.description"), "isis-config-" + ISIS_FISH_MAJOR_VERSION), + ISIS_HOME_DIRECTORY("isis.home.directory", n("isisfish.config.main.compileDirectory.description"), getUserHome() + File.separator + "isis-fish-" + ISIS_FISH_MAJOR_VERSION), COMPILATION_DIRECTORY("compilation.directory", n("isisfish.config.main.compileDirectory.description"), "${isis.home.directory}" + File.separator + "isis-build"), MONITORING_DIRECTORY("monitoring.directory", n("isisfish.config.main.monitoringDirectory.description"), "${isis.home.directory}" + File.separator + "isis-monitoring"), JAVADOC_DIRECTORY("javadoc.directory", n("isisfish.config.main.javadocDirectory.description"), "${isis.home.directory}" + File.separator + "isis-docs"), @@ -1131,9 +1135,9 @@ /** Serveur accessible par ssh : user home directory */ SIMULATOR_SSH_USER_HOME("simulation.ssh.userhome", n("isisfish.config.main.simulation.ssh.userhome.description"), ""), /** Serveur accessible par ssh : remote data path */ - SIMULATOR_SSH_DATAPATH("simulation.ssh.datapath", n("isisfish.config.main.simulation.ssh.datapath.description"), "isis-fish-" + majorVersion.toString() + "/isis-database"), + SIMULATOR_SSH_DATAPATH("simulation.ssh.datapath", n("isisfish.config.main.simulation.ssh.datapath.description"), "isis-fish-4/isis-database"), /** Serveur accessible par ssh : remote isis home install */ - SIMULATOR_SSH_ISIS_HOME("simulation.ssh.isis.home", n("isisfish.config.main.simulation.ssh.isis.home.description"), "/home3/caparmor/poussin/isis-fish-" + IsisConfig.getApiVersion()), + SIMULATOR_SSH_ISIS_HOME("simulation.ssh.isis.home", n("isisfish.config.main.simulation.ssh.isis.home.description"), null), /** Serveur accessible par ssh : remote tmp path */ SIMULATOR_SSH_TMPPATH("simulation.ssh.tmppath", n("isisfish.config.main.simulation.ssh.tmppath.description"), "isis-tmp"), /** Serveur accessible par SSH : emplacement de Java (full path) */ Modified: trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/IsisFish.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2005 - 2013 Ifremer, CodeLutin, Chatellier Eric + * Copyright (C) 2005 - 2014 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 @@ -58,7 +58,7 @@ import org.nuiton.i18n.init.DefaultI18nInitializer; import org.nuiton.math.matrix.MatrixFactory; import org.nuiton.topia.TopiaException; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import org.nuiton.widget.SwingSession; import com.bbn.openmap.MapBean; @@ -83,6 +83,7 @@ import fr.ifremer.isisfish.ui.util.ErrorHelper; import fr.ifremer.isisfish.util.IsisCache; import fr.ifremer.isisfish.util.IsisMatrixSemanticMapper; +import fr.ifremer.isisfish.util.RUtil; import fr.ifremer.isisfish.vcs.VCS; import fr.ifremer.isisfish.vcs.VCSActionEvent; import fr.ifremer.isisfish.vcs.VCSException; @@ -120,12 +121,12 @@ } public static void main(String... args) throws Exception { - + // permet de faire fonctionner la compilation en webstart System.setSecurityManager(null); - // set Rtype in jni mode - System.setProperty("R.type", "jni"); + // initialisation de l'application + init(args); // i18n is not inited here if (log.isInfoEnabled()) { @@ -137,13 +138,9 @@ log.info("PATH: " + System.getenv("PATH")); } - // initialisation de l'application - init(args); + // init R way for isis + RUtil.initJri(); - if (log.isDebugEnabled()) { - log.debug(t("isisfish.launch.init.done", config.getElapsedTimeAsString())); - } - // action after init config.doAction(IsisConfig.STEP_AFTER_INIT); @@ -178,6 +175,13 @@ } /** + * Initialize isis fish version from properties files. + */ + protected static void initVersion() { + + } + + /** * Start cron service (if enabled). */ protected static void startCronService() { @@ -253,6 +257,10 @@ // after init shutdown hook Runtime.getRuntime().addShutdownHook(new IsisQuitHook()); + + if (log.isDebugEnabled()) { + log.debug(t("isisfish.launch.init.done", config.getElapsedTimeAsString())); + } } /** Modified: trunk/src/main/java/fr/ifremer/isisfish/aspect/AspectJUrlClassLoader.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/aspect/AspectJUrlClassLoader.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/aspect/AspectJUrlClassLoader.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -71,13 +71,13 @@ adaptor = new AspectJWeavingAdaptor(getParent(), this); } - private static String getAspectPath() { + /*private static String getAspectPath() { return System.getProperty(WEAVING_ASPECT_PATH, ""); } private static String getClassPath() { return System.getProperty(WEAVING_CLASS_PATH, ""); - } + }*/ protected void addURL(URL url) { adaptor.addURL(url); Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageInMemory.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageInMemory.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorageInMemory.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -53,7 +53,7 @@ * Mise a jour: $Date$ * par : $Author$ * - * @deprecated ResultStorageCSV now support no storage and in memory usage + * @deprecated ResultStorageCSV now support no storage and in memory usage, will be removed in version 4.4 */ public class ResultStorageInMemory extends ResultStorageAbstract { Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,7 +32,6 @@ import org.apache.commons.collections4.map.ReferenceMap; import fr.ifremer.isisfish.IsisFish; -import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.export.SensitivityExport; import fr.ifremer.isisfish.vcs.VCSException; Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationPlanStorage.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -36,7 +36,6 @@ import org.apache.commons.logging.LogFactory; import fr.ifremer.isisfish.IsisFish; -import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.simulator.SimulationPlan; import fr.ifremer.isisfish.util.Doc; import fr.ifremer.isisfish.vcs.VCSException; Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulationStorage.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -44,15 +44,14 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.util.FileUtil; -import org.nuiton.util.Version; import org.nuiton.util.ZipUtil; +import org.nuiton.util.version.Versions; import fr.ifremer.isisfish.IsisFish; import fr.ifremer.isisfish.IsisFishDAOHelper; import fr.ifremer.isisfish.IsisFishRuntimeException; import fr.ifremer.isisfish.entities.FisheryRegion; import fr.ifremer.isisfish.entities.FisheryRegionDAO; -import fr.ifremer.isisfish.logging.SimulationLoggerUtil; import fr.ifremer.isisfish.simulator.SimulationControl; import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.simulator.SimulationParameterImpl; @@ -525,11 +524,9 @@ // mais il faut pouvoir relire les anciennes simulations SimulationParameter param = getParameter(); String isisFishVersion = param.getIsisFishVersion(); - Version simuVersion = new Version(isisFishVersion); - Version version4200 = new Version(4, 2, 0, 0); // instancier un ResultStorage ou un ResultMappedStorage - if (simuVersion.before(version4200)) { + if (Versions.smallerThan(isisFishVersion, "4.2.0.0")) { resultStorage = new ResultDatabaseStorage(this); } else { // if user ask for ResultStorageInMemory, used it @@ -870,56 +867,10 @@ } /** - * This method add logger for current simulation - * - * @param simulLogLevel required min level for simulator logger - * @param threadName name of the thread to log (simulation thread) - * @param scriptLogLevel required min level fro scripts logger - * @param libLogLevel required min level for libraries logger - */ - public void addSimulationLogger(String simulLogLevel, - String scriptLogLevel, String libLogLevel, String threadName) { - - try { - SimulationLoggerUtil.addSimulationAppender(getSimulationLogFile(), - getAppenderId(), simulLogLevel, scriptLogLevel, - libLogLevel, threadName); - useLog = true; - } catch (Exception eee) { - useLog = false; - log.warn(t("Can't create simulation logger", eee)); - // we do not throw any exception, this is a shame but not required - } - } - - /** - * this method remove logger for the simulation - */ - public void removeSimulationLogger() { - - try { - String appenderId = getAppenderId(); - SimulationLoggerUtil.removeSimulationAppender(appenderId); - } finally { - useLog = false; - } - } - - /** - * @return the appender id used for this simulation (simulation_name.hashcode()) - */ - protected String getAppenderId() { - //TODO Perharps we could just use simulation name - //TODO since it seems to be unique. - return "simulation_" + Math.abs(hashCode()); - } - - /** * @return the simulation log file */ public String getSimulationLogFile() { File root = getSimulationDirectory(name); - //TODO Should be IsisConfig.DEFAULT_SIMULATION_LOGFILE ? return root + File.separator + "simulation.log"; } Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -37,7 +37,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.ListenerSet; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import fr.ifremer.isisfish.IsisConfig; import fr.ifremer.isisfish.IsisFish; Modified: trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationGroupImpl.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -25,8 +25,6 @@ package fr.ifremer.isisfish.entities; -import static org.nuiton.i18n.I18n.t; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -58,7 +56,7 @@ public double getAge() { double result = 0; if (getPopulation() != null && getPopulation().getSpecies() != null) { - if (getPopulation().getSpecies().getAgeGroupType()) { + if (getPopulation().getSpecies().isAgeGroupType()) { result = super.getAge(); } else { result = getPopulation().getAge(getLength(), this) @@ -75,7 +73,7 @@ public double getLength() { double result = 0.0; if (getPopulation() != null && getPopulation().getSpecies() != null) { - if (!getPopulation().getSpecies().getAgeGroupType()) { + if (!getPopulation().getSpecies().isAgeGroupType()) { result = (getMinLength() + getMaxLength()) / 2.0; } else { result = getPopulation().getLength( Modified: trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/entities/PopulationSeasonInfoImpl.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -423,24 +423,24 @@ if (log.isDebugEnabled()) { log.debug("pop: " + pop + " AgeGroup: " - + pop.getSpecies().getAgeGroupType() + " groupChange: " - + getGroupChange() + " month: " + month + " firstMonth: " + + pop.getSpecies().isAgeGroupType() + " groupChange: " + + isGroupChange() + " month: " + month + " firstMonth: " + getFirstMonth()); } // si en longueur - if (!pop.getSpecies().getAgeGroupType()) { - if (getSimpleLengthChangeMatrix()) { + if (!pop.getSpecies().isAgeGroupType()) { + if (isSimpleLengthChangeMatrix()) { return spacializeLengthChangeMatrix(getLengthChangeMatrix()); } else { return getLengthChangeMatrix(); } - } else if (getGroupChange() + } else if (isGroupChange() && month.getMonthNumber() == getFirstMonth().getMonthNumber()) { // create identity matrix with special 1 for plus group if necessary int nbrAge = pop.sizePopulationGroup(); int nbrZone = pop.sizePopulationZone(); - boolean groupplus = pop.getPlusGroup(); + boolean groupplus = pop.isPlusGroup(); MatrixND result = createSpacializedChangeGroupMatrix(); for (MatrixIterator mi = result.iterator(); mi.next();) { @@ -496,7 +496,7 @@ mat = createSpacializedChangeGroupMatrix(); MatrixHelper.convertToId(mat); - if (getUseEquationMigration()) { + if (isUseEquationMigration()) { // on commence par faire une copie pour ne pas modifier N MatrixND N = MatrixFactory.getInstance().create(aN); @@ -590,7 +590,7 @@ mat = createSpacializedChangeGroupMatrix(); - if (getUseEquationMigration()) { + if (isUseEquationMigration()) { // on commence par faire une copie pour ne pas modifier N MatrixND N = MatrixFactory.getInstance().create(aN); @@ -659,7 +659,7 @@ mat = MatrixFactory.getInstance().create( new int[] { groups.size() * nbSecteur }); - if (getUseEquationMigration()) { + if (isUseEquationMigration()) { // on commence par faire une copie pour ne pas modifier N MatrixND N = MatrixFactory.getInstance().create(aN); @@ -819,7 +819,7 @@ // on commence par faire une copie pour ne pas modifier N MatrixND N = aN.copy(); - if (getReproduction()) { + if (isReproduction()) { //recuperation de l'equation de reproduction Equation e = pop.getReproductionEquation(); Modified: trunk/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/entities/StrategyImpl.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -156,7 +156,7 @@ double result = 0; StrategyMonthInfo info = getStrategyMonthInfo(month); - if (!getInactivityEquationUsed()) { + if (!isInactivityEquationUsed()) { result = info.getMinInactivityDays(); } else { try { Modified: trunk/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/entities/TargetSpeciesImpl.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -143,7 +143,7 @@ Equation eq = getTargetFactorEquation(); Species species = getSpecies(); MetierSeasonInfo msi = getMetierSeasonInfo(); - boolean primaryCatch = getPrimaryCatch(); + boolean primaryCatch = isPrimaryCatch(); result = eq.evaluate("group", group, "species", species, "infoMetier", msi, "primaryCatch", primaryCatch); } catch (Exception eee) { Copied: trunk/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java (from rev 4129, branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/NullAppender.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,62 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Ifremer, 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ifremer.isisfish.logging; + +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.appender.AbstractAppender; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; + +/** + * This Appender allows the logging event to be manipulated before it is processed by other Appenders. + */ +@Plugin(name = "Null", category = "Core", elementType = "appender", printObject = true) +public final class NullAppender extends AbstractAppender { + + private NullAppender(final String name) { + super(name, null, null, true); + } + + /** + * Modify the event and pass to the subordinate Appenders. + * @param event The LogEvent. + */ + @Override + public void append(LogEvent event) { + + } + + /** + * Create a RewriteAppender. + * @param name The name of the Appender. + * @return The created RewriteAppender. + */ + @PluginFactory + public static NullAppender createAppender(@PluginAttribute("name") final String name) { + return new NullAppender(name); + } +} + Modified: trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationLoggerUtil.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin, Benjamin Poussin, Tony Chemit + * Copyright (C) 2002 - 2014 Ifremer, Code Lutin, Benjamin Poussin, Tony Chemit * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,25 +25,18 @@ package fr.ifremer.isisfish.logging; -import fr.ifremer.isisfish.IsisFish; -import fr.ifremer.isisfish.IsisFishException; -import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.logging.console.LogConsole; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.log4j.Appender; -import org.apache.log4j.FileAppender; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; import static org.nuiton.i18n.I18n.t; import java.io.File; import java.io.IOException; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.logging.console.LogConsole; + /** * FIXME poussin, a priori cette classe ne supporte pas plusieurs simulation * en meme temps, ce qui est le cas si on a plusieurs processeurs de dispo :( @@ -52,17 +45,8 @@ * Usefull class for dealing with hot configuration of log4J. this is temporary * we must find a way to abstract this layer. * - * the class offers three public static methods : - * - * {@link #addSimulationAppender(String, String, String, String, String, String)} - * to add a logger for a given simulation in a given thread, with simulLogLevel, - * scriptLogLvel and libLogLevel given. - * * {@code #removeAppender(String, String)} to remove a appender of a simulation * - * {@link #showSimulationLogConsole(String)} to display the log console of - * a simulation, given his name. - * * @author chemit */ public class SimulationLoggerUtil { @@ -70,102 +54,10 @@ /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(SimulationLoggerUtil.class); - static private Map<String, Level> simulLevelKeeper = null; - static private Map<String, Level> scriptLevelKeeper = null; - static private Map<String, Level> libLevelKeeper = null; - /** pattern to use for simulation appender */ public static final String LOG_PATTERN = "%p|%d{ABSOLUTE}|%F|%L|%M|%m%n"; - /** les catégories rattachées au logger de simulation. */ - private static final String[] simulLoggerToChange = { - "fr.ifremer.isisfish", - }; - - /** les catégories rattachées au logger de script. */ - private static final String[] scriptLoggerToChange = { - "exports", - "formules", - "rules", - "scripts", - "simulators", - "sensitivityexports" - }; - - /** les catégories rattachées au logger de librairies. */ - private static final String[] libLoggerToChange = { - "org.nuiton" - }; - /** - * Add a simple {@link FileAppender} for a given simulation id. - * - * @param filename the filename where appender store logs - * @param appenderId the id of appender to add - * @param simulLogLevel simulator logger level - * @param libLogLevel libraries logger level - * @param scriptLogLevel scripts logger level - * @param threadName the thread to exclude (if null don't use it) - * @throws IsisFishException if we could not create appender - */ - public static void addSimulationAppender(String filename, - String appenderId, - String simulLogLevel, - String scriptLogLevel, - String libLogLevel, - String threadName) - throws IsisFishException { - PatternLayout layout = new PatternLayout(); - layout.setConversionPattern(LOG_PATTERN); - - ThreadFilter filter = new ThreadFilter(threadName); - - simulLevelKeeper = prepareLogger(simulLogLevel, simulLoggerToChange); - scriptLevelKeeper = prepareLogger(scriptLogLevel, scriptLoggerToChange); - libLevelKeeper = prepareLogger(libLogLevel, libLoggerToChange); - - //TODO See if we use should use the buffered version : define buffer size - - try { - FileAppender appender = new FileAppender(layout, filename, false); - appender.setName(appenderId); - - // thread filter come first - appender.addFilter(filter); - - // add the appender to the root appender - Logger.getRootLogger().addAppender(appender); - - if (log.isDebugEnabled()) { - log.debug(t("isisfish.log.addAppender", appenderId)); - } - } catch (IOException ex) { - log.error(t("isisfish.error.log.createAppender", appenderId, ex.getMessage())); - throw new IsisFishException("Can't add appender", ex); - } - - } - - /** - * Remove the appender used for simulation, add restore level to logger. - * - * @param appenderId the appender id to remove - */ - public static void removeSimulationAppender(String appenderId) { - if (log.isDebugEnabled()) { - log.debug(t("isisfish.log.removeAppender", appenderId)); - } - removeAppender(null, appenderId); - // push back to original levels - retablishLogger(simulLevelKeeper); - simulLevelKeeper = null; - retablishLogger(scriptLevelKeeper); - scriptLevelKeeper = null; - retablishLogger(libLevelKeeper); - libLevelKeeper = null; - } - - /** * Open a new log console for the given simulation * * @param simulationName name of the simulation to use @@ -190,91 +82,4 @@ log.info(t("isisfish.simulation.log.showConsole", simulationName)); } } - - /** - * Find categories instanciated keep their level and swap to new - * required level. - * <p/> - * Return the dico produced to be resotre later {@link #retablishLogger(java.util.Map)} - * - * @param logLevel the required level - * @param categoriesToChange list of categories - * @return the dico of matching categories with their orginal level - */ - static Map<String, Level> prepareLogger(String logLevel, String[] categoriesToChange) { - Map<String, Level> result = new HashMap<String, Level>(); - Enumeration enumeration; - - Level level = Level.toLevel(logLevel); - - enumeration = Logger.getRootLogger().getLoggerRepository().getCurrentLoggers(); - while (enumeration.hasMoreElements()) { - Object o = enumeration.nextElement(); - if (o instanceof Logger) { - Logger logger = (Logger) o; - String loggerName = logger.getName(); - for (String category : categoriesToChange) { - if (loggerName.startsWith(category)) { - // we found a logger to keep at his level - result.put(logger.getName(), logger.getLevel()); - if (log.isDebugEnabled()) { - log.debug(t("isisfish.log.swapLogLevel", loggerName, logger.getLevel(), logLevel)); - } - // change to new level - logger.setLevel(level); - break; - } - } - } - } - return result; - } - - /** - * Restore for the given categories, the associated level store in dico. - * - * @param levelKeeper the dico of categories to swap back to original levels - */ - static void retablishLogger(Map<String, Level> levelKeeper) { - Logger rootLogger = Logger.getRootLogger(); - for (Map.Entry<String, Level> entry : levelKeeper.entrySet()) { - Logger logger = rootLogger.getLoggerRepository().getLogger(entry.getKey()); - if (logger != null) { - Level oldLevel = entry.getValue(); - if (log.isDebugEnabled()) { - log.debug(t("isisfish.log.restoreLogLevel", logger.getName(), logger.getLevel(), oldLevel)); - } - logger.setLevel(oldLevel); - } - } - levelKeeper.clear(); - } - - /** - * Remove a Log4J appender given his name for a given category. - * <p/> - * It category is null, we use the rootLogger. - * - * @param category category of appender to remove, it null use rootLogger - * @param name name of appender to remove - */ - static void removeAppender(String category, String name) { - // get logger for the category - Logger logger = category == null ? Logger.getRootLogger() : Logger.getLogger(category); - if (logger == null) { - Logger.getRootLogger().warn(t("isisfish.error.log.closeAppender", name, category)); - return; - } - // get the required appender - Appender app = logger.getAppender(name); - if (app == null) { - logger.warn(t("isisfish.error.log.foundAppender", name, category)); - return; - } - logger.info(t("isisfish.log.closeAppender", name, category)); - // close appender - app.close(); - // and remove it from the logger - logger.removeAppender(app); - } } Copied: trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java (from rev 4129, branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/SimulationThresholdFilter.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,149 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Ifremer, 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.logging; + +import org.apache.commons.lang3.StringUtils; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.Marker; +import org.apache.logging.log4j.ThreadContext; +import org.apache.logging.log4j.core.LogEvent; +import org.apache.logging.log4j.core.Logger; +import org.apache.logging.log4j.core.config.plugins.Plugin; +import org.apache.logging.log4j.core.config.plugins.PluginAttribute; +import org.apache.logging.log4j.core.config.plugins.PluginFactory; +import org.apache.logging.log4j.core.filter.AbstractFilter; +import org.apache.logging.log4j.message.Message; + +import fr.ifremer.isisfish.datastore.ExportStorage; +import fr.ifremer.isisfish.datastore.FormuleStorage; +import fr.ifremer.isisfish.datastore.ObjectiveStorage; +import fr.ifremer.isisfish.datastore.OptimizationStorage; +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.SimulationPlanStorage; +import fr.ifremer.isisfish.datastore.SimulatorStorage; + +/** + * Filter always available in log4j configuration that filter simulation log depending of simulation + * log level configuration. + */ +@Plugin(name = "SimulationThresholdFilter", category = "Core", elementType = "filter", printObject = true) +public final class SimulationThresholdFilter extends AbstractFilter { + private Level defaultThreshold = Level.ERROR; + + /** Simulation id. Present in MDC context only if a simulation is running. */ + public static final String SIMULATION_ID = "simulationId"; + /** Simulation log file for lof4j file appender (only if simulationId is defined) */ + public static final String SIMULATION_LOG_FILE = "simulationLogFile"; + /** {@code fr.ifremer.isisfish} package log level. */ + public static final String SIMUALTION_APPLICATION_LEVEL = "simulationApplicationLevel"; + /** {@code org.nuiton} package log level. */ + public static final String SIMULATION_LIB_LEVEL = "simulationLibLevel"; + /** Script log level. */ + public static final String SIMULATION_SCRIPT_LEVEL = "simulationScriptLevel"; + + private SimulationThresholdFilter(final Level defaultLevel, final Result onMatch, final Result onMismatch) { + super(onMatch, onMismatch); + this.defaultThreshold = defaultLevel; + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final String msg, + final Object... params) { + return filter(logger.getName(), level); + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final Object msg, + final Throwable t) { + return filter(logger.getName(), level); + } + + @Override + public Result filter(final Logger logger, final Level level, final Marker marker, final Message msg, + final Throwable t) { + return filter(logger.getName(), level); + } + + @Override + public Result filter(final LogEvent event) { + return filter(event.getLoggerFqcn(), event.getLevel()); + } + + private Result filter(final String loggerFqcn, final Level level) { + + String simulationId = ThreadContext.get("simulationId"); + + Result result; + + // so simulation, no filtering + if (simulationId == null) { + result = Result.NEUTRAL; + } else { + Level ctxLevel = defaultThreshold; + + if (loggerFqcn.startsWith("fr.ifremer.isisfish")) { + ctxLevel = Level.getLevel(ThreadContext.get("simulationApplicationLevel")); + } else if (loggerFqcn.startsWith("org.nuiton")) { + ctxLevel = Level.getLevel(ThreadContext.get("simulationLibLevel")); + } else if (StringUtils.startsWithAny(loggerFqcn, + ExportStorage.EXPORT_PATH, + FormuleStorage.FORMULE_PATH, + ObjectiveStorage.OBJECTIVE_PATH, + OptimizationStorage.OPTIMIZATION_PATH, + RuleStorage.RULE_PATH, + ScriptStorage.SCRIPT_PATH, + SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_PATH, + SensitivityExportStorage.SENSITIVITY_EXPORT_PATH, + SimulationPlanStorage.SIMULATION_PLAN_PATH, + SimulatorStorage.SIMULATOR_PATH)) { + ctxLevel = Level.getLevel(ThreadContext.get("simulationScriptLevel")); + } + + result = level.isMoreSpecificThan(ctxLevel) ? onMatch : onMismatch; + } + + return result; + } + + /** + * Create the DynamicThresholdFilter. + * @param defaultThreshold The default Level. + * @param onMatch The action to perform if a match occurs. + * @param onMismatch The action to perform if no match occurs. + * @return The DynamicThresholdFilter. + */ + @PluginFactory + public static SimulationThresholdFilter createFilter( + @PluginAttribute("defaultThreshold") final Level defaultThreshold, + @PluginAttribute("onMatch") final Result onMatch, + @PluginAttribute("onMismatch") final Result onMismatch) { + final Level level = defaultThreshold == null ? Level.ERROR : defaultThreshold; + return new SimulationThresholdFilter(level, onMatch, onMismatch); + } +} Deleted: trunk/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/ThreadFilter.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,51 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin, Benjamin Poussin, Tony Chemit - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ - -package fr.ifremer.isisfish.logging; - -/** - * this class is Log4J filter to accept only incoming log events from a unique thread. - * it retains all logEvent coming from other threads (compare with given thread name). - * - * @author chemit - */ -public class ThreadFilter extends org.apache.log4j.spi.Filter { - - /** the name of the only thread to accept */ - protected String threadName; - - public ThreadFilter(String threadName) { - this.threadName=threadName; - } - - public int decide(org.apache.log4j.spi.LoggingEvent event) { - // only accept event coming from a specific thread - return event.getThreadName().equals(threadName) ? ACCEPT : DENY; - } - - public void setThreadName(String threadName) { - this.threadName = threadName; - } -} Modified: trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsole.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -45,7 +45,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.widget.IconFactory; -import fr.ifremer.isisfish.IsisFish; import fr.ifremer.isisfish.ui.logging.console.LogConsoleUI; /** @@ -165,8 +164,6 @@ uiUpdater = new UpdateUI(this); - handler.setStatusBar(getStatusBar()); - log.info(this); } @@ -319,16 +316,4 @@ }); } } - - public static void IsisStart() { - - try { - IsisFish.init(); - } catch (Exception e) { - if (log.isErrorEnabled()) { - log.error("Can't init isis", e); - } - } - - } } Modified: trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsoleHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsoleHandler.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogConsoleHandler.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -47,7 +47,6 @@ import javax.swing.JEditorPane; import org.apache.commons.logging.Log; -import org.nuiton.widget.StatusBar; import fr.ifremer.isisfish.logging.LogLevel; import fr.ifremer.isisfish.logging.LogLevelUtil; @@ -85,9 +84,6 @@ /** a flag to block scroll bar adjustement events */ protected boolean dontAdjust = true; - /** the console status bar where to notify user events */ - protected StatusBar statusBar; - /** the dialog to send mail */ protected LogMail logMail; @@ -328,8 +324,7 @@ int levels = model.getLevels(); log.info("levels:" + model.levels + ", searchText:" + searchText); - long t0; - t0 = System.currentTimeMillis(); + LineReader parent; // we have a levels filter try { @@ -363,7 +358,6 @@ read(0); dontAdjust = true; model.fireStateChanged(); - getStatusBar().setStatus(t("filter loaded in %1$s ms : found %2$s lines.", (System.currentTimeMillis() - t0), reader.getNbLines())); } catch (IOException e) { log.warn("could not open reader [" + this.reader + "] for reason " + e.getMessage()); } @@ -435,18 +429,9 @@ propertyListeners.removePropertyChangeListener(propertyName, listener); } - public StatusBar getStatusBar() { - return statusBar; - } - - public void setStatusBar(StatusBar statusBar) { - this.statusBar = statusBar; - } - public void openLogMail() { if (logMail==null) { - logMail = new LogMail( - statusBar, + logMail = new LogMail( model.getFrom(), model.getLogFile(), model.getLogFile().getParentFile(), Modified: trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogMail.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogMail.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/logging/console/LogMail.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -62,7 +62,6 @@ import org.apache.commons.logging.LogFactory; import org.nuiton.util.FileUtil; import org.nuiton.util.ZipUtil; -import org.nuiton.widget.StatusBar; import fr.ifremer.isisfish.ui.logging.console.LogMailUI; @@ -93,24 +92,21 @@ /** default from from mail send */ protected String from; - /** the console status bar where to notify user events */ - protected StatusBar statusBar; - - public LogMail(final StatusBar statusBar, String from, File logFile, File simulationFile, final String smtpServer) { + public LogMail(String from, File logFile, File simulationFile, final String smtpServer) { setTitle(t("isisfish.log.mail.send.title", simulationFile.getName())); this.from = from; this.logFile = logFile; this.simulationFile = simulationFile; this.smtpServer = smtpServer; - this.statusBar = statusBar; sendMail.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { sendMail(mailTo.getText(), content.getText(), sendAll.isSelected()); - statusBar.setStatus(t("isisfish.log.mail.send" , to)); } catch (Exception eee) { - statusBar.setStatus(t("isisfish.log.mail.failed", smtpServer)); + if (log.isErrorEnabled()) { + log.error("Can't send email", eee); + } } finally { dispose(); } Modified: trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/map/DefaultScale.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -95,12 +95,4 @@ return (int) (value / (getMax() / 255.0)); } - public double getValueAsSqrtScale(double value) { - double scale = getValueAsScale(value); - if (scale < 0) { - return 0; - } - return Math.sqrt(scale); - } - } // DefaultScale Modified: trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/map/Motif.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -197,8 +197,14 @@ Scale sc, DataMap datamap) { if (datamap.getValue() != 0) { int rgb = sc.getValueAsRGB(datamap.getValue()); + + // see http://forge.codelutin.com/issues/5646 + // cela peut se produire en cas de résultat incohérents + if (rgb < 0) { + rgb = 0; + } + Color lColor = new Color(255 - rgb, 255 - rgb, 255 - rgb, 255); - Color fColor = new Color(255 - rgb, 255 - rgb, 255 - rgb, 255); OMRect omrect; Modified: trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/map/Scale.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -48,12 +48,4 @@ public int getValueAsRGB(double value); - /** - * Get the corresponding square root value between 0.0 and 1.0. - * - * @param value value to get sqrt scale - * @return sqrt scale - */ - public double getValueAsSqrtScale(double value); - } // Scale Modified: trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/map/ZoneDelimiterLayer.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -145,7 +145,7 @@ (float) cell.getLongitude(), (float) cell.getLatitude(), (float) (cell.getLongitude() + pasMailleLongitude), OMGraphic.LINETYPE_STRAIGHT); - if (cell.getLand()) { + if (cell.isLand()) { omrect.setLinePaint(new Color(Color.red.getRed(), Color.red .getGreen(), Color.red.getBlue(), 0));//completement transparent } else { Modified: trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/mexico/MexicoHelper.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -415,7 +415,7 @@ ruleAsString.append("<param key=\""); ruleAsString.append(propName); ruleAsString.append("\">"); - ruleAsString.append(StringEscapeUtils.escapeXml(props.getProperty(propName))); + ruleAsString.append(StringEscapeUtils.escapeXml11(props.getProperty(propName))); ruleAsString.append("</param>"); } ruleAsString.append("</rule>"); Modified: trunk/src/main/java/fr/ifremer/isisfish/mexico/export/RegionExportFactorXML.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/mexico/export/RegionExportFactorXML.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/mexico/export/RegionExportFactorXML.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -272,7 +272,7 @@ // not initialized equation can be null :( if (value != null) { result = String.valueOf(((Equation)value).getContent()); - result = StringEscapeUtils.escapeXml(result); + result = StringEscapeUtils.escapeXml11(result); } } // default case, just toString() on value Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -73,7 +73,7 @@ private static Log log = LogFactory.getLog(MetierMonitor.class); protected Set<Metier> forbiddenMetier = new HashSet<Metier>(); - protected Set<MultiKey> forbiddenMetierMonth = new HashSet<MultiKey>(); + protected Set<MultiKey<Object>> forbiddenMetierMonth = new HashSet<>(); protected Map<TimeStep, MatrixND> noActivity = new HashMap<TimeStep, MatrixND>(); /** @@ -102,11 +102,11 @@ * @param month */ public void addforbiddenMetier(Metier metier, Month month) { - forbiddenMetierMonth.add(new MultiKey(metier, month)); + forbiddenMetierMonth.add(new MultiKey<Object>(metier, month)); } public void removeforbiddenMetier(Metier metier, Month month) { - forbiddenMetierMonth.remove(new MultiKey(metier, month)); + forbiddenMetierMonth.remove(new MultiKey<Object>(metier, month)); } public void addforbiddenMetier(Collection<Metier> metiers) { @@ -131,7 +131,7 @@ public boolean isForbidden(Metier metier, Month month) { boolean result = forbiddenMetier.contains(metier); if (!result) { - result = forbiddenMetierMonth.contains(new MultiKey(metier, month)); + result = forbiddenMetierMonth.contains(new MultiKey<Object>(metier, month)); } return result; } @@ -180,25 +180,25 @@ ////////////////////////////////////////////////////////////////////////// /** key <Metier, Month, Month> value: <Licence> */ - protected MultiKeyMap list = new MultiKeyMap(); + protected MultiKeyMap<Object, Licence> list = new MultiKeyMap<>(); - class Licence { + static class Licence { int nbLicences = 0; double proportionMaxTotal = 0; - Map<Month, Double> proportionsMonth = new HashMap<Month, Double>(); + Map<Month, Double> proportionsMonth = new HashMap<>(); } public Licence getLicence(Metier metier, Month month) { Licence result = null; - for (MapIterator i=list.mapIterator(); i.hasNext();) { - MultiKey keys = (MultiKey)i.next(); + for (MapIterator<MultiKey<? extends Object>, Licence> i = list.mapIterator(); i.hasNext();) { + MultiKey<? extends Object> keys = i.next(); Metier metierKey = (Metier)keys.getKey(0); Month firstMonth = (Month)keys.getKey(1); Month lastMonth = (Month)keys.getKey(2); if (metier.equals(metierKey) && firstMonth.compareTo(month) <= 0 && month.compareTo(lastMonth) <= 0) { - result = (Licence)i.getValue(); + result = i.getValue(); break; } } @@ -211,15 +211,13 @@ o.nbLicences = nbLicences; o.proportionMaxTotal = this.computeProportionMaxTotal(metier, nbLicences); - for (Month i=firstMonth; i.compareTo(lastMonth) <= 0; i=i.next()) { + for (Month i = firstMonth; i.compareTo(lastMonth) <= 0; i = i.next()) { o.proportionsMonth.put(i, computeProportionMonth(metier, i)); - } this.list.put(metier, firstMonth, lastMonth, o); - } - else{ + } else { log.warn("il existe deja une licence touchant le metier: " + metier + " sur la periode:"+ firstMonth + "-" + lastMonth); } @@ -293,7 +291,7 @@ try { // FIXME: Cette methode n'existe pas dans L'ECMAScript :( -// strategies = Regle_libUtil.getStrategiesMetier(metier); + // strategies = Regle_libUtil.getStrategiesMetier(metier); // Je l'ai traduit avec ce qui suit TopiaContext tx = metier.getTopiaContext(); List<SetOfVessels> res = null; @@ -301,7 +299,7 @@ res = tx.findAll("select setOfVessels from fr.ifremer.isisfish.entities.EffortDescription where possibleMetiers=?", metier); - for(SetOfVessels sov : res){ + for(SetOfVessels sov : res) { nbBoat = nbBoat + sov.getNumberOfVessels(); } } catch (TopiaException eee) { Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -286,7 +286,7 @@ } } - if (pop.getSpecies().getAgeGroupType()) { + if (pop.getSpecies().isAgeGroupType()) { // conversion et retour de la matrice en vecteur MatrixND N = pop.N2DToN1D(result); // on applique les migrations et le changement d'age sur le resultat Deleted: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationMeta.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationMeta.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationMeta.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,125 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 1999 - 2010 Ifremer, CodeLutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ifremer.isisfish.simulator; - -import fr.ifremer.isisfish.ui.widget.filter.DateInterval; -import fr.ifremer.isisfish.ui.widget.filter.FilterAcceptor; -import fr.ifremer.isisfish.ui.widget.filter.FilterParamModel; -import fr.ifremer.isisfish.ui.widget.filter.ValueGetter; - -import static org.nuiton.i18n.I18n.t; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * This enum represents all properties on which we can perform search. - * - * Each constant is also used as acceptor for the property it represents (using {@link FilterAcceptor#accept(Object, Object)} - * and permit to access SimulationProperties values with methods - * {@link #getValue(SimulationProperties)} - * and {@link #getDateValue(SimulationProperties)} - */ -public enum SimulationMeta implements ValueGetter<SimulationProperties, Object> { - // text - isisFishVersion(String.class), - description(String.class), - simulationName(String.class), - simulatorName(String.class), - simulationPlanName(String.class), - regionName(String.class), - otherInfo(String.class), - - // int - numberOfYear(Integer.class), - simulationPlanNumber(Integer.class), - - // date interval - simulationInterval(DateInterval.class) { - @Override - public DateInterval getValue(SimulationProperties sim) { - return new DateInterval(simulationStart.getDateValue(sim), simulationEnd.getDateValue(sim)); - } - }, - - // date - simulationStart(Long.class), - simulationEnd(Long.class), - exportTime(Long.class), - - // boolean - useOptimization(Boolean.class), - useSimulationPlan(Boolean.class), - useStatistic(Boolean.class), - usePreScript(Boolean.class), - onlyExport(Boolean.class), - local(Boolean.class); - - // others - //statistic(klazz), - //optimizationUsage(klazz), - //exception(klazz); - - private static final Log log = LogFactory.getLog(SimulationMeta.class); - - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss"); - private final Class<?> klazz; - - SimulationMeta(Class<?> klazz) { - this.klazz = klazz; - } - - @SuppressWarnings({"unchecked"}) - public FilterParamModel<SimulationProperties, ?> createParamModel() { - return new FilterParamModel<SimulationProperties, Object>(name(), (Class<Object>) getKlazz(), this); - } - - public Class<?> getKlazz() { - return klazz; - } - - public Object getValue(SimulationProperties sim) { - return sim.getData().getProperty(name()); - } - - public long getDateValue(SimulationProperties sim) { - String d = (String) getValue(sim); - Date result = null; - if (d != null) { - try { - result = dateFormat.parse(d); - } catch (ParseException eee) { - if (log.isWarnEnabled()) { - log.warn(t("isisfish.error.parse.date", d), eee); - } - } - } - return result == null ? -1 : result.getTime(); - } -} Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameter.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -555,7 +555,7 @@ * * Default to "info". * - * @return simualtor log level + * @return simulator log level */ public String getSimulLogLevel(); Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -44,7 +44,6 @@ 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; Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationProperties.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationProperties.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationProperties.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -49,9 +49,6 @@ * <p> * The class is only a properties container, no method to access a data directly * (except to obtain name of underlying simulation). - * <p> - * For this purpose use {@link SimulationMeta#getValue(SimulationProperties)} - * and {@link SimulationMeta#getDateValue(SimulationProperties)} */ public class SimulationProperties { @@ -64,7 +61,7 @@ File simulationDirectory = SimulationStorage.getSimulationDirectory(name); this.name = simulationDirectory.getName(); this.data = new Properties(); - data.put(SimulationMeta.simulationName.name(), this.name); + data.put("simulationName", this.name); loadProperties(SimulationStorage.getSimulationParametersFile(simulationDirectory)); loadProperties(SimulationStorage.getSimulationInformationFile(simulationDirectory)); } Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -41,6 +41,8 @@ import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.ThreadContext; import org.nuiton.topia.TopiaContext; import org.nuiton.topia.TopiaException; import org.nuiton.topia.event.TopiaTransactionEvent; @@ -59,6 +61,7 @@ import fr.ifremer.isisfish.datastore.ResultStorage; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.datastore.SimulatorStorage; +import fr.ifremer.isisfish.logging.SimulationThresholdFilter; import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.simulator.SimulationControl; import fr.ifremer.isisfish.simulator.SimulationException; @@ -70,6 +73,7 @@ import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.util.CompileHelper; + import org.nuiton.math.matrix.MatrixFactory; /** @@ -219,39 +223,15 @@ protected SimulationStorage localSimulate(SimulationControl control, SimulationStorage simulation) { SimThread simThread = new SimThread(control, simulation); - // add simulation logger, we can't make it before since we need thread name - // anyway since if accept only log from simThread, no need to init it before - String simulLogLevel = simulation.getParameter().getSimulLogLevel(); - String scriptLogLevel = simulation.getParameter().getScriptLogLevel(); - String libLogLevel = simulation.getParameter().getLibLogLevel(); + simThread.start(); try { - simulation.addSimulationLogger(simulLogLevel, scriptLogLevel, - libLogLevel, simThread.getName()); - } catch (Exception e) { + simThread.join(); + } catch (InterruptedException eee) { if (log.isWarnEnabled()) { - log.warn(t("isisfish.error.add.logger.simulation", e)); + log.warn(t("isisfish.error.wait.simThread"), eee); } } - try { - simThread.start(); - try { - simThread.join(); - } catch (InterruptedException eee) { - if (log.isWarnEnabled()) { - log.warn(t("isisfish.error.wait.simThread"), eee); - } - } - } finally { - try { - // remove simulation logger (no more need since thread is dead) - simulation.removeSimulationLogger(); - } catch (Exception ex) { - if (log.isDebugEnabled()) { - log.debug("Can't restore logger configuration", ex); - } - // FIXME echatellier 20140729 remove this with log4j 2 - } - } + return simulation; } @@ -267,6 +247,22 @@ @Override public void run() { + + // logger configuration can only be changed with log4j MDC using thread local + String simulLogLevel = simulation.getParameter().getSimulLogLevel(); + String scriptLogLevel = simulation.getParameter().getScriptLogLevel(); + String libLogLevel = simulation.getParameter().getLibLogLevel(); + + String standardSimulLogLevel = Level.toLevel(simulLogLevel, Level.INFO).name(); + String standardLibLogLevel = Level.toLevel(libLogLevel, Level.INFO).name(); + String standardScriptLogLevel = Level.toLevel(scriptLogLevel, Level.WARN).name(); + + ThreadContext.put(SimulationThresholdFilter.SIMULATION_ID, simulation.getName()); + ThreadContext.put(SimulationThresholdFilter.SIMULATION_LOG_FILE, simulation.getSimulationLogFile()); + ThreadContext.put(SimulationThresholdFilter.SIMUALTION_APPLICATION_LEVEL, standardSimulLogLevel); + ThreadContext.put(SimulationThresholdFilter.SIMULATION_SCRIPT_LEVEL, standardLibLogLevel); + ThreadContext.put(SimulationThresholdFilter.SIMULATION_LIB_LEVEL, standardScriptLogLevel); + simulation = localSimulateSameThread(control, simulation); } } Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2012 Ifremer, Code Lutin, Benjamin Poussin, Chatellier Eric + * Copyright (C) 2002 - 2014 Ifremer, 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 @@ -47,8 +47,9 @@ import java.util.concurrent.Executors; import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; +import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.mutable.MutableInt; import org.apache.commons.lang3.time.DurationFormatUtils; @@ -96,6 +97,7 @@ import fr.ifremer.isisfish.simulator.sensitivity.SensitivityUtils; import fr.ifremer.isisfish.simulator.sensitivity.domain.RuleDiscreteDomain; import fr.ifremer.isisfish.util.CompileHelper; +import fr.ifremer.isisfish.util.DependencyUtil; /** * Cette classe est responsable de conservation de toutes les simulations faites @@ -193,14 +195,6 @@ log.warn(t("Can't instantiate %s", value), eee); } } - - // fait un appel au moniteur - // pour reprendre le monitoring des simulation en cours - // TODO check this, don't restart monitoring on non ui launch - // moved to main() - //if (IsisFish.config.isLaunchUI()) { - // SimulationMonitor.getInstance().reloadConfig(this); - //} } /** @@ -403,7 +397,7 @@ } // on construit le zip de la simulation - File zip = prepareSimulationZipFile(control, localParameters, null, null, true); + File zip = prepareSimulationZipFile(control, localParameters, null, null); item.setSimulationZip(zip); if (localParameters.getUseSimulationPlan() && localParameters.isIndependentPlan()) { @@ -481,7 +475,7 @@ // on construit le zip de la simulation // in zip, there will be param "without" prescript - File zip = prepareSimulationZipFile(controlJustForZip, localParameters, xmlDesignPlan, sensitivityScenarios, true); + File zip = prepareSimulationZipFile(controlJustForZip, localParameters, xmlDesignPlan, sensitivityScenarios); // for each simulation, we neeed to launch a specific simulation // new simulation ids will be id + "_" + x @@ -715,48 +709,35 @@ * @param param les parametre de la simulation * @param xmlDesignPlan contenu xml des design plan * @param sensitivityScenarios used to add some extra files (such as rules) - * @param compile si vrai la version compile des fichiers Java est aussi - * mise dans le fichier zip. Cela peut servir pour les simulations locales - * pour ne pas recompiler pour chaque simulation avec plan de simulation * @return un zip de simulation pour une simulation pret a être faite * @throws SimulationException pour tout problème rencontré (IO,Topia...) */ protected File prepareSimulationZipFile(SimulationControl control, - SimulationParameter param, String xmlDesignPlan, SensitivityScenarios sensitivityScenarios, boolean compile) + SimulationParameter param, String xmlDesignPlan, SensitivityScenarios sensitivityScenarios) throws SimulationException { + try { - File tmpDirectory = FileUtil.createTempDirectory( - "isisfish-simulation-", "-preparation"); - //File regionXML = IsisConfig.getDataBackupFile(tmpDirectory); - File regionXML = new File(tmpDirectory, - SimulationStorage.DATA_BACKUP_FILENAME); + File tmpDirectory = FileUtil.createTempDirectory("isisfish-simulation-", "-preparation"); // sauvegarde des parametres Properties prop = param.toProperties(); - //File f = IsisConfig.getSimulationParametersFile(tmpDirectory); File f = new File(tmpDirectory, SimulationStorage.PARAMETERS_FILENAME); - FileOutputStream out = null; - try { - out = new FileOutputStream(f); + try (FileOutputStream out = new FileOutputStream(f)) { prop.store(out, "Parameters"); - } finally { - IOUtils.closeQuietly(out); } // backup pour toutes les simulations, pour eviter que l'utilisateur // ne puisse le modifier en meme temps control.setText(t("isisfish.message.backup.database.progress")); - RegionStorage region = RegionStorage.getRegion(param - .getRegionName()); + File regionBackup = new File(tmpDirectory, SimulationStorage.DATA_BACKUP_FILENAME); + RegionStorage region = RegionStorage.getRegion(param.getRegionName()); TopiaContext tc = region.getStorage().beginTransaction(); - tc.backup(regionXML, true); + tc.backup(regionBackup, true); tc.closeContext(); control.setText(t("isisfish.message.backup.database.finished")); - // copie de toutes regles a utiliser + // extract Rules defined in factors List<Rule> rules = param.getRules(); - - // FIXME small hack to add rules defined in simulations factors if (sensitivityScenarios != null) { for (Scenario sensitivityScenario : sensitivityScenarios.getScenarios()) { List<Factor> factors = sensitivityScenario.getFactors(); @@ -865,13 +846,6 @@ } } - // copie de tous les scripts a utiliser - // les script officiel prevalent sur les scripts communautés - FileUtil.copyRecursively(ScriptStorage.getCommunityScriptDirectory(), - tmpDirectory, ".*\\.java$"); - FileUtil.copyRecursively(ScriptStorage.getScriptDirectory(), - tmpDirectory, ".*\\.java$"); - // copie de tous les simulateurs a utiliser File simulatorFile = new File(SimulatorStorage.getSimulatorDirectory(), param.getSimulatorName()); if (!simulatorFile.isFile()) { @@ -881,14 +855,10 @@ SimulatorStorage.SIMULATOR_PATH + File.separator + param.getSimulatorName())); - // convert all file to UTF-8 - //convertAllFile(control, tmpDirectory); - - if (compile) { - compileAllFile(control, tmpDirectory); - } + // compile and add dependencies + compileAllFile(control, tmpDirectory); - // Sauvegarde du design plan en XML + // sauvegarde du design plan en XML if (!StringUtils.isEmpty(xmlDesignPlan)) { File simulationDesignPlanFile = SimulationStorage.getMexicoDesignPlan(tmpDirectory); FileUtils.writeStringToFile(simulationDesignPlanFile, xmlDesignPlan, "utf-8"); @@ -915,47 +885,6 @@ } - /* - * Convertit tous les fichiers du répertoire directory en UTF-8, - * pour eviter les erreurs d'encodage du la compilation - * sur un autre systeme ne supportant pas l'encodage courant. - * - * @param control le controleur - * @param directory le répertoire a convertir - * - protected void convertAllFile(SimulationControl control, File directory) { - - control.setText("Converting file to unicode"); - - List<File> fileToConvert = new ArrayList<File>(); - - List<File> tmp = FileUtil.find(new File(directory, - ExportStorage.EXPORT_PATH), ".*\\.java$", true); - fileToConvert.addAll(tmp); - - tmp = FileUtil.find(new File(directory, - SensitivityExportStorage.SENSITIVITY_EXPORT_PATH), ".*\\.java$", true); - fileToConvert.addAll(tmp); - - tmp = FileUtil.find(new File(directory, RuleStorage.RULE_PATH), - ".*\\.java$", true); - fileToConvert.addAll(tmp); - - tmp = FileUtil.find(new File(directory, - SimulationPlanStorage.SIMULATION_PLAN_PATH), ".*\\.java$", true); - fileToConvert.addAll(tmp); - - tmp = FileUtil.find( - new File(directory, SimulatorStorage.SIMULATOR_PATH), - ".*\\.java$", true); - fileToConvert.addAll(tmp); - - // - // Convertion - // - //CompileHelper.convertToUnicode(fileToConvert); - }*/ - /** * Compile les fichiers présent dans le répertoire passé en * parametre, ce répertoire est hiérarchisé en: rules, exports, simulators @@ -967,19 +896,21 @@ * * @param control le controleur * @param directory le répertoire où compiler + * @throws IOException */ - protected void compileAllFile(SimulationControl control, File directory) { + protected void compileAllFile(SimulationControl control, File directory) throws IOException { control.setText(t("isisfish.simulation.message.scriptscompilation")); long currentTime = System.nanoTime(); - // // Recherche des fichiers a compiler // On ne prend pas les scripts, car ils sont tous copiés mais pas // forcément util. Lors de la compilation des autres fichiers, les // script servant réellement seront automatiquement compilé - List<File> fileToCompile = new ArrayList<File>(); + List<File> fileToCompile = new ArrayList<>(); // *.java + List<File> fileToInpect = new ArrayList<>(); // *.class + Set<String> dependencies = new HashSet<String>(); // packages String[] modules = { ExportStorage.EXPORT_PATH, @@ -990,17 +921,46 @@ SimulationPlanStorage.SIMULATION_PLAN_PATH, SimulatorStorage.SIMULATOR_PATH }; - + for (String module : modules) { - List<File> tmp = FileUtil.find(new File(directory, module), ".*\\.java$", true); + File moduleDir = new File(directory, module); + List<File> tmp = FileUtil.find(moduleDir, ".*\\.java$", true); fileToCompile.addAll(tmp); + for (File srcFile : tmp) { + // source + fileToCompile.add(srcFile); + // class + File classFile = new File(srcFile.getAbsolutePath().replaceFirst("\\.java", ".class")); + fileToInpect.add(classFile); + // package + dependencies.add(module + "." + FilenameUtils.getBaseName(srcFile.getName())); + } } // // Compilation // - CompileHelper.compile(directory, fileToCompile, directory, null); + + // + // Check dependencies + // + Set<String> allDeps = DependencyUtil.extractDependencies(directory, fileToInpect); + Collection<String> missingDeps = CollectionUtils.subtract(allDeps, dependencies); + for (String missingDep : missingDeps) { + String relativePath = missingDep.replace('.', File.separatorChar) + ".java"; + // try official first + File srcFile = new File(IsisFish.config.getContextDatabaseDirectory(), relativePath); + if (!srcFile.isFile()) { + // if official file not exists, look for community file + srcFile = new File(IsisFish.config.getCommunityDatabaseDirectory(), missingDep.replace('.', File.separatorChar) + ".java"); + } + File destFile = new File(directory, missingDep.replace('.', File.separatorChar) + ".java"); + FileUtils.copyFile(srcFile, destFile); + } + // there is no need to compile this dependancies, they have been compiled by first compilation + // only add missing java files + long time = System.nanoTime() - currentTime; control.setText(t("isisfish.message.compilation.time", DurationFormatUtils.formatDuration(time / 1000000, "s'.'S"))); Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityAnalysis.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityAnalysis.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/AbstractSensitivityAnalysis.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -416,7 +416,7 @@ Distribution distribution = domain.getDistribution(); double result = 0; if (distribution == Distribution.QUNIFPC) { - Object reference = (Double)domain.getDistributionParameter(Distribution.QUNIFPC.getDistibutionParams()[0].getName()); + Object reference = domain.getDistributionParameter(Distribution.QUNIFPC.getDistibutionParams()[0].getName()); if (reference instanceof MatrixND) { result = min ? 0 : 1; } else { Modified: trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/FactorHelper.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/FactorHelper.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/simulator/sensitivity/FactorHelper.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -36,7 +36,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.math.matrix.MatrixND; -import org.nuiton.topia.persistence.TopiaEntity; import fr.ifremer.isisfish.rule.Rule; import fr.ifremer.isisfish.rule.RuleHelper; Modified: trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MatrixType.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin + * Copyright (C) 2002 - 2014 Ifremer, Code Lutin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -320,10 +320,12 @@ return cub; } + @Override public Class returnedClass() { return MatrixND.class; } + @Override public boolean equals(Object x, Object y) throws HibernateException { if (x == y) { return true; @@ -334,10 +336,12 @@ } } + @Override public int hashCode(Object x) throws HibernateException { return x.hashCode(); } + @Override public Object deepCopy(Object value) throws HibernateException { if (value == null) { return null; @@ -345,14 +349,17 @@ return MatrixFactory.getInstance().create((MatrixND)value); } + @Override public String[] getPropertyNames() { return propertyNames; } + @Override public Type[] getPropertyTypes() { return hibernateTypes; } + @Override public Object getPropertyValue(Object component, int property) throws HibernateException { MatrixND matrix = (MatrixND)component; switch (property) { @@ -365,6 +372,7 @@ } } + @Override public void setPropertyValue(Object component, int property, Object value) throws HibernateException { MatrixND matrix = (MatrixND)component; switch (property) { @@ -383,6 +391,7 @@ } } + @Override public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { MatrixND matrix = null; @@ -413,6 +422,7 @@ return matrix; } + @Override public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { if (value == null) { st.setString(index, null); @@ -431,6 +441,7 @@ } } + @Override public Serializable disassemble(Object value, SessionImplementor session) throws HibernateException { MatrixND matrix = (MatrixND)value; return new Serializable[] { @@ -442,6 +453,7 @@ }; } + @Override public Object assemble(Serializable cached, SessionImplementor session, Object owner) throws HibernateException { Serializable[] o = (Serializable[])cached; String name = (String)o[0]; @@ -458,6 +470,7 @@ return matrix; } + @Override public Object replace(Object original, Object target, SessionImplementor session, Object owner) throws HibernateException { return assemble( disassemble(original, session), session, owner); } Modified: trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MonthType.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MonthType.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/MonthType.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin + * Copyright (C) 2002 - 2014 Ifremer, Code Lutin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,13 +25,15 @@ package fr.ifremer.isisfish.types.hibernate; +import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; -import org.hibernate.type.ImmutableType; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; import fr.ifremer.isisfish.types.Month; @@ -46,65 +48,74 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class MonthType extends ImmutableType { +public class MonthType implements UserType { - /** serialVersionUID. */ - private static final long serialVersionUID = 6151047526309798890L; + @Override + public int[] sqlTypes() { + return new int[] {Types.INTEGER}; + } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) - */ @Override - public Object get(ResultSet rs, String name) throws HibernateException, - SQLException { - return Month.MONTH[rs.getInt(name)]; + public Class returnedClass() { + return Month.class; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) - */ @Override - public void set(PreparedStatement st, Object value, int index) - throws HibernateException, SQLException { - st.setInt(index, ((Month) value).getMonthNumber()); + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#sqlType() - */ @Override - public int sqlType() { - return Types.INTEGER; + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#toString(java.lang.Object) - */ @Override - public String toString(Object value) throws HibernateException { - return ((Month)value).toString(); + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + Object result = null; + if (!rs.wasNull()) { + result = Month.MONTH[rs.getInt(names[0])]; + } + return result; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) - */ @Override - public Object fromStringValue(String xml) throws HibernateException { - return Month.MONTH[Integer.parseInt(xml)]; + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, sqlTypes()[0]); + } else { + st.setInt(index, ((Month) value).getMonthNumber()); + } } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getReturnedClass() - */ - public Class getReturnedClass() { - return Month.class; + @Override + public Object deepCopy(Object value) throws HibernateException { + return value; } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getName() - */ - public String getName() { - return MonthType.class.getName(); + @Override + public boolean isMutable() { + return false; } + @Override + public Serializable disassemble(Object value) throws HibernateException { + return (Month)value; + } + + @Override + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + @Override + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } } Modified: trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/RangeOfValuesType.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/RangeOfValuesType.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/RangeOfValuesType.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin + * Copyright (C) 2002 - 2014 Ifremer, Code Lutin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,13 +25,15 @@ package fr.ifremer.isisfish.types.hibernate; +import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; -import org.hibernate.type.ImmutableType; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; import fr.ifremer.isisfish.types.RangeOfValues; @@ -46,65 +48,74 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class RangeOfValuesType extends ImmutableType { +public class RangeOfValuesType implements UserType { - /** serialVersionUID. */ - private static final long serialVersionUID = -5295147041590169149L; + @Override + public int[] sqlTypes() { + return new int[] {Types.VARCHAR}; + } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) - */ @Override - public Object get(ResultSet rs, String name) throws HibernateException, - SQLException { - return new RangeOfValues(rs.getString(name)); + public Class returnedClass() { + return RangeOfValues.class; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) - */ @Override - public void set(PreparedStatement st, Object value, int index) - throws HibernateException, SQLException { - st.setString(index, ((RangeOfValues) value).getAsString()); + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#sqlType() - */ @Override - public int sqlType() { - return Types.VARCHAR; + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#toString(java.lang.Object) - */ @Override - public String toString(Object value) throws HibernateException { - return ((RangeOfValues)value).getAsString(); + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + Object result = null; + if (!rs.wasNull()) { + result = new RangeOfValues(rs.getString(names[0])); + } + return result; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) - */ @Override - public Object fromStringValue(String xml) throws HibernateException { - return new RangeOfValues(xml); + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, sqlTypes()[0]); + } else { + st.setString(index, ((RangeOfValues) value).getAsString()); + } } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getReturnedClass() - */ - public Class getReturnedClass() { - return RangeOfValues.class; + @Override + public Object deepCopy(Object value) throws HibernateException { + return value; } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getName() - */ - public String getName() { - return RangeOfValuesType.class.getName(); + @Override + public boolean isMutable() { + return false; } + @Override + public Serializable disassemble(Object value) throws HibernateException { + return (RangeOfValues)value; + } + + @Override + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + @Override + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } } Modified: trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2011 Ifremer, Code Lutin, Chatellier Eric + * Copyright (C) 2002 - 2014 Ifremer, 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 @@ -25,13 +25,15 @@ package fr.ifremer.isisfish.types.hibernate; +import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; -import org.hibernate.type.ImmutableType; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; import fr.ifremer.isisfish.types.TimeStep; @@ -46,65 +48,74 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class TimeStepType extends ImmutableType { +public class TimeStepType implements UserType { - /** serialVersionUID. */ - private static final long serialVersionUID = -5295147041590169149L; + @Override + public int[] sqlTypes() { + return new int[] {Types.INTEGER}; + } - /* - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) - */ @Override - public Object get(ResultSet rs, String name) throws HibernateException, - SQLException { - return new TimeStep(rs.getInt(name)); + public Class returnedClass() { + return TimeStep.class; } - /* - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) - */ @Override - public void set(PreparedStatement st, Object value, int index) - throws HibernateException, SQLException { - st.setInt(index, ((TimeStep) value).getStep()); + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); } - /* - * @see org.hibernate.type.NullableType#sqlType() - */ @Override - public int sqlType() { - return Types.INTEGER; + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); } - /* - * @see org.hibernate.type.NullableType#toString(java.lang.Object) - */ @Override - public String toString(Object value) throws HibernateException { - return ((TimeStep)value).toString(); + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + Object result = null; + if (!rs.wasNull()) { + result = new TimeStep(rs.getInt(names[0])); + } + return result; } - /* - * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) - */ @Override - public Object fromStringValue(String xml) throws HibernateException { - return new TimeStep(Integer.parseInt(xml)); + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, sqlTypes()[0]); + } else { + st.setInt(index, ((TimeStep) value).getStep()); + } } - /* - * @see org.hibernate.type.Type#getReturnedClass() - */ - public Class getReturnedClass() { - return TimeStep.class; + @Override + public Object deepCopy(Object value) throws HibernateException { + return value; } - /* - * @see org.hibernate.type.Type#getName() - */ - public String getName() { - return TimeStepType.class.getName(); + @Override + public boolean isMutable() { + return false; } + @Override + public Serializable disassemble(Object value) throws HibernateException { + return (TimeStep)value; + } + + @Override + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + @Override + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } } Modified: trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeUnitType.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeUnitType.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeUnitType.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin + * Copyright (C) 2002 - 2014 Ifremer, Code Lutin * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -25,13 +25,15 @@ package fr.ifremer.isisfish.types.hibernate; +import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; import org.hibernate.HibernateException; -import org.hibernate.type.ImmutableType; +import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.usertype.UserType; import fr.ifremer.isisfish.types.TimeUnit; @@ -46,65 +48,74 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class TimeUnitType extends ImmutableType { +public class TimeUnitType implements UserType { - /** serialVersionUID. */ - private static final long serialVersionUID = -5295147041590169149L; + @Override + public int[] sqlTypes() { + return new int[] {Types.DOUBLE}; + } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) - */ @Override - public Object get(ResultSet rs, String name) throws HibernateException, - SQLException { - return new TimeUnit(rs.getDouble(name)); + public Class returnedClass() { + return TimeUnit.class; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) - */ @Override - public void set(PreparedStatement st, Object value, int index) - throws HibernateException, SQLException { - st.setDouble(index, ((TimeUnit) value).getTime()); + public boolean equals(Object x, Object y) throws HibernateException { + if (x == y) { + return true; + } + if (null == x || null == y) { + return false; + } + return x.equals(y); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#sqlType() - */ @Override - public int sqlType() { - return Types.DOUBLE; + public int hashCode(Object x) throws HibernateException { + return x.hashCode(); } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#toString(java.lang.Object) - */ @Override - public String toString(Object value) throws HibernateException { - return ((TimeUnit)value).toString(); + public Object nullSafeGet(ResultSet rs, String[] names, SessionImplementor session, Object owner) throws HibernateException, SQLException { + Object result = null; + if (!rs.wasNull()) { + result = new TimeUnit(rs.getDouble(names[0])); + } + return result; } - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) - */ @Override - public Object fromStringValue(String xml) throws HibernateException { - return new TimeUnit(Double.parseDouble(xml)); + public void nullSafeSet(PreparedStatement st, Object value, int index, SessionImplementor session) throws HibernateException, SQLException { + if (value == null) { + st.setNull(index, sqlTypes()[0]); + } else { + st.setDouble(index, ((TimeUnit) value).getTime()); + } } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getReturnedClass() - */ - public Class getReturnedClass() { - return TimeUnit.class; + @Override + public Object deepCopy(Object value) throws HibernateException { + return value; } - /* (non-Javadoc) - * @see org.hibernate.type.Type#getName() - */ - public String getName() { - return TimeUnitType.class.getName(); + @Override + public boolean isMutable() { + return false; } + @Override + public Serializable disassemble(Object value) throws HibernateException { + return (TimeUnit)value; + } + + @Override + public Object assemble(Serializable cached, Object owner) throws HibernateException { + return cached; + } + + @Override + public Object replace(Object original, Object target, Object owner) throws HibernateException { + return original; + } } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/config/SSHLauncherConfigAction.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -352,6 +352,7 @@ * * @param session opened session * @return 'pwd' result + * @throws SSHException */ protected String getUserHomeDirectory(Session session) throws SSHException { @@ -372,7 +373,9 @@ * Get user home directory with an opened session. * * @param session opened session - * @return 'pwd' result + * @param path path to get size + * @return dir size + * @throws SSHException */ protected String getFolderSize(Session session, String path) throws SSHException { Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/CellUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -170,7 +170,7 @@ <JLabel text="isisfish.cell.land" enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActive()}' selected='{getBean().getLand()}' decorator='boxed'/> + <JCheckBox id="fieldCellLand" onActionPerformed='getBean().setLand(fieldCellLand.isSelected())' enabled='{isActive()}' selected='{getBean().isLand()}' decorator='boxed'/> </cell> </row> <row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputHandler.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -33,7 +33,6 @@ import java.io.IOException; import java.lang.reflect.Constructor; import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.swing.JComponent; @@ -59,7 +58,6 @@ import fr.ifremer.isisfish.IsisFishDAOHelper; import fr.ifremer.isisfish.IsisFishRuntimeException; import fr.ifremer.isisfish.datastore.RegionStorage; -import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.datastore.StorageException; import fr.ifremer.isisfish.entities.Cell; import fr.ifremer.isisfish.entities.FisheryRegion; @@ -89,7 +87,6 @@ import fr.ifremer.isisfish.ui.models.common.GenericComboModel; import fr.ifremer.isisfish.ui.sensitivity.wizard.FactorWizardUI; import fr.ifremer.isisfish.ui.sensitivity.wizard.SensitivityWizardHandler; -import fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil; import fr.ifremer.isisfish.vcs.VCSException; /** @@ -323,11 +320,10 @@ */ public void importRegionFromSimulation(InputUI inputUI) { - setStatusMessage(inputUI, t("isisfish.message.import"), true); + /*setStatusMessage(inputUI, t("isisfish.message.import"), true); // first step select a simulation and new region name try { - //TODO Should use a shared model ? List<String> simulationNames = SimulationStorage.getSimulationNames(); String simulationName = SimulationFilterUtil.selectSimulation(simulationNames); if (simulationName != null) { @@ -355,7 +351,7 @@ throw new IsisFishRuntimeException(t("isisfish.error.no.select.simulation"), eee); } - setStatusMessage(inputUI, t("isisfish.message.export.done")); + setStatusMessage(inputUI, t("isisfish.message.export.done"));*/ } /** Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/InputUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,7 +32,7 @@ <JMenu text="isisfish.common.region"> <JMenuItem text="isisfish.input.menu.importRegion" onActionPerformed="getHandler().importRegion(this)" /> <JMenuItem text="isisfish.input.menu.importRenameRegion" onActionPerformed="getHandler().importRegionAndRename(this)" /> - <JMenuItem text="isisfish.input.menu.importRegionSimulation" onActionPerformed="getHandler().importRegionFromSimulation(this)" /> + <JMenuItem text="isisfish.input.menu.importRegionSimulation" onActionPerformed="getHandler().importRegionFromSimulation(this)" enabled="false"/> <JMenuItem text="isisfish.input.menu.exportRegion" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().exportRegion(this)" /> <JMenuItem text="isisfish.input.menu.copyRegion" enabled='{isRegionLoaded()}' onActionPerformed="getHandler().copyRegion(this)" /> <JSeparator/> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationBasicsUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -94,7 +94,7 @@ wizardFrame.add(wizard, BorderLayout.CENTER); wizardFrame.setTitle(t("isisfish.wizardGroupCreation.title")); Species species = getBean().getSpecies(); - wizard.setAgeType(species.getAgeGroupType()); + wizard.setAgeType(species.isAgeGroupType()); if (wizard.isAgeType()) { wizard.setCard("singleGroupAge"); } else { @@ -179,7 +179,7 @@ <cell fill='horizontal'> <JCheckBox id="fieldPopulationBasicsPlusGroup" text="isisfish.populationBasics.plusGroup" toolTipText="isisfish.populationBasics.plusGroupTip" - selected='{getBean().getPlusGroup()}' + selected='{getBean().isPlusGroup()}' onActionPerformed='getBean().setPlusGroup(fieldPopulationBasicsPlusGroup.isSelected())' enabled='{isActive()}' decorator='boxed' _sensitivityBean='{Population.class}' _sensitivityMethod='"PlusGroup"'/> </cell> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationMigrationUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -122,7 +122,7 @@ } protected void refreshHidablePanel() { if (getPopInfo() != null) { - if (getPopInfo().getUseEquationMigration()) { + if (getPopInfo().isUseEquationMigration()) { fieldUseEquationMigration.setSelected(true); ((CardLayout) hidablePanel.getLayout()).show(hidablePanel, "fieldUseEquation"); } @@ -155,7 +155,7 @@ </row> <row> <cell columns='2' anchor='west'> - <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().getUseEquationMigration()}' + <JCheckBox id="fieldUseEquationMigration" selected='{getPopInfo().isUseEquationMigration()}' text="isisfish.populationMigration.useEquation" onActionPerformed='useEquationChanged()' enabled='{getPopInfo() != null}' decorator='boxed'/> </cell> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonSpacializedUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -66,7 +66,7 @@ try { MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); if (lengthChangeMatrix != null) { - if (popInfo.getSimpleLengthChangeMatrix()) { + if (popInfo.isSimpleLengthChangeMatrix()) { lengthChangeMatrix = popInfo.unspacializeLengthChangeMatrix(lengthChangeMatrix); } else { lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); @@ -85,7 +85,7 @@ protected void computeMatrixChangeOfGroup() { PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); MatrixND lengthChangeMatrix = popInfo.computeLengthChangeMatrix(); - if (!popInfo.getSimpleLengthChangeMatrix()){ + if (!popInfo.isSimpleLengthChangeMatrix()){ lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); } popInfo.setLengthChangeMatrix(lengthChangeMatrix); @@ -94,7 +94,7 @@ protected void showSpacializedMatrixChangeOfGroup() { PopulationSeasonInfo popInfo = getPopulationSeasonInfo(); MatrixND lengthChangeMatrix = popInfo.getLengthChangeMatrix(); - if (popInfo.getSimpleLengthChangeMatrix()) { + if (popInfo.isSimpleLengthChangeMatrix()) { lengthChangeMatrix = popInfo.spacializeLengthChangeMatrix(lengthChangeMatrix); } MatrixPanelEditor panel = new MatrixPanelEditor(false, 800, 300); @@ -112,7 +112,7 @@ <cell fill='horizontal' weightx='0.5'> <JRadioButton id="radioPopulationSeasonGroupChangeLengthNoSpacialized" buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" - selected='{getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}' + selected='{getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}' enabled='{getPopulationSeasonInfo() != null}' text="isisfish.populationSeasons.noSpacialized" onActionPerformed='spacializedActionPerformed()' visible='{isAgeGroupType()}' decorator='boxed' /> @@ -120,7 +120,7 @@ <cell fill='horizontal' weightx='0.5'> <JRadioButton id="radioPopulationSeasonGroupChangeLengthSpacialized" buttonGroup="radioPopulationSeasonGroupChangeLengthSpacializedGroup" - selected='{!getPopulationSeasonInfo().getSimpleLengthChangeMatrix()}' + selected='{!getPopulationSeasonInfo().isSimpleLengthChangeMatrix()}' enabled='{getPopulationSeasonInfo() != null}' text="isisfish.populationSeasons.spacialized" onActionPerformed='spacializedActionPerformed()' visible='{isAgeGroupType()}' decorator='boxed' /> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/PopulationSeasonsUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -282,16 +282,16 @@ <JPanel/> </cell> <cell fill='both' weightx='1.0'> - <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().getGroupChange()}' + <JCheckBox id="fieldPopulationSeasonGroupChange" text="isisfish.populationSeasons.changeGroup" selected='{getPopulationSeasonInfo().isGroupChange()}' decorator='boxed' _sensitivityBean='{PopulationSeasonInfo.class}' _sensitivityMethod='"GroupChange"' - onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().getAgeGroupType())}'/> + onActionPerformed='seasonGroupChanged()' enabled='{getPopulationSeasonInfo() != null}' visible='{isAgeGroupType(getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> </cell> </row> <row> <cell columns='2' fill='both' weightx='1.0' weighty='0.6'> <PopulationSeasonSpacializedUI id='populationSeasonSpecializedUI' constructorParams='this' bean='{getBean()}' populationSeasonInfo='{getPopulationSeasonInfo()}' - ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().getAgeGroupType())}'/> + ageGroupType='{isAgeGroupType(!getPopulationSeasonInfo().getPopulation().getSpecies().isAgeGroupType())}'/> </cell> </row> <row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/SpeciesStructuredUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -38,11 +38,11 @@ <Table> <row> <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().getAgeGroupType()}' + <JRadioButton id="fieldSpeciesDynamicAge" text="isisfish.species.age" selected='{getBean().isAgeGroupType()}' buttonGroup="structuredGroup" onItemStateChanged='dynamicChanged()' enabled='{isActive()}'/> </cell> <cell fill='horizontal' weightx='0.5'> - <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().getAgeGroupType()}' + <JRadioButton id="fieldSpeciesDynamicLength" text="isisfish.species.length" selected='{!getBean().isAgeGroupType()}' buttonGroup="structuredGroup" enabled='{isActive()}'/> </cell> </row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/StrategyTabUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -74,7 +74,7 @@ //fieldStrategyProportionSetOfVessels.init(); // code to replace bindings : - strategyInactivity.setActive(isActive() && getBean().getInactivityEquationUsed()); + strategyInactivity.setActive(isActive() && getBean().isInactivityEquationUsed()); //getSaveVerifier().addCurrentPanel(strategyInactivity); } @@ -144,7 +144,7 @@ <JPanel/> </cell> <cell fill='horizontal' weightx='1.0'> - <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().getInactivityEquationUsed()}' + <JCheckBox id="fieldUseEquationInactivity" selected='{getBean().isInactivityEquationUsed()}' text="isisfish.strategy.inactivityEquationUsed" onActionPerformed='getBean().setInactivityEquationUsed(fieldUseEquationInactivity.isSelected())' enabled='{isActive()}' decorator='boxed'/> </cell> @@ -153,10 +153,10 @@ <cell columns="2" fill='both' weightx='1.0' weighty='0.5'> <InputOneEquationUI id="strategyInactivity" constructorParams='this' text='isisfish.strategy.inactivity' - active="{isActive() && getBean() != null && bean.getInactivityEquationUsed()}" + active="{isActive() && getBean() != null && bean.isInactivityEquationUsed()}" bean='{getBean()}' formuleCategory='Inactivity' beanProperty='InactivityEquation' clazz='{fr.ifremer.isisfish.equation.StrategyInactivityEquation.class}' - decorator='boxed' _sensitivityBean='{Strategy.class}' _sensitivityMethod='"Inactivity"'/> <!-- bindings not work well actif='{getBean().getInactivityEquationUsed()}' --> + decorator='boxed' _sensitivityBean='{Strategy.class}' _sensitivityMethod='"Inactivity"'/> <!-- bindings not work well actif='{getBean().isInactivityEquationUsed()}' --> </cell> </row> <row> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/check/CheckRegion.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -189,7 +189,7 @@ } static public void check(PopulationSeasonInfo infoSaisonPop, CheckResult result){ - if (infoSaisonPop.getUseEquationMigration()) { + if (infoSaisonPop.isUseEquationMigration()) { check(infoSaisonPop, "MigrationEquation", infoSaisonPop.getMigrationEquation(), result); check(infoSaisonPop, "EmigrationEquation", infoSaisonPop.getEmigrationEquation(), result); check(infoSaisonPop, "ImmigrationEquation", infoSaisonPop.getImmigrationEquation(), result); Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/model/MetierSeasonInfoTargetSpeciesTableModel.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -140,7 +140,7 @@ result = targetSpecies.getTargetFactorEquation(); break; case 2: - result = targetSpecies.getPrimaryCatch(); + result = targetSpecies.isPrimaryCatch(); break; default: throw new IndexOutOfBoundsException("No such column " + columnIndex); Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/ObservationsNodeLoador.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/ObservationsNodeLoador.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/input/tree/loadors/ObservationsNodeLoador.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -26,7 +26,6 @@ import jaxx.runtime.swing.nav.NavDataProvider; import fr.ifremer.isisfish.entities.FisheryRegion; -import fr.ifremer.isisfish.entities.Gear; import fr.ifremer.isisfish.entities.Observation; import fr.ifremer.isisfish.ui.input.tree.FisheryDataProvider; import fr.ifremer.isisfish.ui.input.tree.FisheryTreeNode; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/logging/console/LogConsoleUI.jaxx =================================================================== (Binary files differ) Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixMapRenderer.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixMapRenderer.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixMapRenderer.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,9 +32,6 @@ import org.nuiton.math.matrix.MatrixND; import org.nuiton.math.matrix.viewer.MatrixRenderer; -import com.bbn.openmap.gui.OMToolSet; -import com.bbn.openmap.gui.Tool; - import fr.ifremer.isisfish.entities.FisheryRegion; import fr.ifremer.isisfish.map.ResultatLayer; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultHandler.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -35,6 +35,7 @@ import java.io.File; import java.io.FileWriter; import java.io.Writer; +import java.util.List; import javax.swing.JMenuItem; @@ -92,7 +93,7 @@ } @Override public void simulationStop(SimulationService simService, SimulationJob job) { - GenericComboModel<String> model = (GenericComboModel)resultUI.getSimulationComboBox().getModel(); + GenericComboModel<String> model = (GenericComboModel<String>)resultUI.getSimulationComboBox().getModel(); model.addElement(job.getId()); } @Override @@ -108,10 +109,10 @@ * @param resultUI resultUI */ protected void initSimulationList(ResultUI resultUI) { - java.util.List<String> value = SimulationStorage.getSimulationNames(); + List<String> value = SimulationStorage.getSimulationNames(); //resultUI.getSimulationComboBox().setEditable(false); - GenericComboModel model = new GenericComboModel(value); + GenericComboModel<String> model = new GenericComboModel<String>(value); resultUI.getSimulationComboBox().setModel(model); resultUI.getSimulationComboBox().setSelectedItem(null); } @@ -200,7 +201,7 @@ matrixViewerPanel.addMatrixFilter(new SumByYearMatrixFilter()); // init available results list - GenericComboModel model = new GenericComboModel(resultStorage.getResultName()); + GenericComboModel<String> model = new GenericComboModel<String>(resultStorage.getResultName()); resultSimulationFrame.getResultsComboBox().setModel(model); resultSimulationFrame.getResultsComboBox().addItemListener(new ItemListener() { @Override Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -37,7 +37,7 @@ <JLabel text="isisfish.result.choose.simulation"/> </cell> <cell fill="horizontal" weightx="1"> - <fr.ifremer.isisfish.ui.widget.FilterableComboBox id="simulationComboBox" + <fr.ifremer.isisfish.ui.widget.FilterableComboBox id="simulationComboBox" genericType="String" onActionPerformed="openButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);removeButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);logButton.setEnabled(getSimulationComboBox().getSelectedItem() != null);"/> </cell> <cell> Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -68,7 +68,6 @@ import org.nuiton.util.FileUtil; import org.nuiton.util.ZipUtil; import org.nuiton.widget.SwingUtil; -import org.nuiton.widget.editor.RSyntaxEditor; import fr.ifremer.isisfish.IsisFish; import fr.ifremer.isisfish.IsisFishRuntimeException; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -77,7 +77,7 @@ return getContextValue(SimulAction.class); } - public ComboBoxModel getSensitivityAnalysisModel() { + public ComboBoxModel<String> getSensitivityAnalysisModel() { List<String> sensitivityNames = getSimulAction().getSensitivityAnalysisNames(); SensitivityAnalysisComboModel model = new SensitivityAnalysisComboModel(sensitivityNames); return model; Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/TableBlockingLayerUI.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -74,14 +74,14 @@ private static Log log = LogFactory.getLog(TableBlockingLayerUI.class); /** Parent UI. */ - protected InputContentUI parent; + protected InputContentUI<?> parent; /** * Init layer with parent. * * @param parent parent */ - public TableBlockingLayerUI(InputContentUI parent) { + public TableBlockingLayerUI(InputContentUI<?> parent) { this.parent = parent; } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorListModel.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorListModel.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/model/FactorListModel.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -42,7 +42,7 @@ * Last update : $Date$ * By : $Author$ */ -public class FactorListModel extends DefaultListModel { +public class FactorListModel extends DefaultListModel<Factor> { /** serialVersionUID. */ private static final long serialVersionUID = 2281927104735245489L; @@ -73,7 +73,7 @@ * @see javax.swing.ListModel#getElementAt(int) */ @Override - public Object getElementAt(int index) { + public Factor getElementAt(int index) { return factors.get(index); } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/AdvancedParamsUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ $Id$ $HeadURL$ %% - Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric + Copyright (C) 2009 - 2014 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 Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/simulator/ParamsUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -293,25 +293,7 @@ simulAction.setStrategies(listSimulParamsStrategies.getSelectedValues()); } -protected void selectFilter() { - try { - java.util.List<String> simulationsNames = fr.ifremer.isisfish.ui.simulator.filter.SimulationFilterUtil.filterSimulation(simulAction.getOldSimulationItem()); - // TODO add " " to not triger event (need to be fixed) - simulationsNames.add(0, " "); - simulAction.setOldSimulatorNames(simulationsNames); - fieldSimulParamsSelect.setModel(getSimulParamsSelectModel(false)); - } catch (ParseException ex) { - if (log.isErrorEnabled()) { - log.error("Can't select simulation filter", ex); - } - } catch (IOException ex) { - if (log.isErrorEnabled()) { - log.error("Can't select simulation filter", ex); - } - } -} - -protected ComboBoxModel getSimulParamsSelectModel() { +protected ComboBoxModel<String> getSimulParamsSelectModel() { return getSimulParamsSelectModel(false); } Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/vcs/VCSGenerateSshKeyUI.jaxx 2014-11-10 14:51:18 UTC (rev 4130) @@ -33,6 +33,7 @@ java.util.Map; java.awt.Color javax.swing.JComponent + java.nio.charset.StandardCharsets </import> <script><![CDATA[ @@ -89,9 +90,12 @@ JSch jsch=new JSch(); KeyPair kpair=KeyPair.genKeyPair(jsch, KeyPair.RSA, 2048); if (password.length > 0) { - kpair.setPassphrase(Arrays.toString(password)); + String strPassphase = Arrays.toString(password); + byte[] bytPassphrase = strPassphase.getBytes(StandardCharsets.UTF_8); + kpair.writePrivateKey(privateKeyFile.getAbsolutePath(), bytPassphrase); + } else { + kpair.writePrivateKey(privateKeyFile.getAbsolutePath()); } - kpair.writePrivateKey(privateKeyFile.getAbsolutePath()); kpair.writePublicKey(publicKeyFile.getAbsolutePath(), vcsLogin + "@forIsisFish"); if (log.isInfoEnabled()) { log.info("Finger print: "+kpair.getFingerPrint()); Deleted: trunk/src/main/java/fr/ifremer/isisfish/ui/widget/DummyLayerUI.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/widget/DummyLayerUI.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/widget/DummyLayerUI.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,64 +0,0 @@ -/* - * #%L - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2013 Ifremer, Codelutin, Chatellier Eric - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-3.0.html>. - * #L% - */ -package fr.ifremer.isisfish.ui.widget; - -import java.awt.Color; -import java.awt.Font; -import java.awt.Graphics2D; - -import javax.swing.JComponent; - -import org.jdesktop.jxlayer.JXLayer; -import org.jdesktop.jxlayer.plaf.AbstractLayerUI; - -public class DummyLayerUI extends AbstractLayerUI<JComponent> { - - /** serialVersionUID. */ - private static final long serialVersionUID = 309245880711380974L; - - @Override - protected void paintLayer(Graphics2D g2, JXLayer<? extends JComponent> l) { - super.paintLayer(g2, l); - - // position - //g2.translate(-35, 90); // top left - g2.translate(l.getBounds().getMaxX() - 160, l.getBounds().getMaxY()); // bottom right - - // yellow backgroung - g2.rotate(Math.PI * -42 / 180); - g2.setColor(Color.YELLOW); - g2.fillRect(10, 10, 200, 30); - - // text - g2.translate(70, 15); - g2.setFont(new Font("Dialog", Font.BOLD, 16)); - g2.setColor(Color.BLACK); - g2.drawString("Maquette",10,10); - - // for test only - g2.translate(-3, 10); - g2.setFont(new Font("Dialog", Font.ITALIC, 10)); - g2.setColor(Color.BLACK); - g2.drawString("(non fonctionnelle)",10,10); - } -} Copied: trunk/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java (from rev 4129, branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/util/DependencyUtil.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,291 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Ifremer, 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.util; + +import java.io.BufferedInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; +import org.objectweb.asm.Type; +import org.objectweb.asm.TypePath; + +import fr.ifremer.isisfish.datastore.ExportStorage; +import fr.ifremer.isisfish.datastore.FormuleStorage; +import fr.ifremer.isisfish.datastore.ObjectiveStorage; +import fr.ifremer.isisfish.datastore.OptimizationStorage; +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.SimulationPlanStorage; +import fr.ifremer.isisfish.datastore.SimulatorStorage; + +/** + * Class utilitaire chargées d'inspecter le bytecode de certaines classe des scripts utilisateur + * d'IsisFish pour en extraire des informations. + * + * @author Eric Chatellier + */ +public class DependencyUtil { + + private static final Log log = LogFactory.getLog(DependencyUtil.class); + + /** + * Extrait les dépendences d'une class compilé à partir de son bytecode en ne conservant que + * les dependances des scripts utilisateurs. + * + * @param rootDirectory + * @param files ensemble de fichier à analyzer (fichiers .class) + * @return extract class set + */ + public static Set<String> extractDependencies(File rootDirectory, Collection<File> files) { + Set<String> deps = new HashSet<String>(); + Set<File> alreadyDone = new HashSet<File>(); + recursiveExtractDependencies(rootDirectory, files, alreadyDone, deps); + return deps; + } + + protected static void recursiveExtractDependencies(File rootDirectory, Collection<File> todoClassFiles, Set<File> alreadyDone, Set<String> deps) { + + // extract deps + for (File file : todoClassFiles) { + alreadyDone.add(file); + try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { + Set<String> fileDeps = extractDependencies(is); + deps.addAll(fileDeps); + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("Can't extract dependencies", ex); + } + } + + } + + // convert deps to class filTopiaFlywayServicees + Collection<File> newClassFiles = new ArrayList<>(); + for (String dep : deps) { + String classRelative = dep.replace('.', File.separatorChar) + ".class"; + File classFile = new File(rootDirectory, classRelative); + if (!alreadyDone.contains(classFile)) { + newClassFiles.add(classFile); + } + } + + // make new recursion if necessary + if (!newClassFiles.isEmpty()) { + recursiveExtractDependencies(rootDirectory, newClassFiles, alreadyDone, deps); + } + } + + /** + * Extrait les dépendences d'une class compilé à partir de son bytecode. + * + * @param clazzStream la classe à analyser + * @return extract class set + */ + protected static Set<String> extractDependencies(InputStream clazzStream) { + final Set<String> result = new HashSet<>(); + + // method body visitor + final MethodVisitor mv = new MethodVisitor(Opcodes.ASM5) { + + @Override + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { + registerDescriptor(result, desc); + return super.visitAnnotation(desc, visible); + } + + @Override + public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { + registerDescriptor(result, desc); + return super.visitTypeAnnotation(typeRef, typePath, desc, visible); + } + + @Override + public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) { + registerDescriptor(result, desc); + return super.visitParameterAnnotation(parameter, desc, visible); + } + + @Override + public void visitTypeInsn(int opcode, String type) { + registerType(result, type); + super.visitTypeInsn(opcode, type); + } + + @Override + public void visitFieldInsn(int opcode, String owner, String name, String desc) { + registerType(result, owner); + registerDescriptor(result, desc); + super.visitFieldInsn(opcode, owner, name, desc); + } + + @Override + public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) { + registerType(result, owner); + registerDescriptor(result, desc); + super.visitMethodInsn(opcode, owner, name, desc, itf); + } + + @Override + public void visitLdcInsn(Object cst) { + if (cst instanceof Type) { + registerType(result, ((Type)cst).getClassName()); + } + super.visitLdcInsn(cst); + } + + @Override + public void visitTryCatchBlock(Label start, Label end, Label handler, String type) { + registerType(result, type); + super.visitTryCatchBlock(start, end, handler, type); + } + + @Override + public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) { + registerDescriptor(result, desc); + super.visitLocalVariable(name, desc, signature, start, end, index); + } + }; + + // class visitor + ClassVisitor visitor = new ClassVisitor(Opcodes.ASM5) { + + @Override + public void visit(int version, int access, String name, + String signature, String superName, String[] interfaces) { + registerType(result, superName); + super.visit(version, access, name, signature, superName, interfaces); + } + + @Override + public AnnotationVisitor visitAnnotation(String desc, + boolean visible) { + registerDescriptor(result, desc); + return super.visitAnnotation(desc, visible); + } + + @Override + public FieldVisitor visitField(int access, String name, + String desc, String signature, Object value) { + registerDescriptor(result, desc); + return super.visitField(access, name, desc, signature, value); + } + + @Override + public MethodVisitor visitMethod(int access, String name, + String desc, String signature, String[] exceptions) { + registerDescriptor(result, desc); + return mv; + } + }; + + // parse input class + try { + ClassReader classReader = new ClassReader(clazzStream); + classReader.accept(visitor, 0); + } catch (IOException ex) { + if (log.isErrorEnabled()) { + log.error("Can't extract dependencies", ex); + } + } + + return result; + } + + /** + * Register type if necessary (depends on another user script). + * + * @param types types collection + * @param type type to add + */ + protected static void registerType(Set<String> types, String type) { + //System.out.println("==> " + type); + if (StringUtils.startsWithAny(type, + ExportStorage.EXPORT_PATH, + FormuleStorage.FORMULE_PATH, + ObjectiveStorage.OBJECTIVE_PATH, + OptimizationStorage.OPTIMIZATION_PATH, + RuleStorage.RULE_PATH, + ScriptStorage.SCRIPT_PATH, + SensitivityAnalysisStorage.SENSITIVITY_ANALYSIS_PATH, + SensitivityExportStorage.SENSITIVITY_EXPORT_PATH, + SimulationPlanStorage.SIMULATION_PLAN_PATH, + SimulatorStorage.SIMULATOR_PATH)) { + String dotType = type.replace('/', '.'); + types.add(dotType); + } + } + + /** + * Clean type to extract valid class name. + * + * Ex: + * <ul> + * <li>Lfr/ifremer/isisfish/types/Month;</li> + * <li>[Ljava/lang/String;</li> + * <li>(Ljava/lang/Class;)Lorg/apache/commons/logging/Log;</li> + * </ul> + * + * @param types types collection + * @param descriptor descriptor + */ + protected static void registerDescriptor(Set<String> types, String descriptor) { + if (descriptor.startsWith("(")) { + int endIndex = descriptor.indexOf(')'); + registerDescriptor(types, descriptor.substring(1, endIndex)); + registerDescriptor(types, descriptor.substring(endIndex + 1)); + } else { + // full pattern : \\[*L([^;]+);|\\[[ZBCSIFDJ]|[ZBCSIFDJ] + // on exclut la fin (les types primitifs) pour ne conserver que la partie interessante + // du pattern qui nous concerne + Pattern pattern = Pattern.compile("\\[*L([^;]+);"); + Matcher matcher = pattern.matcher(descriptor); + while (matcher.find()) { + String match = matcher.group(1); + registerType(types, match); + } + } + } +} Modified: trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnGuava.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -94,7 +94,7 @@ // elle meme qu'elle soit dans le backend ou non est // certainement utilisee ailleur, donc seul la taille // des pointeurs dans la collection est prise ici - result += ((Collection)value).size() * POINTER_SIZE; + result += ((Collection<?>)value).size() * POINTER_SIZE; } else if (value instanceof Number) { // int| double // seulement une valeur, on ajoute 1 @@ -228,7 +228,7 @@ // to keep more memory for JVM sizeCache = Math.min(this.maxCache, amount); - CacheBuilder builder = CacheBuilder.newBuilder(); + CacheBuilder<Object, Object> builder = CacheBuilder.newBuilder(); builder.maximumWeight(sizeCache); builder.weigher(isisWeigher); if (initialCapacity > 0) { Modified: trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnReferenceMap.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnReferenceMap.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/util/IsisCacheBackendOnReferenceMap.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,7 +32,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import fr.ifremer.isisfish.simulator.SimulationContext; import fr.ifremer.isisfish.types.TimeStep; /** Modified: trunk/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/util/JavadocHelper.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -39,7 +39,6 @@ import java.util.List; import org.apache.commons.io.FileUtils; -import org.apache.commons.lang3.reflect.MethodUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.FileUtil; Copied: trunk/src/main/java/fr/ifremer/isisfish/util/RUtil.java (from rev 4129, branches/4.3.0-log4j2/src/main/java/fr/ifremer/isisfish/util/RUtil.java) =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/RUtil.java (rev 0) +++ trunk/src/main/java/fr/ifremer/isisfish/util/RUtil.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,137 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * 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 + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.util; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Field; +import java.util.List; + +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * Utility class fo R integration with isis fish. + * + * @author Eric Chatellier + */ +public class RUtil { + + private static final Log log = LogFactory.getLog(RUtil.class); + + /** + * Try to call "R" process to get location where jri is installed. + */ + public static void initJri() { + + // set Rtype in jni mode + System.setProperty("R.type", "jni"); + + try { + ProcessBuilder pb = new ProcessBuilder("Rscript", "-e", "installed.packages()[which(installed.packages()[,1]=='rJava'),]['LibPath']"); + Process process = pb.start(); + int exitValue = process.waitFor(); + + if (exitValue == 0) { + // normal exit + parseRscriptOutput(process.getInputStream()); + } else { + // R trouvé, mais la commande R a échoué + InputStream err = process.getErrorStream(); + if (log.isErrorEnabled()) { + log.error("Can't call Rscript : " + IOUtils.toString(err)); + } + } + } catch (IOException ex) { + // Le processus n'a pas pu être lancé (R non trouvé) + if (log.isDebugEnabled()) { + log.debug("Can't find R", ex); + } + } catch (InterruptedException ex) { + if (log.isErrorEnabled()) { + log.error("Can't find R", ex); + } + } + } + + /** + * Parse valid Rscript output to find if rJava is installed and where it is installed. + * + * @param is process output + * @throws IOException + */ + protected static void parseRscriptOutput(InputStream is) throws IOException { + List<String> output = IOUtils.readLines(is); + + // 1 lignes = commande OK, mais rJava n'est pas installé + // 2 lignes = commande OK et rJava est installé + if (output.size() == 1) { + //installRJava(); + } else if (output.size() == 2) { + // get install location without "" + String location = output.get(1).trim(); + location = StringUtils.removeStart(location, "\""); + location = StringUtils.removeEnd(location, "\""); + // build full library path + location = location.replace('/', File.separatorChar); + location += File.separator + "rJava" + File.separator + "jri"; + setJavaLibraryPath(location); + } else if (log.isErrorEnabled()) { + log.error("Can't analyze Rscript output. was: "); + for (String line : output) { + log.error(line); + } + } + } + + /** + * Set runtime java library path. + * + * http://fahdshariff.blogspot.fr/2011/08/changing-java-library-path-at-runtime... + * + * @param newValue new value to set + */ + protected static void setJavaLibraryPath(String newValue) { + if (log.isInfoEnabled()) { + log.info("Adding '" + newValue + "' to java.library.path"); + } + System.setProperty("java.library.path", newValue); + + //set sys_paths to null + try { + final Field sysPathsField = ClassLoader.class.getDeclaredField("sys_paths"); + sysPathsField.setAccessible(true); + sysPathsField.set(null, null); + } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ex) { + if (log.isErrorEnabled()) { + log.error("Cant' reset ClassLoader#sys_paths value", ex); + } + } + } +} Modified: trunk/src/main/java/fr/ifremer/isisfish/util/ssh/ProxyCommand.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/util/ssh/ProxyCommand.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/util/ssh/ProxyCommand.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -51,7 +51,7 @@ public void connect(SocketFactory socket_factory, String host, int port, int timeout) throws Exception { String fullCommand = command.replace("%h", host); - fullCommand = fullCommand.replace("%p", new Integer(port).toString()); + fullCommand = fullCommand.replace("%p", String.valueOf(port)); p = Runtime.getRuntime().exec(fullCommand); in = p.getInputStream(); out = p.getOutputStream(); Modified: trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/vcs/VCS.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -30,7 +30,7 @@ import java.util.List; import java.util.Map; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; /** * Version control system. Modified: trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSNone.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -31,7 +31,7 @@ import java.util.List; import java.util.Map; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; /** * VCSNone (svn or vcs) must extends this class. This class can be used as dummy Modified: trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/java/fr/ifremer/isisfish/vcs/VCSSVN.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -40,7 +40,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; import org.tmatesoft.svn.core.ISVNDirEntryHandler; import org.tmatesoft.svn.core.ISVNLogEntryHandler; import org.tmatesoft.svn.core.SVNCommitInfo; Modified: trunk/src/main/resources/i18n/isis-fish_fr_FR.properties =================================================================== --- trunk/src/main/resources/i18n/isis-fish_fr_FR.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/resources/i18n/isis-fish_fr_FR.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -598,7 +598,7 @@ isisfish.message.import=Importer %1$s isisfish.message.import.equation.convert=Conversion manuelle de l'équation isisfish.message.import.finished=Import terminé -isisfish.message.import.region.name=Entre le nom de la réegion à importer +isisfish.message.import.region.name=Entrer le nom de la région à importer isisfish.message.import.region.xml=Région XML (ISIS-Fish V2.x) isisfish.message.import.region.zipped=Zipped Region isisfish.message.import.scripts.file=Importer des scripts depuis une archive zip Copied: trunk/src/main/resources/isis-config-4 (from rev 4129, branches/4.3.0-log4j2/src/main/resources/isis-config-4) =================================================================== --- trunk/src/main/resources/isis-config-4 (rev 0) +++ trunk/src/main/resources/isis-config-4 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1 @@ +isisfish.version=${project.version} Deleted: trunk/src/main/resources/log4j.properties =================================================================== --- trunk/src/main/resources/log4j.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/resources/log4j.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,45 +0,0 @@ -### -# #%L -# IsisFish -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2005 - 2013 Ifremer, CodeLutin, Chatellier Eric -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -# Global logging configuration -log4j.rootLogger=ERROR, stdout - -# Console output... -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n - -# package level -log4j.logger.fr.ifremer.isisfish=INFO -log4j.logger.org.nuiton=WARN -log4j.logger.exports=INFO -log4j.logger.formules=INFO -log4j.logger.objectives=INFO -log4j.logger.optimizations=INFO -log4j.logger.rules=INFO -log4j.logger.scripts=INFO -log4j.logger.sensitivityanalysis=INFO -log4j.logger.sensitivityexports=INFO -log4j.logger.simulationplans=INFO -log4j.logger.simulators=INFO Copied: trunk/src/main/resources/log4j2.xml (from rev 4129, branches/4.3.0-log4j2/src/main/resources/log4j2.xml) =================================================================== (Binary files differ) Modified: trunk/src/main/resources/sensitivity.properties =================================================================== --- trunk/src/main/resources/sensitivity.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/resources/sensitivity.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ # $Id$ # $HeadURL$ # %% -# Copyright (C) 2009 - 2011 Ifremer, CodeLutin, Chatellier Eric +# Copyright (C) 2009 - 2014 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 Modified: trunk/src/main/xmi/isis-fish.properties =================================================================== --- trunk/src/main/xmi/isis-fish.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/main/xmi/isis-fish.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,7 +32,6 @@ model.tagvalue.hibernateProxyInterface=none model.tagvalue.constantPrefix=PROPERTY_ model.tagvalue.useEnumerationName=true -model.tagvalue.doNotGenerateBooleanGetMethods=false model.tagvalue.notGenerateReadListeners=true fr.ifremer.isisfish.entities.ActiveRule.class.tagvalue.contextable=true fr.ifremer.isisfish.entities.Cell.class.tagvalue.contextable=true Modified: trunk/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/java/fr/ifremer/isisfish/entity/TopiaDAOTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -3,7 +3,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2010 - 2012 Ifremer, Codelutin, Chatellier Eric + * Copyright (C) 2010 - 2014 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 @@ -26,7 +26,6 @@ import java.io.IOException; import java.util.List; -import org.hamcrest.CoreMatchers; import org.junit.Assert; import org.junit.Test; import org.nuiton.topia.TopiaContext; @@ -84,7 +83,7 @@ population2.setName("thon"); allPopulation = populationDAO.findAll(); Assert.assertEquals(2, allPopulation.size()); - Assert.assertThat(allPopulation, CoreMatchers.hasItem(population2)); + Assert.assertTrue(allPopulation.contains(population2)); context.rollbackTransaction(); @@ -93,7 +92,7 @@ population3.setName("requin"); allPopulation = populationDAO.findAll(); Assert.assertEquals(2, allPopulation.size()); - Assert.assertThat(allPopulation, CoreMatchers.hasItem(population3)); + Assert.assertTrue(allPopulation.contains(population3)); context.commitTransaction(); simulation.closeStorage(); Modified: trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/java/fr/ifremer/isisfish/logging/SimulationLoggerUtilTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -32,13 +32,16 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; +import org.apache.logging.log4j.Level; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.junit.Assert; +import org.junit.Ignore; import org.junit.Test; import fr.ifremer.isisfish.AbstractIsisFishTest; +@Ignore public class SimulationLoggerUtilTest extends AbstractIsisFishTest { static private final String category = "fr.ifremer.isisfish.logging"; @@ -60,29 +63,15 @@ logInfo(logInit2, "before new config", null, null); logInfo(log, "before new config", null, null); - String threadName = Thread.currentThread().getName(); - // use a logger we know to be scan as been keep for original level - Logger hibernatelog = Logger.getLogger("org.hibernate"); + Logger hibernatelog = LogManager.getLogger("org.hibernate"); Level hibernateLogLevel = hibernatelog.getLevel(); - String loggerFile = new File(getTestDirectory(), SimulationLoggerUtilTest.class.getSimpleName() + "_" + System.nanoTime() + ".log").getAbsolutePath(); - System.out.println(">>>> loggerFile " + loggerFile); - // todo do a test for addSimulationAppender too! - SimulationLoggerUtil.addSimulationAppender( - loggerFile, - appenderId, - "INFO", - "INFO", - "INFO", - threadName - ); - // check hibernate level was not changed - Assert.assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel()); + Assert.assertEquals(hibernateLogLevel, LogManager.getLogger("org.hibernate").getLevel()); final Log logger = LogFactory.getLog(appenderId); @@ -117,7 +106,6 @@ // means nothing!!! t.join(); Assert.assertTrue(!t.isAlive()); - SimulationLoggerUtil.removeSimulationAppender(appenderId); message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!"; logInit.info(message); @@ -165,27 +153,16 @@ logDebug(logInit2, "before new config", null); logDebug(log, "before new config", null); - String threadName = Thread.currentThread().getName(); - // use a logger we know to be scan as been keep for original level - Logger hibernatelog = Logger.getLogger("org.hibernate"); + Logger hibernatelog = LogManager.getLogger("org.hibernate"); Level hibernateLogLevel = hibernatelog.getLevel(); String loggerFile = "testLog.log"; - // todo do a test for addSimulationAppender too! - SimulationLoggerUtil.addSimulationAppender( - loggerFile, - appenderId, - "DEBUG", - "DEBUG", - "DEBUG", - threadName - ); // check hibernate level was not changed - Assert.assertEquals(hibernateLogLevel, Logger.getLogger("org.hibernate").getLevel()); + Assert.assertEquals(hibernateLogLevel, LogManager.getLogger("org.hibernate").getLevel()); final Log logger = LogFactory.getLog(appenderId); @@ -220,7 +197,6 @@ // means nothing!!! t.join(); Assert.assertTrue(!t.isAlive()); - SimulationLoggerUtil.removeSimulationAppender(appenderId); message = "appender was destoyed WE MUST NOT SEE this message in simulation log file!!!"; logInit.info(message); Modified: trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/java/fr/ifremer/isisfish/simulator/SimulationPreScriptTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -31,9 +31,7 @@ import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.ConvertUtilsBean; -import org.junit.After; import org.junit.Assert; -import org.junit.Before; import org.junit.Test; import org.nuiton.math.matrix.MatrixFactory; import org.nuiton.math.matrix.MatrixND; @@ -55,21 +53,6 @@ */ public class SimulationPreScriptTest extends AbstractIsisFishTest { - @Before - public void setUp() throws Exception { - // not do it in @BeforeClass - // test will fail ! - init(); - // very important , other test wil fail with that - //System.setProperty("hibernate.hbm2ddl.auto", "create"); - } - - @After - public void tearDown() { - // very important , other test wil fail with that - //System.clearProperty("hibernate.hbm2ddl.auto"); - } - /** * Test que les chaine represantant des matrices sont correctement * transformée en MatrixND. Modified: trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2006 - 2011 Ifremer, Code Lutin, Chatellier Eric + * Copyright (C) 2006 - 2014 Ifremer, 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 @@ -25,6 +25,7 @@ package fr.ifremer.isisfish.simulator.launcher; +import java.io.File; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -35,7 +36,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.junit.Assert; -import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.nuiton.math.matrix.MatrixFactory; @@ -48,6 +48,9 @@ import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.datastore.RegionStorage; import fr.ifremer.isisfish.datastore.RuleStorage; +import fr.ifremer.isisfish.datastore.ScriptStorage; +import fr.ifremer.isisfish.datastore.SimulationStorage; +import fr.ifremer.isisfish.datastore.SimulatorStorage; import fr.ifremer.isisfish.datastore.StorageException; import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.entities.PopulationGroup; @@ -85,11 +88,61 @@ /** Commons logging log. */ private static Log log = LogFactory.getLog(SimulationServiceTest.class); - @Before - public void setUp() throws Exception { - // not do it in @BeforeClass - // test will fail ! - AbstractIsisFishTest.init(); + /** + * Lance une simulation simple avec le simulateur par cellule. + * + * Test is wrong if it take more than 2 min. + * + * @throws InterruptedException + */ + @Test(timeout=120 * 1000) + public void testSimulationEffortByCell() throws InterruptedException { + + SimulationParameter params = new SimulationParameterImpl(); + // set params region + params.setRegionName("DemoRegion"); + // simulator + params.setSimulatorName("SimulatorEffortByCell.java"); + // set population + List<Population> pops = new ArrayList<Population>(); + Population pop = new PopulationImpl(); + pop.setName("test population"); + pop.setPopulationGroup(new ArrayList<PopulationGroup>()); + pop.setPopulationZone(new ArrayList<Zone>()); + pops.add(pop); + params.setPopulations(pops); + // strat + List<Strategy> strats = new ArrayList<Strategy>(); + Strategy strategy = new StrategyImpl(); + strategy.setName("stratest"); + strats.add(strategy); + params.setStrategies(strats); + // number of year + params.setNumberOfYear(1); + + // run simulation + SimulationService service = SimulationService.getService(); + SimulatorLauncher launcher = new InProcessSimulatorLauncher(); + service.addSimulationLauncher(launcher); + String simulationId = "effort by cell test number 1"; + service.submit("effort by cell test number 1", params, launcher, 0); + + // temporise la fin de test , sinon junit tue tous les process + do { + Thread.sleep(2000); + } while (!service.jobs.isEmpty()); + + // suite au changement de la compilation, on vérifie que certains fichier java + // doivent être automatiquement inclut dans les sources + File simDir = SimulationStorage.getSimulationDirectory(simulationId); + File simulatorDir = new File(simDir, SimulatorStorage.SIMULATOR_PATH); + File scriptDir = new File(simDir, ScriptStorage.SCRIPT_PATH); + Assert.assertTrue(new File(simulatorDir, "DefaultSimulator.java").exists()); + Assert.assertTrue(new File(simulatorDir, "SimulatorEffortByCell.java").exists()); + Assert.assertTrue(new File(scriptDir, "ResultName.java").exists()); + Assert.assertTrue(new File(scriptDir, "SiMatrix.java").exists()); + Assert.assertTrue(new File(scriptDir, "GravityModel.java").exists()); + Assert.assertTrue(new File(scriptDir, "RuleUtil.java").exists()); } /** @@ -181,9 +234,11 @@ * Lance une simulation avec des facteurs de sensibilité. * * Test is wrong if it take more than 2 min. + * + * @throws InterruptedException */ @Test(timeout=120 * 1000) - public void testRunSensivitySimulation() { + public void testRunSensivitySimulation() throws InterruptedException { SimulationParameter params = new SimulationParameterImpl(); // set params region @@ -217,15 +272,10 @@ sensitivityAnalysis, designPlan); // temporise la fin de test , sinon junit tue tous les process - try { - do { - Thread.sleep(2000); - } while (!service.jobs.isEmpty()); - } catch (InterruptedException e) { - if (log.isErrorEnabled()) { - log.error("Can't wait wimulation to end", e); - } - } + do { + Thread.sleep(2000); + } while (!service.jobs.isEmpty()); + } /** Copied: trunk/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java (from rev 4129, branches/4.3.0-log4j2/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java) =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java (rev 0) +++ trunk/src/test/java/fr/ifremer/isisfish/util/DependencyUtilTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -0,0 +1,162 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2014 Ifremer, 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 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ +package fr.ifremer.isisfish.util; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.Set; + +import org.junit.Assert; +import org.junit.Test; + +import fr.ifremer.isisfish.AbstractIsisFishTest; +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.IsisFishException; +import fr.ifremer.isisfish.datastore.JavaSourceStorage; +import fr.ifremer.isisfish.datastore.RuleStorage; +import fr.ifremer.isisfish.datastore.ScriptStorage; +import fr.ifremer.isisfish.datastore.SimulatorStorage; + +/** + * Test concernant la gestion du bytecode des scripts utilisateur. + * + * @author Eric Chatellier + */ +public class DependencyUtilTest extends AbstractIsisFishTest { + + /** + * Extract dependency for test. + * + * @param storage storage + * @return deps + * @throws IsisFishException + */ + protected static Set<String> extractDependencies(JavaSourceStorage storage) throws IsisFishException { + String clazzName = storage.getCodeClass().getName(); + File classFile = new File(IsisFish.config.getCompileDirectory(), clazzName.replace('.', File.separatorChar) + ".class"); + Set<String> result = DependencyUtil.extractDependencies(IsisFish.config.getCompileDirectory(), Collections.singletonList(classFile)); + return result; + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies1() throws IsisFishException, IOException { + SimulatorStorage script = SimulatorStorage.getSimulator("SimulatorEffortByCell"); + Set<String> deps = extractDependencies(script); + // premier niveau + Assert.assertTrue(deps.contains("simulators.DefaultSimulator")); + // deuxieme niveau de dependance + Assert.assertTrue(deps.contains("scripts.SiMatrix")); + Assert.assertTrue(deps.contains("scripts.GravityModel")); + // troisieme niveau + Assert.assertTrue(deps.contains("scripts.MinimisationUtil")); + Assert.assertTrue(deps.contains("scripts.ObjectiveFunction")); + Assert.assertTrue(deps.contains("scripts.ObjectiveFunctionBaranov")); + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies2() throws IsisFishException, IOException { + SimulatorStorage script = SimulatorStorage.getSimulator("DefaultSimulator"); + Set<String> deps = extractDependencies(script); + Assert.assertTrue(deps.contains("scripts.GravityModel")); + Assert.assertTrue(deps.contains("scripts.ResultName")); + Assert.assertTrue(deps.contains("scripts.SiMatrix")); + + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies3() throws IsisFishException, IOException { + RuleStorage script = RuleStorage.getRule("Cantonnement"); + Set<String> deps = extractDependencies(script); + Assert.assertTrue(deps.contains("scripts.ResultName")); + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies4() throws IsisFishException, IOException { + ScriptStorage script = ScriptStorage.getScript("SiMatrix"); + Set<String> deps = extractDependencies(script); + Assert.assertTrue(deps.contains("scripts.ObjectiveFunctionBaranov")); + Assert.assertTrue(deps.contains("scripts.ObjectiveFunction")); + Assert.assertTrue(deps.contains("scripts.MinimisationUtil")); + Assert.assertTrue(deps.contains("scripts.ResultName")); + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies5() throws IsisFishException, IOException { + ScriptStorage script = ScriptStorage.getScript("GravityModel"); + Set<String> deps = extractDependencies(script); + Assert.assertTrue(deps.contains("scripts.SiMatrix")); + Assert.assertTrue(deps.contains("scripts.ResultName")); + } + + /** + * Récupère une classe parmis les scripts de test et vérifie que les dépendances sont bien + * extraites. + * + * @throws IsisFishException + * @throws IOException + */ + @Test + public void testExtractDependencies6() throws IsisFishException, IOException { + ScriptStorage script = ScriptStorage.getScript("ObjectiveFunctionBaranov"); + Set<String> deps = extractDependencies(script); + Assert.assertTrue(deps.contains("scripts.ObjectiveFunction")); + } +} Modified: trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/java/fr/ifremer/isisfish/vcs/VCSSVNTest.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -37,7 +37,8 @@ import org.apache.commons.io.FileUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.nuiton.util.Version; +import org.nuiton.util.version.Version; +import org.nuiton.util.version.Versions; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -326,7 +327,7 @@ vcs.add(Arrays.asList(fileToAdd), "ajout d'un fichier"); // test switchTag - vcs.setTag(new Version(3, 1, 0)); + vcs.setTag(Versions.valueOf("3.1.0")); Assert.assertTrue(vcs.getTag().startsWith("/tags/3.1.0")); Assert.assertEquals(FILECONTENTTAG, FileUtils.readFileToString(version)); Assert.assertTrue(demo.exists()); @@ -890,10 +891,10 @@ log.info("testGetDiff()"); } - Version version = new Version(3, 1, 0); + Version version = Versions.valueOf("3.1.0"); Assert.assertTrue(vcs.isTag(version)); - version = new Version(3, 2, 0); + version = Versions.valueOf("3.2.0"); Assert.assertFalse(vcs.isTag(version)); } @@ -1144,7 +1145,7 @@ } // chechout tags - vcs.checkout(new Version(3, 1, 0), false); + vcs.checkout(Versions.valueOf("3.1.0"), false); // modif on remote repo on tag :) File file = new File(vcs.getLocalRepository(), "scripts" @@ -1173,7 +1174,7 @@ FileUtils.writeStringToFile(file2, "oooooo"); // try to update... - List<File> filesInConflict = vcs.setTag(new Version(3, 1, 0)); + List<File> filesInConflict = vcs.setTag(Versions.valueOf("3.1.0")); Assert.assertNotNull(filesInConflict); Assert.assertEquals(1, filesInConflict.size()); log.debug("Conflicts are : " + filesInConflict); Deleted: trunk/src/test/resources/VCSConfig-junit_CVS.properties =================================================================== --- trunk/src/test/resources/VCSConfig-junit_CVS.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/resources/VCSConfig-junit_CVS.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,30 +0,0 @@ -### -# #%L -# IsisFish -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2010 Ifremer, Code Lutin -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -vcs.username=anonymous -vcs.hostname=cvs.labs.libre-entreprise.org -vcs.remote.path=/cvsroot/isis-fish -vcs.remote.database=isis-fish-vcs-test_junit -vcs.local.database=isis-vcs-test_junit_SVN -vcs.ssh2.connexion=false Deleted: trunk/src/test/resources/VCSConfig-junit_SVN.properties =================================================================== --- trunk/src/test/resources/VCSConfig-junit_SVN.properties 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/resources/VCSConfig-junit_SVN.properties 2014-11-10 14:51:18 UTC (rev 4130) @@ -1,31 +0,0 @@ -### -# #%L -# IsisFish -# -# $Id$ -# $HeadURL$ -# %% -# Copyright (C) 2009 - 2010 Ifremer, Code Lutin -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public -# License along with this program. If not, see -# <http://www.gnu.org/licenses/gpl-3.0.html>. -# #L% -### -vcs.username=anonymous -vcs.typeRepo=TAG -vcs.hostname=labs.libre-entreprise.org -vcs.remote.path=svnroot/isis-fish-data -vcs.ssh2.connexion=false -vcs.remote.database=isis-fish-vcs-test_junit -vcs.local.database=isis-vcs-test_junit_SVN Deleted: trunk/src/test/resources/isis-database-3_cvs.zip =================================================================== (Binary files differ) Modified: trunk/src/test/resources/test-database/rules/TACpoids.java =================================================================== --- trunk/src/test/resources/test-database/rules/TACpoids.java 2014-11-07 09:20:46 UTC (rev 4129) +++ trunk/src/test/resources/test-database/rules/TACpoids.java 2014-11-10 14:51:18 UTC (rev 4130) @@ -183,7 +183,7 @@ log.info(" TAC atteint [TAC] preAction for: " + metier); TargetSpecies ts = metier.getMetierSeasonInfo(step.getMonth()) .getSpeciesTargetSpecies(param_species); - if (ts != null && ts.getPrimaryCatch()) { + if (ts != null && ts.isPrimaryCatch()) { // recupere tous les metiers qui ont l'espece en capture principale =>metiers vises // aimedMetiers ne fonctionne pas je ne sais pas pourquoi ! mais au final forbiddenMetier aura le meme effet