Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7464d46
export computations parameters
ghazwarhili Aug 18, 2026
d2ab834
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Sep 15, 2026
d20e5fc
clean code
ghazwarhili Sep 15, 2026
2e77539
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Sep 16, 2026
3c0e3db
add export filtersUuids and contingenciesUuids
ghazwarhili Sep 18, 2026
2bab608
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Sep 18, 2026
fa4a4af
handle referenced filters uuids
ghazwarhili Sep 22, 2026
b17341d
sonar issues and rabbit remark
ghazwarhili Sep 22, 2026
2d24d80
fix default case
ghazwarhili Sep 22, 2026
66775ee
draft version to resolve the referenced filters from action and filt…
ghazwarhili Sep 23, 2026
15d3ce3
fix TU
ghazwarhili Sep 23, 2026
e0de2b3
code review remarks
ghazwarhili Sep 25, 2026
1be8ac0
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Sep 25, 2026
49f837c
update TU
ghazwarhili Sep 25, 2026
8ed67c1
rename to ExportedElementInfos
ghazwarhili Sep 25, 2026
4214873
add export filteruuid short circuit ans sensi node
ghazwarhili Sep 29, 2026
b5e89f8
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Sep 29, 2026
79a480b
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Oct 1, 2026
6a02f2e
code review remarks
ghazwarhili Oct 1, 2026
cb101c8
clean code
ghazwarhili Oct 1, 2026
5afbbae
add service name to ComputationParametersService
ghazwarhili Oct 5, 2026
6938f0d
Merge branch 'main' into razwa/export-computations-parameters
ghazwarhili Oct 5, 2026
4ee4027
code review remarks
ghazwarhili Oct 5, 2026
84860be
fix service name
ghazwarhili Oct 6, 2026
fdc01e9
fix sonar issue
ghazwarhili Oct 6, 2026
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
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.databind.JsonNode;

