forked from USACE/cwms-data-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Water Supply DTO and Tests (USACE#751)
Implements water supply DTO and appropriate serialization and validation tests.
- Loading branch information
Showing
7 changed files
with
894 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/PumpType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/WaterSupplyPump.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/WaterUser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.