-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change scheme of COSMO weather data #321
Changes from all commits
697f9da
fa0fc4a
15d9550
343b832
454420d
5365a79
c9a8c16
30699e2
b272635
6940eaf
ccd9418
5609e04
00859be
7995b54
2165981
2c1cc77
1cf83de
a8f1f98
8c6b2b6
6b351f0
a6d8fdd
da408e1
4dfbe0c
2075f1f
46019f2
6c97ff1
98ae220
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# The following file will be copied to a unix Docker image and imported to InfluxDB data base. Therefore, the line | ||
# ending plays a crucial role. This prevents the endings from being adjusted with 'core.autocrlf=true' | ||
src/test/resources/testContainerFiles/influxDb/weather.txt eol=lf | ||
src/test/resources/testContainerFiles/influxDb/cosmo/weather.txt eol=lf |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; | ||
import edu.ie3.datamodel.models.value.WeatherValue; | ||
import edu.ie3.util.interval.ClosedInterval; | ||
import edu.ie3.util.naming.NamingConvention; | ||
import java.sql.*; | ||
import java.time.ZonedDateTime; | ||
import java.util.*; | ||
|
@@ -24,6 +25,8 @@ | |
public class SqlWeatherSource extends SqlDataSource<TimeBasedValue<WeatherValue>> | ||
implements WeatherSource { | ||
private static final String WHERE = " WHERE "; | ||
/* Column names in sql come in "snake" case by default */ | ||
private static final NamingConvention DEFAULT_NAMING_CONVENTION = NamingConvention.SNAKE; | ||
|
||
private final IdCoordinateSource idCoordinateSource; | ||
private final String factoryCoordinateFieldName; | ||
|
@@ -38,39 +41,69 @@ public class SqlWeatherSource extends SqlDataSource<TimeBasedValue<WeatherValue> | |
private final String queryTimeAndCoordinate; | ||
private final String queryTimeIntervalAndCoordinates; | ||
|
||
/** | ||
* Initializes a new SqlWeatherSource. Uses {@link SqlWeatherSource#DEFAULT_NAMING_CONVENTION} as | ||
* naming convention. | ||
* | ||
* @param connector the connector needed for database connection | ||
* @param idCoordinateSource a coordinate source to map ids to points | ||
* @param schemaName the database schema to use | ||
* @param weatherTableName the name of the table containing weather data | ||
* @param weatherFactory instance of a time based weather value factory | ||
* @deprecated Use {@link SqlWeatherSource#SqlWeatherSource(SqlConnector, IdCoordinateSource, | ||
* String, String, NamingConvention, TimeBasedWeatherValueFactory)} instead | ||
*/ | ||
@Deprecated(since = "3.0", forRemoval = true) | ||
public SqlWeatherSource( | ||
SqlConnector connector, | ||
IdCoordinateSource idCoordinateSource, | ||
String schemaName, | ||
String weatherTableName, | ||
TimeBasedWeatherValueFactory weatherFactory) { | ||
this( | ||
connector, | ||
idCoordinateSource, | ||
schemaName, | ||
weatherTableName, | ||
DEFAULT_NAMING_CONVENTION, | ||
weatherFactory); | ||
} | ||
/** | ||
* Initializes a new SqlWeatherSource | ||
* | ||
* @param connector the connector needed for database connection | ||
* @param idCoordinateSource a coordinate source to map ids to points | ||
* @param schemaName the database schema to use | ||
* @param weatherTableName the name of the table containing weather data | ||
* @param namingConvention the (case) convention, how columns are named | ||
* @param weatherFactory instance of a time based weather value factory | ||
*/ | ||
public SqlWeatherSource( | ||
SqlConnector connector, | ||
IdCoordinateSource idCoordinateSource, | ||
String schemaName, | ||
String weatherTableName, | ||
NamingConvention namingConvention, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the current condition of this constructor is quite confusing, as the provided I think it'd be best to either use it for all columns of this data type or none, if we introduce such an api change here (this is the first PR to use |
||
TimeBasedWeatherValueFactory weatherFactory) { | ||
super(connector); | ||
this.idCoordinateSource = idCoordinateSource; | ||
this.weatherFactory = weatherFactory; | ||
this.factoryCoordinateFieldName = weatherFactory.getCoordinateIdFieldString(); | ||
|
||
/* Determine the correct column names in database */ | ||
String coordinateIdColumnName = weatherFactory.getCoordinateIdFieldString(namingConvention); | ||
String dbTimeColumnName = | ||
getDbColumnName(weatherFactory.getTimeFieldString(), weatherTableName); | ||
String dbCoordColumnName = getDbColumnName(factoryCoordinateFieldName, weatherTableName); | ||
|
||
// setup queries | ||
this.queryTimeInterval = | ||
createQueryStringForTimeInterval(schemaName, weatherTableName, dbTimeColumnName); | ||
this.queryTimeAndCoordinate = | ||
createQueryStringForTimeAndCoordinate( | ||
schemaName, weatherTableName, dbTimeColumnName, dbCoordColumnName); | ||
schemaName, weatherTableName, dbTimeColumnName, coordinateIdColumnName); | ||
this.queryTimeIntervalAndCoordinates = | ||
createQueryStringForTimeIntervalAndCoordinates( | ||
schemaName, weatherTableName, dbTimeColumnName, dbCoordColumnName); | ||
schemaName, weatherTableName, dbTimeColumnName, coordinateIdColumnName); | ||
} | ||
|
||
@Override | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in
SqlWeatherSource