-
Notifications
You must be signed in to change notification settings - Fork 0
Add endpoint to process filters and return Identifiables attributes list #167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
fb9292d
Add endpoint to process filters and return Identifiables attributes list
basseche afd87a4
checkStyle
basseche 4e7f9d8
Merge branch 'main' into FilterBasedContingencyList
basseche 6e9eda1
add Unit tests
basseche 08b8d2b
add variant UUID
basseche bbf3a9a
Merge branch 'main' into FilterBasedContingencyList
basseche afc2787
change endpoint to add not found list
basseche 5db16b2
add todo
basseche 79050a2
sort lists
basseche 4533df2
changes to update with directory server for filter elements
basseche 489f922
adapt to record
basseche 45a1407
adapt to change from class to record
basseche 6f8fa5b
fix tests
basseche bebaef0
move ElementAttributes to filter server
basseche 4796ffc
review
basseche bd2fb1f
fix filter not found
basseche b3704a2
Update src/main/java/org/gridsuite/filter/server/FilterController.java
basseche 3845562
Update src/main/java/org/gridsuite/filter/server/FilterService.java
basseche 4b081da
checkstyle
basseche 7327396
review
basseche 249d21d
add tests
basseche 4ec338a
add dependencies
basseche 4a63c55
not finished test
basseche 42e6733
add tests
basseche 7c17c86
more tests
basseche 5d4d2d6
remove comment
basseche File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
26 changes: 26 additions & 0 deletions
26
src/main/java/org/gridsuite/filter/server/configs/RestTemplateConfig.java
This file contains hidden or 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,26 @@ | ||
/* | ||
* 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.filter.server.configs; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
thangqp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* @author Bassel El Cheikh <bassel.el-cheikh at rte-france.com> | ||
*/ | ||
|
||
@Configuration | ||
public class RestTemplateConfig { | ||
|
||
@Bean | ||
public RestTemplate restTemplate() { | ||
return new RestTemplate(); | ||
} | ||
} | ||
|
18 changes: 18 additions & 0 deletions
18
src/main/java/org/gridsuite/filter/server/dto/ElementAttributes.java
This file contains hidden or 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,18 @@ | ||
/** | ||
* 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.filter.server.dto; | ||
|
||
import java.util.UUID; | ||
|
||
thangqp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* @author Bassel El Cheikh <bassel.el-cheikh at rte-france.com> | ||
*/ | ||
|
||
// partial class from ElementAttributes (Directory-server) | ||
public record ElementAttributes(UUID elementUuid, String elementName) { | ||
} |
This file contains hidden or 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 hidden or 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
71 changes: 71 additions & 0 deletions
71
src/main/java/org/gridsuite/filter/server/service/DirectoryService.java
This file contains hidden or 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,71 @@ | ||
/* | ||
* 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.filter.server.service; | ||
|
||
import lombok.Getter; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.ParameterizedTypeReference; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpMethod; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestTemplate; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
import org.gridsuite.filter.server.dto.ElementAttributes; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
thangqp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* @author Bassel El Cheikh <bassel.el-cheikh at rte-france.com> | ||
*/ | ||
|
||
@Service | ||
public class DirectoryService { | ||
public static final String DELIMITER = "/"; | ||
public static final String DIRECTORY_API_VERSION = "v1"; | ||
public static final String ELEMENT_END_POINT_INFOS = "/elements"; | ||
|
||
@Getter | ||
private final String baseUri; | ||
private final RestTemplate restTemplate; | ||
|
||
@Autowired | ||
public DirectoryService(@Value("${gridsuite.services.directory-server.base-uri:http://directory-server/}") String baseUri, | ||
RestTemplate restTemplate) { | ||
this.baseUri = baseUri; | ||
this.restTemplate = restTemplate; | ||
} | ||
|
||
public Map<UUID, String> getElementsName(List<UUID> ids, String userId) { | ||
Map<UUID, String> result = new HashMap<>(); | ||
String endPointUrl = getBaseUri() + DELIMITER + DIRECTORY_API_VERSION + ELEMENT_END_POINT_INFOS; | ||
UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromHttpUrl(endPointUrl); | ||
uriComponentsBuilder.queryParam("ids", ids); | ||
var uriComponent = uriComponentsBuilder.buildAndExpand(); | ||
|
||
HttpHeaders headers = new HttpHeaders(); | ||
headers.set("userId", userId); | ||
|
||
HttpEntity<String> entity = new HttpEntity<>(headers); | ||
|
||
List<ElementAttributes> elementAttributes = restTemplate.exchange(uriComponent.toUriString(), | ||
HttpMethod.GET, entity, new ParameterizedTypeReference<List<ElementAttributes>>() { }).getBody(); | ||
if (elementAttributes != null) { | ||
for (ElementAttributes elementAttribute : elementAttributes) { | ||
result.put(elementAttribute.elementUuid(), elementAttribute.elementName()); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.