From 4ea840fe64f2262dd284bbc09762e96eb8d9c0a8 Mon Sep 17 00:00:00 2001 From: Antoine Bouhours <123802855+antoinebhs@users.noreply.github.com> Date: Fri, 2 Feb 2024 10:49:01 +0100 Subject: [PATCH] update to powsybl-ws-dependencies 2.7.0 (#17) Signed-off-by: BOUHOURS Antoine --- network-store-iidm-tck/pom.xml | 2 +- network-store-integration-test/pom.xml | 2 +- .../NetworkStorageTestCaseFactory.java | 28 +++---- .../store/integration/NetworkStoreIT.java | 73 ++++++++++--------- network-store-server/pom.xml | 4 - .../network/store/server/Mappings.java | 18 +++-- .../store/server/NetworkStoreApplication.java | 4 +- .../store/server/NetworkStoreRepository.java | 7 +- .../changesets/changelog_20240122T120000Z.xml | 28 +++++++ .../db/changelog/db.changelog-master.yaml | 4 + .../server/NetworkStoreControllerIT.java | 32 ++++---- .../server/NetworkStoreRepositoryTest.java | 4 +- pom.xml | 2 +- 13 files changed, 122 insertions(+), 86 deletions(-) create mode 100644 network-store-server/src/main/resources/db/changelog/changesets/changelog_20240122T120000Z.xml diff --git a/network-store-iidm-tck/pom.xml b/network-store-iidm-tck/pom.xml index 78eeedc3..9076b492 100644 --- a/network-store-iidm-tck/pom.xml +++ b/network-store-iidm-tck/pom.xml @@ -43,7 +43,7 @@ com.powsybl - powsybl-iidm-xml-converter + powsybl-iidm-serde test diff --git a/network-store-integration-test/pom.xml b/network-store-integration-test/pom.xml index a71a3388..acf45e2c 100644 --- a/network-store-integration-test/pom.xml +++ b/network-store-integration-test/pom.xml @@ -25,7 +25,7 @@ com.powsybl - powsybl-iidm-xml-converter + powsybl-iidm-serde test diff --git a/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStorageTestCaseFactory.java b/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStorageTestCaseFactory.java index ed22414a..6840fe54 100644 --- a/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStorageTestCaseFactory.java +++ b/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStorageTestCaseFactory.java @@ -7,8 +7,8 @@ package com.powsybl.network.store.integration; import com.powsybl.iidm.network.*; -import org.joda.time.DateTime; +import java.time.ZonedDateTime; import java.util.Objects; /** @@ -28,7 +28,7 @@ public static Network create(NetworkFactory networkFactory) { Objects.requireNonNull(networkFactory); Network network = networkFactory.createNetwork("networkTestCase", "code"); - network.setCaseDate(DateTime.parse("2016-06-29T14:54:03.427+02:00")); + network.setCaseDate(ZonedDateTime.parse("2016-06-29T14:54:03.427+02:00")); Substation s1 = network.newSubstation() .setId("S1") .setCountry(Country.FR) @@ -340,12 +340,12 @@ public static Network create(NetworkFactory networkFactory) { .setRatedU(9) .add() .add(); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE).setP(375); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO).setP(225); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE).setP(200); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE).setQ(48); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO).setQ(28); - threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE).setQ(18); + threeWindingsTransformer.getTerminal(ThreeSides.ONE).setP(375); + threeWindingsTransformer.getTerminal(ThreeSides.TWO).setP(225); + threeWindingsTransformer.getTerminal(ThreeSides.THREE).setP(200); + threeWindingsTransformer.getTerminal(ThreeSides.ONE).setQ(48); + threeWindingsTransformer.getTerminal(ThreeSides.TWO).setQ(28); + threeWindingsTransformer.getTerminal(ThreeSides.THREE).setQ(18); threeWindingsTransformer.getLeg1().newPhaseTapChanger() .setLowTapPosition(0) @@ -353,7 +353,7 @@ public static Network create(NetworkFactory networkFactory) { .setRegulating(true) .setRegulationMode(PhaseTapChanger.RegulationMode.CURRENT_LIMITER) .setRegulationValue(25) - .setRegulationTerminal(threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE)) + .setRegulationTerminal(threeWindingsTransformer.getTerminal(ThreeSides.ONE)) .setTargetDeadband(22) .beginStep() .setAlpha(-10) @@ -384,7 +384,7 @@ public static Network create(NetworkFactory networkFactory) { .setLowTapPosition(0) .setTapPosition(0) .setRegulating(false) - .setRegulationTerminal(threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE)) + .setRegulationTerminal(threeWindingsTransformer.getTerminal(ThreeSides.ONE)) .setTargetDeadband(22) .setTargetV(220) .beginStep() @@ -462,10 +462,10 @@ public static Network create(NetworkFactory networkFactory) { .setRatedS(50) .add(); - twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.ONE).setP(375); - twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.TWO).setP(225); - twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.ONE).setQ(48); - twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.TWO).setQ(28); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setP(375); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setP(225); + twoWindingsTransformer.getTerminal(TwoSides.ONE).setQ(48); + twoWindingsTransformer.getTerminal(TwoSides.TWO).setQ(28); ShuntCompensator shunt1 = vl1.newShuntCompensator() .setId("SHUNT1") diff --git a/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStoreIT.java b/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStoreIT.java index 52a86ab7..afb263a0 100644 --- a/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStoreIT.java +++ b/network-store-integration-test/src/test/java/com/powsybl/network/store/integration/NetworkStoreIT.java @@ -17,7 +17,9 @@ import com.powsybl.commons.datasource.ResourceSet; import com.powsybl.commons.extensions.Extension; import com.powsybl.commons.reporter.ReporterModel; -import com.powsybl.entsoe.util.*; +import com.powsybl.entsoe.util.EntsoeArea; +import com.powsybl.entsoe.util.EntsoeAreaImpl; +import com.powsybl.entsoe.util.EntsoeGeographicalCode; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.*; import com.powsybl.iidm.network.test.*; @@ -1338,22 +1340,22 @@ public void threeWindingsTransformerTest() { assertEquals(19, threeWindingsTransformer.getLeg3().getB(), 0.1); assertEquals(9, threeWindingsTransformer.getLeg3().getRatedU(), 0.1); - assertEquals(375, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE).getP(), 0.1); - assertEquals(225, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO).getP(), 0.1); - assertEquals(200, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE).getP(), 0.1); + assertEquals(375, threeWindingsTransformer.getTerminal(ThreeSides.ONE).getP(), 0.1); + assertEquals(225, threeWindingsTransformer.getTerminal(ThreeSides.TWO).getP(), 0.1); + assertEquals(200, threeWindingsTransformer.getTerminal(ThreeSides.THREE).getP(), 0.1); - assertEquals(48, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE).getQ(), 0.1); - assertEquals(28, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO).getQ(), 0.1); - assertEquals(18, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE).getQ(), 0.1); + assertEquals(48, threeWindingsTransformer.getTerminal(ThreeSides.ONE).getQ(), 0.1); + assertEquals(28, threeWindingsTransformer.getTerminal(ThreeSides.TWO).getQ(), 0.1); + assertEquals(18, threeWindingsTransformer.getTerminal(ThreeSides.THREE).getQ(), 0.1); - assertEquals(1, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE).getNodeBreakerView().getNode()); - assertEquals(2, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO).getNodeBreakerView().getNode()); - assertEquals(3, threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE).getNodeBreakerView().getNode()); + assertEquals(1, threeWindingsTransformer.getTerminal(ThreeSides.ONE).getNodeBreakerView().getNode()); + assertEquals(2, threeWindingsTransformer.getTerminal(ThreeSides.TWO).getNodeBreakerView().getNode()); + assertEquals(3, threeWindingsTransformer.getTerminal(ThreeSides.THREE).getNodeBreakerView().getNode()); assertEquals(3, threeWindingsTransformer.getTerminals().size()); - assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.ONE))); - assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.TWO))); - assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeWindingsTransformer.Side.THREE))); + assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeSides.ONE))); + assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeSides.TWO))); + assertTrue(threeWindingsTransformer.getTerminals().contains(threeWindingsTransformer.getTerminal(ThreeSides.THREE))); PhaseTapChanger phaseTapChanger = threeWindingsTransformer.getLeg1().getPhaseTapChanger(); assertEqualsPhaseTapChangerStep(phaseTapChanger.getStep(0), -10, 1.5, 0.5, 1., 0.99, 4.); @@ -1447,15 +1449,15 @@ public void twoWindingsTransformerTest() { assertEquals(90, twoWindingsTransformer.getRatedU2(), 0.1); assertEquals(50, twoWindingsTransformer.getRatedS(), 0.1); - assertEquals(375, twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.ONE).getP(), 0.1); - assertEquals(225, twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.TWO).getP(), 0.1); + assertEquals(375, twoWindingsTransformer.getTerminal(TwoSides.ONE).getP(), 0.1); + assertEquals(225, twoWindingsTransformer.getTerminal(TwoSides.TWO).getP(), 0.1); - assertEquals(48, twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.ONE).getQ(), 0.1); - assertEquals(28, twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.TWO).getQ(), 0.1); + assertEquals(48, twoWindingsTransformer.getTerminal(TwoSides.ONE).getQ(), 0.1); + assertEquals(28, twoWindingsTransformer.getTerminal(TwoSides.TWO).getQ(), 0.1); assertEquals(2, twoWindingsTransformer.getTerminals().size()); - assertTrue(twoWindingsTransformer.getTerminals().contains(twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.ONE))); - assertTrue(twoWindingsTransformer.getTerminals().contains(twoWindingsTransformer.getTerminal(TwoWindingsTransformer.Side.TWO))); + assertTrue(twoWindingsTransformer.getTerminals().contains(twoWindingsTransformer.getTerminal(TwoSides.ONE))); + assertTrue(twoWindingsTransformer.getTerminals().contains(twoWindingsTransformer.getTerminal(TwoSides.TWO))); service.flush(readNetwork); // flush the network } @@ -2375,8 +2377,8 @@ public void testUcteNetwork() { assertEquals(3.5, tieLine2.getDanglingLine2().getG(), ESP); assertEquals(5.5, tieLine2.getDanglingLine2().getR(), ESP); assertEquals(6.5, tieLine2.getDanglingLine2().getX(), ESP); - assertEquals("DL1", tieLine2.getDanglingLine(Branch.Side.ONE).getId()); - assertEquals("DL2", tieLine2.getDanglingLine(Branch.Side.TWO).getId()); + assertEquals("DL1", tieLine2.getDanglingLine(TwoSides.ONE).getId()); + assertEquals("DL2", tieLine2.getDanglingLine(TwoSides.TWO).getId()); Line regularLine = readNetwork.getLine("F_SU1_12 F_SU2_11 2"); @@ -2761,17 +2763,17 @@ public void visitBusbarSection(BusbarSection section) { } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { visitedConnectables.add(line.getId()); } @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoSides side) { visitedConnectables.add(transformer.getId()); } @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { + public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeSides side) { visitedConnectables.add(transformer.getId()); } @@ -4035,33 +4037,33 @@ public void testVisit2WTConnectedInOneVLOnlyIssue() { String filePath = "/BrranchConnectedInOneVLOnlyIssue.uct"; ReadOnlyDataSource dataSource = getResource(filePath, filePath); Network network = new UcteImporter().importData(dataSource, new NetworkFactoryImpl(), null); - Set visitedLineSides = new HashSet<>(); - Set visited2WTSides = new HashSet<>(); - Set visited3WTSides = new HashSet<>(); + Set visitedLineSides = new HashSet<>(); + Set visited2WTSides = new HashSet<>(); + Set visited3WTSides = new HashSet<>(); network.getVoltageLevelStream().findFirst().get().visitEquipments(new DefaultTopologyVisitor() { @Override - public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, Branch.Side side) { + public void visitTwoWindingsTransformer(TwoWindingsTransformer transformer, TwoSides side) { visited2WTSides.add(side); } @Override - public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeWindingsTransformer.Side side) { + public void visitThreeWindingsTransformer(ThreeWindingsTransformer transformer, ThreeSides side) { visited3WTSides.add(side); } @Override - public void visitLine(Line line, Branch.Side side) { + public void visitLine(Line line, TwoSides side) { visitedLineSides.add(side); } }); assertEquals(2, visitedLineSides.size()); - assertTrue(visitedLineSides.contains(Branch.Side.ONE)); - assertTrue(visitedLineSides.contains(Branch.Side.TWO)); + assertTrue(visitedLineSides.contains(TwoSides.ONE)); + assertTrue(visitedLineSides.contains(TwoSides.TWO)); assertEquals(2, visited2WTSides.size()); - assertTrue(visited2WTSides.contains(Branch.Side.ONE)); - assertTrue(visited2WTSides.contains(Branch.Side.TWO)); + assertTrue(visited2WTSides.contains(TwoSides.ONE)); + assertTrue(visited2WTSides.contains(TwoSides.TWO)); assertEquals(0, visited3WTSides.size()); } @@ -4637,7 +4639,8 @@ public void testImportWithReport() { ReporterModel report = new ReporterModel("test", "test"); service.importNetwork(getResource("test.xiidm", "/"), report); - assertTrue(report.getSubReporters().isEmpty()); + // There are validationWarnings and xiidmImportDone by default with SerDe + assertFalse(report.getSubReporters().isEmpty()); service.importNetwork(getResource("uctNetwork.uct", "/"), report); assertFalse(report.getSubReporters().isEmpty()); diff --git a/network-store-server/pom.xml b/network-store-server/pom.xml index 38e3b002..dd0a1dcf 100644 --- a/network-store-server/pom.xml +++ b/network-store-server/pom.xml @@ -67,10 +67,6 @@ com.google.guava guava - - joda-time - joda-time - org.postgresql postgresql diff --git a/network-store-server/src/main/java/com/powsybl/network/store/server/Mappings.java b/network-store-server/src/main/java/com/powsybl/network/store/server/Mappings.java index f020c01c..176bb639 100644 --- a/network-store-server/src/main/java/com/powsybl/network/store/server/Mappings.java +++ b/network-store-server/src/main/java/com/powsybl/network/store/server/Mappings.java @@ -8,10 +8,11 @@ import com.powsybl.iidm.network.*; import com.powsybl.network.store.model.*; -import org.joda.time.DateTime; import org.springframework.stereotype.Service; import java.time.Instant; +import java.time.ZoneId; +import java.time.ZonedDateTime; import java.util.*; import java.util.function.Supplier; import java.util.stream.IntStream; @@ -105,7 +106,7 @@ public class Mappings { private static final String CONNECTABLE_BUS = "connectableBus"; private static final String CONNECTABLE_BUS_1 = "connectableBus1"; private static final String CONNECTABLE_BUS_2 = "connectableBus2"; - private static final String BRANCH_STATUS = "branchStatus"; + private static final String OPERATING_STATUS = "operatingStatus"; private static final String FICTITIOUS = "fictitious"; private static final String NODE = "node"; private static final String NODE_1 = "node1"; @@ -159,7 +160,7 @@ private void createLineMappings() { lineMappings.addColumnMapping("bus2", new ColumnMapping<>(String.class, LineAttributes::getBus2, LineAttributes::setBus2)); lineMappings.addColumnMapping(CONNECTABLE_BUS_1, new ColumnMapping<>(String.class, LineAttributes::getConnectableBus1, LineAttributes::setConnectableBus1)); lineMappings.addColumnMapping(CONNECTABLE_BUS_2, new ColumnMapping<>(String.class, LineAttributes::getConnectableBus2, LineAttributes::setConnectableBus2)); - lineMappings.addColumnMapping(BRANCH_STATUS, new ColumnMapping<>(String.class, LineAttributes::getBranchStatus, LineAttributes::setBranchStatus)); + lineMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, LineAttributes::getOperatingStatus, LineAttributes::setOperatingStatus)); lineMappings.addColumnMapping("r", new ColumnMapping<>(Double.class, LineAttributes::getR, LineAttributes::setR)); lineMappings.addColumnMapping("x", new ColumnMapping<>(Double.class, LineAttributes::getX, LineAttributes::setX)); lineMappings.addColumnMapping("g1", new ColumnMapping<>(Double.class, LineAttributes::getG1, LineAttributes::setG1)); @@ -351,8 +352,8 @@ private void createNetworkMappings() { networkMappings.addColumnMapping(ALIAS_BY_TYPE, new ColumnMapping<>(Map.class, NetworkAttributes::getAliasByType, NetworkAttributes::setAliasByType)); networkMappings.addColumnMapping(ALIASES_WITHOUT_TYPE, new ColumnMapping<>(Set.class, NetworkAttributes::getAliasesWithoutType, NetworkAttributes::setAliasesWithoutType)); networkMappings.addColumnMapping("idByAlias", new ColumnMapping<>(Map.class, NetworkAttributes::getIdByAlias, NetworkAttributes::setIdByAlias)); - networkMappings.addColumnMapping("caseDate", new ColumnMapping<>(Instant.class, (NetworkAttributes attributes) -> attributes.getCaseDate().toDate().toInstant(), - (NetworkAttributes attributes, Instant instant) -> attributes.setCaseDate(new DateTime(instant.toEpochMilli())))); + networkMappings.addColumnMapping("caseDate", new ColumnMapping<>(Instant.class, (NetworkAttributes attributes) -> attributes.getCaseDate().toInstant(), + (NetworkAttributes attributes, Instant instant) -> attributes.setCaseDate(ZonedDateTime.ofInstant(instant, ZoneId.systemDefault())))); networkMappings.addColumnMapping("forecastDistance", new ColumnMapping<>(Integer.class, NetworkAttributes::getForecastDistance, NetworkAttributes::setForecastDistance)); networkMappings.addColumnMapping("sourceFormat", new ColumnMapping<>(String.class, NetworkAttributes::getSourceFormat, NetworkAttributes::setSourceFormat)); networkMappings.addColumnMapping("connectedComponentsValid", new ColumnMapping<>(Boolean.class, NetworkAttributes::isConnectedComponentsValid, NetworkAttributes::setConnectedComponentsValid)); @@ -511,12 +512,14 @@ private void createDanglingLineMappings() { attributes.getActivePowerLimits().setPermanentLimit(value); })); danglingLineMappings.addColumnMapping(TIE_LINE_ID, new ColumnMapping<>(String.class, DanglingLineAttributes::getTieLineId, DanglingLineAttributes::setTieLineId)); + danglingLineMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, DanglingLineAttributes::getOperatingStatus, DanglingLineAttributes::setOperatingStatus)); } private void createTieLineMappings() { tieLineMappings.addColumnMapping("name", new ColumnMapping<>(String.class, TieLineAttributes::getName, TieLineAttributes::setName)); tieLineMappings.addColumnMapping("danglingLine1Id", new ColumnMapping<>(String.class, TieLineAttributes::getDanglingLine1Id, TieLineAttributes::setDanglingLine1Id)); tieLineMappings.addColumnMapping("danglingLine2Id", new ColumnMapping<>(String.class, TieLineAttributes::getDanglingLine2Id, TieLineAttributes::setDanglingLine2Id)); + tieLineMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, TieLineAttributes::getOperatingStatus, TieLineAttributes::setOperatingStatus)); } public TableMapping getTieLineMappings() { @@ -667,6 +670,7 @@ private void createHvdcLineMappings() { hvdcLineMappings.addColumnMapping("converterStationId2", new ColumnMapping<>(String.class, HvdcLineAttributes::getConverterStationId2, HvdcLineAttributes::setConverterStationId2)); hvdcLineMappings.addColumnMapping("hvdcAngleDroopActivePowerControl", new ColumnMapping<>(HvdcAngleDroopActivePowerControlAttributes.class, HvdcLineAttributes::getHvdcAngleDroopActivePowerControl, HvdcLineAttributes::setHvdcAngleDroopActivePowerControl)); hvdcLineMappings.addColumnMapping("hvdcOperatorActivePowerRange", new ColumnMapping<>(HvdcOperatorActivePowerRangeAttributes.class, HvdcLineAttributes::getHvdcOperatorActivePowerRange, HvdcLineAttributes::setHvdcOperatorActivePowerRange)); + hvdcLineMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, HvdcLineAttributes::getOperatingStatus, HvdcLineAttributes::setOperatingStatus)); } public TableMapping getTwoWindingsTransformerMappings() { @@ -681,7 +685,7 @@ private void createTwoWindingsTransformerMappings() { twoWindingsTransformerMappings.addColumnMapping("bus2", new ColumnMapping<>(String.class, TwoWindingsTransformerAttributes::getBus2, TwoWindingsTransformerAttributes::setBus2)); twoWindingsTransformerMappings.addColumnMapping(CONNECTABLE_BUS_1, new ColumnMapping<>(String.class, TwoWindingsTransformerAttributes::getConnectableBus1, TwoWindingsTransformerAttributes::setConnectableBus1)); twoWindingsTransformerMappings.addColumnMapping(CONNECTABLE_BUS_2, new ColumnMapping<>(String.class, TwoWindingsTransformerAttributes::getConnectableBus2, TwoWindingsTransformerAttributes::setConnectableBus2)); - twoWindingsTransformerMappings.addColumnMapping(BRANCH_STATUS, new ColumnMapping<>(String.class, TwoWindingsTransformerAttributes::getBranchStatus, TwoWindingsTransformerAttributes::setBranchStatus)); + twoWindingsTransformerMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, TwoWindingsTransformerAttributes::getOperatingStatus, TwoWindingsTransformerAttributes::setOperatingStatus)); twoWindingsTransformerMappings.addColumnMapping("r", new ColumnMapping<>(Double.class, TwoWindingsTransformerAttributes::getR, TwoWindingsTransformerAttributes::setR)); twoWindingsTransformerMappings.addColumnMapping("x", new ColumnMapping<>(Double.class, TwoWindingsTransformerAttributes::getX, TwoWindingsTransformerAttributes::setX)); twoWindingsTransformerMappings.addColumnMapping("g", new ColumnMapping<>(Double.class, TwoWindingsTransformerAttributes::getG, TwoWindingsTransformerAttributes::setG)); @@ -922,7 +926,7 @@ public TableMapping getThreeWindingsTransformerMappings() { private void createThreeWindingsTransformerMappings() { threeWindingsTransformerMappings.addColumnMapping("name", new ColumnMapping<>(String.class, ThreeWindingsTransformerAttributes::getName, ThreeWindingsTransformerAttributes::setName)); - threeWindingsTransformerMappings.addColumnMapping(BRANCH_STATUS, new ColumnMapping<>(String.class, ThreeWindingsTransformerAttributes::getBranchStatus, ThreeWindingsTransformerAttributes::setBranchStatus)); + threeWindingsTransformerMappings.addColumnMapping(OPERATING_STATUS, new ColumnMapping<>(String.class, ThreeWindingsTransformerAttributes::getOperatingStatus, ThreeWindingsTransformerAttributes::setOperatingStatus)); threeWindingsTransformerMappings.addColumnMapping("p1", new ColumnMapping<>(Double.class, ThreeWindingsTransformerAttributes::getP1, ThreeWindingsTransformerAttributes::setP1)); threeWindingsTransformerMappings.addColumnMapping("q1", new ColumnMapping<>(Double.class, ThreeWindingsTransformerAttributes::getQ1, ThreeWindingsTransformerAttributes::setQ1)); threeWindingsTransformerMappings.addColumnMapping("p2", new ColumnMapping<>(Double.class, ThreeWindingsTransformerAttributes::getP2, ThreeWindingsTransformerAttributes::setP2)); diff --git a/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreApplication.java b/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreApplication.java index f5c247ff..872e81ee 100644 --- a/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreApplication.java +++ b/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreApplication.java @@ -1,7 +1,7 @@ package com.powsybl.network.store.server; import com.fasterxml.jackson.databind.Module; -import com.fasterxml.jackson.datatype.joda.JodaModule; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; @@ -16,6 +16,6 @@ public static void main(String[] args) { @Bean public Module module() { - return new JodaModule(); + return new JavaTimeModule(); } } diff --git a/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java b/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java index cea48124..7dad7609 100644 --- a/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java +++ b/network-store-server/src/main/java/com/powsybl/network/store/server/NetworkStoreRepository.java @@ -7,7 +7,10 @@ package com.powsybl.network.store.server; import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.powsybl.commons.PowsyblException; @@ -52,8 +55,10 @@ public class NetworkStoreRepository { @Autowired public NetworkStoreRepository(DataSource dataSource, ObjectMapper mapper, Mappings mappings) { this.dataSource = dataSource; - this.mapper = mapper; this.mappings = mappings; + this.mapper = mapper.registerModule(new JavaTimeModule()) + .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) + .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); } private final DataSource dataSource; diff --git a/network-store-server/src/main/resources/db/changelog/changesets/changelog_20240122T120000Z.xml b/network-store-server/src/main/resources/db/changelog/changesets/changelog_20240122T120000Z.xml new file mode 100644 index 00000000..0a0e5cb3 --- /dev/null +++ b/network-store-server/src/main/resources/db/changelog/changesets/changelog_20240122T120000Z.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + diff --git a/network-store-server/src/main/resources/db/changelog/db.changelog-master.yaml b/network-store-server/src/main/resources/db/changelog/db.changelog-master.yaml index ec4b56e3..21248a9c 100644 --- a/network-store-server/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/network-store-server/src/main/resources/db/changelog/db.changelog-master.yaml @@ -31,3 +31,7 @@ databaseChangeLog: - include: file: changesets/changelog_20231026T120000Z.xml relativeToChangelogFile: true + + - include: + file: changesets/changelog_20240122T120000Z.xml + relativeToChangelogFile: true diff --git a/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreControllerIT.java b/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreControllerIT.java index 4bbc71f7..3da68f57 100644 --- a/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreControllerIT.java +++ b/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreControllerIT.java @@ -6,13 +6,14 @@ */ package com.powsybl.network.store.server; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.joda.JodaModule; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.powsybl.iidm.network.*; import com.powsybl.iidm.network.extensions.ConnectablePosition; import com.powsybl.network.store.model.*; import jakarta.servlet.ServletException; -import org.joda.time.DateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,20 +22,13 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.annotation.DirtiesContext.ClassMode; -import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.DynamicPropertyRegistry; +import org.springframework.test.context.DynamicPropertySource; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeMap; -import java.util.UUID; +import java.time.ZonedDateTime; +import java.util.*; import static com.powsybl.network.store.model.NetworkStoreApi.VERSION; import static org.hamcrest.collection.IsCollectionWithSize.hasSize; @@ -69,7 +63,9 @@ static void makeTestDbSuffix(DynamicPropertyRegistry registry) { @Before public void setup() { - this.objectMapper.registerModule(new JodaModule()); + this.objectMapper.registerModule(new JavaTimeModule()) + .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false) + .configure(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS, false); } @Test @@ -89,7 +85,7 @@ public void test() throws Exception { .attributes(NetworkAttributes.builder() .uuid(NETWORK_UUID) .variantId("v") - .caseDate(DateTime.parse("2015-01-01T00:00:00.000Z")) + .caseDate(ZonedDateTime.parse("2015-01-01T00:00:00.000Z")) .build()) .build(); mvc.perform(post("/" + VERSION + "/networks") @@ -816,7 +812,7 @@ public void networkCloneVariantTest() throws Exception { .attributes(NetworkAttributes.builder() .uuid(NETWORK_UUID) .variantId(VariantManagerConstants.INITIAL_VARIANT_ID) - .caseDate(DateTime.parse("2015-01-01T00:00:00.000Z")) + .caseDate(ZonedDateTime.parse("2015-01-01T00:00:00.000Z")) .build()) .build(); mvc.perform(post("/" + VERSION + "/networks") @@ -856,7 +852,7 @@ public void cloneNetworkTest() throws Exception { .attributes(NetworkAttributes.builder() .uuid(NETWORK_UUID) .variantId(VariantManagerConstants.INITIAL_VARIANT_ID) - .caseDate(DateTime.parse("2015-01-01T00:00:00.000Z")) + .caseDate(ZonedDateTime.parse("2015-01-01T00:00:00.000Z")) .build()) .build(); mvc.perform(post("/" + VERSION + "/networks") @@ -890,7 +886,7 @@ public void cloneNetworkTest() throws Exception { .attributes(NetworkAttributes.builder() .uuid(NETWORK_UUID) .variantId("v2") - .caseDate(DateTime.parse("2015-01-01T00:00:00.000Z")) + .caseDate(ZonedDateTime.parse("2015-01-01T00:00:00.000Z")) .build()) .build(); mvc.perform(post("/" + VERSION + "/networks") @@ -905,7 +901,7 @@ public void cloneNetworkTest() throws Exception { .attributes(NetworkAttributes.builder() .uuid(NETWORK_UUID) .variantId("v3") - .caseDate(DateTime.parse("2015-01-01T00:00:00.000Z")) + .caseDate(ZonedDateTime.parse("2015-01-01T00:00:00.000Z")) .build()) .build(); mvc.perform(post("/" + VERSION + "/networks") diff --git a/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreRepositoryTest.java b/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreRepositoryTest.java index c845a6d0..183ecfa1 100644 --- a/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreRepositoryTest.java +++ b/network-store-server/src/test/java/com/powsybl/network/store/server/NetworkStoreRepositoryTest.java @@ -545,7 +545,7 @@ public void insertTapChangerStepsInThreeWindingsTranformerTest() { .attributes(ThreeWindingsTransformerAttributes.builder() .name("id3WTransformerA") .ratedU0(1) - .branchStatus("IN_OPERATION") + .operatingStatus("IN_OPERATION") .leg1(LegAttributes.builder() .ratioTapChangerAttributes(RatioTapChangerAttributes.builder() .lowTapPosition(20) @@ -562,7 +562,7 @@ public void insertTapChangerStepsInThreeWindingsTranformerTest() { .attributes(ThreeWindingsTransformerAttributes.builder() .name("id3WTransformerB") .ratedU0(1) - .branchStatus("IN_OPERATION") + .operatingStatus("IN_OPERATION") .leg1(new LegAttributes()) .leg2(LegAttributes.builder() .phaseTapChangerAttributes(PhaseTapChangerAttributes.builder() diff --git a/pom.xml b/pom.xml index 0f33dc64..25a12dfb 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 1.0 - 2.6.0 + 2.7.0 ../network-store-integration-test/target/site/jacoco-aggregate/jacoco.xml,