Skip to content

Commit 83e70fe

Browse files
authored
gridsuite dependencies 27 (#46)
Signed-off-by: Abdelsalem <[email protected]>
1 parent 6c1b46f commit 83e70fe

File tree

9 files changed

+11
-185
lines changed

9 files changed

+11
-185
lines changed

pom.xml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</developers>
4343

4444
<properties>
45-
<gridsuite-dependencies.version>26</gridsuite-dependencies.version>
45+
<gridsuite-dependencies.version>27</gridsuite-dependencies.version>
4646
<liquibase-hibernate-package>org.gridsuite.shortcircuit.server</liquibase-hibernate-package>
4747
<mockito-inline.version>3.11.1</mockito-inline.version>
4848
<assertj.version>3.24.2</assertj.version>
@@ -121,10 +121,6 @@
121121
<groupId>com.fasterxml.jackson.core</groupId>
122122
<artifactId>jackson-databind</artifactId>
123123
</dependency>
124-
<dependency>
125-
<groupId>com.powsybl</groupId>
126-
<artifactId>powsybl-iidm-mergingview</artifactId>
127-
</dependency>
128124
<dependency>
129125
<groupId>com.powsybl</groupId>
130126
<artifactId>powsybl-network-store-client</artifactId>

src/main/java/org/gridsuite/shortcircuit/server/ShortCircuitController.java

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
*/
77
package org.gridsuite.shortcircuit.server;
88

9-
import com.powsybl.commons.extensions.Extension;
109
import com.powsybl.shortcircuit.ShortCircuitParameters;
1110
import io.swagger.v3.oas.annotations.Operation;
1211
import io.swagger.v3.oas.annotations.Parameter;
@@ -28,8 +27,6 @@
2827
import org.springframework.http.ResponseEntity;
2928
import org.springframework.web.bind.annotation.*;
3029

31-
import java.util.Collection;
32-
import java.util.Collections;
3330
import java.util.List;
3431
import java.util.UUID;
3532

@@ -50,15 +47,7 @@ public ShortCircuitController(ShortCircuitService shortCircuitService) {
5047
}
5148

5249
private static ShortCircuitParameters getNonNullParameters(ShortCircuitParameters parameters) {
53-
//FIXME : this hack has to be removed with the future powsybl version (should be 2023.3.0)
54-
// See the related test to be removed parametersWithExtentionTest()
55-
ShortCircuitParameters nonNullParameters = parameters != null ? parameters : new ShortCircuitParameters();
56-
Collection<Extension<ShortCircuitParameters>> extensions = ShortCircuitParameters.load().getExtensions();
57-
extensions.forEach(e -> {
58-
e.setExtendable(null);
59-
nonNullParameters.addExtension((Class) e.getClass(), e);
60-
});
61-
return nonNullParameters;
50+
return parameters != null ? parameters : new ShortCircuitParameters();
6251
}
6352

6453
@PostMapping(value = "/networks/{networkUuid}/run-and-save", produces = APPLICATION_JSON_VALUE, consumes = APPLICATION_JSON_VALUE)
@@ -69,23 +58,17 @@ private static ShortCircuitParameters getNonNullParameters(ShortCircuitParameter
6958
schema = @Schema(implementation = ShortCircuitParameters.class))})})
7059
public ResponseEntity<UUID> runAndSave(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
7160
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId,
72-
@Parameter(description = "Other networks UUID (to merge with main one))") @RequestParam(name = "networkUuid", required = false) List<UUID> otherNetworkUuids,
7361
@Parameter(description = "Result receiver") @RequestParam(name = "receiver", required = false) String receiver,
7462
@Parameter(description = "reportUuid") @RequestParam(name = "reportUuid", required = false) UUID reportUuid,
7563
@Parameter(description = "reporterId") @RequestParam(name = "reporterId", required = false) String reporterId,
7664
@Parameter(description = "Bus Id - Used for analysis targeting one bus") @RequestParam(name = "busId", required = false) String busId,
7765
@RequestBody(required = false) ShortCircuitParameters parameters,
7866
@RequestHeader(HEADER_USER_ID) String userId) {
7967
ShortCircuitParameters nonNullParameters = getNonNullParameters(parameters);
80-
List<UUID> nonNullOtherNetworkUuids = getNonNullOtherNetworkUuids(otherNetworkUuids);
81-
UUID resultUuid = shortCircuitService.runAndSaveResult(new ShortCircuitRunContext(networkUuid, variantId, nonNullOtherNetworkUuids, receiver, nonNullParameters, reportUuid, reporterId, userId, busId));
68+
UUID resultUuid = shortCircuitService.runAndSaveResult(new ShortCircuitRunContext(networkUuid, variantId, receiver, nonNullParameters, reportUuid, reporterId, userId, busId));
8269
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(resultUuid);
8370
}
8471

