diff --git a/pom.xml b/pom.xml index 89988283da82cc6bb07a40aa635eee4a3f9f15d4..84e0249de28eb52dc434be1d84ff4061e05160d9 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ <dependency> <groupId>no.nibio.vips</groupId> <artifactId>VIPSCommon</artifactId> - <version>2.1.0</version> + <version>2.1.1</version> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> diff --git a/src/main/java/no/nibio/vips/model/alternariamodel/AlternariaModel.java b/src/main/java/no/nibio/vips/model/alternariamodel/AlternariaModel.java index 4b3e53f68b504e92513b760b65a75e141d919803..27eda260ebe71127398e68c2571b8b901d0ec71c 100644 --- a/src/main/java/no/nibio/vips/model/alternariamodel/AlternariaModel.java +++ b/src/main/java/no/nibio/vips/model/alternariamodel/AlternariaModel.java @@ -39,13 +39,17 @@ package no.nibio.vips.model.alternariamodel; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.BufferedInputStream; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; import java.util.Date; import java.util.List; +import java.util.Scanner; import java.util.TimeZone; import java.util.logging.Level; import java.util.logging.Logger; @@ -222,22 +226,10 @@ public class AlternariaModel extends I18nImpl implements Model { return this.getText("name", language); } + @Override public String getLicense() { - /** - * method name : getLicense - * - * @param : - * @return : java.lang.String - * - * purpose : - * - * date : Expression date is undefined on line 20, column 19 in - * Templates/Classes/Code/GeneratedMethodBody. Expression time is - * undefined on line 20, column 27 in - * Templates/Classes/Code/GeneratedMethodBody. - */ - return this.getText("license", Model.DEFAULT_LANGUAGE); + return this.modelUtil.getTextFromFileInJar(this.getClass(), "/LICENSE_header.txt"); } @Override @@ -377,26 +369,13 @@ public class AlternariaModel extends I18nImpl implements Model { } /** - * TODO * - * @return + * + * @return a Json configuration example */ @Override public String getSampleConfig() { - /** - * method name : getSampleConfig - * - * @param : - * @return : java.lang.String - * - * purpose : - * - * date : Expression date is undefined on line 20, column 19 in - * Templates/Classes/Code/GeneratedMethodBody. Expression time is - * undefined on line 20, column 27 in - * Templates/Classes/Code/GeneratedMethodBody. - */ - return this.getText("sampleconfig", Model.DEFAULT_LANGUAGE); + return this.modelUtil.getTextFromFileInJar(this.getClass(), "/sample_config.json"); } /** @@ -743,4 +722,5 @@ public class AlternariaModel extends I18nImpl implements Model { return result; } + } diff --git a/src/main/resources/LICENSE_header.txt b/src/main/resources/LICENSE_header.txt new file mode 100644 index 0000000000000000000000000000000000000000..76e92f2831f909ba16f7b688ec4a83ed204f5929 --- /dev/null +++ b/src/main/resources/LICENSE_header.txt @@ -0,0 +1,16 @@ + + + Copyright (C) 2024 Tor-Einar Skog <tor-einar.skog@nibio.no> + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/src/main/resources/no/nibio/vips/model/alternariamodel/texts.properties b/src/main/resources/no/nibio/vips/model/alternariamodel/texts.properties index e3e34950884c015ce4193aea08ba506ced146243..ff1798cdeb9ed91d7c4b5e843732c1d32957ba74 100644 --- a/src/main/resources/no/nibio/vips/model/alternariamodel/texts.properties +++ b/src/main/resources/no/nibio/vips/model/alternariamodel/texts.properties @@ -26,35 +26,3 @@ observations - list of weather data. The following parameters are required:\n\ * TM - Average temperature (Degrees Celcius)\n\ * BT - Leaf wetness (Minutes/hour) (IF you don't have leaf wetness, you must provide UM (relative humidity). Then we will calculate the leaf wetness.\n\ sprayingDate - (Optional) Farmers can choose multiple spraying dates (upto four spraying dates). -license= Copyright (c) 2020 NIBIO <http://www.nibio.no/>. \n \nThis file is part of AlternariaModel. \nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see <https://www.gnu.org/licenses/>. - -sampleconfig={ \n\ -\t "loginInfo": { \n\ -\t\t "username": "example", \n\ -\t\t "password": "example" \n\ -\t }, \n\ -\t "modelId": "ALTERNARIA", \n\ -\t "configParameters": { \n\ -\t "timeZone": "Europe/Oslo", \n\ -\t "observations": [ \n\ -\t { \n\ -\t\t "elementMeasurementTypeId": "TM", \n\ -\t\t "logIntervalId": 1, \n\ -\t\t "timeMeasured": "2018-08-11T00:00:00+02:00", \n\ -\t\t "value": 10.46 \n\ -\t }, \n\ -\t { \n\ -\t\t "elementMeasurementTypeId": "BT", \n\ -\t\t "logIntervalId": 1, \n\ -\t\t "timeMeasured": "2018-08-11T00:00:00+02:00", \n\ -\t\t "value": 60.0 \n\ -\t } \n\ -\t ], \n\ -\t "sprayingDates": [ \n\ -\t\t "2018-07-02T22:00:00Z", \n\ -\t\t "2018-07-30T22:00:00Z", \n\ -\t\t "2018-09-04T22:00:00Z" \n\ -\t ] \n\ -\t } \n\ - } \n\ - diff --git a/src/main/resources/no/nibio/vips/model/alternariamodel/texts_nb.properties b/src/main/resources/no/nibio/vips/model/alternariamodel/texts_nb.properties index b79332c1e0a8f2aad8ebeb49f93295e6aded08a1..0fa4f36aee3246c03e7cdac84319f27098e65653 100644 --- a/src/main/resources/no/nibio/vips/model/alternariamodel/texts_nb.properties +++ b/src/main/resources/no/nibio/vips/model/alternariamodel/texts_nb.properties @@ -19,4 +19,3 @@ name=TOMCAST (FAST - Dew) modell for Alternaria description= <p>{{filename="/images/ef-20200421-altenaria.jpg" description="Photo: Bilde: S. Abrahamsen, NLR"}}</p>\n<p>TOMCAST er basert på en modell utviklet for varsling av bladflekksjukdommer i tomat. Versjonen som blir brukt her er testet og tilpasset tørrflekksjuke i potet (Alternaria solani) i Danmark. Modellen beregner daglige risikoverdier (DSV: Disease Severity Value) basert på temperatur og bladfuktighet siste døgn. DSV representerer risikoen for angrep av tørrflekksjuke siste døgn. Daglige DSV-verdier blir summert frem til en terskel er nådd og behandling er anbefalt. Modellen er laget slik at akkumulering av DSV nullstilles når sprøyting gjennomføres, og akkumulering starter på nytt fra 0.</p>\n<p>Modellen er under utprøving i 2020, og vil bli testet både i gulrot og i potet. Det vil kun være mulig å starte private varler for denne modellen. Basert på erfaringer fra andre land er terskelverdien for rødt varsel satt til 20.</p>\n<h3>Oppstart av varsel</h3>\n<p>Potetplanter varierer i mottakelighet for tørrflekksjuke gjennom sesongen, og de blir gradvis mer og mer mottakelige. Dette betyr at behovet for beskyttelse også varierer tilsvarende. Modellen startes når man ser de første symptomene på tørrflekksjuke og gjennomfører første behandling (under 0,1% angrep).</p>\n<h3>Tolking av varsel</h3>\n<p>Modellen vil vise grønt (ingen fare) frem til den akkumulerte risikoverdien er 15. Fra denne verdien frem til terskelverdien (20) vil varselet være gult (mulig fare), og deretter gå over til rødt (fare).</p> statusInterpretation=Modellen vil vise gr\u00f8nt (ingen fare) frem til den akkumulerte risikoverdien er 15. Fra denne verdien frem til terskelverdien (20) vil varselet v\u00e6re gult (mulig fare), og deretter g\u00e5 over til r\u00f8dt (fare). usage=TODO -license=Copyright (c) 2020 NIBIO <http://www.nibio.no/>. \n \nThis file is part of AlternariaModel. \nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see <https://www.gnu.org/licenses/>. diff --git a/src/main/resources/sample_config.json b/src/main/resources/sample_config.json new file mode 100644 index 0000000000000000000000000000000000000000..f71ed86a614d6f6c1e65183bb8db332766599764 --- /dev/null +++ b/src/main/resources/sample_config.json @@ -0,0 +1,31 @@ +{ + "loginInfo": { + "username": "example", + "password": "example" + }, + "modelId": "ALTERNARIA", + "configParameters": { + "sprayingDates": [ + "2018-07-02T22:00:00Z", + "2018-07-30T22:00:00Z", + "2018-09-04T22:00:00Z" + ], + "thresholdDSVTempMin": "10.0", + "thresholdDSVMax": "20.0", + "timeZone": "Europe/Oslo", + "observations": [ + { + "elementMeasurementTypeId": "TM", + "logIntervalId": 1, + "timeMeasured": "2018-08-11T00:00:00+02:00", + "value": 10.46 + }, + { + "elementMeasurementTypeId": "BT", + "logIntervalId": 1, + "timeMeasured": "2018-08-11T00:00:00+02:00", + "value": 60 + } + ] + } +} \ No newline at end of file diff --git a/src/test/java/no/nibio/vips/model/alternariamodel/AlternariaModelTest.java b/src/test/java/no/nibio/vips/model/alternariamodel/AlternariaModelTest.java index e4b6a866ea4fe440d76bc24560ff259caa7ed947..001010c8ad7f5cd475ce5bedadac331965bcb319 100644 --- a/src/test/java/no/nibio/vips/model/alternariamodel/AlternariaModelTest.java +++ b/src/test/java/no/nibio/vips/model/alternariamodel/AlternariaModelTest.java @@ -246,9 +246,8 @@ public class AlternariaModelTest { public void testGetLicense() { System.out.println("getLicense"); AlternariaModel instance = new AlternariaModel(); - String expResult = ""; String result = instance.getLicense(); - assertNotNull(result); + assertTrue(result.contains("GNU Affero")); } /** @@ -348,15 +347,13 @@ public class AlternariaModelTest { /** * Test of getSampleConfig method, of class AlternariaModel. - * TODO - Recheck the functionality */ @org.junit.jupiter.api.Test public void testGetSampleConfig() { System.out.println("getSampleConfig"); AlternariaModel instance = new AlternariaModel(); - String expResult = ""; String result = instance.getSampleConfig(); - assertNotNull(result); + assertTrue(result.contains("configParameters")); } /**