diff --git a/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java b/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java index 35acf2c63..53bb41363 100644 --- a/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java +++ b/cwms-data-api/src/main/java/cwms/cda/ApiServlet.java @@ -110,17 +110,14 @@ import cwms.cda.api.project.ProjectPublishStatusUpdate; import cwms.cda.api.project.RemoveAllLockRevokerRights; import cwms.cda.api.project.UpdateLockRevokerRights; -import cwms.cda.api.timeseriesprofile.TimeSeriesProfileBase; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileCatalogController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileCreateController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileDeleteController; -import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceBase; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceCatalogController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceCreateController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceDeleteController; -import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserBase; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserCatalogController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserController; import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserCreateController; @@ -494,31 +491,31 @@ protected void configureRoutes() { addCacheControl(textBinaryValuePath, 1, TimeUnit.DAYS); String timeSeriesProfilePath = "/timeseries/profile/"; - get(format(timeSeriesProfilePath + "{%s}/{%s}", Controllers.LOCATION_ID, TimeSeriesProfileBase.PARAMETER_ID), + get(format(timeSeriesProfilePath + "{%s}/{%s}", Controllers.LOCATION_ID, Controllers.PARAMETER_ID), new TimeSeriesProfileController(metrics)); delete(format(timeSeriesProfilePath + "/{%s}/{%s}", Controllers.LOCATION_ID, - TimeSeriesProfileBase.PARAMETER_ID), new TimeSeriesProfileDeleteController(metrics), + Controllers.PARAMETER_ID), new TimeSeriesProfileDeleteController(metrics), requiredRoles); - get(format(timeSeriesProfilePath, Controllers.LOCATION_ID, TimeSeriesProfileBase.PARAMETER_ID), + get(format(timeSeriesProfilePath, Controllers.LOCATION_ID, Controllers.PARAMETER_ID), new TimeSeriesProfileCatalogController(metrics)); post(timeSeriesProfilePath, new TimeSeriesProfileCreateController(metrics), requiredRoles); String timeSeriesProfileParserPath = "/timeseries/profile-parser/"; get(format(timeSeriesProfileParserPath + "{%s}/{%s}/", Controllers.LOCATION_ID, - TimeSeriesProfileParserBase.PARAMETER_ID), new TimeSeriesProfileParserController(metrics)); + Controllers.PARAMETER_ID), new TimeSeriesProfileParserController(metrics)); post(timeSeriesProfileParserPath, new TimeSeriesProfileParserCreateController(metrics), requiredRoles); delete(format(timeSeriesProfileParserPath + "{%s}/{%s}/", Controllers.LOCATION_ID, - TimeSeriesProfileParserBase.PARAMETER_ID), new TimeSeriesProfileParserDeleteController(metrics), + Controllers.PARAMETER_ID), new TimeSeriesProfileParserDeleteController(metrics), requiredRoles); get(timeSeriesProfileParserPath, new TimeSeriesProfileParserCatalogController(metrics)); String timeSeriesProfileInstancePath = "/timeseries/profile-instance/"; get(format(timeSeriesProfileInstancePath + "{%s}/{%s}/{%s}/", Controllers.LOCATION_ID, - TimeSeriesProfileInstanceBase.PARAMETER_ID, Controllers.VERSION), + Controllers.PARAMETER_ID, Controllers.VERSION), new TimeSeriesProfileInstanceController(metrics)); post(timeSeriesProfileInstancePath, new TimeSeriesProfileInstanceCreateController(metrics), requiredRoles); delete(format(timeSeriesProfileInstancePath + "{%s}/{%s}/{%s}/", Controllers.LOCATION_ID, - TimeSeriesProfileInstanceBase.PARAMETER_ID, Controllers.VERSION), + Controllers.PARAMETER_ID, Controllers.VERSION), new TimeSeriesProfileInstanceDeleteController(metrics), requiredRoles); get(timeSeriesProfileInstancePath, new TimeSeriesProfileInstanceCatalogController(metrics)); @@ -850,7 +847,7 @@ private static String getAccessManagerName() { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + throws IOException { totalRequests.mark(); try { String office = officeFromContext(req.getContextPath()); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java b/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java index b6fe85e0b..4672323f3 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java @@ -128,6 +128,12 @@ public final class Controllers { public static final String LOCATIONS = "locations"; public static final String WATER_USER = "water-user"; public static final String CONTRACT_NAME = "contract-name"; + public static final String PARAMETER_ID = "parameter-id"; + public static final String PARAMETER_ID_MASK = "parameter-id-mask"; + public static final String VERSION_MASK = "version-mask"; + public static final String PROFILE_DATA = "profile-data"; + public static final String PREVIOUS = "previous"; + public static final String NEXT = "next"; public static final String LOCATION_ID = "location-id"; public static final String SOURCE_ENTITY = "source-entity"; diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileBase.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileBase.java index 958113365..d2a01e6ec 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileBase.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileBase.java @@ -32,12 +32,11 @@ import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileDao; import org.jooq.DSLContext; -public class TimeSeriesProfileBase { +public abstract class TimeSeriesProfileBase { static final String TAG = "TimeSeries"; - public static final String PARAMETER_ID = "parameter-id"; private MetricRegistry metrics; - TimeSeriesProfileDao getContractDao(DSLContext dsl) { + TimeSeriesProfileDao getProfileDao(DSLContext dsl) { return new TimeSeriesProfileDao(dsl); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCatalogController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCatalogController.java index 7592d6d08..8148006de 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCatalogController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCatalogController.java @@ -85,7 +85,7 @@ public TimeSeriesProfileCatalogController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(GET_ALL)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileDao tspDao = new TimeSeriesProfileDao(dsl); + TimeSeriesProfileDao tspDao = getProfileDao(dsl); String officeMask = ctx.queryParamAsClass(OFFICE_MASK, String.class).getOrDefault("*"); String locationMask = ctx.queryParamAsClass(LOCATION_MASK, String.class).getOrDefault("*"); String parameterIdMask = ctx.queryParamAsClass(PARAMETER_ID_MASK, String.class).getOrDefault("*"); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileController.java index 1e4a97140..b252bb6b5 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileController.java @@ -29,6 +29,7 @@ import static cwms.cda.api.Controllers.GET_ONE; import static cwms.cda.api.Controllers.LOCATION_ID; import static cwms.cda.api.Controllers.OFFICE; +import static cwms.cda.api.Controllers.PARAMETER_ID; import static cwms.cda.api.Controllers.STATUS_200; import static cwms.cda.api.Controllers.requiredParam; import static cwms.cda.data.dao.JooqDao.getDslContext; @@ -85,9 +86,9 @@ public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(GET_ONE)) { DSLContext dsl = getDslContext(ctx); String parameterId = ctx.pathParam(PARAMETER_ID); - TimeSeriesProfileDao tspDao = new TimeSeriesProfileDao(dsl); + TimeSeriesProfileDao tspDao = getProfileDao(dsl); String office = requiredParam(ctx, OFFICE); - String locationId = requiredParam(ctx, LOCATION_ID); + String locationId = ctx.pathParam(LOCATION_ID); TimeSeriesProfile returned = tspDao.retrieveTimeSeriesProfile(locationId, parameterId, office); String acceptHeader = ctx.header(Header.ACCEPT); ContentType contentType = Formats.parseHeader(acceptHeader, TimeSeriesProfile.class); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCreateController.java index 58797d255..bb3f311bd 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileCreateController.java @@ -74,7 +74,7 @@ public void handle(@NotNull Context ctx) { TimeSeriesProfile timeSeriesProfile = Formats.parseContent(Formats.parseHeader(Formats.JSONV1, TimeSeriesProfile.class), ctx.body(), TimeSeriesProfile.class); boolean failIfExists = ctx.queryParamAsClass(FAIL_IF_EXISTS, boolean.class).getOrDefault(true); - TimeSeriesProfileDao tspDao = new TimeSeriesProfileDao(dsl); + TimeSeriesProfileDao tspDao = getProfileDao(dsl); tspDao.storeTimeSeriesProfile(timeSeriesProfile, failIfExists); ctx.status(HttpServletResponse.SC_CREATED); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileDeleteController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileDeleteController.java index 69c87ef64..d0cf27b08 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileDeleteController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileDeleteController.java @@ -76,7 +76,7 @@ public void handle(@NotNull Context ctx) { String keyParameter = ctx.pathParam(PARAMETER_ID); String office = requiredParam(ctx, OFFICE); String locationId = ctx.pathParam(LOCATION_ID); - TimeSeriesProfileDao tspDao = new TimeSeriesProfileDao(dsl); + TimeSeriesProfileDao tspDao = getProfileDao(dsl); tspDao.deleteTimeSeriesProfile(locationId, keyParameter, office); ctx.status(HttpServletResponse.SC_NO_CONTENT); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceBase.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceBase.java index 6abc55601..e14ab214f 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceBase.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceBase.java @@ -32,19 +32,11 @@ import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileInstanceDao; import org.jooq.DSLContext; -public class TimeSeriesProfileInstanceBase { +public abstract class TimeSeriesProfileInstanceBase { static final String TAG = "TimeSeries"; - public static final String PARAMETER_ID = "parameter-id"; - public static final String PARAMETER_ID_MASK = "parameter-id-mask"; - public static final String VERSION_MASK = "version-mask"; - public static final String PROFILE_DATA = "profile-data"; - public static final String START_INCLUSIVE = "start-inclusive"; - public static final String END_INCLUSIVE = "end-inclusive"; - public static final String PREVIOUS = "previous"; - public static final String NEXT = "next"; private MetricRegistry metrics; - TimeSeriesProfileInstanceDao getContractDao(DSLContext dsl) { + TimeSeriesProfileInstanceDao getProfileInstanceDao(DSLContext dsl) { return new TimeSeriesProfileInstanceDao(dsl); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCatalogController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCatalogController.java index 1e445d064..c26c0160f 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCatalogController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCatalogController.java @@ -84,7 +84,7 @@ public TimeSeriesProfileInstanceCatalogController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(GET_ALL)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileInstanceDao tspInstanceDao = new TimeSeriesProfileInstanceDao(dsl); + TimeSeriesProfileInstanceDao tspInstanceDao = getProfileInstanceDao(dsl); String officeMask = ctx.queryParamAsClass(OFFICE_MASK, String.class).getOrDefault("*"); String locationMask = ctx.queryParamAsClass(LOCATION_MASK, String.class).getOrDefault("*"); String parameterIdMask = ctx.queryParamAsClass(PARAMETER_ID_MASK, String.class).getOrDefault("*"); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceController.java index b59b98d42..c11f1029a 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceController.java @@ -26,7 +26,26 @@ package cwms.cda.api.timeseriesprofile; -import static cwms.cda.api.Controllers.*; +import static cwms.cda.api.Controllers.END; +import static cwms.cda.api.Controllers.END_TIME_INCLUSIVE; +import static cwms.cda.api.Controllers.GET_ONE; +import static cwms.cda.api.Controllers.LOCATION_ID; +import static cwms.cda.api.Controllers.MAX_VERSION; +import static cwms.cda.api.Controllers.NEXT; +import static cwms.cda.api.Controllers.OFFICE; +import static cwms.cda.api.Controllers.PAGE; +import static cwms.cda.api.Controllers.PAGE_SIZE; +import static cwms.cda.api.Controllers.PARAMETER_ID; +import static cwms.cda.api.Controllers.PREVIOUS; +import static cwms.cda.api.Controllers.START; +import static cwms.cda.api.Controllers.START_TIME_INCLUSIVE; +import static cwms.cda.api.Controllers.STATUS_200; +import static cwms.cda.api.Controllers.TIMEZONE; +import static cwms.cda.api.Controllers.UNIT; +import static cwms.cda.api.Controllers.VERSION; +import static cwms.cda.api.Controllers.VERSION_DATE; +import static cwms.cda.api.Controllers.requiredInstant; +import static cwms.cda.api.Controllers.requiredParam; import static cwms.cda.data.dao.JooqDao.getDslContext; import com.codahale.metrics.MetricRegistry; @@ -70,9 +89,9 @@ public TimeSeriesProfileInstanceController(MetricRegistry metrics) { + " time series profile instance. Default is the min or max version date, depending on the maxVersion"), @OpenApiParam(name = UNIT, description = "The units of the" + " time series profile instance. Provided as a list separated by ','", required = true), - @OpenApiParam(name = START_INCLUSIVE, type = Boolean.class, description = "The start inclusive of the" + @OpenApiParam(name = START_TIME_INCLUSIVE, type = Boolean.class, description = "The start inclusive of the" + " time series profile instance. Default is true"), - @OpenApiParam(name = END_INCLUSIVE, type = Boolean.class, description = "The end inclusive of the" + @OpenApiParam(name = END_TIME_INCLUSIVE, type = Boolean.class, description = "The end inclusive of the" + " time series profile instance. Default is true"), @OpenApiParam(name = PREVIOUS, type = boolean.class, description = "Whether to include the previous " + " time window of the time series profile instance. Default is false"), @@ -99,7 +118,9 @@ public TimeSeriesProfileInstanceController(MetricRegistry metrics) { + " time series profile instance.", required = true), }, method = HttpMethod.GET, - summary = "Get all time series profile instances", + summary = "Get all time series profile instances that match the provided masks. This endpoint will return a " + + "list of time series profile instances without the associated data. Data for an instance can be " + + "retrieved using the singular retrieval endpoint.", tags = {TAG}, responses = { @OpenApiResponse(status = STATUS_200, @@ -115,34 +136,32 @@ public TimeSeriesProfileInstanceController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(GET_ONE)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileInstanceDao tspInstanceDao = new TimeSeriesProfileInstanceDao(dsl); + TimeSeriesProfileInstanceDao tspInstanceDao = getProfileInstanceDao(dsl); String officeId = requiredParam(ctx, OFFICE); String locationId = ctx.pathParam(LOCATION_ID); String keyParameter = ctx.pathParam(PARAMETER_ID); String version = ctx.pathParam(VERSION); List unit = Arrays.asList(requiredParam(ctx, UNIT).split(",")); - Instant startTime = Instant.ofEpochMilli(Long.parseLong(ctx.queryParamAsClass(START, String.class) - .getOrDefault(String.valueOf(Instant.now().toEpochMilli())))); - Instant endTime = Instant.ofEpochMilli(Long.parseLong(ctx.queryParamAsClass(END, String.class) - .getOrDefault(String.valueOf(Instant.now().toEpochMilli())))); + Instant startTime = requiredInstant(ctx, START); + Instant endTime = requiredInstant(ctx, END); String timeZone = ctx.queryParamAsClass(TIMEZONE, String.class).getOrDefault("UTC"); - boolean startInclusive = ctx.queryParamAsClass(START_INCLUSIVE, boolean.class) + boolean startInclusive = ctx.queryParamAsClass(START_TIME_INCLUSIVE, boolean.class) .getOrDefault(true); - boolean endInclusive = ctx.queryParamAsClass(END_INCLUSIVE, boolean.class) + boolean endInclusive = ctx.queryParamAsClass(END_TIME_INCLUSIVE, boolean.class) .getOrDefault(true); boolean previous = ctx.queryParamAsClass(PREVIOUS, boolean.class).getOrDefault(false); boolean next = ctx.queryParamAsClass(NEXT, boolean.class).getOrDefault(false); Instant versionDate = ctx.queryParamAsClass(VERSION_DATE, String.class).getOrDefault(null) == null - ? null : Instant.ofEpochMilli(Long.parseLong(ctx.queryParamAsClass(VERSION_DATE, String.class) - .getOrDefault(null))); + ? null : Instant.parse(ctx.queryParamAsClass(VERSION_DATE, String.class) + .getOrDefault(null)); boolean maxVersion = ctx.queryParamAsClass(MAX_VERSION, boolean.class) .getOrDefault(false); String page = ctx.queryParam(PAGE); int pageSize = ctx.queryParamAsClass(PAGE_SIZE, Integer.class).getOrDefault(500); - CwmsId tspIdentifier = new CwmsId.Builder().withOfficeId(officeId).withName(locationId).build(); - TimeSeriesProfileInstance returnedInstance = tspInstanceDao.retrieveTimeSeriesProfileInstance(tspIdentifier, - keyParameter, version, unit, startTime, endTime, timeZone, startInclusive, endInclusive, - previous, next, versionDate, maxVersion, page, pageSize); + CwmsId tspLocationIdentifier = new CwmsId.Builder().withOfficeId(officeId).withName(locationId).build(); + TimeSeriesProfileInstance returnedInstance = tspInstanceDao.retrieveTimeSeriesProfileInstance( + tspLocationIdentifier, keyParameter, version, unit, startTime, endTime, timeZone, startInclusive, + endInclusive, previous, next, versionDate, maxVersion, page, pageSize); String acceptHeader = ctx.header(Header.ACCEPT); ContentType contentType = Formats.parseHeader(acceptHeader, TimeSeriesProfileInstance.class); String result = Formats.format(contentType, returnedInstance); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCreateController.java index 6632af131..147d45141 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceCreateController.java @@ -26,8 +26,14 @@ package cwms.cda.api.timeseriesprofile; -import static cwms.cda.api.Controllers.*; +import static cwms.cda.api.Controllers.CREATE; +import static cwms.cda.api.Controllers.METHOD; import static cwms.cda.api.Controllers.OVERRIDE_PROTECTION; +import static cwms.cda.api.Controllers.PROFILE_DATA; +import static cwms.cda.api.Controllers.VERSION; +import static cwms.cda.api.Controllers.VERSION_DATE; +import static cwms.cda.api.Controllers.requiredInstant; +import static cwms.cda.api.Controllers.requiredParam; import static cwms.cda.data.dao.JooqDao.getDslContext; import com.codahale.metrics.MetricRegistry; @@ -62,7 +68,7 @@ public TimeSeriesProfileInstanceCreateController(MetricRegistry metrics) { @OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, description = "Override protection" + " for the time series profile instance. Default is false"), @OpenApiParam(name = VERSION_DATE, type = Long.class, description = "The version date of the" - + " time series profile instance. Default is the current date and time"), + + " time series profile instance.", required = true), @OpenApiParam(name = PROFILE_DATA, required = true, description = "The profile data of the" + " time series profile instance"), @OpenApiParam(name = VERSION, description = "The version of the" @@ -82,13 +88,12 @@ public TimeSeriesProfileInstanceCreateController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(CREATE)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileInstanceDao tspInstanceDao = new TimeSeriesProfileInstanceDao(dsl); + TimeSeriesProfileInstanceDao tspInstanceDao = getProfileInstanceDao(dsl); TimeSeriesProfile timeSeriesProfile = Formats.parseContent(Formats.parseHeader(Formats.JSONV1, TimeSeriesProfile.class), ctx.body(), TimeSeriesProfile.class); String profileData = requiredParam(ctx, PROFILE_DATA); String versionId = requiredParam(ctx, VERSION); - Instant versionDate = Instant.ofEpochMilli(ctx.queryParamAsClass(VERSION_DATE, Long.class) - .getOrDefault(Instant.now().toEpochMilli())); + Instant versionDate = requiredInstant(ctx, VERSION_DATE); StoreRule storeRule = ctx.queryParamAsClass(METHOD, StoreRule.class).getOrDefault(StoreRule.REPLACE_ALL); boolean overrideProtection = ctx.queryParamAsClass(OVERRIDE_PROTECTION, boolean.class) .getOrDefault(false); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceDeleteController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceDeleteController.java index 6120cdd0c..cdadd7367 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceDeleteController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileInstanceDeleteController.java @@ -26,7 +26,17 @@ package cwms.cda.api.timeseriesprofile; -import static cwms.cda.api.Controllers.*; +import static cwms.cda.api.Controllers.DATE; +import static cwms.cda.api.Controllers.DELETE; +import static cwms.cda.api.Controllers.LOCATION_ID; +import static cwms.cda.api.Controllers.OFFICE; +import static cwms.cda.api.Controllers.OVERRIDE_PROTECTION; +import static cwms.cda.api.Controllers.PARAMETER_ID; +import static cwms.cda.api.Controllers.TIMEZONE; +import static cwms.cda.api.Controllers.VERSION; +import static cwms.cda.api.Controllers.VERSION_DATE; +import static cwms.cda.api.Controllers.requiredInstant; +import static cwms.cda.api.Controllers.requiredParam; import static cwms.cda.data.dao.JooqDao.getDslContext; import com.codahale.metrics.MetricRegistry; @@ -55,12 +65,13 @@ public TimeSeriesProfileInstanceDeleteController(MetricRegistry metrics) { queryParams = { @OpenApiParam(name = OFFICE, description = "The office associated with the" + " time series profile instance.", required = true), - @OpenApiParam(name = TIMEZONE, description = "The timezone of the" - + " time series profile instance. Default is UTC"), + @OpenApiParam(name = TIMEZONE, description = "Specifies " + + "the time zone of the values of the begin and end fields. If this field is not specified, " + + "the default time zone of UTC shall be used."), @OpenApiParam(name = VERSION_DATE, type = Instant.class, description = "The version date of the" - + " time series profile instance. Default is current time"), + + " time series profile instance.", required = true), @OpenApiParam(name = DATE, type = Instant.class, description = "The first date of the" - + " time series profile instance. Default is current time"), + + " time series profile instance.", required = true), @OpenApiParam(name = OVERRIDE_PROTECTION, type = Boolean.class, description = "Override protection" + " for the time series profile instance. Default is true") }, @@ -83,16 +94,14 @@ public TimeSeriesProfileInstanceDeleteController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(DELETE)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileInstanceDao tspInstanceDao = new TimeSeriesProfileInstanceDao(dsl); + TimeSeriesProfileInstanceDao tspInstanceDao = getProfileInstanceDao(dsl); String office = requiredParam(ctx, OFFICE); String locationId = ctx.pathParam(LOCATION_ID); String timeZone = ctx.queryParamAsClass(TIMEZONE, String.class).getOrDefault("UTC"); String version = ctx.pathParam(VERSION); String keyParameter = ctx.pathParam(PARAMETER_ID); - Instant versionDate = Instant.ofEpochMilli(ctx.queryParamAsClass(VERSION_DATE, Long.class) - .getOrDefault(Instant.now().toEpochMilli())); - Instant firstDate = Instant.ofEpochMilli(ctx.queryParamAsClass(DATE, Long.class) - .getOrDefault(Instant.now().toEpochMilli())); + Instant versionDate = requiredInstant(ctx, VERSION_DATE); + Instant firstDate = requiredInstant(ctx, DATE); CwmsId tspIdentifier = new CwmsId.Builder().withName(locationId).withOfficeId(office).build(); boolean overrideProtection = ctx.queryParamAsClass(OVERRIDE_PROTECTION, boolean.class).getOrDefault(true); tspInstanceDao.deleteTimeSeriesProfileInstance(tspIdentifier, keyParameter, version, firstDate, timeZone, diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserBase.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserBase.java index 73154ccc9..e8e12671c 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserBase.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserBase.java @@ -32,13 +32,13 @@ import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileParserDao; import org.jooq.DSLContext; -public class TimeSeriesProfileParserBase { +public abstract class TimeSeriesProfileParserBase { static final String TAG = "TimeSeries"; - public static final String PARAMETER_ID = "parameter-id"; + public static final String PARAMETER_ID_MASK = "parameter-id-mask"; private MetricRegistry metrics; - TimeSeriesProfileParserDao getContractDao(DSLContext dsl) { + TimeSeriesProfileParserDao getParserDao(DSLContext dsl) { return new TimeSeriesProfileParserDao(dsl); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCatalogController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCatalogController.java index 5bb6ad852..0bd4a8116 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCatalogController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCatalogController.java @@ -26,15 +26,18 @@ package cwms.cda.api.timeseriesprofile; -import static cwms.cda.api.Controllers.*; +import static cwms.cda.api.Controllers.GET_ALL; import static cwms.cda.api.Controllers.LOCATION_MASK; +import static cwms.cda.api.Controllers.OFFICE_MASK; +import static cwms.cda.api.Controllers.STATUS_200; +import static cwms.cda.api.Controllers.STATUS_404; +import static cwms.cda.api.Controllers.STATUS_501; import static cwms.cda.data.dao.JooqDao.getDslContext; import com.codahale.metrics.MetricRegistry; import com.codahale.metrics.Timer; import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileParserDao; import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfileParser; -import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfileParserList; import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfileParsers; import cwms.cda.formatters.ContentType; import cwms.cda.formatters.Formats; @@ -59,28 +62,28 @@ public TimeSeriesProfileParserCatalogController(MetricRegistry metrics) { } @OpenApi( - queryParams = { - @OpenApiParam(name = PARAMETER_ID_MASK, description = "The ID mask of the TimeSeriesProfileParser" - + " parameter. Default is *"), - @OpenApiParam(name = OFFICE_MASK, description = "The office mask associated with the " - + "TimeSeriesProfile. Default is *"), - @OpenApiParam(name = LOCATION_MASK, description = "The location ID mask associated" - + " with the TimeSeriesProfile. Default is *"), - }, - responses = { - @OpenApiResponse(status = STATUS_200, - description = "A TimeSeriesProfileParser object", - content = { - @OpenApiContent(from = TimeSeriesProfileParsers.class, type = Formats.JSONV1), - }), - @OpenApiResponse(status = STATUS_404, description = "The provided combination of parameters did not" - + " find a TimeSeriesProfileParser object"), - @OpenApiResponse(status = STATUS_501, description = "Requested format is not " - + "implemented") - }, - method = HttpMethod.GET, - summary = "Get a TimeSeriesProfileParser by ID", - tags = {TAG} + queryParams = { + @OpenApiParam(name = PARAMETER_ID_MASK, description = "The ID mask of the TimeSeriesProfileParser" + + " parameter. Default is *"), + @OpenApiParam(name = OFFICE_MASK, description = "The office mask associated with the " + + "TimeSeriesProfile. Default is *"), + @OpenApiParam(name = LOCATION_MASK, description = "The location ID mask associated" + + " with the TimeSeriesProfile. Default is *"), + }, + responses = { + @OpenApiResponse(status = STATUS_200, + description = "A TimeSeriesProfileParser object", + content = { + @OpenApiContent(from = TimeSeriesProfileParsers.class, type = Formats.JSONV1), + }), + @OpenApiResponse(status = STATUS_404, description = "The provided combination of parameters did not" + + " find a TimeSeriesProfileParser object"), + @OpenApiResponse(status = STATUS_501, description = "Requested format is not " + + "implemented") + }, + method = HttpMethod.GET, + summary = "Get a TimeSeriesProfileParser by ID", + tags = {TAG} ) @Override public void handle(@NotNull Context ctx) { @@ -91,16 +94,15 @@ public void handle(@NotNull Context ctx) { String locationId = ctx.queryParamAsClass(LOCATION_MASK, String.class).getOrDefault("*"); String parameterIdMask = ctx.queryParamAsClass(PARAMETER_ID_MASK, String.class).getOrDefault("*"); - TimeSeriesProfileParserDao tspParserDao = new TimeSeriesProfileParserDao(dsl); + TimeSeriesProfileParserDao tspParserDao = getParserDao(dsl); List tspParsers = tspParserDao.catalogTimeSeriesProfileParsers(locationId, officeIdMask, parameterIdMask, true); String acceptHeader = ctx.header(Header.ACCEPT); - // Added custom List wrapper due to serialization issues with List for TimeSeriesProfileParser Type handling. + // Added type to DTO due to serialization issues with List for TimeSeriesProfileParser Type handling. // Related to Jackson subclassing annotations @JSONTypeInfo and @JSONSubTypes // See issue: https://github.com/FasterXML/jackson-databind/issues/2185 - TimeSeriesProfileParserList parserList = new TimeSeriesProfileParserList(tspParsers); ContentType contentType = Formats.parseHeader(acceptHeader, TimeSeriesProfileParsers.class); - String result = Formats.format(contentType, parserList, TimeSeriesProfileParsers.class); + String result = Formats.format(contentType, tspParsers, TimeSeriesProfileParsers.class); ctx.status(HttpServletResponse.SC_OK); ctx.result(result); } diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserController.java index e31bab938..9ba94734c 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserController.java @@ -29,6 +29,7 @@ import static cwms.cda.api.Controllers.GET_ONE; import static cwms.cda.api.Controllers.LOCATION_ID; import static cwms.cda.api.Controllers.OFFICE; +import static cwms.cda.api.Controllers.PARAMETER_ID; import static cwms.cda.api.Controllers.STATUS_200; import static cwms.cda.api.Controllers.STATUS_404; import static cwms.cda.api.Controllers.STATUS_501; @@ -94,7 +95,7 @@ public void handle(@NotNull Context ctx) { String parameterId = ctx.pathParam(PARAMETER_ID); String officeId = requiredParam(ctx, OFFICE); String locationId = ctx.pathParam(LOCATION_ID); - TimeSeriesProfileParserDao tspParserDao = new TimeSeriesProfileParserDao(dsl); + TimeSeriesProfileParserDao tspParserDao = getParserDao(dsl); TimeSeriesProfileParser tspParser = tspParserDao.retrieveTimeSeriesProfileParser(locationId, parameterId, officeId); String acceptHeader = ctx.header(Header.ACCEPT); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCreateController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCreateController.java index 656777773..ae5dd52bc 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCreateController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserCreateController.java @@ -79,7 +79,7 @@ public void handle(@NotNull Context ctx) { TimeSeriesProfileParserColumnar tspParserColumnar = null; TimeSeriesProfileParserIndexed tspParserIndexed = null; - TimeSeriesProfileParserDao tspParserDao = new TimeSeriesProfileParserDao(dsl); + TimeSeriesProfileParserDao tspParserDao = getParserDao(dsl); if (ctx.body().contains("columnar-timeseries-profile-parser")) { tspParserColumnar = Formats.parseContent(Formats.parseHeader(Formats.JSONV1, TimeSeriesProfileParserColumnar.class), ctx.body(), TimeSeriesProfileParserColumnar.class); diff --git a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserDeleteController.java b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserDeleteController.java index 193285aa7..e2ac2f2b8 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserDeleteController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/timeseriesprofile/TimeSeriesProfileParserDeleteController.java @@ -74,7 +74,7 @@ public TimeSeriesProfileParserDeleteController(MetricRegistry metrics) { public void handle(@NotNull Context ctx) { try (final Timer.Context ignored = markAndTime(DELETE)) { DSLContext dsl = getDslContext(ctx); - TimeSeriesProfileParserDao tspParserDao = new TimeSeriesProfileParserDao(dsl); + TimeSeriesProfileParserDao tspParserDao = getParserDao(dsl); String parameterId = ctx.pathParam(PARAMETER_ID); String locationId = ctx.pathParam(LOCATION_ID); String officeId = requiredParam(ctx, OFFICE); diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileDao.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileDao.java index f57cb0043..3d7305261 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileDao.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileDao.java @@ -145,35 +145,36 @@ public TimeSeriesProfileList catalogTimeSeriesProfiles(String locationIdMask, St // Map the results to the return object // Initialize the previous location code and parameter id to split the pages correctly - Long prevLocationCode = AV_TS_PROFILE.LOCATION_CODE.get(timeSeriesProfileResults.get(0)); - String prevParameterId = AV_TS_PROFILE.KEY_PARAMETER_ID.get(timeSeriesProfileResults.get(0)); + Long prevLocationCode = timeSeriesProfileResults.get(0).get(AV_TS_PROFILE.LOCATION_CODE); + String prevParameterId = timeSeriesProfileResults.get(0).get(AV_TS_PROFILE.KEY_PARAMETER_ID); for (Record timeSeriesProfileResult : timeSeriesProfileResults) { - String parameters = AV_TS_PROFILE.PARAMETERS.get(timeSeriesProfileResult); + String parameters = timeSeriesProfileResult.get(AV_TS_PROFILE.PARAMETERS); String[] parameterArray = parameters.split(","); List parameterList = Arrays.asList(parameterArray); CwmsId locationId = new CwmsId.Builder() - .withName(AV_TS_PROFILE.LOCATION_ID.get(timeSeriesProfileResult)) - .withOfficeId(AV_TS_PROFILE.OFFICE_ID.get(timeSeriesProfileResult)) + .withName(timeSeriesProfileResult.get(AV_TS_PROFILE.LOCATION_ID)) + .withOfficeId(timeSeriesProfileResult.get(AV_TS_PROFILE.OFFICE_ID)) .build(); CwmsId referenceTsId = new CwmsId.Builder() - .withName(AV_TS_PROFILE.ELEV_TS_ID.get(timeSeriesProfileResult)) - .withOfficeId(AV_TS_PROFILE.OFFICE_ID.get(timeSeriesProfileResult)) + .withName(timeSeriesProfileResult.get(AV_TS_PROFILE.ELEV_TS_ID)) + .withOfficeId(timeSeriesProfileResult.get(AV_TS_PROFILE.OFFICE_ID)) .build(); // Add the value to the return object // Adds page breaks if the page size is reached - timeSeriesProfileList.addValue(AV_TS_PROFILE.LOCATION_CODE.get(timeSeriesProfileResult), - new TimeSeriesProfile.Builder().withDescription(AV_TS_PROFILE.DESCRIPTION.get(timeSeriesProfileResult)) + timeSeriesProfileList.addValue(timeSeriesProfileResult.get(AV_TS_PROFILE.LOCATION_CODE), + new TimeSeriesProfile.Builder().withDescription(timeSeriesProfileResult + .get(AV_TS_PROFILE.DESCRIPTION)) .withReferenceTsId(referenceTsId) - .withKeyParameter(AV_TS_PROFILE.KEY_PARAMETER_ID.get(timeSeriesProfileResult)) + .withKeyParameter(timeSeriesProfileResult.get(AV_TS_PROFILE.KEY_PARAMETER_ID)) .withLocationId(locationId) .withParameterList(parameterList) .build(), prevParameterId, prevLocationCode) ; - prevLocationCode = AV_TS_PROFILE.LOCATION_CODE.get(timeSeriesProfileResult); - prevParameterId = AV_TS_PROFILE.KEY_PARAMETER_ID.get(timeSeriesProfileResult); + prevLocationCode = timeSeriesProfileResult.get(AV_TS_PROFILE.LOCATION_CODE); + prevParameterId = timeSeriesProfileResult.get(AV_TS_PROFILE.KEY_PARAMETER_ID); } return timeSeriesProfileList; } diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileInstanceDao.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileInstanceDao.java index 848454635..ec6c42cde 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileInstanceDao.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileInstanceDao.java @@ -1,6 +1,11 @@ package cwms.cda.data.dao.timeseriesprofile; -import static org.jooq.impl.DSL.*; +import static org.jooq.impl.DSL.asterisk; +import static org.jooq.impl.DSL.count; +import static org.jooq.impl.DSL.max; +import static org.jooq.impl.DSL.min; +import static org.jooq.impl.DSL.using; +import static org.jooq.impl.DSL.val; import cwms.cda.api.errors.NotFoundException; import cwms.cda.data.dao.JooqDao; @@ -46,577 +51,576 @@ public class TimeSeriesProfileInstanceDao extends JooqDao { - private static final Logger logger = Logger.getLogger(TimeSeriesProfileInstanceDao.class.getName()); - private static final AV_TS_PROFILE_INST_TSV2 cwmsTsInstView = AV_TS_PROFILE_INST_TSV2.AV_TS_PROFILE_INST_TSV2; - private static final AV_TS_PROFILE_INST cwmsTsProfileView = AV_TS_PROFILE_INST.AV_TS_PROFILE_INST; - - public TimeSeriesProfileInstanceDao(DSLContext dsl) { - super(dsl); - } - - public void storeTimeSeriesProfileInstance(TimeSeriesProfile timeSeriesProfile, String profileData, - Instant versionDate, String versionId, String storeRule, boolean overrideProtection) { - connection(dsl, conn -> { - setOffice(conn, timeSeriesProfile.getLocationId().getOfficeId()); - CWMS_TS_PROFILE_PACKAGE.call_STORE_TS_PROFILE_INSTANCE__2(using(conn).configuration(), - timeSeriesProfile.getLocationId().getName(), - timeSeriesProfile.getKeyParameter(), - profileData, - versionId, - storeRule, - overrideProtection ? "T" : "F", - versionDate != null ? Timestamp.from(versionDate) : null, - timeSeriesProfile.getLocationId().getOfficeId()); - }); - } - - public void storeTimeSeriesProfileInstance(TimeSeriesProfileInstance timeseriesProfileInstance, String versionId, - Instant versionInstant, String storeRule,String overrideProtection) { - connection(dsl, conn -> { - setOffice(conn, timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); - BigDecimal locationCodeId = CWMS_LOC_PACKAGE.call_GET_LOCATION_CODE(using(conn).configuration(), - timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId(), - timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getName()); - - - Map parameterIdToCode = new HashMap<>(); - - String parameter = timeseriesProfileInstance.getTimeSeriesProfile().getKeyParameter(); - BigDecimal parameterCodeDec = CWMS_UTIL_PACKAGE.call_GET_PARAMETER_CODE(using(conn).configuration(), - parameter, timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); - parameterIdToCode.put(parameter, parameterCodeDec.toBigInteger()); - - List dependentParameters = timeseriesProfileInstance.getTimeSeriesProfile().getParameterList(); - for (String param : dependentParameters) { - parameter = param; - parameterCodeDec = CWMS_UTIL_PACKAGE.call_GET_PARAMETER_CODE(using(conn).configuration(), parameter, - timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); - parameterIdToCode.put(parameter, parameterCodeDec.toBigInteger()); - } - - TS_PROF_DATA_T tsProfileData = new TS_PROF_DATA_T(); - tsProfileData.attach(using(conn).configuration()); - - TS_PROF_DATA_TAB_T records = new TS_PROF_DATA_TAB_T(); - - STR_TAB_T units = new STR_TAB_T(); - for (Map.Entry> entry : timeseriesProfileInstance.getTimeSeriesList().entrySet()) { - Long timestamp = entry.getKey(); - TS_PROF_DATA_REC_T dataRecord = new TS_PROF_DATA_REC_T(); - Timestamp timeStamp = Timestamp.from(Instant.ofEpochMilli(timestamp)); - dataRecord.setDATE_TIME(timeStamp); - - PVQ_TAB_T parameters = new PVQ_TAB_T(); - int n = 0; - for (TimeSeriesData data : entry.getValue()) { - PVQ_T pvq = new PVQ_T(); - String parameterId = timeseriesProfileInstance.getParameterColumns().get(n).getParameter(); - BigInteger parameterCode = parameterIdToCode.get(parameterId); - pvq.setPARAMETER_CODE(parameterCode); - pvq.setVALUE(data.getValue()); - pvq.setQUALITY_CODE(BigInteger.valueOf(data.getQuality())); - parameters.add(pvq); - if (!units.contains(timeseriesProfileInstance.getParameterColumns().get(n).getUnit())) { - units.add(timeseriesProfileInstance.getParameterColumns().get(n).getUnit()); - } - n++; - } - dataRecord.setPARAMETERS(parameters); - records.add(dataRecord); - } - - tsProfileData.setRECORDS(records); - tsProfileData.setLOCATION_CODE(locationCodeId.toBigInteger()); - tsProfileData.setTIME_ZONE("UTC"); - tsProfileData.setKEY_PARAMETER(parameterIdToCode.get(timeseriesProfileInstance - .getTimeSeriesProfile().getKeyParameter())); - tsProfileData.setUNITS(units); - - Timestamp versionTimeStamp = Timestamp.from(versionInstant); - - CWMS_TS_PROFILE_PACKAGE.call_STORE_TS_PROFILE_INSTANCE(using(conn).configuration(), - tsProfileData, - versionId, - storeRule, - overrideProtection, - versionTimeStamp, - timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); - } - ); - } - - - public List catalogTimeSeriesProfileInstances(String officeIdMask, - String locationIdMask, String parameterIdMask, String versionMask) - { - List timeSeriesProfileInstanceList = new ArrayList<>(); - - Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue( - cwmsTsProfileView.LOCATION_ID, locationIdMask); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( - cwmsTsProfileView.OFFICE_ID, officeIdMask)); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( - cwmsTsProfileView.KEY_PARAMETER_ID, parameterIdMask)); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( - cwmsTsProfileView.VERSION_ID, versionMask)); - - @NotNull Result timeSeriesProfileInstanceResults = dsl.select(asterisk()) - .from(cwmsTsProfileView) - .where(whereCondition) - .fetch(); - for (Record result : timeSeriesProfileInstanceResults) { - CwmsId locationId = new CwmsId.Builder() - .withOfficeId(cwmsTsProfileView.OFFICE_ID.get(result)) - .withName(cwmsTsProfileView.LOCATION_ID.get(result)) - .build(); - String parameterId = cwmsTsProfileView.KEY_PARAMETER_ID.get(result); - TimeSeriesProfile timeSeriesProfile = new TimeSeriesProfile.Builder() - .withLocationId(locationId) - .withKeyParameter(parameterId) - .build(); - TimeSeriesProfileInstance timeSeriesProfileInstance = new TimeSeriesProfileInstance.Builder() - .withTimeSeriesProfile(timeSeriesProfile) - .withVersion(cwmsTsProfileView.VERSION_ID.get(result)) - .withVersionDate(cwmsTsProfileView.VERSION_DATE.get(result) != null - ? cwmsTsProfileView.VERSION_DATE.get(result).toInstant() : null) - .withFirstDate(cwmsTsProfileView.FIRST_DATE_TIME.get(result) != null - ? cwmsTsProfileView.FIRST_DATE_TIME.get(result).toInstant() : null) - .withLastDate(cwmsTsProfileView.LAST_DATE_TIME.get(result) != null - ? cwmsTsProfileView.LAST_DATE_TIME.get(result).toInstant() : null) - .build(); - - timeSeriesProfileInstanceList.add(timeSeriesProfileInstance); - } - return timeSeriesProfileInstanceList; - } - - public TimeSeriesProfileInstance retrieveTimeSeriesProfileInstance(CwmsId location, String keyParameter, - String version, - List unit, - Instant startTime, - Instant endTime, - String timeZone, - boolean startInclusive, - boolean endInclusive, - boolean previous, - boolean next, - Instant versionDate, - boolean maxVersion, - String page, - int pageSize) - { - Integer total = null; - String cursor = null; - Timestamp tsCursor = null; - String parameterId = null; - - if (versionDate != null && maxVersion) { - throw new IllegalArgumentException("Cannot specify both version date and max version"); - } - - // Decode the cursor - if (page != null && !page.isEmpty()) { - final String[] parts = CwmsDTOPaginated.decodeCursor(page); - - logger.fine("Decoded cursor"); - logger.finest(() -> { - StringBuilder sb = new StringBuilder(); - for (String part : parts) { - sb.append(part).append("\n"); - } - return sb.toString(); - }); - - if (parts.length > 1) { - cursor = parts[0]; - tsCursor = Timestamp.from(Instant.ofEpochMilli(Long.parseLong(parts[0]))); - - if (parts.length > 2) { - parameterId = parts[1]; - total = Integer.parseInt(parts[2]); - } - } - } - - Condition whereCondition; - if (!maxVersion && versionDate != null) { - // Build the where condition - whereCondition = cwmsTsInstView.KEY_PARAMETER_ID.eq(keyParameter) - .and(cwmsTsInstView.LOCATION_ID.eq(location.getName()) - .and(cwmsTsInstView.OFFICE_ID.eq(location.getOfficeId())) - .and(cwmsTsInstView.VERSION_ID.eq(version)) - .and(cwmsTsInstView.VERSION_DATE.eq(Timestamp.from(versionDate)))); - } - else { - whereCondition = cwmsTsInstView.KEY_PARAMETER_ID.eq(keyParameter) - .and(cwmsTsInstView.LOCATION_ID.eq(location.getName()) - .and(cwmsTsInstView.OFFICE_ID.eq(location.getOfficeId())) - .and(cwmsTsInstView.VERSION_ID.eq(version))); - } - - // Add the unit conditions - Condition unitCondition = cwmsTsInstView.UNIT_ID.eq(unit.get(0)); + private static final Logger logger = Logger.getLogger(TimeSeriesProfileInstanceDao.class.getName()); + private static final AV_TS_PROFILE_INST_TSV2 VIEW_TSV2 = AV_TS_PROFILE_INST_TSV2.AV_TS_PROFILE_INST_TSV2; + private static final AV_TS_PROFILE_INST VIEW = AV_TS_PROFILE_INST.AV_TS_PROFILE_INST; + + public TimeSeriesProfileInstanceDao(DSLContext dsl) { + super(dsl); + } + + public void storeTimeSeriesProfileInstance(TimeSeriesProfile timeSeriesProfile, String profileData, + Instant versionDate, String versionId, String storeRule, boolean overrideProtection) { + connection(dsl, conn -> { + setOffice(conn, timeSeriesProfile.getLocationId().getOfficeId()); + CWMS_TS_PROFILE_PACKAGE.call_STORE_TS_PROFILE_INSTANCE__2(using(conn).configuration(), + timeSeriesProfile.getLocationId().getName(), + timeSeriesProfile.getKeyParameter(), + profileData, + versionId, + storeRule, + overrideProtection ? "T" : "F", + versionDate != null ? Timestamp.from(versionDate) : null, + timeSeriesProfile.getLocationId().getOfficeId()); + }); + } + + public void storeTimeSeriesProfileInstance(TimeSeriesProfileInstance timeseriesProfileInstance, String versionId, + Instant versionInstant, String storeRule,String overrideProtection) { + connection(dsl, conn -> { + setOffice(conn, timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); + Map parameterIdToCode = new HashMap<>(); + + String parameter = timeseriesProfileInstance.getTimeSeriesProfile().getKeyParameter(); + BigDecimal parameterCodeDec = CWMS_UTIL_PACKAGE.call_GET_PARAMETER_CODE(using(conn).configuration(), + parameter, timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); + parameterIdToCode.put(parameter, parameterCodeDec.toBigInteger()); + + List dependentParameters = timeseriesProfileInstance.getTimeSeriesProfile().getParameterList(); + for (String param : dependentParameters) { + parameter = param; + parameterCodeDec = CWMS_UTIL_PACKAGE.call_GET_PARAMETER_CODE(using(conn).configuration(), parameter, + timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); + parameterIdToCode.put(parameter, parameterCodeDec.toBigInteger()); + } + + TS_PROF_DATA_T tsProfileData = new TS_PROF_DATA_T(); + tsProfileData.attach(using(conn).configuration()); + + TS_PROF_DATA_TAB_T records = new TS_PROF_DATA_TAB_T(); + + STR_TAB_T units = new STR_TAB_T(); + for (Map.Entry> entry + : timeseriesProfileInstance.getTimeSeriesList().entrySet()) { + Long timestamp = entry.getKey(); + TS_PROF_DATA_REC_T dataRecord = new TS_PROF_DATA_REC_T(); + Timestamp timeStamp = Timestamp.from(Instant.ofEpochMilli(timestamp)); + dataRecord.setDATE_TIME(timeStamp); + + PVQ_TAB_T parameters = new PVQ_TAB_T(); + int n = 0; + for (TimeSeriesData data : entry.getValue()) { + PVQ_T pvq = new PVQ_T(); + String parameterId = timeseriesProfileInstance.getParameterColumns().get(n).getParameter(); + BigInteger parameterCode = parameterIdToCode.get(parameterId); + pvq.setPARAMETER_CODE(parameterCode); + pvq.setVALUE(data.getValue()); + pvq.setQUALITY_CODE(BigInteger.valueOf(data.getQuality())); + parameters.add(pvq); + if (!units.contains(timeseriesProfileInstance.getParameterColumns().get(n).getUnit())) { + units.add(timeseriesProfileInstance.getParameterColumns().get(n).getUnit()); + } + n++; + } + dataRecord.setPARAMETERS(parameters); + records.add(dataRecord); + } + + BigDecimal locationCodeId = CWMS_LOC_PACKAGE.call_GET_LOCATION_CODE(using(conn).configuration(), + timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId(), + timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getName()); + + tsProfileData.setRECORDS(records); + tsProfileData.setLOCATION_CODE(locationCodeId.toBigInteger()); + tsProfileData.setTIME_ZONE("UTC"); + tsProfileData.setKEY_PARAMETER(parameterIdToCode.get(timeseriesProfileInstance + .getTimeSeriesProfile().getKeyParameter())); + tsProfileData.setUNITS(units); + + Timestamp versionTimeStamp = Timestamp.from(versionInstant); + + CWMS_TS_PROFILE_PACKAGE.call_STORE_TS_PROFILE_INSTANCE(using(conn).configuration(), + tsProfileData, + versionId, + storeRule, + overrideProtection, + versionTimeStamp, + timeseriesProfileInstance.getTimeSeriesProfile().getLocationId().getOfficeId()); + }); + } + + + public List catalogTimeSeriesProfileInstances(String officeIdMask, + String locationIdMask, String parameterIdMask, String versionMask) { + + Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue( + VIEW.LOCATION_ID, locationIdMask); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( + VIEW.OFFICE_ID, officeIdMask)); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( + VIEW.KEY_PARAMETER_ID, parameterIdMask)); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex( + VIEW.VERSION_ID, versionMask)); + + @NotNull Result timeSeriesProfileInstanceResults = dsl.select(asterisk()) + .from(VIEW) + .where(whereCondition) + .fetch(); + List timeSeriesProfileInstanceList = new ArrayList<>(); + for (Record result : timeSeriesProfileInstanceResults) { + CwmsId locationId = new CwmsId.Builder() + .withOfficeId(result.get(VIEW.OFFICE_ID)) + .withName(result.get(VIEW.LOCATION_ID)) + .build(); + String parameterId = result.get(VIEW.KEY_PARAMETER_ID); + TimeSeriesProfile timeSeriesProfile = new TimeSeriesProfile.Builder() + .withLocationId(locationId) + .withKeyParameter(parameterId) + .build(); + TimeSeriesProfileInstance timeSeriesProfileInstance = new TimeSeriesProfileInstance.Builder() + .withTimeSeriesProfile(timeSeriesProfile) + .withVersion(result.get(VIEW.VERSION_ID)) + .withVersionDate(result.get(VIEW.VERSION_DATE) != null + ? result.get(VIEW.VERSION_DATE).toInstant() : null) + .withFirstDate(result.get(VIEW.FIRST_DATE_TIME) != null + ? result.get(VIEW.FIRST_DATE_TIME).toInstant() : null) + .withLastDate(result.get(VIEW.LAST_DATE_TIME) != null + ? result.get(VIEW.LAST_DATE_TIME).toInstant() : null) + .build(); + + timeSeriesProfileInstanceList.add(timeSeriesProfileInstance); + } + return timeSeriesProfileInstanceList; + } + + public TimeSeriesProfileInstance retrieveTimeSeriesProfileInstance(CwmsId location, String keyParameter, + String version, + List unit, + Instant startTime, + Instant endTime, + String timeZone, + boolean startInclusive, + boolean endInclusive, + boolean previous, + boolean next, + Instant versionDate, + boolean maxVersion, + String page, + int pageSize) { + + Integer total = null; + String cursor = null; + Timestamp tsCursor = null; + String parameterId = null; + + if (versionDate != null && maxVersion) { + throw new IllegalArgumentException("Cannot specify both version date and max version"); + } + + // Decode the cursor + if (page != null && !page.isEmpty()) { + final String[] parts = CwmsDTOPaginated.decodeCursor(page); + + logger.fine("Decoded cursor"); + logger.finest(() -> { + StringBuilder sb = new StringBuilder(); + for (String part : parts) { + sb.append(part).append("\n"); + } + return sb.toString(); + }); + + if (parts.length > 1) { + cursor = parts[0]; + tsCursor = Timestamp.from(Instant.ofEpochMilli(Long.parseLong(parts[0]))); + + if (parts.length > 2) { + parameterId = parts[1]; + total = Integer.parseInt(parts[2]); + } + } + } + + Condition whereCondition; + if (!maxVersion && versionDate != null) { + // Build the where condition + whereCondition = VIEW_TSV2.KEY_PARAMETER_ID.eq(keyParameter) + .and(VIEW_TSV2.LOCATION_ID.eq(location.getName()) + .and(VIEW_TSV2.OFFICE_ID.eq(location.getOfficeId())) + .and(VIEW_TSV2.VERSION_ID.eq(version)) + .and(VIEW_TSV2.VERSION_DATE.eq(Timestamp.from(versionDate)))); + } else { + whereCondition = VIEW_TSV2.KEY_PARAMETER_ID.eq(keyParameter) + .and(VIEW_TSV2.LOCATION_ID.eq(location.getName()) + .and(VIEW_TSV2.OFFICE_ID.eq(location.getOfficeId())) + .and(VIEW_TSV2.VERSION_ID.eq(version))); + } + + // Add the unit conditions + Condition unitCondition = VIEW_TSV2.UNIT_ID.eq(unit.get(0)); for (int i = 1; i < unit.size(); i++) { - unitCondition = unitCondition.or(cwmsTsInstView.UNIT_ID.eq(unit.get(i))); + unitCondition = unitCondition.or(VIEW_TSV2.UNIT_ID.eq(unit.get(i))); } whereCondition = whereCondition.and(unitCondition); - // give the date time columns a name - Field endTimeCol = cwmsTsInstView.LAST_DATE_TIME; - Field startTimeCol = cwmsTsInstView.FIRST_DATE_TIME; - Field dateTimeCol = cwmsTsInstView.DATE_TIME; - - // handle previous flag - if (previous) { - Timestamp previousDateTime = null; - SelectConditionStep> prev = dsl.select(max(cwmsTsInstView.DATE_TIME)) - .from(cwmsTsInstView) - .where(whereCondition.and(dateTimeCol.lessThan(Timestamp.from(startTime))) - .and(endTimeCol.greaterThan(Timestamp.from(startTime)))); - previousDateTime = prev.fetchOne().value1(); - if (previousDateTime != null) { - startTime = previousDateTime.toInstant(); - startInclusive = true; - } - } - - // handle next flag - if (next) { - Timestamp nextDateTime = null; - SelectConditionStep> nex = dsl.select(min(cwmsTsInstView.DATE_TIME)) - .from(cwmsTsInstView) - .where(whereCondition.and(dateTimeCol.greaterThan(Timestamp.from(endTime))) - .and(startTimeCol.le(Timestamp.from(endTime)))); - nextDateTime = nex.fetchOne().value1(); - if (nextDateTime != null) { - endTime = nextDateTime.toInstant(); - endInclusive = true; - } - } - - // Add the time windows conditions depending on the inclusive flags - if (startInclusive && endInclusive){ - whereCondition = whereCondition - .and(cwmsTsInstView.FIRST_DATE_TIME.ge(Timestamp.from(startTime))) - .and(cwmsTsInstView.LAST_DATE_TIME.le(Timestamp.from(endTime))); - } else if (!startInclusive && endInclusive) { - whereCondition = whereCondition - .and(cwmsTsInstView.FIRST_DATE_TIME.greaterThan(Timestamp.from(startTime))) - .and(cwmsTsInstView.LAST_DATE_TIME.le(Timestamp.from(endTime))); - } else if (startInclusive) { - whereCondition = whereCondition - .and(cwmsTsInstView.FIRST_DATE_TIME.ge(Timestamp.from(startTime))) - .and(cwmsTsInstView.LAST_DATE_TIME.lessThan(Timestamp.from(endTime))); - } else { - whereCondition = whereCondition - .and(cwmsTsInstView.FIRST_DATE_TIME.greaterThan(Timestamp.from(startTime))) - .and(cwmsTsInstView.LAST_DATE_TIME.lessThan(Timestamp.from(endTime))); - } - Condition finalWhereCondition = whereCondition; - - // set semi-final variables for lambda - final String recordCursor = cursor; - final int recordPageSize = pageSize; - - // Get the total number of records if not already set - if (total == null) { - SelectConditionStep> count = dsl.select(count(asterisk())) - .from(cwmsTsInstView) - .where(finalWhereCondition); - total = count.fetchOne().value1(); - } - - // Get the max version date if needed - Timestamp maxVersionDate = null; - if (maxVersion) { - SelectConditionStep> maxVer = dsl.select(max(cwmsTsInstView.VERSION_DATE)) - .from(cwmsTsInstView) - .where(finalWhereCondition); - maxVersionDate = maxVer.fetchOne().value1(); - } - Timestamp minVersionDate = null; - if (!maxVersion && versionDate == null) { - SelectConditionStep> minVer = dsl.select(min(cwmsTsInstView.VERSION_DATE)) - .from(cwmsTsInstView) - .where(finalWhereCondition); - minVersionDate = minVer.fetchOne().value1(); - } - - // generate and run query to get the time series profile data - Result> result = null; - SelectSeekStep1, Timestamp> resultQuery = null; - SelectConditionStep> resultCondQuery = null; - SelectSeekLimitStep> resultQuery2 = null; - if (pageSize != 0) { - if (maxVersion) { - resultCondQuery = dsl.select(cwmsTsInstView.VALUE, - cwmsTsInstView.QUALITY_CODE, - cwmsTsInstView.DATE_TIME, - cwmsTsInstView.LOCATION_CODE, - cwmsTsInstView.KEY_PARAMETER_CODE, - cwmsTsInstView.PARAMETER_ID, - cwmsTsInstView.UNIT_ID) - .from(cwmsTsInstView) - .where(finalWhereCondition.and(cwmsTsInstView.VERSION_DATE.eq(maxVersionDate))); - } else if (versionDate == null) { - resultCondQuery = dsl.select(cwmsTsInstView.VALUE, - cwmsTsInstView.QUALITY_CODE, - cwmsTsInstView.DATE_TIME, - cwmsTsInstView.LOCATION_CODE, - cwmsTsInstView.KEY_PARAMETER_CODE, - cwmsTsInstView.PARAMETER_ID, - cwmsTsInstView.UNIT_ID) - .from(cwmsTsInstView) - .where(finalWhereCondition.and(cwmsTsInstView.VERSION_DATE.eq(minVersionDate))); - } else { - resultCondQuery = dsl.select(cwmsTsInstView.VALUE, - cwmsTsInstView.QUALITY_CODE, - cwmsTsInstView.DATE_TIME, - cwmsTsInstView.LOCATION_CODE, - cwmsTsInstView.KEY_PARAMETER_CODE, - cwmsTsInstView.PARAMETER_ID, - cwmsTsInstView.UNIT_ID) - .from(cwmsTsInstView) - .where(finalWhereCondition); - } - - // If there is a cursor, use it with the JOOQ seek method - // Needs the parameter and cursor of the record before the first one on the next page - // to correctly split the data into pages - // Searches for matching records based on the cursor to start the next page's results - if (tsCursor == null) { - resultQuery = resultCondQuery.and(dateTimeCol.greaterOrEqual(CWMS_UTIL_PACKAGE - .call_TO_TIMESTAMP__2(val(startTime.toEpochMilli())))) - .and(dateTimeCol.lessOrEqual(CWMS_UTIL_PACKAGE - .call_TO_TIMESTAMP__2(val(endTime.toEpochMilli())))) - .orderBy(cwmsTsInstView.DATE_TIME); - - } else { - resultQuery2 = resultCondQuery - .and(dateTimeCol.greaterOrEqual(CWMS_UTIL_PACKAGE - .call_TO_TIMESTAMP__2(val(tsCursor.toInstant().toEpochMilli())))) - .and(dateTimeCol.lessOrEqual(CWMS_UTIL_PACKAGE - .call_TO_TIMESTAMP__2(val(endTime.toEpochMilli())))) - .orderBy(cwmsTsInstView.DATE_TIME, cwmsTsInstView.PARAMETER_ID) - .seek(tsCursor, parameterId); - } - - // Get the results - // if the page number is set, limit the results to the page size (plus one for setting the next page) - if (pageSize > 0) { - if (tsCursor == null) { - result = resultQuery.limit(pageSize + 1).fetch(); - } else { - result = resultQuery2.limit(pageSize + 1).fetch(); - } - } else { - if (tsCursor == null) { - result = resultQuery.fetch(); - } else { - result = resultQuery2.fetch(); - } - } - Result lastRecord = result; - logger.fine(lastRecord::toString); - } - - // Throw 404 if no results - if (result == null || result.isEmpty()) { - throw new NotFoundException("No time series profile data found for the given parameters"); - } - - // map the results to a TimeSeriesProfileInstance - Result finalResult = result; - int totalRecords = total; - TS_PROF_DATA_T timeSeriesProfileData; - BigInteger locationCode = null; - BigInteger keyParameterCode = null; - STR_TAB_T units = new STR_TAB_T(unit); - TS_PROF_DATA_TAB_T records = new TS_PROF_DATA_TAB_T(); - Map> timeValuePairMap = new TreeMap<>(); - Map unitParamMap = new TreeMap<>(); - - // boolean to keep track of data that is consistent across all records - boolean parentData = false; - for (Record resultRecord : finalResult) { - if (!parentData) { - locationCode = BigInteger.valueOf(cwmsTsInstView.LOCATION_CODE.get(resultRecord)); - keyParameterCode = BigInteger.valueOf(cwmsTsInstView.KEY_PARAMETER_CODE.get(resultRecord)); - parentData = true; - } - - // map the unit to the parameter - if (unitParamMap.get(cwmsTsInstView.PARAMETER_ID.get(resultRecord)) == null) { - unitParamMap.put(cwmsTsInstView.PARAMETER_ID.get(resultRecord), - cwmsTsInstView.UNIT_ID.get(resultRecord)); - } - - // map the parameter, TVQ data - Timestamp dateTime = cwmsTsInstView.DATE_TIME.get(resultRecord); - Map dataMap; - if (timeValuePairMap.get(dateTime) == null) { - dataMap = new TreeMap<>(); - } else { - dataMap = timeValuePairMap.get(dateTime); - } - dataMap.put(cwmsTsInstView.PARAMETER_ID.get(resultRecord), new PVQ_T(keyParameterCode, - cwmsTsInstView.VALUE.get(resultRecord), - BigInteger.valueOf(cwmsTsInstView.QUALITY_CODE.get(resultRecord)))); - timeValuePairMap.put(dateTime, dataMap); - } - - // map the value/quality data to the timestamp - int index = 0; - for (Map.Entry> entry : timeValuePairMap.entrySet()) { - PVQ_TAB_T parameters = new PVQ_TAB_T(); - for (Map.Entry value : entry.getValue().entrySet()) { - parameters.add(value.getValue()); - } - records.add(index, new TS_PROF_DATA_REC_T(entry.getKey(), parameters)); - index++; - } - - timeSeriesProfileData = new TS_PROF_DATA_T(locationCode, keyParameterCode, timeZone, units, records); - - if (minVersionDate != null) { - versionDate = minVersionDate.toInstant(); - } else if (maxVersionDate != null) { - versionDate = maxVersionDate.toInstant(); - } - - // map the TimeSeriesProfileInstance without the value/quality data - TimeSeriesProfileInstance returnInstance = map(location.getOfficeId(), location.getName(), keyParameter, - timeSeriesProfileData, version, versionDate, startTime, endTime, unitParamMap, recordCursor, - recordPageSize, totalRecords); - - List paramlist = returnInstance.getParameterColumns(); - - // map the TVQ data to the TimeSeriesProfileInstance - // needs previous parameter and cursor to be set to correctly split the data into pages - // adds page, nextpage data to the TimeSeriesProfileInstance - String previousParameter = null; - Timestamp previousCursor = Timestamp.from(startTime); - for (Map.Entry> entry : timeValuePairMap.entrySet()) { - for (Map.Entry dataValue : entry.getValue().entrySet()) { - Timestamp dateTime = entry.getKey(); - returnInstance.addValue(dateTime, dataValue.getValue().getVALUE(), dataValue.getValue().getQUALITY_CODE().intValue(), - previousParameter, previousCursor); - previousCursor = dateTime; - previousParameter = dataValue.getKey(); - } - } - - // add null values to the TimeSeriesProfileInstance value list if the data is missing for the associated parameter - for (Map.Entry> entry : returnInstance.getTimeSeriesList().entrySet()) { - if (entry.getValue().size() < paramlist.size()) { - for (int i = 0; i < paramlist.size(); i++) { - Timestamp dateTime = Timestamp.from(Instant.ofEpochMilli(entry.getKey())); - try { - entry.getValue().get(i); - } catch (IndexOutOfBoundsException e) { - returnInstance.addNullValue(dateTime, i); - continue; - } - if (timeValuePairMap.get(dateTime) == null - || !timeValuePairMap.get(dateTime).containsKey(paramlist.get(i).getParameter())) { - returnInstance.addNullValue(dateTime, i); - } - } - } - } - - return returnInstance; - } - - public void deleteTimeSeriesProfileInstance(CwmsId location, String keyParameter, - String version, Instant firstDate, String timeZone,boolean overrideProtection, Instant versionDate) - { - connection(dsl, conn -> { - setOffice(conn, location.getOfficeId()); - Timestamp versionTimestamp = null; - if(versionDate!=null) { - versionTimestamp = Timestamp.from(versionDate); - } - - CWMS_TS_PROFILE_PACKAGE.call_DELETE_TS_PROFILE_INSTANCE( - using(conn).configuration(), - location.getName(), - keyParameter, - version, - Timestamp.from(firstDate), - timeZone, - overrideProtection?"T":"F", - versionTimestamp, - location.getOfficeId() - ); - - }); - } - - - private TimeSeriesProfileInstance map(String officeId, String location, String keyParameter, - TS_PROF_DATA_T timeSeriesProfileData, String version, Instant versionDate, Instant startTime, - Instant endTime, Map unitParamMap, String page, int pageSize, int total) { - String timeZone = timeSeriesProfileData.getTIME_ZONE(); - TS_PROF_DATA_TAB_T records = timeSeriesProfileData.getRECORDS(); - List timeList = new ArrayList<>(); - List dataColumnInfoList = new ArrayList<>(); - DataColumnInfo valueDataColumnInfo = new DataColumnInfo.Builder() - .withName("value") - .withOrdinal(1) - .withDataType(Double.class.getName()) - .build(); - DataColumnInfo qualityDataColumnInfo = new DataColumnInfo.Builder() - .withName("quality") - .withOrdinal(2) - .withDataType(Integer.class.getName()) - .build(); - dataColumnInfoList.add(valueDataColumnInfo); - dataColumnInfoList.add(qualityDataColumnInfo); - - for (TS_PROF_DATA_REC_T dataRecord : records) { - Timestamp dateTime = dataRecord.getDATE_TIME(); - timeList.add(dateTime.toInstant()); - } - - List parameterColumnInfoList = new ArrayList<>(); - int ordinal = 1; - for (Map.Entry entry : unitParamMap.entrySet()) { - ParameterColumnInfo parameterColumnInfo = new ParameterColumnInfo.Builder() - .withParameter(entry.getKey()) - .withOrdinal(ordinal) - .withUnit(entry.getValue()) - .build(); - ordinal++; - parameterColumnInfoList.add(parameterColumnInfo); - } - - List parameterList = new ArrayList<>(unitParamMap.keySet()); - - CwmsId locationId = new CwmsId.Builder() - .withOfficeId(officeId) - .withName(location) - .build(); - TimeSeriesProfile timeSeriesProfile = new TimeSeriesProfile.Builder() - .withKeyParameter(keyParameter) - .withLocationId(locationId) - .withParameterList(parameterList) - .build(); - return new TimeSeriesProfileInstance.Builder() - .withTimeSeriesProfile(timeSeriesProfile) - .withTimeSeriesList(new TreeMap<>()) - .withVersion(version) - .withFirstDate(startTime) - .withLastDate(endTime) - .withLocationTimeZone(timeZone) - .withPage(page) - .withPageSize(pageSize) - .withTotal(total) - .withDataColumns(dataColumnInfoList) - .withParameterColumns(parameterColumnInfoList) - .withPageFirstDate(timeList.stream().min(Instant::compareTo).orElse(null)) - .withPageLastDate(timeList.stream().max(Instant::compareTo).orElse(null)) - .withVersionDate(versionDate) - .build(); - } + // give the date time columns a name + Field endTimeCol = VIEW_TSV2.LAST_DATE_TIME; + Field startTimeCol = VIEW_TSV2.FIRST_DATE_TIME; + Field dateTimeCol = VIEW_TSV2.DATE_TIME; + + // handle previous flag + if (previous) { + Timestamp previousDateTime = null; + SelectConditionStep> prev = dsl.select(max(VIEW_TSV2.DATE_TIME)) + .from(VIEW_TSV2) + .where(whereCondition.and(dateTimeCol.lessThan(Timestamp.from(startTime))) + .and(endTimeCol.greaterThan(Timestamp.from(startTime)))); + previousDateTime = prev.fetchOne().value1(); + if (previousDateTime != null) { + startTime = previousDateTime.toInstant(); + startInclusive = true; + } + } + + // handle next flag + if (next) { + Timestamp nextDateTime = null; + SelectConditionStep> nex = dsl.select(min(VIEW_TSV2.DATE_TIME)) + .from(VIEW_TSV2) + .where(whereCondition.and(dateTimeCol.greaterThan(Timestamp.from(endTime))) + .and(startTimeCol.le(Timestamp.from(endTime)))); + nextDateTime = nex.fetchOne().value1(); + if (nextDateTime != null) { + endTime = nextDateTime.toInstant(); + endInclusive = true; + } + } + + // Add the time windows conditions depending on the inclusive flags + if (startInclusive && endInclusive) { + whereCondition = whereCondition + .and(VIEW_TSV2.FIRST_DATE_TIME.ge(Timestamp.from(startTime))) + .and(VIEW_TSV2.LAST_DATE_TIME.le(Timestamp.from(endTime))); + } else if (!startInclusive && endInclusive) { + whereCondition = whereCondition + .and(VIEW_TSV2.FIRST_DATE_TIME.greaterThan(Timestamp.from(startTime))) + .and(VIEW_TSV2.LAST_DATE_TIME.le(Timestamp.from(endTime))); + } else if (startInclusive) { + whereCondition = whereCondition + .and(VIEW_TSV2.FIRST_DATE_TIME.ge(Timestamp.from(startTime))) + .and(VIEW_TSV2.LAST_DATE_TIME.lessThan(Timestamp.from(endTime))); + } else { + whereCondition = whereCondition + .and(VIEW_TSV2.FIRST_DATE_TIME.greaterThan(Timestamp.from(startTime))) + .and(VIEW_TSV2.LAST_DATE_TIME.lessThan(Timestamp.from(endTime))); + } + Condition finalWhereCondition = whereCondition; + + // set semi-final variables for lambda + final String recordCursor = cursor; + final int recordPageSize = pageSize; + + // Get the total number of records if not already set + if (total == null) { + SelectConditionStep> count = dsl.select(count(VIEW_TSV2.LOCATION_CODE)) + .from(VIEW_TSV2) + .where(finalWhereCondition); + total = count.fetchOne().value1(); + } + + // Get the max version date if needed + Timestamp maxVersionDate = null; + if (maxVersion) { + SelectConditionStep> maxVer = dsl.select(max(VIEW_TSV2.VERSION_DATE)) + .from(VIEW_TSV2) + .where(finalWhereCondition); + maxVersionDate = maxVer.fetchOne().value1(); + } + Timestamp minVersionDate = null; + if (!maxVersion && versionDate == null) { + SelectConditionStep> minVer = dsl.select(min(VIEW_TSV2.VERSION_DATE)) + .from(VIEW_TSV2) + .where(finalWhereCondition); + minVersionDate = minVer.fetchOne().value1(); + } + + // generate and run query to get the time series profile data + Result> result = null; + SelectSeekStep1, Timestamp> resultQuery = null; + SelectConditionStep> resultCondQuery = null; + SelectSeekLimitStep> resultQuery2 = null; + if (pageSize != 0) { + if (maxVersion) { + resultCondQuery = dsl.select(VIEW_TSV2.VALUE, + VIEW_TSV2.QUALITY_CODE, + VIEW_TSV2.DATE_TIME, + VIEW_TSV2.LOCATION_CODE, + VIEW_TSV2.KEY_PARAMETER_CODE, + VIEW_TSV2.PARAMETER_ID, + VIEW_TSV2.UNIT_ID) + .from(VIEW_TSV2) + .where(finalWhereCondition.and(VIEW_TSV2.VERSION_DATE.eq(maxVersionDate))); + } else if (versionDate == null) { + resultCondQuery = dsl.select(VIEW_TSV2.VALUE, + VIEW_TSV2.QUALITY_CODE, + VIEW_TSV2.DATE_TIME, + VIEW_TSV2.LOCATION_CODE, + VIEW_TSV2.KEY_PARAMETER_CODE, + VIEW_TSV2.PARAMETER_ID, + VIEW_TSV2.UNIT_ID) + .from(VIEW_TSV2) + .where(finalWhereCondition.and(VIEW_TSV2.VERSION_DATE.eq(minVersionDate))); + } else { + resultCondQuery = dsl.select(VIEW_TSV2.VALUE, + VIEW_TSV2.QUALITY_CODE, + VIEW_TSV2.DATE_TIME, + VIEW_TSV2.LOCATION_CODE, + VIEW_TSV2.KEY_PARAMETER_CODE, + VIEW_TSV2.PARAMETER_ID, + VIEW_TSV2.UNIT_ID) + .from(VIEW_TSV2) + .where(finalWhereCondition); + } + + // If there is a cursor, use it with the JOOQ seek method + // Needs the parameter and cursor of the record before the first one on the next page + // to correctly split the data into pages + // Searches for matching records based on the cursor to start the next page's results + if (tsCursor == null) { + resultQuery = resultCondQuery.and(dateTimeCol.greaterOrEqual(CWMS_UTIL_PACKAGE + .call_TO_TIMESTAMP__2(val(startTime.toEpochMilli())))) + .and(dateTimeCol.lessOrEqual(CWMS_UTIL_PACKAGE + .call_TO_TIMESTAMP__2(val(endTime.toEpochMilli())))) + .orderBy(VIEW_TSV2.DATE_TIME); + + } else { + resultQuery2 = resultCondQuery + .and(dateTimeCol.greaterOrEqual(CWMS_UTIL_PACKAGE + .call_TO_TIMESTAMP__2(val(tsCursor.toInstant().toEpochMilli())))) + .and(dateTimeCol.lessOrEqual(CWMS_UTIL_PACKAGE + .call_TO_TIMESTAMP__2(val(endTime.toEpochMilli())))) + .orderBy(VIEW_TSV2.DATE_TIME, VIEW_TSV2.PARAMETER_ID) + .seek(tsCursor, parameterId); + } + + // Get the results + // if the page number is set, limit the results to the page size (plus one for setting the next page) + if (pageSize > 0) { + if (tsCursor == null) { + result = resultQuery.limit(pageSize + 1).fetch(); + } else { + result = resultQuery2.limit(pageSize + 1).fetch(); + } + } else { + if (tsCursor == null) { + result = resultQuery.fetch(); + } else { + result = resultQuery2.fetch(); + } + } + Result lastRecord = result; + logger.fine(lastRecord::toString); + } + + // Throw 404 if no results + if (result == null || result.isEmpty()) { + throw new NotFoundException("No time series profile data found for the given parameters"); + } + + // map the results to a TimeSeriesProfileInstance + Result finalResult = result; + + BigInteger locationCode = null; + BigInteger keyParameterCode = null; + STR_TAB_T units = new STR_TAB_T(unit); + TS_PROF_DATA_TAB_T records = new TS_PROF_DATA_TAB_T(); + Map> timeValuePairMap = new TreeMap<>(); + Map unitParamMap = new TreeMap<>(); + + // boolean to keep track of data that is consistent across all records + boolean parentData = false; + for (Record resultRecord : finalResult) { + if (!parentData) { + locationCode = BigInteger.valueOf(resultRecord.get(VIEW_TSV2.LOCATION_CODE)); + keyParameterCode = BigInteger.valueOf(resultRecord.get(VIEW_TSV2.KEY_PARAMETER_CODE)); + parentData = true; + } + + // map the unit to the parameter + if (unitParamMap.get(resultRecord.get(VIEW_TSV2.PARAMETER_ID)) == null) { + unitParamMap.put(resultRecord.get(VIEW_TSV2.PARAMETER_ID), + resultRecord.get(VIEW_TSV2.UNIT_ID)); + } + + // map the parameter, TVQ data + Timestamp dateTime = resultRecord.get(VIEW_TSV2.DATE_TIME); + Map dataMap; + if (timeValuePairMap.get(dateTime) == null) { + dataMap = new TreeMap<>(); + } else { + dataMap = timeValuePairMap.get(dateTime); + } + dataMap.put(resultRecord.get(VIEW_TSV2.PARAMETER_ID), new PVQ_T(keyParameterCode, + resultRecord.get(VIEW_TSV2.VALUE), + BigInteger.valueOf(resultRecord.get(VIEW_TSV2.QUALITY_CODE)))); + timeValuePairMap.put(dateTime, dataMap); + } + + // map the value/quality data to the timestamp + int index = 0; + for (Map.Entry> entry : timeValuePairMap.entrySet()) { + PVQ_TAB_T parameters = new PVQ_TAB_T(); + for (Map.Entry value : entry.getValue().entrySet()) { + parameters.add(value.getValue()); + } + records.add(index, new TS_PROF_DATA_REC_T(entry.getKey(), parameters)); + index++; + } + + TS_PROF_DATA_T timeSeriesProfileData = new TS_PROF_DATA_T(locationCode, keyParameterCode, + timeZone, units, records); + + if (minVersionDate != null) { + versionDate = minVersionDate.toInstant(); + } else if (maxVersionDate != null) { + versionDate = maxVersionDate.toInstant(); + } + + int totalRecords = total; + + // map the TimeSeriesProfileInstance without the value/quality data + TimeSeriesProfileInstance returnInstance = map(location.getOfficeId(), location.getName(), keyParameter, + timeSeriesProfileData, version, versionDate, startTime, endTime, unitParamMap, recordCursor, + recordPageSize, totalRecords); + + List paramlist = returnInstance.getParameterColumns(); + + // map the TVQ data to the TimeSeriesProfileInstance + // needs previous parameter and cursor to be set to correctly split the data into pages + // adds page, nextpage data to the TimeSeriesProfileInstance + String previousParameter = null; + Timestamp previousCursor = Timestamp.from(startTime); + for (Map.Entry> entry : timeValuePairMap.entrySet()) { + for (Map.Entry dataValue : entry.getValue().entrySet()) { + Timestamp dateTime = entry.getKey(); + returnInstance.addValue(dateTime, dataValue.getValue().getVALUE(), + dataValue.getValue().getQUALITY_CODE().intValue(), + previousParameter, previousCursor); + previousCursor = dateTime; + previousParameter = dataValue.getKey(); + } + } + + // add null values to the TimeSeriesProfileInstance value list if + // the data is missing for the associated parameter + for (Map.Entry> entry : returnInstance.getTimeSeriesList().entrySet()) { + if (entry.getValue().size() < paramlist.size()) { + for (int i = 0; i < paramlist.size(); i++) { + Timestamp dateTime = Timestamp.from(Instant.ofEpochMilli(entry.getKey())); + try { + entry.getValue().get(i); + } catch (IndexOutOfBoundsException e) { + returnInstance.addNullValue(dateTime, i); + continue; + } + if (timeValuePairMap.get(dateTime) == null + || !timeValuePairMap.get(dateTime).containsKey(paramlist.get(i).getParameter())) { + returnInstance.addNullValue(dateTime, i); + } + } + } + } + + return returnInstance; + } + + public void deleteTimeSeriesProfileInstance(CwmsId location, String keyParameter, + String version, Instant firstDate, String timeZone,boolean overrideProtection, Instant versionDate) { + + connection(dsl, conn -> { + setOffice(conn, location.getOfficeId()); + Timestamp versionTimestamp = null; + if (versionDate != null) { + versionTimestamp = Timestamp.from(versionDate); + } + + CWMS_TS_PROFILE_PACKAGE.call_DELETE_TS_PROFILE_INSTANCE( + using(conn).configuration(), + location.getName(), + keyParameter, + version, + Timestamp.from(firstDate), + timeZone, + overrideProtection ? "T" : "F", + versionTimestamp, + location.getOfficeId() + ); + }); + } + + + private TimeSeriesProfileInstance map(String officeId, String location, String keyParameter, + TS_PROF_DATA_T timeSeriesProfileData, String version, Instant versionDate, Instant startTime, + Instant endTime, Map unitParamMap, String page, int pageSize, int total) { + + List timeList = new ArrayList<>(); + List dataColumnInfoList = new ArrayList<>(); + DataColumnInfo valueDataColumnInfo = new DataColumnInfo.Builder() + .withName("value") + .withOrdinal(1) + .withDataType(Double.class.getName()) + .build(); + DataColumnInfo qualityDataColumnInfo = new DataColumnInfo.Builder() + .withName("quality") + .withOrdinal(2) + .withDataType(Integer.class.getName()) + .build(); + dataColumnInfoList.add(valueDataColumnInfo); + dataColumnInfoList.add(qualityDataColumnInfo); + TS_PROF_DATA_TAB_T records = timeSeriesProfileData.getRECORDS(); + for (TS_PROF_DATA_REC_T dataRecord : records) { + Timestamp dateTime = dataRecord.getDATE_TIME(); + timeList.add(dateTime.toInstant()); + } + + List parameterColumnInfoList = new ArrayList<>(); + int ordinal = 1; + for (Map.Entry entry : unitParamMap.entrySet()) { + ParameterColumnInfo parameterColumnInfo = new ParameterColumnInfo.Builder() + .withParameter(entry.getKey()) + .withOrdinal(ordinal) + .withUnit(entry.getValue()) + .build(); + ordinal++; + parameterColumnInfoList.add(parameterColumnInfo); + } + + List parameterList = new ArrayList<>(unitParamMap.keySet()); + String timeZone = timeSeriesProfileData.getTIME_ZONE(); + CwmsId locationId = new CwmsId.Builder() + .withOfficeId(officeId) + .withName(location) + .build(); + TimeSeriesProfile timeSeriesProfile = new TimeSeriesProfile.Builder() + .withKeyParameter(keyParameter) + .withLocationId(locationId) + .withParameterList(parameterList) + .build(); + return new TimeSeriesProfileInstance.Builder() + .withTimeSeriesProfile(timeSeriesProfile) + .withTimeSeriesList(new TreeMap<>()) + .withVersion(version) + .withFirstDate(startTime) + .withLastDate(endTime) + .withLocationTimeZone(timeZone) + .withPage(page) + .withPageSize(pageSize) + .withTotal(total) + .withDataColumns(dataColumnInfoList) + .withParameterColumns(parameterColumnInfoList) + .withPageFirstDate(timeList.stream().min(Instant::compareTo).orElse(null)) + .withPageLastDate(timeList.stream().max(Instant::compareTo).orElse(null)) + .withVersionDate(versionDate) + .build(); + } } \ No newline at end of file diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileParserDao.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileParserDao.java index 917e94b43..de3c6600b 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileParserDao.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/timeseriesprofile/TimeSeriesProfileParserDao.java @@ -23,20 +23,21 @@ public class TimeSeriesProfileParserDao extends JooqDao { - private static final AV_TS_PROFILE_PARSER_PARAM cwmsTsProfileParserParamView = AV_TS_PROFILE_PARSER_PARAM + private static final AV_TS_PROFILE_PARSER_PARAM PARAM_VIEW = AV_TS_PROFILE_PARSER_PARAM .AV_TS_PROFILE_PARSER_PARAM; - private static final AV_TS_PROFILE_PARSER cwmsTsProfileParserView = AV_TS_PROFILE_PARSER.AV_TS_PROFILE_PARSER; + private static final AV_TS_PROFILE_PARSER VIEW = AV_TS_PROFILE_PARSER.AV_TS_PROFILE_PARSER; public TimeSeriesProfileParserDao(DSLContext dsl) { super(dsl); } - protected static List getParameterInfoList(String info, String recordDelimiter, String fieldDelimiter) { + protected static List getParameterInfoList(String info, String recordDelimiter, + String fieldDelimiter) { fieldDelimiter = fieldDelimiter == null ? "," : fieldDelimiter; List parameterInfoList = new ArrayList<>(); String[] records = info.split(recordDelimiter); - for (String aRecord : records) { - String[] fields = aRecord.split(fieldDelimiter); + for (String oneRecord : records) { + String[] fields = oneRecord.split(fieldDelimiter); int index; if (fields[2].isEmpty()) { index = Integer.parseInt(fields[3]); @@ -113,26 +114,26 @@ public TimeSeriesProfileParser retrieveTimeSeriesProfileParser(String locationId public List retrieveParameterInfoList(String locationId, String parameterId, String officeId) { List parameterInfoList = new ArrayList<>(); - Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue(cwmsTsProfileParserParamView.LOCATION_ID, locationId); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(cwmsTsProfileParserParamView.OFFICE_ID, officeId)); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(cwmsTsProfileParserParamView.KEY_PARAMETER_ID, parameterId)); - Result parameterInfoResults = dsl.select(DSL.asterisk()).from(cwmsTsProfileParserParamView) + Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue(PARAM_VIEW.LOCATION_ID, locationId); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(PARAM_VIEW.OFFICE_ID, officeId)); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(PARAM_VIEW.KEY_PARAMETER_ID, parameterId)); + Result parameterInfoResults = dsl.select(DSL.asterisk()).from(PARAM_VIEW) .where(whereCondition) .fetch(); for (Record recordParameterInfo : parameterInfoResults) { - Short parameterField = cwmsTsProfileParserParamView.PARAMETER_FIELD.get(recordParameterInfo); + Short parameterField = recordParameterInfo.get(PARAM_VIEW.PARAMETER_FIELD); if (parameterField != null) { parameterInfoList.add(new ParameterInfoIndexed.Builder() .withIndex(parameterField) - .withParameter(cwmsTsProfileParserParamView.PARAMETER_ID.get(recordParameterInfo)) - .withUnit(cwmsTsProfileParserParamView.PARAMETER_UNIT.get(recordParameterInfo)) + .withParameter(recordParameterInfo.get(PARAM_VIEW.PARAMETER_ID)) + .withUnit(recordParameterInfo.get(PARAM_VIEW.PARAMETER_UNIT)) .build()); } else { parameterInfoList.add(new ParameterInfoColumnar.Builder() - .withStartColumn(cwmsTsProfileParserParamView.PARAMETER_COL_START.get(recordParameterInfo)) - .withEndColumn(cwmsTsProfileParserParamView.PARAMETER_COL_END.get(recordParameterInfo)) - .withParameter(cwmsTsProfileParserParamView.PARAMETER_ID.get(recordParameterInfo)) - .withUnit(cwmsTsProfileParserParamView.PARAMETER_UNIT.get(recordParameterInfo)) + .withStartColumn(recordParameterInfo.get(PARAM_VIEW.PARAMETER_COL_START)) + .withEndColumn(recordParameterInfo.get(PARAM_VIEW.PARAMETER_COL_END)) + .withParameter(recordParameterInfo.get(PARAM_VIEW.PARAMETER_ID)) + .withUnit(recordParameterInfo.get(PARAM_VIEW.PARAMETER_UNIT)) .build()); } } @@ -143,25 +144,25 @@ public List catalogTimeSeriesProfileParsers(String loca String officeIdMask, boolean includeParameters) { List timeSeriesProfileParserList = new ArrayList<>(); - Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue(cwmsTsProfileParserView.LOCATION_ID, locationIdMask); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(cwmsTsProfileParserView.OFFICE_ID, officeIdMask)); - whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(cwmsTsProfileParserView.KEY_PARAMETER_ID, parameterIdMask)); + Condition whereCondition = JooqDao.caseInsensitiveLikeRegexNullTrue(VIEW.LOCATION_ID, locationIdMask); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(VIEW.OFFICE_ID, officeIdMask)); + whereCondition = whereCondition.and(JooqDao.caseInsensitiveLikeRegex(VIEW.KEY_PARAMETER_ID, parameterIdMask)); @NotNull Result timeSeriesProfileParserResults = dsl.select(DSL.asterisk()) - .from(cwmsTsProfileParserView) + .from(VIEW) .where(whereCondition) .fetch(); for (Record profileParser : timeSeriesProfileParserResults) { - String recordDelimiter = cwmsTsProfileParserView.RECORD_DELIMTER_VALUE.get(profileParser); - String fieldDelimiter = cwmsTsProfileParserView.FIELD_DELIMIETER_VALUE.get(profileParser); - Short timeField = cwmsTsProfileParserView.TIME_FIELD.get(profileParser); - Short timeStartCol = cwmsTsProfileParserView.TIME_COL_START.get(profileParser); - Short timeEndCol = cwmsTsProfileParserView.TIME_COL_END.get(profileParser); + String recordDelimiter = profileParser.get(VIEW.RECORD_DELIMTER_VALUE); + String fieldDelimiter = profileParser.get(VIEW.FIELD_DELIMIETER_VALUE); + Short timeField = profileParser.get(VIEW.TIME_FIELD); + Short timeStartCol = profileParser.get(VIEW.TIME_COL_START); + Short timeEndCol = profileParser.get(VIEW.TIME_COL_END); CwmsId locationId = new CwmsId.Builder() - .withOfficeId(cwmsTsProfileParserView.OFFICE_ID.get(profileParser)) - .withName(cwmsTsProfileParserView.LOCATION_ID.get(profileParser)) + .withOfficeId(profileParser.get(VIEW.OFFICE_ID)) + .withName(profileParser.get(VIEW.LOCATION_ID)) .build(); - String keyParameter = cwmsTsProfileParserView.KEY_PARAMETER_ID.get(profileParser); + String keyParameter = profileParser.get(VIEW.KEY_PARAMETER_ID); TimeSeriesProfileParser timeSeriesProfileParser; List parameterInfoList = null; if (includeParameters) { @@ -175,8 +176,8 @@ public List catalogTimeSeriesProfileParsers(String loca .withLocationId(locationId) .withKeyParameter(keyParameter) .withParameterInfoList(parameterInfoList) - .withTimeFormat(cwmsTsProfileParserView.TIME_FORMAT.get(profileParser)) - .withTimeZone(cwmsTsProfileParserView.TIME_ZONE_ID.get(profileParser)) + .withTimeFormat(profileParser.get(VIEW.TIME_FORMAT)) + .withTimeZone(profileParser.get(VIEW.TIME_ZONE_ID)) .withRecordDelimiter(recordDelimiter.toCharArray()[0]) .build(); timeSeriesProfileParserList.add(timeSeriesProfileParser); @@ -187,8 +188,8 @@ public List catalogTimeSeriesProfileParsers(String loca .withLocationId(locationId) .withKeyParameter(keyParameter) .withParameterInfoList(parameterInfoList) - .withTimeFormat(cwmsTsProfileParserView.TIME_FORMAT.get(profileParser)) - .withTimeZone(cwmsTsProfileParserView.TIME_ZONE_ID.get(profileParser)) + .withTimeFormat(profileParser.get(VIEW.TIME_FORMAT)) + .withTimeZone(profileParser.get(VIEW.TIME_ZONE_ID)) .withRecordDelimiter(recordDelimiter.toCharArray()[0]) .build(); timeSeriesProfileParserList.add(timeSeriesProfileParser); diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParser.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParser.java index 0d5bc060f..68eb4cce6 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParser.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParser.java @@ -19,8 +19,10 @@ @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type") @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) @JsonDeserialize(builder = TimeSeriesProfileInstance.Builder.class) -@JsonSubTypes({@JsonSubTypes.Type(value = TimeSeriesProfileParserIndexed.class, name = "indexed-timeseries-profile-parser"), - @JsonSubTypes.Type(value = TimeSeriesProfileParserColumnar.class, name = "columnar-timeseries-profile-parser") +@JsonSubTypes({@JsonSubTypes.Type(value = TimeSeriesProfileParserIndexed.class, + name = "indexed-timeseries-profile-parser"), + @JsonSubTypes.Type(value = TimeSeriesProfileParserColumnar.class, + name = "columnar-timeseries-profile-parser") }) public class TimeSeriesProfileParser extends CwmsDTOBase { @@ -48,7 +50,6 @@ protected void validateInternal(CwmsDTOValidator validator) { validator.required(getKeyParameter(),"keyParameter"); } - public CwmsId getLocationId() { return locationId; } diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserColumnar.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserColumnar.java index f602d643e..9fcbb5510 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserColumnar.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserColumnar.java @@ -20,11 +20,13 @@ public final class TimeSeriesProfileParserColumnar extends TimeSeriesProfileParser { private final Integer timeStartColumn; private final Integer timeEndColumn; + private final String type; TimeSeriesProfileParserColumnar(Builder builder) { super(builder); timeStartColumn = builder.timeStartColumn; timeEndColumn = builder.timeEndColumn; + type = builder.type; } @Override @@ -47,11 +49,16 @@ public BigInteger getTimeEndColumn() { return null; } + public String getType() { + return type; + } + @JsonPOJOBuilder @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) public static final class Builder extends TimeSeriesProfileParser.Builder { private Integer timeStartColumn = null; private Integer timeEndColumn = null; + private String type = "columnar-timeseries-profile-parser"; public TimeSeriesProfileParserColumnar.Builder withTimeStartColumn(int timeStartColumn) { this.timeStartColumn = timeStartColumn; @@ -63,6 +70,11 @@ public TimeSeriesProfileParserColumnar.Builder withTimeEndColumn(int timeEndColu return this; } + public TimeSeriesProfileParserColumnar.Builder withType(String type) { + this.type = type; + return this; + } + @Override public TimeSeriesProfileParserColumnar build() { return new TimeSeriesProfileParserColumnar(this); diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserIndexed.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserIndexed.java index f2e3a2e8e..94a77a3c2 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserIndexed.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserIndexed.java @@ -20,11 +20,13 @@ public class TimeSeriesProfileParserIndexed extends TimeSeriesProfileParser { private final Character fieldDelimiter; private final Integer timeField; + private final String type; TimeSeriesProfileParserIndexed(Builder builder) { super(builder); fieldDelimiter = builder.fieldDelimiter; timeField = builder.timeField; + type = builder.type; } @Override @@ -43,11 +45,16 @@ public BigInteger getTimeField() { return BigInteger.valueOf(timeField); } + public String getType() { + return type; + } + @JsonPOJOBuilder @JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) public static class Builder extends TimeSeriesProfileParser.Builder { private Character fieldDelimiter = null; private Integer timeField = null; + private String type = "indexed-timeseries-profile-parser"; public TimeSeriesProfileParserIndexed.Builder withFieldDelimiter(char delimiter) { @@ -61,6 +68,11 @@ public TimeSeriesProfileParserIndexed.Builder withTimeField(int field) { return this; } + public TimeSeriesProfileParserIndexed.Builder withType(String type) { + this.type = type; + return this; + } + @Override public TimeSeriesProfileParserIndexed build() { return new TimeSeriesProfileParserIndexed(this); diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserList.java b/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserList.java deleted file mode 100644 index e568b06d1..000000000 --- a/cwms-data-api/src/main/java/cwms/cda/data/dto/timeseriesprofile/TimeSeriesProfileParserList.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * - * MIT License - * - * Copyright (c) 2024 Hydrologic Engineering Center - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE - * SOFTWARE. - */ - -package cwms.cda.data.dto.timeseriesprofile; - -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - -public class TimeSeriesProfileParserList extends ArrayList { - private final List parsers; - - public TimeSeriesProfileParserList(List parsers) { - this.parsers = parsers; - } - - public List getParsers() { - return parsers; - } - - @Override - public int size() { - return parsers.size(); - } - - @Override - public boolean isEmpty() { - return parsers.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return parsers.contains(o); - } - - @NotNull - @Override - public Iterator iterator() { - return parsers.iterator(); - } - - @NotNull - @Override - public Object[] toArray() { - return parsers.toArray(new TimeSeriesProfileParser[0]); - } - - @NotNull - @Override - public T[] toArray(T[] a) { - return parsers.toArray(a); - } - - @Override - public boolean add(TimeSeriesProfileParser e) { - return parsers.add(e); - } - - @Override - public boolean remove(Object o) { - return parsers.remove(o); - } - - @Override - public boolean containsAll(@NotNull Collection c) { - return new HashSet<>(parsers).containsAll(c); - } - - @Override - public boolean addAll(Collection c) { - return parsers.addAll(c); - } - - @Override - public boolean addAll(int index, Collection c) { - return parsers.addAll(index, c); - } - - @Override - public boolean removeAll(Collection c) { - return parsers.removeAll(c); - } - - @Override - public boolean retainAll(Collection c) { - return parsers.retainAll(c); - } - - @Override - public void clear() { - parsers.clear(); - } - - @Override - public TimeSeriesProfileParser get(int index) { - return parsers.get(index); - } - - @Override - public TimeSeriesProfileParser set(int index, TimeSeriesProfileParser element) { - return parsers.set(index, element); - } - - @Override - public void add(int index, TimeSeriesProfileParser element) { - parsers.add(index, element); - } - - @Override - - public TimeSeriesProfileParser remove(int index) { - return parsers.remove(index); - } - - @Override - public int indexOf(Object o) { - return parsers.indexOf(o); - } - - @Override - public int lastIndexOf(Object o) { - return parsers.lastIndexOf(o); - } - - @NotNull - @Override - public ListIterator listIterator() { - return parsers.listIterator(); - } - - @NotNull - @Override - public ListIterator listIterator(int index) { - return parsers.listIterator(index); - } - - @NotNull - @Override - public List subList(int fromIndex, int toIndex) { - return parsers.subList(fromIndex, toIndex); - } - - @Override - public boolean equals(Object o) { - if (o == null || o.getClass() != this.getClass()) { - return false; - } - return parsers.equals(o); - } - - @Override - public int hashCode() { - return parsers.hashCode(); - } - - @Override - public String toString() { - return parsers.toString(); - } -} \ No newline at end of file diff --git a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileControllerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileControllerIT.java index eb78dba33..15f4077b5 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileControllerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileControllerIT.java @@ -84,6 +84,8 @@ public void setup() throws Exception { @AfterEach public void tearDown() throws Exception { + // cleans up time series profiles between tests + // this is necessary because the tests reuse the same profiles cleanupTS(tsProfile.getLocationId().getName(), tsProfile.getKeyParameter()); cleanupTS(tsProfile2.getLocationId().getName(), tsProfile2.getKeyParameter()); } diff --git a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileInstanceControllerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileInstanceControllerIT.java index 120428a6d..df9bed0f3 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileInstanceControllerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileInstanceControllerIT.java @@ -27,7 +27,6 @@ package cwms.cda.api; import static cwms.cda.api.Controllers.*; -import static cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceController.*; import static cwms.cda.security.KeyAccessManager.AUTH_HEADER; import static io.restassured.RestAssured.given; import static org.hamcrest.Matchers.*; @@ -186,7 +185,7 @@ void test_create_retrieve_TimeSeriesProfileInstance_Columnar() throws Exception .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar) .queryParam(VERSION, "OBS") .when() @@ -206,12 +205,12 @@ void test_create_retrieve_TimeSeriesProfileInstance_Columnar() throws Exception .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .when() .redirects().follow(true) @@ -247,7 +246,7 @@ void test_create_retrieve_TimeSeriesProfileInstance_Indexed() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, true) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataIndexed) .queryParam(VERSION, "USGS-Raw") .when() @@ -267,12 +266,12 @@ void test_create_retrieve_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .when() .redirects().follow(true) @@ -309,7 +308,7 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Indexed() throws Excep .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, true) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataIndexed) .queryParam(VERSION, "Raw") .when() @@ -329,12 +328,12 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Indexed() throws Excep .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(PAGE_SIZE, 10) .when() @@ -368,12 +367,12 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Indexed() throws Excep .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(PAGE, cursor) .queryParam(PAGE_SIZE, 10) @@ -414,7 +413,7 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Columnar() throws Exce .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar) .queryParam(VERSION, "TEST-raw") .when() @@ -434,12 +433,12 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Columnar() throws Exce .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(PAGE_SIZE, 3) .when() @@ -473,12 +472,12 @@ void test_create_retrieve_paged_TimeSeriesProfileInstance_Columnar() throws Exce .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(PAGE, cursor) .queryParam(PAGE_SIZE, 3) @@ -517,7 +516,7 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar) .queryParam(VERSION, "OBS") .when() @@ -539,7 +538,7 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2023-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2023-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar2) .queryParam(VERSION, "OBS") .when() @@ -561,12 +560,12 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .queryParam(OFFICE, OFFICE_ID) .queryParam(PARAMETER_ID, tspParserColumnar.getKeyParameter()) .queryParam(VERSION, "OBS") - .queryParam(VERSION_DATE, Instant.parse("2023-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, Instant.parse("2023-07-09T12:00:00.00Z")) .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z")) + .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z")) + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(MAX_VERSION, true) .queryParam(UNIT, units) .queryParam(PAGE_SIZE, 3) @@ -588,12 +587,12 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(MAX_VERSION, false) .queryParam(PAGE_SIZE, 3) @@ -626,10 +625,10 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(MAX_VERSION, true) .queryParam(PAGE_SIZE, 3) @@ -662,10 +661,10 @@ void test_retrieve_TimeSeriesProfileInstance_Columnar_maxVersion() throws Except .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .queryParam(MAX_VERSION, false) .queryParam(PAGE_SIZE, 3) @@ -705,7 +704,7 @@ void test_previous_next_TimeSeriesProfileInstance_Indexed() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, true) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE,"2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataIndexed) .queryParam(VERSION, "USGS-Obs") .when() @@ -725,14 +724,14 @@ void test_previous_next_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2019-09-09T12:45:00.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2019-09-09T14:45:00.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) + .queryParam(START, "2019-09-09T12:45:00.00Z") + .queryParam(END, "2019-09-09T14:45:00.00Z") + .queryParam(START_TIME_INCLUSIVE, true) .queryParam(PREVIOUS, true) .queryParam(NEXT, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .when() .redirects().follow(true) @@ -762,12 +761,12 @@ void test_previous_next_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2019-09-09T12:45:00.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2019-09-09T14:45:00.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2019-09-09T12:45:00.00Z") + .queryParam(END, "2019-09-09T14:45:00.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(NEXT, true) .queryParam(UNIT, units) .when() @@ -799,12 +798,12 @@ void test_previous_next_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2019-09-09T12:45:00.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2019-09-09T14:45:00.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2019-09-09T12:45:00.00Z") + .queryParam(END, "2019-09-09T14:45:00.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(PREVIOUS, true) .queryParam(UNIT, units) .when() @@ -843,7 +842,7 @@ void test_delete_TimeSeriesProfileInstance_Columnar() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(PROFILE_DATA, tsProfileDataColumnar) .queryParam(VERSION, tspInstance.getVersion()) .when() @@ -863,10 +862,10 @@ void test_delete_TimeSeriesProfileInstance_Columnar() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(TIMEZONE, "UTC") .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(DATE, Instant.parse("2019-09-09T12:49:07Z").toEpochMilli()) + .queryParam(DATE, "2019-09-09T12:49:07Z") .when() .redirects().follow(true) .redirects().max(3) @@ -887,12 +886,12 @@ void test_delete_TimeSeriesProfileInstance_Columnar() throws Exception { .queryParam(OFFICE, OFFICE_ID) .queryParam(PARAMETER_ID, tspParserIndexed.getKeyParameter()) .queryParam(VERSION, tspInstance.getVersion()) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .when() .redirects().follow(true) @@ -920,7 +919,7 @@ void test_delete_TimeSeriesProfileInstance_Indexed() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(PROFILE_DATA, tsProfileDataIndexed) .queryParam(VERSION, "Raw") .when() @@ -940,10 +939,10 @@ void test_delete_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(TIMEZONE, "UTC") .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(DATE, Instant.parse("2019-09-09T12:48:57Z").toEpochMilli()) + .queryParam(DATE, "2019-09-09T12:48:57Z") .when() .redirects().follow(true) .redirects().max(3) @@ -962,12 +961,12 @@ void test_delete_TimeSeriesProfileInstance_Indexed() throws Exception { .contentType(Formats.JSONV1) .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(OFFICE, OFFICE_ID) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(TIMEZONE, "UTC") - .queryParam(START, Instant.parse("2018-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(END, Instant.parse("2025-07-09T19:06:20.00Z").toEpochMilli()) - .queryParam(START_INCLUSIVE, true) - .queryParam(END_INCLUSIVE, true) + .queryParam(START, "2018-07-09T19:06:20.00Z") + .queryParam(END, "2025-07-09T19:06:20.00Z") + .queryParam(START_TIME_INCLUSIVE, true) + .queryParam(END_TIME_INCLUSIVE, true) .queryParam(UNIT, units) .when() .redirects().follow(true) @@ -992,10 +991,10 @@ void test_delete_nonExistent_TimeSeriesProfileInstance() { .queryParam(OFFICE, OFFICE_ID) .queryParam(PARAMETER_ID, tspInstance.getTimeSeriesProfile().getKeyParameter()) .queryParam(VERSION, tspInstance.getVersion()) - .queryParam(VERSION_DATE, tspInstance.getVersionDate().toEpochMilli()) + .queryParam(VERSION_DATE, tspInstance.getVersionDate().toString()) .queryParam(TIMEZONE, "UTC") .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(DATE, tspInstance.getFirstDate().toEpochMilli()) + .queryParam(DATE, tspInstance.getFirstDate().toString()) .when() .redirects().follow(true) .redirects().max(3) @@ -1020,7 +1019,7 @@ void test_retrieve_all_TimeSeriesProfileInstance_Columnar() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar) .queryParam(VERSION, tspInstance.getVersion()) .when() @@ -1042,7 +1041,7 @@ void test_retrieve_all_TimeSeriesProfileInstance_Columnar() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataColumnar2) .queryParam(VERSION, tspInstance.getVersion()) .when() @@ -1093,7 +1092,7 @@ void test_retrieve_all_TimeSeriesProfileInstance_Indexed() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(VERSION, "USGS-Raw") .queryParam(PROFILE_DATA, tsProfileDataIndexed) .when() @@ -1114,7 +1113,7 @@ void test_retrieve_all_TimeSeriesProfileInstance_Indexed() throws Exception { .header(AUTH_HEADER, user.toHeaderValue()) .queryParam(METHOD, StoreRule.REPLACE_ALL) .queryParam(OVERRIDE_PROTECTION, false) - .queryParam(VERSION_DATE, Instant.parse("2024-07-09T12:00:00.00Z").toEpochMilli()) + .queryParam(VERSION_DATE, "2024-07-09T12:00:00.00Z") .queryParam(PROFILE_DATA, tsProfileDataIndexed2) .queryParam(VERSION, "USGS-Raw") .when() diff --git a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileParserControllerIT.java b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileParserControllerIT.java index cb6a7e762..a8c9a3a34 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileParserControllerIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesProfileParserControllerIT.java @@ -353,8 +353,8 @@ void test_get_all_TimeSeriesProfileParser() throws Exception { .body("[0].key-parameter", equalTo(tspIndex.getKeyParameter())) .body("[0].time-format", equalTo(tspIndex.getTimeFormat())) .body("[0].time-zone", equalTo(tspIndex.getTimeZone())) - .body("[0].parameter-info-list[0].parameter", equalTo(tspIndex.getParameterInfoList().get(1).getParameter())) - .body("[0].parameter-info-list[1].parameter", equalTo(tspIndex.getParameterInfoList().get(0).getParameter())) + .body("[0].parameter-info-list[0].parameter", equalTo(tspIndex.getParameterInfoList().get(0).getParameter())) + .body("[0].parameter-info-list[1].parameter", equalTo(tspIndex.getParameterInfoList().get(1).getParameter())) .body("[0].location-id.office-id", equalTo(tspIndex.getLocationId().getOfficeId())) .body("[0].type", equalTo("indexed-timeseries-profile-parser")) ; diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile.json index 3e37015b0..bb3a87f06 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile.json @@ -1,9 +1,9 @@ { "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location" + "name": "Beaverdam Ck Dam" }, - "description": "Test Description", + "description": "Dam near Durham", "parameter-list": [ "Depth", "Temp-Water" diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_2.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_2.json index 3b075baca..f85fa39d0 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_2.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_2.json @@ -1,9 +1,9 @@ { "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location2" + "name": "Little Rock Dam" }, - "description": "Test Description 2", + "description": "Dam near College Station", "parameter-list": [ "Depth", "Temp-Water" diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_instance.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_instance.json index d3dd461b2..55be6f942 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_instance.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_instance.json @@ -2,9 +2,9 @@ "time-series-profile": { "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location" + "name": "Beaverdam Ck Dam" }, - "description": "Test Description", + "description": "Dam near Durham", "parameter-list": [ "Depth", "Temp-Water" diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_columnar.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_columnar.json index 2d013def5..e2825240d 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_columnar.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_columnar.json @@ -2,7 +2,7 @@ "type": "columnar-timeseries-profile-parser", "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location" + "name": "Beaverdam Ck Dam" }, "key-parameter": "Depth", "record-delimiter": "\n", diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_indexed.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_indexed.json index 2c2449ca4..85e6bd88f 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_indexed.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_parser_indexed.json @@ -2,7 +2,7 @@ "type": "indexed-timeseries-profile-parser", "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location" + "name": "Beaverdam Ck Dam" }, "key-parameter": "Depth", "record-delimiter": "\n", diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_ref.json b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_ref.json index a432ba752..a85463817 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_ref.json +++ b/cwms-data-api/src/test/resources/cwms/cda/api/timeseriesprofile/ts_profile_ref.json @@ -6,11 +6,11 @@ ], "location-id": { "office-id": "SPK", - "name": "Test_TSP_Location" + "name": "Beaverdam Ck Dam" }, "reference-ts-id": { - "office-id": "SWT", - "name": "Test_TSP_Location.Elev.Inst.1Hour.0.DSS-Obs" + "office-id": "SPK", + "name": "Beaverdam Ck Dam.Elev.Inst.1Hour.0.DSS-Obs" }, "key-parameter": "Depth" } \ No newline at end of file