Class CouchbaseWeatherSource

java.lang.Object
edu.ie3.datamodel.io.source.couchbase.CouchbaseWeatherSource
All Implemented Interfaces:
DataSource, WeatherSource

public class CouchbaseWeatherSource extends Object implements WeatherSource
Couchbase Source for weather data
  • 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 uses DEFAULT_KEY_PREFIX as key prefix and DEFAULT_TIMESTAMP_PATTERN as timestamp pattern.
      Parameters:
      connector - Connector, that establishes the connection to the couchbase instance
      coordinateSource - Source to obtain actual coordinates from
      coordinateIdColumnName - Name of the column containing the information about the coordinate identifier
      weatherFactory - 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 uses DEFAULT_KEY_PREFIX as key prefix.
      Parameters:
      connector - Connector, that establishes the connection to the couchbase instance
      coordinateSource - Source to obtain actual coordinates from
      coordinateIdColumnName - Name of the column containing the information about the coordinate identifier
      weatherFactory - Factory to transfer field to value mapping into actual java object instances
      timeStampPattern - 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 uses DEFAULT_TIMESTAMP_PATTERN as timestamp pattern.
      Parameters:
      connector - Connector, that establishes the connection to the couchbase instance
      coordinateSource - Source to obtain actual coordinates from
      keyPrefix - Prefix of entries, that belong to weather
      weatherFactory - 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 instance
      coordinateSource - Source to obtain actual coordinates from
      coordinateIdColumnName - Name of the column containing the information about the coordinate identifier
      keyPrefix - Prefix of entries, that belong to weather
      weatherFactory - Factory to transfer field to value mapping into actual java object instances
      timeStampPattern - 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 interface WeatherSource
      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 interface WeatherSource
      Parameters:
      timeInterval - Queried time interval
      coordinates - 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 interface WeatherSource
      Parameters:
      date - Queried date time
      coordinate - Queried coordinate
      Returns:
      weather data for the specified time and coordinate
    • generateWeatherKey

      public String generateWeatherKey(ZonedDateTime time, Integer coordinateId)
      Generates a key for weather documents with the pattern: weather::<coordinate_id>::<time>
      Parameters:
      time - the timestamp for the weather data
      coordinateId - 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 queried
      coordinateId - 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