Skip to content

Commit 520bd8e

Browse files
author
Slimane AMAR
committed
Merge branch 'main' of https://github.com/powsybl/powsybl-study-server into use_sql_recursive_for_node_tree_invalidation
2 parents 7547737 + 5b44284 commit 520bd8e

File tree

11 files changed

+309
-129
lines changed

11 files changed

+309
-129
lines changed

src/main/java/org/gridsuite/study/server/StudyConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ public enum Severity {
9898
UNKNOWN,
9999
TRACE,
100100
DEBUG,
101+
DETAIL,
101102
INFO,
102103
WARN,
103104
ERROR,

src/main/java/org/gridsuite/study/server/controller/StudyController.java

Lines changed: 25 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import jakarta.servlet.http.HttpServletResponse;
1818
import org.apache.commons.lang3.StringUtils;
1919
import org.gridsuite.study.server.StudyApi;
20+
import org.gridsuite.study.server.StudyConstants.ModificationsActionType;
21+
import org.gridsuite.study.server.StudyConstants.SldDisplayMode;
2022
import org.gridsuite.study.server.StudyException;
2123
import org.gridsuite.study.server.StudyException.Type;
2224
import org.gridsuite.study.server.dto.*;
@@ -180,9 +182,8 @@ public ResponseEntity<CreatedStudyBasicInfos> getStudy(@PathVariable("studyUuid"
180182
@DeleteMapping(value = "/studies/{studyUuid}")
181183
@Operation(summary = "delete the study")
182184
@ApiResponse(responseCode = "200", description = "Study deleted")
183-
public ResponseEntity<Void> deleteStudy(@PathVariable("studyUuid") UUID studyUuid,
184-
@RequestHeader(HEADER_USER_ID) String userId) {
185-
studyService.deleteStudyIfNotCreationInProgress(studyUuid, userId);
185+
public ResponseEntity<Void> deleteStudy(@PathVariable("studyUuid") UUID studyUuid) {
186+
studyService.deleteStudyIfNotCreationInProgress(studyUuid);
186187
return ResponseEntity.ok().build();
187188
}
188189

@@ -1208,33 +1209,33 @@ public ResponseEntity<List<Report>> getParentNodesReport(@Parameter(description
12081209
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getParentNodesReport(nodeUuid, rootNetworkUuid, nodeOnlyReport, reportType, severityLevels));
12091210
}
12101211

1211-
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/{reportId}/logs", produces = MediaType.APPLICATION_JSON_VALUE)
1212-
@Operation(summary = "Get node report logs")
1213-
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The node report logs"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
1214-
public ResponseEntity<ReportPage> getNodeReportLogs(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
1215-
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
1216-
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1217-
@Parameter(description = "reportId") @PathVariable("reportId") String reportId,
1218-
@Parameter(description = "The message filter") @RequestParam(name = "message", required = false) String messageFilter,
1219-
@Parameter(description = "Severity levels filter") @RequestParam(name = "severityLevels", required = false) Set<String> severityLevels,
1220-
@Parameter(description = "Whether we want paged logs") @RequestParam(name = "paged", required = false, defaultValue = "false") boolean paged,
1221-
Pageable pageable) {
1212+
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/logs", produces = MediaType.APPLICATION_JSON_VALUE)
1213+
@Operation(summary = "Get the report logs of the given node and all its parents")
1214+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report logs of the node and all its parent"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
1215+
public ResponseEntity<ReportPage> getReportLogs(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
1216+
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
1217+
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1218+
@Parameter(description = "report id") @RequestParam(name = "reportId", required = false) UUID reportId,
1219+
@Parameter(description = "The message filter") @RequestParam(name = "message", required = false) String messageFilter,
1220+
@Parameter(description = "Severity levels filter") @RequestParam(name = "severityLevels", required = false) Set<String> severityLevels,
1221+
@Parameter(description = "If we wanted the paged version of the results or not") @RequestParam(name = "paged", required = false, defaultValue = "false") boolean paged,
1222+
Pageable pageable) {
12221223
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
12231224
rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid);
1224-
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getReportLogs(reportId, messageFilter, severityLevels, paged, pageable));
1225+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getReportLogs(nodeUuid, rootNetworkUuid, reportId, messageFilter, severityLevels, paged, pageable));
12251226
}
12261227

1227-
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/{reportId}/logs/search", produces = MediaType.APPLICATION_JSON_VALUE)
1228-
@Operation(summary = "Get search term matches in node report logs")
1228+
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/logs/search", produces = MediaType.APPLICATION_JSON_VALUE)
1229+
@Operation(summary = "Get search term matches in parent nodes filtered logs")
12291230
@ApiResponses(value = {
1230-
@ApiResponse(responseCode = "200", description = "The search term matches in the node report logs"),
1231+
@ApiResponse(responseCode = "200", description = "The search term matches in the parent nodes filtered logs"),
12311232
@ApiResponse(responseCode = "404", description = "The study/node is not found")
12321233
})
1233-
public ResponseEntity<String> getNodeReportLogsSearchTermMatches(
1234+
public ResponseEntity<String> getSearchTermMatchesInFilteredLogs(
12341235
@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
12351236
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
12361237
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1237-
@Parameter(description = "reportId") @PathVariable("reportId") UUID reportId,
1238+
@Parameter(description = "report id") @RequestParam(name = "reportId", required = false) UUID reportId,
12381239
@Parameter(description = "The message filter") @RequestParam(name = "message", required = false) String messageFilter,
12391240
@Parameter(description = "Severity levels filter") @RequestParam(name = "severityLevels", required = false) Set<String> severityLevels,
12401241
@Parameter(description = "The search term") @RequestParam(name = "searchTerm") String searchTerm,
@@ -1243,43 +1244,19 @@ public ResponseEntity<String> getNodeReportLogsSearchTermMatches(
12431244
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
12441245
rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid);
12451246
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(
1246-
studyService.getSearchTermMatchesInFilteredLogs(reportId, severityLevels, messageFilter, searchTerm, pageSize));
1247-
}
1248-
1249-
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/{reportId}/aggregated-severities", produces = MediaType.APPLICATION_JSON_VALUE)
1250-
@Operation(summary = "Get node report severities")
1251-
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The node report severities"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
1252-
public ResponseEntity<Set<String>> getNodeReportAggregatedSeverities(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
1253-
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
1254-
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1255-
@Parameter(description = "reportId") @PathVariable("reportId") UUID reportId) {
1256-
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
1257-
rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid);
1258-
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNodeReportAggregatedSeverities(reportId));
1247+
studyService.getSearchTermMatchesInFilteredLogs(nodeUuid, rootNetworkUuid, reportId, severityLevels, messageFilter, searchTerm, pageSize));
12591248
}
12601249