import java.util.UUID;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
public record ExportedElementInfos(UUID uuid, String name, JsonNode content) { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
public interface ExportedParameters {

default Set<UUID> getFilterUuids() {
return Set.of();
}

default Set<UUID> getContingencyListUuids() {
return Set.of();
}

static <T> Stream<T> nullSafe(List<T> list) {
return list == null ? Stream.empty() : list.stream();
}

static Set<UUID> toUuidSet(Stream<UUID> uuids) {
return uuids.filter(Objects::nonNull).collect(Collectors.toSet());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;
import java.util.Set;
import java.util.UUID;

import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.nullSafe;
import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.toUuidSet;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record PccMinExportedParameters(List<UUID> filters) implements ExportedParameters {

@Override
public Set<UUID> getFilterUuids() {
return toUuidSet(nullSafe(filters));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;
import java.util.Set;
import java.util.UUID;

import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.nullSafe;
import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.toUuidSet;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record SecurityAnalysisExportedParameters(List<ContingencyListsInfos> contingencyListsInfos) implements ExportedParameters {

@JsonIgnoreProperties(ignoreUnknown = true)
public record ContingencyListsInfos(List<UUID> contingencyLists) { }

@Override
public Set<UUID> getContingencyListUuids() {
return toUuidSet(nullSafe(contingencyListsInfos).flatMap(infos -> nullSafe(infos.contingencyLists())));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Stream;

import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.nullSafe;
import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.toUuidSet;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record SensitivityAnalysisExportedParameters(
List<SensitivityFactor> sensitivityInjectionsSet,
List<SensitivityFactor> sensitivityInjection,
List<SensitivityFactor> sensitivityHVDC,
List<SensitivityFactor> sensitivityPST,
List<SensitivityNodes> sensitivityNodes
) implements ExportedParameters {
@JsonIgnoreProperties(ignoreUnknown = true)
public record SensitivityFactor(
List<UUID> monitoredBranches,
List<UUID> injections,
List<UUID> hvdcs,
List<UUID> psts,
List<UUID> contingencies
) {
Stream<UUID> filterUuids() {
return Stream.of(monitoredBranches, injections, hvdcs, psts)
.flatMap(ExportedParameters::nullSafe);
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
public record SensitivityNodes(
List<UUID> monitoredVoltageLevels,
List<UUID> equipmentsInVoltageRegulation,
List<UUID> contingencies
) {
Stream<UUID> filterUuids() {
return Stream.of(monitoredVoltageLevels, equipmentsInVoltageRegulation)
.flatMap(ExportedParameters::nullSafe);
}
}

private Stream<SensitivityFactor> allFactors() {
return Stream.of(sensitivityInjectionsSet, sensitivityInjection, sensitivityHVDC, sensitivityPST)
.flatMap(ExportedParameters::nullSafe);
}

@Override
public Set<UUID> getFilterUuids() {
return toUuidSet(Stream.concat(
allFactors().flatMap(SensitivityFactor::filterUuids),
nullSafe(sensitivityNodes).flatMap(SensitivityNodes::filterUuids)));
}

@Override
public Set<UUID> getContingencyListUuids() {
return toUuidSet(Stream.concat(
allFactors().flatMap(factor -> nullSafe(factor.contingencies())),
nullSafe(sensitivityNodes).flatMap(nodes -> nullSafe(nodes.contingencies()))));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;

import java.io.UncheckedIOException;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Stream;

import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.nullSafe;
import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.toUuidSet;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record ShortCircuitExportedParameters(Map<String, Map<String, String>> specificParametersPerProvider) implements ExportedParameters {

public static final String POWER_ELECTRONICS_CLUSTERS = "powerElectronicsClusters";
public static final String NODE_CLUSTER_FILTER_IDS = "nodeClusterFilterIds";

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@JsonIgnoreProperties(ignoreUnknown = true)
public record FilterElements(UUID filterId) { }

@JsonIgnoreProperties(ignoreUnknown = true)
public record PowerElectronicsCluster(List<FilterElements> filters) { }

@Override
public Set<UUID> getFilterUuids() {
Stream<Map<String, String>> specificParameters = specificParametersPerProvider == null ? Stream.empty()
: specificParametersPerProvider.values().stream().filter(Objects::nonNull);
return toUuidSet(specificParameters.flatMap(parameters -> Stream.concat(
parseList(parameters.get(POWER_ELECTRONICS_CLUSTERS), new TypeReference<List<PowerElectronicsCluster>>() { })
.flatMap(cluster -> nullSafe(cluster.filters())),
parseList(parameters.get(NODE_CLUSTER_FILTER_IDS), new TypeReference<List<FilterElements>>() { })))
.map(FilterElements::filterId));
}

private static <T> Stream<T> parseList(String json, TypeReference<List<T>> type) {
if (StringUtils.isBlank(json)) {
return Stream.empty();
}
try {
return nullSafe(OBJECT_MAPPER.readValue(json, type)).filter(Objects::nonNull);
} catch (JsonProcessingException e) {
throw new UncheckedIOException(e);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package org.gridsuite.study.server.dto.studyexport.parameters;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Stream;

import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.nullSafe;
import static org.gridsuite.study.server.dto.studyexport.parameters.ExportedParameters.toUuidSet;

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public record VoltageInitExportedParameters(
List<VoltageLimit> voltageLimitsModification,
List<VoltageLimit> voltageLimitsDefault,
List<FilterEquipments> variableQGenerators,
List<FilterEquipments> variableTwoWindingsTransformers,
List<FilterEquipments> variableShuntCompensators
) implements ExportedParameters {

@JsonIgnoreProperties(ignoreUnknown = true)
public record VoltageLimit(List<FilterEquipments> filters) { }

@JsonIgnoreProperties(ignoreUnknown = true)
public record FilterEquipments(UUID filterId) { }

@Override
public Set<UUID> getFilterUuids() {
Stream<FilterEquipments> limitFilters = Stream.concat(nullSafe(voltageLimitsModification), nullSafe(voltageLimitsDefault))
.flatMap(voltageLimit -> nullSafe(voltageLimit.filters()));
Stream<FilterEquipments> variableFilters = Stream.of(variableQGenerators, variableTwoWindingsTransformers, variableShuntCompensators)
.flatMap(ExportedParameters::nullSafe);
return toUuidSet(Stream.concat(limitFilters, variableFilters).map(FilterEquipments::filterId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
* @author Kevin Le Saulnier <kevin.lesaulnier at rte-france.com>
*/

import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.gridsuite.study.server.RemoteServicesProperties;
import org.gridsuite.study.server.dto.ContingencyCount;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand All @@ -32,9 +35,11 @@ public class ActionsService {

private static final String NETWORK_UUID = "networkUuid";
private static final String CONTINGENCY_LIST_IDS = "ids";
private static final String EMPTY_JSON_ARRAY = "[]";

public static final ContingencyCount EMPTY_CONTINGENCY_COUNT = new ContingencyCount(Map.of());

@Setter
private String actionsServerBaseUri;

public ActionsService(RemoteServicesProperties remoteServicesProperties, RestTemplate restTemplate) {
Expand All @@ -58,7 +63,17 @@ public ContingencyCount getContingencyCount(UUID networkUuid, String variantId,
).getBody();
}

public void setActionsServerBaseUri(String actionsServerBaseUri) {
this.actionsServerBaseUri = actionsServerBaseUri;
public List<UUID> getReferencedFilterUuids(Collection<UUID> contingencyListUuids) {
String path = UriComponentsBuilder.fromPath(DELIMITER + ACTIONS_API_VERSION + "/contingency-lists/filter-uuids")
.queryParam(CONTINGENCY_LIST_IDS, contingencyListUuids)
.toUriString();
return restTemplate.exchange(actionsServerBaseUri + path, HttpMethod.GET, null, new ParameterizedTypeReference<List<UUID>>() { }).getBody();
}

public String getContingencyLists(Collection<UUID> ids) {
if (ids.isEmpty()) {
return EMPTY_JSON_ARRAY;
}
return restTemplate.postForObject(actionsServerBaseUri + DELIMITER + ACTIONS_API_VERSION + "/contingency-lists", ids, String.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
Expand All @@ -43,6 +44,7 @@ public class FilterService {
public static final String FILTER_END_POINT_EVALUATE_IDS = "/filters/evaluate/identifiables";
public static final String FILTER_END_POINT_EXPORT = "/filters/{id}/export";
public static final String FILTERS_END_POINT_EXPORT = "/filters/export";
private static final String EMPTY_JSON_ARRAY = "[]";

private final RestTemplate restTemplate;

Expand Down Expand Up @@ -158,4 +160,21 @@ public String evaluateFilters(UUID networkUuid, String filters) {

return restTemplate.postForObject(uriComponent.toUriString(), request, String.class);
}

public List<UUID> getReferencedFilterUuids(Collection<UUID> filterUuids) {
String path = UriComponentsBuilder.fromPath(DELIMITER + FILTER_API_VERSION + "/filters/referenced-filter-uuids")
.queryParam(IDS, filterUuids)
.toUriString();
return restTemplate.exchange(getBaseUri() + path, HttpMethod.GET, null, new ParameterizedTypeReference<List<UUID>>() { }).getBody();
}

public String getFilters(Collection<UUID> filterUuids) {
if (filterUuids.isEmpty()) {
return EMPTY_JSON_ARRAY;
}
String path = UriComponentsBuilder.fromPath(DELIMITER + FILTER_API_VERSION + "/filters/metadata")
.queryParam(IDS, filterUuids)
.toUriString();
return restTemplate.getForObject(getBaseUri() + path, String.class);
}
}
Loading
Loading