-
Notifications
You must be signed in to change notification settings - Fork 14
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
Feature/time series profile dto #733
Draft
AndreasChristmann
wants to merge
29
commits into
USACE:develop
Choose a base branch
from
AndreasChristmann:feature/TimeSeriesProfileDto
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1b8b925
ts profile json
AndreasChristmann 32c0927
ts profile json
AndreasChristmann 7b61ef3
ts profile json
AndreasChristmann ab58110
ts profile json
AndreasChristmann 15fdef1
sample time series profile data
AndreasChristmann 88d5079
time series profile dto's
AndreasChristmann 994c908
time series profile dao's
AndreasChristmann 2f32183
time series profile dto's unit test
AndreasChristmann 8fbcb4e
time series profile dao integration test
AndreasChristmann 814dd54
time series profile unit test
AndreasChristmann 5c8ed92
added db cleanup
AndreasChristmann a1aead4
moved equals to test classes and removed hashcode
AndreasChristmann 3d5ddce
reformatted code
AndreasChristmann 51e8a69
Merge branch 'USACE:develop' into develop
AndreasChristmann 28d35f7
Merge remote-tracking branch 'origin/develop' into develop
AndreasChristmann 4712033
use CWMS-Id for location id
AndreasChristmann 011a1c2
use CWMSId, TimeSeriesProfile Instance DTO, json and unittest
AndreasChristmann c1068e2
unit test for timeseries profile instance, cleanup code
AndreasChristmann e20b5d5
Timeseries profile instance dao and test, columnar data, timeseries p…
AndreasChristmann a6107f2
use Temp-Water instead of Temperature
AndreasChristmann e6f9d96
change profile time series json to match time series
AndreasChristmann 4d92184
use real life names
AndreasChristmann 614f9b2
Time series profile parser dao
AndreasChristmann a8432dc
changed record to recordParam
AndreasChristmann 0498368
Merge remote-tracking branch 'refs/remotes/USACE/cwms-data-api/develo…
AndreasChristmann 691b79c
subclassed TimeSeriesProfileParser into Indexed and Columnar
AndreasChristmann 8093f60
renamed the retrieve method for multiple DTOs to catalog...
AndreasChristmann 5e0714e
DTO changes from Peter's review
AndreasChristmann 7fc5082
access View, bypass PL/SQL, prepare for pagination
AndreasChristmann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
package cwms.cda.data.dao.timeseriesprofile; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import cwms.cda.data.dao.JooqDao; | ||
import cwms.cda.data.dto.CwmsId; | ||
import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfile; | ||
import org.jooq.DSLContext; | ||
import org.jooq.Record; | ||
import org.jooq.Result; | ||
import org.jooq.impl.DSL; | ||
|
||
import usace.cwms.db.jooq.codegen.packages.CWMS_TS_PROFILE_PACKAGE; | ||
import usace.cwms.db.jooq.codegen.udt.records.STR_TAB_T; | ||
import usace.cwms.db.jooq.codegen.udt.records.TS_PROFILE_T; | ||
|
||
public class TimeSeriesProfileDao extends JooqDao<TimeSeriesProfile> { | ||
public TimeSeriesProfileDao(DSLContext dsl) { | ||
super(dsl); | ||
} | ||
|
||
public void storeTimeSeriesProfile(TimeSeriesProfile timeSeriesProfile, boolean failIfExists) { | ||
|
||
connection(dsl, conn -> { | ||
List<String> parameterList = timeSeriesProfile.getParameterList(); | ||
StringBuilder parameterString = new StringBuilder(parameterList.get(0)); | ||
|
||
for (int i = 1; i < parameterList.size(); i++) { | ||
parameterString.append(",").append(parameterList.get(i)); | ||
} | ||
String referenceTsId = null; | ||
if (timeSeriesProfile.getReferenceTsId() != null) { | ||
referenceTsId = timeSeriesProfile.getReferenceTsId().getName(); | ||
} | ||
CWMS_TS_PROFILE_PACKAGE.call_STORE_TS_PROFILE(DSL.using(conn).configuration(), timeSeriesProfile.getLocationId().getName(), | ||
timeSeriesProfile.getKeyParameter(), | ||
parameterString.toString(), | ||
timeSeriesProfile.getDescription(), referenceTsId, failIfExists?"T":"F", "T", timeSeriesProfile.getLocationId().getOfficeId()); | ||
}); | ||
} | ||
|
||
public TimeSeriesProfile retrieveTimeSeriesProfile(String locationId, String parameterId, String officeId) { | ||
return connectionResult(dsl, conn -> { | ||
TS_PROFILE_T timeSeriesProfile = CWMS_TS_PROFILE_PACKAGE.call_RETRIEVE_TS_PROFILE( | ||
DSL.using(conn).configuration(), locationId, parameterId, officeId); | ||
return map(timeSeriesProfile, locationId, parameterId, officeId); | ||
}); | ||
} | ||
|
||
public void deleteTimeSeriesProfile(String locationId, String keyParameter, String officeId) { | ||
connection(dsl, conn -> | ||
CWMS_TS_PROFILE_PACKAGE.call_DELETE_TS_PROFILE(DSL.using(conn).configuration(), locationId, keyParameter, "DELETE ALL", | ||
officeId)); | ||
} | ||
|
||
public void copyTimeSeriesProfile(String locationId, String keyParameter, String destinationLocation, String destRefTsId, String officeId) { | ||
connection(dsl, conn -> | ||
CWMS_TS_PROFILE_PACKAGE.call_COPY_TS_PROFILE(DSL.using(conn).configuration(), locationId, keyParameter, destinationLocation, | ||
destRefTsId, "F", "F", | ||
officeId)); | ||
} | ||
|
||
public List<TimeSeriesProfile> retrieveTimeSeriesProfiles(String locationIdMask, String parameterIdMask, String officeIdMask) { | ||
return connectionResult(dsl, conn -> { | ||
List<TimeSeriesProfile> timeSeriesProfileList = new ArrayList<>(); | ||
Result<Record> timeSeriesProfileResults = CWMS_TS_PROFILE_PACKAGE.call_CAT_TS_PROFILE( | ||
DSL.using(conn).configuration(), locationIdMask, parameterIdMask, officeIdMask); | ||
for (Record timeSeriesProfileResult : timeSeriesProfileResults) { | ||
Result<?> values = timeSeriesProfileResult.get("VALUE_PARAMETERS", Result.class); | ||
List<String> parameterList = new ArrayList<>(); | ||
for (Record value : values) { | ||
parameterList.add(value.get("PARMETER_ID", String.class)); | ||
} | ||
CwmsId locationId = new CwmsId.Builder() | ||
.withName((String) timeSeriesProfileResult.get("LOCATION_ID")) | ||
.withOfficeId((String) timeSeriesProfileResult.get("OFFICE_ID")) | ||
.build(); | ||
CwmsId referenceTsId = new CwmsId.Builder() | ||
.withName((String) timeSeriesProfileResult.get("REF_TS_ID")) | ||
.withOfficeId((String) timeSeriesProfileResult.get("OFFICE_ID")) | ||
.build(); | ||
timeSeriesProfileList.add(new TimeSeriesProfile.Builder() | ||
.withDescription((String) timeSeriesProfileResult.get("DESCRIPTION")) | ||
.withReferenceTsId(referenceTsId) | ||
.withKeyParameter((String) timeSeriesProfileResult.get("KEY_PARAMETER_ID")) | ||
.withLocationId(locationId) | ||
.withParameterList(parameterList) | ||
.build()); | ||
} | ||
return timeSeriesProfileList; | ||
}); | ||
} | ||
|
||
private TimeSeriesProfile map(TS_PROFILE_T timeSeriesProfile, String locationName, String keyParameter, String officeId) { | ||
STR_TAB_T profileParams = timeSeriesProfile.getPROFILE_PARAMS(); | ||
List<String> parameterList = new ArrayList<>(profileParams); | ||
CwmsId locationId = new CwmsId.Builder().withName(locationName).withOfficeId(officeId).build(); | ||
CwmsId referenceTsId = null; | ||
if (timeSeriesProfile.getREFERENCE_TS_ID() != null) { | ||
referenceTsId = new CwmsId.Builder().withName(timeSeriesProfile.getREFERENCE_TS_ID()).withOfficeId(officeId).build(); | ||
} | ||
return new TimeSeriesProfile.Builder() | ||
.withLocationId(locationId) | ||
.withDescription(timeSeriesProfile.getDESCRIPTION()) | ||
.withReferenceTsId(referenceTsId) | ||
.withKeyParameter(keyParameter) | ||
.withParameterList(parameterList) | ||
.build(); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are we sure this isn't going to end up large in the future?
If so we can wait on pagination but it's generally something we want to consider.
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.
@AndreasChristmann From internal meeting recommend coding this against the view to allow for pagination to be added if needed later on.