12611250
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/aggregated-severities", produces = MediaType.APPLICATION_JSON_VALUE)
12621251
@Operation(summary = "Get the report severities of the given node and all its parents")
12631252
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report severities of the node and all its parent"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
12641253
public ResponseEntity<Set<String>> getParentNodesAggregatedReportSeverities(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
12651254
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
1266-
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid) {
1267-
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
1268-
rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid);
1269-
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getParentNodesAggregatedReportSeverities(nodeUuid, rootNetworkUuid));
1270-
}
1271-
1272-
@GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/report/logs", produces = MediaType.APPLICATION_JSON_VALUE)
1273-
@Operation(summary = "Get the report logs of the given node and all its parents")
1274-
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report logs of the node and all its parent"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
1275-
public ResponseEntity<List<ReportLog>> getParentNodesReportLogs(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
1276-
@Parameter(description = "root network id") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
1277-
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1278-
@Parameter(description = "The message filter") @RequestParam(name = "message", required = false) String messageFilter,
1279-
@Parameter(description = "Severity levels filter") @RequestParam(name = "severityLevels", required = false) Set<String> severityLevels) {
1255+
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
1256+
@Parameter(description = "reportId") @RequestParam(name = "reportId", required = false) UUID reportId) {
12801257
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
12811258
rootNetworkService.assertIsRootNetworkInStudy(studyUuid, rootNetworkUuid);
1282-
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getParentNodesReportLogs(nodeUuid, rootNetworkUuid, messageFilter, severityLevels));
1259+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getAggregatedReportSeverities(nodeUuid, rootNetworkUuid, reportId));
12831260
}
12841261

12851262
@GetMapping(value = "/svg-component-libraries")

src/main/java/org/gridsuite/study/server/controller/SupervisionController.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import org.apache.http.HttpHost;
1515
import org.elasticsearch.client.RestClient;
1616
import org.gridsuite.study.server.StudyApi;
17+
import org.gridsuite.study.server.dto.supervision.SupervisionStudyInfos;
18+
import org.gridsuite.study.server.service.RootNetworkService;
1719
import org.gridsuite.study.server.service.StudyService;
1820
import org.gridsuite.study.server.service.SupervisionService;
1921

