Package edu.ie3.datamodel.io.source.sql
Class SqlDataSource<T>
java.lang.Object
edu.ie3.datamodel.io.source.sql.SqlDataSource<T>
- Direct Known Subclasses:
SqlTimeSeriesMappingSource
,SqlTimeSeriesMetaInformationSource
,SqlTimeSeriesSource
,SqlWeatherSource
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected static String
createBaseQueryString
(String schemaName, String tableName) Creates a base query string without closing semicolon of the following pattern:
SELECT * FROM <schema>.<table>
createEntity
(Map<String, String> fieldToValues) Instantiates an entity produced by this source given the required field value map.executeQuery
(String query, edu.ie3.datamodel.io.source.sql.SqlDataSource.AddParams addParams) Executes the prepared statement after possibly adding parameters to the query using the given function.protected String
getDbColumnName
(String factoryColumnName, String tableName) Determine the corresponding database column name based on the provided factory field parameter name.getDbTables
(String schemaPattern, String tableNamePattern) Determine the corresponding table names based on the provided table name pattern.
-
Field Details
-
log
protected static final org.slf4j.Logger log
-
-
Constructor Details
-
SqlDataSource
-
-
Method Details
-
createBaseQueryString
Creates a base query string without closing semicolon of the following pattern:
SELECT * FROM <schema>.<table>
- Parameters:
schemaName
- the name of the database schematableName
- the name of the database table- Returns:
- basic query string without semicolon
-
getDbColumnName
Determine the corresponding database column name based on the provided factory field parameter name. Needed to support camel as well as snake case database column names.- Parameters:
factoryColumnName
- the name of the field parameter set in the entity factorytableName
- the table name where the data is stored- Returns:
- the column name that corresponds to the provided field parameter or an empty optional if no matching column can be found
-
getDbTables
Determine the corresponding table names based on the provided table name pattern.- Parameters:
schemaPattern
- pattern of the schema to search intableNamePattern
- pattern of the table name- Returns:
- matching table names
-
executeQuery
protected List<T> executeQuery(String query, edu.ie3.datamodel.io.source.sql.SqlDataSource.AddParams addParams) Executes the prepared statement after possibly adding parameters to the query using the given function. Finally, processes the results and creates a list of time based values via field map extraction.- Parameters:
query
- the query to useaddParams
- function that possibly adds parameters to query- Returns:
- a list of resulting entities
-
createEntity
Instantiates an entity produced by this source given the required field value map.- Parameters:
fieldToValues
- map of fields to their respective values- Returns:
- the entity if instantiation succeeds
-