Skip to content

Commit

Permalink
Issue 765 - Addressed LocationLevel Catalog requiring start date (#889)
Browse files Browse the repository at this point in the history
Fixes [#765](#765)
  • Loading branch information
zack-rma authored Oct 25, 2024
1 parent 5fd3d7e commit 0a320f5
Show file tree
Hide file tree
Showing 2 changed files with 261 additions and 36 deletions.
29 changes: 8 additions & 21 deletions cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static cwms.cda.api.Controllers.VERSION;
import static cwms.cda.api.Controllers.addDeprecatedContentTypeWarning;
import static cwms.cda.api.Controllers.queryParamAsClass;
import static cwms.cda.api.Controllers.queryParamAsZdt;
import static cwms.cda.api.Controllers.requiredParam;
import static cwms.cda.data.dao.JooqDao.getDslContext;

Expand All @@ -67,7 +68,6 @@
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import cwms.cda.api.enums.UnitSystem;
import cwms.cda.api.errors.CdaError;
import cwms.cda.data.dao.LocationLevelsDao;
import cwms.cda.data.dao.LocationLevelsDaoImpl;
import cwms.cda.data.dto.LocationLevel;
Expand Down Expand Up @@ -220,11 +220,10 @@ public void delete(@NotNull Context ctx, @NotNull String levelId) {
+ "specified or default units above the NGVD-29 datum."),
@OpenApiParam(name = BEGIN, description = "Specifies the start of the time "
+ "window for data to be included in the response. If this field is "
+ "not specified, any required time window begins 24 hours prior to "
+ "the specified or default end time."),
+ "not specified, no beginning time will be used."),
@OpenApiParam(name = END, description = "Specifies the end of the time "
+ "window for data to be included in the response. If this field is "
+ "not specified, any required time window ends at the current time"),
+ "not specified, no end time will be used."),
@OpenApiParam(name = TIMEZONE, description = "Specifies the time zone of "
+ "the values of the begin and end fields (unless otherwise "
+ "specified), as well as the time zone of any times in the response."
Expand Down Expand Up @@ -280,23 +279,14 @@ public void getAll(@NotNull Context ctx) {

boolean isLegacyVersion = version.equals("1");

if (format.isEmpty() && !isLegacyVersion)
{
if (format.isEmpty() && !isLegacyVersion) {
String cursor = ctx.queryParamAsClass(PAGE, String.class)
.getOrDefault("");
int pageSize = ctx.queryParamAsClass(PAGE_SIZE, Integer.class)
.getOrDefault(DEFAULT_PAGE_SIZE);

ZoneId tz = ZoneId.of(timezone, ZoneId.SHORT_IDS);

ZonedDateTime endZdt = end != null ? DateUtils.parseUserDate(end, timezone) :
ZonedDateTime.now(tz);
ZonedDateTime beginZdt;
if (begin != null) {
beginZdt = DateUtils.parseUserDate(begin, timezone);
} else {
beginZdt = endZdt.minusHours(24);
}
ZonedDateTime endZdt = queryParamAsZdt(ctx, END);
ZonedDateTime beginZdt = queryParamAsZdt(ctx, BEGIN);

LocationLevels levels = levelsDao.getLocationLevels(cursor, pageSize, levelIdMask,
office, unit, datum, beginZdt, endZdt);
Expand All @@ -315,12 +305,9 @@ public void getAll(@NotNull Context ctx) {
ctx.status(HttpServletResponse.SC_OK);
ctx.result(results);
requestResultSize.update(results.length());
if (isLegacyVersion)
{
if (isLegacyVersion) {
ctx.contentType(contentType.toString());
}
else
{
} else {
ctx.contentType(contentType.getType());
}
}
Expand Down
Loading

0 comments on commit 0a320f5

Please sign in to comment.