Skip to content
Snippets Groups Projects
Commit ab387eb0 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Adding pois and DeliaRadicumFloralis model preprocessing

parent 4c480d4f
Branches
Tags
No related merge requests found
Showing
with 262 additions and 2 deletions
......@@ -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>
......
/*
* 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";
}
}
/*
* 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";
}
}
/*
* 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";
}
}
......@@ -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 {
......
......@@ -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
......@@ -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
......@@ -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
......@@ -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
......@@ -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
{
"_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
}
]
}
{
"_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
}
]
}
{
"_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
}
]
}
......@@ -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>
......
......@@ -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>
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment