Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time Series Profile Controllers #856

Open
wants to merge 72 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
90665dd
ts profile json
AndreasChristmann Jun 14, 2024
9d137d8
ts profile json
AndreasChristmann Jun 18, 2024
b9131e7
ts profile json
AndreasChristmann Jun 18, 2024
6458099
ts profile json
AndreasChristmann Jun 18, 2024
7141f7e
sample time series profile data
AndreasChristmann Jun 19, 2024
5aeaa72
time series profile dto's
AndreasChristmann Jun 19, 2024
085e855
time series profile dao's
AndreasChristmann Jun 19, 2024
21b9c8b
time series profile dto's unit test
AndreasChristmann Jun 19, 2024
a15f561
time series profile dao integration test
AndreasChristmann Jun 19, 2024
d0dec1f
time series profile unit test
AndreasChristmann Jun 20, 2024
825c55e
added db cleanup
AndreasChristmann Jun 21, 2024
20095a3
moved equals to test classes and removed hashcode
AndreasChristmann Jun 25, 2024
5b7fd48
reformatted code
AndreasChristmann Jun 26, 2024
1922694
use CWMS-Id for location id
AndreasChristmann Jun 27, 2024
180bef7
use CWMSId, TimeSeriesProfile Instance DTO, json and unittest
AndreasChristmann Jun 27, 2024
c371fd7
unit test for timeseries profile instance, cleanup code
AndreasChristmann Jul 19, 2024
116ff55
Timeseries profile instance dao and test, columnar data, timeseries p…
AndreasChristmann Jul 24, 2024
9536980
use Temp-Water instead of Temperature
AndreasChristmann Jul 24, 2024
f3bea82
change profile time series json to match time series
AndreasChristmann Jul 24, 2024
43c0715
use real life names
AndreasChristmann Jul 24, 2024
980d3cc
Time series profile parser dao
AndreasChristmann Jul 29, 2024
98f1d7b
changed record to recordParam
AndreasChristmann Jul 29, 2024
2a18d87
subclassed TimeSeriesProfileParser into Indexed and Columnar
AndreasChristmann Jul 30, 2024
1f5d732
renamed the retrieve method for multiple DTOs to catalog...
AndreasChristmann Jul 31, 2024
3ebf9ff
DTO changes from Peter's review
AndreasChristmann Aug 5, 2024
6ad5db7
access View, bypass PL/SQL, prepare for pagination
AndreasChristmann Aug 9, 2024
a1defcb
TSP Controllers in progress
zack-rma Aug 21, 2024
4d495da
TSP Controllers in progress - Instance storage bug remaining
zack-rma Aug 22, 2024
b9d338c
Integration tests passing
zack-rma Aug 23, 2024
d54e9d3
Fixed annotations for Swagger code gen and JSON deserialization
zack-rma Aug 23, 2024
e9eef3f
Cleaned up accepted content types for TSP Parser create
zack-rma Aug 27, 2024
ec59ed9
Cleaned up formatting
zack-rma Aug 27, 2024
2058ed2
Annotation and Parser subtype modifications
zack-rma Aug 29, 2024
0b9ab3b
Updated controllers to support JSONV1, fixed serialization failures
zack-rma Sep 5, 2024
5f209ba
Fixed JSON serialization, other bug fixes in progress
zack-rma Sep 7, 2024
74aa6e3
TSP Instance Pagination in progress
zack-rma Sep 14, 2024
0a1c410
TSP Instance Pagination in progress - paging bug
zack-rma Sep 17, 2024
2f6a920
TSP Instance Pagination finished, controller updates underway
zack-rma Sep 18, 2024
392e496
TSP Instance Pagination working, controller updated, tests updated
zack-rma Sep 18, 2024
216a181
Time Series Profile Pagination working, controller and tests updated
zack-rma Sep 18, 2024
fbb9e05
Updated formatting, return type from controller
zack-rma Sep 19, 2024
9e7955d
Added controller variable
zack-rma Sep 19, 2024
4499436
Removed unnecessary classes, fixed CDA Swagger loading bug
zack-rma Sep 19, 2024
615d487
Added parser type serialization fix back in
zack-rma Sep 20, 2024
bf12a16
Fixed unit handling, time comparison
zack-rma Sep 20, 2024
631ab4b
Updated tests
zack-rma Sep 20, 2024
527fa0d
Fixed serialization issue with custom serializer. Added more tests. I…
zack-rma Sep 24, 2024
ac900eb
Cleaned up retrieval mapping, added tests to check parameter order. F…
zack-rma Sep 25, 2024
3a15ae9
Updated controllers, DAOs based on Adam's feedback
zack-rma Oct 8, 2024
fd14485
Updated endpoint naming, tests in response to Adam and Mike's feedback
zack-rma Oct 9, 2024
21a4417
TS - Updated total query for profile, rewrote paging implementation f…
zack-rma Oct 15, 2024
0e5a956
TS Profiles - Updated type handling, no longer requires type explicit…
zack-rma Oct 16, 2024
3a94f71
TS - performance updates, re-write of total query, rewrite of page br…
zack-rma Oct 17, 2024
41c2576
Updated profile mapping to include reference TS ID, added tests
zack-rma Oct 18, 2024
a54bd0e
Replaced ternary
zack-rma Oct 18, 2024
6e5822d
Made fixes to DB queries, exception handling based on Adam's feedback
zack-rma Oct 21, 2024
588cbcc
cleanup serialization
adamkorynta Oct 22, 2024
458a5ae
Merge pull request #1 from adamkorynta/feature/TimeSeriesProfileContr…
zack-rma Oct 22, 2024
2bd9381
TimeSeries Parser serialization update, response to feedback
zack-rma Oct 23, 2024
8aaeb9c
Merge cleanup of ApiServlet imports
zack-rma Oct 23, 2024
1510ba2
Fixed assertions and exception handling for bad parser type
zack-rma Oct 24, 2024
284a6b2
Updated Swagger documentation for TimeSeries profile endpoints
zack-rma Oct 25, 2024
47807ec
Updated tests with parser existence verification, diagnosing TC build…
zack-rma Oct 28, 2024
51eb45a
Merge remote-tracking branch 'hec/develop' into feature/TimeSeriesPro…
zack-rma Oct 30, 2024
d494dab
Updated test to fix build error
zack-rma Oct 30, 2024
43ad339
Updated version date input handling
zack-rma Nov 4, 2024
4aab9b4
Added version date input handling tests
zack-rma Nov 4, 2024
9e71d6c
Updated instance integration test to resolve TC build error
zack-rma Nov 8, 2024
0b05e7a
Updated test case to verify instance is in DB before deletion
zack-rma Nov 11, 2024
770d0ef
TimeSeries test case fix attempt - fixing build error with instance s…
zack-rma Nov 12, 2024
05a5cce
update to latest schema version
adamkorynta Nov 13, 2024
e37aaff
Merge pull request #2 from adamkorynta/feature/TimeSeriesProfileContr…
zack-rma Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 45 additions & 15 deletions cwms-data-api/src/main/java/cwms/cda/ApiServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,8 @@

