Isis-fish-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
June 2011
- 3 participants
- 85 discussions
r3420 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore export rule simulator ui/sensitivity util
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
17 Jun '11
Author: chatellier
Date: 2011-06-17 13:55:14 +0000 (Fri, 17 Jun 2011)
New Revision: 3420
Log:
Storage parameters storing/reloading refactored.
SensitivityCalculator parameters are not lost anymore ;)
Added:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
Removed:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DocHelper.java
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/RuleHelper.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Doc.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Docable.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -25,26 +25,22 @@
package fr.ifremer.isisfish.datastore;
-import fr.ifremer.isisfish.IsisFishException;
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.simulator.AnalysePlan;
-import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.DocHelper;
-import fr.ifremer.isisfish.util.Docable;
-import fr.ifremer.isisfish.vcs.VCSException;
-
import static org.nuiton.i18n.I18n._;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.simulator.AnalysePlan;
+import fr.ifremer.isisfish.util.Doc;
+import fr.ifremer.isisfish.util.Docable;
+import fr.ifremer.isisfish.vcs.VCSException;
/**
* Class permettant de representer un plan d'analyse.
@@ -60,7 +56,7 @@
*
* Last update: $Date$ by : $Author$
*/
-public class AnalysePlanStorage extends JavaSourceStorage implements Docable { // AnalysePlanStorage
+public class AnalysePlanStorage extends JavaSourceStorage { // AnalysePlanStorage
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(AnalysePlanStorage.class);
@@ -163,129 +159,6 @@
return (AnalysePlan) result;
}
- /**
- * Permet de recuperer les parametres du plan.
- *
- * @return Une map contenant le nom du parametre et son type
- * @throws IsisFishException s'il est impossible de retourner une map
- * convenable
- */
- public Map<String, Class<?>> getParameterNames() throws IsisFishException {
- Map<String, Class<?>> result = null;
- // On essai de recuperer les paramètres depuis la classe compilé
- // si c possible
- try {
- if (0 == compile(false, null)) {
- AnalysePlan plan = getNewAnalysePlanInstance();
- result = AnalysePlanStorage.getParameterNames(plan);
- }
- } catch (Exception eee) {
- log.info(_("isisfish.error.plan.parameter"), eee);
- }
- // si on ne reussi pas avec la classe compilé on essai en parsant le
- // source
- if (result == null) {
- try {
- //String code = getContent();
- log.fatal("FIXME a faire recherche des parametre dans le source");
- throw new IsisFishException(_("isisfish.error.source.parameter"));
- // TODO implanter la recherche des parametres.
- // Se sont les attributs commencant par 'param_' et ils doivent
- // etre public non static, non transient.
- // ex: public Date param_Date.
- // Lorsqu'on ajoute un champs dans la map il ne faut pas mettre
- // le prefix param.
- } catch (Exception eee) {
- throw new IsisFishException(_("isisfish.error.source.parameter"), eee);
- }
- }
- return result;
- }
-
-
- /**
- * Recherche par introspection tous les parametres de la classe
- * commencant par param_
- *
- * @param plan le plan dont on souhaite les infos de parametre
- * @return retourne le nom et le type des parametres du plan
- */
- public static Map<String, Class<?>> getParameterNames(AnalysePlan plan) {
- Map<String, Class<?>> result = new LinkedHashMap<String, Class<?>>();
- for (Field field : plan.getClass().getFields()) {
- if (field.getName().startsWith(PARAM_PREFIX)) {
- result.put(field.getName().substring(PARAM_PREFIX.length()),
- field.getType());
- }
- }
- return result;
- }
-
- /**
- * Donne la valeur d'un parametre par introspection
- *
- * @param name le nom du parametre
- * @param plan le plan dont on souhaite la valeur du parametre
- * @return la valeur courante du parametre
- * @throws IsisFishException s'il y a un probleme pour recuperer la valeur
- */
- static public Object getParameterValue(AnalysePlan plan, String name) throws IsisFishException {
- if (plan == null || name == null || "".equals(name)) {
- return null;
- }
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = plan.getClass().getDeclaredField(fieldName);
- return field.get(plan);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't get plan parameter: " + name, eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't get plan parameter: " + name, eee);
- }
- }
-
- /**
- * Modifie la valeur d'un attribut pas introspection
- *
- * @param name le nom de l'attribut
- * @param value la valeur de l'attribut
- * @param plan le plan dont on souhaite modifier la valeur de parametre
- * @throws IsisFishException s'il y a un probleme
- */
- static public void setParameterValue(AnalysePlan plan, String name, Object value) throws IsisFishException {
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = plan.getClass().getDeclaredField(fieldName);
- field.set(plan, value);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- } catch (IllegalArgumentException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- }
- }
-
- /**
- * Recupere les parametres et leur valeur pour les retourner sous forme
- * de chaine. Pour pouvoir par exemple les afficher a l'utilisateur
- *
- * @param plan le plan dont on souhaite la valeur du parametre en string
- * @return la valeur sous forme de string
- * @throws IsisFishException
- */
- public static String getParamAsString(AnalysePlan plan) throws IsisFishException {
- StringBuffer result = new StringBuffer();
-
- for (String name : getParameterNames(plan).keySet()) {
- Object value = getParameterValue(plan, name);
-
- result.append(name).append(" : ").append(value);
- result.append("\n");
- }
- return result.toString();
- }
-
static public void checkout() throws VCSException {
checkout(IsisFish.config.getDatabaseDirectory(), ANALYSE_PLAN_PATH);
}
@@ -329,51 +202,6 @@
}
/**
- * @return the @Doc of the underlied AnalysePlan class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getClassDoc() {
- Doc result = null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getClassDoc(klazz);
- } catch (IsisFishException e) {
- log.warn(_("isisfish.error.not.found.code", this));
- }
- return result;
- }
-
- /**
- * @param fieldName name of the field to inspect
- * @return the @Doc of the given field of the underlied AnalysePlan class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getFieldDoc(String fieldName) {
- Doc result = null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getFieldDoc(klazz, fieldName);
- } catch (Exception e) {
- log.warn(_("isisfish.error.not.found.field", fieldName, this));
- }
- return result;
- }
-
- /**
- * @param paramName the name of the param to inspect
- * @return the doc associated with the param,
- * (says the field PARAM_PREFIX+fieldName)
- */
- public Doc getParamDoc(String paramName) {
- Doc doc = getFieldDoc(PARAM_PREFIX + paramName);
- return doc;
- }
-
- /**
* <b>Be ware this method require to instanciate a AnalysePlan, so
* it would be better to call as often as possible.</b>
*
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -28,13 +28,10 @@
import static org.nuiton.i18n.I18n._;
import java.io.File;
-import java.lang.reflect.Field;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,7 +39,6 @@
import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.export.Export;
import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.DocHelper;
import fr.ifremer.isisfish.util.Docable;
import fr.ifremer.isisfish.vcs.VCSException;
@@ -58,7 +54,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class ExportStorage extends JavaSourceStorage implements Docable {
+public class ExportStorage extends JavaSourceStorage {
/** Class logger. */
private static Log log = LogFactory.getLog(ExportStorage.class);
@@ -165,41 +161,6 @@
}
/**
- * @return the @Doc of the underlied rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getClassDoc() {
- Doc result = null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getClassDoc(klazz);
- } catch (IsisFishException e) {
- log.warn(_("isisfish.error.not.found.code", this));
- }
- return result;
- }
-
- /**
- * @param fieldName name of the field to inspect
- * @return the @Doc of the given field of the underlied Rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getFieldDoc(String fieldName) {
- Doc result=null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getFieldDoc(klazz,fieldName);
- } catch (Exception e) {
- log.warn(_("isisfish.error.not.found.field",fieldName,this));
- }
- return result;
- }
-
- /**
* <b>Be ware this method require to instanciate a Export, so
* it would be better to call as often as possible.</b>
*
@@ -219,124 +180,4 @@
}
return result;
}
-
- /**
- * @param paramName the name of the param to inspect
- * @return the doc associated with the param,
- * (says the field PARAM_PREFIX+fieldName)
- */
- public Doc getParamDoc(String paramName) {
- Doc doc;
- doc = getFieldDoc(PARAM_PREFIX + paramName);
- return doc;
- }
-
- /**
- * Permet de recuperer les parametres de l'export.
- *
- * @return Une map contenant le nom du parametre et son type
- * @throws IsisFishException s'il est impossible de retourner une map
- * convenable
- */
- public Map<String, Class<?>> getParameterNames() throws IsisFishException {
- Map<String, Class<?>> result = null;
- // On essai de recuperer les paramètres depuis la classe compilé
- // si c possible
- try {
- if (0 == compile(false, null)) {
- Export export = getNewExportInstance();
- result = ExportStorage.getParameterNames(export);
- }
- } catch (Exception eee) {
- log.info(_("isisfish.error.compiled.parameter"), eee);
- }
- // si on ne reussi pas avec la classe compilé on essai en parsant le
- // source
- if (result == null) {
- try {
- //String code = getContent();
- log.fatal("FIXME a faire recherche des parametre dans le source");
- throw new IsisFishException(_("isisfish.error.source.parameter"));
- // TODO implanter la recherche des parametres.
- // Se sont les attributs commencant par 'param_' et ils doivent
- // etre public non static, non transient.
- // ex: public Date param_Date.
- // Lorsqu'on ajoute un champs dans la map il ne faut pas mettre
- // le prefix param.
- } catch (Exception eee) {
- throw new IsisFishException(_("isisfish.error.source.parameter"), eee);
- }
- }
- return result;
- }
-
- /**
- * Recherche par introspection tous les parametres de la classe
- * commencant par {@link #PARAM_PREFIX}.
- *
- * @param export the export to inspect
- * @return the list of parameters for a given export
- */
- public static Map<String, Class<?>> getParameterNames(Export export) {
- Map<String, Class<?>> result = new LinkedHashMap<String, Class<?>>();
- for (Field field : export.getClass().getFields()) {
- if (field.getName().startsWith(PARAM_PREFIX)) {
- result.put(field.getName().substring(PARAM_PREFIX.length()),
- field.getType());
- }
- }
- return result;
- }
-
- /**
- * Donne la valeur d'un parametre par introspection.
- *
- * @param name le nom du parametre
- * @param export the export to inspect
- * @return la valeur courante du parametre
- * @throws IsisFishException if any exception
- */
- public static Object getParameterValue(Export export, String name) throws IsisFishException {
- if (export == null || name == null || "".equals(name)) {
- return null;
- }
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = export.getClass().getDeclaredField(fieldName);
- return field.get(export);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't get rule parameter: " + name, eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't get rule parameter: " + name, eee);
- }
- }
-
- /**
- * Modifie la valeur d'un attribut par introspection.
- *
- * @param name le nom de l'attribut
- * @param value la valeur de l'attribut
- * @param export the export to inspect
- * @throws IsisFishException if any exception
- */
- public static void setParameterValue(Export export, String name,
- Object value) throws IsisFishException {
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = export.getClass().getDeclaredField(fieldName);
- field.set(export, value);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't modify export parameter: "
- + name + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't modify export parameter: "
- + name + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- } catch (IllegalArgumentException eee) {
- throw new IsisFishException("Can't modify export parameter: "
- + name + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- }
- }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/JavaSourceStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2006 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
+ * Copyright (C) 2006 - 2011 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
@@ -29,14 +29,21 @@
import java.io.File;
import java.io.PrintWriter;
+import java.lang.reflect.Field;
+import java.util.LinkedHashMap;
+import java.util.Map;
import org.apache.commons.lang.ClassUtils;
+import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import fr.ifremer.isisfish.IsisFish;
import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.rule.Rule;
import fr.ifremer.isisfish.util.CompileHelper;
import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.DocHelper;
+import fr.ifremer.isisfish.util.Docable;
import fr.ifremer.isisfish.util.JavadocHelper;
/**
@@ -56,8 +63,12 @@
*
* Last update: $Date$ by : $Author$
*/
-public abstract class JavaSourceStorage extends CodeSourceStorage {
+public abstract class JavaSourceStorage extends CodeSourceStorage implements Docable {
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(ExportStorage.class);
+
+ /** Le prefix de tous les attributs java manipulable par Isis. */
protected static final String PARAM_PREFIX = "param_";
/**
@@ -171,7 +182,13 @@
}
return result;
}
-
+
+ protected static Doc getFieldDoc(Class klass, String paramName) throws SecurityException, NoSuchFieldException {
+ Field f = klass == null ? null : klass.getField(paramName);
+ Doc result = f == null ? null : f.getAnnotation(Doc.class);
+ return result;
+ }
+
/**
* Get doc of parameter.
*
@@ -180,7 +197,166 @@
* @return {@link Doc} annotation
*/
public static Doc getParameterDoc(Object object, String paramName) {
- Doc result = DocHelper.getFieldDoc(object.getClass(), PARAM_PREFIX + paramName);
+ Doc result = null;
+ try {
+ result = getFieldDoc(object.getClass(), PARAM_PREFIX + paramName);
+ } catch (Exception e) {
+ log.warn(_("isisfish.error.not.found.field", paramName, object));
+ }
return result;
}
+
+ /**
+ * @param paramName the name of the param to inspect
+ * @return the doc associated with the param,
+ * (says the field PARAM_PREFIX+fieldName)
+ */
+ public Doc getFieldDoc(String paramName) {
+ Doc result = null;
+ try {
+ Class<?> clazz = getCodeClass();
+ result = getFieldDoc(clazz, PARAM_PREFIX + paramName);
+ } catch (Exception e) {
+ log.warn(_("isisfish.error.not.found.field", paramName, this));
+ }
+ return result;
+ }
+
+ /**
+ * Get docable element description.
+ */
+ @Override
+ public String getDescription() {
+ return null;
+ }
+
+ /**
+ * Permet de recuperer les parametres de l'export.
+ *
+ * @return Une map contenant le nom du parametre et son type
+ * @throws IsisFishException s'il est impossible de retourner une map
+ * convenable
+ */
+ public Map<String, Class<?>> getParameterNames() throws IsisFishException {
+ Map<String, Class<?>> result = null;
+ // On essai de recuperer les paramètres depuis la classe compilé
+ // si c possible
+ try {
+ if (0 == compile(false, null)) {
+ Object instance = getNewInstance();
+ result = getParameterNames(instance);
+ }
+ } catch (Exception eee) {
+ log.info(_("isisfish.error.compiled.parameter"), eee);
+ }
+ // si on ne reussi pas avec la classe compilé on essai en parsant le
+ // source
+ if (result == null) {
+ try {
+ //String code = getContent();
+ log.fatal("FIXME a faire recherche des parametre dans le source");
+ throw new IsisFishException(_("isisfish.error.source.parameter"));
+ // TODO implanter la recherche des parametres.
+ // Se sont les attributs commencant par 'param_' et ils doivent
+ // etre public non static, non transient.
+ // ex: public Date param_Date.
+ // Lorsqu'on ajoute un champs dans la map il ne faut pas mettre
+ // le prefix param.
+ } catch (Exception eee) {
+ throw new IsisFishException(_("isisfish.error.source.parameter"), eee);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Recherche par introspection tous les parametres de la classe
+ * commencant par {@link #PARAM_PREFIX}.
+ *
+ * @param instance the instance to inspect
+ * @return the list of parameters for a given export
+ */
+ public static Map<String, Class<?>> getParameterNames(Object instance) {
+ Map<String, Class<?>> result = new LinkedHashMap<String, Class<?>>();
+ for (Field field : instance.getClass().getFields()) {
+ if (field.getName().startsWith(PARAM_PREFIX)) {
+ result.put(field.getName().substring(PARAM_PREFIX.length()),
+ field.getType());
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Donne la valeur d'un parametre par introspection.
+ *
+ * @param name le nom du parametre
+ * @param instance the instance to inspect
+ * @return la valeur courante du parametre
+ * @throws IsisFishException if any exception
+ */
+ public static Object getParameterValue(Object instance, String name) throws IsisFishException {
+ if (instance == null || name == null || "".equals(name)) {
+ return null;
+ }
+ try {
+ String fieldName = PARAM_PREFIX + name;
+ Field field = instance.getClass().getDeclaredField(fieldName);
+ return field.get(instance);
+ } catch (IllegalAccessException eee) {
+ throw new IsisFishException("Can't get rule parameter: " + name, eee);
+ } catch (NoSuchFieldException eee) {
+ throw new IsisFishException("Can't get rule parameter: " + name, eee);
+ }
+ }
+
+ /**
+ * Modifie la valeur d'un attribut par introspection.
+ *
+ * @param name le nom de l'attribut
+ * @param value la valeur de l'attribut
+ * @param instance the instance to inspect
+ * @throws IsisFishException if any exception
+ */
+ public static void setParameterValue(Object instance, String name,
+ Object value) throws IsisFishException {
+ try {
+ String fieldName = PARAM_PREFIX + name;
+ Field field = instance.getClass().getDeclaredField(fieldName);
+ field.set(instance, value);
+ } catch (IllegalAccessException eee) {
+ throw new IsisFishException("Can't modify export parameter: "
+ + name + " with '" + value + "'("
+ + ObjectUtils.identityToString(value) + ")", eee);
+ } catch (NoSuchFieldException eee) {
+ throw new IsisFishException("Can't modify export parameter: "
+ + name + " with '" + value + "'("
+ + ObjectUtils.identityToString(value) + ")", eee);
+ } catch (IllegalArgumentException eee) {
+ throw new IsisFishException("Can't modify export parameter: "
+ + name + " with '" + value + "'("
+ + ObjectUtils.identityToString(value) + ")", eee);
+ }
+ }
+
+ /**
+ * Recupere les parametres et leur valeur pour les retourner sous forme
+ * de chaine. Pour pouvoir par exemple les afficher a l'utilisateur.
+ *
+ * @param instance the instance to inspect
+ * @return a string representation of parameters and their values for
+ * a given rule
+ * @throws IsisFishException if any exception
+ */
+ public static String getParamAsString(Object instance) throws IsisFishException {
+ StringBuffer result = new StringBuffer();
+
+ for (String name : getParameterNames(instance).keySet()) {
+ Object value = getParameterValue(instance, name);
+
+ result.append(name).append(" : ").append(value);
+ result.append("\n");
+ }
+ return result.toString();
+ }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -25,26 +25,22 @@
package fr.ifremer.isisfish.datastore;
-import fr.ifremer.isisfish.IsisFishException;
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.DocHelper;
-import fr.ifremer.isisfish.util.Docable;
-import fr.ifremer.isisfish.rule.Rule;
-import fr.ifremer.isisfish.vcs.VCSException;
-
import static org.nuiton.i18n.I18n._;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.util.Doc;
+import fr.ifremer.isisfish.util.Docable;
+import fr.ifremer.isisfish.vcs.VCSException;
/**
* Class permettant de representer une regle de gestion.
@@ -166,130 +162,6 @@
return (Rule) result;
}
- /**
- * Permet de recuperer les parametres de la regle.
- *
- * @return Une map contenant le nom du parametre et son type
- * @throws IsisFishException s'il est impossible de retourner une map
- * convenable
- */
- public Map<String, Class<?>> getParameterNames() throws IsisFishException {
- Map<String, Class<?>> result = null;
- // On essai de recuperer les paramètres depuis la classe compilé
- // si c possible
- try {
- if (0 == compile(false, null)) {
- Rule rule = getNewRuleInstance();
- result = RuleStorage.getParameterNames(rule);
- }
- } catch (Exception eee) {
- log.info(_("isisfish.error.compiled.parameter"), eee);
- }
- // si on ne reussi pas avec la classe compilé on essai en parsant le
- // source
- if (result == null) {
- try {
- //String code = getContent();
- log.fatal("FIXME a faire recherche des parametre dans le source");
- throw new IsisFishException(_("isisfish.error.source.parameter"));
- // TODO implanter la recherche des parametres.
- // Se sont les attributs commencant par 'param_' et ils doivent
- // etre public non static, non transient.
- // ex: public Date param_Date.
- // Lorsqu'on ajoute un champs dans la map il ne faut pas mettre
- // le prefix param.
- } catch (Exception eee) {
- throw new IsisFishException(_("isisfish.error.source.parameter"), eee);
- }
- }
- return result;
- }
-
-
- /**
- * Recherche par introspection tous les parametres de la classe
- * commencant par param_
- *
- * @param rule the rule to inspect
- * @return the list of parameters for a given rule
- */
- static public Map<String, Class<?>> getParameterNames(Rule rule) {
- Map<String, Class<?>> result = new LinkedHashMap<String, Class<?>>();
- for (Field field : rule.getClass().getFields()) {
- if (field.getName().startsWith(PARAM_PREFIX)) {
- result.put(field.getName().substring(PARAM_PREFIX.length()),
- field.getType());
- }
- }
- return result;
- }
-
- /**
- * Donne la valeur d'un parametre par introspection
- *
- * @param name le nom du parametre
- * @param rule the rule to inspect
- * @return la valeur courante du parametre
- * @throws IsisFishException if any exception
- */
- static public Object getParameterValue(Rule rule, String name) throws IsisFishException {
- if (rule == null || name == null || "".equals(name)) {
- return null;
- }
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = rule.getClass().getDeclaredField(fieldName);
- return field.get(rule);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't get rule parameter: " + name, eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't get rule parameter: " + name, eee);
- }
- }
-
- /**
- * Modifie la valeur d'un attribut par introspection.
- *
- * @param name le nom de l'attribut
- * @param value la valeur de l'attribut
- * @param rule the rule to inspect
- * @throws IsisFishException if any exception
- */
- static public void setParameterValue(Rule rule, String name, Object value) throws IsisFishException {
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = rule.getClass().getDeclaredField(fieldName);
- field.set(rule, value);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't modify rule parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't modify rule parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- } catch (IllegalArgumentException eee) {
- throw new IsisFishException("Can't modify rule parameter: " + name + " with '" + value + "'(" + ObjectUtils.identityToString(value) + ")", eee);
- }
- }
-
- /**
- * Recupere les parametres et leur valeur pour les retourner sous forme
- * de chaine. Pour pouvoir par exemple les afficher a l'utilisateur.
- *
- * @param rule the rule to inspect
- * @return a string representation of parameters and their values for
- * a given rule
- * @throws IsisFishException if any exception
- */
- public static String getParamAsString(Rule rule) throws IsisFishException {
- StringBuffer result = new StringBuffer();
-
- for (String name : getParameterNames(rule).keySet()) {
- Object value = getParameterValue(rule, name);
-
- result.append(name).append(" : ").append(value);
- result.append("\n");
- }
- return result.toString();
- }
-
static public void checkout() throws VCSException {
checkout(IsisFish.config.getDatabaseDirectory(), RULE_PATH);
}
@@ -332,52 +204,6 @@
}
/**
- * @return the @Doc of the underlied rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getClassDoc() {
- Doc result=null;
- try {
- Class klazz = getCodeClass();
- result = DocHelper.getClassDoc(klazz);
- } catch (IsisFishException e) {
- log.warn(_("isisfish.error.not.found.code",this));
- }
- return result;
- }
-
- /**
- * @param fieldName name of the field to inspect
- * @return the @Doc of the given field of the underlied Rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getFieldDoc(String fieldName) {
- Doc result=null;
- try {
- Class klazz = getCodeClass();
- result = DocHelper.getFieldDoc(klazz,fieldName);
- } catch (Exception e) {
- log.warn(_("isisfish.error.not.found.field",fieldName,this));
- }
- return result;
- }
-
- /**
- * @param paramName the name of the param to inspect
- * @return the doc associated with the param,
- * (says the field PARAM_PREFIX+fieldName)
- */
- public Doc getParamDoc(String paramName) {
- Doc doc;
- doc = getFieldDoc(PARAM_PREFIX + paramName);
- return doc;
- }
-
- /**
* <b>Be ware this method require to instanciate a Rule, so
* it would be better to call as often as possible.</b>
*
@@ -386,10 +212,10 @@
* @see Docable
*/
public String getDescription() {
- String result=null;
+ String result = null;
try {
Rule rule = getNewRuleInstance();
- result =rule == null ? null : rule.getDescription();
+ result = rule == null ? null : rule.getDescription();
} catch (Exception e) {
log.warn(_("isisfish.error.not.found.description",this));
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -25,24 +25,16 @@
package fr.ifremer.isisfish.datastore;
-import fr.ifremer.isisfish.IsisFishException;
-import fr.ifremer.isisfish.IsisFishRuntimeException;
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.util.DocHelper;
-import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.Docable;
-import fr.ifremer.isisfish.vcs.VCSException;
-
-import static org.nuiton.i18n.I18n._;
-
-import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
import java.io.File;
import java.util.List;
import java.util.Map;
+import org.apache.commons.collections.map.ReferenceMap;
+
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.vcs.VCSException;
+
/**
* Gestion des fichers CVS de type scripts (appartenant au module scripts).
*
@@ -54,11 +46,8 @@
* Last update: $Date$
* by : $Author$
*/
-public class ScriptStorage extends JavaSourceStorage implements Docable {
+public class ScriptStorage extends JavaSourceStorage {
- /** to use log facility, just put in your code: log.info(\"...\"); */
- private static Log log = LogFactory.getLog(ScriptStorage.class);
-
public static final String SCRIPT_PATH = "scripts";
/** Template freemarker pour les scripts. */
@@ -197,52 +186,4 @@
result.removeAll(getScriptNames());
return result;
}
-
- /**
- * @return the @Doc of the underlied rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getClassDoc() {
- Doc result=null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getClassDoc(klazz);
- } catch (IsisFishException e) {
- log.warn(_("isisfish.error.not.found.code",this));
- }
- return result;
- }
-
- /**
- * @param fieldName name of the field to inspect
- * @return the @Doc of the given field of the underlied Rule class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getFieldDoc(String fieldName) {
- Doc result=null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getFieldDoc(klazz,fieldName);
- } catch (Exception e) {
- log.warn(_("isisfish.error.not.found.field",fieldName,this));
- }
- return result;
- }
-
-
- /**
- * <b>Be ware this method require to instanciate a Rule, so
- * it would be better to call as often as possible.</b>
- *
- * @return the descript of the instanciate AnalysePlan
- * @see Doc
- * @see Docable
- */
- public String getDescription() {
- throw new IsisFishRuntimeException(_("isisfish.error.not.support.class",this));
- }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -53,9 +53,6 @@
*/
public class SensitivityExportStorage extends ExportStorage implements Docable {
- /** Class logger. */
- private static Log log = LogFactory.getLog(SensitivityExportStorage.class);
-
public static final String SENSITIVITY_EXPORT_PATH = "sensitivityexports";
/** Template freemarker pour les scripts d'export . */
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -25,26 +25,22 @@
package fr.ifremer.isisfish.datastore;
-import fr.ifremer.isisfish.IsisFishException;
-import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
-import fr.ifremer.isisfish.util.Doc;
-import fr.ifremer.isisfish.util.DocHelper;
-import fr.ifremer.isisfish.util.Docable;
-import fr.ifremer.isisfish.vcs.VCSException;
-
import static org.nuiton.i18n.I18n._;
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.collections.map.ReferenceMap;
-import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.simulator.sensitivity.SensitivityCalculator;
+import fr.ifremer.isisfish.util.Doc;
+import fr.ifremer.isisfish.util.Docable;
+import fr.ifremer.isisfish.vcs.VCSException;
/**
* Cette class permet de stocker les fichiers de calculateur de sensibilité.
@@ -57,7 +53,7 @@
* @version $Revision$
* Last update: $Date$ by : $Author$
*/
-public class SensitivityStorage extends JavaSourceStorage implements Docable { // SensitivityStorage
+public class SensitivityStorage extends JavaSourceStorage { // SensitivityStorage
/** to use log facility, just put in your code: log.info(\"...\"); */
private static Log log = LogFactory.getLog(SensitivityStorage.class);
@@ -161,144 +157,6 @@
}
/**
- * Permet de recuperer les parametres du calculateur.
- *
- * @return Une map contenant le nom du parametre et son type
- * @throws IsisFishException s'il est impossible de retourner une map
- * convenable
- */
- public Map<String, Class<?>> getParameterNames() throws IsisFishException {
- Map<String, Class<?>> result = null;
- // On essai de recuperer les paramètres depuis la classe compilé
- // si c possible
- try {
- if (0 == compile(false, null)) {
- SensitivityCalculator calculator = getNewSensitivityInstance();
- result = SensitivityStorage.getParameterNames(calculator);
- }
- } catch (Exception eee) {
- if (log.isErrorEnabled()) {
- log.error(_("isisfish.error.source.parameter"), eee);
- }
- }
- // si on ne reussi pas avec la classe compilé on essai en parsant le
- // source
- if (result == null) {
- try {
- //String code = getContent();
- log.fatal("FIXME a faire recherche des parametres dans le source");
- throw new IsisFishException(
- _("isisfish.error.source.parameter"));
- // TODO implanter la recherche des parametres.
- // Se sont les attributs commencant par 'param_' et ils doivent
- // etre public non static, non transient.
- // ex: public Date param_Date.
- // Lorsqu'on ajoute un champs dans la map il ne faut pas mettre
- // le prefix param.
- } catch (Exception eee) {
- throw new IsisFishException(
- _("isisfish.error.source.parameter"), eee);
- }
- }
- return result;
- }
-
- /**
- * Recherche par introspection tous les parametres de la classe
- * commencant par {@link #PARAM_PREFIX}.
- *
- * @param calculator le calculateur dont on souhaite les infos de parametre
- * @return retourne le nom et le type des parametres du calculateur
- */
- public static Map<String, Class<?>> getParameterNames(
- SensitivityCalculator calculator) {
- Map<String, Class<?>> result = new LinkedHashMap<String, Class<?>>();
- for (Field field : calculator.getClass().getFields()) {
- if (field.getName().startsWith(PARAM_PREFIX)) {
- result.put(field.getName().substring(PARAM_PREFIX.length()),
- field.getType());
- }
- }
- return result;
- }
-
- /**
- * Donne la valeur d'un parametre par introspection.
- *
- * @param name le nom du parametre
- * @param calculator le calculateur dont on souhaite la valeur du parametre
- * @return la valeur courante du parametre
- * @throws IsisFishException s'il y a un probleme pour recuperer la valeur
- */
- public static Object getParameterValue(SensitivityCalculator calculator,
- String name) throws IsisFishException {
- if (calculator == null || name == null || "".equals(name)) {
- return null;
- }
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = calculator.getClass().getDeclaredField(fieldName);
- return field.get(calculator);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't get plan parameter: " + name,
- eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't get plan parameter: " + name,
- eee);
- }
- }
-
- /**
- * Modifie la valeur d'un attribut pas introspection.
- *
- * @param name le nom de l'attribut
- * @param value la valeur de l'attribut
- * @param calculator le calculator dont on souhaite modifier la valeur de parametre
- * @throws IsisFishException s'il y a un probleme
- */
- public static void setParameterValue(SensitivityCalculator calculator,
- String name, Object value) throws IsisFishException {
- try {
- String fieldName = PARAM_PREFIX + name;
- Field field = calculator.getClass().getDeclaredField(fieldName);
- field.set(calculator, value);
- } catch (IllegalAccessException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name
- + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- } catch (NoSuchFieldException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name
- + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- } catch (IllegalArgumentException eee) {
- throw new IsisFishException("Can't modify plan parameter: " + name
- + " with '" + value + "'("
- + ObjectUtils.identityToString(value) + ")", eee);
- }
- }
-
- /**
- * Recupere les paramètres et leur valeur pour les retourner sous forme
- * de chaine. Pour pouvoir par exemple les afficher à l'utilisateur.
- *
- * @param calculator le calculateur dont on souhaite la valeur du parametre en string
- * @return la valeur sous forme de string
- * @throws IsisFishException
- */
- public static String getParamAsString(SensitivityCalculator calculator)
- throws IsisFishException {
- StringBuffer result = new StringBuffer();
-
- for (String name : getParameterNames(calculator).keySet()) {
- Object value = getParameterValue(calculator, name);
-
- result.append(name).append(" : ").append(value);
- result.append("\n");
- }
- return result.toString();
- }
-
- /**
* Effectue un chekout VCS sur le répertoire des calculateurs.
*
* @see VersionStorage#checkout(File, String)
@@ -351,54 +209,6 @@
}
/**
- * @return the @Doc of the underlied {@link SensitivityCalculator} class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getClassDoc() {
- Doc result = null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getClassDoc(klazz);
- } catch (IsisFishException e) {
- if (log.isWarnEnabled()) {
- log.warn(_("isisfish.error.not.found.code", this));
- }
- }
- return result;
- }
-
- /**
- * @param fieldName name of the field to inspect
- * @return the @Doc of the given field of the underlied {@link SensitivityCalculator} class
- * @see DocHelper
- * @see Doc
- * @see Docable
- */
- public Doc getFieldDoc(String fieldName) {
- Doc result = null;
- try {
- Class<?> klazz = getCodeClass();
- result = DocHelper.getFieldDoc(klazz, fieldName);
- } catch (Exception e) {
- log.warn(_("isisfish.error.not.found.field", fieldName, this));
- }
- return result;
- }
-
- /**
- * @param paramName the name of the param to inspect
- * @return the doc associated with the param,
- * (says the field {@link #PARAM_PREFIX} + fieldName)
- */
- public Doc getParamDoc(String paramName) {
- Doc doc;
- doc = getFieldDoc(PARAM_PREFIX + paramName);
- return doc;
- }
-
- /**
* <b>Be ware this method require to instanciate a AnalysePlan, so
* it would be better to call as often as possible.</b>
*
@@ -406,6 +216,7 @@
* @see Doc
* @see Docable
*/
+ @Override
public String getDescription() {
String result = null;
try {
Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java (rev 0)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -0,0 +1,137 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.isisfish.datastore;
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.commons.beanutils.ConvertUtilsBean;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.nuiton.topia.TopiaContext;
+import org.nuiton.topia.persistence.TopiaEntity;
+
+import fr.ifremer.isisfish.IsisFishException;
+import fr.ifremer.isisfish.rule.Rule;
+import fr.ifremer.isisfish.util.ConverterUtil;
+
+/**
+ * Helper used to populate and extract instance parameters
+ * from simulation.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class StorageHelper {
+
+ /** Class logger. */
+ private static Log log = LogFactory.getLog(StorageHelper.class);
+
+ /**
+ * Recupere dans prop les valeurs des champs specifique au export et met a
+ * jour les champs de l'export.
+ *
+ * @param instanceIndex l'index de l'instance
+ * @param instance l'instance a mettre à jour
+ * @param context le topia context dont on a besoin
+ * @param props les proprietes contenant les parametre de l'export
+ * @param propPrefix prefix des clés a prendre en compte dans {@code props}
+ */
+ public static void populateStorageParams(int instanceIndex, TopiaContext context,
+ Object instance, Properties props, String propPrefix) {
+ //ConvertUtilsBean beanUtils = ConverterUtil.getConverter(region
+ // .getStorage());
+ String exportName = JavaSourceStorage.getName(instance);
+ String paramTag = propPrefix + "." + instanceIndex + ".parameter.";
+
+ for (Map.Entry<String, Class<?>> entry : JavaSourceStorage.getParameterNames(instance).entrySet()) {
+ String propName = entry.getKey();
+ Class<?> type = entry.getValue();
+ if (TopiaEntity.class.isAssignableFrom(type)) {
+ type = TopiaEntity.class;
+ }
+ String valueString = "not initialized";
+ try {
+ valueString = props.getProperty(paramTag + propName);
+
+ // ATTENTION il semblerait que notre intance de beanUtils
+ // soit ecrasé par celle du MatrixType ...
+ // a ne pas deplacer avant la boucle
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(context);
+
+ Object value = beanUtils.convert(valueString, type);
+ if (log.isDebugEnabled()) {
+ log.debug("Set instance param: " + paramTag +
+ propName + " = " + value + "(" + valueString + ")");
+ }
+
+ JavaSourceStorage.setParameterValue(instance, propName, value);
+ } catch (Exception eee) {
+ if (log.isWarnEnabled()) {
+ log.info("Properties: " + props);
+ log.warn("Can't reload field " + propName + " for export "
+ + exportName + " with value " + valueString, eee);
+ }
+ }
+ }
+ }
+
+ /**
+ * Permet de mettre les parametres d'un object Isis sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param instanceIndex l'index de la rule
+ * @param context le context
+ * @param instance La regle dont on souhaite mettre les parametres dans l'objet
+ * Properties retourne
+ * @param propPrefix prefix des clés a prendre en compte dans {@code props}
+ * @return L'objet Properties contenant les valeurs des parametres de l'instance
+ */
+ public static Properties getParamsAsProperties(int instanceIndex, TopiaContext context,
+ Object instance, String propPrefix) {
+ Properties result = new Properties();
+ ConvertUtilsBean beanUtils = ConverterUtil.getConverter(context);
+ for (String paramName : RuleStorage.getParameterNames(instance).keySet()) {
+ String paramValueString;
+ try {
+ Object value = RuleStorage.getParameterValue(instance, paramName);
+ paramValueString = beanUtils.convert(value);
+ if (paramValueString != null) {
+ result.setProperty(propPrefix + "." + instanceIndex + ".parameter." + paramName, paramValueString);
+ }
+ } catch (IsisFishException eee) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't convert parameter value to String: " + paramName, eee);
+ }
+ }
+ }
+
+ return result;
+ }
+}
Property changes on: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/StorageHelper.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/export/ExportHelper.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -30,7 +30,6 @@
import java.io.FileWriter;
import java.io.Writer;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
import org.apache.commons.beanutils.ConvertUtilsBean;
@@ -38,11 +37,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
+import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.ExportStorage;
import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
+import fr.ifremer.isisfish.datastore.StorageHelper;
import fr.ifremer.isisfish.util.ConverterUtil;
/**
@@ -56,7 +56,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class ExportHelper {
+public class ExportHelper extends StorageHelper {
/** Class logger. */
private static Log log = LogFactory.getLog(ExportHelper.class);
@@ -135,41 +135,21 @@
*/
public static void populateSensitivityExport(int exportIndex, TopiaContext context,
SensitivityExport export, Properties props) {
- //ConvertUtilsBean beanUtils = ConverterUtil.getConverter(region
- // .getStorage());
- String exportName = SensitivityExportStorage.getName(export);
- String paramTag = "sensitivityexport." + exportIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : SensitivityExportStorage
- .getParameterNames(export).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = "not initialized";
- try {
- valueString = props.getProperty(paramTag + propName);
-
- // ATTENTION il semblerait que notre intance de beanUtils
- // soit ecrasé par celle du MatrixType ...
- // a ne pas deplacer avant la boucle
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(context);
-
- Object value = beanUtils.convert(valueString, type);
- if (log.isDebugEnabled()) {
- log.debug("Set sensitivityexport param: " + paramTag +
- propName + " = " + value + "(" + valueString + ")");
- }
-
- SensitivityExportStorage.setParameterValue(export, propName, value);
- } catch (Exception eee) {
- if (log.isWarnEnabled()) {
- log.info("Properties: " + props);
- log.warn("Can't reload field " + propName + " for export "
- + exportName + " with value " + valueString, eee);
- }
- }
- }
+ populateStorageParams(exportIndex, context, export, props, "sensitivityexport");
}
+
+ /**
+ * Permet de mettre les parametres de l'export sous une forme String pour
+ * pouvoir les relire ensuite.
+ *
+ * @param sensitivityExportIndex l'index de l'export
+ * @param context le topia context dont on a besoin
+ * @param sensitivityExport l'export dont on souhaite mettre les parametres dans l'objet
+ * Properties retourné
+ * @return L'objet Properties contenant les valeurs des parametres de l'export
+ */
+ public static Properties getSensitivityExportAsProperties(
+ int sensitivityExportIndex, TopiaContext context, SensitivityExport sensitivityExport) {
+ return getParamsAsProperties(sensitivityExportIndex, context, sensitivityExport, "sensitivityexport");
+ }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/RuleHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/RuleHelper.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/RuleHelper.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -25,19 +25,14 @@
package fr.ifremer.isisfish.rule;
-import java.util.Map;
import java.util.Properties;
-import org.apache.commons.beanutils.ConvertUtilsBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.topia.TopiaContext;
-import org.nuiton.topia.persistence.TopiaEntity;
-import fr.ifremer.isisfish.IsisFishException;
import fr.ifremer.isisfish.datastore.RegionStorage;
-import fr.ifremer.isisfish.datastore.RuleStorage;
-import fr.ifremer.isisfish.util.ConverterUtil;
+import fr.ifremer.isisfish.datastore.StorageHelper;
/**
* Helper pour effectuer des manipulations sur les règles.
@@ -55,7 +50,7 @@
* Last update: $Date$
* by : $Author$
*/
-public class RuleHelper {
+public class RuleHelper extends StorageHelper {
/** Logger for this class. */
private static final Log log = LogFactory.getLog(RuleHelper.class);
@@ -88,41 +83,7 @@
* @param props les propriétés contenant les paramètres de la règle
*/
public static void populateRule(int ruleIndex, TopiaContext context, Rule rule, Properties props) {
- String ruleName = RuleStorage.getName(rule);
- String paramTag = "rule." + ruleIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : RuleStorage.getParameterNames(rule).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = "not initialized";
- try {
- valueString = props.getProperty(paramTag + propName);
-
- if (log.isDebugEnabled()) {
- log.debug("About to convert rule param: " + paramTag + propName + " = " + valueString);
- }
-
- // ATTENTION il semblerait que notre intance de beanUtils
- // soit ecrasé par celle du MatrixType ...
- // a ne pas deplacer avant la boucle
- ConvertUtilsBean beanUtils = ConverterUtil
- .getConverter(context);
- Object value = beanUtils.convert(valueString, type);
-
- if (log.isDebugEnabled()) {
- log.debug("Set rule param: " + paramTag + propName + " = " + value + "(" + valueString + ")");
- }
- RuleStorage.setParameterValue(rule, propName, value);
- } catch (Exception eee) {
- if (log.isWarnEnabled()) {
- log.info("Properties: " + props);
- log.warn("Can't reload field " + propName + " for rule " + ruleName + " with value " + valueString, eee);
- }
- }
- }
+ populateStorageParams(ruleIndex, context, rule, props, "rule");
}
/**
@@ -137,23 +98,6 @@
* regle
*/
public static Properties getRuleAsProperties(int ruleIndex, TopiaContext context, Rule rule) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(context);
- for (String paramName : RuleStorage.getParameterNames(rule).keySet()) {
- String paramValueString;
- try {
- Object value = RuleStorage.getParameterValue(rule, paramName);
- paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("rule." + ruleIndex + ".parameter." + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: " + paramName, eee);
- }
- }
- }
-
- return result;
+ return getParamsAsProperties(ruleIndex, context, rule, "rule");
}
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationParameterImpl.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -60,6 +60,7 @@
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
import fr.ifremer.isisfish.datastore.SensitivityStorage;
+import fr.ifremer.isisfish.datastore.StorageHelper;
import fr.ifremer.isisfish.entities.Population;
import fr.ifremer.isisfish.entities.PopulationDAO;
import fr.ifremer.isisfish.entities.Strategy;
@@ -294,206 +295,6 @@
return result;
}
- /**
- * Permet de mettre les parametres de la regle sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param ruleIndex l'index de la rule
- * @param rule La regle dont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres de la
- * regle
- */
- protected Properties ruleParametertoProperties(int ruleIndex, Rule rule) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- for (String paramName : RuleStorage.getParameterNames(rule).keySet()) {
- String paramValueString;
- try {
- Object value = RuleStorage.getParameterValue(rule, paramName);
- paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("rule." + ruleIndex + ".parameter." + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: " + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres de l'export sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param sensitivityExportIndex l'index de l'export
- * @param sensitivityExport l'export dont on souhaite mettre les parametres dans l'objet
- * Properties retourné
- * @return L'objet Properties contenant les valeurs des parametres de l'export
- */
- protected Properties sensitivityExportParametertoProperties(
- int sensitivityExportIndex, SensitivityExport sensitivityExport) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : SensitivityExportStorage.getParameterNames(sensitivityExport).keySet()) {
- try {
- Object value = SensitivityExportStorage.getParameterValue(
- sensitivityExport, paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("sensitivityexport."
- + sensitivityExportIndex + ".parameter."
- + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres du calculateur sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param sensitivityIndex l'index du calculateur de sensitivity
- * @param calculator Le calculateurdont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres du calculateur de sensibilité
- */
- protected Properties sensitivityCalculatorParametertoProperties(
- int sensitivityIndex, SensitivityCalculator calculator) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : SensitivityStorage.getParameterNames(calculator).keySet()) {
- try {
- Object value = SensitivityStorage.getParameterValue(calculator,
- paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("sensitivity." + sensitivityIndex + ".parameter." + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parameter value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Permet de mettre les parametres du plan sous une forme String pour
- * pouvoir les relire ensuite.
- *
- * @param planIndex l'index du plan
- * @param plan Le plan dont on souhaite mettre les parametres dans l'objet
- * Properties retourne
- * @return L'objet Properties contenant les valeurs des parametres du plan
- */
- protected Properties planParametertoProperties(int planIndex,
- AnalysePlan plan) {
- Properties result = new Properties();
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion().getStorage());
- for (String paramName : AnalysePlanStorage.getParameterNames(plan).keySet()) {
- try {
- Object value = AnalysePlanStorage.getParameterValue(plan,paramName);
- String paramValueString = beanUtils.convert(value);
- if (paramValueString != null) {
- result.setProperty("plan." + planIndex + ".parameter."
- + paramName, paramValueString);
- }
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't convert parametre value to String: "
- + paramName, eee);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Recupere dans prop les valeurs des champs specifique au plan et met a
- * jour les champs du plan.
- *
- * @param planIndex l'index du plan
- * @param plan le plan dont les parametres doivent etre lu depuis les
- * proprietes
- * @param props les proprietes contenant les parametre du plan
- */
- protected void populateAnalysePlan(int planIndex, AnalysePlan plan,
- Properties props) {
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- String planName = AnalysePlanStorage.getName(plan);
- String paramTag = "plan." + planIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : AnalysePlanStorage.getParameterNames(plan).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = props.getProperty(paramTag + propName);
- Object value = beanUtils.convert(valueString, type);
- try {
- AnalysePlanStorage.setParameterValue(plan, propName, value);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't reload field " + propName + " for plan "
- + planName, eee);
- }
- }
- }
- }
-
- /**
- * Recupere dans prop les valeurs des champs specifique au calculateur de
- * sensibilité et met a jour les champs du calculateur.
- *
- * @param calculatorIndex l'index du calculateur
- * @param calculator le calculateur dont les parametres doivent etre lu depuis lesproprietes
- * @param props les proprietes contenant les parametre du calculateur
- */
- protected void populateSensitivityCalculator(int calculatorIndex,
- SensitivityCalculator calculator, Properties props) {
- ConvertUtilsBean beanUtils = ConverterUtil.getConverter(getRegion()
- .getStorage());
- String calculatorName = SensitivityStorage.getName(calculator);
- String paramTag = "sensitivity." + calculatorIndex + ".parameter.";
-
- for (Map.Entry<String, Class<?>> entry : SensitivityStorage.getParameterNames(calculator).entrySet()) {
- String propName = entry.getKey();
- Class<?> type = entry.getValue();
- if (TopiaEntity.class.isAssignableFrom(type)) {
- type = TopiaEntity.class;
- }
- String valueString = props.getProperty(paramTag + propName);
- Object value = beanUtils.convert(valueString, type);
- try {
- SensitivityStorage.setParameterValue(calculator, propName, value);
- } catch (IsisFishException eee) {
- if (log.isWarnEnabled()) {
- log.warn("Can't reload field " + propName
- + " for sensitivity calculator " + calculatorName,
- eee);
- }
- }
- }
- }
-
/*
* @see fr.ifremer.isisfish.simulator.SimulationParameter#getExtraRules()
*/
@@ -692,7 +493,8 @@
AnalysePlan plan = AnalysePlanStorage
.getAnalysePlan(name)
.getNewAnalysePlanInstance();
- populateAnalysePlan(planIndex++, plan, propertiesParameters);
+ StorageHelper.populateStorageParams(planIndex++,
+ getRegion().getStorage(), plan, propertiesParameters, "plan");
analysePlans.add(plan);
} catch (IsisFishException eee) {
if (log.isWarnEnabled()) {
@@ -955,7 +757,8 @@
SensitivityStorage sensitivityStorage = SensitivityStorage.getSensitivity(calculatorName);
sensitivityCalculator = sensitivityStorage.getNewSensitivityInstance();
// 0 = only single sensitivity
- populateSensitivityCalculator(0, sensitivityCalculator, propertiesParameters);
+ StorageHelper.populateStorageParams(0, getRegion().getStorage(), sensitivityCalculator,
+ propertiesParameters, "sensitivity");
} catch (IsisFishException eee) {
sensitivityCalculator = null;
if (log.isWarnEnabled()) {
@@ -1700,7 +1503,7 @@
int ruleIndex = 0;
for (Rule rule : getRules()) {
ruleList += RuleStorage.getName(rule) + ",";
- Properties ruleProp = ruleParametertoProperties(ruleIndex++, rule);
+ Properties ruleProp = RuleHelper.getRuleAsProperties(ruleIndex++, getRegion().getStorage(), rule);
result.putAll(ruleProp);
}
result.setProperty("rules", ruleList);
@@ -1724,7 +1527,8 @@
int planIndex = 0;
for (AnalysePlan plan : getAnalysePlans()) {
planList += AnalysePlanStorage.getName(plan) + ",";
- Properties planProp = planParametertoProperties(planIndex++, plan);
+ Properties planProp = StorageHelper.getParamsAsProperties(planIndex++,
+ getRegion().getStorage(), plan, "plan");
result.putAll(planProp);
}
result.setProperty("plans", planList);
@@ -1760,8 +1564,8 @@
result.setProperty("sensitivitycalculator", calculatorName);
// calculator parameter
- Properties calculatorParams = sensitivityCalculatorParametertoProperties(
- 0, getSensitivityCalculator());
+ Properties calculatorParams = StorageHelper.getParamsAsProperties(0,
+ getRegion().getStorage(), getSensitivityCalculator(), "sensitivity");
result.putAll(calculatorParams);
} else {
if (propertiesParameters != null
@@ -1783,8 +1587,8 @@
for (SensitivityExport sensitivityExport : getSensitivityExport()) {
sensitivityExportList += SensitivityExportStorage
.getName(sensitivityExport) + ",";
- Properties exportProp = sensitivityExportParametertoProperties(
- sensitivityExportIndex++, sensitivityExport);
+ Properties exportProp = ExportHelper.getSensitivityExportAsProperties(
+ sensitivityExportIndex++, getRegion().getStorage(), sensitivityExport);
result.putAll(exportProp);
}
result.setProperty("sensitivityexports", sensitivityExportList);
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/sensitivity/SensitivityChooserUI.jaxx 2011-06-17 13:55:14 UTC (rev 3420)
@@ -83,22 +83,23 @@
}
protected void sensCalculatorChanged() {
-
- // TODO change combo box content
+
+ String sensitivityName = (String)fieldSensitivityCalculatorSelect.getSelectedItem();
+
// when calculator is changed by refreshSelectedSensitivityCalculator
// this event is thrown by build a new Calculator instance
// and parameter are lost
+ // fix it with a small class name test
+ SensitivityCalculator sensivitityCalculator = getSimulAction().getSensitivityCalculator();
+ if (sensivitityCalculator != null && sensivitityCalculator.getClass().getSimpleName().equals(sensitivityName)) {
+ sensivitityCalculator = getSimulAction().getSensitivityCalculator();
+ } else {
+ sensivitityCalculator = getSimulAction().getSensivitityCalculatorInstance(sensitivityName);
+ }
- String sensitivityName = (String)fieldSensitivityCalculatorSelect.getSelectedItem();
- SensitivityCalculator sensivitityCalculator = getSimulAction().getSensivitityCalculatorInstance(sensitivityName);
-
// can be null for example if calculator can't be compiled
if (sensivitityCalculator != null) {
getSimulAction().setSensitivityCalculator(sensivitityCalculator);
-
- // enable/disable table (if sensivitityCalculator can manage it)
- //factorCardinalityScrollPane.setVisible(!sensivitityCalculator.canManageCardinality());
- //validate();
CardLayout factorPanelLayout = (CardLayout)factorCardinalityPanel.getLayout();
if (sensivitityCalculator.canManageCardinality()) {
@@ -106,10 +107,8 @@
} else {
factorPanelLayout.show(factorCardinalityPanel, "factorCardinalityNotSupported");
}
-
// update model
- //setSensitivityCalculatorParamsModel();
SensitivityCalculatorParametersTableModel parametersTableModel = new SensitivityCalculatorParametersTableModel(sensivitityCalculator);
simulSensitivityCalculatorParam.setModel(parametersTableModel);
simulSensitivityCalculatorParam.getColumnModel().getColumn(0).setCellRenderer(new SensitivityCalculatorParametersTableCellRenderer(sensivitityCalculator));
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Doc.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Doc.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Doc.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * Copyright (C) 2009 - 2011 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
Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DocHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DocHelper.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DocHelper.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -1,140 +0,0 @@
-/*
- * #%L
- * IsisFish
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2007 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as
- * published by the Free Software Foundation, either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/gpl-2.0.html>.
- * #L%
- */
-
-package fr.ifremer.isisfish.util;
-
-import static org.nuiton.i18n.I18n._;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.lang.reflect.Field;
-
-/**
- * Class containing usefull methods to obtain @Doc informations
- * for a class,field,method...
- *
- * @author chemit
- * @version $Revision$
- *
- * Last update : $Date$
- * By : $Author$
- */
-public class DocHelper {
-
- /** Logger for this class */
- private static final Log log = LogFactory.getLog(DocHelper.class);
-
- /**
- * @param klazz class to use
- * @return the @Doc associated with the class of null if klazz is null or
- * there is no Doc for this klazz
- */
- public static Doc getClassDoc(Class<?> klazz) {
- return klazz == null ? null : klazz.getAnnotation(Doc.class);
- }
-
- /**
- * @param value object given
- * @return the @Doc associated to the class of the given object, or null if value is
- * null or no doc found for his class
- *
- * @deprecated as of 20090408 never used
- */
- public static Doc getClassDoc(Object value) {
- return value == null ? null : getClassDoc(value.getClass());
- }
-
- /**
- * @param f file to use
- * @return the @Doc associated to the field, or null
- * if field is null of no @doc found
- *
- * @deprecated as of 20090408 never used
- */
- public static Doc getFieldDoc(Field f) {
- return f == null ? null : f.getAnnotation(Doc.class);
- }
-
- /**
- * @param klazz class to use
- * @param fieldName field name to use
- * @return the @Doc associated with e filed of the given class,
- * or null if class is null, field does not exist, or no
- * Doc for the field
- */
- public static Doc getFieldDoc(Class<?> klazz, String fieldName) {
- Field f = null;
- try {
- f = klazz == null ? null : klazz.getField(fieldName);
- } catch (NoSuchFieldException e) {
- // should never appear
- log.warn(_("isisfish.error.not.found.field.class", fieldName,
- klazz));
- //throw new IsisFishRuntimeException(e);
- }
- return f == null ? null : f.getAnnotation(Doc.class);
- }
-
- /**
- * @param doc doc to use
- * @return the {@link Doc#value()} of the given @Doc
- *
- * @deprecated as of 20090408 never used
- */
- public static String getValue(Doc doc) {
- return doc == null ? "" : doc.value();
- }
-
- /**
- * @param doc doc to use
- * @return the {@link Doc#author()}} of the given @Doc
- *
- * @deprecated as of 20090408 never used
- */
- public static String getAuthor(Doc doc) {
- return doc == null ? "" : doc.author();
- }
-
- /**
- * @param doc doc to use
- * @return the {@link Doc#date()} of the given @Doc
- *
- * @deprecated as of 20090408 never used
- */
- public static String getDate(Doc doc) {
- return doc == null ? "" : doc.date();
- }
-
- /**
- * @param doc doc to use
- * @return the {@link Doc#version()} of the given @Doc
- *
- * @deprecated as of 20090408 never used
- */
- public static String getVersion(Doc doc) {
- return doc == null ? "" : doc.version();
- }
-}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Docable.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Docable.java 2011-06-17 12:13:36 UTC (rev 3419)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/Docable.java 2011-06-17 13:55:14 UTC (rev 3420)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2009 - 2010 Ifremer, Code Lutin
+ * Copyright (C) 2009 - 2011 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
@@ -30,7 +30,6 @@
*
* @author chemit
* @see Doc
- * @see DocHelper
* @version $Revision$
*
* Last update : $Date$
@@ -39,13 +38,6 @@
public interface Docable {
/**
- * Class documentation (if any).
- *
- * @return the @Doc of the class, or null if none
- */
- Doc getClassDoc();
-
- /**
* Field documentation (if any).
*
* @param fieldName name of the field to use
1
0
r3419 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
17 Jun '11
Author: chatellier
Date: 2011-06-17 12:13:36 +0000 (Fri, 17 Jun 2011)
New Revision: 3419
Log:
Fix preparation zip creation (including community scripts)
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-17 09:41:30 UTC (rev 3418)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationService.java 2011-06-17 12:13:36 UTC (rev 3419)
@@ -74,6 +74,7 @@
import fr.ifremer.isisfish.datastore.RuleStorage;
import fr.ifremer.isisfish.datastore.ScriptStorage;
import fr.ifremer.isisfish.datastore.SensitivityExportStorage;
+import fr.ifremer.isisfish.datastore.SensitivityStorage;
import fr.ifremer.isisfish.datastore.SimulationStorage;
import fr.ifremer.isisfish.datastore.SimulatorStorage;
import fr.ifremer.isisfish.export.SensitivityExport;
@@ -1115,16 +1116,21 @@
List<Rule> rules = param.getRules();
for (Rule rule : rules) {
String name = RuleStorage.getName(rule);
- FileUtil.copy(new File(RuleStorage.getRuleDirectory(), name
- + ".java"),
- new File(tmpDirectory, RuleStorage.RULE_PATH
+ File ruleFile = new File(RuleStorage.getRuleDirectory(), name + ".java");
+ if (!ruleFile.isFile()) {
+ ruleFile = new File(RuleStorage.getCommunityRuleDirectory(), name + ".java");
+ }
+ FileUtil.copy(ruleFile, new File(tmpDirectory, RuleStorage.RULE_PATH
+ File.separator + name + ".java"));
}
+
// copie des regles reclamées par les plans d'analyse
for (String name : param.getExtraRules()) {
- FileUtil.copy(new File(RuleStorage.getRuleDirectory(), name
- + ".java"),
- new File(tmpDirectory, RuleStorage.RULE_PATH
+ File ruleFile = new File(RuleStorage.getRuleDirectory(), name + ".java");
+ if (!ruleFile.isFile()) {
+ ruleFile = new File(RuleStorage.getCommunityRuleDirectory(), name + ".java");
+ }
+ FileUtil.copy(ruleFile, new File(tmpDirectory, RuleStorage.RULE_PATH
+ File.separator + name + ".java"));
}
@@ -1132,17 +1138,22 @@
List<AnalysePlan> plans = param.getAnalysePlans();
for (AnalysePlan plan : plans) {
String name = AnalysePlanStorage.getName(plan);
- FileUtil.copy(new File(AnalysePlanStorage
- .getAnalysePlanDirectory(), name + ".java"), new File(
- tmpDirectory, AnalysePlanStorage.ANALYSE_PLAN_PATH
+ File planFile = new File(AnalysePlanStorage.getAnalysePlanDirectory(), name + ".java");
+ if (!planFile.isFile()) {
+ planFile = new File(AnalysePlanStorage.getCommunityAnalysePlanDirectory(), name + ".java");
+ }
+ FileUtil.copy(planFile, new File(tmpDirectory, AnalysePlanStorage.ANALYSE_PLAN_PATH
+ File.separator + name + ".java"));
}
// copie de tous les exports a utiliser
for (String name : param.getExportNames()) {
name = name.endsWith(".java") ? name : name + ".java";
- FileUtil.copy(
- new File(ExportStorage.getExportDirectory(), name),
+ File exportFile = new File(ExportStorage.getExportDirectory(), name);
+ if (!exportFile.isFile()) {
+ exportFile = new File(ExportStorage.getCommunityExportDirectory(), name);
+ }
+ FileUtil.copy(exportFile,
new File(tmpDirectory, ExportStorage.EXPORT_PATH
+ File.separator + name));
}
@@ -1151,24 +1162,33 @@
for (SensitivityExport sensitivity : param.getSensitivityExport()) {
String name = SensitivityExportStorage.getName(sensitivity);
name = name.endsWith(".java") ? name : name + ".java";
- FileUtil.copy(
- new File(SensitivityExportStorage.getSensitivityExportDirectory(), name),
+ File sensitivityFile = new File(SensitivityExportStorage.getSensitivityExportDirectory(), name);
+ if (!sensitivityFile.isFile()) {
+ sensitivityFile = new File(SensitivityExportStorage.getCommunitySensitivityExportDirectory(), name);
+ }
+ FileUtil.copy(sensitivityFile,
new File(tmpDirectory, SensitivityExportStorage.SENSITIVITY_EXPORT_PATH
+ File.separator + name));
}
// 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
- FileUtil.copy(new File(SimulatorStorage.getSimulatorDirectory(),
- param.getSimulatorName()), new File(tmpDirectory,
+ File simulatorFile = new File(SimulatorStorage.getSimulatorDirectory(), param.getSimulatorName());
+ if (!simulatorFile.isFile()) {
+ simulatorFile = new File(SimulatorStorage.getCommunitySimulatorDirectory(), param.getSimulatorName());
+ }
+ FileUtil.copy(simulatorFile, new File(tmpDirectory,
SimulatorStorage.SIMULATOR_PATH + File.separator
+ param.getSimulatorName()));
// convert all file to UTF-8
- convertAllFile(control, tmpDirectory);
+ //convertAllFile(control, tmpDirectory);
if (compile) {
compileAllFile(control, tmpDirectory);
@@ -1201,14 +1221,14 @@
}
- /**
+ /*
* 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");
@@ -1240,9 +1260,8 @@
// 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
@@ -1268,27 +1287,21 @@
List<File> fileToCompile = new ArrayList<File>();
- List<File> tmp = FileUtil.find(new File(directory,
- ExportStorage.EXPORT_PATH), ".*\\.java$", true);
- fileToCompile.addAll(tmp);
-
- tmp = FileUtil.find(new File(directory,
- SensitivityExportStorage.SENSITIVITY_EXPORT_PATH), ".*\\.java$", true);
- fileToCompile.addAll(tmp);
+ String[] modules = {
+ AnalysePlanStorage.ANALYSE_PLAN_PATH,
+ ExportStorage.EXPORT_PATH,
+ RuleStorage.RULE_PATH,
+ SensitivityExportStorage.SENSITIVITY_EXPORT_PATH,
+ SensitivityStorage.SENSITIVITY_PATH,
+ ScriptStorage.SCRIPT_PATH,
+ SimulatorStorage.SIMULATOR_PATH
+ };
- tmp = FileUtil.find(new File(directory, RuleStorage.RULE_PATH),
- ".*\\.java$", true);
- fileToCompile.addAll(tmp);
+ for (String module : modules) {
+ List<File> tmp = FileUtil.find(new File(directory, module), ".*\\.java$", true);
+ fileToCompile.addAll(tmp);
+ }
- tmp = FileUtil.find(new File(directory,
- AnalysePlanStorage.ANALYSE_PLAN_PATH), ".*\\.java$", true);
- fileToCompile.addAll(tmp);
-
- tmp = FileUtil.find(
- new File(directory, SimulatorStorage.SIMULATOR_PATH),
- ".*\\.java$", true);
- fileToCompile.addAll(tmp);
-
//
// Compilation
//
1
0
r3418 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
17 Jun '11
Author: chatellier
Date: 2011-06-17 09:41:30 +0000 (Fri, 17 Jun 2011)
New Revision: 3418
Log:
Fix vcs delete diff
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2011-06-17 08:39:59 UTC (rev 3417)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2011-06-17 09:41:30 UTC (rev 3418)
@@ -191,15 +191,4 @@
public void reload() {
content = null;
}
-
- /**
- * Return diff between current file content and VCS file content.
- *
- * @return diff as string
- * @throws VCSException
- * @throws IOException
- */
- public String diff() throws VCSException, IOException {
- return getVCS().getDiff(getFile());
- }
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2011-06-17 08:39:59 UTC (rev 3417)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ScriptStorage.java 2011-06-17 09:41:30 UTC (rev 3418)
@@ -136,11 +136,11 @@
* @return Le storage pour la regle
*/
static public ScriptStorage getCommunityScript(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
+ String cacheName = getCommunityDatabaseCacheKey(name);
ScriptStorage result = scriptsCache.get(cacheName);
if (result == null) {
- result = new ScriptStorage(getContextDatabaseDirectory(),
- getScriptDirectory(), name);
+ result = new ScriptStorage(getCommunityDatabaseDirectory(),
+ getCommunityScriptDirectory(), name);
scriptsCache.put(cacheName, result);
}
return result;
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-17 08:39:59 UTC (rev 3417)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-17 09:41:30 UTC (rev 3418)
@@ -28,6 +28,7 @@
import static org.nuiton.i18n.I18n._;
import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -327,7 +328,7 @@
}
try {
- getVCS().delete(files, _("isisfish.versionStorage.removed"));
+ getCurrentVCS().delete(files, _("isisfish.versionStorage.removed"));
} catch (VCSException eee) {
throw new StorageException(
_("isisfish.error.delete.vcs.files"), eee);
@@ -362,15 +363,26 @@
*/
public void update() throws VCSException {
prepare();
- getVCS().update(getFile(), true);
+ getCurrentVCS().update(getFile(), true);
}
public boolean isUpToDate() throws VCSException {
prepare();
- return getVCS().isUpToDate(getFile());
+ return getCurrentVCS().isUpToDate(getFile());
}
/**
+ * Return diff between current file content and VCS file content.
+ *
+ * @return diff as string
+ * @throws VCSException
+ * @throws IOException
+ */
+ public String diff() throws VCSException, IOException {
+ return getCurrentVCS().getDiff(getFile());
+ }
+
+ /**
* Permet de ramener tout un répertoire du VCS. Utile seulement pour le
* premier lancement pour scipts et exports.
*
1
0
r3417 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore ui/script util
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
by chatellier@users.labs.libre-entreprise.org 17 Jun '11
17 Jun '11
Author: chatellier
Date: 2011-06-17 08:39:59 +0000 (Fri, 17 Jun 2011)
New Revision: 3417
Log:
Fix la compilation des sources community qui dependent de sources officiel.
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2011-06-16 16:43:54 UTC (rev 3416)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/CodeSourceStorage.java 2011-06-17 08:39:59 UTC (rev 3417)
@@ -166,11 +166,23 @@
* @throws IOException
*/
public void setContent(String content) throws IOException {
+ setContent(content, true);
+ }
+
+ /**
+ * Set file content.
+ *
+ * @param content new content
+ * @param saveToFile if {@code true} also save content to file
+ * @throws IOException
+ */
+ public void setContent(String content, boolean saveToFile) throws IOException {
this.content = content;
- // FIXME hard coded encoding ?
- FileUtil.writeString(getFile(), content, "utf-8");
- lastContentUpdate = System.nanoTime();
- lastContentLength = getFile().length();
+ if (saveToFile) {
+ FileUtil.writeString(getFile(), content, "utf-8");
+ lastContentUpdate = System.nanoTime();
+ lastContentLength = getFile().length();
+ }
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-16 16:43:54 UTC (rev 3416)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-17 08:39:59 UTC (rev 3417)
@@ -119,7 +119,7 @@
* @return context cache key
*/
protected static String getCommunityDatabaseCacheKey(String key) {
- String result = getContextDatabaseDirectory().getAbsolutePath() + key;
+ String result = getCommunityDatabaseDirectory().getAbsolutePath() + key;
return result;
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:43:54 UTC (rev 3416)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-17 08:39:59 UTC (rev 3417)
@@ -509,12 +509,12 @@
}
try {
- //String content = scriptUI.getEditor().getText();
- //codeStorage.setContent(content);
// setContent() or scriptUI.getEditor().save()
// if setContent() only editor ask for t saving
scriptUI.getEditor().save();
-
+ String content = scriptUI.getEditor().getText();
+ codeStorage.setContent(content, false);
+
// notify tree to refresh
ScriptTreeModel model = scriptUI.getScriptTreeModel();
model.fileModified(codeStorage.getFile());
@@ -686,49 +686,43 @@
public boolean checkScript() {
boolean check = false;
- String content = scriptUI.getEditor().getText();
// can't compile formule
if (codeStorage instanceof FormuleStorage) {
return false;
}
+ if (log.isDebugEnabled()) {
+ log.debug("checkScript called");
+ }
+ // save script before compile
+ saveScript();
+
+ JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
+ StringWriter result = new StringWriter();
+ PrintWriter out = new PrintWriter(result);
try {
- if (log.isDebugEnabled()) {
- log.debug("checkScript called");
- }
- // save script before commit
- codeStorage.setContent(content);
- JavaSourceStorage javaCode = (JavaSourceStorage) codeStorage;
- StringWriter result = new StringWriter();
- PrintWriter out = new PrintWriter(result);
- try {
- int compileResult = javaCode.compile(false, out);
+ int compileResult = javaCode.compile(false, out);
- if (compileResult == 0) {
- check = true;
- }
- } catch (Exception eee) {
- eee.printStackTrace(out);
+ if (compileResult == 0) {
+ check = true;
}
- out.flush();
+ } catch (Exception eee) {
+ eee.printStackTrace(out);
+ }
+ out.flush();
- if (check) {
- scriptUI.getActionLogArea().setText(
- _("isisfish.script.compilation.ok", result.toString()));
- scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
- } else {
- scriptUI.getActionLogArea().setText(
- _("isisfish.script.compilation.failed", result
- .toString()));
- scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
- }
-
- } catch (IOException ex) {
- if (log.isErrorEnabled()) {
- log.error("Error on script check", ex);
- }
+ if (check) {
+ scriptUI.getActionLogArea().setText(
+ _("isisfish.script.compilation.ok", result.toString()));
+ scriptUI.getActionLogArea().setBackground(COLOR_SUCCESS);
+ } else {
+ scriptUI.getActionLogArea().setText(
+ _("isisfish.script.compilation.failed", result
+ .toString()));
+ scriptUI.getActionLogArea().setBackground(COLOR_FAILURE);
}
+
setStatusMessage(_("isisfish.message.check.finished"));
return check;
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2011-06-16 16:43:54 UTC (rev 3416)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2011-06-17 08:39:59 UTC (rev 3417)
@@ -139,8 +139,7 @@
boolean force, PrintWriter out) {
File src = source.getFile();
File dst = new File(destDir, source.getFQN().replace('.',
- File.separatorChar)
- + ".class");
+ File.separatorChar) + ".class");
if (force || FileUtil.isNewer(src, dst)) {
return compile(source.getRoot(), src, destDir, out);
}
@@ -187,7 +186,14 @@
int result = -10000;
try {
List<File> classpath = new ArrayList<File>();
+
classpath.add(rootSrc.getAbsoluteFile());
+ // FIXME echatellier 20110617 : hack depuis qu'il y a un
+ // nouveau dossier de sources de script "communauté", mais
+ // qui peu dépendre de sources du dossier "officiel"
+ if (rootSrc.equals(IsisFish.config.getCommunityDatabaseDirectory())) {
+ classpath.add(IsisFish.config.getDatabaseDirectory());
+ }
result = compile(classpath, src, dest, out);
} catch (Exception eee) {
1
0
r3416 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore ui/script
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
16 Jun '11
Author: chatellier
Date: 2011-06-16 16:43:54 +0000 (Thu, 16 Jun 2011)
New Revision: 3416
Log:
Fix export compilation
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-16 16:15:36 UTC (rev 3415)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-16 16:43:54 UTC (rev 3416)
@@ -155,8 +155,9 @@
* @return la liste des noms de toutes les régions disponible en local
*/
public static List<String> getExportNames() {
- File dir = getExportDirectory();
- return getStorageNames(dir);
+ List<String> result = getStorageNames(getExportDirectory());
+ result.addAll(getStorageNames(getCommunityExportDirectory()));
+ return result;
}
public static void checkout() throws VCSException {
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:15:36 UTC (rev 3415)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:43:54 UTC (rev 3416)
@@ -1121,28 +1121,28 @@
CommunityAnalysePlan(
AnalysePlanStorage.getCommunityAnalysePlanDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ AnalysePlanStorage.ANALYSE_PLAN_TEMPLATE),
CommunityExport(
ExportStorage.getCommunityExportDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ ExportStorage.EXPORT_TEMPLATE),
CommunityRule(
RuleStorage.getCommunityRuleDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ RuleStorage.RULE_TEMPLATE),
CommunityScript(
ScriptStorage.getCommunityScriptDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ ScriptStorage.SCRIPT_TEMPLATE),
CommunitySensitivity(
SensitivityStorage.getCommunitySensitivityDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ SensitivityStorage.SENSIVITY_TEMPLATE),
CommunitySensitivityExport(
SensitivityExportStorage.getCommunitySensitivityExportDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE),
+ SensitivityExportStorage.SENSITIVITY_EXPORT_TEMPLATE),
CommunitySimulator(
SimulatorStorage.getCommunitySimulatorDirectory(),
SimulatorStorage.SIMULATOR_TEMPLATE),
CommunityFormule(
FormuleStorage.getCommunityFormuleDirectory(),
- SimulatorStorage.SIMULATOR_TEMPLATE);
+ FormuleStorage.FORMULE_TEMPLATE);
protected File module;
protected String templatePath;
1
0
16 Jun '11
Author: chatellier
Date: 2011-06-16 16:15:36 +0000 (Thu, 16 Jun 2011)
New Revision: 3415
Log:
Wrong commit
Modified:
isis-fish/trunk/src/main/resources/log4j.properties
Modified: isis-fish/trunk/src/main/resources/log4j.properties
===================================================================
--- isis-fish/trunk/src/main/resources/log4j.properties 2011-06-16 16:15:05 UTC (rev 3414)
+++ isis-fish/trunk/src/main/resources/log4j.properties 2011-06-16 16:15:36 UTC (rev 3415)
@@ -41,6 +41,3 @@
log4j.logger.sensitivity=INFO
log4j.logger.sensitivityexports=INFO
log4j.logger.simulators=INFO
-
-log4j.logger.fr.ifremer.isisfish.datastore=DEBUG
-log4j.logger.fr.ifremer.isisfish.vcs=DEBUG
1
0
r3414 - in isis-fish/trunk/src/main: java/fr/ifremer/isisfish/datastore java/fr/ifremer/isisfish/ui/script resources
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
16 Jun '11
Author: chatellier
Date: 2011-06-16 16:15:05 +0000 (Thu, 16 Jun 2011)
New Revision: 3414
Log:
Oubli?\195?\169 les exports
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
isis-fish/trunk/src/main/resources/log4j.properties
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ExportStorage.java 2011-06-16 16:15:05 UTC (rev 3414)
@@ -116,21 +116,38 @@
}
/**
- * Retourne le storage pour la regle demandée
+ * Retourne le storage pour l'export demandée
*
- * @param name le nom de la regle souhaitée
- * @return Le storage pour la regle
+ * @param name le nom de l'export souhaitée
+ * @return Le storage pour l'export
*/
public static ExportStorage getExport(String name) {
String cacheName = getContextDatabaseCacheKey(name);
ExportStorage result = scriptsCache.get(cacheName);
if (result == null) {
- result = new ExportStorage(IsisFish.config.getContextDatabaseDirectory(),
+ result = new ExportStorage(getContextDatabaseDirectory(),
getExportDirectory(), name);
scriptsCache.put(cacheName, result);
}
return result;
}
+
+ /**
+ * Retourne le storage pour l'export demandée
+ *
+ * @param name le nom de l'export souhaitée
+ * @return Le storage pour l'export
+ */
+ public static ExportStorage getCommunityExport(String name) {
+ String cacheName = getCommunityDatabaseCacheKey(name);
+ ExportStorage result = scriptsCache.get(cacheName);
+ if (result == null) {
+ result = new ExportStorage(getCommunityDatabaseDirectory(),
+ getCommunityExportDirectory(), name);
+ scriptsCache.put(cacheName, result);
+ }
+ return result;
+ }
/**
* Retourne la liste des noms de toutes les régions disponible en local
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:01:05 UTC (rev 3413)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:15:05 UTC (rev 3414)
@@ -464,7 +464,7 @@
script = AnalysePlanStorage.getCommunityAnalysePlan(file.getName());
break;
case CommunityExport:
- script = RuleStorage.getCommunityRule(file.getName());
+ script = ExportStorage.getCommunityExport(file.getName());
break;
case CommunityScript:
script = ScriptStorage.getCommunityScript(file.getName());
Modified: isis-fish/trunk/src/main/resources/log4j.properties
===================================================================
--- isis-fish/trunk/src/main/resources/log4j.properties 2011-06-16 16:01:05 UTC (rev 3413)
+++ isis-fish/trunk/src/main/resources/log4j.properties 2011-06-16 16:15:05 UTC (rev 3414)
@@ -41,3 +41,6 @@
log4j.logger.sensitivity=INFO
log4j.logger.sensitivityexports=INFO
log4j.logger.simulators=INFO
+
+log4j.logger.fr.ifremer.isisfish.datastore=DEBUG
+log4j.logger.fr.ifremer.isisfish.vcs=DEBUG
1
0
r3413 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore ui/script
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
16 Jun '11
Author: chatellier
Date: 2011-06-16 16:01:05 +0000 (Thu, 16 Jun 2011)
New Revision: 3413
Log:
Fixage du cache des storages.
Ajout des sensitivity oubli?\195?\169s.
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -142,7 +142,7 @@
* @return Le storage pour le plan
*/
static public AnalysePlanStorage getCommunityAnalysePlan(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
+ String cacheName = getCommunityDatabaseCacheKey(name);
AnalysePlanStorage result = plansCache.get(cacheName);
if (result == null) {
result = new AnalysePlanStorage(getCommunityDatabaseDirectory(),
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -269,7 +269,7 @@
* @return Le storage pour la regle
*/
static public FormuleStorage getCommunityFormule(String category, String name) {
- String key = category + File.separator + name;
+ String key = "community" + category + File.separator + name;
FormuleStorage result = formulesCache.get(key);
if (result == null) {
String extension = FileUtil.extension(new File(name), ".");
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -145,7 +145,7 @@
* @return Le storage pour la regle
*/
static public RuleStorage getCommunityRule(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
+ String cacheName = getCommunityDatabaseCacheKey(name);
RuleStorage result = rulesCache.get(cacheName);
if (result == null) {
result = new RuleStorage(getCommunityDatabaseDirectory(),
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -132,7 +132,7 @@
* @return Le storage pour l'export
*/
public static SensitivityExportStorage getCommunitySensitivityExport(String name) {
- String cacheName = getContextDatabaseCacheKey(name);
+ String cacheName = getCommunityDatabaseCacheKey(name);
SensitivityExportStorage result = sensitivityExportsCache.get(cacheName);
if (result == null) {
result = new SensitivityExportStorage(getCommunityDatabaseDirectory(),
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -112,8 +112,9 @@
* @return le nom de tous les calculateurs de sensibilité existans en local
*/
public static List<String> getSensitivityNames() {
- File dir = getSensitivityDirectory();
- return getStorageNames(dir);
+ List<String> result = getStorageNames(getSensitivityDirectory());
+ result.addAll(getStorageNames(getCommunitySensitivityDirectory()));
+ return result;
}
/**
@@ -131,6 +132,22 @@
}
return result;
}
+
+ /**
+ * Retourne le storage pour le calculateur demandé.
+ *
+ * @param name le nom du calculateur souhaité
+ * @return Le {@link SensitivityStorage} pour le calculateur
+ */
+ public static SensitivityStorage getCommunitySensitivity(String name) {
+ String cacheName = getCommunityDatabaseCacheKey(name);
+ SensitivityStorage result = sensitivityCache.get(cacheName);
+ if (result == null) {
+ result = new SensitivityStorage(getCommunityDatabaseDirectory(), getCommunitySensitivityDirectory(), name);
+ sensitivityCache.put(cacheName, result);
+ }
+ return result;
+ }
/**
* Retourne une nouvelle instance du calculateur. Compile le fichier si besoin
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -40,7 +40,6 @@
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFish;
-import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.vcs.VCS;
import fr.ifremer.isisfish.vcs.VCSException;
import fr.ifremer.isisfish.vcs.VCSNone;
@@ -106,13 +105,23 @@
* Two simulation must have their own cache.
*
* @return context cache key
- *
- * TODO better place in other storage, but needed for region and java scripts
*/
protected static String getContextDatabaseCacheKey(String key) {
String result = getContextDatabaseDirectory().getAbsolutePath() + key;
return result;
}
+
+ /**
+ * Get cache storage key to use depending on context storage used.
+ *
+ * Two simulation must have their own cache and community scripts too.
+ *
+ * @return context cache key
+ */
+ protected static String getCommunityDatabaseCacheKey(String key) {
+ String result = getContextDatabaseDirectory().getAbsolutePath() + key;
+ return result;
+ }
/**
* Get VCS instance for storage file.
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 15:19:52 UTC (rev 3412)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 16:01:05 UTC (rev 3413)
@@ -472,6 +472,12 @@
case CommunitySimulator:
script = SimulatorStorage.getCommunitySimulator(file.getName());
break;
+ case CommunitySensitivity:
+ script = SensitivityStorage.getCommunitySensitivity(file.getName());
+ break;
+ case CommunitySensitivityExport:
+ script = SensitivityExportStorage.getCommunitySensitivityExport(file.getName());
+ break;
default:
log.fatal("ScriptType unknown: " + file.getName());
}
@@ -682,6 +688,11 @@
boolean check = false;
String content = scriptUI.getEditor().getText();
+ // can't compile formule
+ if (codeStorage instanceof FormuleStorage) {
+ return false;
+ }
+
try {
if (log.isDebugEnabled()) {
log.debug("checkScript called");
1
0
r3412 - isis-fish/trunk/src/main/java/fr/ifremer/isisfish
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
16 Jun '11
Author: chatellier
Date: 2011-06-16 15:19:52 +0000 (Thu, 16 Jun 2011)
New Revision: 3412
Log:
modify default config
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2011-06-16 15:02:46 UTC (rev 3411)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/IsisConfig.java 2011-06-16 15:19:52 UTC (rev 3412)
@@ -1055,7 +1055,7 @@
VCS_COMMUNITY_PROTOCOL("vcs.community.protocole", n_("isisfish.config.vcs.community.protocol.description"), "http"),
VCS_COMMUNITY_USER_NAME("vcs.community.username", n_("isisfish.config.vcs.community.username.description"), ""),
VCS_COMMUNITY_PASSWORD("vcs.community.password", n_("isisfish.config.vcs.community.password.description"), ""),
- VCS_COMMUNITY_HOST_NAME("vcs.community.hostname", n_("isisfish.config.vcs.community.hostname.description"), "www.isis-fish.org"),
+ VCS_COMMUNITY_HOST_NAME("vcs.community.hostname", n_("isisfish.config.vcs.community.hostname.description"), "svn.isis-fish.org"),
VCS_COMMUNITY_PATH("vcs.community.path", n_("isisfish.config.vcs.community.remotepath.description"), "/svn/isis-fish-community/"),
// misc options
1
0
r3411 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish: datastore ui/script util
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
by chatellier@users.labs.libre-entreprise.org 16 Jun '11
16 Jun '11
Author: chatellier
Date: 2011-06-16 15:02:46 +0000 (Thu, 16 Jun 2011)
New Revision: 3411
Log:
Multi VCS may now works
Modified:
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/AnalysePlanStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -113,8 +113,9 @@
* @return les noms de tous les plans existant en local
*/
static public List<String> getAnalysePlanNames() {
- File dir = getAnalysePlanDirectory();
- return AnalysePlanStorage.getStorageNames(dir);
+ List<String> result = getStorageNames(getAnalysePlanDirectory());
+ result.addAll(getStorageNames(getCommunityAnalysePlanDirectory()));
+ return result;
}
/**
@@ -133,6 +134,23 @@
}
return result;
}
+
+ /**
+ * Retourne le storage pour le plan demandé.
+ *
+ * @param name le nom du plan souhaité
+ * @return Le storage pour le plan
+ */
+ static public AnalysePlanStorage getCommunityAnalysePlan(String name) {
+ String cacheName = getContextDatabaseCacheKey(name);
+ AnalysePlanStorage result = plansCache.get(cacheName);
+ if (result == null) {
+ result = new AnalysePlanStorage(getCommunityDatabaseDirectory(),
+ getCommunityAnalysePlanDirectory(), name);
+ plansCache.put(cacheName, result);
+ }
+ return result;
+ }
/**
* Retourne une nouvelle instance du plan. Compile le fichier si besoin
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/FormuleStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -260,6 +260,28 @@
}
return result;
}
+
+ /**
+ * Retourne le storage pour la regle demandée
+ *
+ * @param name le nom de la regle souhaitée
+ * @param category la categorie de la regle
+ * @return Le storage pour la regle
+ */
+ static public FormuleStorage getCommunityFormule(String category, String name) {
+ String key = category + File.separator + name;
+ FormuleStorage result = formulesCache.get(key);
+ if (result == null) {
+ String extension = FileUtil.extension(new File(name), ".");
+ if (!"".equals(extension)) {
+ name = name.substring(0, name.length() - (extension.length() + 1));
+ }
+ result = new FormuleStorage(IsisFish.config.getCommunityDatabaseDirectory(),
+ getCommunityFormuleDirectory(), category, name, extension);
+ formulesCache.put(key, result);
+ }
+ return result;
+ }
/**
* creer une nouvelle formule, si la formule existait deja, elle est ecrasé
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/RuleStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -116,8 +116,9 @@
* @return all rule names found in local user database
*/
static public List<String> getRuleNames() {
- File dir = getRuleDirectory();
- return RuleStorage.getStorageNames(dir);
+ List<String> rules = getStorageNames(getRuleDirectory());
+ rules.addAll(getStorageNames(getCommunityRuleDirectory()));
+ return rules;
}
/**
@@ -137,6 +138,22 @@
return result;
}
+ /**
+ * Retourne le storage pour la regle demandée
+ *
+ * @param name le nom de la regle souhaitée
+ * @return Le storage pour la regle
+ */
+ static public RuleStorage getCommunityRule(String name) {
+ String cacheName = getContextDatabaseCacheKey(name);
+ RuleStorage result = rulesCache.get(cacheName);
+ if (result == null) {
+ result = new RuleStorage(getCommunityDatabaseDirectory(),
+ getCommunityRuleDirectory(), name);
+ rulesCache.put(cacheName, result);
+ }
+ return result;
+ }
/**
* Retourne une nouvelle instance de la regle. Compile le fichier si besoin
@@ -300,7 +317,6 @@
static public List<String> getRemoteRuleNames() {
File dir = getRuleDirectory();
return getRemoteStorageNames(dir);
-
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SensitivityExportStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -111,8 +111,8 @@
/**
* Retourne le storage pour l'export demandé.
*
- * @param name le nom de la regle souhaitée
- * @return Le storage pour la regle
+ * @param name le nom de la export souhaitée
+ * @return Le storage pour l'export
*/
public static SensitivityExportStorage getSensitivityExport(String name) {
String cacheName = getContextDatabaseCacheKey(name);
@@ -126,13 +126,31 @@
}
/**
+ * Retourne le storage pour l'export demandé.
+ *
+ * @param name le nom de l'export souhaitée
+ * @return Le storage pour l'export
+ */
+ public static SensitivityExportStorage getCommunitySensitivityExport(String name) {
+ String cacheName = getContextDatabaseCacheKey(name);
+ SensitivityExportStorage result = sensitivityExportsCache.get(cacheName);
+ if (result == null) {
+ result = new SensitivityExportStorage(getCommunityDatabaseDirectory(),
+ getCommunitySensitivityExportDirectory(), name);
+ sensitivityExportsCache.put(cacheName, result);
+ }
+ return result;
+ }
+
+ /**
* Retourne la liste des noms de toutes les régions disponible en local.
*
* @return la liste des noms de toutes les régions disponible en local
*/
public static List<String> getSensitivityExportNames() {
- File dir = getSensitivityExportDirectory();
- return getStorageNames(dir);
+ List<String> result = getStorageNames(getSensitivityExportDirectory());
+ result.addAll(getStorageNames(getCommunitySensitivityExportDirectory()));
+ return result;
}
public static void checkout() throws VCSException {
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/SimulatorStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -131,7 +131,7 @@
SimulatorStorage result = simulatorsCache.get(cacheName);
if (result == null) {
result = new SimulatorStorage(getCommunityDatabaseDirectory(),
- getSimulatorDirectory(), name);
+ getCommunitySimulatorDirectory(), name);
simulatorsCache.put(cacheName, result);
}
return result;
@@ -147,8 +147,8 @@
* @return la liste des noms de toutes les régions disponible en local
*/
static public List<String> getSimulatorNames() {
- File dir = getSimulatorDirectory();
- List<String> result = getStorageNames(dir);
+ List<String> result = getStorageNames(getSimulatorDirectory());
+ result.addAll(getStorageNames(getCommunitySimulatorDirectory()));
return result;
}
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/VersionStorage.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -40,8 +40,10 @@
import fr.ifremer.isisfish.IsisConfig;
import fr.ifremer.isisfish.IsisFish;
+import fr.ifremer.isisfish.IsisFishDAOHelper;
import fr.ifremer.isisfish.vcs.VCS;
import fr.ifremer.isisfish.vcs.VCSException;
+import fr.ifremer.isisfish.vcs.VCSNone;
/**
* Classe permettant de géré l'interaction avec le VCS.
@@ -105,7 +107,7 @@
*
* @return context cache key
*
- * TODO better place in other storage, but needed for region anad java scrits
+ * TODO better place in other storage, but needed for region and java scripts
*/
protected static String getContextDatabaseCacheKey(String key) {
String result = getContextDatabaseDirectory().getAbsolutePath() + key;
@@ -113,6 +115,38 @@
}
/**
+ * Get VCS instance for storage file.
+ *
+ * @return vcs instance
+ */
+ protected VCS getCurrentVCS() {
+ return getCurrentVCS(getFile());
+ }
+
+ /**
+ * Get VCS instance for given file.
+ *
+ * @param file file to get VCS
+ * @return
+ */
+ protected VCS getCurrentVCS(File file) {
+ VCS result;
+ String absolutePath = file.getAbsolutePath();
+ if (absolutePath.startsWith(IsisFish.config.getDatabaseDirectory() + File.separator)) {
+ result = IsisFish.vcs;
+ } else if (absolutePath.startsWith(IsisFish.config.getCommunityDatabaseDirectory() + File.separator)) {
+ result = IsisFish.communityVcs;
+ } else {
+ result = new VCSNone(file.getParentFile(), "", "", "", null, "", "");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("VCS for file " + getFile() + " is " + result);
+ }
+ return result;
+ }
+
+ /**
* Get {@link VCS}.
*
* @return VCS
@@ -263,7 +297,7 @@
if (log.isDebugEnabled()) {
log.debug("files to add: " + files);
}
- getVCS().add(files, msg);
+ getCurrentVCS().add(files, msg);
}
/**
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptAction.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -423,13 +423,18 @@
try {
switch (mapping) {
case Formule:
+ case CommunityFormule:
String fullPath = file.getAbsolutePath();
int lastIndexOf = fullPath.lastIndexOf('/');
// in string .../aaa/bbb/ccc/ddd.java
// get ccc
String category = fullPath.substring(fullPath.lastIndexOf('/',
lastIndexOf - 1) + 1, lastIndexOf);
- script = FormuleStorage.getFormule(category, file.getName());
+ if (mapping.equals(ScriptMapping.Formule)) {
+ script = FormuleStorage.getFormule(category, file.getName());
+ } else {
+ script = FormuleStorage.getCommunityFormule(category, file.getName());
+ }
break;
case Rule:
script = RuleStorage.getRule(file.getName());
@@ -452,13 +457,14 @@
case SensitivityExport:
script = SensitivityExportStorage.getSensitivityExport(file.getName());
break;
- case CommunityFormule:
- break;
case CommunityRule:
+ script = RuleStorage.getCommunityRule(file.getName());
break;
case CommunityAnalysePlan:
+ script = AnalysePlanStorage.getCommunityAnalysePlan(file.getName());
break;
case CommunityExport:
+ script = RuleStorage.getCommunityRule(file.getName());
break;
case CommunityScript:
script = ScriptStorage.getCommunityScript(file.getName());
Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java
===================================================================
--- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2011-06-16 12:30:48 UTC (rev 3410)
+++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/CompileHelper.java 2011-06-16 15:02:46 UTC (rev 3411)
@@ -28,7 +28,6 @@
import static org.nuiton.i18n.I18n._;
import java.io.File;
-import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Method;
import java.net.URL;
@@ -94,7 +93,8 @@
}
/**
- * Load la class demandé
+ * Load la class demandé.
+ *
* @param fqn le nom complet de la classe a charger
* @return la classe souhaité ou null si la class n'est pas trouvée
*/
1
0