-
Notifications
You must be signed in to change notification settings - Fork 14
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
Water Supply Accounting DTO #800
Open
zack-rma
wants to merge
40
commits into
USACE:develop
Choose a base branch
from
zack-rma:feature/water_supply_accounting_dto
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 34 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
b0c875e
Implemented Water Supply DTO and Tests
zack-rma f4130b5
Implemented Water Supply DTO and Tests with updated design
zack-rma d6708f8
Updated Water Supply DTO validators
zack-rma d396307
Removed internal validation, replaced with JSON require; Added format…
zack-rma df3d007
Renamed PUMP enum and some other variables, Removed WaterUserContract…
zack-rma a202cc8
Implemented Water Supply DTO and Tests
zack-rma 8b534c9
Updated validation function
zack-rma e203dc8
Renamed Type files, Removed duplicate LookupType and LocationRefType …
zack-rma ed7290f
Removed duplicate location class
zack-rma 92ea19f
Delete LookupType.java
zack-rma 26e395f
First draft of Water Supply DAO
zack-rma 52ab248
Updated Dao to reflect class renames and removals
zack-rma 335cd3d
DAO Testing in progress
zack-rma ee271fc
First draft of Water supply controllers, tests in progress
zack-rma 68cbcb9
Controllers working, testing still in progress
zack-rma a1de635
Test cases passed, Controllers working
zack-rma e5c0de5
Fixed Water Supply Controller tests to match DTO changes
zack-rma 750fd25
Updated Controllers to match DTO and DAO changes
zack-rma 3f01352
Renamed Project Location Ref to Project ID, Removed deprecated Locati…
zack-rma 5547fb9
Incorporated changed DTOs (changed constructors to builders)
zack-rma d9c0f15
Implemented Water Supply Accounting DTO
zack-rma 8593b6e
Refactored DTO, added Mappable data representation
zack-rma 415f9b4
Changed DTO Location from Location object to CwmsId
zack-rma 4108154
Updated JSON input, renamed Project Location Ref to Project ID
zack-rma 3b11d17
Updated Dates to Instant
zack-rma 376b9ec
Incorporated changed Water Supply DTOs (changed constructors to build…
zack-rma 9cc67e3
Switched DTOs to Builder Constructors
zack-rma 6e21d95
Reworked DTO to clarify Structure for JSON
zack-rma e55e9cd
Removed deprecated water pump controller
zack-rma 3208e5a
Updated Accounting DTO and tests
zack-rma f612350
Added base location to pump names
zack-rma 950e791
Added sublocations to tests
zack-rma 40a3c41
Rewrote Water Pump Accounting DTO for more concise JSON files
zack-rma 1a86b94
Finalized pump transfer dto
zack-rma f834f81
CTO-97 - Water Pump Accounting DTO update with TS-style JSON
zack-rma 49af9c3
Updated format to match TimeSeries format, added tests
zack-rma 6baeaf0
Added test
zack-rma 21f1cd3
Updated DTO paging structure
zack-rma 7d5210b
Updated DTO to initialize list
zack-rma 0b17adb
Merge branch 'develop' into feature/water_supply_accounting_dto
zack-rma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
cwms-data-api/src/main/java/cwms/cda/data/dto/watersupply/PumpAccounting.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,75 @@ | ||
/* | ||
* | ||
* 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.databind.annotation.JsonDeserialize; | ||
import cwms.cda.data.dto.CwmsDTOBase; | ||
import cwms.cda.data.dto.CwmsId; | ||
import java.time.Instant; | ||
import java.util.Map; | ||
|
||
|
||
@JsonDeserialize(builder = PumpAccounting.Builder.class) | ||
public final class PumpAccounting extends CwmsDTOBase { | ||
@JsonProperty(required = true) | ||
private final CwmsId pumpLocation; | ||
@JsonProperty(required = true) | ||
private final Map<Instant, PumpTransfer> pumpTransfers; | ||
|
||
private PumpAccounting(Builder builder) { | ||
this.pumpLocation = builder.pumpLocation; | ||
this.pumpTransfers = builder.pumpTransfers; | ||
} | ||
|
||
public CwmsId getPumpLocation() { | ||
return this.pumpLocation; | ||
} | ||
|
||
public Map<Instant, PumpTransfer> getPumpTransfers() { | ||
return this.pumpTransfers; | ||
} | ||
|
||
public static final class Builder { | ||
private CwmsId pumpLocation; | ||
private Map<Instant, PumpTransfer> pumpTransfers; | ||
|
||
public Builder withPumpLocation(CwmsId pumpLocation) { | ||
this.pumpLocation = pumpLocation; | ||
return this; | ||
} | ||
|
||
public Builder withPumpTransfers(Map<Instant, PumpTransfer> pumpTransfers) { | ||
this.pumpTransfers = pumpTransfers; | ||
return this; | ||
} | ||
|
||
public PumpAccounting build() { | ||
return new PumpAccounting(this); | ||
} | ||
} | ||
} |
98 changes: 98 additions & 0 deletions
98
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,98 @@ | ||
/* | ||
* | ||
* 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.databind.annotation.JsonDeserialize; | ||
import cwms.cda.data.dto.CwmsDTOBase; | ||
|
||
import java.time.Instant; | ||
|
||
@JsonDeserialize(builder = PumpTransfer.Builder.class) | ||
public final class PumpTransfer extends CwmsDTOBase { | ||
@JsonProperty(required = true) | ||
private final String transferTypeDisplay; | ||
@JsonProperty(required = true) | ||
private final Double flow; | ||
@JsonProperty(required = true) | ||
private final Instant transferDate; | ||
private final String comment; | ||
|
||
private PumpTransfer(Builder builder) { | ||
this.transferTypeDisplay = builder.transferTypeDisplay; | ||
this.flow = builder.flow; | ||
this.transferDate = builder.transferDate; | ||
this.comment = builder.comment; | ||
} | ||
|
||
public String getTransferTypeDisplay() { | ||
return this.transferTypeDisplay; | ||
} | ||
|
||
public Double getFlow() { | ||
return this.flow; | ||
} | ||
|
||
public Instant getTransferDate() { | ||
return this.transferDate; | ||
} | ||
|
||
public String getComment() { | ||
return this.comment; | ||
} | ||
|
||
public static final class Builder { | ||
private String transferTypeDisplay; | ||
private Double flow; | ||
private Instant transferDate; | ||
private String comment; | ||
|
||
public Builder withTransferTypeDisplay(String transferTypeDisplay) { | ||
this.transferTypeDisplay = transferTypeDisplay; | ||
return this; | ||
} | ||
|
||
public Builder withFlow(Double flow) { | ||
this.flow = flow; | ||
return this; | ||
} | ||
|
||
public Builder withTransferDate(Instant transferDate) { | ||
this.transferDate = transferDate; | ||
return this; | ||
} | ||
|
||
public Builder withComment(String comment) { | ||
this.comment = comment; | ||
return this; | ||
} | ||
|
||
public PumpTransfer build() { | ||
return new PumpTransfer(this); | ||
} | ||
} | ||
} |
122 changes: 122 additions & 0 deletions
122
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,122 @@ | ||
/* | ||
* | ||
* 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.formatters.Formats; | ||
import cwms.cda.formatters.annotations.FormattableWith; | ||
import cwms.cda.formatters.json.JsonV1; | ||
import java.util.Map; | ||
|
||
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class, | ||
aliases = {Formats.DEFAULT, Formats.JSON}) | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
@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; | ||
private final Map<String, PumpAccounting> pumpInAccounting; | ||
private final Map<String, PumpAccounting> pumpOutAccounting; | ||
private final Map<String, PumpAccounting> pumpBelowAccounting; | ||
|
||
private WaterSupplyAccounting(Builder builder) { | ||
this.contractName = builder.contractName; | ||
this.waterUser = builder.waterUser; | ||
this.pumpBelowAccounting = builder.pumpBelowAccounting; | ||
this.pumpInAccounting = builder.pumpInAccounting; | ||
this.pumpOutAccounting = builder.pumpOutAccounting; | ||
} | ||
|
||
public String getContractName() { | ||
return this.contractName; | ||
} | ||
|
||
public WaterUser getWaterUser() { | ||
return this.waterUser; | ||
} | ||
|
||
public Map<String, PumpAccounting> getPumpInAccounting() { | ||
return this.pumpInAccounting; | ||
} | ||
|
||
public Map<String, PumpAccounting> getPumpOutAccounting() { | ||
return this.pumpOutAccounting; | ||
} | ||
|
||
public Map<String, PumpAccounting> getPumpBelowAccounting() { | ||
return this.pumpBelowAccounting; | ||
} | ||
|
||
public static final class Builder { | ||
private String contractName; | ||
private WaterUser waterUser; | ||
private Map<String, PumpAccounting> pumpInAccounting; | ||
private Map<String, PumpAccounting> pumpOutAccounting; | ||
private Map<String, PumpAccounting> pumpBelowAccounting; | ||
|
||
public Builder withContractName(String contractName) { | ||
this.contractName = contractName; | ||
return this; | ||
} | ||
|
||
public Builder withWaterUser(WaterUser waterUser) { | ||
this.waterUser = waterUser; | ||
return this; | ||
} | ||
|
||
public Builder withPumpInAccounting( | ||
Map<String, PumpAccounting> pumpInAccounting) { | ||
this.pumpInAccounting = pumpInAccounting; | ||
return this; | ||
} | ||
|
||
public Builder withPumpOutAccounting( | ||
Map<String, PumpAccounting> pumpOutAccounting) { | ||
this.pumpOutAccounting = pumpOutAccounting; | ||
return this; | ||
} | ||
|
||
public Builder withPumpBelowAccounting( | ||
Map<String, PumpAccounting> pumpBelowAccounting) { | ||
this.pumpBelowAccounting = pumpBelowAccounting; | ||
return this; | ||
} | ||
|
||
public WaterSupplyAccounting build() { | ||
return new WaterSupplyAccounting(this); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid repeated dates, you could drop this date (stop using a Map) and use a navigable set with a comparator on the pump transfer date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll consider doing that with the new DTO structure.