r3437 - in isis-fish/trunk/src: main/java/fr/ifremer/isisfish/aspect main/java/fr/ifremer/isisfish/datastore main/java/fr/ifremer/isisfish/datastore/migration main/java/fr/ifremer/isisfish/entities main/java/fr/ifremer/isisfish/rule main/java/fr/ifremer/isisfish/simulator main/java/fr/ifremer/isisfish/simulator/launcher main/java/fr/ifremer/isisfish/types main/java/fr/ifremer/isisfish/types/hibernate main/java/fr/ifremer/isisfish/ui/result main/java/fr/ifremer/isisfish/ui/widget/editor m
Author: chatellier Date: 2011-07-08 11:26:05 +0000 (Fri, 08 Jul 2011) New Revision: 3437 Log: Refactoring : - Date > TimeStep Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/TimeStep.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/TimeStepConverter.java Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/DateType.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DateConverter.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/aspect/RuleAspect.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorage.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/AbstractRule.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/Rule.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationControl.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultGetter.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultListener.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultXML.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTableModel.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Date.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultMatrixFilter.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/YearSumDimensionAction.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterTableCellEditor.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ConverterUtil.java isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/StringConverter.java isis-fish/trunk/src/main/xmi/isis-fish.zargo isis-fish/trunk/src/test/java/fr/ifremer/isisfish/rule/RuleMock.java isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceIT.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/aspect/RuleAspect.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/aspect/RuleAspect.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/aspect/RuleAspect.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -36,12 +36,12 @@ import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.rule.Rule; import fr.ifremer.isisfish.simulator.SimulationContext; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Aspect utiliser pour intersepecter les appels a - * {@link Rule#init(SimulationContext)}, {@link Rule#preAction(SimulationContext, Date, Metier)}, - * {@link Rule#postAction(SimulationContext, Date, Metier)} et memoriser + * {@link Rule#init(SimulationContext)}, {@link Rule#preAction(SimulationContext, TimeStep, Metier)}, + * {@link Rule#postAction(SimulationContext, TimeStep, Metier)} et memoriser * le temps mit. * * @author chatellier @@ -79,7 +79,7 @@ } /** - * Aspect around {@link Rule#preAction(SimulationContext, Date, Metier)} in packages "rules". + * Aspect around {@link Rule#preAction(SimulationContext, TimeStep, Metier)} in packages "rules". * * @param jp join point * @return preAction result @@ -93,7 +93,7 @@ } /** - * Aspect around {@link Rule#postAction(SimulationContext, Date, Metier)} in packages "rules". + * Aspect around {@link Rule#postAction(SimulationContext, TimeStep, Metier)} in packages "rules". * * @param jp join point * @return preAction result Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorage.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorage.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultStorage.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -60,7 +60,7 @@ import fr.ifremer.isisfish.simulator.SimulationPlan; import fr.ifremer.isisfish.simulator.SimulationResultGetter; import fr.ifremer.isisfish.simulator.SimulationResultListener; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; /** @@ -75,13 +75,14 @@ * Mise a jour: $Date$ * par : $Author$ */ -public class ResultStorage implements SimulationResultListener, SimulationResultGetter{ // ResultStorage +public class ResultStorage implements SimulationResultListener, + SimulationResultGetter { // ResultStorage /** to use log facility, just put in your code: log.info(\"...\"); */ static private Log log = LogFactory.getLog(ResultStorage.class); protected SimulationStorage simulation = null; -// transient protected HashMap<String, MatrixND> globalMatrix = new HashMap<String, MatrixND>(); + // transient protected HashMap<String, MatrixND> globalMatrix = new HashMap<String, MatrixND>(); transient protected ReferenceMap cacheContext = new ReferenceMap(ReferenceMap.HARD, ReferenceMap.WEAK); /** cache to maintains some result. key: String(date + ':' + name), value: matrix @@ -103,10 +104,11 @@ this.simulation = simulation; } - protected void putInCache(Date date, String name, MatrixND mat, TopiaContext context) { - String key = date + ":" + name; + protected void putInCache(TimeStep step, String name, MatrixND mat, TopiaContext context) { + String key = step + ":" + name; putInCache(key, mat, context); } + protected void putInCache(String name, MatrixND mat, TopiaContext context) { if (mat != null) { cache.put(name, mat); @@ -114,18 +116,19 @@ } } - protected MatrixND getInCache(Date date, String name) { - String key = date + ":" + name; + protected MatrixND getInCache(TimeStep step, String name) { + String key = step + ":" + name; MatrixND result = getInCache(key); return result; } + protected MatrixND getInCache(String name) { MatrixND result = null; - TopiaContext context = (TopiaContext)cacheContext.get(name); + TopiaContext context = (TopiaContext) cacheContext.get(name); if (context != null && !context.isClosed()) { // on verifie que le context existe encore car on peut vouloir // naviguer dans les semantics - result = (MatrixND)cache.get(name); + result = (MatrixND) cache.get(name); } return result; } @@ -152,9 +155,8 @@ tx = simulation.getStorage().beginTransaction(); mustClose = true; } - @SuppressWarnings("unchecked") - List<String> result = (List<String>)tx.find( - "Select resultDate||':'||name from fr.ifremer.isisfish.entities.Result"); + + List<String> result = (List<String>) tx.find("Select resultDate||':'||name from fr.ifremer.isisfish.entities.Result"); if (mustClose) { tx.closeContext(); } @@ -164,19 +166,19 @@ log.warn("Can't get result available", eee); } } - } return availableResult; } /** - * Verifie si un resultat est disponible pour une date donnée - * @param date + * Verifie si un resultat est disponible pour une date donnée. + * + * @param step * @param name * @return {@code true} if result is available */ - protected boolean isAvailableResult(Date date, String name) { - String key = date.getDate() + ":" + name; + protected boolean isAvailableResult(TimeStep step, String name) { + String key = step.getStep() + ":" + name; boolean result = getAvailableResult().contains(key); return result; } @@ -184,11 +186,11 @@ /** * Ajoute un resultat comme etant disponible pour une date donnée. * - * @param date + * @param step * @param name */ - protected void addAvailableResult(Date date, String name) { - String key = date.getDate() + ":" + name; + protected void addAvailableResult(TimeStep step, String name) { + String key = step.getStep() + ":" + name; getAvailableResult().add(key); } @@ -207,12 +209,13 @@ * @param name result name * @return {@code true} if result is enabled */ - public boolean isEnabled(String name){ + public boolean isEnabled(String name) { name = name.trim(); if (enabledResult == null) { enabledResult = new HashSet<String>(); - Collection<String> resultEnabled = simulation.getParameter().getResultEnabled(); + Collection<String> resultEnabled = simulation.getParameter() + .getResultEnabled(); enabledResult.addAll(resultEnabled); // test on export @@ -227,14 +230,16 @@ } } catch (IsisFishException eee) { if (log.isWarnEnabled()) { - log.warn(_("isisfish.error.instanciate.export", exportName), eee); + log.warn(_("isisfish.error.instanciate.export", + exportName), eee); } } } } // test on sensitivity export - List<SensitivityExport> sensitivityExports = simulation.getParameter().getSensitivityExport(); + List<SensitivityExport> sensitivityExports = simulation + .getParameter().getSensitivityExport(); if (sensitivityExports != null) { for (SensitivityExport sensitivityExport : sensitivityExports) { for (String resultName : sensitivityExport.getNecessaryResult()) { @@ -268,43 +273,43 @@ return result; } - public void addResult(Date date, MatrixND mat) throws IsisFishException{ - addResult(false, date, mat.getName(), mat); + public void addResult(TimeStep step, MatrixND mat) throws IsisFishException { + addResult(false, step, mat.getName(), mat); } - public void addResult(Date date, Population pop, MatrixND mat) throws IsisFishException{ - addResult(false, date, mat.getName(), pop, mat); + public void addResult(TimeStep step, Population pop, MatrixND mat) throws IsisFishException { + addResult(false, step, mat.getName(), pop, mat); } - public void addResult(boolean force, Date date, MatrixND mat) throws IsisFishException{ - addResult(force, date, mat.getName(), mat); + public void addResult(boolean force, TimeStep step, MatrixND mat) throws IsisFishException { + addResult(force, step, mat.getName(), mat); } - public void addResult(boolean force, Date date, Population pop, MatrixND mat) throws IsisFishException{ - addResult(force, date, mat.getName(), pop, mat); + public void addResult(boolean force, TimeStep step, Population pop, MatrixND mat) throws IsisFishException { + addResult(force, step, mat.getName(), pop, mat); } - public void addResult(Date date, String name, Population pop, MatrixND mat) throws IsisFishException{ - addResult(false, date, name, pop, mat); + public void addResult(TimeStep step, String name, Population pop, MatrixND mat) throws IsisFishException { + addResult(false, step, name, pop, mat); } - public void addResult(Date date, String name, MatrixND mat) throws IsisFishException{ - addResult(false, date, name, mat); + public void addResult(TimeStep step, String name, MatrixND mat) throws IsisFishException { + addResult(false, step, name, mat); } - public void addResult(boolean force, Date date, String name, Population pop, MatrixND mat) throws IsisFishException{ + public void addResult(boolean force, TimeStep step, String name, Population pop, MatrixND mat) throws IsisFishException { if (force || isEnabled(name)) { - doAddResult(date, name + " " + pop, mat); + doAddResult(step, name + " " + pop, mat); } } - public void addResult(boolean force, Date date, String name, MatrixND mat) throws IsisFishException{ + public void addResult(boolean force, TimeStep step, String name, MatrixND mat) throws IsisFishException { if (force || isEnabled(name)) { - doAddResult(date, name, mat); + doAddResult(step, name, mat); } } - protected void doAddResult(Date date, String name, MatrixND mat) throws IsisFishException{ + protected void doAddResult(TimeStep step, String name, MatrixND mat) throws IsisFishException { try { TopiaContext tx = null; boolean mustClose = false; @@ -317,22 +322,25 @@ tx = simulation.getStorage().beginTransaction(); mustClose = true; } - doAddResult(date, name, mat, tx); + doAddResult(step, name, mat, tx); if (mustClose) { tx.commitTransaction(); tx.closeContext(); } } catch (TopiaException eee) { - log.warn("Can't add result '" + name + "' at date " + date , eee); + log.warn("Can't add result '" + name + "' at step " + step, eee); } } - protected void doAddResult(Date date, String name, MatrixND mat, TopiaContext tx) throws IsisFishException{ + protected void doAddResult(TimeStep step, String name, MatrixND mat, + TopiaContext tx) throws IsisFishException { // si la matrice n'a pas de semantique on refuse - for (int i=0; i<mat.getDimCount(); i++) { + for (int i = 0; i < mat.getDimCount(); i++) { // la semantique n'est pas bonne des qu'il y a un null dedans if (mat.getSemantic(i).contains(null)) { - throw new SimulationException("Erreur le résultat que vous souhaitez enregistrer n'a pas d'information convenable pour la dimension: " + i + " " + mat.getDimensionName(i) ); + throw new SimulationException( + "Erreur le résultat que vous souhaitez enregistrer n'a pas d'information convenable pour la dimension: " + + i + " " + mat.getDimensionName(i)); } } @@ -341,19 +349,19 @@ try { ResultDAO resultPS = IsisFishDAOHelper.getResultDAO(tx); Result result = resultPS.create(); - result.setResultDate(date); + result.setResultStep(step); result.setName(name); result.setMatrix(newMat); resultPS.update(result); - addAvailableResult(date, name); - putInCache(date, name, newMat, tx); + addAvailableResult(step, name); + putInCache(step, name, newMat, tx); } catch (TopiaException eee) { - log.warn("Can't add result '" + name + "' at date " + date , eee); + log.warn("Can't add result '" + name + "' at step " + step, eee); } } - public void addActiveRule(Date date, Rule rule) throws IsisFishException { + public void addActiveRule(TimeStep step, Rule rule) throws IsisFishException { try { TopiaContext tx = null; boolean mustClose = false; @@ -368,7 +376,7 @@ } ActiveRuleDAO ps = IsisFishDAOHelper.getActiveRuleDAO(tx); ActiveRule result = ps.create(); - result.setActiveRuleDate(date); + result.setActiveRuleStep(step); result.setName(RuleStorage.getName(rule)); result.setParam(RuleStorage.getParamAsString(rule)); ps.update(result); @@ -403,9 +411,8 @@ } ResultDAO resultPS = IsisFishDAOHelper.getResultDAO(tx); - - result = (List<String>)resultPS.getContext().find( - "Select distinct name from fr.ifremer.isisfish.entities.Result order by name"); + result = (List<String>) resultPS.getContext() + .find("Select distinct name from fr.ifremer.isisfish.entities.Result order by name"); if (mustClose) { tx.closeContext(); } @@ -422,20 +429,20 @@ /** * Retourne la matrice stocke pour un pas de temps - * @param date le pas de temps que l'on souhaite + * @param step le pas de temps que l'on souhaite * @param pop la population pour lequelle on souhaite le resultat * @param name le nom des resultats dont on veut la matrice * @return La matrice demandée ou null si aucune matrice ne correspond a * la demande. */ - public MatrixND getMatrix(Date date, Population pop, String name) { + public MatrixND getMatrix(TimeStep step, Population pop, String name) { String newName = name + " " + pop; - return getMatrix(date, newName); + return getMatrix(step, newName); } - public MatrixND getMatrix(Date date, String name) { - MatrixND mat = getInCache(date, name); - if (mat == null && isAvailableResult(date, name)) { + public MatrixND getMatrix(TimeStep step, String name) { + MatrixND mat = getInCache(step, name); + if (mat == null && isAvailableResult(step, name)) { try { TopiaContext tx = null; boolean mustClose = false; @@ -448,7 +455,7 @@ tx = simulation.getStorage().beginTransaction(); mustClose = true; } - mat = getMatrix(date, name, tx); + mat = getMatrix(step, name, tx); if (mustClose) { // FIXME transaction never closed // quand peut on fermer la transaction ? @@ -459,7 +466,8 @@ } } catch (Exception eee) { if (log.isWarnEnabled()) { - log.warn("Can't return matrix '" + name + "' for date " + date, eee); + log.warn("Can't return matrix '" + name + "' for step " + + step, eee); } } } @@ -469,25 +477,28 @@ /** * Retourne la matrice stocke pour un pas de temps. * - * @param date le pas de temps que l'on souhaite + * @param step le pas de temps que l'on souhaite * @param name le nom des resultats dont on veut la matrice * @param tx TopiaContext a utiliser pour recuperer les resultats et donc les semantiques * @return La matrice demandée ou {@code null} si aucune matrice ne correspond a * la demande. */ - public MatrixND getMatrix(Date date, String name, TopiaContext tx) { - MatrixND mat = getInCache(date, name); - if (mat == null && isAvailableResult(date, name)) { + public MatrixND getMatrix(TimeStep step, String name, TopiaContext tx) { + MatrixND mat = getInCache(step, name); + if (mat == null && isAvailableResult(step, name)) { try { ResultDAO resultPS = IsisFishDAOHelper.getResultDAO(tx); - Result result = resultPS.findByProperties("resultDate", date, "name", name); + Result result = resultPS.findByProperties( + Result.PROPERTY_RESULT_STEP, step, + Result.PROPERTY_NAME, name); if (result != null) { mat = result.getMatrix(); - putInCache(date, name, mat, tx); + putInCache(step, name, mat, tx); } } catch (Exception eee) { if (log.isWarnEnabled()) { - log.warn("Can't return matrix '" + name + "' for date " + date, eee); + log.warn("Can't return matrix '" + name + "' for step " + + step, eee); } } } @@ -548,7 +559,7 @@ log.debug("Get result: " + name); MatrixND resultMat = getInCache(name); - if(resultMat != null){ + if (resultMat != null) { return resultMat; } @@ -571,71 +582,70 @@ // Creation des listes pour chaque dimension // creation de la liste de date - Date lastDate = getLastDate(); - List<Date> dates = new ArrayList<Date>(); - Date date = new Date(0); - dates.add(date); - while (date.before(lastDate)) { - date = date.next(); - dates.add(date); + TimeStep lastStep = getLastStep(); + List<TimeStep> steps = new ArrayList<TimeStep>(); + TimeStep step = new TimeStep(0); + steps.add(step); + while (step.before(lastStep)) { + step = step.next(); + steps.add(step); } if (log.isTraceEnabled()) { - log.trace("List des dates: "+ dates); + log.trace("Steps list : " + steps); } // recuperation des dimensions des matrices - MatrixND mat = (MatrixND)results.get(0).getMatrix(); + MatrixND mat = (MatrixND) results.get(0).getMatrix(); // recuperation des noms des dimensions - String [] dimNames = new String[1 + mat.getDimCount()]; + String[] dimNames = new String[1 + mat.getDimCount()]; dimNames[0] = _("isisfish.common.date"); - for (int i=1; i<dimNames.length; i++) { - dimNames[i] = mat.getDimensionName(i-1); + for (int i = 1; i < dimNames.length; i++) { + dimNames[i] = mat.getDimensionName(i - 1); } - // creation de la semantique pour la matrice resultat. +1 pour les dates List[] sem = new List[1 + mat.getDimCount()]; - sem[0] = dates; + sem[0] = steps; - for (int i=1; i<sem.length; i++) { + for (int i = 1; i < sem.length; i++) { sem[i] = new HashList(); } - for (Result result: results) { + for (Result result : results) { MatrixND mattmp = result.getMatrix(); if (log.isTraceEnabled()) { - log.trace("Ajout de la semantics: "+ Arrays.asList(mattmp.getSemantics())); + log.trace("Ajout de la semantics: " + + Arrays.asList(mattmp.getSemantics())); } - for (int s=0; s<mattmp.getDimCount(); s++) { - sem[s+1].addAll(mattmp.getSemantic(s)); + for (int s = 0; s < mattmp.getDimCount(); s++) { + sem[s + 1].addAll(mattmp.getSemantic(s)); } } if (log.isTraceEnabled()) { - log.trace("La semantique final est: "+ Arrays.asList(sem)); + log.trace("La semantique final est: " + Arrays.asList(sem)); } // creation de la matrice resultat resultMat = MatrixFactory.getInstance().create(name, sem, dimNames); // recuperation du resultat pour chaque date de la simulation, de Date(0) à lastDate - for(Result result: results){ - Date d = result.getResultDate(); + for (Result result : results) { + TimeStep d = result.getResultStep(); mat = result.getMatrix(); // on met ce resultat dans la matrice result si besoin - if(mat != null){ + if (mat != null) { // on recupere dans la matrice resultat l'endroit on il faut // mettre la matrice MatrixND submat = resultMat.getSubMatrix(0, d, 1); // on met les valeur de mat dans la sous matrice extraite - for(MatrixIterator mi=mat.iterator(); mi.next();){ + for (MatrixIterator mi = mat.iterator(); mi.next();) { submat.setValue( - ArrayUtil.concat(new Object[]{d}, - mi.getSemanticsCoordinates()), - mi.getValue()); + ArrayUtil.concat(new Object[] { d }, + mi.getSemanticsCoordinates()), mi.getValue()); } } } @@ -649,38 +659,40 @@ * * @return last simulation date */ - public Date getLastDate() { - int monthNumber = simulation.getParameter().getNumberOfYear() * Month.NUMBER_OF_MONTH; - Date result = new Date(monthNumber - 1); // -1 because date begin at 0 + public TimeStep getLastStep() { + int monthNumber = simulation.getParameter().getNumberOfYear() + * Month.NUMBER_OF_MONTH; + TimeStep result = new TimeStep(monthNumber - 1); // -1 because date begin at 0 return result; } /* - * @see fr.ifremer.isisfish.simulator.SimulationResultListener#addResult(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, java.lang.String, org.nuiton.math.matrix.MatrixND) + * @see fr.ifremer.isisfish.simulator.SimulationResultListener#addResult(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, java.lang.String, org.nuiton.math.matrix.MatrixND) */ @Override - public void addResult(SimulationContext context, Date date, String name, MatrixND mat) throws IsisFishException { + public void addResult(SimulationContext context, TimeStep step, String name, + MatrixND mat) throws IsisFishException { try { - doAddResult(date, name, mat, context.getDbResult()); + doAddResult(step, name, mat, context.getDbResult()); } catch (TopiaException eee) { - log.warn(_("Can't add result '%1$s' at date %2$s", name, date) , eee); + log.warn(_("Can't add result '%1$s' at date %2$s", name, step), eee); } - } + } /* - * @see fr.ifremer.isisfish.simulator.SimulationResultGetter#getMatrix(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, java.lang.String) + * @see fr.ifremer.isisfish.simulator.SimulationResultGetter#getMatrix(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, java.lang.String) */ @Override - public MatrixND getMatrix(SimulationContext context, Date date, String name) { + public MatrixND getMatrix(SimulationContext context, TimeStep step, String name) { MatrixND result = null; try { - result = getMatrix(date, name, context.getDbResult()); + result = getMatrix(step, name, context.getDbResult()); } catch (TopiaException eee) { if (log.isWarnEnabled()) { log.warn(_("Can't get result: %1$s", name), eee); } } - return result; + return result; } /* @@ -696,7 +708,7 @@ log.warn(_("Can't get result: %1$s", name), eee); } } - return result; + return result; } /* Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/datastore/migration/MigrationV33V40.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -65,5 +65,8 @@ queries.add("alter table POPULATION drop column MATURITYGROUP;"); queries.add("alter table POPULATION add column MATURITYOGIVEEQUATION VARCHAR(255);"); queries.add("alter table POPULATION add column REPRODUCTIONRATEEQUATION VARCHAR(255);"); + + queries.add("alter table Result ALTER COLUMN resultdate RENAME TO resultstep;"); + queries.add("alter table ActiveRule ALTER COLUMN activeruledate RENAME TO activerulestep;"); } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/entities/SetOfVesselsImpl.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -84,20 +84,19 @@ /** * Evaluate {@link SetOfVesselsAbstract#technicalEfficiencyEquation} with - * {@link Date} and {@link Metier}. + * {@link Gear} and {@link Metier}. * * By default return {@code 1} if equation can't be evaluated. */ @Override - public double getTechnicalEfficiency(Date date, Metier metier) { + public double getTechnicalEfficiency(Metier metier) { double result = 1; try { Equation eq = getTechnicalEfficiencyEquation(); if (eq != null) { Gear gear = metier.getGear(); - result = eq.evaluate("date", date, "metier", metier, "gear", - gear); + result = eq.evaluate("metier", metier, "gear", gear); } } catch (Exception eee) { if (log.isWarnEnabled()) { Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/AbstractRule.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/AbstractRule.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/AbstractRule.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -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 Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/Rule.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/Rule.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/rule/Rule.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -27,7 +27,7 @@ import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.simulator.SimulationContext; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Interface d'une regle. setValue et getValue permet de stocker des @@ -40,7 +40,7 @@ * <li> un nombre (int, long, float, double, ...) * <li> un boolean * <li> une chaine String - * <li> un objet Date ({@link fr.ifremer.isisfish.types.Date}) + * <li> un objet Date ({@link fr.ifremer.isisfish.types.TimeStep}) * <li> un objet Month ({@link fr.ifremer.isisfish.types.Month}) * <li> Le type d'une entité (@see fr.ifremer.isisfish.entities) * @@ -85,16 +85,16 @@ * La condition qui doit etre vrai pour faire les actions. * * Si la confition return vrai alors les methodes - * {@link #preAction(SimulationContext, Date, Metier)} et - * {@link #postAction(SimulationContext, Date, Metier)} seront appelée. + * {@link #preAction(SimulationContext, TimeStep, Metier)} et + * {@link #postAction(SimulationContext, TimeStep, Metier)} seront appelée. * * @param context la simulation pour lequel on utilise cette regle - * @param date la date courante + * @param step le pas de temps courant * @param metier le metier * @return vrai si on souhaite que les actions soit faites * @throws Exception s'il y a une erreur, met fin a la simulation */ - public boolean condition(SimulationContext context, Date date, Metier metier) + public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception; /** @@ -102,11 +102,11 @@ * de temps de la simulation. * * @param context la simulation pour lequel on utilise cette regle - * @param date la date courant + * @param step le pas de temps courant * @param metier le metier * @throws Exception s'il y a une erreur, met fin a la simulation */ - public void preAction(SimulationContext context, Date date, Metier metier) + public void preAction(SimulationContext context, TimeStep step, Metier metier) throws Exception; /** @@ -114,11 +114,11 @@ * de temps de la simulation. * * @param context la simulation pour lequel on utilise cette regle - * @param date la date courante + * @param step le pas de temps courant * @param metier le metier * @throws Exception s'il y a une erreur, met fin a la simulation */ - public void postAction(SimulationContext context, Date date, Metier metier) + public void postAction(SimulationContext context, TimeStep step, Metier metier) throws Exception; /** Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/MetierMonitor.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -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 @@ -50,7 +50,7 @@ import fr.ifremer.isisfish.entities.SetOfVessels; import fr.ifremer.isisfish.entities.Strategy; import fr.ifremer.isisfish.entities.StrategyMonthInfo; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; /** @@ -74,7 +74,7 @@ protected Set<Metier> forbiddenMetier = new HashSet<Metier>(); protected Set<MultiKey> forbiddenMetierMonth = new HashSet<MultiKey>(); - protected Map<Date, MatrixND> noActivity = new HashMap<Date, MatrixND>(); + protected Map<TimeStep, MatrixND> noActivity = new HashMap<TimeStep, MatrixND>(); /** * clear all data @@ -140,12 +140,12 @@ /** * @return Returns the nonActivity. */ - public MatrixND getNoActivity(Date date) { - return this.noActivity.get(date); + public MatrixND getNoActivity(TimeStep step) { + return this.noActivity.get(step); } - public MatrixND getOrCreateNoActivity(Date date, String name, List<Strategy> strategies, List<Metier> metiers) { - MatrixND result = getNoActivity(date); + public MatrixND getOrCreateNoActivity(TimeStep step, String name, List<Strategy> strategies, List<Metier> metiers) { + MatrixND result = getNoActivity(step); if (result == null){ if (strategies.size() == 0) { strategies = new ArrayList<Strategy>(); @@ -161,7 +161,7 @@ name, new List[] {strategies, metiers}, new String[] {n_("isisfish.metierMonitor.strategies"), n_("isisfish.metierMonitor.metiers")}); - setNoActivity(date, result); + setNoActivity(step, result); } return result; } @@ -169,8 +169,8 @@ /** * @param nonActivity The nonActivity to set. */ - public void setNoActivity(Date date, MatrixND nonActivity) { - this.noActivity.put(date, nonActivity); + public void setNoActivity(TimeStep step, MatrixND nonActivity) { + this.noActivity.put(step, nonActivity); } ////////////////////////////////////////////////////////////////////////// Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/PopulationMonitor.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -41,7 +41,7 @@ import fr.ifremer.isisfish.entities.PopulationSeasonInfo; import fr.ifremer.isisfish.entities.Species; import fr.ifremer.isisfish.entities.Zone; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; import java.util.Collections; @@ -71,9 +71,9 @@ /** current number of fish by Pop */ protected Map<Population, MatrixND> Ns = new HashMap<Population, MatrixND>(); /** reproduction key: <date, pop> value:<MatrixND> */ - protected Map<Population, Map<Date, MatrixND>> reproductions = new HashMap<Population, Map<Date, MatrixND>>(); + protected Map<Population, Map<TimeStep, MatrixND>> reproductions = new HashMap<Population, Map<TimeStep, MatrixND>>(); /** discard key: <date, pop> value:<MatrixND> */ - protected Map<Population, Map<Date, MatrixND>> discards = new HashMap<Population, Map<Date, MatrixND>>(); + protected Map<Population, Map<TimeStep, MatrixND>> discards = new HashMap<Population, Map<TimeStep, MatrixND>>(); /** catch per population, only last catch is remaining */ protected Map<Population, MatrixND> catchs = new HashMap<Population, MatrixND>(); /** catch per population, only last catch is remaining */ @@ -96,8 +96,8 @@ this.pops = Collections .unmodifiableList(new ArrayList<Population>(pops)); for (Population pop : this.pops) { - reproductions.put(pop, new HashMap<Date, MatrixND>()); - discards.put(pop, new HashMap<Date, MatrixND>()); + reproductions.put(pop, new HashMap<TimeStep, MatrixND>()); + discards.put(pop, new HashMap<TimeStep, MatrixND>()); } } @@ -173,23 +173,23 @@ /** * Return reproduction. * - * @param date date + * @param step step * @param pop population * @return the reproduction */ - public MatrixND getReproduction(Date date, Population pop) { - return this.reproductions.get(pop).get(date); + public MatrixND getReproduction(TimeStep step, Population pop) { + return this.reproductions.get(pop).get(step); } /** * Set new reproduction. * - * @param date date + * @param step step * @param pop population * @param repro reproduction to set */ - public void setReproduction(Date date, Population pop, MatrixND repro) { - reproductions.get(pop).put(date, repro); + public void setReproduction(TimeStep step, Population pop, MatrixND repro) { + reproductions.get(pop).put(step, repro); } /** @@ -226,11 +226,11 @@ * Une autre facon de faire est de supprimer les repro == 0 car normalement * toute la repro doit etre utilisé au bout d'un certain temps * - * @param date + * @param step * @param pop * @return population recruitment */ - public MatrixND getRecruitment(Date date, Population pop) { + public MatrixND getRecruitment(TimeStep step, Population pop) { MatrixND matEtalement = pop.getRecruitmentDistribution(); int etalement = matEtalement.getDim(0); @@ -242,9 +242,9 @@ // pour chaque for (int e = 0; e < etalement; e++) { // recuperation de la reproduction stucture en zone repro - Date d = new Date(date.getDate() - e + TimeStep t = new TimeStep(step.getStep() - e - pop.getMonthGapBetweenReproRecrutement()); - MatrixND repro = (MatrixND) reproductions.get(pop).get(d); + MatrixND repro = (MatrixND) reproductions.get(pop).get(t); if (repro != null) { // si une repro existe pour le mois @@ -290,20 +290,20 @@ MatrixND N = pop.N2DToN1D(result); // on applique les migrations et le changement d'age sur le resultat // on suppose que la reproduction est toujours dans une seul saison - Date dateRepro = new Date(date.getDate() + TimeStep stepRepro = new TimeStep(step.getStep() - pop.getMonthGapBetweenReproRecrutement()); // recherche les saisons des differents mois entre les deux dates List<PopulationSeasonInfo> infos = pop.getPopulationSeasonInfo(); List<PopulationSeasonInfo> usedSeasons = new ArrayList<PopulationSeasonInfo>(); - while (date.after(dateRepro)) { - dateRepro = dateRepro.next(); - Month month = dateRepro.getMonth(); + while (step.after(stepRepro)) { + stepRepro = stepRepro.next(); + Month month = stepRepro.getMonth(); for (PopulationSeasonInfo info : infos) { if (month.equals(info.getFirstMonth())) { usedSeasons.add(info); - dateRepro = new Date(dateRepro.getDate() + stepRepro = new TimeStep(stepRepro.getStep() + info.getMonths().size() - 1); // -1 because, for have next() break; } @@ -390,12 +390,12 @@ /** * Get discard. * - * @param date date to get discard + * @param step step to get discard * @param pop population to get discard * @return le discard */ - public MatrixND getDiscard(Date date, Population pop) { - MatrixND result = discards.get(pop).get(date); + public MatrixND getDiscard(TimeStep step, Population pop) { + MatrixND result = discards.get(pop).get(step); return result; } @@ -404,17 +404,17 @@ * * Force discard at date for population. * - * @param date date to set discard + * @param step step to set discard * @param pop population to set discard * @param discard le discard */ - public void setDiscard(Date date, Population pop, MatrixND discard) { - Map<Date, MatrixND> oneDiscard = discards.get(pop); + public void setDiscard(TimeStep step, Population pop, MatrixND discard) { + Map<TimeStep, MatrixND> oneDiscard = discards.get(pop); synchronized (oneDiscard) { // meme si discards.get(pop) != null // replace toujours le précédent MatrixND tmp = discard.copy(); - discards.get(pop).put(date, tmp); + discards.get(pop).put(step, tmp); } } @@ -422,17 +422,17 @@ * FIXME: discards n'est jamais vider, on le conserve pour toutes les annees * il serait bon de faire un peu le menage de temps en temps. * - * @param date + * @param step * @param pop * @param discard */ - public void addDiscard(Date date, Population pop, MatrixND discard) { - Map<Date, MatrixND> oneDiscard = discards.get(pop); + public void addDiscard(TimeStep step, Population pop, MatrixND discard) { + Map<TimeStep, MatrixND> oneDiscard = discards.get(pop); synchronized (oneDiscard) { - MatrixND tmp = oneDiscard.get(date); + MatrixND tmp = oneDiscard.get(step); if (tmp == null) { tmp = discard.copy(); - discards.get(pop).put(date, tmp); + discards.get(pop).put(step, tmp); } else { tmp.add(discard); } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/ResultManager.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -42,7 +42,7 @@ import fr.ifremer.isisfish.entities.Population; import fr.ifremer.isisfish.export.Export; import fr.ifremer.isisfish.rule.Rule; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Used to store and retrieve result during simulation. This class manage @@ -155,48 +155,48 @@ boolean result = enabledResult.contains(name); return result; } - public void addActiveRule(Date date, Rule rule) throws IsisFishException { + public void addActiveRule(TimeStep step, Rule rule) throws IsisFishException { log.warn("addActiveRule not implemented"); // FIXME: addActiveRule not implemented } - public void addResult(Date date, MatrixND mat) throws IsisFishException{ - addResult(false, date, mat.getName(), mat); + public void addResult(TimeStep step, MatrixND mat) throws IsisFishException{ + addResult(false, step, mat.getName(), mat); } - public void addResult(Date date, Population pop, MatrixND mat) throws IsisFishException{ - addResult(false, date, mat.getName(), pop, mat); + public void addResult(TimeStep step, Population pop, MatrixND mat) throws IsisFishException{ + addResult(false, step, mat.getName(), pop, mat); } - public void addResult(boolean force, Date date, MatrixND mat) throws IsisFishException{ - addResult(force, date, mat.getName(), mat); + public void addResult(boolean force, TimeStep step, MatrixND mat) throws IsisFishException{ + addResult(force, step, mat.getName(), mat); } - public void addResult(boolean force, Date date, Population pop, MatrixND mat) throws IsisFishException{ - addResult(force, date, mat.getName(), pop, mat); + public void addResult(boolean force, TimeStep step, Population pop, MatrixND mat) throws IsisFishException{ + addResult(force, step, mat.getName(), pop, mat); } - public void addResult(Date date, String name, Population pop, MatrixND mat) throws IsisFishException{ - addResult(false, date, name, pop, mat); + public void addResult(TimeStep step, String name, Population pop, MatrixND mat) throws IsisFishException{ + addResult(false, step, name, pop, mat); } - public void addResult(Date date, String name, MatrixND mat) throws IsisFishException{ - addResult(false, date, name, mat); + public void addResult(TimeStep step, String name, MatrixND mat) throws IsisFishException{ + addResult(false, step, name, mat); } - public void addResult(boolean force, Date date, String name, Population pop, MatrixND mat) throws IsisFishException{ + public void addResult(boolean force, TimeStep step, String name, Population pop, MatrixND mat) throws IsisFishException{ // don't call generic addResult, because pop name is added if (force || isEnabled(name)) { for (SimulationResultListener l : listeners) { - l.addResult(context, date, name + " " + pop, mat); + l.addResult(context, step, name + " " + pop, mat); } } } - public void addResult(boolean force, Date date, String name, MatrixND mat) throws IsisFishException{ + public void addResult(boolean force, TimeStep step, String name, MatrixND mat) throws IsisFishException{ if (force || isEnabled(name)) { for (SimulationResultListener l : listeners) { - l.addResult(context, date, name, mat); + l.addResult(context, step, name, mat); } } } @@ -209,15 +209,15 @@ * @return La matrice demandée ou null si aucune matrice ne correspond a * la demande. */ - public MatrixND getMatrix(Date date, Population pop, String name){ + public MatrixND getMatrix(TimeStep step, Population pop, String name){ name += " " + pop; - return getMatrix(date, name); + return getMatrix(step, name); } - public MatrixND getMatrix(Date date, String name){ + public MatrixND getMatrix(TimeStep step, String name){ MatrixND result = null; if (getter != null) { - result = getter.getMatrix(context, date, name); + result = getter.getMatrix(context, step, name); } return result; } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/RuleMonitor.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -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,7 +29,7 @@ import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.rule.Rule; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * This class keep trace of rule evalution condition for all step and all metier. @@ -46,13 +46,13 @@ protected MultiKeyMap evalutionCondition = new MultiKeyMap(); - public boolean getEvalutionCondition(Date date, Rule rule, Metier metier) { - return (Boolean) this.evalutionCondition.get(date, rule, metier); + public boolean getEvalutionCondition(TimeStep step, Rule rule, Metier metier) { + return (Boolean) this.evalutionCondition.get(step, rule, metier); } - public void setEvaluationCondition(Date date, Rule rule, Metier metier, + public void setEvaluationCondition(TimeStep step, Rule rule, Metier metier, boolean evalutionCondition) { - this.evalutionCondition.put(date, rule, metier, evalutionCondition); + this.evalutionCondition.put(step, rule, metier, evalutionCondition); } } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationControl.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationControl.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationControl.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -34,7 +34,7 @@ import org.apache.commons.logging.LogFactory; import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Permit to communicate with user interface from simulation thread. @@ -60,7 +60,7 @@ protected boolean started = false; protected boolean running = true; protected boolean stop = false; - protected Date date; + protected TimeStep step; protected long progressMax = 0; protected long progress = 0; protected String text = ""; @@ -105,7 +105,7 @@ started = false; running = true; stop = false; - date = null; + step = null; progressMax = 0; progress = 0; } @@ -281,22 +281,22 @@ * * @return donne la date utiliser par la simulation */ - public Date getDate() { - return date; + public TimeStep getTimeStep() { + return step; } /** * Modifie la date de la simulation. * - * @param d la nouvelle date + * @param t la nouvelle etape */ - public void setDate(Date d) { + public void setTimeStep(TimeStep t) { int oldValue = 0; - if (this.date != null) { - oldValue = this.date.getDate(); + if (this.step != null) { + oldValue = this.step.getStep(); } - this.date = d; - listeners.firePropertyChange("date", oldValue, this.date.getDate()); + this.step = t; + listeners.firePropertyChange("date", oldValue, this.step.getStep()); } /** @@ -309,8 +309,8 @@ result.setProperty("started", String.valueOf(started)); result.setProperty("running", String.valueOf(running)); result.setProperty("stop", String.valueOf(stop)); - if (date != null) { - result.setProperty("date", String.valueOf(date.getDate())); + if (step != null) { + result.setProperty("date", String.valueOf(step.getStep())); } result.setProperty("progressMax", String.valueOf(progressMax)); result.setProperty("progress", String.valueOf(progress)); @@ -350,10 +350,10 @@ .getProperty("stop")); setStopSimulationRequest(stop); } - if (props.containsKey("date")) { - Date date = new Date(Integer - .parseInt(props.getProperty("date"))); - setDate(date); + if (props.containsKey("step")) { + TimeStep step = new TimeStep(Integer + .parseInt(props.getProperty("step"))); + setTimeStep(step); } if (props.containsKey("progressMax")) { long progressMax = Long.parseLong(props Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultGetter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultGetter.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultGetter.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2007 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * Copyright (C) 2007 - 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 @@ -27,9 +27,8 @@ import org.nuiton.math.matrix.MatrixND; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; - /** * Some SimulationResultListener can implement this interface to show that can * be used to retrieve result @@ -39,16 +38,18 @@ public interface SimulationResultGetter { /** - * Retourne la matrice stocke pour un pas de temps - * @param date le pas de temps que l'on souhaite + * Retourne la matrice stocke pour un pas de temps. + * + * @param step le pas de temps que l'on souhaite * @param name le nom des resultats dont on veut la matrice * @return La matrice demandée ou null si aucune matrice ne correspond a * la demande. */ - public MatrixND getMatrix(SimulationContext context, Date date, String name); + public MatrixND getMatrix(SimulationContext context, TimeStep step, String name); /** * Retourne une matrice contenant tous les pas de temps. + * * @param name le nom des resultats dont on veut une matrice globale. */ public MatrixND getMatrix(SimulationContext context, String name); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultListener.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultListener.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultListener.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2007 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * Copyright (C) 2007 - 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 @@ -28,7 +28,7 @@ import org.nuiton.math.matrix.MatrixND; import fr.ifremer.isisfish.IsisFishException; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * SimulationResultListener.java @@ -42,10 +42,10 @@ * by : $Author$ */ public interface SimulationResultListener extends SimulationListener { - + public void addResult(SimulationContext context, - Date date, String name, MatrixND mat) throws IsisFishException; - + TimeStep step, String name, MatrixND mat) throws IsisFishException; + } Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultXML.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultXML.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/SimulationResultXML.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2007 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * Copyright (C) 2007 - 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 @@ -39,7 +39,7 @@ import fr.ifremer.isisfish.IsisFishException; import fr.ifremer.isisfish.datastore.SimulationStorage; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** @@ -139,15 +139,15 @@ } /* (non-Javadoc) - * @see fr.ifremer.isisfish.simulator.SimulationResultListener#addResult(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, java.lang.String, org.nuiton.math.matrix.MatrixND) + * @see fr.ifremer.isisfish.simulator.SimulationResultListener#addResult(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, java.lang.String, org.nuiton.math.matrix.MatrixND) */ - public void addResult(SimulationContext context, Date date, String name, + public void addResult(SimulationContext context, TimeStep step, String name, MatrixND mat) throws IsisFishException { try { - out.write(" <m name='" + name + "' date='" + date + "'>\n"); - for (int dim=0; dim<mat.getNbDim(); dim++) { + out.write(" <m name='" + name + "' step='" + step + "'>\n"); + for (int dim=0; dim<mat.getDimCount(); dim++) { out.write(" <dimension name='" + mat.getDimensionName(dim) + "' size='" + mat.getDim(dim) + "'>"); - for (Object sem : mat.getSemantics(dim)) { + for (Object sem : mat.getSemantic(dim)) { out.write(" <label>" + sem + "</label>"); } out.write(" </dimension>"); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/InProcessSimulatorLauncher.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -66,7 +66,7 @@ import fr.ifremer.isisfish.simulator.SimulationParameter; import fr.ifremer.isisfish.simulator.SimulationPreScript; import fr.ifremer.isisfish.simulator.Simulator; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; /** @@ -129,7 +129,7 @@ // WARNING: make sure to not open Region before being in simulation context // add missing control informations SimulationParameter param = simulation.getParameter(); - control.setDate(new Date()); + control.setTimeStep(new TimeStep()); control.setProgress(0); control.setStarted(true); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTableModel.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTableModel.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceTableModel.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -42,7 +42,7 @@ import fr.ifremer.isisfish.simulator.SimulationControl; import fr.ifremer.isisfish.simulator.SimulationParameter; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Model de table pour suivre l'evolution des differentes simulations en cours. @@ -227,7 +227,7 @@ + ", " + "control.getProgress() = " + control.getProgress() + ", " + "control.getProgressMax() = " + control.getProgressMax() + ", " + "control.getDate() = " - + control.getDate()); + + control.getTimeStep()); } switch (columnIndex) { @@ -266,9 +266,9 @@ pb.setValue((int) control.getProgress()); // progress can be used for other things - Date date = control.getDate(); - if (date != null) { - pb.setString(date.getMonth() + "/" + date.getYear()); + TimeStep step = control.getTimeStep(); + if (step != null) { + pb.setString(step.getMonth() + "/" + step.getYear()); } else { pb.setString(""); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Date.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Date.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/Date.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -5,7 +5,7 @@ * $Id$ * $HeadURL$ * %% - * Copyright (C) 2005 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * Copyright (C) 2005 - 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 @@ -25,163 +25,30 @@ package fr.ifremer.isisfish.types; -import java.io.Serializable; -import static org.nuiton.i18n.I18n._; - /** - * This object can't be modified. If this beaviour is modified pay attention + * This object can't be modified. If this behavior is modified pay attention * if you used date as key in Map, in this case you will have error * * @author poussin + * + * @deprecated since 4.0.0.0, use {@link TimeStep} instead */ -public class Date implements Cloneable, Serializable, Comparable<Date> { // Date + at Deprecated +public class Date extends TimeStep { // Date - /** serialVersionUID. */ - private static final long serialVersionUID = 1L; - - protected int date = 0; - - public Date() { - } - - public Date(int date) { - this.date = date; - } - - public int compareTo(Date d) { - if (this.before(d)) - return -1; - else if (this.after(d)) - return 1; - else - return 0; - } - - public int getYear() { - return date / 12; - } - - public Month getMonth() { - int tmp = date; - while (tmp < 0) { - tmp += 12; - } - Month result = Month.MONTH[tmp % 12]; - return result; - } - - // public Date inc() { - // date++; - // return this; - // } - - public int getDate() { - return date; - } - /** - * Method next retourne une nouvelle date qui est la date suivante de la - * date courante. la date courante n'est pas modifier. * - * @return Date */ - public Date next() { - return new Date(this.date + 1); + public Date() { + super(); } /** - * Method preview retourne une nouvelle date qui est la date precedente de - * la date courante la date courante n'est pas modifier. - * - * @return Date + * @param step */ - public Date previous() { - return new Date(this.date - 1); - } + public Date(int step) { + super(step); + } - /** - * Method next retourne une nouvelle date qui est le meme mois de l'annee - * suivante de la date courante. la date courante n'est pas modifier. - * - * @return Date - */ - public Date nextYear() { - return new Date(this.date + 12); - } - - /** - * Method preview retourne une nouvelle date qui est le meme mois de l'annee - * precedente de la date courante la date courante n'est pas modifier. - * - * @return Date - */ - public Date previousYear() { - return new Date(this.date - 12); - } - - - /** - * compare 2 dates. - * - * @return retourne vrai si d est strictement superieur - */ - public boolean before(Date d) { - return this.date < d.date; - } - - public boolean beforeOrEquals(Date d) { - return this.date <= d.date; - } - - /** - * compare 2 dates. - * - * @return retourne vrai si d est strictement inferieur - */ - public boolean after(Date d) { - return this.date > d.date; - } - - public boolean afterOrEquals(Date d) { - return this.date >= d.date; - } - - public boolean equals(Object o) { - if (o instanceof Date) - return date == ((Date) o).date; - return false; - } - - public int hashCode() { - return date; - } - - /** - * @param date2 - * @return month array - */ - public Month[] getMonthBetweenDate(Date date2) { - if(date2.getDate() - getDate() <0) { - return new Month[0]; - } - - Month[] result = new Month[date2.getDate() - getDate()]; - Month month = getMonth(); - for (int i=0; i<result.length; i++) { - month = month.next(); - result[i] = month; - } - return result; - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() { - String result = _("isisfish.date.toString", getMonth(), getYear()); - return result; - } - } // Date Added: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/TimeStep.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/TimeStep.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/TimeStep.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -0,0 +1,192 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2005 - 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 + * 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.types; + +import java.io.Serializable; +import static org.nuiton.i18n.I18n._; + +/** + * This object can't be modified. If this beaviour is modified pay attention + * if you used date as key in Map, in this case you will have error + * + * @author poussin + */ +public class TimeStep implements Cloneable, Serializable, Comparable<TimeStep> { // Date + + /** serialVersionUID. */ + private static final long serialVersionUID = 1L; + + protected int step = 0; + + public TimeStep() { + } + + public TimeStep(int step) { + this.step = step; + } + + public int compareTo(TimeStep t) { + if (this.before(t)) { + return -1; + } else if (this.after(t)) { + return 1; + } else { + return 0; + } + } + + public int getYear() { + return step / 12; + } + + public Month getMonth() { + int tmp = step; + while (tmp < 0) { + tmp += 12; + } + Month result = Month.MONTH[tmp % 12]; + return result; + } + + /** + * @deprecated since 4.0.0.0, use {@link #getStep()} instead + * @return date + */ + @Deprecated + public int getDate() { + return step; + } + + public int getStep() { + return step; + } + + /** + * Method next retourne une nouvelle date qui est la date suivante de la + * date courante. la date courante n'est pas modifier. + * + * @return Date + */ + public TimeStep next() { + return new TimeStep(this.step + 1); + } + + /** + * Method preview retourne une nouvelle date qui est la date precedente de + * la date courante la date courante n'est pas modifier. + * + * @return Date + */ + public TimeStep previous() { + return new TimeStep(this.step - 1); + } + + /** + * Method next retourne une nouvelle date qui est le meme mois de l'annee + * suivante de la date courante. la date courante n'est pas modifier. + * + * @return Date + */ + public TimeStep nextYear() { + return new TimeStep(this.step + 12); + } + + /** + * Method preview retourne une nouvelle date qui est le meme mois de l'annee + * precedente de la date courante la date courante n'est pas modifier. + * + * @return Date + */ + public TimeStep previousYear() { + return new TimeStep(this.step - 12); + } + + /** + * compare 2 dates. + * + * @return retourne vrai si t est strictement superieur + */ + public boolean before(TimeStep t) { + return this.step < t.step; + } + + public boolean beforeOrEquals(TimeStep t) { + return this.step <= t.step; + } + + /** + * compare 2 dates. + * + * @return retourne vrai si t est strictement inferieur + */ + public boolean after(TimeStep t) { + return this.step > t.step; + } + + public boolean afterOrEquals(TimeStep d) { + return this.step >= d.step; + } + + public boolean equals(Object o) { + if (o instanceof TimeStep) { + return step == ((TimeStep) o).step; + } + return false; + } + + public int hashCode() { + return step; + } + + /** + * @param timeStep2 + * @return month array + */ + public Month[] getMonthBetweenDate(TimeStep timeStep2) { + if (timeStep2.getStep() - getStep() < 0) { + return new Month[0]; + } + + Month[] result = new Month[timeStep2.getStep() - getStep()]; + Month month = getMonth(); + for (int i = 0; i < result.length; i++) { + month = month.next(); + result[i] = month; + } + return result; + } + + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + String result = _("isisfish.date.toString", getMonth(), getYear()); + return result; + } + +} // Date + Property changes on: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/TimeStep.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/DateType.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/DateType.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/DateType.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -1,111 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2002 - 2010 Ifremer, Code Lutin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 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.types.hibernate; - -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.sql.Types; - -import org.hibernate.HibernateException; -import org.hibernate.type.ImmutableType; - -import fr.ifremer.isisfish.types.Date; - -/** - * DateType.java - * - * Created: 19 janv. 2006 - * - * @author Arnaud Thimel <thimel at codelutin.com> - * Copyright Code Lutin - * @version $Revision$ - * - * Mise a jour: $Date$ - * par : $Author$ - */ -public class DateType extends ImmutableType { - - /** */ - private static final long serialVersionUID = -5295147041590169149L; - - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) - */ - @Override - public Object get(ResultSet rs, String name) throws HibernateException, - SQLException { - return new Date(rs.getInt(name)); - } - - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) - */ - @Override - public void set(PreparedStatement st, Object value, int index) - throws HibernateException, SQLException { - st.setInt(index, ((Date) value).getDate()); - } - - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#sqlType() - */ - @Override - public int sqlType() { - return Types.INTEGER; - } - - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#toString(java.lang.Object) - */ - @Override - public String toString(Object value) throws HibernateException { - return ((Date)value).toString(); - } - - /* (non-Javadoc) - * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) - */ - @Override - public Object fromStringValue(String xml) throws HibernateException { - return new Date(Integer.parseInt(xml)); - } - - /* (non-Javadoc) - * @see org.hibernate.type.Type#getReturnedClass() - */ - public Class getReturnedClass() { - return Date.class; - } - - /* (non-Javadoc) - * @see org.hibernate.type.Type#getName() - */ - public String getName() { - return DateType.class.getName(); - } - -} Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java (from rev 3392, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/DateType.java) =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/types/hibernate/TimeStepType.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -0,0 +1,111 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2002 - 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 + * 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.types.hibernate; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.sql.Types; + +import org.hibernate.HibernateException; +import org.hibernate.type.ImmutableType; + +import fr.ifremer.isisfish.types.TimeStep; + +/** + * DateType.java + * + * Created: 19 janv. 2006 + * + * @author Arnaud Thimel <thimel at codelutin.com> + * Copyright Code Lutin + * @version $Revision$ + * + * Mise a jour: $Date$ + * par : $Author$ + */ +public class TimeStepType extends ImmutableType { + + /** serialVersionUID. */ + private static final long serialVersionUID = -5295147041590169149L; + + /* + * @see org.hibernate.type.NullableType#get(java.sql.ResultSet, java.lang.String) + */ + @Override + public Object get(ResultSet rs, String name) throws HibernateException, + SQLException { + return new TimeStep(rs.getInt(name)); + } + + /* + * @see org.hibernate.type.NullableType#set(java.sql.PreparedStatement, java.lang.Object, int) + */ + @Override + public void set(PreparedStatement st, Object value, int index) + throws HibernateException, SQLException { + st.setInt(index, ((TimeStep) value).getStep()); + } + + /* + * @see org.hibernate.type.NullableType#sqlType() + */ + @Override + public int sqlType() { + return Types.INTEGER; + } + + /* + * @see org.hibernate.type.NullableType#toString(java.lang.Object) + */ + @Override + public String toString(Object value) throws HibernateException { + return ((TimeStep)value).toString(); + } + + /* + * @see org.hibernate.type.NullableType#fromStringValue(java.lang.String) + */ + @Override + public Object fromStringValue(String xml) throws HibernateException { + return new TimeStep(Integer.parseInt(xml)); + } + + /* + * @see org.hibernate.type.Type#getReturnedClass() + */ + public Class getReturnedClass() { + return TimeStep.class; + } + + /* + * @see org.hibernate.type.Type#getName() + */ + public String getName() { + return TimeStepType.class.getName(); + } + +} Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/MatrixSummaryRenderer.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -40,7 +40,7 @@ import fr.ifremer.isisfish.datastore.ResultStorage; import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.simulator.SimulationParameter; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Simulation summary renderer. @@ -88,13 +88,13 @@ // TODO EC20090717 ca marche plus ca if (name.startsWith(ABONDANCE_STRING)){ - MatrixND mat1 = resultStorage.getMatrix(new Date(0), name, topiaContext); + MatrixND mat1 = resultStorage.getMatrix(new TimeStep(0), name, topiaContext); mat1 = mat1.sumOverDim(0); mat1 = mat1.sumOverDim(1); mat1 = mat1.reduce(); resume.append(_("isisfish.result.begin.simulation")).append(mat1.getName()).append(": ").append(mat1.getValue(0)).append("\n"); - mat1 = resultStorage.getMatrix(resultStorage.getLastDate(), name, topiaContext); + mat1 = resultStorage.getMatrix(resultStorage.getLastStep(), name, topiaContext); mat1 = mat1.sumOverDim(0); mat1 = mat1.sumOverDim(1); mat1 = mat1.reduce(); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultMatrixFilter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultMatrixFilter.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/ResultMatrixFilter.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -32,7 +32,7 @@ import org.nuiton.math.matrix.viewer.MatrixFilter; import fr.ifremer.isisfish.datastore.ResultStorage; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Filtre qui ajoute les trou dans les données (valeur intermédiares absentes) @@ -82,10 +82,10 @@ List<Object> newList = new ArrayList<Object>(); for (int index = 0 ; index < semList.size(); ++index) { Object semObject = semList.get(index); - if (semObject instanceof Date) { - Date semDate = (Date)semObject; - Date newDate = new Date(semDate.getDate() * sumStep); - newList.add(newDate); + if (semObject instanceof TimeStep) { + TimeStep semStep = (TimeStep)semObject; + TimeStep newStep = new TimeStep(semStep.getStep() * sumStep); + newList.add(newStep); } else { newList.add(semObject); Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/YearSumDimensionAction.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/YearSumDimensionAction.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/result/YearSumDimensionAction.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -28,7 +28,7 @@ import org.nuiton.math.matrix.viewer.MatrixDimensionAction; import org.nuiton.util.Resource; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Action de somme des elements par 12 (année) pour la dimension des pas de temps. @@ -58,7 +58,7 @@ @Override public Class<?> getDimensionType() { - return Date.class; + return TimeStep.class; } @Override Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterTableCellEditor.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterTableCellEditor.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/widget/editor/ParameterTableCellEditor.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -51,7 +51,7 @@ import org.nuiton.util.MonthEnum; import fr.ifremer.isisfish.datastore.RegionStorage; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.util.ConverterUtil; @@ -89,7 +89,7 @@ /** for a mounth. */ Mounth(Month.class), /** for a simple date. */ - Date(Date.class), + TimeStep(TimeStep.class), /** for a simple boolean. */ Double(double.class, Double.class), /** for a simple boolean. */ @@ -181,10 +181,10 @@ c.setSelectedItem(value); editor = c; break; - case Date: - Date date = (Date) value; + case TimeStep: + TimeStep date = (TimeStep) value; if (date == null) { - date = new Date(0); + date = new TimeStep(0); } int month = date.getMonth().getMonthNumber(); int yea = date.getYear(); @@ -273,7 +273,7 @@ case Mounth: result = getComboBoxIndex(editor) + ""; break; - case Date: + case TimeStep: result = ((DateComponent) editor).getSelectedValue() + ""; break; case File: Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ConverterUtil.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ConverterUtil.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/ConverterUtil.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -32,7 +32,7 @@ import org.nuiton.topia.TopiaContext; import org.nuiton.topia.persistence.TopiaEntity; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.types.RangeOfValues; import fr.ifremer.isisfish.types.TimeUnit; @@ -56,7 +56,7 @@ // mise en place de converter de string vers des objet ... cub.register(new TopiaEntityConverter(context), TopiaEntity.class); - cub.register(new DateConverter(), Date.class); + cub.register(new TimeStepConverter(), TimeStep.class); cub.register(new MonthConverter(), Month.class); cub.register(new TimeUnitConverter(), TimeUnit.class); cub.register(new RangeOfValuesConverter(), RangeOfValues.class); Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DateConverter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DateConverter.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DateConverter.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -1,63 +0,0 @@ -/* - * #%L - * IsisFish - * - * $Id$ - * $HeadURL$ - * %% - * Copyright (C) 2006 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin - * %% - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as - * published by the Free Software Foundation, either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program. If not, see - * <http://www.gnu.org/licenses/gpl-2.0.html>. - * #L% - */ - -package fr.ifremer.isisfish.util; - -import org.apache.commons.beanutils.ConversionException; -import org.apache.commons.beanutils.Converter; - -import fr.ifremer.isisfish.types.Date; - - -/** - * Classe utilise pour convertir une chaine en un objet Date. - * - * Utilisé pour la conversion et le stockage en propriete des parametres. - * - * @author poussin - */ -public class DateConverter implements Converter { - - /* (non-Javadoc) - * @see org.apache.commons.beanutils.Converter#convert(java.lang.Class, java.lang.Object) - */ - public Object convert(Class type, Object value) { - Object result; - if (value instanceof Date) { - result = value; - } else if (value instanceof String) { - int d = Integer.parseInt(value.toString()); - result = new Date(d); - } else if (value == null) { - result = new Date(0); - } else { - throw new ConversionException("Can't convert '" + value + "' to " + type.getName()); - } - return result; - } - -} - - Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/StringConverter.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/StringConverter.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/StringConverter.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -30,7 +30,7 @@ import org.nuiton.math.matrix.MatrixND; import org.nuiton.topia.persistence.TopiaEntity; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; import fr.ifremer.isisfish.types.Month; import fr.ifremer.isisfish.types.TimeUnit; @@ -59,8 +59,8 @@ if (o != null) { if (o instanceof TopiaEntity) { result = ((TopiaEntity) o).getTopiaId(); - } else if (o instanceof Date) { - result = String.valueOf(((Date) o).getDate()); + } else if (o instanceof TimeStep) { + result = String.valueOf(((TimeStep) o).getStep()); } else if (o instanceof Month) { result = String.valueOf(((Month) o).getMonthNumber()); } else if (o instanceof TimeUnit) { Copied: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/TimeStepConverter.java (from rev 3392, isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/DateConverter.java) =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/TimeStepConverter.java (rev 0) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/util/TimeStepConverter.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -0,0 +1,63 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2006 - 2010 Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-2.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.util; + +import org.apache.commons.beanutils.ConversionException; +import org.apache.commons.beanutils.Converter; + +import fr.ifremer.isisfish.types.TimeStep; + + +/** + * Classe utilise pour convertir une chaine en un objet Date. + * + * Utilisé pour la conversion et le stockage en propriete des parametres. + * + * @author poussin + */ +public class TimeStepConverter implements Converter { + + /* (non-Javadoc) + * @see org.apache.commons.beanutils.Converter#convert(java.lang.Class, java.lang.Object) + */ + public Object convert(Class type, Object value) { + Object result; + if (value instanceof TimeStep) { + result = value; + } else if (value instanceof String) { + int d = Integer.parseInt(value.toString()); + result = new TimeStep(d); + } else if (value == null) { + result = new TimeStep(0); + } else { + throw new ConversionException("Can't convert '" + value + "' to " + type.getName()); + } + return result; + } + +} + + Modified: isis-fish/trunk/src/main/xmi/isis-fish.zargo =================================================================== (Binary files differ) Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/rule/RuleMock.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/rule/RuleMock.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/rule/RuleMock.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -27,7 +27,7 @@ import fr.ifremer.isisfish.entities.Metier; import fr.ifremer.isisfish.simulator.SimulationContext; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * A basic rule implementation. @@ -71,29 +71,29 @@ } /* - * @see fr.ifremer.isisfish.rule.Rule#condition(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, fr.ifremer.isisfish.entities.Metier) + * @see fr.ifremer.isisfish.rule.Rule#condition(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, fr.ifremer.isisfish.entities.Metier) */ @Override - public boolean condition(SimulationContext context, Date date, Metier metier) + public boolean condition(SimulationContext context, TimeStep step, Metier metier) throws Exception { return false; } /* - * @see fr.ifremer.isisfish.rule.Rule#preAction(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, fr.ifremer.isisfish.entities.Metier) + * @see fr.ifremer.isisfish.rule.Rule#preAction(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, fr.ifremer.isisfish.entities.Metier) */ @Override - public void preAction(SimulationContext context, Date date, Metier metier) + public void preAction(SimulationContext context, TimeStep step, Metier metier) throws Exception { // TODO Auto-generated method stub } /* - * @see fr.ifremer.isisfish.rule.Rule#postAction(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.Date, fr.ifremer.isisfish.entities.Metier) + * @see fr.ifremer.isisfish.rule.Rule#postAction(fr.ifremer.isisfish.simulator.SimulationContext, fr.ifremer.isisfish.types.TimeStep, fr.ifremer.isisfish.entities.Metier) */ @Override - public void postAction(SimulationContext context, Date date, Metier metier) + public void postAction(SimulationContext context, TimeStep step, Metier metier) throws Exception { } Modified: isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceIT.java =================================================================== --- isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceIT.java 2011-07-07 14:33:45 UTC (rev 3436) +++ isis-fish/trunk/src/test/java/fr/ifremer/isisfish/simulator/launcher/SimulationServiceIT.java 2011-07-08 11:26:05 UTC (rev 3437) @@ -41,7 +41,7 @@ import fr.ifremer.isisfish.datastore.SimulationStorage; import fr.ifremer.isisfish.entities.Result; import fr.ifremer.isisfish.simulator.SimulationControl; -import fr.ifremer.isisfish.types.Date; +import fr.ifremer.isisfish.types.TimeStep; /** * Integration tests for {@link SimulationService}. @@ -92,7 +92,7 @@ // lancement de la simulation SimulationControl control = new SimulationControl(sim.getName()); - control.setDate(new Date()); + control.setTimeStep(new TimeStep()); InProcessSimulatorLauncher launcher = new InProcessSimulatorLauncher(); sim = launcher.localSimulate(control, sim); @@ -108,21 +108,21 @@ List<String> resultNames = resultRef.getResultName(); Assert.assertEquals(resultNames, result.getResultName()); - Date lastDate = resultRef.getLastDate(); + TimeStep lastStep = resultRef.getLastStep(); if (log.isInfoEnabled()) { log.info("Check result ..."); } - for (Date date = new Date(0); date.beforeOrEquals(lastDate); date = date.next()) { + for (TimeStep step = new TimeStep(0); step.beforeOrEquals(lastStep); step = step.next()) { for (String resultName : resultNames) { if (log.isDebugEnabled()) { - log.debug("Check result " + date + " " + resultName); + log.debug("Check result " + step + " " + resultName); } - Assert.assertEquals("Date " + date.getDate() + " result " + resultName, - resultRef.getMatrix(date, resultName), - result.getMatrix(date, resultName)); + Assert.assertEquals("Date " + step.getStep() + " result " + resultName, + resultRef.getMatrix(step, resultName), + result.getMatrix(step, resultName)); resultChecked++; }
participants (1)
-
chatellier@users.labs.libre-entreprise.org