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

Issue 765 - Addressed LocationLevel Catalog requiring start date #889

Merged
merged 4 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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) {
adamkorynta marked this conversation as resolved.
Show resolved Hide resolved
ctx.contentType(contentType.toString());
}
else
{
} else {
ctx.contentType(contentType.getType());
}
}
Expand Down
Loading
Loading