Skip to content

Commit 772a17d

Browse files
committed
Merge branch 'master' of https://github.com/powsybl/powsybl-network-store into complete_persistent_iidm_implementation
2 parents af29586 + e221022 commit 772a17d

File tree

14 files changed

+410
-1230
lines changed

14 files changed

+410
-1230
lines changed

network-store-client/src/main/java/com/powsybl/network/store/client/BufferedNetworkStoreClient.java

+66-66
Large diffs are not rendered by default.

network-store-client/src/main/java/com/powsybl/network/store/client/PreloadingNetworkStoreClient.java

+64-160
Large diffs are not rendered by default.

network-store-client/src/main/java/com/powsybl/network/store/client/RestClient.java

-8
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,6 @@ public <T extends IdentifiableAttributes> List<Resource<T>> getAll(String target
7171
return getBody(response).getData();
7272
}
7373

74-
public <T extends IdentifiableAttributes> int getTotalCount(String target, String url, Object... uriVariables) {
75-
ResponseEntity<TopLevelDocument<T>> response = getDocument(url, uriVariables);
76-
if (response.getStatusCode() != HttpStatus.OK) {
77-
throw new PowsyblException("Fail to get " + target + " empty list, status: " + response.getStatusCode());
78-
}
79-
return Integer.parseInt(getBody(response).getMeta().get("totalCount"));
80-
}
81-
8274
public <T extends IdentifiableAttributes> void update(String url, Resource<T> resource, Object... uriVariables) {
8375
restTemplate.put(url, resource, uriVariables);
8476
}

network-store-client/src/main/java/com/powsybl/network/store/client/RestNetworkStoreClient.java

+23-268
Large diffs are not rendered by default.

network-store-client/src/test/java/com/powsybl/network/store/client/PreloadingNetworkStoreClientTest.java

+44-43
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.springframework.test.web.client.MockRestServiceServer;
2626

2727
import java.io.IOException;
28+
import java.util.Collections;
2829
import java.util.UUID;
2930

3031
import static org.junit.Assert.assertEquals;
@@ -96,9 +97,9 @@ public void testSubstationCache() throws IOException {
9697
assertEquals(Boolean.TRUE, substationAttributesResource.getAttributes().getName().equals("SUBSTATION1")); // test substation name
9798

9899
// Remove component
99-
assertEquals(1, cachedClient.getSubstationCount(networkUuid));
100-
cachedClient.removeSubstation(networkUuid, "sub1");
101-
assertEquals(0, cachedClient.getSubstationCount(networkUuid));
100+
assertEquals(1, cachedClient.getSubstations(networkUuid).size());
101+
cachedClient.removeSubstations(networkUuid, Collections.singletonList("sub1"));
102+
assertEquals(0, cachedClient.getSubstations(networkUuid).size());
102103
server.verify();
103104
}
104105

@@ -133,9 +134,9 @@ public void testVoltageLevelCache() throws IOException {
133134
assertEquals(Boolean.TRUE, voltageLevelAttributesResource.getAttributes().getName().equals("VOLTAGE_LEVEL_1")); // test voltage level name
134135

135136
// Remove component
136-
assertEquals(1, cachedClient.getVoltageLevelCount(networkUuid));
137-
cachedClient.removeVoltageLevel(networkUuid, "vl1");
138-
assertEquals(0, cachedClient.getVoltageLevelCount(networkUuid));
137+
assertEquals(1, cachedClient.getVoltageLevels(networkUuid).size());
138+
cachedClient.removeVoltageLevels(networkUuid, Collections.singletonList("vl1"));
139+
assertEquals(0, cachedClient.getVoltageLevels(networkUuid).size());
139140
server.verify();
140141
}
141142

@@ -174,9 +175,9 @@ public void testSwitchCache() throws IOException {
174175
assertEquals(Boolean.TRUE, switchAttributesResource.getAttributes().isOpen()); // test switch is open
175176

176177
// Remove component
177-
assertEquals(1, cachedClient.getSwitchCount(networkUuid));
178-
cachedClient.removeSwitch(networkUuid, "b1");
179-
assertEquals(0, cachedClient.getSwitchCount(networkUuid));
178+
assertEquals(1, cachedClient.getSwitches(networkUuid).size());
179+
cachedClient.removeSwitches(networkUuid, Collections.singletonList("b1"));
180+
assertEquals(0, cachedClient.getSwitches(networkUuid).size());
180181
server.verify();
181182
}
182183

@@ -211,9 +212,9 @@ public void testGeneratorCache() throws IOException {
211212
assertEquals(300., generatorAttributesResource.getAttributes().getP(), 0.001);
212213

213214
// Remove component
214-
assertEquals(1, cachedClient.getGeneratorCount(networkUuid));
215-
cachedClient.removeGenerator(networkUuid, "g1");
216-
assertEquals(0, cachedClient.getGeneratorCount(networkUuid));
215+
assertEquals(1, cachedClient.getGenerators(networkUuid).size());
216+
cachedClient.removeGenerators(networkUuid, Collections.singletonList("g1"));
217+
assertEquals(0, cachedClient.getGenerators(networkUuid).size());
217218

218219
server.verify();
219220
}
@@ -253,9 +254,9 @@ public void testBatteryCache() throws IOException {
253254
assertEquals(150., batteryAttributesResource.getAttributes().getQ(), 0.001);
254255

255256
// Remove component
256-
assertEquals(1, cachedClient.getBatteryCount(networkUuid));
257-
cachedClient.removeBattery(networkUuid, "b1");
258-
assertEquals(0, cachedClient.getBatteryCount(networkUuid));
257+
assertEquals(1, cachedClient.getBatteries(networkUuid).size());
258+
cachedClient.removeBatteries(networkUuid, Collections.singletonList("b1"));
259+
assertEquals(0, cachedClient.getBatteries(networkUuid).size());
259260

260261
server.verify();
261262
}
@@ -295,9 +296,9 @@ public void testLoadCache() throws IOException {
295296
assertEquals(2000., loadAttributesResource.getAttributes().getP0(), 0.001);
296297

297298
// Remove component
298-
assertEquals(1, cachedClient.getLoadCount(networkUuid));
299-
cachedClient.removeLoad(networkUuid, "l1");
300-
assertEquals(0, cachedClient.getLoadCount(networkUuid));
299+
assertEquals(1, cachedClient.getLoads(networkUuid).size());
300+
cachedClient.removeLoads(networkUuid, Collections.singletonList("l1"));
301+
assertEquals(0, cachedClient.getLoads(networkUuid).size());
301302

302303
server.verify();
303304
}
@@ -333,9 +334,9 @@ public void testShuntCompensatorCache() throws IOException {
333334
assertEquals(8, shuntCompensatorAttributesResource.getAttributes().getSectionCount());
334335

335336
// Remove component
336-
assertEquals(1, cachedClient.getShuntCompensatorCount(networkUuid));
337-
cachedClient.removeShuntCompensator(networkUuid, "sc1");
338-
assertEquals(0, cachedClient.getShuntCompensatorCount(networkUuid));
337+
assertEquals(1, cachedClient.getShuntCompensators(networkUuid).size());
338+
cachedClient.removeShuntCompensators(networkUuid, Collections.singletonList("sc1"));
339+
assertEquals(0, cachedClient.getShuntCompensators(networkUuid).size());
339340

340341
server.verify();
341342
}
@@ -375,9 +376,9 @@ public void testStaticVarCompensatorCache() throws IOException {
375376
assertEquals(1500., staticVarCompensatorAttributesResource.getAttributes().getReactivePowerSetPoint(), 0.001);
376377

377378
// Remove component
378-
assertEquals(1, cachedClient.getStaticVarCompensatorCount(networkUuid));
379-
cachedClient.removeStaticVarCompensator(networkUuid, "svc1");
380-
assertEquals(0, cachedClient.getStaticVarCompensatorCount(networkUuid));
379+
assertEquals(1, cachedClient.getStaticVarCompensators(networkUuid).size());
380+
cachedClient.removeStaticVarCompensators(networkUuid, Collections.singletonList("svc1"));
381+
assertEquals(0, cachedClient.getStaticVarCompensators(networkUuid).size());
381382

382383
server.verify();
383384
}
@@ -413,9 +414,9 @@ public void testVscConverterStationCache() throws IOException {
413414
assertEquals(0.8, vscConverterStationAttributesResource.getAttributes().getLossFactor(), 0.001);
414415

415416
// Remove component
416-
assertEquals(1, cachedClient.getVscConverterStationCount(networkUuid));
417-
cachedClient.removeVscConverterStation(networkUuid, "vsc1");
418-
assertEquals(0, cachedClient.getVscConverterStationCount(networkUuid));
417+
assertEquals(1, cachedClient.getVscConverterStations(networkUuid).size());
418+
cachedClient.removeVscConverterStations(networkUuid, Collections.singletonList("vsc1"));
419+
assertEquals(0, cachedClient.getVscConverterStations(networkUuid).size());
419420

420421
server.verify();
421422
}
@@ -451,9 +452,9 @@ public void testLccConverterStationCache() throws IOException {
451452
assertEquals(400, lccConverterStationAttributesResource.getAttributes().getPowerFactor(), 0.001);
452453

453454
// Remove component
454-
assertEquals(1, cachedClient.getLccConverterStationCount(networkUuid));
455-
cachedClient.removeLccConverterStation(networkUuid, "lcc1");
456-
assertEquals(0, cachedClient.getLccConverterStationCount(networkUuid));
455+
assertEquals(1, cachedClient.getLccConverterStations(networkUuid).size());
456+
cachedClient.removeLccConverterStations(networkUuid, Collections.singletonList("lcc1"));
457+
assertEquals(0, cachedClient.getLccConverterStations(networkUuid).size());
457458

458459
server.verify();
459460
}
@@ -493,9 +494,9 @@ public void testTwoWindingsTransformerCache() throws IOException {
493494
assertEquals(9, twoWindingsTransformerAttributesResource.getAttributes().getX(), 0.001);
494495

495496
// Remove component
496-
assertEquals(1, cachedClient.getTwoWindingsTransformerCount(networkUuid));
497-
cachedClient.removeTwoWindingsTransformer(networkUuid, "tw1");
498-
assertEquals(0, cachedClient.getTwoWindingsTransformerCount(networkUuid));
497+
assertEquals(1, cachedClient.getTwoWindingsTransformers(networkUuid).size());
498+
cachedClient.removeTwoWindingsTransformers(networkUuid, Collections.singletonList("tw1"));
499+
assertEquals(0, cachedClient.getTwoWindingsTransformers(networkUuid).size());
499500

500501
server.verify();
501502
}
@@ -545,9 +546,9 @@ public void testThreeWindingsTransformerCache() throws IOException {
545546
assertEquals(550, threeWindingsTransformerAttributesResource.getAttributes().getQ3(), 0.001);
546547

547548
// Remove component
548-
assertEquals(1, cachedClient.getThreeWindingsTransformerCount(networkUuid));
549-
cachedClient.removeThreeWindingsTransformer(networkUuid, "tw1");
550-
assertEquals(0, cachedClient.getThreeWindingsTransformerCount(networkUuid));
549+
assertEquals(1, cachedClient.getThreeWindingsTransformers(networkUuid).size());
550+
cachedClient.removeThreeWindingsTransformers(networkUuid, Collections.singletonList("tw1"));
551+
assertEquals(0, cachedClient.getThreeWindingsTransformers(networkUuid).size());
551552

552553
server.verify();
553554
}
@@ -584,9 +585,9 @@ public void testLineCache() throws IOException {
584585
assertEquals(1000., lineAttributesResource.getAttributes().getP1(), 0.001);
585586

586587
// Remove component
587-
assertEquals(1, cachedClient.getLineCount(networkUuid));
588-
cachedClient.removeLine(networkUuid, "l1");
589-
assertEquals(0, cachedClient.getLineCount(networkUuid));
588+
assertEquals(1, cachedClient.getLines(networkUuid).size());
589+
cachedClient.removeLines(networkUuid, Collections.singletonList("l1"));
590+
assertEquals(0, cachedClient.getLines(networkUuid).size());
590591

591592
server.verify();
592593
}
@@ -621,9 +622,9 @@ public void testHvdcLineCache() throws IOException {
621622
hvdcLineAttributesResource = cachedClient.getHvdcLine(networkUuid, "hvdc1").orElse(null);
622623
assertNotNull(hvdcLineAttributesResource);
623624
assertEquals(3000., hvdcLineAttributesResource.getAttributes().getMaxP(), 0.001);
624-
assertEquals(1, cachedClient.getHvdcLineCount(networkUuid));
625-
cachedClient.removeHvdcLine(networkUuid, "hvdc1");
626-
assertEquals(0, cachedClient.getHvdcLineCount(networkUuid));
625+
assertEquals(1, cachedClient.getHvdcLines(networkUuid).size());
626+
cachedClient.removeHvdcLines(networkUuid, Collections.singletonList("hvdc1"));
627+
assertEquals(0, cachedClient.getHvdcLines(networkUuid).size());
627628
server.verify();
628629
}
629630

