-
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 pagination and filtering for one bus analysis (#41)
Add an endpoint to get paginated FeederResults for one bus analysis. Add the possibility to filter the data. Add a new mode BASIC to get the faults included in the ShortCircuitAnalysisResult DTO but without the limit violations or feeders. Drop the database because of schema changes. Add some comments. Signed-off-by: Florent MILLOT <millotflo@gmail.com>
- Loading branch information
Showing
14 changed files
with
862 additions
and
50 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
56 changes: 56 additions & 0 deletions
56
src/main/java/org/gridsuite/shortcircuit/server/dto/ResourceFilter.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,56 @@ | ||
/** | ||
* 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.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* An object that can be used to filter data with the JPA Criteria API (via Spring Specification) | ||
* @param dataType the type of data we want to filter (text, number) | ||
* @param type the type of filter (contains, startsWith...) | ||
* @param value the value of the filter | ||
* @param field the field on which the filter will be applied | ||
* @author Florent MILLOT <florent.millot@rte-france.com> | ||
*/ | ||
public record ResourceFilter(DataType dataType, Type type, String value, String field) { | ||
|
||
private static ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
public enum DataType { | ||
@JsonProperty("text") | ||
TEXT, | ||
@JsonProperty("number") | ||
NUMBER, | ||
} | ||
|
||
public enum Type { | ||
@JsonProperty("contains") | ||
CONTAINS, | ||
@JsonProperty("startsWith") | ||
STARTS_WITH, | ||
@JsonProperty("notEqual") | ||
NOT_EQUAL, | ||
@JsonProperty("lessThanOrEqual") | ||
LESS_THAN_OR_EQUAL, | ||
@JsonProperty("greaterThanOrEqual") | ||
GREATER_THAN_OR_EQUAL | ||
} | ||
|
||
public static List<ResourceFilter> fromStringToList(String filters) throws JsonProcessingException { | ||
if (filters == null || filters.isEmpty()) { | ||
return List.of(); | ||
} | ||
return objectMapper.readValue(filters, new TypeReference<>() { | ||
}); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
src/main/java/org/gridsuite/shortcircuit/server/repositories/FeederResultRepository.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,22 @@ | ||
/** | ||
* 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.repositories; | ||
|
||
import org.gridsuite.shortcircuit.server.entities.FeederResultEntity; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* @author Florent MILLOT <florent.millot@rte-france.com> | ||
*/ | ||
@Repository | ||
public interface FeederResultRepository extends JpaRepository<FeederResultEntity, UUID>, JpaSpecificationExecutor<FeederResultEntity> { | ||
} |
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
Oops, something went wrong.