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 @@ -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.commons;
package org.gridsuite.monitor.commons.api.types.messaging;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
* 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.commons;
package org.gridsuite.monitor.commons.api.types.messaging;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessType;
import org.gridsuite.monitor.commons.api.types.processconfig.ProcessConfig;
import org.gridsuite.monitor.commons.api.types.processconfig.SecurityAnalysisConfig;

import java.util.UUID;

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.commons;
package org.gridsuite.monitor.commons.api.types.processconfig;

import java.util.List;
import java.util.UUID;
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.commons;
package org.gridsuite.monitor.commons.api.types.processconfig;

import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
* 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.commons;
package org.gridsuite.monitor.commons.api.types.processconfig;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessType;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* 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.commons;
package org.gridsuite.monitor.commons.api.types.processconfig;

import org.gridsuite.monitor.commons.api.types.processexecution.ProcessType;

import java.util.List;
import java.util.UUID;
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.commons;
package org.gridsuite.monitor.commons.api.types.processexecution;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is also for messaging?

Copy link
Author

Choose a reason for hiding this comment

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

When a type is placed in common or core, the objective is to make it directly shareable across different components. However, when organizing types into domain-specific subpackages, we should classify them based on the domain they originate from and logically belong to.


import lombok.AllArgsConstructor;
import lombok.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
* 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.commons;
package org.gridsuite.monitor.commons.api.types.processexecution;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.gridsuite.monitor.commons.api.types.result.ResultType;

import java.time.Instant;
import java.util.UUID;
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.commons;
package org.gridsuite.monitor.commons.api.types.processexecution;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
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.commons;
package org.gridsuite.monitor.commons.api.types.processexecution;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
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.commons;
package org.gridsuite.monitor.commons.api.types.processexecution;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
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.commons;
package org.gridsuite.monitor.commons.api.types.result;

import java.util.UUID;

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.commons;
package org.gridsuite.monitor.commons.api.types.result;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* 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.server.services;
package org.gridsuite.monitor.server.clients;