package cwms.cda;


import static cwms.cda.api.Controllers.CONTRACT_NAME;
import static cwms.cda.api.Controllers.NAME;
import static cwms.cda.api.Controllers.OFFICE;
import static cwms.cda.api.Controllers.PROJECT_ID;
import static cwms.cda.api.Controllers.WATER_USER;
import static io.javalin.apibuilder.ApiBuilder.crud;
import static io.javalin.apibuilder.ApiBuilder.delete;
import static io.javalin.apibuilder.ApiBuilder.get;
import static io.javalin.apibuilder.ApiBuilder.patch;
import static io.javalin.apibuilder.ApiBuilder.post;
import static io.javalin.apibuilder.ApiBuilder.prefixPath;
import static io.javalin.apibuilder.ApiBuilder.staticInstance;
import static cwms.cda.api.Controllers.*;
import static io.javalin.apibuilder.ApiBuilder.*;
import static java.lang.String.format;

import com.codahale.metrics.Meter;
Expand Down Expand Up @@ -104,9 +93,9 @@
import cwms.cda.api.errors.JsonFieldsException;
import cwms.cda.api.errors.NotFoundException;
import cwms.cda.api.errors.RequiredQueryParameterException;
import cwms.cda.api.location.kind.GateChangeCreateController;
import cwms.cda.api.location.kind.GateChangeDeleteController;
import cwms.cda.api.location.kind.GateChangeGetAllController;
import cwms.cda.api.location.kind.GateChangeCreateController;
import cwms.cda.api.location.kind.OutletController;
import cwms.cda.api.location.kind.VirtualOutletController;
import cwms.cda.api.location.kind.VirtualOutletCreateController;
Expand All @@ -121,6 +110,18 @@
import cwms.cda.api.project.ProjectPublishStatusUpdate;
import cwms.cda.api.project.RemoveAllLockRevokerRights;
import cwms.cda.api.project.UpdateLockRevokerRights;
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.TimeSeriesProfileInstanceCatalogController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceCreateController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileInstanceDeleteController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserCatalogController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserCreateController;
import cwms.cda.api.timeseriesprofile.TimeSeriesProfileParserDeleteController;
import cwms.cda.api.watersupply.WaterContractCatalogController;
import cwms.cda.api.watersupply.WaterContractController;
import cwms.cda.api.watersupply.WaterContractCreateController;
Expand Down Expand Up @@ -489,6 +490,35 @@ protected void configureRoutes() {
get(textBinaryValuePath, new BinaryTimeSeriesValueController(metrics));
addCacheControl(textBinaryValuePath, 1, TimeUnit.DAYS);

String timeSeriesProfilePath = "/timeseries/profile/";
get(format(timeSeriesProfilePath + "{%s}/{%s}", Controllers.LOCATION_ID, Controllers.PARAMETER_ID),
new TimeSeriesProfileController(metrics));
delete(format(timeSeriesProfilePath + "/{%s}/{%s}", Controllers.LOCATION_ID,
Controllers.PARAMETER_ID), new TimeSeriesProfileDeleteController(metrics),
requiredRoles);
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,
Controllers.PARAMETER_ID), new TimeSeriesProfileParserController(metrics));
post(timeSeriesProfileParserPath, new TimeSeriesProfileParserCreateController(metrics), requiredRoles);
delete(format(timeSeriesProfileParserPath + "{%s}/{%s}/", Controllers.LOCATION_ID,
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,
Controllers.PARAMETER_ID, Controllers.VERSION),
new TimeSeriesProfileInstanceController(metrics));
post(timeSeriesProfileInstancePath, new TimeSeriesProfileInstanceCreateController(metrics), requiredRoles);
delete(format(timeSeriesProfileInstancePath + "{%s}/{%s}/{%s}/", Controllers.LOCATION_ID,
Controllers.PARAMETER_ID, Controllers.VERSION),
new TimeSeriesProfileInstanceDeleteController(metrics), requiredRoles);
get(timeSeriesProfileInstancePath, new TimeSeriesProfileInstanceCatalogController(metrics));

