diff --git a/src/main/java/no/nibio/vips/model/psilarosaetempmodel/PsilaRosaeTempModel.java b/src/main/java/no/nibio/vips/model/psilarosaetempmodel/PsilaRosaeTempModel.java index f9f1317ddf7f544310150d1178644af05b0df1d7..167bd5a6673a6628de1e886e8f4ba30408c14e01 100755 --- a/src/main/java/no/nibio/vips/model/psilarosaetempmodel/PsilaRosaeTempModel.java +++ b/src/main/java/no/nibio/vips/model/psilarosaetempmodel/PsilaRosaeTempModel.java @@ -19,8 +19,6 @@ package no.nibio.vips.model.psilarosaetempmodel; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.text.DecimalFormat; import java.util.ArrayList; @@ -223,8 +221,6 @@ public class PsilaRosaeTempModel extends I18nImpl implements Model { // Init data matrix this.dataMatrix = new DataMatrix(); - ObjectMapper mapper = new ObjectMapper(); - // Setting timezone this.timeZone = TimeZone.getTimeZone((String) config.getConfigParameter("timeZone")); //System.out.println("TimeZone=" + this.timeZone); @@ -232,9 +228,14 @@ public class PsilaRosaeTempModel extends I18nImpl implements Model { // Importing weather data, creating collections // Can accept both hourly and daily data WeatherUtil wUtil = new WeatherUtil(); - List<WeatherObservation> observations = mapper.convertValue(config.getConfigParameter("observations"), new TypeReference<List<WeatherObservation>>(){}); - for(WeatherObservation o:observations) + + List<WeatherObservation> observations = modelUtil.extractWeatherObservationList(config.getConfigParameter("observations")); + if(observations == null || observations.isEmpty()) { + throw new ConfigValidationException("Please provide weather data."); + } + for(WeatherObservation o:observations) + { switch(o.getElementMeasurementTypeId()) { case WeatherElements.TEMPERATURE_MEAN: @@ -260,7 +261,9 @@ public class PsilaRosaeTempModel extends I18nImpl implements Model { this.TM, this.timeZone, 15, - WeatherUtil.AGGREGATION_TYPE_AVERAGE); + WeatherUtil.AGGREGATION_TYPE_AVERAGE, + 0, + true); for(WeatherObservation obs:dailyTemperatures) { this.dataMatrix.setParamValueForDate(obs.getTimeMeasured(), DataMatrix.TMD, obs);