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

Bugfix in using NORMAL data for service

parent ad4c1a3b
No related branches found
No related tags found
No related merge requests found
......@@ -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());
......
......@@ -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;
......
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment