-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add filtering to fault results (#48)
Add the possibility to filter the fault results. Change default fault mode to FULL for paged fault results. Add 2 endpoints to return fault types and limit violation types. Some codde cleaning and refactoring. Signed-off-by: Florent MILLOT <millotflo@gmail.com>
- Loading branch information
Showing
12 changed files
with
641 additions
and
246 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/org/gridsuite/shortcircuit/server/utils/FaultResultSpecificationBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2023, 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.shortcircuit.server.utils; | ||
|
||
import org.gridsuite.shortcircuit.server.dto.ResourceFilter; | ||
import org.gridsuite.shortcircuit.server.entities.FaultResultEntity; | ||
import org.springframework.data.jpa.domain.Specification; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
/** | ||
* @author Florent MILLOT <florent.millot@rte-france.com> | ||
*/ | ||
public final class FaultResultSpecificationBuilder { | ||
|
||
// Utility class, so no constructor | ||
private FaultResultSpecificationBuilder() { | ||
} | ||
|
||
public static Specification<FaultResultEntity> resultUuidEquals(UUID value) { | ||
return (faultResult, cq, cb) -> cb.equal(faultResult.get("result").get("resultUuid"), value); | ||
} | ||
|
||
public static Specification<FaultResultEntity> buildSpecification(UUID resultUuid, List<ResourceFilter> resourceFilters) { | ||
Specification<FaultResultEntity> specification = Specification.where(resultUuidEquals(resultUuid)); | ||
return SpecificationUtils.appendFiltersToSpecification(specification, resourceFilters); | ||
} | ||
|
||
public static Specification<FaultResultEntity> appendWithLimitViolationsToSpecification(Specification<FaultResultEntity> specification) { | ||
return specification.and(SpecificationUtils.isNotEmpty("limitViolations")); | ||
} | ||
} |
Oops, something went wrong.