Skip to content
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
wants to merge 40 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 Jul 1, 2024
f4130b5
Implemented Water Supply DTO and Tests with updated design
zack-rma Jul 3, 2024
d6708f8
Updated Water Supply DTO validators
zack-rma Jul 16, 2024
d396307
Removed internal validation, replaced with JSON require; Added format…
zack-rma Jul 16, 2024
df3d007
Renamed PUMP enum and some other variables, Removed WaterUserContract…
zack-rma Jul 17, 2024
a202cc8
Implemented Water Supply DTO and Tests
zack-rma Jul 1, 2024
8b534c9
Updated validation function
zack-rma Jul 1, 2024
e203dc8
Renamed Type files, Removed duplicate LookupType and LocationRefType …
zack-rma Jul 2, 2024
ed7290f
Removed duplicate location class
zack-rma Jul 2, 2024
92ea19f
Delete LookupType.java
zack-rma Jul 2, 2024
26e395f
First draft of Water Supply DAO
zack-rma Jul 1, 2024
52ab248
Updated Dao to reflect class renames and removals
zack-rma Jul 2, 2024
335cd3d
DAO Testing in progress
zack-rma Jul 4, 2024
ee271fc
First draft of Water supply controllers, tests in progress
zack-rma Jul 10, 2024
68cbcb9
Controllers working, testing still in progress
zack-rma Jul 12, 2024
a1de635
Test cases passed, Controllers working
zack-rma Jul 16, 2024
e5c0de5
Fixed Water Supply Controller tests to match DTO changes
zack-rma Jul 16, 2024
750fd25
Updated Controllers to match DTO and DAO changes
zack-rma Jul 18, 2024
3f01352
Renamed Project Location Ref to Project ID, Removed deprecated Locati…
zack-rma Jul 22, 2024
5547fb9
Incorporated changed DTOs (changed constructors to builders)
zack-rma Jul 24, 2024
d9c0f15
Implemented Water Supply Accounting DTO
zack-rma Jul 18, 2024
8593b6e
Refactored DTO, added Mappable data representation
zack-rma Jul 19, 2024
415f9b4
Changed DTO Location from Location object to CwmsId
zack-rma Jul 19, 2024
4108154
Updated JSON input, renamed Project Location Ref to Project ID
zack-rma Jul 22, 2024
3b11d17
Updated Dates to Instant
zack-rma Jul 22, 2024
376b9ec
Incorporated changed Water Supply DTOs (changed constructors to build…
zack-rma Jul 24, 2024
9cc67e3
Switched DTOs to Builder Constructors
zack-rma Jul 24, 2024
6e21d95
Reworked DTO to clarify Structure for JSON
zack-rma Jul 25, 2024
e55e9cd
Removed deprecated water pump controller
zack-rma Aug 12, 2024
3208e5a
Updated Accounting DTO and tests
zack-rma Aug 12, 2024
f612350
Added base location to pump names
zack-rma Aug 14, 2024
950e791
Added sublocations to tests
zack-rma Aug 14, 2024
40a3c41
Rewrote Water Pump Accounting DTO for more concise JSON files
zack-rma Aug 26, 2024
1a86b94
Finalized pump transfer dto
zack-rma Aug 27, 2024
f834f81
CTO-97 - Water Pump Accounting DTO update with TS-style JSON
zack-rma Oct 14, 2024
49af9c3
Updated format to match TimeSeries format, added tests
zack-rma Oct 29, 2024
6baeaf0
Added test
zack-rma Oct 29, 2024
21f1cd3
Updated DTO paging structure
zack-rma Oct 31, 2024
7d5210b
Updated DTO to initialize list
zack-rma Nov 1, 2024
0b17adb
Merge branch 'develop' into feature/water_supply_accounting_dto
zack-rma Nov 4, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
*
* 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.formatters.Formats;
import cwms.cda.formatters.annotations.FormattableWith;
import cwms.cda.formatters.json.JsonV1;

@JsonDeserialize(builder = PumpColumn.Builder.class)
@FormattableWith(contentType = Formats.JSONV1, formatter = JsonV1.class,
aliases = {Formats.DEFAULT, Formats.JSON})
public final class PumpColumn extends CwmsDTOBase {
@JsonProperty(value = "name", required = true)
private final String name;
@JsonProperty(value = "ordinal", required = true)
private final int ordinal;
@JsonProperty(value = "datatype", required = true)
private final String dataType;

private PumpColumn(Builder builder) {
name = builder.name;
ordinal = builder.ordinal;
dataType = builder.dataType;
}

public String getName() {
return name;
}

public int getOrdinal() {
return ordinal;
}

public String getDataType() {
return dataType;
}

public static class Builder {
@JsonProperty("name")
private String name;
@JsonProperty("ordinal")
private int ordinal;
@JsonProperty("datatype")
private String dataType;

public Builder withName(String name) {
this.name = name;
return this;
}

public Builder withOrdinal(int ordinal) {
this.ordinal = ordinal;
return this;
}

public Builder withDataType(String dataType) {
this.dataType = dataType;
return this;
}

public PumpColumn build() {
return new PumpColumn(this);
}
}
}
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);
}
}
}
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.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
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)
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
public final class PumpTransfer extends CwmsDTOBase {
@JsonProperty(required = true, index = 0)
private final PumpType pumpType;
@JsonProperty(required = true, index = 1)
private final String transferTypeDisplay;
@JsonProperty(required = true, index = 2)
private final Double flow;
@JsonProperty(required = true, index = 3)
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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
*
* 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.ArrayList;
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")
@JsonProperty(required = true, value = "data-columns")
private final List<PumpColumn> pumpColumn;
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;
this.pumpColumn = buildPumpColumns();
}

public String getContractName() {
return this.contractName;
}

public WaterUser getWaterUser() {
return this.waterUser;
}

public List<PumpColumn> getPumpColumn() {
return this.pumpColumn;
}

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);
}
}

private List<PumpColumn> buildPumpColumns() {
List<PumpColumn> retVal = new ArrayList<>();
retVal.add(new PumpColumn.Builder()
.withName("pump-type")
.withOrdinal(1)
.withDataType(String.class.getTypeName())
.build());
retVal.add(new PumpColumn.Builder()
.withName("transfer-type-display")
.withOrdinal(2)
.withDataType(String.class.getTypeName())
.build());
retVal.add(new PumpColumn.Builder()
.withName("flow").withOrdinal(3)
.withDataType(Double.class.getTypeName())
.build());
retVal.add(new PumpColumn.Builder()
.withName("comment")
.withOrdinal(4)
.withDataType(String.class.getTypeName())
.build());
return retVal;
}
}
Loading
Loading