diff --git a/src/main/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8Adapter.java b/src/main/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8Adapter.java index 73acb405932598d9e76ebe81a9d9773c996b009f..fc5d1483662b4befe5dc3b534c454d7bbc2366ed 100644 --- a/src/main/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8Adapter.java +++ b/src/main/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8Adapter.java @@ -94,8 +94,7 @@ public class FallArmywormModelJ2V8Adapter extends I18nImpl implements Model{ r.setValidTimeEnd(mapper.convertValue((String)resultObject.getString("validTimeEnd"), Date.class)); V8Object allValues = resultObject.getObject("allValues"); for(String key: allValues.getKeys()) - { System.out.println("key=" + key); - + { String keyWithoutNS = key.split("\\.")[key.split("\\.").length - 1]; String nameSpace = key.split("\\.").length == 1 ? FallArmywormModelJ2V8Adapter.MODEL_ID.toString() : key.split("\\.")[0]; r.setValue(nameSpace, keyWithoutNS, String.valueOf(allValues.get(key))); @@ -106,24 +105,11 @@ public class FallArmywormModelJ2V8Adapter extends I18nImpl implements Model{ } resultArray.release(); - String[] keysLeft = this.runtime.getKeys(); - System.out.println("Still keeping " + keysLeft[0]); - //this.releaseAll(); this.runtime.release(); return retVal; } - private void releaseAll() - { - for(String key: this.runtime.getKeys()) - { - System.out.println("Trying to release " + key +", which is a " + V8.getStringRepresentation(this.runtime.getType(key))); - ((V8Object)this.runtime.get(key)).release(); - } - } - - public ModelId getModelId() { return MODEL_ID; } diff --git a/src/main/resources/js/FallArmywormModelImpl.js b/src/main/resources/js/FallArmywormModelImpl.js index 2c625dec1137484deeaf49a88af9dd20728915fb..f7f0c9354dfb7265d0d9a798f12afd482bd01249 100644 --- a/src/main/resources/js/FallArmywormModelImpl.js +++ b/src/main/resources/js/FallArmywormModelImpl.js @@ -33,9 +33,9 @@ var observations25kmLast3Months = 0; //var TM_UPPER_THRESHOLD = 26.0; //var UNFAVOURABLE_TEMP_RISK_REDUCTION = 40/100; // 40% reduction if unfavourable temperature -var RISK_THRESHOLD_HIGH = 100; +var RISK_THRESHOLD_HIGH = 50; var OBSERVATIONS_10KM_ABSCENCE_RISK_REDUCTION = 10/100; // 10% risk reduction if no observations within 10km -var OBSERVATIONS_25KM_ABSCENCE_RISK_REDUCTION = 60/100; // 60% risk reduction if no observations within 25km +var OBSERVATIONS_25KM_ABSCENCE_RISK_REDUCTION = 70/100; // 60% risk reduction if no observations within 25km var INTERCROPPING_RISK_REDUCTION = { "NONE": 0/100, "OTHER": 10/100, diff --git a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJSAdapterTest.java b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelGraalVMAdapterTest.java similarity index 81% rename from src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJSAdapterTest.java rename to src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelGraalVMAdapterTest.java index a5890344e4f316a3465d0ff0028aee53f5de3a2e..a78b7b47989b59cfe1c1c005ec205565aef60f28 100644 --- a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJSAdapterTest.java +++ b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelGraalVMAdapterTest.java @@ -2,12 +2,12 @@ * Copyright (c) 2019 NIBIO <http://www.nibio.no/>. * * This file is part of FallArmywormModel. - * FallArmywormModel is free software: you can redistribute it and/or modify + * FallArmywormModelGraalVMAdapter 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. * - * FallArmywormModel is distributed in the hope that it will be useful, + * FallArmywormModelGraalVMAdapter 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. @@ -18,7 +18,6 @@ */ package no.nibio.vips.model.fallarmywormmodel; -import no.nibio.vips.model.fallarmywormmodel.FallArmywormModel; import java.util.List; import no.nibio.vips.entity.ModelConfiguration; import no.nibio.vips.entity.Result; @@ -35,9 +34,9 @@ import static org.junit.Assert.*; * * @author treinar */ -public class FallArmywormModelJSAdapterTest { +public class FallArmywormModelGraalVMAdapterTest { - public FallArmywormModelJSAdapterTest() { + public FallArmywormModelGraalVMAdapterTest() { } @BeforeClass @@ -72,7 +71,7 @@ public class FallArmywormModelJSAdapterTest { config.setConfigParameter("intercroppingType", "BEANS/DESMODIUM"); config.setConfigParameter("observations10kmLast3Months", 0); config.setConfigParameter("observations25kmLast3Months", 0); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); instance.setConfiguration(config); List<Result> result = instance.getResult(); assertNotNull(result); @@ -87,8 +86,8 @@ public class FallArmywormModelJSAdapterTest { public void testGetModelId() { System.out.println("getModelId"); - FallArmywormModel instance = new FallArmywormModel(); - String expResult = "FAWMODEL01"; + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); + String expResult = "FAWMODEL02"; ModelId result = instance.getModelId(); assertEquals(expResult, result.toString()); @@ -102,7 +101,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetModelName_0args() { System.out.println("getModelName"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String expResult = "Fall Armyworm Model"; String result = instance.getModelName(); assertEquals(expResult, result); @@ -117,7 +116,7 @@ public class FallArmywormModelJSAdapterTest { System.out.println("getModelName"); String language = "nb"; - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String expResult = "Fall Armyworm-modell"; String result = instance.getModelName(language); assertEquals(expResult, result); @@ -131,7 +130,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetLicense() { System.out.println("getLicense"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String expResult = ""; String result = instance.getLicense(); assertNotNull(result); @@ -146,7 +145,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetCopyright() { System.out.println("getCopyright"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getCopyright(); assertNotNull(result); @@ -160,7 +159,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetModelDescription_0args() { System.out.println("getModelDescription"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getModelDescription(); assertNotNull(result); @@ -174,7 +173,7 @@ public class FallArmywormModelJSAdapterTest { System.out.println("getModelDescription"); String language = "nb"; - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getModelDescription(language); assertNotNull(result); @@ -188,7 +187,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetWarningStatusInterpretation_0args() { System.out.println("getWarningStatusInterpretation"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getWarningStatusInterpretation(); assertNotNull(result); @@ -202,7 +201,7 @@ public class FallArmywormModelJSAdapterTest { System.out.println("getWarningStatusInterpretation"); String language = "nb"; - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getWarningStatusInterpretation(language); assertNotNull(result); @@ -216,7 +215,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetModelUsage_0args() { System.out.println("getModelUsage"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getModelUsage(); assertNotNull(result); @@ -231,7 +230,7 @@ public class FallArmywormModelJSAdapterTest { System.out.println("getModelUsage"); String language = "nb"; - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getModelUsage(language); assertNotNull(result); @@ -244,7 +243,7 @@ public class FallArmywormModelJSAdapterTest { public void testGetSampleConfig() { System.out.println("getSampleConfig"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); String result = instance.getSampleConfig(); assertNotNull(result); @@ -261,7 +260,7 @@ public class FallArmywormModelJSAdapterTest { ModelConfiguration config = fr.getModelConfigurationWithWeatherData("/romeweather.json", "FAWMODEL01"); config.setConfigParameter("plantingDate", "2019-01-22+01"); config.setConfigParameter("timeZone", "Europe/Rome"); - FallArmywormModel instance = new FallArmywormModel(); + FallArmywormModelGraalVMAdapter instance = new FallArmywormModelGraalVMAdapter(); instance.setConfiguration(config); } diff --git a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJV8AdapterTest.java b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8AdapterTest.java similarity index 98% rename from src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJV8AdapterTest.java rename to src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8AdapterTest.java index a134f7f1feb98036588bd3e8ec5d317d6f840857..b73222bb5d6fa38c3ffd25656342ef80d7ccfcc1 100644 --- a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJV8AdapterTest.java +++ b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelJ2V8AdapterTest.java @@ -35,9 +35,9 @@ import static org.junit.Assert.*; * * @author treinar */ -public class FallArmywormModelJV8AdapterTest { +public class FallArmywormModelJ2V8AdapterTest { - public FallArmywormModelJV8AdapterTest() { + public FallArmywormModelJ2V8AdapterTest() { } @BeforeClass diff --git a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelTest.java b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelTest.java index 27e62a281cb35a6d943f05f6d7638a8fe8461ead..4948c1f5f4ef65b8a08c1fa8f6618a244ceb3c51 100644 --- a/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelTest.java +++ b/src/test/java/no/nibio/vips/model/fallarmywormmodel/FallArmywormModelTest.java @@ -18,7 +18,6 @@ */ package no.nibio.vips.model.fallarmywormmodel; -import no.nibio.vips.model.fallarmywormmodel.FallArmywormModel; import java.util.List; import no.nibio.vips.entity.ModelConfiguration; import no.nibio.vips.entity.Result;