@@ -691,7 +692,7 @@ public void testConfiguredBusCache() throws IOException {
691692
assertEquals(5., configuredBusAttributesResource.getAttributes().getAngle(), 0.001);
692693

693694
assertEquals(1, cachedClient.getConfiguredBuses(networkUuid).size());
694-
cachedClient.removeConfiguredBus(networkUuid, "cb1");
695+
cachedClient.removeConfiguredBuses(networkUuid, Collections.singletonList("cb1"));
695696
assertEquals(0, cachedClient.getConfiguredBuses(networkUuid).size());
696697
server.verify();
697698
}

network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/ForwardingNetworkStoreClient.java renamed to network-store-iidm-impl/src/main/java/com/powsybl/network/store/iidm/impl/AbstractForwardingNetworkStoreClient.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
/**
1414
* @author Geoffroy Jamgotchian <geoffroy.jamgotchian at rte-france.com>
1515
*/
16-
public class ForwardingNetworkStoreClient implements NetworkStoreClient {
16+
public abstract class AbstractForwardingNetworkStoreClient implements NetworkStoreClient {
1717

1818
@Delegate
1919
protected final NetworkStoreClient delegate;
2020

21-
protected ForwardingNetworkStoreClient(NetworkStoreClient delegate) {
21+
protected AbstractForwardingNetworkStoreClient(NetworkStoreClient delegate) {
2222
this.delegate = Objects.requireNonNull(delegate);
2323
this.delegate.setSelf(this);
2424
}

0 commit comments

Comments
 (0)