@@ -37,18 +39,42 @@ public class SupervisionController {
3739
private final SupervisionService supervisionService;
3840

3941
private final StudyService studyService;
42+
private final RootNetworkService rootNetworkService;
4043

4144
private final EquipmentInfosService equipmentInfosService;
4245

4346
private final RestClient restClient;
4447

45-
public SupervisionController(SupervisionService supervisionService, StudyService studyService, EquipmentInfosService equipmentInfosService, RestClient restClient) {
48+
public SupervisionController(SupervisionService supervisionService, StudyService studyService, RootNetworkService rootNetworkService, EquipmentInfosService equipmentInfosService, RestClient restClient) {
4649
this.supervisionService = supervisionService;
4750
this.studyService = studyService;
51+
this.rootNetworkService = rootNetworkService;
4852
this.equipmentInfosService = equipmentInfosService;
4953
this.restClient = restClient;
5054
}
5155

56+
@GetMapping(value = "/root-networks")
57+
@Operation(summary = "Get all the root networks uuids")
58+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "List of all the root networks uuids")})
59+
public ResponseEntity<List<UUID>> getAllRootNetworks() {
60+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(supervisionService.getAllRootNetworksUuids());
61+
}
62+
63+
@DeleteMapping(value = "/root-networks/{rootNetworkUuid}")
64+
@Operation(summary = "Delete a root network")
65+
@ApiResponse(responseCode = "200", description = "Root network deleted")
66+
public ResponseEntity<Void> deleteRootNetwork(@PathVariable("rootNetworkUuid") UUID rootNetworkUuid) {
67+
rootNetworkService.deleteRootNetwork(rootNetworkUuid);
68+
return ResponseEntity.ok().build();
69+
}
70+
71+
@GetMapping(value = "/studies")
72+
@Operation(summary = "Get supervision information for all studies")
73+
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "List of supervision information for all studies")})
74+
public ResponseEntity<List<SupervisionStudyInfos>> getAllStudiesBasicData() {
75+
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(supervisionService.getSupervisionStudiesInfos());
76+
}
77+
5278
@DeleteMapping(value = "/computation/results")
5379
@Operation(summary = "delete all results of a given computation")
5480
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all computation results have been deleted")})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
package org.gridsuite.study.server.dto.supervision;
8+
9+
import io.swagger.v3.oas.annotations.media.Schema;
10+
import lombok.EqualsAndHashCode;
11+
import lombok.Getter;
12+
import lombok.NoArgsConstructor;
13+
import lombok.ToString;
14+
import lombok.experimental.SuperBuilder;
15+
import org.gridsuite.study.server.dto.RootNetworkInfos;
16+
import org.gridsuite.study.server.dto.StudyInfos;
17+
18+
import java.util.List;
19+
import java.util.UUID;
20+
21+
/**
22+
* More detailed version of {@code StudyInfos} used for supervision and admin tools operations.
23+
*
24+
* @author Mathieu Deharbe <[email protected]>
25+
*/
26+
@SuperBuilder
27+
@NoArgsConstructor
28+
@Getter
29+
@ToString(callSuper = true)
30+
@Schema(description = "Supervision Study attributes")
31+
@EqualsAndHashCode(callSuper = true)
32+
public class SupervisionStudyInfos extends StudyInfos {
33+
private List<RootNetworkInfos> rootNetworkInfos;
34+
private List<UUID> caseUuids;
35+
}

src/main/java/org/gridsuite/study/server/service/ConsumerService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ public Consumer<Message<String>> consumeCaseImportSucceeded() {
265265
} finally {
266266
// if studyEntity is already existing, we don't delete anything in the end of the process
267267
if (caseImportAction == CaseImportAction.STUDY_CREATION) {
268-
studyService.deleteStudyIfNotCreationInProgress(studyUuid, userId);
268+
studyService.deleteStudyIfNotCreationInProgress(studyUuid);
269269
}
270270
LOGGER.trace("{} for study uuid '{}' : {} seconds", caseImportAction.getLabel(), studyUuid,
271271
TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime));
@@ -490,7 +490,7 @@ public Consumer<Message<String>> consumeCaseImportFailed() {
490490
UUID rootNetworkUuid = receiver.getRootNetworkUuid();
491491

492492
if (receiver.getCaseImportAction() == CaseImportAction.STUDY_CREATION) {
493-
studyService.deleteStudyIfNotCreationInProgress(studyUuid, userId);
493+
studyService.deleteStudyIfNotCreationInProgress(studyUuid);
494494
notificationService.emitStudyCreationError(studyUuid, userId, errorMessage);
495495
} else {
496496
if (receiver.getCaseImportAction() == CaseImportAction.ROOT_NETWORK_CREATION) {

0 commit comments

Comments
 (0)