Skip to content
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
wants to merge 29 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1b8b925
ts profile json
AndreasChristmann Jun 14, 2024
32c0927
ts profile json
AndreasChristmann Jun 18, 2024
7b61ef3
ts profile json
AndreasChristmann Jun 18, 2024
ab58110
ts profile json
AndreasChristmann Jun 18, 2024
15fdef1
sample time series profile data
AndreasChristmann Jun 19, 2024
88d5079
time series profile dto's
AndreasChristmann Jun 19, 2024
994c908
time series profile dao's
AndreasChristmann Jun 19, 2024
2f32183
time series profile dto's unit test
AndreasChristmann Jun 19, 2024
8fbcb4e
time series profile dao integration test
AndreasChristmann Jun 19, 2024
814dd54
time series profile unit test
AndreasChristmann Jun 20, 2024
5c8ed92
added db cleanup
AndreasChristmann Jun 21, 2024
a1aead4
moved equals to test classes and removed hashcode
AndreasChristmann Jun 25, 2024
3d5ddce
reformatted code
AndreasChristmann Jun 26, 2024
51e8a69
Merge branch 'USACE:develop' into develop
AndreasChristmann Jun 26, 2024
28d35f7
Merge remote-tracking branch 'origin/develop' into develop
AndreasChristmann Jun 26, 2024
4712033
use CWMS-Id for location id
AndreasChristmann Jun 27, 2024
011a1c2
use CWMSId, TimeSeriesProfile Instance DTO, json and unittest
AndreasChristmann Jun 27, 2024
c1068e2
unit test for timeseries profile instance, cleanup code
AndreasChristmann Jul 19, 2024
e20b5d5
Timeseries profile instance dao and test, columnar data, timeseries p…
AndreasChristmann Jul 24, 2024
a6107f2
use Temp-Water instead of Temperature
AndreasChristmann Jul 24, 2024
e6f9d96
change profile time series json to match time series
AndreasChristmann Jul 24, 2024
4d92184
use real life names
AndreasChristmann Jul 24, 2024
614f9b2
Time series profile parser dao
AndreasChristmann Jul 29, 2024
a8432dc
changed record to recordParam
AndreasChristmann Jul 29, 2024
0498368
Merge remote-tracking branch 'refs/remotes/USACE/cwms-data-api/develo…
AndreasChristmann Jul 29, 2024
691b79c
subclassed TimeSeriesProfileParser into Indexed and Columnar
AndreasChristmann Jul 30, 2024
8093f60
renamed the retrieve method for multiple DTOs to catalog...
AndreasChristmann Jul 31, 2024
5e0714e
DTO changes from Peter's review
AndreasChristmann Aug 5, 2024
7fc5082
access View, bypass PL/SQL, prepare for pagination
AndreasChristmann Aug 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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<>();
Copy link
Contributor

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.

Copy link
Collaborator

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.

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();
}
}
Loading