Skip to content
Open
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 @@ -4,14 +4,15 @@
* 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.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 +28,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 @@ -5,7 +5,7 @@
* 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.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/.
*/
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();
}

public CaseDataSourceClient getCaseDataSource(UUID caseUuid) {
return new CaseDataSourceClient(caseServerRest, caseUuid);
}
}
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.client;

import com.powsybl.commons.PowsyblException;
import org.gridsuite.filter.AbstractFilter;
Expand All @@ -24,7 +24,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 +33,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 @@ -5,7 +5,7 @@
* 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.client;

import org.apache.commons.collections4.CollectionUtils;
import org.gridsuite.modification.dto.ModificationInfos;
Expand All @@ -23,15 +23,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,4 @@
package org.gridsuite.monitor.worker.server.services;
package org.gridsuite.monitor.worker.server.services.external.client;

import com.powsybl.security.SecurityAnalysisResult;
import lombok.Setter;
Expand All @@ -18,8 +18,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 +32,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
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.internal;

import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.commons.ProcessExecutionStatusUpdate;
Expand All @@ -16,6 +16,7 @@
import org.gridsuite.monitor.worker.server.core.Process;
import org.gridsuite.monitor.worker.server.core.ProcessExecutionContext;
import org.gridsuite.monitor.worker.server.core.ProcessStep;
import org.gridsuite.monitor.worker.server.services.messaging.NotificationService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
* 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.internal;

import lombok.RequiredArgsConstructor;
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.commons.ProcessExecutionStep;
import org.gridsuite.monitor.commons.StepStatus;
import org.gridsuite.monitor.worker.server.core.ProcessStep;
import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext;
import org.gridsuite.monitor.worker.server.services.external.client.ReportRestClient;
import org.gridsuite.monitor.worker.server.services.messaging.NotificationService;
import org.springframework.stereotype.Service;

import java.time.Instant;
Expand All @@ -24,7 +26,7 @@
public class StepExecutionService<C extends ProcessConfig> {

private final NotificationService notificationService;
private final ReportService reportService;
private final ReportRestClient reportRestClient;

public void skipStep(ProcessStepExecutionContext<?> context, ProcessStep<?> step) {
ProcessExecutionStep executionStep = new ProcessExecutionStep(
Expand Down Expand Up @@ -57,7 +59,7 @@ public void executeStep(ProcessStepExecutionContext<C> context, ProcessStep<C> s

try {
step.execute(context);
reportService.sendReport(context.getReportInfos());
reportRestClient.sendReport(context.getReportInfos());
updateStepStatus(context, StepStatus.COMPLETED, step);
} catch (Exception e) {
updateStepStatus(context, StepStatus.FAILED, step);
Expand Down
Loading