cdaCrudCache("/timeseries/category/{category-id}",
new TimeSeriesCategoryController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/timeseries/identifier-descriptor/{timeseries-id}",
Expand Down Expand Up @@ -817,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());
Expand Down
7 changes: 7 additions & 0 deletions cwms-data-api/src/main/java/cwms/cda/api/Controllers.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public final class Controllers {
public static final String DATE = "date";
public static final String LEVEL_ID = "level-id";
public static final String LEVEL_ID_MASK = "level-id-mask";
public static final String LOCATION_MASK = "location-mask";
public static final String NAME = "name";
public static final String CASCADE_DELETE = "cascade-delete";
public static final String DATUM = "datum";
Expand Down Expand Up @@ -127,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";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
*
* 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.api.timeseriesprofile;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.api.Controllers;
import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileDao;
import org.jooq.DSLContext;

public abstract class TimeSeriesProfileBase {
static final String TAG = "TimeSeries";
private MetricRegistry metrics;

TimeSeriesProfileDao getProfileDao(DSLContext dsl) {
return new TimeSeriesProfileDao(dsl);
}

Timer.Context markAndTime(String subject) {
return Controllers.markAndTime(metrics, getClass().getName(), subject);
}

void tspMetrics(MetricRegistry metrics) {
this.metrics = metrics;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
*
* 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.api.timeseriesprofile;

import static cwms.cda.api.Controllers.*;
import static cwms.cda.api.Controllers.PAGE_SIZE;
import static cwms.cda.data.dao.JooqDao.getDslContext;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileDao;
import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfileList;
import cwms.cda.formatters.ContentType;
import cwms.cda.formatters.Formats;
import io.javalin.core.util.Header;
import io.javalin.http.Context;
import io.javalin.http.Handler;
import io.javalin.plugin.openapi.annotations.HttpMethod;
import io.javalin.plugin.openapi.annotations.OpenApi;
import io.javalin.plugin.openapi.annotations.OpenApiContent;
import io.javalin.plugin.openapi.annotations.OpenApiParam;
import io.javalin.plugin.openapi.annotations.OpenApiResponse;
import javax.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;


public final class TimeSeriesProfileCatalogController extends TimeSeriesProfileBase implements Handler {
public static final String PARAMETER_ID_MASK = "parameter-id-mask";

public TimeSeriesProfileCatalogController(MetricRegistry metrics) {
tspMetrics(metrics);
}

@OpenApi(
queryParams = {
@OpenApiParam(name = OFFICE_MASK, description = "The office mask for the time series profile. "
+ "Default is *"),
@OpenApiParam(name = LOCATION_MASK, description = "The location mask for the time series profile. "
+ "Default is *"),
@OpenApiParam(name = PARAMETER_ID_MASK, description = "The key parameter mask for the time series "
+ "profile. Default is *"),
@OpenApiParam(name = PAGE, description = "The page cursor. Default is null"),
@OpenApiParam(name = PAGE_SIZE, description = "The page size. Default is 500")
},
method = HttpMethod.GET,
summary = "Get a time series profile",
tags = {TAG},
responses = {
@OpenApiResponse(status = STATUS_200,
description = "A TimeSeriesProfile object",
content = {
@OpenApiContent(from = TimeSeriesProfileList.class, type = Formats.JSONV1),
@OpenApiContent(from = TimeSeriesProfileList.class, type = Formats.XMLV2),
}),
@OpenApiResponse(status = STATUS_400, description = "Invalid input"),
@OpenApiResponse(status = STATUS_404, description = "No data matching input parameters found")
}
)
@Override
public void handle(@NotNull Context ctx) {
try (final Timer.Context ignored = markAndTime(GET_ALL)) {
DSLContext dsl = getDslContext(ctx);
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("*");
String cursor = ctx.queryParam(PAGE);
int pageSize = ctx.queryParamAsClass(PAGE_SIZE, Integer.class).getOrDefault(500);
TimeSeriesProfileList retrievedProfiles = tspDao.catalogTimeSeriesProfiles(locationMask,
parameterIdMask, officeMask, cursor, pageSize);
String acceptHeader = ctx.header(Header.ACCEPT);
ContentType contentType = Formats.parseHeader(acceptHeader, TimeSeriesProfileList.class);
String results = Formats.format(contentType, retrievedProfiles);
ctx.status(HttpServletResponse.SC_OK);
ctx.result(results);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
*
* 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.api.timeseriesprofile;

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;

import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import cwms.cda.data.dao.timeseriesprofile.TimeSeriesProfileDao;
import cwms.cda.data.dto.timeseriesprofile.TimeSeriesProfile;
import cwms.cda.formatters.ContentType;
import cwms.cda.formatters.Formats;
import io.javalin.core.util.Header;
import io.javalin.http.Context;
import io.javalin.http.Handler;
import io.javalin.plugin.openapi.annotations.HttpMethod;
import io.javalin.plugin.openapi.annotations.OpenApi;
import io.javalin.plugin.openapi.annotations.OpenApiContent;
import io.javalin.plugin.openapi.annotations.OpenApiParam;
import io.javalin.plugin.openapi.annotations.OpenApiResponse;
import javax.servlet.http.HttpServletResponse;
import org.jetbrains.annotations.NotNull;
import org.jooq.DSLContext;


public final class TimeSeriesProfileController extends TimeSeriesProfileBase implements Handler {
public TimeSeriesProfileController(MetricRegistry metrics) {
tspMetrics(metrics);
}

@OpenApi(
queryParams = {
@OpenApiParam(name = OFFICE, description = "The office ID associated with the time series profile"),
},
pathParams = {
@OpenApiParam(name = PARAMETER_ID, description = "The key parameter ID associated with the time "
+ "series profile"),
@OpenApiParam(name = LOCATION_ID, description = "The location ID associated with the "
+ "time series profile")
},
method = HttpMethod.GET,
summary = "Get a time series profile",
tags = {TAG},
responses = {
@OpenApiResponse(status = STATUS_200,
description = "A TimeSeriesProfileParser object",
content = {
@OpenApiContent(from = TimeSeriesProfile.class, type = Formats.JSONV1),
@OpenApiContent(from = TimeSeriesProfile.class, type = Formats.XMLV2),
}),
@OpenApiResponse(status = "400", description = "Invalid input")
}
)
@Override
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 = getProfileDao(dsl);
String office = requiredParam(ctx, OFFICE);
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);
String result = Formats.format(contentType, returned);
ctx.status(HttpServletResponse.SC_OK);
ctx.result(result);
}
}
}
Loading
Loading