-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements Water Supply Accounting DTO with tests
- Loading branch information
Showing
7 changed files
with
756 additions
and
1 deletion.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/PumpLocation.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,83 @@ | ||
/* | ||
* | ||
* 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.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import cwms.cda.data.dto.CwmsId; | ||
|
||
@JsonDeserialize(builder = PumpLocation.Builder.class) | ||
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) | ||
public final class PumpLocation { | ||
private final CwmsId pumpIn; | ||
private final CwmsId pumpOut; | ||
private final CwmsId pumpBelow; | ||
|
||
private PumpLocation(Builder builder) { | ||
this.pumpIn = builder.pumpIn; | ||
this.pumpOut = builder.pumpOut; | ||
this.pumpBelow = builder.pumpBelow; | ||
} | ||
|
||
public CwmsId getPumpIn() { | ||
return this.pumpIn; | ||
} | ||
|
||
public CwmsId getPumpOut() { | ||
return this.pumpOut; | ||
} | ||
|
||
public CwmsId getPumpBelow() { | ||
return this.pumpBelow; | ||
} | ||
|
||
public static final class Builder { | ||
private CwmsId pumpIn; | ||
private CwmsId pumpOut; | ||
private CwmsId pumpBelow; | ||
|
||
public Builder withPumpIn(CwmsId pumpIn) { | ||
this.pumpIn = pumpIn; | ||
return this; | ||
} | ||
|
||
public Builder withPumpOut(CwmsId pumpOut) { | ||
this.pumpOut = pumpOut; | ||
return this; | ||
} | ||
|
||
public Builder withPumpBelow(CwmsId pumpBelow) { | ||
this.pumpBelow = pumpBelow; | ||
return this; | ||
} | ||
|
||
public PumpLocation build() { | ||
return new PumpLocation(this); | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/PumpTransfer.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,72 @@ | ||
/* | ||
* | ||
* 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.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.PropertyNamingStrategies; | ||
import com.fasterxml.jackson.databind.annotation.JsonNaming; | ||
import cwms.cda.data.dto.CwmsDTOBase; | ||
|
||
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) | ||
public final class PumpTransfer extends CwmsDTOBase { | ||
@JsonProperty(required = true) | ||
private final PumpType pumpType; | ||
@JsonProperty(required = true) | ||
private final String transferTypeDisplay; | ||
@JsonProperty(required = true) | ||
private final Double flow; | ||
@JsonProperty(required = true) | ||
private final String comment; | ||
|
||
@JsonCreator | ||
public PumpTransfer(@JsonProperty("pump-type") PumpType pumpType, | ||
@JsonProperty("transfer-type-display") String transferTypeDisplay, | ||
@JsonProperty("flow") Double flow, @JsonProperty("comment") String comment) { | ||
this.transferTypeDisplay = transferTypeDisplay; | ||
this.flow = flow; | ||
this.comment = comment; | ||
this.pumpType = pumpType; | ||
} | ||
|
||
public String getTransferTypeDisplay() { | ||
return this.transferTypeDisplay; | ||
} | ||
|
||
public Double getFlow() { | ||
return this.flow; | ||
} | ||
|
||
public PumpType getPumpType() { | ||
return this.pumpType; | ||
} | ||
|
||
public String getComment() { | ||
return this.comment; | ||
} | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/WaterSupplyAccounting.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,115 @@ | ||
/* | ||
* | ||
* 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.JsonIgnoreProperties; | ||
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.formatters.Formats; | ||
import cwms.cda.formatters.annotations.FormattableWith; | ||
import cwms.cda.formatters.json.JsonV1; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import java.time.Instant; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class, | ||
aliases = {Formats.DEFAULT, Formats.JSON}) | ||
@JsonDeserialize(builder = WaterSupplyAccounting.Builder.class) | ||
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class) | ||
@JsonNaming(PropertyNamingStrategies.KebabCaseStrategy.class) | ||
public final class WaterSupplyAccounting extends CwmsDTOBase { | ||
@JsonProperty(required = true) | ||
private final String contractName; | ||
@JsonProperty(required = true) | ||
private final WaterUser waterUser; | ||
@JsonProperty(required = true) | ||
private final PumpLocation pumpLocations; | ||
@Schema(name = "data-columns") | ||
private final Map<Instant, List<PumpTransfer>> pumpAccounting; | ||
|
||
private WaterSupplyAccounting(Builder builder) { | ||
this.contractName = builder.contractName; | ||
this.waterUser = builder.waterUser; | ||
this.pumpLocations = builder.pumpLocations; | ||
this.pumpAccounting = builder.pumpAccounting; | ||
} | ||
|
||
public String getContractName() { | ||
return this.contractName; | ||
} | ||
|
||
public WaterUser getWaterUser() { | ||
return this.waterUser; | ||
} | ||
|
||
public Map<Instant, List<PumpTransfer>> getPumpAccounting() { | ||
return this.pumpAccounting; | ||
} | ||
|
||
public PumpLocation getPumpLocations() { | ||
return this.pumpLocations; | ||
} | ||
|
||
|
||
@JsonIgnoreProperties("data-columns") | ||
public static final class Builder { | ||
private String contractName; | ||
private WaterUser waterUser; | ||
private Map<Instant, List<PumpTransfer>> pumpAccounting; | ||
private PumpLocation pumpLocations; | ||
|
||
public Builder withContractName(String contractName) { | ||
this.contractName = contractName; | ||
return this; | ||
} | ||
|
||
public Builder withWaterUser(WaterUser waterUser) { | ||
this.waterUser = waterUser; | ||
return this; | ||
} | ||
|
||
public Builder withPumpAccounting( | ||
Map<Instant, List<PumpTransfer>> pumpAccounting) { | ||
this.pumpAccounting = pumpAccounting; | ||
return this; | ||
} | ||
|
||
public Builder withPumpLocations( | ||
PumpLocation pumpLocations) { | ||
this.pumpLocations = pumpLocations; | ||
return this; | ||
} | ||
|
||
public WaterSupplyAccounting build() { | ||
return new WaterSupplyAccounting(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.