diff --git a/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityAnalysisResultRepository.java b/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityAnalysisResultRepository.java index 690bf306..c2f10f31 100644 --- a/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityAnalysisResultRepository.java +++ b/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityAnalysisResultRepository.java @@ -151,8 +151,8 @@ public SensitivityResultFilterOptions getSensitivityResultFilterOptions(UUID res } SensitivityResultFilterOptions.SensitivityResultFilterOptionsBuilder sensitivityResultOptionsBuilder = SensitivityResultFilterOptions.builder() - .allFunctionIds(sensitivityRepository.getDistinctFunctionIds(sas.getResultUuid(), selector.getFunctionType())) - .allVariableIds(sensitivityRepository.getDistinctVariableIds(sas.getResultUuid(), selector.getFunctionType())); + .allFunctionIds(sensitivityRepository.getDistinctFunctionIds(sas.getResultUuid(), selector.getFunctionType(), !selector.getIsJustBefore())) + .allVariableIds(sensitivityRepository.getDistinctVariableIds(sas.getResultUuid(), selector.getFunctionType(), !selector.getIsJustBefore())); if (!selector.getIsJustBefore()) { sensitivityResultOptionsBuilder.allContingencyIds(sensitivityRepository.getDistinctContingencyIds(sas.getResultUuid(), selector.getFunctionType()) diff --git a/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityRepository.java b/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityRepository.java index 75841a3a..1891293b 100644 --- a/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityRepository.java +++ b/src/main/java/org/gridsuite/sensitivityanalysis/server/repositories/SensitivityRepository.java @@ -38,13 +38,19 @@ public interface SensitivityRepository extends JpaRepository findAll(Specification specification, Pageable pageable); - @Query(value = "SELECT distinct s.factor.functionId from SensitivityEntity as s where s.result.resultUuid = :resultUuid and s.factor.functionType = :sensitivityFunctionType") - List getDistinctFunctionIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType); + @Query(value = "SELECT distinct s.factor.functionId from SensitivityEntity as s " + + "where s.result.resultUuid = :resultUuid " + + "and s.factor.functionType = :sensitivityFunctionType " + + "and ((:withContingency = true and s.contingency is not null ) or (:withContingency = false and s.contingency is null ))") + List getDistinctFunctionIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType, boolean withContingency); - @Query(value = "SELECT distinct s.factor.variableId from SensitivityEntity as s where s.result.resultUuid = :resultUuid and s.factor.functionType = :sensitivityFunctionType") - List getDistinctVariableIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType); + @Query(value = "SELECT distinct s.factor.variableId from SensitivityEntity as s " + + "where s.result.resultUuid = :resultUuid " + + "and s.factor.functionType = :sensitivityFunctionType " + + "and ((:withContingency = true and s.contingency is not null ) or (:withContingency = false and s.contingency is null ))") + List getDistinctVariableIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType, boolean withContingency); - @Query(value = "SELECT distinct s.contingency.contingencyId from SensitivityEntity as s where s.result.resultUuid = :resultUuid and s.factor.functionType = :sensitivityFunctionType") + @Query(value = "SELECT distinct s.contingency.contingencyId from SensitivityEntity as s where s.result.resultUuid = :resultUuid and s.factor.functionType = :sensitivityFunctionType ") List getDistinctContingencyIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType); static Specification getSpecification(AnalysisResultEntity sas,