-
Notifications
You must be signed in to change notification settings - Fork 16
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
Fixes #634 - Implemented data entry date option for TS data retrieval #927
base: develop
Are you sure you want to change the base?
Conversation
…on bug in progress
cwms-data-api/src/main/java/cwms/cda/api/TimeSeriesController.java
Outdated
Show resolved
Hide resolved
@@ -248,6 +256,11 @@ public static class Record { | |||
@JsonProperty(value = "quality-code", index = 2) | |||
int qualityCode; | |||
|
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.
This might be better as a sub class. I know that adds some complex but eventually we may also want to include the version date and text notes that may be attached and that would be a lot of logic in this one class.
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.
Changed to a subclass. I added a custom deserializer to handle the different classes.
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.
Okay, so I said this, Adam said this, but after reading the code and our other discussions above timeseries does it make more sense to just make TimeSeries more generic?
e.g.
A builder where you manually add column names, index, and type, and and functions in the row builder to set such?
something like
withColumn(int index, String name, String description, Class<T> type) {
"logic"
}
... Record:
<T> setColumn(int index, T value, Class<T> type) {
"logic"
}
Or something like that, it would prevent the need in TimeSeriesDaoImpl have two different loops doing almost 90% the same work. just a check for "I have this column requested, let's also add it."
Basically instead of hard coding the columns at all (okay, maybe time... is a time series) , the user of the given TimeSeries object (after set by builder) can define them at run-time.
Sorry, I know you did a lot here, that just came to me now looking through the current PR.
…dle custom output, adds data entry date support
@jbkolze what are your thoughts on this? At least how it's done. Some appears it may be a breaking change which we want to avoid. |
cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java
Outdated
Show resolved
Hide resolved
Conceptually, I don't personally have any qualms with it. You had mentioned in the typing discussion that you all were trying to leave flexibility for dynamically adjusting the time series values array, and this seems like a prime use case for that. That being said, I am a little concerned about the part you marked as a breaking change. I don't know the CDA source that well, but is this indicating that the response would include a fourth null value even if the include_entry_date is false? Because that definitely would not be ideal -- we've written a lot of CDA code already (and I think other districts have as well) that would have to be updated. Not as big of a deal if an API version were included in the path ( My understanding from previous conversations is that you'd get the normal 3-value array if this were set to false, but receive a 4-value array if include_entry_date is true. And the "value-columns" object would be updated to match. That'd be my "ideal" implementation. |
You are correct that setting the include_entry_date parameter to true would result in a four-value array, whereas setting it to false would return a three-value array. Your "ideal" implementation is what I was aiming for to retain backwards compatibility and avoid breaking any of the other endpoints that rely on the TimeSeries implementation. |
tsRecord.getValue(qualityNormCol).intValue() | ||
) | ||
); | ||
if (includeEntryDate) { |
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.
This query is doubling the time it takes to retrieve time series. Can this replace the retrieve_ts_out_tab
calls?
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.
While it could replace the retrieve_ts_out_tab
call above, doing so would require implementing trim support into the query, as that is currently handled by the retrieve_ts_out_tab
call. I haven't quite figured out the best way to do so, so maybe we can discuss this in more detail
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.
if the schema needs to provide more, we can update the schema call
cwms-data-api/src/main/java/cwms/cda/formatters/json/adapters/TimeSeriesRecordDeserializer.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/formatters/json/adapters/TimeSeriesRecordDeserializer.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/formatters/json/adapters/TimeSeriesRecordDeserializer.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java
Outdated
Show resolved
Hide resolved
That is correct for the location indicated, which is location levels backed by a time series. I don't know how much it would affect what you're currently using, but it's definitely not ideal. At the least it definitely shouldn't be null, may as well provide the data, but seems like a parameter should be added to match on the location level end point. But it sounds like your on the same page with Adam about the shape being already explicitly flexible so I'm okay with that section now; not "ideal", but what is, definitely something to better document though. |
}); | ||
logger.fine(() -> query2.getSQL(ParamType.INLINED)); | ||
final TimeSeriesWithDate timeSeries = new TimeSeriesWithDate(timeseries); | ||
query2.forEach(tsRecord -> timeSeries.addValue( |
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.
we don't need to solve this now, but definitely before we add requesting any text notes as well. There has to be a better way to handle this with the builders.
if (pageSize != 0) { | ||
if (versionDate != null) { | ||
whereCond = whereCond.and(AV_TSV_DQU.AV_TSV_DQU.VERSION_DATE.eq(versionDate == null ? null : |
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.
Does this logic handle max version? or will AV_TSV_DQU always return every version? or only the specifically requested version?
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.
Updated logic to handle max version in line with previous implementation. If the version date is not specified, the max version will be set to true and the most recent version date will be used for retrieval. This does prevent retrieval of multiple versions in one call, so that could be a problem if that is a desired feature.
@@ -248,6 +256,11 @@ public static class Record { | |||
@JsonProperty(value = "quality-code", index = 2) | |||
int qualityCode; | |||
|
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.
Okay, so I said this, Adam said this, but after reading the code and our other discussions above timeseries does it make more sense to just make TimeSeries more generic?
e.g.
A builder where you manually add column names, index, and type, and and functions in the row builder to set such?
something like
withColumn(int index, String name, String description, Class<T> type) {
"logic"
}
... Record:
<T> setColumn(int index, T value, Class<T> type) {
"logic"
}
Or something like that, it would prevent the need in TimeSeriesDaoImpl have two different loops doing almost 90% the same work. just a check for "I have this column requested, let's also add it."
Basically instead of hard coding the columns at all (okay, maybe time... is a time series) , the user of the given TimeSeries object (after set by builder) can define them at run-time.
Sorry, I know you did a lot here, that just came to me now looking through the current PR.
Build errors appear to be unrelated to these changes |
cwms-data-api/src/main/java/cwms/cda/api/TimeSeriesController.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/data/dto/TimeSeriesWithDate.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/main/java/cwms/cda/data/dto/TimeSeriesWithDate.java
Outdated
Show resolved
Hide resolved
@FormattableWith(contentType = Formats.XMLV2, formatter = XMLv2.class, aliases = {Formats.XML}) | ||
public final class TimeSeriesWithDate extends TimeSeries { | ||
|
||
private List<TimeSeriesWithDate.Record> values; |
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.
should be able to reuse the parent's values since there is inheritance
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.
Needed to add the local variables to get the typing correct. Removing it causes loss of type within the List, which drops the data entry date value.
cwms-data-api/src/main/java/cwms/cda/data/dto/TimeSeriesWithDate.java
Outdated
Show resolved
Hide resolved
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.
Post/Patch should throw an error if the client is sending a time series with a data-entry-date as that field isn't editable
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.
Added a check for data entry date values
cwms-data-api/src/test/resources/cwms/cda/api/lrl/1day_offset_version_date.json
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/data/dao/TimeSeriesDaoTest.java
Outdated
Show resolved
Hide resolved
cwms-data-api/src/test/java/cwms/cda/api/TimeseriesControllerTestIT.java
Show resolved
Hide resolved
…e values with data entry date
Fixes #634 - Implements data entry date as option for TimeSeries data retrieval - Serialization bug in progress