From baab97cfd14f054083e3e800be0e6e081ec82cd6 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@nibio.no> Date: Tue, 17 Apr 2018 15:08:05 +0200 Subject: [PATCH] Bugfix in using NORMAL data for service --- .../vips/logic/modules/roughage/RoughageService.java | 12 ++++++++++++ .../preprocessor/FinnCerealModelsPreprocessor.java | 4 ---- .../vips/util/weather/WeatherDataSourceUtil.java | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java b/src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java index cfe05d63..c8cd224a 100755 --- a/src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java +++ b/src/main/java/no/nibio/vips/logic/modules/roughage/RoughageService.java @@ -369,6 +369,12 @@ public class RoughageService { Organization org = em.find(Organization.class, organizationId); Integer VIPSCoreUserId = org.getDefaultVipsCoreUserId(); + /*System.out.println("Antall ordinære værdata: " + observations.size()); + for(WeatherObservation obs:observations) + { + System.out.println(obs.toString()); + }*/ + List<Result> results; try { @@ -376,6 +382,7 @@ public class RoughageService { } catch(RunModelException ex) { + //System.out.println("Feilen skjer med ordinære værdata"); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(ex.getMessage()).build(); } // NORMALDATA @@ -402,6 +409,10 @@ public class RoughageService { latestObsDate ); + // The observations are tainted with the _NORMAL prefix, must clean up + // before sending to model + observations.stream().forEach(obs->obs.setElementMeasurementTypeId(obs.getElementMeasurementTypeId().substring(0, obs.getElementMeasurementTypeId().indexOf("_NORMAL")))); + // Add waterings to normal data precipitation? if( wateringAffectsNormalData != null && wateringAffectsNormalData.equals("true") @@ -418,6 +429,7 @@ public class RoughageService { //System.out.println("Old: " + obs.getValue() + ", new: " + (obs.getValue() + wateringMap.get(obs.getTimeMeasured()))); obs.setValue(obs.getValue() + wateringMap.get(obs.getTimeMeasured())); } + } } /*System.out.println("Antall normaldata: " + observations.size()); diff --git a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/FinnCerealModelsPreprocessor.java b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/FinnCerealModelsPreprocessor.java index 790d467b..d648ac9f 100644 --- a/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/FinnCerealModelsPreprocessor.java +++ b/src/main/java/no/nibio/vips/logic/scheduling/model/preprocessor/FinnCerealModelsPreprocessor.java @@ -2,10 +2,7 @@ package no.nibio.vips.logic.scheduling.model.preprocessor; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; -import java.util.HashSet; import java.util.List; import java.util.stream.Collectors; @@ -15,7 +12,6 @@ import no.nibio.vips.logic.entity.ForecastConfiguration; import no.nibio.vips.logic.entity.PointOfInterestWeatherStation; import no.nibio.vips.logic.scheduling.model.ModelRunPreprocessor; import no.nibio.vips.logic.scheduling.model.PreprocessorException; -import no.nibio.vips.model.ConfigValidationException; import no.nibio.vips.util.WeatherElements; import no.nibio.vips.util.WeatherObservationListException; import no.nibio.vips.util.WeatherUtil; diff --git a/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java b/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java index 3e94f1be..e79b30a8 100755 --- a/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java +++ b/src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java @@ -189,6 +189,7 @@ public class WeatherDataSourceUtil { URLOutput = IOUtils.toString(URLStream); List<WeatherObservation> preliminaryResult = this.getWeatherObservations(URLOutput); List<WeatherObservation> filteredObservations = new ArrayList<>(); + //System.out.println(this.getClass().getName() + "/preliminaryResult.size()=" + preliminaryResult.size()); preliminaryResult.stream().filter((candidateObs) -> ( candidateObs.getLogIntervalId().equals(logIntervalId) && Arrays.asList(elementMeasurementTypes).contains(candidateObs.getElementMeasurementTypeId()) @@ -196,6 +197,7 @@ public class WeatherDataSourceUtil { ).forEachOrdered((candidateObs) -> { filteredObservations.add(candidateObs); }); + //System.out.println(this.getClass().getName() + "/filteredObservations.size()=" + filteredObservations.size()); return filteredObservations; } catch (IOException ex) { StringBuilder errorMessage = new StringBuilder().append("Could not fetch weather observations from URI ").append(URL.toString()).append(".\n"); -- GitLab