Class CouchbaseWeatherSource
java.lang.Object
edu.ie3.datamodel.io.source.couchbase.CouchbaseWeatherSource
- All Implemented Interfaces:
DataSource
,WeatherSource
Couchbase Source for weather data
-
Constructor Summary
ConstructorDescriptionCouchbaseWeatherSource
(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, TimeBasedWeatherValueFactory weatherFactory) Deprecated, for removal: This API element is subject to removal in a future version.CouchbaseWeatherSource
(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, TimeBasedWeatherValueFactory weatherFactory, String timeStampPattern) Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector.CouchbaseWeatherSource
(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, String keyPrefix, TimeBasedWeatherValueFactory weatherFactory) Deprecated, for removal: This API element is subject to removal in a future version.CouchbaseWeatherSource
(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, String keyPrefix, TimeBasedWeatherValueFactory weatherFactory, String timeStampPattern) Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector -
Method Summary
Modifier and TypeMethodDescriptioncreateQueryStringForIntervalAndCoordinate
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, int coordinateId) Create a query string to search for documents for the given coordinate in the given time interval by querying a range of document keysgenerateWeatherKey
(ZonedDateTime time, Integer coordinateId) Generates a key for weather documents with the pattern:weather::<coordinate_id>::<time>
Map<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval) Return the weather for the given time intervalMap<org.locationtech.jts.geom.Point,
IndividualTimeSeries<WeatherValue>> getWeather
(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates) Return the weather for the given time interval AND coordinatesgetWeather
(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate) Return the weather for the given time date AND coordinatetoTimeBasedWeatherValue
(com.couchbase.client.java.json.JsonObject jsonObj) Converts a JsonObject into a time based weather value by converting it to a TimeBasedWeatherValueData first, then using the TimeBasedWeatherValueFactory to create an entity
-
Constructor Details
-
CouchbaseWeatherSource
@Deprecated(since="3.0", forRemoval=true) public CouchbaseWeatherSource(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, TimeBasedWeatherValueFactory weatherFactory) Deprecated, for removal: This API element is subject to removal in a future version.Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector. This convenient constructor usesDEFAULT_KEY_PREFIX
as key prefix andDEFAULT_TIMESTAMP_PATTERN
as timestamp pattern.- Parameters:
connector
- Connector, that establishes the connection to the couchbase instancecoordinateSource
- Source to obtain actual coordinates fromcoordinateIdColumnName
- Name of the column containing the information about the coordinate identifierweatherFactory
- Factory to transfer field to value mapping into actual java object instances
-
CouchbaseWeatherSource
public CouchbaseWeatherSource(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, TimeBasedWeatherValueFactory weatherFactory, String timeStampPattern) Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector. This convenient constructor usesDEFAULT_KEY_PREFIX
as key prefix.- Parameters:
connector
- Connector, that establishes the connection to the couchbase instancecoordinateSource
- Source to obtain actual coordinates fromcoordinateIdColumnName
- Name of the column containing the information about the coordinate identifierweatherFactory
- Factory to transfer field to value mapping into actual java object instancestimeStampPattern
- Pattern of time stamps to parse
-
CouchbaseWeatherSource
@Deprecated(since="3.0", forRemoval=true) public CouchbaseWeatherSource(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, String keyPrefix, TimeBasedWeatherValueFactory weatherFactory) Deprecated, for removal: This API element is subject to removal in a future version.Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector. This convenient constructor usesDEFAULT_TIMESTAMP_PATTERN
as timestamp pattern.- Parameters:
connector
- Connector, that establishes the connection to the couchbase instancecoordinateSource
- Source to obtain actual coordinates fromkeyPrefix
- Prefix of entries, that belong to weatherweatherFactory
- Factory to transfer field to value mapping into actual java object instances
-
CouchbaseWeatherSource
public CouchbaseWeatherSource(CouchbaseConnector connector, IdCoordinateSource coordinateSource, String coordinateIdColumnName, String keyPrefix, TimeBasedWeatherValueFactory weatherFactory, String timeStampPattern) Instantiate a weather source utilising a connection to a couchbase instance obtained via the connector- Parameters:
connector
- Connector, that establishes the connection to the couchbase instancecoordinateSource
- Source to obtain actual coordinates fromcoordinateIdColumnName
- Name of the column containing the information about the coordinate identifierkeyPrefix
- Prefix of entries, that belong to weatherweatherFactory
- Factory to transfer field to value mapping into actual java object instancestimeStampPattern
- Pattern of time stamps to parse
-
-
Method Details
-
getWeather
public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval) Description copied from interface:WeatherSource
Return the weather for the given time interval- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
timeInterval
- Queried time interval- Returns:
- weather data for the specified time range, sorted by coordinate
-
getWeather
public Map<org.locationtech.jts.geom.Point,IndividualTimeSeries<WeatherValue>> getWeather(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, Collection<org.locationtech.jts.geom.Point> coordinates) Description copied from interface:WeatherSource
Return the weather for the given time interval AND coordinates- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
timeInterval
- Queried time intervalcoordinates
- Queried coordinates- Returns:
- weather data for the specified time range and coordinates, sorted by coordinate
-
getWeather
public Optional<TimeBasedValue<WeatherValue>> getWeather(ZonedDateTime date, org.locationtech.jts.geom.Point coordinate) Description copied from interface:WeatherSource
Return the weather for the given time date AND coordinate- Specified by:
getWeather
in interfaceWeatherSource
- Parameters:
date
- Queried date timecoordinate
- Queried coordinate- Returns:
- weather data for the specified time and coordinate
-
generateWeatherKey
Generates a key for weather documents with the pattern:weather::<coordinate_id>::<time>
- Parameters:
time
- the timestamp for the weather datacoordinateId
- the coordinate Id of the weather data- Returns:
- a weather document key
-
createQueryStringForIntervalAndCoordinate
public String createQueryStringForIntervalAndCoordinate(edu.ie3.util.interval.ClosedInterval<ZonedDateTime> timeInterval, int coordinateId) Create a query string to search for documents for the given coordinate in the given time interval by querying a range of document keys- Parameters:
timeInterval
- the time interval for which the documents are queriedcoordinateId
- the coordinate ID for which the documents are queried- Returns:
- the query string
-
toTimeBasedWeatherValue
public Optional<TimeBasedValue<WeatherValue>> toTimeBasedWeatherValue(com.couchbase.client.java.json.JsonObject jsonObj) Converts a JsonObject into a time based weather value by converting it to a TimeBasedWeatherValueData first, then using the TimeBasedWeatherValueFactory to create an entity- Parameters:
jsonObj
- the JsonObject to convert- Returns:
- an optional weather value
-
CouchbaseWeatherSource(CouchbaseConnector, IdCoordinateSource, String, TimeBasedWeatherValueFactory, String)
instead