diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000000000000000000000000000000000000..0d56da1cc9a3bf898bb1b4e54de50b59ae093a1a --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,25 @@ +node { + + try { + stage('Checkout'){ + checkout scm + } + stage('Test'){ + sh 'mvn test' + } + stage('Build'){ + sh 'mvn install -DskipTests=true' + } + } + + catch (err) { + + throw err + } + + finally { + sh """ + """ + } +} + diff --git a/pom.xml b/pom.xml index ea5b44942a3122db8c7433effc1c4cfe152b846a..dff56c8d524612165e1c3ab310de9e09e201db23 100755 --- a/pom.xml +++ b/pom.xml @@ -142,6 +142,11 @@ <id>bedatadriven</id> <name>bedatadriven public repo</name> <url>https://nexus.bedatadriven.com/content/groups/public/</url> + </repository> + <repository> + <id>osgeo</id> + <name>OSGEO</name> + <url>https://download.osgeo.org/webdav/geotools/</url> </repository> <repository> <id>jitpack.io</id> diff --git a/src/main/java/no/nibio/vips/util/WeatherUtil.java b/src/main/java/no/nibio/vips/util/WeatherUtil.java index c45eb824b7750db0e86171260be7ff849ee673c6..8168a3e295da0826da84f93a7605433b503e20ba 100755 --- a/src/main/java/no/nibio/vips/util/WeatherUtil.java +++ b/src/main/java/no/nibio/vips/util/WeatherUtil.java @@ -228,8 +228,16 @@ public class WeatherUtil { return this.getAggregatedDailyValues(observations, timeZone, minimumObservationsPerDay, typeOfAggregation, 0); } + public List<WeatherObservation> getAggregatedDailyValues( + List<WeatherObservation> observations, TimeZone timeZone, Integer minimumObservationsPerDay, Integer typeOfAggregation, Integer maxDuplicates) + throws WeatherObservationListException, + InvalidAggregationTypeException + { + return this.getAggregatedDailyValues(observations, timeZone, minimumObservationsPerDay, typeOfAggregation, maxDuplicates, false); + } + /** - * Aggregates daily values. Can be set to tolerate duplicates + * Aggregates daily values. Can be set to tolerate duplicates and to ignore errors * @param observations the value of observations * @param timeZone the value of timeZone * @param minimumObservationsPerDay the value of minimumObservationsPerDay @@ -238,7 +246,7 @@ public class WeatherUtil { * @return the java.util.List<no.nibio.vips.entity.WeatherObservation> */ public List<WeatherObservation> getAggregatedDailyValues( - List<WeatherObservation> observations, TimeZone timeZone, Integer minimumObservationsPerDay, Integer typeOfAggregation, Integer maxDuplicates) + List<WeatherObservation> observations, TimeZone timeZone, Integer minimumObservationsPerDay, Integer typeOfAggregation, Integer maxDuplicates, Boolean skipDaysWithTooFewObservations) throws WeatherObservationListException, InvalidAggregationTypeException { @@ -298,20 +306,23 @@ public class WeatherUtil { { //System.out.println("date=" + aDay); Map hourValuesForADay = dateBucket.get(aDay); - // We accept less than minimum values for the last day (we don't throw an error) - if(hourValuesForADay.size() < minimumObservationsPerDay && aDay.compareTo(lastDate) < 0) + + if(hourValuesForADay.size() < minimumObservationsPerDay) { - throw new WeatherObservationListException( + // We accept less than minimum values for the last day (we don't throw an error) + if(skipDaysWithTooFewObservations || aDay.compareTo(lastDate) == 0) + { + continue; + } + else + { + throw new WeatherObservationListException( "Too few observations to aggregate for parameter " + templateObservation.getElementMeasurementTypeId() + " at date " + aDay +". Found " + hourValuesForADay.size() + ", expected minimum " + minimumObservationsPerDay ); - } - // If last day and too few values: Skip it - else if(hourValuesForADay.size() < minimumObservationsPerDay) - { - continue; + } } switch(typeOfAggregation){ case WeatherUtil.AGGREGATION_TYPE_AVERAGE: