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

first commit

parents
No related branches found
No related tags found
No related merge requests found
target/
classes/
<?xml version="1.0" encoding="UTF-8"?>
<project-shared-configuration>
<!--
This file contains additional configuration written by modules in the NetBeans IDE.
The configuration is intended to be shared among all the users of project and
therefore it is assumed to be part of version control checkout.
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
-->
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
<!--
Properties that influence various parts of the IDE, especially code formatting and the like.
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.license>nibio_open_source_license.ftl</netbeans.hint.license>
</properties>
</project-shared-configuration>
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>no.bioforsk.vips.model</groupId>
<artifactId>SeptoriaApiicolaModel</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>no.nibio.vips.common</groupId>
<artifactId>VIPSCommon</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project>
\ No newline at end of file
/*
* Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
*
* This file is part of SeptoriaApiicolaModel.
* SeptoriaApiicolaModel 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.
*
* SeptoriaApiicolaModel 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 SeptoriaApiicolaModel. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.model.septoriaapiicolamodel;
import no.nibio.vips.util.DateMap;
/**
* @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class DataMatrix extends DateMap{
public final static String BT = "BT";
public final static String WET_DAY = "WET_DAY";
public final static String PEST_OBSERVED = "PEST_OBSERVED";
}
/*
* Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
*
* This file is part of SeptoriaApiicolaModel.
* SeptoriaApiicolaModel 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.
*
* SeptoriaApiicolaModel 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 SeptoriaApiicolaModel. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.model.septoriaapiicolamodel;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.entity.ResultImpl;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.i18n.I18nImpl;
import no.nibio.vips.model.ConfigValidationException;
import no.nibio.vips.model.Model;
import no.nibio.vips.model.ModelExcecutionException;
import no.nibio.vips.model.ModelId;
import no.nibio.vips.observation.Observation;
import no.nibio.vips.observation.ObservationImpl;
import no.nibio.vips.util.ModelUtil;
import no.nibio.vips.util.WeatherUtil;
/**
* Model developed in 2011 by Berit Nordskog and Arne Hermansen, NIBIO Division Biotechnology and Plant Health
* Based on Lacy, M.L. 1994. Influence of wetness periods on infection of celery
* by Septoria apiicola and use in timing sprays for control. Plant Disease 78, 975-979.
* Weather criteria: Minimum 12 consecutive hours with leaf wetness > 48 (minutes/hour) gives infection risk
* If weather conditions are met, the infection risk is considered high if at lease one disease observation
* has been made in the field in the same season, moderate otherwise.
* @copyright 2016 <a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
public class SeptoriaApiicolaModel extends I18nImpl implements Model{
private final static ModelId MODEL_ID = new ModelId("SEPAPIICOL");
private final static Integer NIGHT_STARTS_AT_HOUR = 13;
private final static Integer MINIMUM_LW_VALUE = 48;
private final static Integer MINIMUM_CONSECUTIVE_WET_HOURS = 12;
private ObjectMapper objectMapper;
private final ModelUtil modelUtil;
private DataMatrix dataMatrix;
private List<Observation> pestObservations;
private TimeZone timeZone;
public SeptoriaApiicolaModel()
{
super("no.nibio.vips.model.septoriaapiicolamodel.texts");
this.modelUtil = new ModelUtil();
}
@Override
public List<Result> getResult() throws ModelExcecutionException {
this.calculateLeafWetnessConditions();
Observation firstSeasonPestObservation = this.getFirstSeasonPestObservation();
Date firstSeasonPestObservationDate = firstSeasonPestObservation != null ?
new WeatherUtil().normalizeToExactDate(firstSeasonPestObservation.getTimeOfObservation(), this.timeZone)
: null;
System.out.println(this.dataMatrix.toCSV());
Date currentDate = this.dataMatrix.getFirstDateWithParameterValue(DataMatrix.WET_DAY);
Date endDate = this.dataMatrix.getLastDateWithParameterValue(DataMatrix.WET_DAY);
Calendar cal = Calendar.getInstance(timeZone);
List<Result> retVal = new ArrayList<>();
while(currentDate.compareTo(endDate) <= 0)
{
Result result = new ResultImpl();
result.setResultValidTime(currentDate);
Integer warningStatus = Result.WARNING_STATUS_NO_RISK;
if(this.dataMatrix.getParamStringValueForDate(currentDate, DataMatrix.WET_DAY).equals(Boolean.TRUE.toString()))
{
// We have wet day. Status MINOR or HIGH RISK is decided based on season pest observation(s)
if(firstSeasonPestObservationDate == null || currentDate.before(firstSeasonPestObservationDate))
{
warningStatus = Result.WARNING_STATUS_MINOR_RISK;
}
else
{
warningStatus = Result.WARNING_STATUS_HIGH_RISK;
}
}
result.setWarningStatus(warningStatus);
result.setValue(SeptoriaApiicolaModel.MODEL_ID.toString(), DataMatrix.WET_DAY, this.dataMatrix.getParamStringValueForDate(currentDate, DataMatrix.WET_DAY).equals(Boolean.TRUE.toString()) ? "1" : "0");
result.setValue(SeptoriaApiicolaModel.MODEL_ID.toString(), DataMatrix.PEST_OBSERVED,
this.dataMatrix.getParamIntValueForDate(currentDate, DataMatrix.PEST_OBSERVED) != null ?
String.valueOf(this.dataMatrix.getParamIntValueForDate(currentDate, DataMatrix.PEST_OBSERVED))
: "0"
);
retVal.add(result);
// Moving on
cal.setTime(currentDate);
cal.add(Calendar.DATE, 1);
currentDate = cal.getTime();
}
return retVal;
}
@Override
public ModelId getModelId() {
return SeptoriaApiicolaModel.MODEL_ID;
}
@Override
public String getModelName() {
return this.getModelName(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelName(String language) {
return this.getText("name", language);
}
@Override
public String getLicense() {
return "\n" +
"Copyright (c) 2016 NIBIO <http://www.nibio.no/>. \n" +
"\n" +
"This file is part of SeptoriaApiicolaModel.\n" +
"SeptoriaApiicolaModel is free software: you can redistribute it and/or modify\n" +
"it under the terms of the NIBIO Open Source License as published by \n" +
"NIBIO, either version 1 of the License, or (at your option) any\n" +
"later version.\n" +
"\n" +
"SeptoriaApiicolaModel is distributed in the hope that it will be useful,\n" +
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +
"NIBIO Open Source License for more details.\n" +
"\n" +
"You should have received a copy of the NIBIO Open Source License\n" +
"along with SeptoriaApiicolaModel. If not, see <http://www.nibio.no/licenses/>.";
}
@Override
public String getCopyright() {
return "(c) 2016 NIBIO (http://www.nibio.no/). Contact: post@nibio.no";
}
@Override
public String getModelDescription() {
return this.getModelDescription(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelDescription(String language) {
try
{
return this.modelUtil.getTextWithBase64EncodedImages(this.getText("description", language), this.getClass());
}
catch(IOException ex)
{
return this.getText("description", language);
}
}
@Override
public String getWarningStatusInterpretation() {
return this.getWarningStatusInterpretation(Model.DEFAULT_LANGUAGE);
}
@Override
public String getWarningStatusInterpretation(String language) {
return this.getText("statusInterpretation", language);
}
@Override
public String getModelUsage() {
return this.getModelUsage(Model.DEFAULT_LANGUAGE);
}
@Override
public String getModelUsage(String language) {
return this.getText("usage", language);
}
@Override
public String getSampleConfig() {
return "{\n" +
"\t\"loginInfo\":{\n" +
"\t\t\"username\":\"example\",\n" +
"\t\t\"password\":\"example\"\n" +
"\t},\n" +
"\t\"modelId\":\"" + MODEL_ID.toString() + "\",\n" +
"\t\"configParameters\":{\n" +
"\t\t\"timeZone\":\"Europe/Oslo\",\n" +
"\t\t\"startDateGrowth\":\"2012-03-25\",\n" +
"\t\t\"endDateCalculation\":\"2012-03-25\",\n" +
"\t\t\"pestObservations\":[\n" +
"\t\t\t{" +
"\t\t\t\t\"timeOfObservation\":\"2016-04-20T00:00:00+02:00\"," +
"\t\t\t\t\"observationData\":{}" +
"\t\t\t\"}" +
"\t\t],\n" +
"\t\t\"observations\":[\n" +
"\t\t{\n" +
"\t\t\t\t\"timeMeasured\": \"2016-06-20T00:00:00+02:00\",\n" +
"\t\t\t\t\"elementMeasurementTypeId\":\"BT\",\n" +
"\t\t\t\t\"logIntervalId\":1,\n" +
"\t\t\t\t\"value\":48\n" +
"\t\t}\n" +
"\t\t]\n" +
"\t}\n" +
"}\n";
}
@Override
public void setConfiguration(ModelConfiguration config) throws ConfigValidationException {
this.dataMatrix = new DataMatrix();
WeatherUtil wUtil = new WeatherUtil();
this.getObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
this.timeZone = TimeZone.getTimeZone((String) config.getConfigParameter("timeZone"));
this.pestObservations = this.getObjectMapper().convertValue(config.getConfigParameter("pestObservations"), new TypeReference<List<ObservationImpl>>(){});
if(this.pestObservations != null && ! this.pestObservations.isEmpty())
{
for(Observation o:this.pestObservations)
{
this.dataMatrix.setParamIntValueForDate(wUtil.normalizeToExactHour(o.getTimeOfObservation(), timeZone), DataMatrix.PEST_OBSERVED, 1);
}
}
// Setting timezone
// Getting weather data
List<WeatherObservation> observations = this.getObjectMapper().convertValue(config.getConfigParameter("observations"), new TypeReference<List<WeatherObservation>>(){});
for(WeatherObservation o:observations)
{
if(o.getElementMeasurementTypeId().equals(DataMatrix.BT))
{
this.dataMatrix.setParamDoubleValueForDate(o.getTimeMeasured(), o.getElementMeasurementTypeId(), o.getValue());
}
}
}
private ObjectMapper getObjectMapper()
{
if(this.objectMapper == null)
{
this.objectMapper = new ObjectMapper();
}
return this.objectMapper;
}
/**
*
* @return date of the first pest observation the current season. Null if none found
*/
private Observation getFirstSeasonPestObservation() {
// What's the season?
// Assuming season starts the same year as first weather data
Calendar cal = Calendar.getInstance(this.timeZone);
cal.setTime(this.dataMatrix.getFirstDateWithParameterValue(DataMatrix.BT));
cal.set(cal.get(Calendar.YEAR), 0, 1, 0, 0, 0);
Date seasonStart = cal.getTime();
if(this.pestObservations != null && ! this.pestObservations.isEmpty())
{
Collections.sort(pestObservations);
for(Observation o:pestObservations)
{
if(o.getTimeOfObservation().after(seasonStart))
{
return o;
}
}
}
return null;
}
private void calculateLeafWetnessConditions() throws ModelExcecutionException {
Calendar cal = Calendar.getInstance(timeZone);
WeatherUtil wUtil = new WeatherUtil();
cal.setTime(wUtil.normalizeToExactDate(this.dataMatrix.getFirstDateWithParameterValue(DataMatrix.BT), timeZone));
// Add two days to be sure to have complete weather data
cal.add(Calendar.DATE, 2);
Date currentDate = cal.getTime();
Date lastLeafWetnessTimestamp = this.dataMatrix.getLastDateWithParameterValue(DataMatrix.BT);
while(currentDate.before(lastLeafWetnessTimestamp))
{
cal.setTime(currentDate);
cal.set(Calendar.HOUR_OF_DAY,23);
cal.set(Calendar.MINUTE,59);
Date endOfCurrentDay = cal.getTime();
cal.set(Calendar.MINUTE, 0);
cal.add(Calendar.DATE, -1);
cal.set(Calendar.HOUR_OF_DAY, SeptoriaApiicolaModel.NIGHT_STARTS_AT_HOUR);
Date startOfYesterdayData = cal.getTime();
Boolean wetConditionsMet = this.isWetConditionsMet(startOfYesterdayData, endOfCurrentDay);
this.dataMatrix.setParamStringValueForDate(currentDate, DataMatrix.WET_DAY, wetConditionsMet.toString());
// Moving forward
cal.setTime(currentDate);
cal.add(Calendar.DATE, 1);
currentDate = cal.getTime();
}
}
private Boolean isWetConditionsMet(Date startOfYesterdayData, Date endOfCurrentDay) throws ModelExcecutionException {
Calendar cal = Calendar.getInstance(timeZone);
Date currentHour = startOfYesterdayData;
Integer consecutiveWetHours = 0;
while(currentHour.before(endOfCurrentDay))
{
Double hourLeafWetness = this.dataMatrix.getParamDoubleValueForDate(currentHour, DataMatrix.BT);
if(hourLeafWetness == null)
{
throw new ModelExcecutionException("Missing leaf wetness at " + currentHour);
}
if(hourLeafWetness >= SeptoriaApiicolaModel.MINIMUM_LW_VALUE)
{
consecutiveWetHours++;
}
else
{
consecutiveWetHours = 0;
}
if(consecutiveWetHours >= SeptoriaApiicolaModel.MINIMUM_CONSECUTIVE_WET_HOURS)
{
return true;
}
cal.setTime(currentHour);
cal.add(Calendar.HOUR_OF_DAY, 1);
currentHour = cal.getTime();
}
return false;
}
}
# Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
#
# This file is part of MamestraBrassicaeModel.
# MamestraBrassicaeModel 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.
#
# MamestraBrassicaeModel 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 MamestraBrassicaeModel. If not, see <http://www.nibio.no/licenses/>.
#
name=Septoria apiicola model
description=TODO
statusInterpretation=TODO
usage=TODO
name=Selleribladflekkmodell
description=TODO
statusInterpretation=TODO
usage=TODO
/*
* Copyright (c) 2016 NIBIO <http://www.nibio.no/>.
*
* This file is part of SeptoriaApiicolaModel.
* SeptoriaApiicolaModel 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.
*
* SeptoriaApiicolaModel 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 SeptoriaApiicolaModel. If not, see <http://www.nibio.no/licenses/>.
*
*/
package no.bioforsk.vips.model.septoriaapiicolamodel;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MappingJsonFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;
import static junit.framework.Assert.fail;
import no.nibio.vips.entity.ModelConfiguration;
import no.nibio.vips.entity.Result;
import no.nibio.vips.entity.WeatherObservation;
import no.nibio.vips.model.ModelId;
import no.nibio.vips.observation.Observation;
import no.nibio.vips.observation.ObservationImpl;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author treinar
*/
public class SeptoriaApiicolaModelTest {
public SeptoriaApiicolaModelTest() {
}
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of getResult method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetResult() throws Exception {
System.out.println("getResult");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
ModelConfiguration config = this.getConfiguration("/aas_2015.json");
ObservationImpl obs = new ObservationImpl();
Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("Europe/Oslo"));
cal.set(2015, Calendar.JULY, 15, 12, 2, 0);
Date obsDate = cal.getTime();
obs.setTimeOfObservation(obsDate);
obs.setName("TEST");
List<Observation> pestObservations = new ArrayList<>();
pestObservations.add(obs);
config.setConfigParameter("pestObservations", pestObservations);
instance.setConfiguration(config);
List<Result> result = instance.getResult();
/*for(Result res:result)
{
System.out.println(res.toString());
}*/
assertNotNull(result);
}
/**
* Test of getModelId method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetModelId() {
System.out.println("getModelId");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
ModelId expResult = new ModelId("SEPAPIICOL");
ModelId result = instance.getModelId();
assertEquals(expResult.toString(), result.toString());
}
/**
* Test of getModelName method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetModelName_0args() {
System.out.println("getModelName");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getModelName();
assertNotNull(result);
}
/**
* Test of getLicense method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetLicense() {
System.out.println("getLicense");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getLicense();
assertNotNull(result);
}
/**
* Test of getCopyright method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetCopyright() {
System.out.println("getCopyright");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getCopyright();
assertNotNull(result);
}
/**
* Test of getModelDescription method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetModelDescription_0args() {
System.out.println("getModelDescription");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getModelDescription();
assertNotNull(result);
}
/**
* Test of getWarningStatusInterpretation method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetWarningStatusInterpretation_0args() {
System.out.println("getWarningStatusInterpretation");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getWarningStatusInterpretation();
assertNotNull(result);
}
/**
* Test of getModelUsage method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetModelUsage_0args() {
System.out.println("getModelUsage");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getModelUsage();
assertNotNull(result);
}
/**
* Test of getSampleConfig method, of class SeptoriaApiicolaModel.
*/
@Test
public void testGetSampleConfig() {
System.out.println("getSampleConfig");
SeptoriaApiicolaModel instance = new SeptoriaApiicolaModel();
String result = instance.getSampleConfig();
assertNotNull(result);
}
private ModelConfiguration getConfiguration(String fileName)
{
try {
ModelConfiguration config = new ModelConfiguration();
config.setModelId("NEGPROGMOD");
config.setConfigParameter("timeZone", "Europe/Oslo");
BufferedInputStream inputStream = new BufferedInputStream(this.getClass().getResourceAsStream(fileName));
JsonFactory f = new MappingJsonFactory();
JsonParser jp = f.createParser(inputStream);
JsonNode all = jp.readValueAsTree();
List<WeatherObservation> observations = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
Date firstDate = null;
Date lastDate = null;
if(all.isArray())
{
for(JsonNode node : all){
Date timeMeasured = (Date)mapper.convertValue(node.get("timeMeasured").asText(), new TypeReference<Date>(){});
if(firstDate == null || firstDate.compareTo(timeMeasured) > 0)
{
firstDate = timeMeasured;
}
if(lastDate == null || lastDate.compareTo(timeMeasured) < 0)
{
lastDate = timeMeasured;
}
//System.out.println(node.toString());
WeatherObservation observation = new WeatherObservation();
observation.setTimeMeasured(timeMeasured);
observation.setLogIntervalId(node.get("logIntervalId").asInt());
observation.setElementMeasurementTypeId(node.get("elementMeasurementTypeId").asText());
observation.setValue(node.get("value").asDouble());
observations.add(observation);
}
}
else
{
fail("Data input from file is not a JSON array");
}
config.setConfigParameter("observations", observations);
return config;
} catch (IOException ex) {
ex.printStackTrace();
return null;
}
}
}
Source diff could not be displayed: it is too large. Options to address this: view the blob.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment