Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
Expand Up @@ -19,10 +19,7 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.*;

import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
import java.util.*;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;

Expand Down Expand Up @@ -52,13 +49,14 @@ public List<String> getElementsIds(@Parameter(description = "Network UUID") @Pat
return networkMapService.getElementsIds(networkUuid, variantId, substationsIds.orElseGet(List::of), elementType, nominalVoltages);
}

@GetMapping(value = "/networks/{networkUuid}/all", produces = APPLICATION_JSON_VALUE)
@PostMapping(value = "/networks/{networkUuid}/all", produces = APPLICATION_JSON_VALUE)
@Operation(summary = "Get all equipments descriptions")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all equipments descriptions")})
public AllElementsInfos getAll(@Parameter(description = "Network UUID") @PathVariable("networkUuid") UUID networkUuid,
@Parameter(description = "Variant Id") @RequestParam(name = "variantId", required = false) String variantId,
@Parameter(description = "Substations id") @RequestParam(name = "substationId", defaultValue = "") List<String> substationsIds) {
return networkMapService.getAllElementsInfos(networkUuid, variantId, substationsIds);
@Parameter(description = "Substations id") @RequestParam(name = "substationId", defaultValue = "") List<String> substationsIds,
@RequestBody Map<String, Map<String, String>> additionalParametersByType) {
return networkMapService.getAllElementsInfos(networkUuid, variantId, substationsIds, additionalParametersByType);
}

@PostMapping(value = "/networks/{networkUuid}/elements", produces = APPLICATION_JSON_VALUE)
Expand Down
42 changes: 23 additions & 19 deletions src/main/java/org/gridsuite/network/map/NetworkMapService.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,30 +61,34 @@ private List<String> getSubstationsIds(UUID networkUuid, String variantId, List<
.map(Substation::getId).toList();
}

public AllElementsInfos getAllElementsInfos(UUID networkUuid, String variantId, @NonNull List<String> substationsId) {
public AllElementsInfos getAllElementsInfos(UUID networkUuid, String variantId, @NonNull List<String> substationsId, Map<String, Map<String, String>> additionalParametersByType) {
Network network = getNetwork(networkUuid, PreloadingStrategy.ALL_COLLECTIONS_NEEDED_FOR_BUS_VIEW, variantId);
return AllElementsInfos.builder()
.substations(getSubstationsInfos(network, substationsId, InfoTypeParameters.TAB, null))
.voltageLevels(getVoltageLevelsInfos(network, substationsId, InfoTypeParameters.TAB, null))
.hvdcLines(getHvdcLinesInfos(network, substationsId, InfoTypeParameters.TAB, null))
.lines(getElementsInfos(network, substationsId, ElementType.LINE, InfoTypeParameters.TAB, null))
.loads(getElementsInfos(network, substationsId, ElementType.LOAD, InfoTypeParameters.TAB, null))
.generators(getElementsInfos(network, substationsId, ElementType.GENERATOR, InfoTypeParameters.TAB, null))
.twoWindingsTransformers(getElementsInfos(network, substationsId, ElementType.TWO_WINDINGS_TRANSFORMER, InfoTypeParameters.TAB, null))
.threeWindingsTransformers(getElementsInfos(network, substationsId, ElementType.THREE_WINDINGS_TRANSFORMER, InfoTypeParameters.TAB, null))
.batteries(getElementsInfos(network, substationsId, ElementType.BATTERY, InfoTypeParameters.TAB, null))
.danglingLines(getElementsInfos(network, substationsId, ElementType.DANGLING_LINE, InfoTypeParameters.TAB, null))
.tieLines(getTieLinesInfos(network, substationsId, InfoTypeParameters.TAB, null))
.lccConverterStations(getElementsInfos(network, substationsId, ElementType.LCC_CONVERTER_STATION, InfoTypeParameters.TAB, null))
.shuntCompensators(getElementsInfos(network, substationsId, ElementType.SHUNT_COMPENSATOR, InfoTypeParameters.TAB, null))
.staticVarCompensators(getElementsInfos(network, substationsId, ElementType.STATIC_VAR_COMPENSATOR, InfoTypeParameters.TAB, null))
.vscConverterStations(getElementsInfos(network, substationsId, ElementType.VSC_CONVERTER_STATION, InfoTypeParameters.TAB, null))
.buses(getBusesInfos(network, substationsId, InfoTypeParameters.TAB))
.busbarSections(getElementsInfos(network, substationsId, ElementType.BUSBAR_SECTION, InfoTypeParameters.TAB, null))
.branches(getElementsInfos(network, substationsId, ElementType.BRANCH, InfoTypeParameters.TAB, null))
.substations(getSubstationsInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.SUBSTATION), null))
.voltageLevels(getVoltageLevelsInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.VOLTAGE_LEVEL), null))
.hvdcLines(getHvdcLinesInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.HVDC_LINE), null))
.lines(getElementsInfos(network, substationsId, ElementType.LINE, getInfoTypeParameters(additionalParametersByType, ElementType.LINE), null))
.loads(getElementsInfos(network, substationsId, ElementType.LOAD, getInfoTypeParameters(additionalParametersByType, ElementType.LOAD), null))
.generators(getElementsInfos(network, substationsId, ElementType.GENERATOR, getInfoTypeParameters(additionalParametersByType, ElementType.GENERATOR), null))
.twoWindingsTransformers(getElementsInfos(network, substationsId, ElementType.TWO_WINDINGS_TRANSFORMER, getInfoTypeParameters(additionalParametersByType, ElementType.TWO_WINDINGS_TRANSFORMER), null))
.threeWindingsTransformers(getElementsInfos(network, substationsId, ElementType.THREE_WINDINGS_TRANSFORMER, getInfoTypeParameters(additionalParametersByType, ElementType.THREE_WINDINGS_TRANSFORMER), null))
.batteries(getElementsInfos(network, substationsId, ElementType.BATTERY, getInfoTypeParameters(additionalParametersByType, ElementType.BATTERY), null))
.danglingLines(getElementsInfos(network, substationsId, ElementType.DANGLING_LINE, getInfoTypeParameters(additionalParametersByType, ElementType.DANGLING_LINE), null))
.tieLines(getTieLinesInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.TIE_LINE), null))
.lccConverterStations(getElementsInfos(network, substationsId, ElementType.LCC_CONVERTER_STATION, getInfoTypeParameters(additionalParametersByType, ElementType.LCC_CONVERTER_STATION), null))
.shuntCompensators(getElementsInfos(network, substationsId, ElementType.SHUNT_COMPENSATOR, getInfoTypeParameters(additionalParametersByType, ElementType.SHUNT_COMPENSATOR), null))
.staticVarCompensators(getElementsInfos(network, substationsId, ElementType.STATIC_VAR_COMPENSATOR, getInfoTypeParameters(additionalParametersByType, ElementType.STATIC_VAR_COMPENSATOR), null))
.vscConverterStations(getElementsInfos(network, substationsId, ElementType.VSC_CONVERTER_STATION, getInfoTypeParameters(additionalParametersByType, ElementType.VSC_CONVERTER_STATION), null))
.buses(getBusesInfos(network, substationsId, getInfoTypeParameters(additionalParametersByType, ElementType.BUS)))
.busbarSections(getElementsInfos(network, substationsId, ElementType.BUSBAR_SECTION, getInfoTypeParameters(additionalParametersByType, ElementType.BUSBAR_SECTION), null))
.branches(getElementsInfos(network, substationsId, ElementType.BRANCH, getInfoTypeParameters(additionalParametersByType, ElementType.BRANCH), null))
.build();
}

private static InfoTypeParameters getInfoTypeParameters(Map<String, Map<String, String>> additionalParametersByType, ElementType elementType) {
return new InfoTypeParameters(ElementInfos.InfoType.TAB, additionalParametersByType.get(String.valueOf(elementType)));
}

private List<String> getVoltageLevelsIds(UUID networkUuid, String variantId, @NonNull List<String> substationsIds, List<Double> nominalVoltages) {
Network network = getNetwork(networkUuid, getPreloadingStrategy(substationsIds), variantId);
return getVoltageLevelStream(network, substationsIds, nominalVoltages).map(VoltageLevel::getId).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
@Data
public class InfoTypeParameters {
public static final String QUERY_PARAM_DC_POWERFACTOR = "dcPowerFactor";
public static final String QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS = "loadOperationalLimitGroups";
public static final String QUERY_PARAM_LOAD_REGULATING_TERMINALS = "loadRegulatingTerminals";

public static final InfoTypeParameters TAB = new InfoTypeParameters(ElementInfos.InfoType.TAB, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.stream.Stream;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_DC_POWERFACTOR;
import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS;
import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.SIDE1;
import static org.gridsuite.network.map.dto.common.CurrentLimitsData.Applicability.SIDE2;
import static org.gridsuite.network.map.dto.utils.ElementUtils.mapCountry;
Expand All @@ -39,14 +40,19 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
final Branch<?> branch = (Branch<?>) identifiable;
final Double dcPowerFactor = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_DC_POWERFACTOR))
.map(Double::valueOf).orElse(null);
final boolean loadOperationalLimitGroups = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS))
.map(Boolean::valueOf).orElse(false);
return switch (infoTypeParameters.getInfoType()) {
case TAB -> toTabInfos(branch, dcPowerFactor);
case TAB -> toTabInfos(branch, dcPowerFactor, loadOperationalLimitGroups);
default -> throw new UnsupportedOperationException("TODO");
};
}

protected static<T extends BranchTabInfos, B extends BranchTabInfosBuilder<T, ?>> B toTabBuilder(
@NonNull final B builder, @NonNull final Branch<?> branch, @Nullable final Double dcPowerFactor
@NonNull final B builder,
@NonNull final Branch<?> branch,
@Nullable final Double dcPowerFactor,
@NonNull final boolean loadOperationalLimitGroups
) {
/* even if x & r properties are in branch properties doc, it is not in branch getter but each impls... */
//TODO https://github.com/powsybl/powsybl-core/issues/3521 tagged for release 09/2025
Expand All @@ -66,14 +72,16 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
// common properties
final Terminal terminal1 = branch.getTerminal1();
final Terminal terminal2 = branch.getTerminal2();
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup1 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups1());
builder.operationalLimitsGroup1(mapOperationalLimitsGroup1)
if (loadOperationalLimitGroups) {
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup1 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups1());
builder.operationalLimitsGroup1(mapOperationalLimitsGroup1)
.operationalLimitsGroup1Names(List.copyOf(mapOperationalLimitsGroup1.keySet()))
.selectedOperationalLimitsGroup1(branch.getSelectedOperationalLimitsGroupId1().orElse(null));
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup2 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups2());
builder.operationalLimitsGroup2(mapOperationalLimitsGroup2)
final Map<String, CurrentLimitsData> mapOperationalLimitsGroup2 = buildCurrentLimitsMap(branch.getOperationalLimitsGroups2());
builder.operationalLimitsGroup2(mapOperationalLimitsGroup2)
.operationalLimitsGroup2Names(List.copyOf(mapOperationalLimitsGroup2.keySet()))
.selectedOperationalLimitsGroup2(branch.getSelectedOperationalLimitsGroupId2().orElse(null));
}
//noinspection unchecked
return (B) builder
.type(branch.getType().name())
Expand Down Expand Up @@ -106,9 +114,9 @@ public static ElementInfos toData(@NonNull final Identifiable<?> identifiable,
.operatingStatus(ExtensionUtils.toOperatingStatus(branch));
}

private static BranchTabInfos toTabInfos(@NonNull final Branch<?> branch, @Nullable final Double dcPowerFactor) {
private static BranchTabInfos toTabInfos(@NonNull final Branch<?> branch, @Nullable final Double dcPowerFactor, @NonNull final Boolean loadOperationalLimitGroups) {
/// Why is {@link BranchTabInfos#builder()} return wildcards in return type {@code BranchTabInfosBuilder<?, ?>}
return toTabBuilder((BranchTabInfosBuilder<BranchTabInfos, ?>) BranchTabInfos.builder(), branch, dcPowerFactor).build();
return toTabBuilder((BranchTabInfosBuilder<BranchTabInfos, ?>) BranchTabInfos.builder(), branch, dcPowerFactor, loadOperationalLimitGroups).build();
}

private static Map<String, CurrentLimitsData> buildCurrentLimitsMap(@NonNull final Collection<OperationalLimitsGroup> operationalLimitsGroups) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_REGULATING_TERMINALS;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

/**
Expand All @@ -42,8 +43,10 @@ private GeneratorInfosMapper() {
}

public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParameters infoTypeParameters) {
boolean loadRegulatingTerminals = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_LOAD_REGULATING_TERMINALS))
.map(Boolean::valueOf).orElse(false);
return switch (infoTypeParameters.getInfoType()) {
case TAB -> toTabInfos(identifiable);
case TAB -> toTabInfos(identifiable, loadRegulatingTerminals);
case FORM -> toFormInfos(identifiable);
case LIST -> ElementInfosMapper.toInfosWithType(identifiable);
default -> throw new UnsupportedOperationException("TODO");
Expand All @@ -60,7 +63,7 @@ private static List<ReactiveCapabilityCurveMapData> getReactiveCapabilityCurvePo
.collect(Collectors.toList());
}

private static GeneratorTabInfos toTabInfos(Identifiable<?> identifiable) {
private static GeneratorTabInfos toTabInfos(Identifiable<?> identifiable, boolean loadRegulatingTerminals) {
Generator generator = (Generator) identifiable;
Terminal terminal = generator.getTerminal();
GeneratorTabInfos.GeneratorTabInfosBuilder<?, ?> builder = GeneratorTabInfos.builder()
Expand All @@ -87,14 +90,17 @@ private static GeneratorTabInfos toTabInfos(Identifiable<?> identifiable) {
.generatorShortCircuit(toGeneratorShortCircuit(generator))
.generatorStartup(toGeneratorStartup(generator));

Terminal regulatingTerminal = generator.getRegulatingTerminal();
//If there is no regulating terminal in file, regulating terminal voltage level is equal to generator voltage level
if (regulatingTerminal != null && !regulatingTerminal.getVoltageLevel().equals(terminal.getVoltageLevel())) {
builder.regulatingTerminalVlName(regulatingTerminal.getVoltageLevel().getOptionalName().orElse(null));
builder.regulatingTerminalConnectableId(regulatingTerminal.getConnectable().getId());
builder.regulatingTerminalConnectableType(regulatingTerminal.getConnectable().getType().name());
builder.regulatingTerminalVlId(regulatingTerminal.getVoltageLevel().getId());
if (loadRegulatingTerminals) {
Terminal regulatingTerminal = generator.getRegulatingTerminal();
//If there is no regulating terminal in file, regulating terminal voltage level is equal to generator voltage level
if (regulatingTerminal != null && !regulatingTerminal.getVoltageLevel().equals(terminal.getVoltageLevel())) {
builder.regulatingTerminalVlName(regulatingTerminal.getVoltageLevel().getOptionalName().orElse(null));
builder.regulatingTerminalConnectableId(regulatingTerminal.getConnectable().getId());
builder.regulatingTerminalConnectableType(regulatingTerminal.getConnectable().getType().name());
builder.regulatingTerminalVlId(regulatingTerminal.getVoltageLevel().getId());
}
}

ReactiveLimits reactiveLimits = generator.getReactiveLimits();
if (reactiveLimits != null) {
ReactiveLimitsKind limitsKind = reactiveLimits.getKind();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
import org.gridsuite.network.map.dto.definition.branch.line.LineTabInfos.LineTabInfosBuilder;
import org.gridsuite.network.map.dto.utils.ExtensionUtils;

import java.util.Optional;

import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_DC_POWERFACTOR;
import static org.gridsuite.network.map.dto.InfoTypeParameters.QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS;
import static org.gridsuite.network.map.dto.utils.ElementUtils.*;

/**
Expand All @@ -30,8 +33,10 @@ private LineInfosMapper() {
public static ElementInfos toData(Identifiable<?> identifiable, InfoTypeParameters infoTypeParameters) {
String dcPowerFactorStr = infoTypeParameters.getOptionalParameters().getOrDefault(QUERY_PARAM_DC_POWERFACTOR, null);
Double dcPowerFactor = dcPowerFactorStr == null ? null : Double.valueOf(dcPowerFactorStr);
boolean loadOperationalLimitGroups = Optional.ofNullable(infoTypeParameters.getOptionalParameters().get(QUERY_PARAM_LOAD_OPERATIONAL_LIMIT_GROUPS))
.map(Boolean::valueOf).orElse(false);
return switch (infoTypeParameters.getInfoType()) {
case TAB -> toTabInfos(identifiable, dcPowerFactor);
case TAB -> toTabInfos(identifiable, dcPowerFactor, loadOperationalLimitGroups);
case FORM -> toFormInfos(identifiable);
case MAP -> toMapInfos(identifiable, dcPowerFactor);
case LIST -> ElementInfosMapper.toListInfos(identifiable);
Expand Down Expand Up @@ -131,9 +136,9 @@ private static LineMapInfos toMapInfos(Identifiable<?> identifiable, Double dcPo
return builder.build();
}

private static LineTabInfos toTabInfos(Identifiable<?> identifiable, Double dcPowerFactor) {
private static LineTabInfos toTabInfos(Identifiable<?> identifiable, Double dcPowerFactor, boolean loadOperationalLimitGroups) {
final Line line = (Line) identifiable;
return toTabBuilder((LineTabInfosBuilder<LineTabInfos, ?>) LineTabInfos.builder(), line, dcPowerFactor)
return toTabBuilder((LineTabInfosBuilder<LineTabInfos, ?>) LineTabInfos.builder(), line, dcPowerFactor, loadOperationalLimitGroups)
.g1(line.getG1())
.b1(line.getB1())
.g2(line.getG2())
Expand Down
Loading