From ab71ab49ff06db9bbeff405cbe9f14d5eed69ec4 Mon Sep 17 00:00:00 2001 From: BOUHOURS Antoine Date: Fri, 27 Sep 2024 11:23:20 +0200 Subject: [PATCH] Remove workaround for specific parameters --- .../server/service/LoadFlowService.java | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gridsuite/loadflow/server/service/LoadFlowService.java b/src/main/java/org/gridsuite/loadflow/server/service/LoadFlowService.java index f07625a5..47aab5b8 100644 --- a/src/main/java/org/gridsuite/loadflow/server/service/LoadFlowService.java +++ b/src/main/java/org/gridsuite/loadflow/server/service/LoadFlowService.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import com.powsybl.commons.config.PlatformConfig; import com.powsybl.commons.parameters.Parameter; import com.powsybl.commons.parameters.ParameterScope; import com.powsybl.iidm.network.TwoSides; @@ -79,39 +80,14 @@ public List getProviders() { } public static Map> getSpecificLoadFlowParameters(String providerName) { - Map> powsyblSpecificLFParameters = LoadFlowProvider.findAll().stream() + return LoadFlowProvider.findAll().stream() .filter(provider -> providerName == null || provider.getName().equals(providerName)) .map(provider -> { - List params = provider.getSpecificParameters().stream() + List params = provider.getSpecificParameters(PlatformConfig.defaultConfig()).stream() .filter(p -> p.getScope() == ParameterScope.FUNCTIONAL) .toList(); return Pair.of(provider.getName(), params); }).collect(Collectors.toMap(Pair::getLeft, Pair::getRight)); - - // FIXME: We need to override Powsybl default values in the loadflow-server as up to now we can't override those values through PlatformConfig for the specific parameters. - // To be removed when it's fixed. - changeDefaultValue(powsyblSpecificLFParameters, "OpenLoadFlow", "writeReferenceTerminals", false); - changeDefaultValue(powsyblSpecificLFParameters, "DynaFlow", "mergeLoads", false); - - return powsyblSpecificLFParameters; - } - - public static void changeDefaultValue(Map> specificParameters, String providerName, String parameterName, Object defaultValue) { - if (specificParameters.get(providerName) == null) { - return; - } - List providerParams = new ArrayList<>(specificParameters.get(providerName)); - providerParams.stream().filter(parameter -> parameterName.equals(parameter.getName())).findAny().ifPresent(parameterToOverride -> { - providerParams.remove(parameterToOverride); - providerParams.add(new Parameter(parameterToOverride.getName(), - parameterToOverride.getType(), - parameterToOverride.getDescription(), - defaultValue, - parameterToOverride.getPossibleValues(), - parameterToOverride.getScope() - )); - }); - specificParameters.put(providerName, providerParams); } @Override