Skip to content

Commit

Permalink
Implemented Water Supply DTO and Tests (USACE#751)
Browse files Browse the repository at this point in the history
Implements water supply DTO and appropriate serialization and validation
tests.
  • Loading branch information
zack-rma authored Jul 30, 2024
1 parent f9d7ac6 commit 25a4605
Show file tree
Hide file tree
Showing 7 changed files with 894 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* MIT License
*
* Copyright (c) 2024 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.watersupply;

public enum PumpType {
IN("IN"),
OUT("OUT"),
BELOW("BELOW");

private final String pumpName;

PumpType(String name) {
this.pumpName = name;
}

public String getName() {
return pumpName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
*
* MIT License
*
* Copyright (c) 2024 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.watersupply;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import cwms.cda.data.dto.CwmsDTOBase;
import cwms.cda.data.dto.Location;

@JsonRootName("water_supply_pump")
@JsonDeserialize(builder = WaterSupplyPump.Builder.class)
public final class WaterSupplyPump extends CwmsDTOBase {
@JsonProperty(required = true)
private final Location pumpLocation;
@JsonProperty(required = true)
private final PumpType pumpType;

private WaterSupplyPump(Builder builder) {
this.pumpLocation = builder.pumpLocation;
this.pumpType = builder.pumpType;
}

public Location getPumpLocation() {
return this.pumpLocation;
}

public PumpType getPumpType() {
return this.pumpType;
}

public static class Builder {
private Location pumpLocation;
private PumpType pumpType;

public Builder withPumpLocation(@JsonProperty("pump-location") Location pumpLocation) {
this.pumpLocation = pumpLocation;
return this;
}

public Builder withPumpType(@JsonProperty("pump-type") PumpType pumpType) {
this.pumpType = pumpType;
return this;
}

public WaterSupplyPump build() {
return new WaterSupplyPump(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
*
* MIT License
*
* Copyright (c) 2024 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.watersupply;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import cwms.cda.data.dto.CwmsDTOBase;
import cwms.cda.data.dto.CwmsId;
import cwms.cda.formatters.Formats;
import cwms.cda.formatters.annotations.FormattableWith;
import cwms.cda.formatters.json.JsonV1;


@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class,
aliases = {Formats.DEFAULT, Formats.JSON})
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class)
@JsonDeserialize(builder = WaterUser.Builder.class)
public final class WaterUser extends CwmsDTOBase {
@JsonProperty(required = true)
private final String entityName;
@JsonProperty(required = true)
private final CwmsId projectId;
@JsonProperty(required = true)
private final String waterRight;

private WaterUser(Builder builder) {
this.entityName = builder.entityName;
this.projectId = builder.projectId;
this.waterRight = builder.waterRight;
}

public CwmsId getProjectId() {
return this.projectId;
}

public String getEntityName() {
return this.entityName;
}

public String getWaterRight() {
return this.waterRight;
}

public static class Builder {
private String entityName;
private CwmsId projectId;
private String waterRight;

public Builder withEntityName(@JsonProperty("entity-name") String entityName) {
this.entityName = entityName;
return this;
}

public Builder withProjectId(@JsonProperty("project-id") CwmsId projectId) {
this.projectId = projectId;
return this;
}

public Builder withWaterRight(@JsonProperty("water-right") String waterRight) {
this.waterRight = waterRight;
return this;
}

public WaterUser build() {
return new WaterUser(this);
}
}
}
Loading

0 comments on commit 25a4605

Please sign in to comment.