Skip to content

Commit

Permalink
check contingency when getting filter options
Browse files Browse the repository at this point in the history
  • Loading branch information
Seddik Yengui committed Oct 4, 2023
1 parent 93f55d2 commit a70687e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,19 @@ public interface SensitivityRepository extends JpaRepository<SensitivityEntity,

Page<SensitivityEntity> findAll(Specification<SensitivityEntity> 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<String> 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<String> 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<String> 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<String> 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<String> getDistinctContingencyIds(UUID resultUuid, SensitivityFunctionType sensitivityFunctionType);

static Specification<SensitivityEntity> getSpecification(AnalysisResultEntity sas,
Expand Down

0 comments on commit a70687e

Please sign in to comment.