Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
657c5c8
First step in adding global filter on shortcircuit analysis panel
ipirog Jul 18, 2025
d33b8b8
Unused import and TU
ipirog Jul 18, 2025
72b0a39
Merge branch 'main' of https://github.com/gridsuite/study-server into…
ipirog Jul 18, 2025
35e5d7b
Merge branch 'main' of https://github.com/gridsuite/study-server into…
ipirog Jul 18, 2025
daa1f9b
Merge branch 'short_circuit_results_add_global_filter' of https://git…
ipirog Jul 21, 2025
4eb160c
Merge branch 'main' of https://github.com/gridsuite/study-server into…
ipirog Jul 21, 2025
ab017a5
Adjust number of parameters below the max sonar
ipirog Jul 21, 2025
14a5c75
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Jul 21, 2025
52baf0a
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Jul 21, 2025
9583426
Merge branch 'main' of https://github.com/gridsuite/study-server into…
ipirog Jul 22, 2025
970a028
Merge branch 'main' of https://github.com/gridsuite/study-server into…
ipirog Jul 23, 2025
24cbfda
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Jul 23, 2025
c42bb7b
Merge branch 'main' into short_circuit_results_add_global_filter
ghazwarhili Jul 25, 2025
21f6b50
Merge branch 'main' into short_circuit_results_add_global_filter
ghazwarhili Jul 25, 2025
0b6bf8f
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Aug 18, 2025
eff43d7
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Aug 18, 2025
249c169
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Aug 19, 2025
6e9bfdf
Merge branch 'main' into short_circuit_results_add_global_filter
ipirog Aug 20, 2025
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 @@ -46,6 +46,7 @@
import org.gridsuite.study.server.service.securityanalysis.SecurityAnalysisResultType;
import org.gridsuite.study.server.service.shortcircuit.FaultResultsMode;
import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType;
import org.gridsuite.study.server.utils.StudyParameters;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.util.Pair;
Expand Down Expand Up @@ -806,17 +807,18 @@ public ResponseEntity<Void> stopShortCircuitAnalysis(@Parameter(description = "S
@ApiResponse(responseCode = "204", description = "No short circuit analysis has been done yet"),
@ApiResponse(responseCode = "404", description = "The short circuit analysis has not been found")})
public ResponseEntity<String> getShortCircuitResult(@Parameter(description = "study UUID") @PathVariable("studyUuid") UUID studyUuid,
@PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
@Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "root network UUID") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid,
@Parameter(description = "node UUID") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "BASIC (faults without limits and feeders), " +
"FULL (faults with both), " +
"WITH_LIMIT_VIOLATIONS (like FULL but only those with limit violations) or " +
"NONE (no fault)") @RequestParam(name = "mode", required = false, defaultValue = "FULL") FaultResultsMode mode,
@Parameter(description = "type") @RequestParam(value = "type", required = false, defaultValue = "ALL_BUSES") ShortcircuitAnalysisType type,
@Parameter(description = "JSON array of filters") @RequestParam(name = "filters", required = false) String filters,
@Parameter(description = "JSON array of global filters") @RequestParam(name = "globalFilters", required = false) String globalFilters,
@Parameter(description = "If we wanted the paged version of the results or not") @RequestParam(name = "paged", required = false, defaultValue = "false") boolean paged,
Pageable pageable) {
String result = rootNetworkNodeInfoService.getShortCircuitAnalysisResult(nodeUuid, rootNetworkUuid, mode, type, filters, paged, pageable);
String result = rootNetworkNodeInfoService.getShortCircuitAnalysisResult(new StudyParameters(rootNetworkUuid, nodeUuid), mode, type, filters, globalFilters, paged, pageable);
return result != null ? ResponseEntity.ok().body(result) :
ResponseEntity.noContent().build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public void consumeCalculationFailed(Message<String> msg, ComputationType comput
try {
receiverObj = objectMapper.readValue(URLDecoder.decode(receiver, StandardCharsets.UTF_8), NodeReceiver.class);

LOGGER.info("{} failed for node '{}' with error messsage: {}", computationType.getLabel(), receiverObj.getNodeUuid(), errorMessage);
LOGGER.info("{} failed for node '{}' with error message: {}", computationType.getLabel(), receiverObj.getNodeUuid(), errorMessage);

// delete computation results from the databases
// ==> will probably be removed soon because it prevents the front from recovering the resultId ; or 'null' parameter will be replaced by null like in VOLTAGE_INITIALIZATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.gridsuite.study.server.service.shortcircuit.FaultResultsMode;
import org.gridsuite.study.server.service.shortcircuit.ShortCircuitService;
import org.gridsuite.study.server.service.shortcircuit.ShortcircuitAnalysisType;
import org.gridsuite.study.server.utils.StudyParameters;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
Expand Down Expand Up @@ -603,10 +604,13 @@ public String getNonEvacuatedEnergyResult(UUID nodeUuid, UUID rootNetworkUuid) {
}

@Transactional(readOnly = true)
public String getShortCircuitAnalysisResult(UUID nodeUuid, UUID rootNetworkUuid, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, boolean paged, Pageable pageable) {
UUID resultUuid = getComputationResultUuid(nodeUuid, rootNetworkUuid,
type == ShortcircuitAnalysisType.ALL_BUSES ? SHORT_CIRCUIT : SHORT_CIRCUIT_ONE_BUS);
return shortCircuitService.getShortCircuitAnalysisResult(resultUuid, mode, type, filters, paged, pageable);
public String getShortCircuitAnalysisResult(StudyParameters studyParameters, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, String globalFilters, boolean paged, Pageable pageable) {
RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(studyParameters.getNodeUuid(), studyParameters.getRootNetworkUuid()).orElse(null);
studyParameters.setVariantId(rootNetworkNodeInfoEntity == null ? null : rootNetworkNodeInfoEntity.getVariantId());
studyParameters.setNetworkUuid(rootNetworkNodeInfoEntity == null ? studyParameters.getRootNetworkUuid() : rootNetworkNodeInfoEntity.getRootNetwork().getNetworkUuid());
studyParameters.setResultUuid(getComputationResultUuid(studyParameters.getNodeUuid(), studyParameters.getRootNetworkUuid(),
type == ShortcircuitAnalysisType.ALL_BUSES ? SHORT_CIRCUIT : SHORT_CIRCUIT_ONE_BUS));
return shortCircuitService.getShortCircuitAnalysisResult(studyParameters, mode, type, filters, globalFilters, paged, pageable);
}

@Transactional(readOnly = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.gridsuite.study.server.dto.ShortCircuitStatus;
import org.gridsuite.study.server.service.StudyService;
import org.gridsuite.study.server.service.common.AbstractComputationService;
import org.gridsuite.study.server.utils.StudyParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.*;
Expand Down Expand Up @@ -122,11 +123,11 @@ private String getShortCircuitAnalysisResultsPageResourcePath(UUID resultUuid, S
return resultPath + "/paged";
}

public String getShortCircuitAnalysisResult(UUID resultUuid, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, boolean paged, Pageable pageable) {
public String getShortCircuitAnalysisResult(StudyParameters studyParameters, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, String globalFilters, boolean paged, Pageable pageable) {
if (paged) {
return getShortCircuitAnalysisResultsPage(resultUuid, mode, type, filters, pageable);
return getShortCircuitAnalysisResultsPage(studyParameters, mode, type, filters, globalFilters, pageable);
} else {
return getShortCircuitAnalysisResult(resultUuid, mode);
return getShortCircuitAnalysisResult(studyParameters.getResultUuid(), mode);
}
}

Expand Down Expand Up @@ -170,19 +171,25 @@ public String getShortCircuitAnalysisResult(UUID resultUuid, FaultResultsMode mo
return getShortCircuitAnalysisResource(builder.build().toUri());
}

public String getShortCircuitAnalysisResultsPage(UUID resultUuid, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, Pageable pageable) {
String resultsPath = getShortCircuitAnalysisResultsPageResourcePath(resultUuid, type);
public String getShortCircuitAnalysisResultsPage(StudyParameters studyParameters, FaultResultsMode mode, ShortcircuitAnalysisType type, String filters, String globalFilters, Pageable pageable) {
String resultsPath = getShortCircuitAnalysisResultsPageResourcePath(studyParameters.getResultUuid(), type);
if (resultsPath == null) {
return null;
}

UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(shortCircuitServerBaseUri + resultsPath)
.queryParam("rootNetworkUuid", studyParameters.getNetworkUuid())
.queryParam("variantId", studyParameters.getVariantId())
.queryParam("mode", mode);

if (filters != null && !filters.isEmpty()) {
builder.queryParam("filters", filters);
}

if (globalFilters != null && !globalFilters.isEmpty()) {
builder.queryParam("globalFilters", globalFilters);
}

addPageableToQueryParams(builder, pageable);

return getShortCircuitAnalysisResource(builder.build().encode().toUri()); // need to encode because of filter JSON array
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.gridsuite.study.server.utils;

import lombok.Getter;
import lombok.Setter;

import java.util.UUID;

@Getter
public class StudyParameters {

private final UUID rootNetworkUuid;
private final UUID nodeUuid;
@Setter
private String variantId = null;
@Setter
private UUID networkUuid = null;
@Setter
private UUID resultUuid = null;

public StudyParameters(UUID rootNetworkUuid, UUID nodeUuid) {
this.rootNetworkUuid = rootNetworkUuid;
this.nodeUuid = nodeUuid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,13 @@ public MockResponse dispatch(RecordedRequest request) {
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), SHORT_CIRCUIT_ANALYSIS_RESULT_JSON);
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault-types")) {
return new MockResponse(200);
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged" + "\\?mode=FULL&page=0&size=20&sort=id,DESC")) {
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged" + "\\?rootNetworkUuid=" + NETWORK_UUID_STRING + "&variantId=" + VARIANT_ID_2 + "&mode=FULL&page=0&size=20&sort=id,DESC")) {
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), SHORT_CIRCUIT_ANALYSIS_RESULT_JSON);
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/csv")) {
return new MockResponse.Builder().code(200).body(getBinaryAsBuffer(SHORT_CIRCUIT_ANALYSIS_CSV_RESULT)).addHeader("Content-Type", "application/json; charset=utf-8").build();
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID_NOT_FOUND + "/csv")) {
return new MockResponse(404);
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/feeder_results/paged" + "\\?mode=FULL&filters=fakeFilters&page=0&size=20&sort=id,DESC")) {
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/feeder_results/paged" + "\\?rootNetworkUuid=" + NETWORK_UUID_STRING + "&variantId=" + VARIANT_ID_2 + "&mode=FULL&filters=fakeFilters&page=0&size=20&sort=id,DESC")) {
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), SHORT_CIRCUIT_ANALYSIS_RESULT_JSON);
} else if (path.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/status")) {
return new MockResponse(200, Headers.of(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE), SHORT_CIRCUIT_ANALYSIS_STATUS_JSON);
Expand Down Expand Up @@ -502,7 +502,7 @@ void testPagedShortCircuit(final MockWebServer server) throws Exception {
status().isOk(),
content().string(SHORT_CIRCUIT_ANALYSIS_RESULT_JSON));

assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged\\?mode=FULL&page=0&size=20&sort=id,DESC")));
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/fault_results/paged\\?rootNetworkUuid=38400000-8cf0-11bd-b23e-10b96e4ef00d&variantId=variant_2&mode=FULL&page=0&size=20&sort=id,DESC")));

// get short circuit result with pagination but with unknown node
mockMvc.perform(get("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/shortcircuit/result?paged=true&page=0&size=20", studyNameUserIdUuid, firstRootNetworkUuid, unknownModificationNodeUuid)).andExpect(
Expand Down Expand Up @@ -588,7 +588,7 @@ void testOneBusShortCircuit(final MockWebServer server) throws Exception {
status().isOk(),
content().string(SHORT_CIRCUIT_ANALYSIS_RESULT_JSON));

assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/feeder_results/paged\\?mode=FULL&filters=fakeFilters&page=0&size=20&sort=id,DESC")));
assertTrue(TestUtils.getRequestsDone(1, server).stream().anyMatch(r -> r.matches("/v1/results/" + SHORT_CIRCUIT_ANALYSIS_RESULT_UUID + "/feeder_results/paged\\?rootNetworkUuid=38400000-8cf0-11bd-b23e-10b96e4ef00d&variantId=variant_2&mode=FULL&filters=fakeFilters&page=0&size=20&sort=id,DESC")));

// get one bus short circuit status
mockMvc.perform(get("/v1/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/shortcircuit/status", studyNameUserIdUuid, firstRootNetworkUuid, modificationNode3Uuid)
Expand Down