r4290 - in trunk/src: main/java/fr/ifremer/isisfish/datastore main/java/fr/ifremer/isisfish/ui/script main/resources/templates/script test/java/fr/ifremer/isisfish/datastore
Author: echatellier Date: 2015-06-23 16:49:38 +0000 (Tue, 23 Jun 2015) New Revision: 4290 Url: http://forge.codelutin.com/projects/isis-fish/repository/revisions/4290 Log: Fix resultInfo template. Add test for it. Added: trunk/src/main/resources/templates/script/resultinfo.ftl trunk/src/test/java/fr/ifremer/isisfish/datastore/ResultInfoStorageTest.java Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultInfoStorage.java trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java trunk/src/main/resources/templates/script/export.ftl trunk/src/main/resources/templates/script/exportStep.ftl trunk/src/main/resources/templates/script/objective.ftl trunk/src/main/resources/templates/script/optimization.ftl trunk/src/main/resources/templates/script/rule.ftl trunk/src/main/resources/templates/script/sensitivityexport.ftl trunk/src/main/resources/templates/script/simulationplan.ftl Modified: trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultInfoStorage.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultInfoStorage.java 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/java/fr/ifremer/isisfish/datastore/ResultInfoStorage.java 2015-06-23 16:49:38 UTC (rev 4290) @@ -54,7 +54,7 @@ public static final String RESULT_INFO_PATH = "resultinfos"; /** Template freemarker pour les noms de resultats. */ - public static final String RESULT_NAME_TEMPLATE = "templates/script/resultInfo.ftl"; + public static final String RESULT_INFO_TEMPLATE = "templates/script/resultinfo.ftl"; /** Instance cache. */ protected static Map<String, ResultInfoStorage> resultInfosCache = new ReferenceMap<String, ResultInfoStorage>(); Modified: trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java =================================================================== --- trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/java/fr/ifremer/isisfish/ui/script/ScriptHandler.java 2015-06-23 16:49:38 UTC (rev 4290) @@ -975,7 +975,7 @@ RuleStorage.RULE_TEMPLATE, true), ResultInfo( ResultInfoStorage.getResultInfoDirectory(), - ResultInfoStorage.RESULT_NAME_TEMPLATE, true), + ResultInfoStorage.RESULT_INFO_TEMPLATE, true), Objective( ObjectiveStorage.getObjectiveDirectory(), ObjectiveStorage.OBJECTIVE_TEMPLATE, true), @@ -1018,7 +1018,7 @@ RuleStorage.RULE_TEMPLATE), CommunityResultInfo( ResultInfoStorage.getCommunityResultInfoDirectory(), - ResultInfoStorage.RESULT_NAME_TEMPLATE), + ResultInfoStorage.RESULT_INFO_TEMPLATE), CommunityScript( ScriptStorage.getCommunityScriptDirectory(), ScriptStorage.SCRIPT_TEMPLATE), Modified: trunk/src/main/resources/templates/script/export.ftl =================================================================== --- trunk/src/main/resources/templates/script/export.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/export.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -76,8 +76,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; public String[] getNecessaryResult() { Modified: trunk/src/main/resources/templates/script/exportStep.ftl =================================================================== --- trunk/src/main/resources/templates/script/exportStep.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/exportStep.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -75,8 +75,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; /** Modified: trunk/src/main/resources/templates/script/objective.ftl =================================================================== --- trunk/src/main/resources/templates/script/objective.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/objective.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -76,8 +76,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; @Override Modified: trunk/src/main/resources/templates/script/optimization.ftl =================================================================== --- trunk/src/main/resources/templates/script/optimization.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/optimization.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -77,8 +77,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; @Override Added: trunk/src/main/resources/templates/script/resultinfo.ftl =================================================================== --- trunk/src/main/resources/templates/script/resultinfo.ftl (rev 0) +++ trunk/src/main/resources/templates/script/resultinfo.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -0,0 +1,72 @@ +<#-- + #%L + IsisFish + + $Id: rule.ftl 4277 2015-06-21 17:24:03Z echatellier $ + $HeadURL: http://svn.codelutin.com/isis-fish/trunk/src/main/resources/templates/script... $ + %% + Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program. If not, see + <http://www.gnu.org/licenses/gpl-3.0.html>. + #L% +--> +/* + * Copyright (C) ${date?date?string("yyyy")} ${author} + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + */ + +package resultinfos; + +import fr.ifremer.isisfish.result.AbstractResultInfo; + +/** + * ${name}.java + * + * Created: ${date?date?string.long} + */ +public class ${name} extends AbstractResultInfo { + + public static final String NAME = ${name}.class.getSimpleName(); + + protected String[] necessaryResult = { + // put here all necessary result for this rule + // example: + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, + }; + + @Override + public String[] getNecessaryResult() { + return necessaryResult; + } + + @Override + public String getDescription() { + return "do the doc of Result ${name}"; + } +} Modified: trunk/src/main/resources/templates/script/rule.ftl =================================================================== --- trunk/src/main/resources/templates/script/rule.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/rule.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -75,8 +75,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; public String[] getNecessaryResult() { Modified: trunk/src/main/resources/templates/script/sensitivityexport.ftl =================================================================== --- trunk/src/main/resources/templates/script/sensitivityexport.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/sensitivityexport.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -74,8 +74,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; public String[] getNecessaryResult() { Modified: trunk/src/main/resources/templates/script/simulationplan.ftl =================================================================== --- trunk/src/main/resources/templates/script/simulationplan.ftl 2015-06-23 16:39:29 UTC (rev 4289) +++ trunk/src/main/resources/templates/script/simulationplan.ftl 2015-06-23 16:49:38 UTC (rev 4290) @@ -80,8 +80,8 @@ protected String[] necessaryResult = { // put here all necessary result for this rule // example: - // MatrixBiomass.class.getSimpleName(), - // MatrixNetValueOfLandingsPerStrategyMet.class.getSimpleName(), + // MatrixBiomass.NAME, + // MatrixNetValueOfLandingsPerStrategyMet.NAME, }; @Override Added: trunk/src/test/java/fr/ifremer/isisfish/datastore/ResultInfoStorageTest.java =================================================================== --- trunk/src/test/java/fr/ifremer/isisfish/datastore/ResultInfoStorageTest.java (rev 0) +++ trunk/src/test/java/fr/ifremer/isisfish/datastore/ResultInfoStorageTest.java 2015-06-23 16:49:38 UTC (rev 4290) @@ -0,0 +1,88 @@ +/* + * #%L + * IsisFish + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2015 Ifremer, CodeLutin, Chatellier Eric + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +package fr.ifremer.isisfish.datastore; + +import java.io.StringWriter; +import java.io.Writer; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import fr.ifremer.isisfish.AbstractIsisFishTest; +import fr.ifremer.isisfish.IsisFish; +import fr.ifremer.isisfish.datastore.CodeSourceStorage.Location; +import freemarker.template.Configuration; +import freemarker.template.Template; + +/** + * ResultInfoStorageTest. + */ +public class ResultInfoStorageTest extends AbstractIsisFishTest { + + protected Configuration freemarkerConfiguration; + + @Before + public void setUp() throws Exception { + freemarkerConfiguration = getFreemarkerConfiguration(); + } + + @Test + public void testNewResultWithCompilation() throws Exception { + + String fileName = "TestResult1"; + + ResultInfoStorage resultInfoStorage = ResultInfoStorage.createResultInfo(fileName, Location.COMMUNITY); + + // get template + Template template = freemarkerConfiguration + .getTemplate(ResultInfoStorage.RESULT_INFO_TEMPLATE); + + // context values + Map<String, Object> root = new HashMap<String, Object>(); + // FIXME what is category ? + root.put("category", ""); + root.put("name", fileName); + root.put("date", new Date()); + root.put("author", IsisFish.config.getUserName()); + root.put("email", IsisFish.config.getUserMail()); + + // process template + Writer out = new StringWriter(); + template.process(root, out); + out.flush(); + String content = out.toString(); + + resultInfoStorage.setContent(content); + + // 0 = compile success + int compileResult = resultInfoStorage.compile(false, null); + Assert.assertEquals(0, compileResult); + } +} Property changes on: trunk/src/test/java/fr/ifremer/isisfish/datastore/ResultInfoStorageTest.java ___________________________________________________________________ Added: svn:eol-style + native Added: svn:keywords + Author Date Id Revision HeadURL
participants (1)
-
echatellier@users.forge.codelutin.com