Skip to content

Add support for virtual location levels #1086

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

Merged
merged 27 commits into from
Jun 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c764bfd
Integration testing in progress
zack-rma Apr 28, 2025
b846e8d
Updated constituent handling, tests in progress
zack-rma Apr 28, 2025
b7f503e
Added delete method support
zack-rma Apr 29, 2025
5086782
Deletion testing in progress
zack-rma Apr 29, 2025
09fb5be
Deletion testing completed
zack-rma Apr 30, 2025
f9c4e69
Cleaned up testing, added creation helper functions
zack-rma May 1, 2025
840bb31
Removed ratings cleanup
zack-rma May 1, 2025
54ff757
Refactored LocationLevel, added child classes. Updated controller, DAO
zack-rma May 6, 2025
912c138
Moved interpolate parameter, updated controller to handle LocationLev…
zack-rma May 6, 2025
392e35c
Updated per feedback, added subclasses
zack-rma May 8, 2025
fe6211e
Updates from feedback. Fixed scoping and builders
zack-rma May 9, 2025
6ef2488
Updates from feedback. Removed unnecessary query param, updated loggi…
zack-rma May 12, 2025
cc3e071
Formatting fixes
zack-rma May 13, 2025
24c67cb
Minor unit test fixes
zack-rma May 13, 2025
321df49
Updated naming, generic typing
zack-rma May 20, 2025
3d211bd
Update query to handle paging. Catalog will not return virtual level …
zack-rma May 22, 2025
76105c6
Paging test update
zack-rma May 22, 2025
fffb3d5
Improved paging test coverage
zack-rma May 23, 2025
451c511
Updated virtual location level test data
zack-rma Jun 5, 2025
c0475c6
Merge remote-tracking branch 'refs/remotes/hec/develop' into feature/…
zack-rma Jun 6, 2025
62659ab
Fix broken symbol reference
zack-rma Jun 6, 2025
62e8d55
Fix broken latest rating test
zack-rma Jun 6, 2025
f70c4e0
Removed unnecessary casting method
zack-rma Jun 6, 2025
cdd814f
extracted common builder attributes
zack-rma Jun 6, 2025
0b06084
Merge branch 'develop' into feature/virtual_loc_levels
zack-rma Jun 10, 2025
dc6363c
Cleaned up LocationLevel builder usage, added unit tests
zack-rma Jun 10, 2025
5b0d47e
Fixed location level base class builder
zack-rma Jun 10, 2025
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
260 changes: 115 additions & 145 deletions cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@

package cwms.cda.data.dao;

import cwms.cda.data.dto.LocationLevel;
import cwms.cda.data.dto.LocationLevels;
import cwms.cda.data.dto.locationlevel.LocationLevel;
import cwms.cda.data.dto.locationlevel.LocationLevels;
import cwms.cda.data.dto.TimeSeries;
import hec.data.level.ILocationLevelRef;

import mil.army.usace.hec.metadata.Interval;

import java.time.Instant;
import java.time.ZoneId;
import java.time.ZonedDateTime;

public interface LocationLevelsDao {
Expand Down
565 changes: 394 additions & 171 deletions cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java

Large diffs are not rendered by default.

589 changes: 0 additions & 589 deletions cwms-data-api/src/main/java/cwms/cda/data/dto/LocationLevel.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
*
* MIT License
*
* Copyright (c) 2025 Hydrologic Engineering Center
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE
* SOFTWARE.
*/

package cwms.cda.data.dto.locationlevel;

import java.time.ZonedDateTime;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
import cwms.cda.data.dto.CwmsDTOValidator;
import cwms.cda.formatters.Formats;
import cwms.cda.formatters.annotations.FormattableWith;
import cwms.cda.formatters.json.JsonV1;
import cwms.cda.formatters.json.JsonV2;
import cwms.cda.formatters.xml.XMLv2;
import io.swagger.v3.oas.annotations.media.Schema;

import hec.data.level.IParameterTypedValue;
import hec.data.level.JDomLocationLevelImpl;
import rma.util.RMAConst;

@JsonRootName("ConstantLocationLevel")
@JsonDeserialize(builder = ConstantLocationLevel.Builder.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
@FormattableWith(contentType = Formats.JSONV2, formatter = JsonV2.class, aliases = {Formats.DEFAULT, Formats.JSON})
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class)
@FormattableWith(contentType = Formats.XMLV2, formatter = XMLv2.class, aliases = {Formats.XML})
public final class ConstantLocationLevel extends LocationLevel {
@Schema(description = "Single value for this location level.")

private final Double constantValue;

private ConstantLocationLevel(ConstantLocationLevel.Builder builder) {
super(builder);
constantValue = builder.constantValue;
}

public Double getConstantValue() {
return constantValue;
}

@JsonPOJOBuilder
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Builder extends LocationLevel.Builder<ConstantLocationLevel.Builder> {
private Double constantValue;

@JsonCreator
public Builder(@JsonProperty(value = "location-level-id", required = true) String name,
@JsonProperty(value = "level-date", required = true) ZonedDateTime lvlDate) {
super(name, lvlDate);
}

public Builder(ConstantLocationLevel copyFrom) {
super(copyFrom);
withConstantValue(copyFrom.getConstantValue());
}

public Builder(JDomLocationLevelImpl copyFrom) {
super(copyFrom);
IParameterTypedValue constantLevel = copyFrom.getConstantLevel();
if (constantLevel != null) {
withConstantValue(constantLevel.getSiParameterUnitsValue());
}
}

public ConstantLocationLevel.Builder withConstantValue(Double value) {
if (value != null && RMAConst.isUndefinedValue(value)) {
value = null;
}
this.constantValue = value;
return this;
}

@Override
public ConstantLocationLevel build() {
return new ConstantLocationLevel(this);
}
}

@Override
protected void validateInternal(CwmsDTOValidator validator) {
super.validateInternal(validator);
validator.required(getOfficeId(), "office-id");
validator.required(getLocationLevelId(), "location-level-id");
validator.required(getConstantValue(), "constant-value");
}
}
Loading
Loading