Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
V
VIPSLogic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
VIPS
VIPSLogic
Commits
db941576
Commit
db941576
authored
8 years ago
by
Tor-Einar Skog
Browse files
Options
Downloads
Patches
Plain Diff
Changing to stream paradigm
parent
6027922b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java
+11
-11
11 additions, 11 deletions
...ava/no/nibio/vips/util/weather/WeatherDataSourceUtil.java
with
11 additions
and
11 deletions
src/main/java/no/nibio/vips/util/weather/WeatherDataSourceUtil.java
+
11
−
11
View file @
db941576
/*
/*
* Copyright (c) 201
5
NIBIO <http://www.nibio.no/>.
* Copyright (c) 201
7
NIBIO <http://www.nibio.no/>.
*
*
* This file is part of VIPSLogic.
* This file is part of VIPSLogic.
* VIPSLogic is free software: you can redistribute it and/or modify
* VIPSLogic is free software: you can redistribute it and/or modify
...
@@ -40,7 +40,7 @@ import no.nibio.vips.logic.scheduling.model.PreprocessorException;
...
@@ -40,7 +40,7 @@ import no.nibio.vips.logic.scheduling.model.PreprocessorException;
import
org.apache.commons.io.IOUtils
;
import
org.apache.commons.io.IOUtils
;
/**
/**
* @copyright 201
5
<a href="http://www.nibio.no/">NIBIO</a>
* @copyright 201
7
<a href="http://www.nibio.no/">NIBIO</a>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
* @author Tor-Einar Skog <tor-einar.skog@nibio.no>
*/
*/
public
class
WeatherDataSourceUtil
{
public
class
WeatherDataSourceUtil
{
...
@@ -72,13 +72,13 @@ public class WeatherDataSourceUtil {
...
@@ -72,13 +72,13 @@ public class WeatherDataSourceUtil {
List
<
WeatherObservation
>
forecasts
=
forecastProvider
.
getWeatherForecasts
(
station
);
List
<
WeatherObservation
>
forecasts
=
forecastProvider
.
getWeatherForecasts
(
station
);
Map
<
String
,
List
<
WeatherObservation
>>
obsMap
=
new
HashMap
<>();
Map
<
String
,
List
<
WeatherObservation
>>
obsMap
=
new
HashMap
<>();
for
(
String
elementMeasurementType
:
elementMeasurementTypes
)
{
for
(
String
elementMeasurementType
:
elementMeasurementTypes
)
{
obsMap
.
put
(
elementMeasurementType
,
new
ArrayList
<
WeatherObservation
>());
obsMap
.
put
(
elementMeasurementType
,
new
ArrayList
<>());
}
}
for
(
WeatherObservation
obs
:
forecasts
)
{
forecasts
.
stream
().
filter
((
obs
)
->
(
if
(
obs
.
getLogIntervalId
().
equals
(
logIntervalId
)
&&
obsMap
.
get
(
obs
.
getElementMeasurementTypeId
())
!=
null
)
{
obs
.
getLogIntervalId
().
equals
(
logIntervalId
)
&&
obsMap
.
get
(
obs
.
getElementMeasurementTypeId
())
!=
null
)
).
forEachOrdered
((
obs
)
->
{
obsMap
.
get
(
obs
.
getElementMeasurementTypeId
()).
add
(
obs
);
obsMap
.
get
(
obs
.
getElementMeasurementTypeId
()).
add
(
obs
);
}
});
}
Date
latestCommonDate
=
null
;
Date
latestCommonDate
=
null
;
for
(
String
elementMeasurementType
:
elementMeasurementTypes
)
{
for
(
String
elementMeasurementType
:
elementMeasurementTypes
)
{
List
<
WeatherObservation
>
paramObs
=
obsMap
.
get
(
elementMeasurementType
);
List
<
WeatherObservation
>
paramObs
=
obsMap
.
get
(
elementMeasurementType
);
...
@@ -149,11 +149,11 @@ public class WeatherDataSourceUtil {
...
@@ -149,11 +149,11 @@ public class WeatherDataSourceUtil {
URLOutput
=
IOUtils
.
toString
(
URLStream
);
URLOutput
=
IOUtils
.
toString
(
URLStream
);
List
<
WeatherObservation
>
preliminaryResult
=
this
.
getWeatherObservations
(
URLOutput
);
List
<
WeatherObservation
>
preliminaryResult
=
this
.
getWeatherObservations
(
URLOutput
);
List
<
WeatherObservation
>
filteredObservations
=
new
ArrayList
<>();
List
<
WeatherObservation
>
filteredObservations
=
new
ArrayList
<>();
for
(
WeatherObservation
candidateObs
:
preliminaryResult
)
{
preliminaryResult
.
stream
().
filter
((
candidateObs
)
->
(
if
(
candidateObs
.
getLogIntervalId
().
equals
(
logIntervalId
))
{
candidateObs
.
getLogIntervalId
().
equals
(
logIntervalId
))
).
forEachOrdered
((
candidateObs
)
->
{
filteredObservations
.
add
(
candidateObs
);
filteredObservations
.
add
(
candidateObs
);
}
});
}
return
filteredObservations
;
return
filteredObservations
;
}
catch
(
IOException
ex
)
{
}
catch
(
IOException
ex
)
{
StringBuilder
errorMessage
=
new
StringBuilder
().
append
(
"Could not fetch weather observations from URI "
).
append
(
URL
.
toString
()).
append
(
".\n"
);
StringBuilder
errorMessage
=
new
StringBuilder
().
append
(
"Could not fetch weather observations from URI "
).
append
(
URL
.
toString
()).
append
(
".\n"
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment