Skip to content
Merged
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 @@ -36,6 +36,7 @@

import static org.gridsuite.computation.service.NotificationService.HEADER_USER_ID;
import static org.gridsuite.computation.utils.FilterUtils.fromStringFiltersToDTO;
import static org.gridsuite.computation.utils.FilterUtils.fromStringGlobalFiltersToDTO;
import static org.springframework.http.MediaType.*;

/**
Expand Down Expand Up @@ -122,12 +123,19 @@ public ResponseEntity<UUID> runAndSave(@Parameter(description = "Network UUID")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis result"),
@ApiResponse(responseCode = "404", description = "Security analysis result has not been found")})
public ResponseEntity<List<PreContingencyLimitViolationResultDTO>> getNResult(@Parameter(description = "Result UUID") @PathVariable("resultUuid") UUID resultUuid,
@Parameter(description = "network Uuid") @RequestParam(name = "networkUuid", required = false) UUID networkUuid,
@Parameter(description = "variant Id") @RequestParam(name = "variantId", required = false) String variantId,
@Parameter(description = "Filters") @RequestParam(name = "filters", required = false) String stringFilters,
@Parameter(description = "Global Filters") @RequestParam(name = "globalFilters", required = false) String globalFilters,
@Parameter(description = "Pageable parameters for pagination and sorting") Sort sort) {
String decodedStringFilters = stringFilters != null ? URLDecoder.decode(stringFilters, StandardCharsets.UTF_8) : null;
String decodedStringGlobalFilters = globalFilters != null ? URLDecoder.decode(globalFilters, StandardCharsets.UTF_8) : null;
List<PreContingencyLimitViolationResultDTO> result = securityAnalysisResultService.findNResult(
resultUuid,
networkUuid,
variantId,
fromStringFiltersToDTO(decodedStringFilters, securityAnalysisResultService.getObjectMapper()),
fromStringGlobalFiltersToDTO(decodedStringGlobalFilters, securityAnalysisResultService.getObjectMapper()),
sort);

return result != null
Expand All @@ -151,10 +159,14 @@ public ResponseEntity<byte[]> getNResultZippedCsv(@Parameter(description = "Resu
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis result"),
@ApiResponse(responseCode = "404", description = "Security analysis result has not been found")})
public ResponseEntity<Page<ContingencyResultDTO>> getNmKContingenciesResult(@Parameter(description = "Result UUID") @PathVariable("resultUuid") UUID resultUuid,
@Parameter(description = "Filters") @RequestParam(name = "filters", required = false) String stringFilters,
@Parameter(description = "Pagination parameters") Pageable pageable) {
@Parameter(description = "network Uuid") @RequestParam(name = "networkUuid", required = false) UUID networkUuid,
@Parameter(description = "variant Id") @RequestParam(name = "variantId", required = false) String variantId,
@Parameter(description = "Filters") @RequestParam(name = "filters", required = false) String stringFilters,
@Parameter(description = "Global Filters") @RequestParam(name = "globalFilters", required = false) String globalFilters,
@Parameter(description = "Pagination parameters") Pageable pageable) {
String decodedStringFilters = stringFilters != null ? URLDecoder.decode(stringFilters, StandardCharsets.UTF_8) : null;
Page<ContingencyResultDTO> result = securityAnalysisResultService.findNmKContingenciesPaged(resultUuid, decodedStringFilters, pageable);
String decodedStringGlobalFilters = globalFilters != null ? URLDecoder.decode(globalFilters, StandardCharsets.UTF_8) : null;
Page<ContingencyResultDTO> result = securityAnalysisResultService.findNmKContingenciesPaged(resultUuid, networkUuid, variantId, decodedStringFilters, decodedStringGlobalFilters, pageable);

return result != null
? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result)
Expand All @@ -177,10 +189,14 @@ public ResponseEntity<byte[]> getNmKContingenciesResultZippedCsv(@Parameter(desc
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The security analysis result"),
@ApiResponse(responseCode = "404", description = "Security analysis result has not been found")})
public ResponseEntity<Page<SubjectLimitViolationResultDTO>> getNmKConstraintsResult(@Parameter(description = "Result UUID") @PathVariable("resultUuid") UUID resultUuid,
@Parameter(description = "network Uuid") @RequestParam(name = "networkUuid", required = false) UUID networkUuid,
@Parameter(description = "variant Id") @RequestParam(name = "variantId", required = false) String variantId,
@Parameter(description = "Filters") @RequestParam(name = "filters", required = false) String stringFilters,
@Parameter(description = "Global Filters") @RequestParam(name = "globalFilters", required = false) String globalFilters,
@Parameter(description = "Pagination parameters") Pageable pageable) {
String decodedStringFilters = stringFilters != null ? URLDecoder.decode(stringFilters, StandardCharsets.UTF_8) : null;
Page<SubjectLimitViolationResultDTO> result = securityAnalysisResultService.findNmKConstraintsResultPaged(resultUuid, decodedStringFilters, pageable);
String decodedStringGlobalFilters = globalFilters != null ? URLDecoder.decode(globalFilters, StandardCharsets.UTF_8) : null;
Page<SubjectLimitViolationResultDTO> result = securityAnalysisResultService.findNmKConstraintsResultPaged(resultUuid, networkUuid, variantId, decodedStringFilters, decodedStringGlobalFilters, pageable);
return result != null
? ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result)
: ResponseEntity.notFound().build();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* Copyright (c) 2025, 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.securityanalysis.server.service;

import com.powsybl.network.store.client.NetworkStoreService;
import lombok.NonNull;
import org.gridsuite.computation.dto.GlobalFilter;
import org.gridsuite.computation.dto.ResourceFilterDTO;
import org.gridsuite.computation.service.AbstractFilterService;
import org.gridsuite.filter.utils.EquipmentType;
import org.gridsuite.securityanalysis.server.entities.ContingencyEntity;
import org.gridsuite.securityanalysis.server.entities.SubjectLimitViolationEntity;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;
import java.util.UUID;

/**
* @author Rehili Ghazwa <ghazwa.rehili at rte-france.com>
*/
@Service
public class FilterService extends AbstractFilterService {

public FilterService(
NetworkStoreService networkStoreService,
@Value("${gridsuite.services.filter-server.base-uri:http://filter-server/}") String filterServerBaseUri) {
super(networkStoreService, filterServerBaseUri);
}

public Optional<ResourceFilterDTO> getResourceFilterN(@NonNull UUID networkUuid, @NonNull String variantId, @NonNull GlobalFilter globalFilter) {
return super.getResourceFilter(networkUuid, variantId, globalFilter, List.of(EquipmentType.VOLTAGE_LEVEL), "subjectLimitViolation.subjectId");
}

public Optional<ResourceFilterDTO> getResourceFilterContingencies(@NonNull UUID networkUuid, @NonNull String variantId, @NonNull GlobalFilter globalFilter) {
return super.getResourceFilter(networkUuid, variantId, globalFilter, List.of(EquipmentType.LINE, EquipmentType.TWO_WINDINGS_TRANSFORMER, EquipmentType.VOLTAGE_LEVEL), ContingencyEntity.Fields.contingencyId);
}

public Optional<ResourceFilterDTO> getResourceFilterSubjectLimitViolations(@NonNull UUID networkUuid, @NonNull String variantId, @NonNull GlobalFilter globalFilter) {
return super.getResourceFilter(networkUuid, variantId, globalFilter, List.of(EquipmentType.LINE, EquipmentType.TWO_WINDINGS_TRANSFORMER, EquipmentType.VOLTAGE_LEVEL), SubjectLimitViolationEntity.Fields.subjectId);
}
}
Loading