Skip to content

Commit

Permalink
Issue 854 - Rename TS Identifier patch path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
zack-rma committed Sep 30, 2024
1 parent 7f3ebaf commit e69cce7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
2 changes: 1 addition & 1 deletion cwms-data-api/src/main/java/cwms/cda/ApiServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ protected void configureRoutes() {

cdaCrudCache("/timeseries/category/{category-id}",
new TimeSeriesCategoryController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/timeseries/identifier-descriptor/{timeseries-id}",
cdaCrudCache("/timeseries/identifier-descriptor/{name}",
new TimeSeriesIdentifierDescriptorController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/timeseries/group/{group-id}",
new TimeSeriesGroupController(metrics), requiredRoles,5, TimeUnit.MINUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,7 @@
package cwms.cda.api;

import static com.codahale.metrics.MetricRegistry.name;
import static cwms.cda.api.Controllers.ACTIVE;
import static cwms.cda.api.Controllers.CREATE;
import static cwms.cda.api.Controllers.DELETE;
import static cwms.cda.api.Controllers.FAIL_IF_EXISTS;
import static cwms.cda.api.Controllers.GET_ALL;
import static cwms.cda.api.Controllers.GET_ONE;
import static cwms.cda.api.Controllers.INTERVAL_OFFSET;
import static cwms.cda.api.Controllers.METHOD;
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.RESULTS;
import static cwms.cda.api.Controllers.SIZE;
import static cwms.cda.api.Controllers.SNAP_BACKWARD;
import static cwms.cda.api.Controllers.SNAP_FORWARD;
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.api.Controllers.TIMESERIES_ID;
import static cwms.cda.api.Controllers.TIMESERIES_ID_REGEX;
import static cwms.cda.api.Controllers.UPDATE;
import static cwms.cda.api.Controllers.requiredParam;
import static cwms.cda.api.Controllers.*;

import com.codahale.metrics.Histogram;
import com.codahale.metrics.MetricRegistry;
Expand Down Expand Up @@ -189,7 +168,7 @@ public void getAll(Context ctx) {
+ "implemented")},
description = "Retrieves requested timeseries identifier descriptor", tags = {TAG})
@Override
public void getOne(Context ctx, @NotNull String timeseriesId) {
public void getOne(@NotNull Context ctx, @NotNull String timeseriesId) {

try (final Timer.Context ignored = markAndTime(GET_ONE)){
DSLContext dsl = getDslContext(ctx);
Expand Down Expand Up @@ -263,7 +242,7 @@ public void create(@NotNull Context ctx) {

@OpenApi(
pathParams = {
@OpenApiParam(name = TIMESERIES_ID, description = "The timeseries id"),
@OpenApiParam(name = NAME, description = "The timeseries id"),
},
queryParams = {
@OpenApiParam(name = OFFICE, required = true, description = "Specifies the "
Expand All @@ -280,7 +259,7 @@ public void create(@NotNull Context ctx) {
}, tags = {TAG}
)
@Override
public void update(Context ctx, @NotNull String timeseriesId) {
public void update(@NotNull Context ctx, @NotNull String name) {

String office = requiredParam(ctx, OFFICE);
String newTimeseriesId = ctx.queryParam(TIMESERIES_ID);
Expand All @@ -306,13 +285,13 @@ public void update(Context ctx, @NotNull String timeseriesId) {

if (foundUpdateKeys.isEmpty()) {
// basic rename.
dao.rename(office, timeseriesId, newTimeseriesId, intervalOffset);
dao.rename(office, name, newTimeseriesId, intervalOffset);
} else {
Long forward = ctx.queryParamAsClass(SNAP_FORWARD, Long.class).getOrDefault(null);
Long backward = ctx.queryParamAsClass(SNAP_BACKWARD, Long.class).getOrDefault(null);
boolean active = ctx.queryParamAsClass(ACTIVE, Boolean.class).getOrDefault(true);

dao.update(office, timeseriesId, intervalOffset, forward, backward, active);
dao.update(office, name, intervalOffset, forward, backward, active);
}
}

Expand Down

0 comments on commit e69cce7

Please sign in to comment.