Skip to content

Commit

Permalink
Renamed controller and changed url. Adding StandardTextTimeSeriesRow.
Browse files Browse the repository at this point in the history
  • Loading branch information
rma-rripken committed Dec 4, 2023
1 parent aafe874 commit a8d6d19
Show file tree
Hide file tree
Showing 9 changed files with 633 additions and 181 deletions.
12 changes: 5 additions & 7 deletions cwms-data-api/src/main/java/cwms/cda/ApiServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
"/auth/*",
"/swagger-docs",
"/timeseries/*",
"/text-timeseries/*",
"/offices/*",
"/states/*",
"/counties/*",
Expand Down Expand Up @@ -370,6 +369,8 @@ protected void configureRoutes() {
get(recentPath, tsController::getRecent);
addCacheControl(recentPath, 5, TimeUnit.MINUTES);

cdaCrudCache("/timeseries/text/{ts-id}",
new TextTimeSeriesController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/timeseries/category/{category-id}",
new TimeSeriesCategoryController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/timeseries/identifier-descriptor/{timeseries-id}",
Expand Down Expand Up @@ -397,8 +398,7 @@ protected void configureRoutes() {
new PoolController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/specified-levels/{specified-level-id}",
new SpecifiedLevelController(metrics), requiredRoles,5, TimeUnit.MINUTES);
cdaCrudCache("/text-timeseries/{ts-id}",
new TextTimeSeriesController(metrics), requiredRoles,5, TimeUnit.MINUTES);

}

/**
Expand Down Expand Up @@ -514,7 +514,7 @@ private void getOpenApiOptions(JavalinConfig config) {
CdaAccessManager am = buildAccessManager(provider);
Components components = new Components();
final ArrayList<SecurityRequirement> secReqs = new ArrayList<>();
am.getContainedManagers().forEach((manager)->{
am.getContainedManagers().forEach(manager -> {
components.addSecuritySchemes(manager.getName(),manager.getScheme());
SecurityRequirement req = new SecurityRequirement();
if (!manager.getName().equalsIgnoreCase("guestauth") && !manager.getName().equalsIgnoreCase("noauth")) {
Expand All @@ -533,9 +533,7 @@ private void getOpenApiOptions(JavalinConfig config) {
);
ops.path("/swagger-docs")
.responseModifier((ctx,api) -> {
api.getPaths().forEach((key,path) -> {
setSecurityRequirements(key,path,secReqs);
});
api.getPaths().forEach((key,path) -> setSecurityRequirements(key,path,secReqs));
return api;
})
.defaultDocumentation(doc -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import cwms.cda.api.errors.CdaError;
import cwms.cda.data.dao.TextTimeSeriesDao;
import cwms.cda.data.dao.TimeSeriesTextDao;
import cwms.cda.data.dto.TextTimeSeries;
import cwms.cda.formatters.ContentType;
import cwms.cda.formatters.Formats;
Expand Down Expand Up @@ -77,8 +77,8 @@ public TextTimeSeriesController(MetricRegistry metrics) {
}

@NotNull
protected TextTimeSeriesDao getDao(DSLContext dsl) {
return new TextTimeSeriesDao(dsl);
protected TimeSeriesTextDao getDao(DSLContext dsl) {
return new TimeSeriesTextDao(dsl);
}


Expand Down Expand Up @@ -114,7 +114,7 @@ public void getAll(Context ctx) {
ContentType contentType = Formats.parseHeaderAndQueryParm(formatHeader, "");
try (Timer.Context timeContext = markAndTime(GET_ALL);
DSLContext dsl = getDslContext(ctx)) {
TextTimeSeriesDao dao = getDao(dsl);
TimeSeriesTextDao dao = getDao(dsl);
List<TextTimeSeries> textTimeSeries = null; // dao.get(office, templateIdMask);

ctx.contentType(contentType.toString());
Expand Down Expand Up @@ -161,7 +161,7 @@ public void create(Context ctx) {
String formatHeader = reqContentType != null ? reqContentType : Formats.JSONV2;
String body = ctx.body();
TextTimeSeries deserialize = deserialize(body, formatHeader);
TextTimeSeriesDao dao = getDao(dsl);
TimeSeriesTextDao dao = getDao(dsl);
boolean failIfExists = ctx.queryParamAsClass(FAIL_IF_EXISTS, Boolean.class).getOrDefault(true);
// dao.create(deserialize, failIfExists);
ctx.status(HttpServletResponse.SC_CREATED);
Expand Down Expand Up @@ -189,7 +189,7 @@ public void create(Context ctx) {
public void update(Context ctx, @NotNull String oldTextTimeSeriesId) {
try (Timer.Context ignored = markAndTime(UPDATE);
DSLContext dsl = getDslContext(ctx)) {
TextTimeSeriesDao dao = getDao(dsl);
TimeSeriesTextDao dao = getDao(dsl);
String newTextTimeSeriesId = ctx.queryParam(TEXT_TIMESERIES_ID);
String office = ctx.queryParam(OFFICE);
// dao.update(oldTextTimeSeriesId, newTextTimeSeriesId, office);
Expand All @@ -215,9 +215,9 @@ public void update(Context ctx, @NotNull String oldTextTimeSeriesId) {
public void delete(Context ctx, String textTimeSeriesId) {
try (Timer.Context ignored = markAndTime(UPDATE);
DSLContext dsl = getDslContext(ctx)) {
TextTimeSeriesDao dao = getDao(dsl);
TimeSeriesTextDao dao = getDao(dsl);
String office = ctx.queryParam(OFFICE);
// dao.delete(textTimeSeriesId, office);
// dao.delete(textTimeSeriesId, office); // TODO: add this back.
ctx.status(HttpServletResponse.SC_NO_CONTENT);
}
}
Expand Down
Loading

0 comments on commit a8d6d19

Please sign in to comment.