85-
private static List<UUID> getNonNullOtherNetworkUuids(List<UUID> otherNetworkUuids) {
86-
return otherNetworkUuids != null ? otherNetworkUuids : Collections.emptyList();
87-
}
88-
8972
@GetMapping(value = "/results/{resultUuid}", produces = APPLICATION_JSON_VALUE)
9073
@Operation(summary = "Get a short circuit analysis result from the database")
9174
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The short circuit analysis result"),

src/main/java/org/gridsuite/shortcircuit/server/repositories/ShortCircuitAnalysisResultRepository.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import lombok.extern.slf4j.Slf4j;
1111
import org.gridsuite.shortcircuit.server.dto.ShortCircuitLimits;
1212
import org.gridsuite.shortcircuit.server.entities.*;
13-
import org.gridsuite.shortcircuit.server.utils.ShortcircuitUtils;
1413
import org.springframework.beans.factory.annotation.Autowired;
1514
import org.springframework.data.domain.Page;
1615
import org.springframework.data.domain.Pageable;
@@ -78,6 +77,7 @@ private static FaultResultEntity toGenericFaultResultEntity(final FaultResult fa
7877
ipMax = shortCircuitLimits.getIpMax();
7978
ipMin = shortCircuitLimits.getIpMin();
8079
}
80+
8181
return new FaultResultEntity(
8282
new FaultEmbeddable(fault.getId(), fault.getElementId(), fault.getFaultType()),
8383
Double.NaN,
@@ -110,7 +110,7 @@ private static FaultResultEntity toFortescueFaultResultEntity(FortescueFaultResu
110110
entity.setFeederResults(faultResult.getFeederResults().stream()
111111
.map(feederResult -> {
112112
final FortescueValue feederFortescueCurrent = ((FortescueFeederResult) feederResult).getCurrent();
113-
final FortescueValue.ThreePhaseValue feederFortescueThreePhaseValue = ShortcircuitUtils.toThreePhaseValue(feederFortescueCurrent);
113+
final FortescueValue.ThreePhaseValue feederFortescueThreePhaseValue = feederFortescueCurrent.toThreePhaseValue();
114114
return new FeederResultEmbeddable(feederResult.getConnectableId(), Double.NaN, new FortescueResultEmbeddable(
115115
feederFortescueCurrent.getPositiveMagnitude(), feederFortescueCurrent.getZeroMagnitude(),
116116
feederFortescueCurrent.getNegativeMagnitude(), feederFortescueCurrent.getPositiveAngle(),
@@ -127,11 +127,10 @@ private static FaultResultEntity toFortescueFaultResultEntity(FortescueFaultResu
127127
entity.setDeltaCurrentIpMax(current.getPositiveMagnitude() - entity.getIpMax() / 1000.0);
128128
}
129129

130-
//We here use the function toThreePhaseValue from the utils class instead of FortescueValue's one because it is currently private by mistake, to be changed once Powsybl core 6.0.0 is out
131-
final FortescueValue.ThreePhaseValue currentThreePhaseValue = ShortcircuitUtils.toThreePhaseValue(current);
130+
final FortescueValue.ThreePhaseValue currentThreePhaseValue = current.toThreePhaseValue();
132131
entity.setFortescueCurrent(new FortescueResultEmbeddable(current.getPositiveMagnitude(), current.getZeroMagnitude(), current.getNegativeMagnitude(), current.getPositiveAngle(), current.getZeroAngle(), current.getNegativeAngle(), currentThreePhaseValue.getMagnitudeA(), currentThreePhaseValue.getMagnitudeB(), currentThreePhaseValue.getMagnitudeC(), currentThreePhaseValue.getAngleA(), currentThreePhaseValue.getAngleB(), currentThreePhaseValue.getAngleC()));
133132
final FortescueValue voltage = faultResult.getVoltage();
134-
final FortescueValue.ThreePhaseValue voltageThreePhaseValue = ShortcircuitUtils.toThreePhaseValue(voltage);
133+
final FortescueValue.ThreePhaseValue voltageThreePhaseValue = voltage.toThreePhaseValue();
135134
entity.setFortescueVoltage(new FortescueResultEmbeddable(voltage.getPositiveMagnitude(), voltage.getZeroMagnitude(), voltage.getNegativeMagnitude(), voltage.getPositiveAngle(), voltage.getZeroAngle(), voltage.getNegativeAngle(), voltageThreePhaseValue.getMagnitudeA(), voltageThreePhaseValue.getMagnitudeB(), voltageThreePhaseValue.getMagnitudeC(), voltageThreePhaseValue.getAngleA(), voltageThreePhaseValue.getAngleB(), voltageThreePhaseValue.getAngleC()));
136135

137136
return entity;

src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitResultContext.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import java.io.UncheckedIOException;
1919
import java.util.*;
20-
import java.util.stream.Collectors;
2120

2221
import static org.gridsuite.shortcircuit.server.service.NotificationService.*;
2322

@@ -44,16 +43,6 @@ public ShortCircuitResultContext(UUID resultUuid, ShortCircuitRunContext runCont
4443
this.runContext = Objects.requireNonNull(runContext);
4544
}
4645

47-
private static List<UUID> getHeaderList(MessageHeaders headers, String name) {
48-
String header = (String) headers.get(name);
49-
if (header == null || header.isEmpty()) {
50-
return Collections.emptyList();
51-
}
52-
return Arrays.asList(header.split(",")).stream()
53-
.map(UUID::fromString)
54-
.collect(Collectors.toList());
55-
}
56-
5746
private static String getNonNullHeader(MessageHeaders headers, String name) {
5847
String header = (String) headers.get(name);
5948
if (header == null) {
@@ -72,8 +61,6 @@ public static ShortCircuitResultContext fromMessage(Message<String> message, Obj
7261
String userId = (String) headers.get(HEADER_USER_ID);
7362
String busId = (String) headers.get(HEADER_BUS_ID);
7463

75-
List<UUID> otherNetworkUuids = getHeaderList(headers, "otherNetworkUuids");
76-
7764
ShortCircuitParameters parameters;
7865
try {
7966
// can't use the following line because jackson doesn't play well with null..?
@@ -85,7 +72,7 @@ public static ShortCircuitResultContext fromMessage(Message<String> message, Obj
8572
UUID reportUuid = headers.containsKey(REPORT_UUID_HEADER) ? UUID.fromString((String) headers.get(REPORT_UUID_HEADER)) : null;
8673
String reporterId = headers.containsKey(REPORTER_ID_HEADER) ? (String) headers.get(REPORTER_ID_HEADER) : null;
8774
ShortCircuitRunContext runContext = new ShortCircuitRunContext(networkUuid,
88-
variantId, otherNetworkUuids, receiver,
75+
variantId, receiver,
8976
parameters, reportUuid, reporterId, userId, busId);
9077
return new ShortCircuitResultContext(resultUuid, runContext);
9178
}
@@ -103,7 +90,6 @@ public Message<String> toMessage(ObjectMapper objectMapper) {
10390
.setHeader("resultUuid", resultUuid.toString())
10491
.setHeader("networkUuid", runContext.getNetworkUuid().toString())
10592
.setHeader(VARIANT_ID_HEADER, runContext.getVariantId())
106-
.setHeader("otherNetworkUuids", runContext.getOtherNetworkUuids().stream().map(UUID::toString).collect(Collectors.joining(",")))
10793
.setHeader(HEADER_RECEIVER, runContext.getReceiver())
10894
.setHeader(HEADER_USER_ID, runContext.getUserId())
10995
.setHeader(REPORT_UUID_HEADER, runContext.getReportUuid() != null ? runContext.getReportUuid().toString() : null)

src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitRunContext.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.powsybl.shortcircuit.ShortCircuitParameters;
1010
import lombok.Getter;
1111

12-
import java.util.List;
1312
import java.util.Objects;
1413
import java.util.UUID;
1514

@@ -23,8 +22,6 @@ public class ShortCircuitRunContext {
2322

2423
private final String variantId;
2524

26-
private final List<UUID> otherNetworkUuids;
27-
2825
private final String receiver;
2926

3027
private final ShortCircuitParameters parameters;
@@ -37,10 +34,9 @@ public class ShortCircuitRunContext {
3734

3835
private final String busId;
3936

40-
public ShortCircuitRunContext(UUID networkUuid, String variantId, List<UUID> otherNetworkUuids, String receiver, ShortCircuitParameters parameters, UUID reportUuid, String reporterId, String userId, String busId) {
37+
public ShortCircuitRunContext(UUID networkUuid, String variantId, String receiver, ShortCircuitParameters parameters, UUID reportUuid, String reporterId, String userId, String busId) {
4138
this.networkUuid = Objects.requireNonNull(networkUuid);
4239
this.variantId = variantId;
43-
this.otherNetworkUuids = Objects.requireNonNull(otherNetworkUuids);
4440
this.receiver = receiver;
4541
this.parameters = Objects.requireNonNull(parameters);
4642
this.reportUuid = reportUuid;

src/main/java/org/gridsuite/shortcircuit/server/service/ShortCircuitWorkerService.java

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.powsybl.commons.reporter.Reporter;
1313
import com.powsybl.commons.reporter.ReporterModel;
1414
import com.powsybl.computation.local.LocalComputationManager;
15-
import com.powsybl.iidm.mergingview.MergingView;
1615
import com.powsybl.iidm.network.*;
1716
import com.powsybl.iidm.network.extensions.IdentifiableShortCircuit;
1817
import com.powsybl.network.store.client.NetworkStoreService;
@@ -93,26 +92,11 @@ private Network getNetwork(UUID networkUuid, String variantId) {
9392
return network;
9493
}
9594

96-
private Network getNetwork(UUID networkUuid, List<UUID> otherNetworkUuids, String variantId) {
97-
Network network = getNetwork(networkUuid, variantId);
98-
if (otherNetworkUuids.isEmpty()) {
99-
return network;
100-
} else {
101-
List<Network> otherNetworks = otherNetworkUuids.stream().map(uuid -> getNetwork(uuid, variantId)).collect(Collectors.toList());
102-
List<Network> networks = new ArrayList<>();
103-
networks.add(network);
104-
networks.addAll(otherNetworks);
105-
MergingView mergingView = MergingView.create("merge", "iidm");
106-
mergingView.merge(networks.toArray(new Network[0]));
107-
return mergingView;
108-
}
109-
}
110-
11195
private ShortCircuitAnalysisResult run(ShortCircuitRunContext context, UUID resultUuid) throws ExecutionException, InterruptedException {
11296
Objects.requireNonNull(context);
11397

11498
LOGGER.info("Run short circuit analysis...");
115-
Network network = getNetwork(context.getNetworkUuid(), context.getOtherNetworkUuids(), context.getVariantId());
99+
Network network = getNetwork(context.getNetworkUuid(), context.getVariantId());
116100

117101
Reporter rootReporter = Reporter.NO_OP;
118102
Reporter reporter = Reporter.NO_OP;

src/main/java/org/gridsuite/shortcircuit/server/utils/ShortcircuitUtils.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)