Skip to content

Commit ec069a2

Browse files
solve conflicts
Signed-off-by: Mathieu DEHARBE <[email protected]>
2 parents 0c330d9 + 94ec2cd commit ec069a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1331
-1233
lines changed

pom.xml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,14 @@
8080

8181
<dependencyManagement>
8282
<dependencies>
83-
83+
<!-- project specific dependencies (must be before to have priority during resolution) -->
84+
<dependency><!--TODO remove when springboot version will be updated-->
85+
<groupId>org.junit</groupId>
86+
<artifactId>junit-bom</artifactId>
87+
<version>5.13.4</version>
88+
<type>pom</type>
89+
<scope>import</scope>
90+
</dependency>
8491

8592
<!-- imports -->
8693
<dependency>
@@ -90,8 +97,6 @@
9097
<type>pom</type>
9198
<scope>import</scope>
9299
</dependency>
93-
94-
<!-- project specific dependencies -->
95100
</dependencies>
96101
</dependencyManagement>
97102

src/main/java/org/gridsuite/network/map/NetworkMapController.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import io.swagger.v3.oas.annotations.responses.ApiResponse;
1414
import io.swagger.v3.oas.annotations.responses.ApiResponses;
1515
import io.swagger.v3.oas.annotations.tags.Tag;
16+
import lombok.AllArgsConstructor;
1617
import org.gridsuite.network.map.dto.*;
1718
import org.gridsuite.network.map.dto.definition.hvdc.HvdcShuntCompensatorsInfos;
1819
import org.springframework.context.annotation.ComponentScan;
@@ -33,16 +34,13 @@
3334
@RequestMapping(value = "/" + NetworkMapController.API_VERSION + "/")
3435
@Tag(name = "network-map-server")
3536
@ComponentScan(basePackageClasses = NetworkMapService.class)
37+
@AllArgsConstructor
3638
public class NetworkMapController {
3739

3840
public static final String API_VERSION = "v1";
3941

4042
private final NetworkMapService networkMapService;
4143

42-
public NetworkMapController(NetworkMapService networkMapService) {
43-
this.networkMapService = networkMapService;
44-
}
45-
4644
@PostMapping(value = "/networks/{networkUuid}/elements-ids", produces = APPLICATION_JSON_VALUE)
4745
@Operation(summary = "Get elements ids")
4846
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Equipments ids")})

src/main/java/org/gridsuite/network/map/NetworkMapService.java

Lines changed: 42 additions & 49 deletions
Large diffs are not rendered by default.

src/main/java/org/gridsuite/network/map/dto/ElementType.java

Lines changed: 96 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,47 +7,110 @@
77
package org.gridsuite.network.map.dto;
88

99
import com.powsybl.iidm.network.*;
10+
import lombok.Getter;
11+
import lombok.NonNull;
1012
import org.gridsuite.network.map.dto.mapper.*;
13+
import org.springframework.lang.Nullable;
1114

15+
import java.util.Set;
1216
import java.util.function.BiFunction;
13-
17+
import java.util.function.Function;
18+
import java.util.stream.Stream;
1419

1520
public enum ElementType {
16-
SUBSTATION(Substation.class, SubstationInfosMapper::toData),
17-
VOLTAGE_LEVEL(VoltageLevel.class, VoltageLevelInfosMapper::toData),
18-
LINE(Line.class, LineInfosMapper::toData),
19-
TIE_LINE(TieLine.class, TieLineInfosMapper::toData),
20-
HVDC_LINE(HvdcLine.class, HvdcInfosMapper::toData),
21-
HVDC_LINE_LCC(HvdcLine.class, HvdcLccInfosMapper::toData),
22-
HVDC_LINE_VSC(HvdcLine.class, HvdcVscInfosMapper::toData),
23-
LOAD(Load.class, LoadInfosMapper::toData),
24-
TWO_WINDINGS_TRANSFORMER(TwoWindingsTransformer.class, TwoWindingsTransformerInfosMapper::toData),
25-
THREE_WINDINGS_TRANSFORMER(ThreeWindingsTransformer.class, ThreeWindingsTransformerInfosMapper::toData),
26-
BUSBAR_SECTION(BusbarSection.class, BusBarSectionInfosMapper::toData),
27-
BUS(Bus.class, BusInfosMapper::toData),
28-
GENERATOR(Generator.class, GeneratorInfosMapper::toData),
29-
BATTERY(Battery.class, BatteryInfosMapper::toData),
30-
SHUNT_COMPENSATOR(ShuntCompensator.class, ShuntCompensatorMapper::toData),
31-
DANGLING_LINE(DanglingLine.class, DanglingLineInfosMapper::toData),
32-
STATIC_VAR_COMPENSATOR(StaticVarCompensator.class, StaticVarCompensatorInfosMapper::toData),
33-
LCC_CONVERTER_STATION(LccConverterStation.class, LccConverterStationInfosMapper::toData),
34-
VSC_CONVERTER_STATION(VscConverterStation.class, VscConverterStationInfosMapper::toData);
35-
36-
private final Class<? extends Identifiable> elementClass;
37-
38-
private final BiFunction<Identifiable<?>, InfoTypeParameters, ElementInfos> infosGetter;
39-
40-
public Class<? extends Identifiable> getElementClass() {
41-
return elementClass;
21+
SUBSTATION(Substation.class, SubstationInfosMapper::toData, null),
22+
VOLTAGE_LEVEL(VoltageLevel.class, VoltageLevelInfosMapper::toData, null),
23+
BRANCH(Branch.class, BranchInfosMapper::toData,
24+
network -> Stream.concat(network.getLineStream(), network.getTwoWindingsTransformerStream()),
25+
Line.class, TwoWindingsTransformer.class),
26+
LINE(Line.class, LineInfosMapper::toData, Network::getLineStream),
27+
TIE_LINE(TieLine.class, TieLineInfosMapper::toData, null),
28+
HVDC_LINE(HvdcLine.class, HvdcInfosMapper::toData, null),
29+
HVDC_LINE_LCC(HvdcLine.class, HvdcLccInfosMapper::toData, null),
30+
HVDC_LINE_VSC(HvdcLine.class, HvdcVscInfosMapper::toData, null),
31+
LOAD(Load.class, LoadInfosMapper::toData, Network::getLoadStream),
32+
TWO_WINDINGS_TRANSFORMER(TwoWindingsTransformer.class, TwoWindingsTransformerInfosMapper::toData, Network::getTwoWindingsTransformerStream),
33+
THREE_WINDINGS_TRANSFORMER(ThreeWindingsTransformer.class, ThreeWindingsTransformerInfosMapper::toData, Network::getThreeWindingsTransformerStream),
34+
BUSBAR_SECTION(BusbarSection.class, BusBarSectionInfosMapper::toData, Network::getBusbarSectionStream),
35+
BUS(Bus.class, BusInfosMapper::toData, Network::getBusbarSectionStream),
36+
GENERATOR(Generator.class, GeneratorInfosMapper::toData, Network::getGeneratorStream),
37+
BATTERY(Battery.class, BatteryInfosMapper::toData, Network::getBatteryStream),
38+
SHUNT_COMPENSATOR(ShuntCompensator.class, ShuntCompensatorMapper::toData, Network::getShuntCompensatorStream),
39+
DANGLING_LINE(DanglingLine.class, DanglingLineInfosMapper::toData, Network::getDanglingLineStream),
40+
STATIC_VAR_COMPENSATOR(StaticVarCompensator.class, StaticVarCompensatorInfosMapper::toData, Network::getStaticVarCompensatorStream),
41+
LCC_CONVERTER_STATION(LccConverterStation.class, LccConverterStationInfosMapper::toData, Network::getLccConverterStationStream),
42+
VSC_CONVERTER_STATION(VscConverterStation.class, VscConverterStationInfosMapper::toData, Network::getVscConverterStationStream);
43+
44+
/**
45+
* @since 2.22.0
46+
* @apiNote Is {@code null} if it's not a concrete class.
47+
*/
48+
@NonNull private final Class<? extends Identifiable<?>> elementClass;
49+
50+
/**
51+
* For composed element classes
52+
* @since 2.22.0
53+
*/
54+
@Nullable private final Set<Class<? extends Identifiable<?>>> subClasses;
55+
56+
/**
57+
* Is {@link #elementClass}, or all {@link #subClasses} if present, is an instance of {@link Connectable}?
58+
* @apiNote Is only to not have to do the test each time the information is needed.
59+
* @since 2.22.0
60+
*/
61+
@Getter final boolean isConnectable;
62+
63+
/**
64+
* {@code toData()} function from the mapper
65+
*/
66+
@Getter @NonNull
67+
private final BiFunction</*? extends*/ Identifiable<?>, InfoTypeParameters, ElementInfos> infosGetter;
68+
69+
/**
70+
* @since 2.22.0
71+
*/
72+
@NonNull
73+
private final Function<Network, Stream</*? extends*/ Connectable<?>>> connectableStream;
74+
75+
@SafeVarargs
76+
<T extends Identifiable<T>> ElementType(
77+
@NonNull final Class<T> typeClass,
78+
@NonNull final BiFunction<T, InfoTypeParameters, ElementInfos> dataGetter,
79+
@Nullable final Function<Network, Stream</*T*/ ? extends Connectable<?>>> connectableStream,
80+
@Nullable final Class</*? extends T*/? extends Identifiable<?>>... subTypes) {
81+
this.connectableStream = connectableStream != null ? ((Function<Network, Stream<Connectable<?>>>) (Object) connectableStream) : (n -> {
82+
throw new IllegalStateException("Unexpected connectable type:" + this);
83+
});
84+
this.elementClass = typeClass;
85+
//noinspection unchecked
86+
this.infosGetter = (BiFunction<Identifiable<?>, InfoTypeParameters, ElementInfos>) dataGetter;
87+
if (subTypes != null && subTypes.length > 0) {
88+
this.subClasses = Set.of(subTypes);
89+
if (subClasses.stream().anyMatch(subType -> !typeClass.isAssignableFrom(subType))) {
90+
// typing the list as Class<? extends T> to check during compile-time don't work, so let's at least check during class loading
91+
throw new VerifyError("Not all sub-classes extends base class");
92+
}
93+
this.isConnectable = subClasses.stream().allMatch(Connectable.class::isAssignableFrom);
94+
} else {
95+
this.subClasses = null;
96+
this.isConnectable = Connectable.class.isAssignableFrom(this.elementClass);
97+
}
4298
}
4399

44-
public BiFunction<Identifiable<?>, InfoTypeParameters, ElementInfos> getInfosGetter() {
45-
return infosGetter;
100+
public Stream<Connectable<?>> getVoltageLevelConnectableStream(@NonNull final VoltageLevel voltageLevel) {
101+
if (!this.isConnectable) {
102+
throw new UnsupportedOperationException("This element type is not a connectable type");
103+
}
104+
if (this.subClasses == null) {
105+
return voltageLevel.getConnectableStream((Class<Connectable<?>>) this.elementClass);
106+
} else {
107+
return this.subClasses.stream()
108+
.map(c -> (Class<? extends Connectable<?>>) c)
109+
.flatMap(voltageLevel::getConnectableStream);
110+
}
46111
}
47112

48-
ElementType(Class<? extends Identifiable> typeClass, BiFunction<Identifiable<?>, InfoTypeParameters, ElementInfos> dataGetter) {
49-
this.elementClass = typeClass;
50-
this.infosGetter = dataGetter;
113+
public Stream<Connectable<?>> getConnectableStream(final Network network) {
114+
return this.connectableStream.apply(network);
51115
}
52116
}
53-
Lines changed: 37 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/**
2-
* Copyright (c) 2023, RTE (http://www.rte-france.com)
2+
* Copyright © 2025, RTE (http://www.rte-france.com)
33
* This Source Code Form is subject to the terms of the Mozilla Public
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
package org.gridsuite.network.map.dto.definition.line;
7+
package org.gridsuite.network.map.dto.definition.branch;
88

99
import com.fasterxml.jackson.annotation.JsonInclude;
10-
import com.powsybl.iidm.network.Country;
10+
import com.fasterxml.jackson.annotation.JsonInclude.Include;
1111
import lombok.Getter;
1212
import lombok.experimental.SuperBuilder;
1313
import org.gridsuite.network.map.dto.ElementInfosWithProperties;
@@ -19,90 +19,82 @@
1919
import java.util.Map;
2020
import java.util.Optional;
2121

22-
/**
23-
* @author Slimane Amar <slimane.amar at rte-france.com>
24-
*/
2522
@SuperBuilder
2623
@Getter
27-
public class LineTabInfos extends ElementInfosWithProperties {
28-
24+
public class BranchTabInfos extends ElementInfosWithProperties {
2925
private String voltageLevelId1;
26+
private String voltageLevelId2;
3027

31-
@JsonInclude(JsonInclude.Include.NON_NULL)
28+
@JsonInclude(Include.NON_NULL)
3229
private String voltageLevelName1;
3330

34-
private Double nominalVoltage1;
35-
36-
private String voltageLevelId2;
37-
38-
@JsonInclude(JsonInclude.Include.NON_NULL)
31+
@JsonInclude(Include.NON_NULL)
3932
private String voltageLevelName2;
4033

34+
private Double nominalVoltage1;
4135
private Double nominalVoltage2;
4236

43-
@JsonInclude(JsonInclude.Include.NON_NULL)
44-
private Country country1;
45-
46-
@JsonInclude(JsonInclude.Include.NON_NULL)
47-
private Country country2;
48-
4937
private Boolean terminal1Connected;
50-
5138
private Boolean terminal2Connected;
5239

53-
@JsonInclude(JsonInclude.Include.NON_NULL)
40+
@JsonInclude(Include.NON_NULL)
5441
private Double p1;
5542

56-
@JsonInclude(JsonInclude.Include.NON_NULL)
43+
@JsonInclude(Include.NON_NULL)
5744
private Double q1;
5845

59-
@JsonInclude(JsonInclude.Include.NON_NULL)
46+
@JsonInclude(Include.NON_NULL)
6047
private Double p2;
6148

62-
@JsonInclude(JsonInclude.Include.NON_NULL)
49+
@JsonInclude(Include.NON_NULL)
6350
private Double q2;
6451

65-
@JsonInclude(JsonInclude.Include.NON_NULL)
52+
@JsonInclude(Include.NON_NULL)
6653
private Double i1;
6754

68-
@JsonInclude(JsonInclude.Include.NON_NULL)
55+
@JsonInclude(Include.NON_NULL)
6956
private Double i2;
7057

71-
@JsonInclude(JsonInclude.Include.NON_EMPTY)
58+
@JsonInclude(Include.NON_NULL)
59+
private Double r;
60+
61+
@JsonInclude(Include.NON_NULL)
62+
private Double x;
63+
64+
@JsonInclude(Include.NON_EMPTY)
7265
private Map<String, CurrentLimitsData> operationalLimitsGroup1;
7366

74-
@JsonInclude(JsonInclude.Include.NON_EMPTY)
67+
@JsonInclude(Include.NON_EMPTY)
7568
private List<String> operationalLimitsGroup1Names;
7669

77-
@JsonInclude(JsonInclude.Include.NON_NULL)
70+
@JsonInclude(Include.NON_NULL)
7871
private String selectedOperationalLimitsGroup1;
7972

80-
@JsonInclude(JsonInclude.Include.NON_EMPTY)
73+
@JsonInclude(Include.NON_EMPTY)
8174
private Map<String, CurrentLimitsData> operationalLimitsGroup2;
8275

83-
@JsonInclude(JsonInclude.Include.NON_EMPTY)
76+
@JsonInclude(Include.NON_EMPTY)
8477
private List<String> operationalLimitsGroup2Names;
8578

86-
@JsonInclude(JsonInclude.Include.NON_NULL)
79+
@JsonInclude(Include.NON_NULL)
8780
private String selectedOperationalLimitsGroup2;
8881

89-
@JsonInclude(JsonInclude.Include.NON_NULL)
90-
private Double r;
82+
@JsonInclude(Include.NON_ABSENT)
83+
private Optional<BranchObservabilityInfos> branchObservability;
9184

92-
@JsonInclude(JsonInclude.Include.NON_NULL)
93-
private Double x;
85+
@JsonInclude(Include.NON_NULL)
86+
private Map<String, String> substationProperties1;
9487

95-
@JsonInclude(JsonInclude.Include.NON_NULL)
96-
private Double g1;
88+
@JsonInclude(Include.NON_NULL)
89+
private Map<String, String> voltageLevelProperties1;
9790

98-
@JsonInclude(JsonInclude.Include.NON_NULL)
99-
private Double b1;
91+
@JsonInclude(Include.NON_NULL)
92+
private Map<String, String> substationProperties2;
10093

101-
@JsonInclude(JsonInclude.Include.NON_NULL)
102-
private Double g2;
94+
@JsonInclude(Include.NON_NULL)
95+
private Map<String, String> voltageLevelProperties2;
10396

104-
@JsonInclude(JsonInclude.Include.NON_NULL)
105-
private Double b2;
97+
/* * * Extensions * * */
10698

10799
@JsonInclude(JsonInclude.Include.NON_ABSENT)
108100
private Optional<MeasurementsInfos> measurementP1;
@@ -115,19 +107,4 @@ public class LineTabInfos extends ElementInfosWithProperties {
115107

116108
@JsonInclude(JsonInclude.Include.NON_ABSENT)
117109
private Optional<MeasurementsInfos> measurementQ2;
118-
119-
@JsonInclude(JsonInclude.Include.NON_ABSENT)
120-
private Optional<BranchObservabilityInfos> branchObservability;
121-
122-
@JsonInclude(JsonInclude.Include.NON_NULL)
123-
private Map<String, String> substationProperties1;
124-
125-
@JsonInclude(JsonInclude.Include.NON_NULL)
126-
private Map<String, String> voltageLevelProperties1;
127-
128-
@JsonInclude(JsonInclude.Include.NON_NULL)
129-
private Map<String, String> substationProperties2;
130-
131-
@JsonInclude(JsonInclude.Include.NON_NULL)
132-
private Map<String, String> voltageLevelProperties2;
133110
}

src/main/java/org/gridsuite/network/map/dto/definition/line/LineFormInfos.java renamed to src/main/java/org/gridsuite/network/map/dto/definition/branch/line/LineFormInfos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
package org.gridsuite.network.map.dto.definition.line;
7+
package org.gridsuite.network.map.dto.definition.branch.line;
88

99
import com.fasterxml.jackson.annotation.JsonInclude;
1010
import lombok.Getter;

src/main/java/org/gridsuite/network/map/dto/definition/line/LineMapInfos.java renamed to src/main/java/org/gridsuite/network/map/dto/definition/branch/line/LineMapInfos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
package org.gridsuite.network.map.dto.definition.line;
7+
package org.gridsuite.network.map.dto.definition.branch.line;
88

99
import com.fasterxml.jackson.annotation.JsonInclude;
1010
import lombok.Getter;

src/main/java/org/gridsuite/network/map/dto/definition/line/LineOperatingStatusInfos.java renamed to src/main/java/org/gridsuite/network/map/dto/definition/branch/line/LineOperatingStatusInfos.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
package org.gridsuite.network.map.dto.definition.line;
7+
package org.gridsuite.network.map.dto.definition.branch.line;
88

99
import com.fasterxml.jackson.annotation.JsonInclude;
1010
import lombok.Getter;

0 commit comments

Comments
 (0)