From a421791eb4e331559fcb03afc265d30812bc1a7a Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@nibio.no>
Date: Tue, 28 Apr 2020 16:43:38 +0200
Subject: [PATCH] Fixing deserialization of Weather data

---
 .../vips/model/cerealmodels/FinnCerealModels.java     | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/main/java/fi/luke/vips/model/cerealmodels/FinnCerealModels.java b/src/main/java/fi/luke/vips/model/cerealmodels/FinnCerealModels.java
index 77e8de6..61cfabb 100644
--- a/src/main/java/fi/luke/vips/model/cerealmodels/FinnCerealModels.java
+++ b/src/main/java/fi/luke/vips/model/cerealmodels/FinnCerealModels.java
@@ -22,6 +22,7 @@ import no.nibio.vips.model.Model;
 import no.nibio.vips.model.ModelExcecutionException;
 import no.nibio.vips.model.ModelId;
 import no.nibio.vips.util.InvalidAggregationTypeException;
+import no.nibio.vips.util.ModelUtil;
 import no.nibio.vips.util.WeatherObservationListException;
 import no.nibio.vips.util.WeatherUtil;
 
@@ -345,12 +346,12 @@ public class FinnCerealModels extends I18nImpl implements Model {
 				m.setTimeTillageEffects(b);
 			}
 
+                        ModelUtil modelUtil = new ModelUtil();
 			// weather information
-                        ObjectMapper objectMapper = new ObjectMapper();
-			List<WeatherObservation> temperature = objectMapper.convertValue(arg0.getConfigParameter("temperature"), new TypeReference<List<WeatherObservation>>(){});
-			List<WeatherObservation> rainfall = objectMapper.convertValue(arg0.getConfigParameter("rainfall"), new TypeReference<List<WeatherObservation>>(){});
-			List<WeatherObservation> rh = objectMapper.convertValue(arg0.getConfigParameter("rh"), new TypeReference<List<WeatherObservation>>(){});
-			List<WeatherObservation> windSpeedAll = objectMapper.convertValue(arg0.getConfigParameter("windspeed"), new TypeReference<List<WeatherObservation>>(){});
+			List<WeatherObservation> temperature = modelUtil.extractWeatherObservationList(arg0.getConfigParameter("temperature"));//objectMapper.convertValue(arg0.getConfigParameter("temperature"), new TypeReference<List<WeatherObservation>>(){});
+			List<WeatherObservation> rainfall = modelUtil.extractWeatherObservationList(arg0.getConfigParameter("rainfall"));//objectMapper.convertValue(arg0.getConfigParameter("rainfall"), new TypeReference<List<WeatherObservation>>(){});
+			List<WeatherObservation> rh = modelUtil.extractWeatherObservationList(arg0.getConfigParameter("rh"));//objectMapper.convertValue(arg0.getConfigParameter("rh"), new TypeReference<List<WeatherObservation>>(){});
+			List<WeatherObservation> windSpeedAll = modelUtil.extractWeatherObservationList(arg0.getConfigParameter("windspeed"));//objectMapper.convertValue(arg0.getConfigParameter("windspeed"), new TypeReference<List<WeatherObservation>>(){});
 			WeatherUtil wu = new WeatherUtil();
 			// get average daily temperatures
 			try {
-- 
GitLab