import org.gridsuite.monitor.server.dto.ReportPage;
import org.gridsuite.monitor.server.dto.report.ReportPage;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.core.ParameterizedTypeReference;
Expand All @@ -24,7 +24,7 @@
* @author Franck Lecuyer <franck.lecuyer at rte-france.com>
*/
@Service
public class ReportService {
public class ReportRestClient {
private static final String REPORT_API_VERSION = "v1";

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

private final RestTemplate restTemplate;

public ReportService(@Value("${gridsuite.services.report-server.base-uri:http://report-server/}") String reportServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
public ReportRestClient(@Value("${gridsuite.services.report-server.base-uri:http://report-server/}") String reportServerBaseUri,
RestTemplateBuilder restTemplateBuilder) {
this.reportServerBaseUri = reportServerBaseUri;
this.restTemplate = restTemplateBuilder.build();
}
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.server.services;
package org.gridsuite.monitor.server.clients;

import lombok.Setter;
import org.slf4j.Logger;
Expand All @@ -23,8 +23,8 @@
* @author Kevin Le Saulnier <kevin.le-saulnier at rte-france.com>
*/
@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 @@ -37,7 +37,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.server.services;
package org.gridsuite.monitor.server.clients;

import lombok.Setter;
import org.slf4j.Logger;
Expand All @@ -23,8 +23,8 @@
* @author Achour BERRAHMA <achour.berrahma at rte-france.com>
*/
@Service
public class StateEstimationService {
private static final Logger LOGGER = LoggerFactory.getLogger(StateEstimationService.class);
public class StateEstimationRestClient {
private static final Logger LOGGER = LoggerFactory.getLogger(StateEstimationRestClient.class);
static final String SE_API_VERSION = "v1";
private static final String DELIMITER = "/";

Expand All @@ -37,7 +37,7 @@ private String getStateEstimationServerBaseUri() {
return this.stateEstimationServerBaseUri + DELIMITER + SE_API_VERSION + DELIMITER;
}

public StateEstimationService(
public StateEstimationRestClient(
RestTemplateBuilder restTemplateBuilder,
@Value("${gridsuite.services.state-estimation-server.base-uri:http://state-estimation-server/}") String stateEstimationServerBaseUri) {
this.stateEstimationServerBaseUri = stateEstimationServerBaseUri;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.gridsuite.monitor.commons.ProcessExecutionStep;
import org.gridsuite.monitor.commons.ProcessType;
import org.gridsuite.monitor.commons.SecurityAnalysisConfig;
import org.gridsuite.monitor.server.dto.ProcessExecution;
import org.gridsuite.monitor.server.dto.ReportPage;
import org.gridsuite.monitor.server.services.MonitorService;
import org.gridsuite.monitor.commons.api.types.processconfig.SecurityAnalysisConfig;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessExecutionStep;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessType;
import org.gridsuite.monitor.server.dto.processexecution.ProcessExecution;
import org.gridsuite.monitor.server.dto.report.ReportPage;
import org.gridsuite.monitor.server.services.processexecution.ProcessExecutionService;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
Expand All @@ -33,12 +33,12 @@
@Tag(name = "Monitor server")
public class MonitorController {

private final MonitorService monitorService;
private final ProcessExecutionService processExecutionService;

public static final String HEADER_USER_ID = "userId";

public MonitorController(MonitorService monitorService) {
this.monitorService = monitorService;
public MonitorController(ProcessExecutionService processExecutionService) {
this.processExecutionService = processExecutionService;
}

@PostMapping("/execute/security-analysis")
Expand All @@ -49,31 +49,31 @@ public ResponseEntity<UUID> executeSecurityAnalysis(
@RequestParam(required = false, defaultValue = "false") boolean isDebug,
@RequestBody SecurityAnalysisConfig securityAnalysisConfig,
@RequestHeader(HEADER_USER_ID) String userId) {
UUID executionId = monitorService.executeProcess(caseUuid, userId, securityAnalysisConfig, isDebug);
UUID executionId = processExecutionService.executeProcess(caseUuid, userId, securityAnalysisConfig, isDebug);
return ResponseEntity.ok(executionId);
}

@GetMapping("/executions/{executionId}/reports")
@Operation(summary = "Get reports for an execution")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The execution reports")})
public ResponseEntity<List<ReportPage>> getExecutionReports(@Parameter(description = "Execution UUID") @PathVariable UUID executionId) {
List<ReportPage> reports = monitorService.getReports(executionId);
List<ReportPage> reports = processExecutionService.getReports(executionId);
return ResponseEntity.ok(reports);
}

@GetMapping("/executions/{executionId}/results")
@Operation(summary = "Get results for an execution")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The execution results")})
public ResponseEntity<List<String>> getExecutionResults(@Parameter(description = "Execution UUID") @PathVariable UUID executionId) {
List<String> results = monitorService.getResults(executionId);
List<String> results = processExecutionService.getResults(executionId);
return ResponseEntity.ok(results);
}

@GetMapping("/executions")
@Operation(summary = "Get launched processes")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The launched processes")})
public ResponseEntity<List<ProcessExecution>> getLaunchedProcesses(@Parameter(description = "Process type") @RequestParam(name = "processType") ProcessType processType) {
return ResponseEntity.ok(monitorService.getLaunchedProcesses(processType));
return ResponseEntity.ok(processExecutionService.getLaunchedProcesses(processType));
}

@GetMapping("/executions/{executionId}/step-infos")
Expand All @@ -82,7 +82,7 @@ public ResponseEntity<List<ProcessExecution>> getLaunchedProcesses(@Parameter(de
@ApiResponse(responseCode = "200", description = "The execution steps statuses"),
@ApiResponse(responseCode = "404", description = "execution id was not found")})
public ResponseEntity<List<ProcessExecutionStep>> getStepsInfos(@Parameter(description = "Execution UUID") @PathVariable UUID executionId) {
return monitorService.getStepsInfos(executionId).map(list -> ResponseEntity.ok().body(list))
return processExecutionService.getStepsInfos(executionId).map(list -> ResponseEntity.ok().body(list))
.orElseGet(() -> ResponseEntity.notFound().build());
}

Expand All @@ -92,7 +92,7 @@ public ResponseEntity<List<ProcessExecutionStep>> getStepsInfos(@Parameter(descr
@ApiResponse(responseCode = "200", description = "Debug file downloaded"),
@ApiResponse(responseCode = "404", description = "execution id was not found")})
public ResponseEntity<byte[]> getDebugInfos(@Parameter(description = "Execution UUID") @PathVariable UUID executionId) {
return monitorService.getDebugInfos(executionId)
return processExecutionService.getDebugInfos(executionId)
.map(bytes -> ResponseEntity.ok()
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"archive.zip\"")
Expand All @@ -107,7 +107,7 @@ public ResponseEntity<byte[]> getDebugInfos(@Parameter(description = "Execution
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Execution was deleted"),
@ApiResponse(responseCode = "404", description = "Execution was not found")})
public ResponseEntity<Void> deleteExecution(@PathVariable UUID executionId) {
return monitorService.deleteExecution(executionId) ?
return processExecutionService.deleteExecution(executionId) ?
ResponseEntity.ok().build() :
ResponseEntity.notFound().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.gridsuite.monitor.commons.PersistedProcessConfig;
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.commons.ProcessType;
import org.gridsuite.monitor.server.services.ProcessConfigService;
import org.gridsuite.monitor.commons.api.types.processconfig.PersistedProcessConfig;
import org.gridsuite.monitor.commons.api.types.processconfig.ProcessConfig;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessType;
import org.gridsuite.monitor.server.services.processconfig.ProcessConfigService;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* 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.server.dto;
package org.gridsuite.monitor.server.dto.processexecution;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
import org.gridsuite.monitor.commons.ProcessStatus;
import org.gridsuite.monitor.commons.api.types.processexecution.ProcessStatus;

import java.time.Instant;
import java.util.UUID;
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.server.dto;
package org.gridsuite.monitor.server.dto.report;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Builder;
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.server.dto;
package org.gridsuite.monitor.server.dto.report;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;
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.server.dto;
package org.gridsuite.monitor.server.dto.report;

import org.springframework.data.domain.Page;

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.server.dto;
package org.gridsuite.monitor.server.dto.report;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
Expand Down
Loading