java.lang.Object
io.openems.backend.timedata.timescaledb.internal.Utils

public class Utils extends Object
  • Method Details

    • getDataSource

      public static com.zaxxer.hikari.HikariDataSource getDataSource(String host, int port, String database, String user, String password, int poolSize) throws SQLException
      Creates a HikariDataSource connection pool.
      Parameters:
      host - the database hostname
      port - the database port
      database - the database name
      user - the database user
      password - the database password
      poolSize - the pool size
      Returns:
      the HikariDataSource
      Throws:
      SQLException - on error
    • querySchemaCache

      public static Map<Type,Map<Priority,Map<Integer,String>>> querySchemaCache(Schema schema, String edgeId, Set<String> channelAddresses)
      Gets the database Channel-IDs for the given Channel-Addresses from the Schema Cache.
      Parameters:
      schema - the Schema
      edgeId - the Edge-ID
      channelAddresses - a Set of Channel-Addresses
      Returns:
      a map of Types to Prioritys to Channel-IDs to Channel-Addresses
    • prepareDataMap

      public static TreeMap<ZonedDateTime,SortedMap<ChannelAddress,com.google.gson.JsonElement>> prepareDataMap(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels, Resolution resolution)
      Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.
      Parameters:
      fromDate - the From-Date
      toDate - the To-Date
      channels - the Channels
      resolution - the Resolution
      Returns:
      a prefilled result-map
    • prepareEnergyMap

      public static SortedMap<ChannelAddress,com.google.gson.JsonElement> prepareEnergyMap(ZonedDateTime fromDate, ZonedDateTime toDate, Set<ChannelAddress> channels)
      Prefills a Result-Map with JsonNull values for every timestamp/ChannelAddress.
      Parameters:
      fromDate - the From-Date
      toDate - the To-Date
      channels - the Channels
      Returns:
      a prefilled result-map
    • toSqlInterval

      public static String toSqlInterval(Resolution resolution)
      Converts a Resolution to an SQL interval.
      Parameters:
      resolution - the Resolution
      Returns:
      a SQL interval string