Skip to content

Commit

Permalink
fix incorrect changes made to controllers api
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkorynta committed Jun 5, 2024
1 parent c2d105d commit 1e5705b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 45 deletions.
6 changes: 4 additions & 2 deletions cwms-data-api/src/main/java/cwms/cda/api/BlobController.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ protected DSLContext getDslContext(Context ctx) {
responses = {@OpenApiResponse(status = STATUS_200,
description = "A list of blobs.",
content = {
@OpenApiContent(type = Formats.JSONV2, from = Blobs.class)
@OpenApiContent(type = Formats.JSONV2, from = Blobs.class),
@OpenApiContent(type = Formats.XMLV2, from = Blobs.class)
})
},
tags = {TAG}
Expand Down Expand Up @@ -168,7 +169,8 @@ public void getOne(@NotNull Context ctx, @NotNull String blobId) {
description = "Create new Blob",
requestBody = @OpenApiRequestBody(
content = {
@OpenApiContent(from = Blob.class, type = Formats.JSONV2)
@OpenApiContent(from = Blob.class, type = Formats.JSONV2),
@OpenApiContent(from = Blob.class, type = Formats.XMLV2)
},
required = true),
queryParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ public void create(@NotNull Context ctx) {
DSLContext dsl = getDslContext(ctx);

String reqContentType = ctx.req.getContentType();
String formatHeader = reqContentType != null ? reqContentType : Formats.JSON;
String formatHeader = reqContentType != null ? reqContentType : Formats.JSONV2;

boolean failIfExists = ctx.queryParamAsClass(FAIL_IF_EXISTS, Boolean.class).getOrDefault(true);

Expand Down
14 changes: 6 additions & 8 deletions cwms-data-api/src/main/java/cwms/cda/api/LocationController.java
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ public void getAll(@NotNull Context ctx) {
String version = contentType.getParameters().get(VERSION);
if (version != null && version.equals("2")) {
List<Location> locations = locationsDao.getLocations(names, units, datum, office);
ObjectMapper om = getObjectMapperForFormat(contentType.getType());
results = om.writeValueAsString(locations);
results = Formats.format(contentType, locations, Location.class);
ctx.result(results);
requestResultSize.update(results.length());
} else if (contentType.getType().equals(Formats.GEOJSON)) {
Expand Down Expand Up @@ -274,8 +273,7 @@ public void getOne(@NotNull Context ctx, @NotNull String name) {
ctx.contentType(contentType.toString());
LocationsDao locationDao = getLocationsDao(dsl);
Location location = locationDao.getLocation(name, units, office);
ObjectMapper om = getObjectMapperForFormat(contentType.getType());
String serializedLocation = om.writeValueAsString(location);
String serializedLocation = Formats.format(contentType, location);
ctx.result(serializedLocation);
} catch (NotFoundException e) {
CdaError re = new CdaError("Not found.");
Expand All @@ -293,8 +291,8 @@ public void getOne(@NotNull Context ctx, @NotNull String name) {
@OpenApi(
requestBody = @OpenApiRequestBody(
content = {
@OpenApiContent(from = Location.class, type = Formats.JSONV2),
@OpenApiContent(from = Location.class, type = Formats.XMLV2)
@OpenApiContent(from = Location.class, type = Formats.JSON),
@OpenApiContent(from = Location.class, type = Formats.XML)
},
required = true),
description = "Create new CWMS Location",
Expand Down Expand Up @@ -326,8 +324,8 @@ public void create(@NotNull Context ctx) {
@OpenApi(
requestBody = @OpenApiRequestBody(
content = {
@OpenApiContent(from = Location.class, type = Formats.XMLV2),
@OpenApiContent(from = Location.class, type = Formats.JSONV2)
@OpenApiContent(from = Location.class, type = Formats.XML),
@OpenApiContent(from = Location.class, type = Formats.JSON)
},
required = true),
description = "Update CWMS Location",
Expand Down
4 changes: 0 additions & 4 deletions cwms-data-api/src/main/java/cwms/cda/data/dto/Location.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ public final class Location extends CwmsDTO {
private final String mapLabel;
private final String boundingOfficeId;

private Location() {
this(new Builder(null, null, null, null, null,null, null));
}

private Location(Builder builder) {
super(builder.officeId);
this.name = builder.name;
Expand Down
40 changes: 18 additions & 22 deletions cwms-data-api/src/main/java/cwms/cda/data/dto/LocationLevel.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public final class LocationLevel extends CwmsDTO {
@JsonProperty(required = true)
@Schema(description = "Name of the location level")

private String locationLevelId;
private final String locationLevelId;
@Schema(description = "Timeseries ID (e.g. from the times series catalog) to use as the "
+ "location level. Mutually exclusive with seasonalValues and "
+ "siParameterUnitsConstantValue")

private String seasonalTimeSeriesId;
private final String seasonalTimeSeriesId;
@Schema(description = "Generic name of this location level. Common names are 'Top of Dam', "
+ "'Streambed', 'Bottom of Dam'.")

Expand All @@ -65,48 +65,48 @@ public final class LocationLevel extends CwmsDTO {
private final String parameterTypeId;
@Schema(description = "Data Type such as Stage, Elevation, or others.")

private String parameterId;
private final String parameterId;
@Schema(description = "Single value for this location level. Mutually exclusive with "
+ "seasonableTimeSeriesId and seasonValues.")

private Double constantValue;
private final Double constantValue;
@Schema(description = "Units the provided levels are in")

private String levelUnitsId;
private final String levelUnitsId;
@Schema(description = "The date/time at which this location level configuration takes effect.")
@JsonFormat(shape = JsonFormat.Shape.STRING)

private ZonedDateTime levelDate;
private final ZonedDateTime levelDate;

private String levelComment;
private final String levelComment;
@Schema(description = "The start point of provided seasonal values")
@JsonFormat(shape = JsonFormat.Shape.STRING)

private ZonedDateTime intervalOrigin;
private final ZonedDateTime intervalOrigin;

private Integer intervalMonths;
private final Integer intervalMonths;

private Integer intervalMinutes;
private final Integer intervalMinutes;
@Schema(description = "Indicating whether or not to interpolate between seasonal values.",
allowableValues = {"T", "F"})

private String interpolateString;
private final String interpolateString;
@Schema(description = "0 if parameterTypeId is Inst. Otherwise duration indicating the time "
+ "window of the aggregate value.")

private String durationId;
private final String durationId;

private BigDecimal attributeValue;
private final BigDecimal attributeValue;

private String attributeUnitsId;
private final String attributeUnitsId;

private String attributeParameterTypeId;
private final String attributeParameterTypeId;

private String attributeParameterId;
private final String attributeParameterId;

private String attributeDurationId;
private final String attributeDurationId;

private String attributeComment;
private final String attributeComment;

@Schema(description = "List of Repeating seasonal values. The values repeater after the "
+ "specified interval."
Expand All @@ -116,10 +116,6 @@ public final class LocationLevel extends CwmsDTO {

private final List<SeasonalValueBean> seasonalValues;

private LocationLevel() {
this(new Builder(null, null));
}

private LocationLevel(Builder builder) {
super(builder.officeId);
seasonalTimeSeriesId = builder.seasonalTimeSeriesId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
@JsonRootName("location-levels")
@FormattableWith(contentType = Formats.JSONV2, formatter = JsonV2.class)
public class LocationLevels extends CwmsDTOPaginated {
@JacksonXmlElementWrapper(localName = "location-levels")
@JacksonXmlElementWrapper
@JacksonXmlProperty(localName = "location-level")
@Schema(description = "List of retrieved location levels")
private List<LocationLevel> levels;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
public class SeasonalValueBean {
private Double value;
private Integer offsetMonths;
private BigInteger offsetMinutes;

private SeasonalValueBean() {
this(new Builder((Double) null));
}
private final Double value;
private final Integer offsetMonths;
private final BigInteger offsetMinutes;

private SeasonalValueBean(Builder builder) {
this.value = builder.value;
Expand Down

0 comments on commit 1e5705b

Please sign in to comment.