Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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 @@ -9,7 +9,7 @@
import lombok.Getter;
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.commons.ProcessType;
import org.gridsuite.monitor.worker.server.services.StepExecutionService;
import org.gridsuite.monitor.worker.server.services.internal.StepExecutionService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.worker.server.core.AbstractProcessStep;
import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext;
import org.gridsuite.monitor.worker.server.services.FilterService;
import org.gridsuite.monitor.worker.server.services.NetworkModificationRestService;
import org.gridsuite.monitor.worker.server.services.NetworkModificationService;
import org.gridsuite.monitor.worker.server.services.external.adapter.FilterService;
import org.gridsuite.monitor.worker.server.services.external.client.NetworkModificationRestClient;
import org.gridsuite.monitor.worker.server.services.external.adapter.NetworkModificationService;
import org.springframework.stereotype.Component;

import java.util.List;
Expand All @@ -28,15 +28,15 @@
public class ApplyModificationsStep<C extends ProcessConfig> extends AbstractProcessStep<C> {

private final NetworkModificationService networkModificationService;
private final NetworkModificationRestService networkModificationRestService;
private final NetworkModificationRestClient networkModificationRestClient;

private final FilterService filterService;

public ApplyModificationsStep(NetworkModificationService networkModificationService, NetworkModificationRestService networkModificationRestService,
public ApplyModificationsStep(NetworkModificationService networkModificationService, NetworkModificationRestClient networkModificationRestClient,
FilterService filterService) {
super(CommonStepType.APPLY_MODIFICATIONS);
this.networkModificationService = networkModificationService;
this.networkModificationRestService = networkModificationRestService;
this.networkModificationRestClient = networkModificationRestClient;
this.filterService = filterService;
}

Expand All @@ -50,7 +50,7 @@ public void execute(ProcessStepExecutionContext<C> context) {
}

private void applyModifications(List<UUID> modificationIds, Network network, ReportNode reportNode) {
List<ModificationInfos> modificationInfos = networkModificationRestService.getModifications(modificationIds);
List<ModificationInfos> modificationInfos = networkModificationRestClient.getModifications(modificationIds);
networkModificationService.applyModifications(network, modificationInfos, reportNode, filterService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.worker.server.core.AbstractProcessStep;
import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext;
import org.gridsuite.monitor.worker.server.services.NetworkConversionService;
import org.gridsuite.monitor.worker.server.services.external.adapter.NetworkConversionService;
import org.springframework.stereotype.Component;

import java.util.UUID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import org.gridsuite.monitor.worker.server.processes.commons.steps.ApplyModificationsStep;
import org.gridsuite.monitor.worker.server.processes.commons.steps.LoadNetworkStep;
import org.gridsuite.monitor.worker.server.processes.securityanalysis.steps.SecurityAnalysisRunComputationStep;
import org.gridsuite.monitor.worker.server.services.StepExecutionService;
import org.gridsuite.monitor.worker.server.services.internal.StepExecutionService;
import org.springframework.stereotype.Component;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.gridsuite.monitor.worker.server.core.AbstractProcessStep;
import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext;
import org.gridsuite.monitor.worker.server.processes.securityanalysis.SecurityAnalysisStepType;
import org.gridsuite.monitor.worker.server.services.SecurityAnalysisService;
import org.gridsuite.monitor.worker.server.services.external.client.SecurityAnalysisRestClient;
import org.springframework.stereotype.Component;

import java.util.List;
Expand All @@ -30,11 +30,11 @@
@Component
public class SecurityAnalysisRunComputationStep extends AbstractProcessStep<SecurityAnalysisConfig> {

private final SecurityAnalysisService securityAnalysisService;
private final SecurityAnalysisRestClient securityAnalysisRestClient;

public SecurityAnalysisRunComputationStep(SecurityAnalysisService securityAnalysisService) {
public SecurityAnalysisRunComputationStep(SecurityAnalysisRestClient securityAnalysisRestClient) {
super(SecurityAnalysisStepType.RUN_SA_COMPUTATION);
this.securityAnalysisService = securityAnalysisService;
this.securityAnalysisRestClient = securityAnalysisRestClient;
}

@Override
Expand All @@ -50,7 +50,7 @@ public void execute(ProcessStepExecutionContext<SecurityAnalysisConfig> context)
SecurityAnalysisReport saReport = SecurityAnalysis.run(context.getNetwork(), contingencyList, runParameters);

ResultInfos resultInfos = new ResultInfos(UUID.randomUUID(), ResultType.SECURITY_ANALYSIS);
securityAnalysisService.saveResult(resultInfos.resultUUID(), saReport.getResult());
securityAnalysisRestClient.saveResult(resultInfos.resultUUID(), saReport.getResult());
context.setResultInfos(resultInfos);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.adapter;

import com.powsybl.iidm.network.Network;
import org.gridsuite.filter.AbstractFilter;
import org.gridsuite.filter.utils.FilterServiceUtils;
import org.gridsuite.modification.IFilterService;
import org.gridsuite.modification.dto.FilterEquipments;
import org.gridsuite.modification.dto.IdentifiableAttributes;
import org.gridsuite.monitor.worker.server.services.external.client.FilterRestClient;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand All @@ -27,14 +29,14 @@
*/
@Service
public class FilterService implements IFilterService {
private final FilterRestService filterRestService;
private final FilterRestClient filterRestClient;

public FilterService(FilterRestService filterRestService) {
this.filterRestService = filterRestService;
public FilterService(FilterRestClient filterRestClient) {
this.filterRestClient = filterRestClient;
}

public List<AbstractFilter> getFilters(List<UUID> filtersUuids) {
return filterRestService.getFilters(filtersUuids);
return filterRestClient.getFilters(filtersUuids);
}

public Stream<org.gridsuite.filter.identifierlistfilter.FilterEquipments> exportFilters(List<UUID> filtersUuids, Network network) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 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.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.adapter;

import com.powsybl.cases.datasource.CaseDataSourceClient;
import com.powsybl.commons.PowsyblException;
Expand All @@ -13,12 +13,10 @@
import com.powsybl.iidm.network.Importer;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.NetworkFactory;
import org.gridsuite.monitor.worker.server.services.external.client.CaseRestClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.Properties;
import java.util.UUID;
Expand All @@ -30,17 +28,16 @@
public class NetworkConversionService {
private static final Logger LOGGER = LoggerFactory.getLogger(NetworkConversionService.class);

private final RestTemplate caseServerRest;
private final CaseRestClient caseRestClient;

public NetworkConversionService(@Value("${powsybl.services.case-server.base-uri:http://case-server/}") String caseServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.caseServerRest = restTemplateBuilder.rootUri(caseServerBaseUri).build();
public NetworkConversionService(CaseRestClient caseRestClient) {
this.caseRestClient = caseRestClient;
}

public Network createNetwork(UUID caseUuid, ReportNode reporter) {
LOGGER.info("Creating network");

CaseDataSourceClient dataSource = new CaseDataSourceClient(caseServerRest, caseUuid);
CaseDataSourceClient dataSource = caseRestClient.getCaseDataSource(caseUuid);

Importer importer = Importer.find(dataSource, LocalComputationManager.getDefault());
if (importer == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/

package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.adapter;

import com.powsybl.commons.PowsyblException;
import com.powsybl.commons.report.ReportNode;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* 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/.
*/
Comment on lines +1 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Missing SPDX license identifier.

Other files modified or added in this PR include SPDX-License-Identifier: MPL-2.0 in the license header (e.g., NetworkModificationRestClient.java line 6, FilterRestClient.java line 6). This new file omits it.

Proposed fix
  * 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/.
+ * SPDX-License-Identifier: MPL-2.0
  */
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
/**
* 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/.
*/
/**
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
🤖 Prompt for AI Agents
In
`@monitor-worker-server/src/main/java/org/gridsuite/monitor/worker/server/services/external/client/CaseRestClient.java`
around lines 1 - 6, The file CaseRestClient is missing the SPDX license
identifier in its header; update the file header in CaseRestClient.java to
include the SPDX-License-Identifier: MPL-2.0 comment (matching the other
new/modified files such as NetworkModificationRestClient and FilterRestClient)
so the top-of-file license block includes the SPDX line immediately after the
copyright/license text.

package org.gridsuite.monitor.worker.server.services.external.client;

import com.powsybl.cases.datasource.CaseDataSourceClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import java.util.UUID;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
*/
@Service
public class CaseRestClient {

private final RestTemplate caseServerRest;

public CaseRestClient(@Value("${powsybl.services.case-server.base-uri:http://case-server/}") String caseServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.caseServerRest = restTemplateBuilder.rootUri(caseServerBaseUri).build();
Comment on lines +25 to +27
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for all `@Value` annotations with service base-uri properties
rg -n '@Value.*services.*base-uri' --type java -A 1

Repository: gridsuite/monitor-core

Length of output: 3236


Use gridsuite.services.case-server.base-uri instead of powsybl.services.case-server.base-uri.

All other REST clients in the codebase use the gridsuite.services.*.base-uri property prefix (SecurityAnalysisRestClient, ReportRestClient, NetworkModificationRestClient, FilterRestClient). Align this property to the same convention for consistency.

🤖 Prompt for AI Agents
In
`@monitor-worker-server/src/main/java/org/gridsuite/monitor/worker/server/services/external/client/CaseRestClient.java`
around lines 25 - 27, The property key used in the CaseRestClient constructor is
inconsistent: replace the
'@Value("${powsybl.services.case-server.base-uri:http://case-server/}")' usage
with the gridsuite prefix to match other clients; update the CaseRestClient
constructor parameter annotation to
'@Value("${gridsuite.services.case-server.base-uri:http://case-server/}")'
(keeping the same default) so the RestTemplateBuilder.rootUri(...) receives the
correctly named property (refer to the CaseRestClient constructor and the
caseServerBaseUri parameter).

}

public CaseDataSourceClient getCaseDataSource(UUID caseUuid) {
return new CaseDataSourceClient(caseServerRest, caseUuid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.client;

import com.powsybl.commons.PowsyblException;
import org.gridsuite.filter.AbstractFilter;
Expand All @@ -24,7 +25,7 @@
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@Service
public class FilterRestService {
public class FilterRestClient {
private static final String FILTER_SERVER_API_VERSION = "v1";

private static final String DELIMITER = "/";
Expand All @@ -33,8 +34,8 @@ public class FilterRestService {

private final RestTemplate restTemplate;

public FilterRestService(@Value("${gridsuite.services.filter-server.base-uri:http://filter-server/}") String filterServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
public FilterRestClient(@Value("${gridsuite.services.filter-server.base-uri:http://filter-server/}") String filterServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.filterServerBaseUri = filterServerBaseUri;
this.restTemplate = restTemplateBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/

package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.client;

import org.apache.commons.collections4.CollectionUtils;
import org.gridsuite.modification.dto.ModificationInfos;
Expand All @@ -23,15 +24,15 @@
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@Service
public class NetworkModificationRestService {
public class NetworkModificationRestClient {
private static final String NETWORK_MODIFICATION_SERVER_API_VERSION = "v1";
private static final String DELIMITER = "/";

private final RestTemplate networkModificationServerRest;
private final String networkModificationServerBaseUri;

public NetworkModificationRestService(@Value("${gridsuite.services.network-modification-server.base-uri:http://network-modification-server/}") String networkModificationServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
public NetworkModificationRestClient(@Value("${gridsuite.services.network-modification-server.base-uri:http://network-modification-server/}") String networkModificationServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.networkModificationServerRest = restTemplateBuilder.build();
this.networkModificationServerBaseUri = networkModificationServerBaseUri;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.client;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand All @@ -28,7 +29,7 @@
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
*/
@Service
public class ReportService {
public class ReportRestClient {

static final String REPORT_API_VERSION = "v1";
private static final String DELIMITER = "/";
Expand All @@ -39,9 +40,9 @@ public class ReportService {

private final ObjectMapper objectMapper;

public ReportService(ObjectMapper objectMapper,
@Value("${gridsuite.services.report-server.base-uri:http://report-server/}") String reportServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
public ReportRestClient(ObjectMapper objectMapper,
@Value("${gridsuite.services.report-server.base-uri:http://report-server/}") String reportServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.reportServerBaseUri = reportServerBaseUri;
this.objectMapper = objectMapper;
this.restTemplate = restTemplateBuilder.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package org.gridsuite.monitor.worker.server.services;
/**
* 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/.
* SPDX-License-Identifier: MPL-2.0
*/
package org.gridsuite.monitor.worker.server.services.external.client;

import com.powsybl.security.SecurityAnalysisResult;
import lombok.Setter;
Expand All @@ -18,8 +25,8 @@
import java.util.UUID;

@Service
public class SecurityAnalysisService {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityAnalysisService.class);
public class SecurityAnalysisRestClient {
private static final Logger LOGGER = LoggerFactory.getLogger(SecurityAnalysisRestClient.class);
static final String SA_API_VERSION = "v1";
private static final String DELIMITER = "/";

Expand All @@ -32,7 +39,7 @@ private String getSecurityAnalysisServerBaseUri() {
return this.securityAnalysisServerBaseUri + DELIMITER + SA_API_VERSION + DELIMITER;
}

public SecurityAnalysisService(
public SecurityAnalysisRestClient(
RestTemplateBuilder restTemplateBuilder,
@Value("${gridsuite.services.security-analysis-server.base-uri:http://security-analysis-server/}") String securityAnalysisServerBaseUri) {
this.securityAnalysisServerBaseUri = securityAnalysisServerBaseUri;
Expand Down
Loading
Loading