diff --git a/pom.xml b/pom.xml index 1dce8a8ddae448a08eb9d04d75847638ad966530..f513549707ae477db909320cf2b4d065ef5d9850 100644 --- a/pom.xml +++ b/pom.xml @@ -141,7 +141,7 @@ <dependency> <groupId>org.freemarker</groupId> <artifactId>freemarker</artifactId> - <version>2.3.21</version> + <version>2.3.24-incubating</version> </dependency> <dependency> <groupId>it.sauronsoftware.cron4j</groupId> diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelOldCropPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelOldCropPreprocessor.java new file mode 100644 index 0000000000000000000000000000000000000000..3009d229af3defcf279ad2260b5f3a8413acaf31 --- /dev/null +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelOldCropPreprocessor.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic 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 + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.logic.scheduling.model.preprocessor; + +/** + * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +public class DeliaRadicumFloralisModelOldCropPreprocessor extends DeliaRadicumFloralisModelPreprocessor{ + + @Override + public String getModelId() + { + return "DELIARFOBO"; + } +} diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelPreprocessor.java new file mode 100644 index 0000000000000000000000000000000000000000..b37b952aad06bd38d1914e161e87c21405c51f80 --- /dev/null +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelPreprocessor.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic 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 + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.logic.scheduling.model.preprocessor; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; +import no.nibio.vips.entity.ModelConfiguration; +import no.nibio.vips.logic.entity.ForecastConfiguration; +import no.nibio.vips.logic.entity.Organism; +import no.nibio.vips.logic.entity.PointOfInterest; +import no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor; +import no.nibio.vips.logic.scheduling.model.PreprocessorException; +import no.nibio.vips.logic.util.SessionControllerGetter; +import no.nibio.vips.logic.util.SystemTime; +import no.nibio.vips.observation.Observation; +import no.nibio.vips.util.WeatherUtil; + +/** + * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +public class DeliaRadicumFloralisModelPreprocessor extends ModelRunPreprocessor{ + public final static String START_DATE_GROWTH = "START_DATE_GROWTH"; + + @Override + public ModelConfiguration getModelConfiguration(ForecastConfiguration configuration) throws PreprocessorException { + ModelConfiguration config = null; + try + { + PointOfInterest location = configuration.getLocationPointOfInterestId(); + config = new ModelConfiguration(); + String tzID = configuration.getVipsLogicUserId().getOrganizationId().getDefaultTimeZone(); + TimeZone timeZone = TimeZone.getTimeZone(tzID); + config.setConfigParameter("timeZone", tzID); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + format.setTimeZone(timeZone); + + Date startDateGrowth = format.parse(configuration.getForecastModelConfigurationValue(this.getModelId() + "_" + START_DATE_GROWTH)); + config.setConfigParameter("startDateGrowth", configuration.getForecastModelConfigurationValue(this.getModelId() + "_" + START_DATE_GROWTH)); + WeatherUtil wUtil = new WeatherUtil(); + Date endDateCalculation = wUtil.normalizeToExactDate(SystemTime.getSystemTime(),timeZone); + config.setConfigParameter("endDateCalculation", format.format(endDateCalculation)); + + Organism organism = SessionControllerGetter.getOrganismBean().getOrganismByLatinName("Delia floralis/radicum"); + List<Observation> pestObservations = SessionControllerGetter.getObservationBean().getObservations(organism.getOrganismId(), location.getPointOfInterestId(),startDateGrowth,SystemTime.getSystemTime()); + + config.setConfigParameter("pestObservations", pestObservations); + config.setModelId(this.getModelId()); + } + catch(ParseException | NullPointerException ex) + { + throw new PreprocessorException(ex.getMessage()); + } + return config; + } + + @Override + public String getModelId() { + return "DELIARFOBS"; + } + +} diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelYoungCropPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelYoungCropPreprocessor.java new file mode 100644 index 0000000000000000000000000000000000000000..32b7f920f197c8be48c581784c67957d1edd93c0 --- /dev/null +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/DeliaRadicumFloralisModelYoungCropPreprocessor.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 NIBIO <http://www.nibio.no/>. + * + * This file is part of VIPSLogic. + * VIPSLogic is free software: you can redistribute it and/or modify + * it under the terms of the NIBIO Open Source License as published by + * NIBIO, either version 1 of the License, or (at your option) any + * later version. + * + * VIPSLogic 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 + * NIBIO Open Source License for more details. + * + * You should have received a copy of the NIBIO Open Source License + * along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. + * + */ + +package no.nibio.vips.logic.scheduling.model.preprocessor; + +/** + * @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a> + * @author Tor-Einar Skog <tor-einar.skog@nibio.no> + */ +public class DeliaRadicumFloralisModelYoungCropPreprocessor extends DeliaRadicumFloralisModelPreprocessor{ + + @Override + public String getModelId() + { + return "DELIARFOBY"; + } +} diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRuguliPennisModelPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRugulipennisModelPreprocessor.java similarity index 98% rename from src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRuguliPennisModelPreprocessor.java rename to src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRugulipennisModelPreprocessor.java index c9687fccb9e6be4ec85c38fd981cb6e96bd4e5ed..fd1812685a5fcee90382f92640a8ff054cc18914 100644 --- a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRuguliPennisModelPreprocessor.java +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/LygusRugulipennisModelPreprocessor.java @@ -41,7 +41,7 @@ import no.nibio.vips.util.weather.WeatherDataSourceUtil; * @copyright 2015 <a href="http://www.nibio.no/">NIBIO</a> * @author Tor-Einar Skog <tor-einar.skog@nibio.no> */ -public class LygusRuguliPennisModelPreprocessor extends ModelRunPreprocessor { +public class LygusRugulipennisModelPreprocessor extends ModelRunPreprocessor { @Override public ModelConfiguration getModelConfiguration(ForecastConfiguration configuration) throws PreprocessorException { diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties index a3a575ba47645859b48219088059c879b25fba29..dd9755905d9974358c02ab55c6108539c54dffb4 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts.properties @@ -397,3 +397,7 @@ pointOfInterestType=Point of Interest Type poiStored=Poi was stored pointOfInterestType_0=General noMapDataEntered=No map data entered +DELIARFOBS=Delia radicum/floralis observation model +DELIARFOBY=Delia radicum/floralis observation model for young crops +DELIARFOBO=Delia radicum/floralis observation model for old crops +startDateGrowth=Start date for growth diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties index 5547c89607ecd685695ae98871e60b47c25caa06..163839ccc758b357b28e1531f99e56bac58d7d56 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_bs.properties @@ -397,3 +397,7 @@ pointOfInterestType=Point of Interest Type poiStored=Poi was stored pointOfInterestType_0=General noMapDataEntered=No map data entered +DELIARFOBS=Delia radicum/floralis observation model +DELIARFOBY=Delia radicum/floralis observation model for young crops +DELIARFOBO=Delia radicum/floralis observation model for old crops +startDateGrowth=Start date for growth diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties index bc21fc56fbbe6daac0ecb445f475984710b4f913..ccc78a3a2a46d46e40414326eac1b5ea0b1eb667 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_hr.properties @@ -396,3 +396,7 @@ pointOfInterestType=Point of Interest Type poiStored=Poi was stored pointOfInterestType_0=General noMapDataEntered=No map data entered +DELIARFOBS=Delia radicum/floralis observation model +DELIARFOBY=Delia radicum/floralis observation model for young crops +DELIARFOBO=Delia radicum/floralis observation model for old crops +startDateGrowth=Start date for growth diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties index aa1b404731847c97729c880adf25e3838ee6fee4..a93dec752201e4a538173957607c0ada17f0768e 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_nb.properties @@ -397,3 +397,7 @@ pointOfInterestType=Stedstype poiStored=Stedet ble lagret pointOfInterestType_0=Generelt noMapDataEntered=Kartdata ikke registrert +DELIARFOBS=Liten og stor k\u00e5lflue - observasjonsmodell +DELIARFOBY=Liten og stor k\u00e5lflue - observasjonsmodell i nyplantede felt +DELIARFOBO=Liten og stor k\u00e5lflue - observasjonsmodell i felt eldre enn 4 uker +startDateGrowth=Dato for vekststart diff --git a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties index fae40f7bff0323182e932f5d3d50335549e09921..171403693681193dd18563ab7f2c1f09bef37258 100644 --- a/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties +++ b/src/main/resources/no/nibio/vips/logic/i18n/vipslogictexts_sr.properties @@ -397,3 +397,7 @@ pointOfInterestType=Point of Interest Type poiStored=Poi was stored pointOfInterestType_0=General noMapDataEntered=No map data entered +DELIARFOBS=Delia radicum/floralis observation model +DELIARFOBY=Delia radicum/floralis observation model for young crops +DELIARFOBO=Delia radicum/floralis observation model for old crops +startDateGrowth=Start date for growth diff --git a/src/main/webapp/formdefinitions/models/DELIARFOBO.json b/src/main/webapp/formdefinitions/models/DELIARFOBO.json new file mode 100644 index 0000000000000000000000000000000000000000..1403be2e085b3c3c87ebb7793da4360a08244587 --- /dev/null +++ b/src/main/webapp/formdefinitions/models/DELIARFOBO.json @@ -0,0 +1,28 @@ +{ + "_licenseNote": [ + "Copyright (c) 2016 NIBIO <http://www.nibio.no/>. ", + "", + "This file is part of VIPSLogic. ", + "VIPSLogic is free software: you can redistribute it and/or modify ", + "it under the terms of the NIBIO Open Source License as published by ", + "NIBIO, either version 1 of the License, or (at your option) any ", + "later version. ", + "", + "VIPSLogic 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 ", + "NIBIO Open Source License for more details. ", + "", + "You should have received a copy of the NIBIO Open Source License ", + "along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. " + ], + "_comment" : "Structure of the specific fields for DELIARFOBS", + "fields": [ + { + "name" : "startDateGrowth", + "dataType" : "DATE", + "dateFormat" : "yyyy-MM-dd", + "required" : true + } + ] +} diff --git a/src/main/webapp/formdefinitions/models/DELIARFOBS.json b/src/main/webapp/formdefinitions/models/DELIARFOBS.json new file mode 100644 index 0000000000000000000000000000000000000000..1403be2e085b3c3c87ebb7793da4360a08244587 --- /dev/null +++ b/src/main/webapp/formdefinitions/models/DELIARFOBS.json @@ -0,0 +1,28 @@ +{ + "_licenseNote": [ + "Copyright (c) 2016 NIBIO <http://www.nibio.no/>. ", + "", + "This file is part of VIPSLogic. ", + "VIPSLogic is free software: you can redistribute it and/or modify ", + "it under the terms of the NIBIO Open Source License as published by ", + "NIBIO, either version 1 of the License, or (at your option) any ", + "later version. ", + "", + "VIPSLogic 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 ", + "NIBIO Open Source License for more details. ", + "", + "You should have received a copy of the NIBIO Open Source License ", + "along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. " + ], + "_comment" : "Structure of the specific fields for DELIARFOBS", + "fields": [ + { + "name" : "startDateGrowth", + "dataType" : "DATE", + "dateFormat" : "yyyy-MM-dd", + "required" : true + } + ] +} diff --git a/src/main/webapp/formdefinitions/models/DELIARFOBY.json b/src/main/webapp/formdefinitions/models/DELIARFOBY.json new file mode 100644 index 0000000000000000000000000000000000000000..1403be2e085b3c3c87ebb7793da4360a08244587 --- /dev/null +++ b/src/main/webapp/formdefinitions/models/DELIARFOBY.json @@ -0,0 +1,28 @@ +{ + "_licenseNote": [ + "Copyright (c) 2016 NIBIO <http://www.nibio.no/>. ", + "", + "This file is part of VIPSLogic. ", + "VIPSLogic is free software: you can redistribute it and/or modify ", + "it under the terms of the NIBIO Open Source License as published by ", + "NIBIO, either version 1 of the License, or (at your option) any ", + "later version. ", + "", + "VIPSLogic 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 ", + "NIBIO Open Source License for more details. ", + "", + "You should have received a copy of the NIBIO Open Source License ", + "along with VIPSLogic. If not, see <http://www.nibio.no/licenses/>. " + ], + "_comment" : "Structure of the specific fields for DELIARFOBS", + "fields": [ + { + "name" : "startDateGrowth", + "dataType" : "DATE", + "dateFormat" : "yyyy-MM-dd", + "required" : true + } + ] +} diff --git a/src/main/webapp/templates/master.ftl b/src/main/webapp/templates/master.ftl index 030bbc2d57d58e2d10a285a9f96855e842c95d6b..dc8892e28eab09cc5635e532ad67906efec695c5 100644 --- a/src/main/webapp/templates/master.ftl +++ b/src/main/webapp/templates/master.ftl @@ -55,6 +55,7 @@ <#else> <li><a href="/user?action=viewUser&userId=${user.userId}">${i18nBundle.myAccount}</a></li> </#if> + <li><a href="/poi">${i18nBundle.pois}</a></li> <#if user.isOrganizationAdmin() || user.isSuperUser() || user.isMessageAuthor()> <li><a href="/message">${i18nBundle.messages}</a></li> </#if> diff --git a/src/main/webapp/templates/poiForm.ftl b/src/main/webapp/templates/poiForm.ftl index f385d9d58076e03594e2d055d6c6225627a78d9d..0e10b8f0d30454c471edd1d2df56efabc25f090f 100644 --- a/src/main/webapp/templates/poiForm.ftl +++ b/src/main/webapp/templates/poiForm.ftl @@ -122,6 +122,7 @@ <span class="help-block" id="${formId}_countryCode_validation"></span> </div> <fieldset> + <#if user.isSuperUser() || user.isOrganizationAdmin()> <h3>${i18nBundle.externalResources}</h3> <#if poi.pointOfInterestExternalResourceSet?has_content> <#list poi.pointOfInterestExternalResourceSet as poiExternalResource> @@ -139,6 +140,7 @@ </#list> </fieldset> + </#if> <#if user.isSuperUser()> <div class="form-group"> <label for="userId">${i18nBundle.vipsLogicUserId}</label> diff --git a/src/main/webapp/templates/poiList.ftl b/src/main/webapp/templates/poiList.ftl index d2901b7cb444f4a16c00e0349bdcbea0f2d88f8f..593d3b1f2888b6bef9dd8c36e861141daad63575 100644 --- a/src/main/webapp/templates/poiList.ftl +++ b/src/main/webapp/templates/poiList.ftl @@ -35,6 +35,10 @@ var organizationId = selectList.options[selectList.selectedIndex].value; window.location="/poi?organizationId=" + organizationId; } + + var userPoiIds = [ + <#list pois?sort_by("name") as poi>${poi.pointOfInterestId}<#sep>,</#list> + ]; </script> </#macro> <#macro page_contents>