-
Notifications
You must be signed in to change notification settings - Fork 0
[DRAFT] Move contingency lists to SA parameters #220
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
base: main
Are you sure you want to change the base?
Conversation
| static final UUID CONTINGENCY_LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791f"); //"list1"; | ||
| static final UUID CONTINGENCY_LIST2_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791g"); //"list2"; | ||
| static final UUID CONTINGENCY_LIST_ERROR_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791h"); //"listError"; | ||
| static final UUID CONTINGENCY_LIST_NAME_VARIANT = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791i"); //"listVariant"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| static final UUID CONTINGENCY_LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791f"); //"list1"; | |
| static final UUID CONTINGENCY_LIST2_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791g"); //"list2"; | |
| static final UUID CONTINGENCY_LIST_ERROR_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791h"); //"listError"; | |
| static final UUID CONTINGENCY_LIST_NAME_VARIANT = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791i"); //"listVariant"; | |
| static final UUID CONTINGENCY_LIST_NAME = UUID.fromString("f7e8f79b-7626-4f46-939d-3bfdc895b0dd"); | |
| static final UUID CONTINGENCY_LIST2_NAME = UUID.fromString("99fdbba0-0f30-4f24-b206-5481b00ad910"); | |
| static final UUID CONTINGENCY_LIST_ERROR_NAME = UUID.fromString("d6e582ca-5084-4ad6-bf56-2ed3effdf9eb"); | |
| static final UUID CONTINGENCY_LIST_NAME_VARIANT = UUID.fromString("98b6dcfc-0186-4aa6-a4e0-e4d04c4faab2"); |
Correct UUID format, could you replace XXX_NAME to XXX_UUID and search 'NAME' or 'Name' in the whole code to replace by 'UUID' or 'Uuid'
| private static final UUID LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791j"); //"myList"; | ||
| private static final UUID LIST_NAME_VARIANT = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791k"); //"myListVariant"; | ||
|
|
||
| private static final String VERY_LARGE_LIST_NAME = "veryLargelist"; | ||
| private static final UUID VERY_LARGE_LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791l"); //"veryLargelist"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| private static final UUID LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791j"); //"myList"; | |
| private static final UUID LIST_NAME_VARIANT = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791k"); //"myListVariant"; | |
| private static final String VERY_LARGE_LIST_NAME = "veryLargelist"; | |
| private static final UUID VERY_LARGE_LIST_NAME = UUID.fromString("6afd3d28-3f99-48d7-be9e-e97ffd0b791l"); //"veryLargelist"; | |
| private static final UUID LIST_NAME = UUID.fromString("e6bc6e4b-bbf1-4342-a8ae-49b213f0c85a"); | |
| private static final UUID LIST_NAME_VARIANT = UUID.fromString("81bb191f-b899-4999-91e3-2d158d208764"); | |
| private static final UUID VERY_LARGE_LIST_NAME = UUID.fromString("4856bff4-9ebe-4ba2-b66d-0242f27fce7b"); |
Could you replace XXX_NAME to XXX_UUID
| contingencyLists.clear(); | ||
| contingencyLists.addAll(entities); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| contingencyLists.clear(); | |
| contingencyLists.addAll(entities); | |
| if (contingencyLists == null) { // due to the use of @Builder.Default, the field is not initialized with an empty array | |
| this.contingencyLists = entities; | |
| } else { | |
| contingencyLists.clear(); | |
| contingencyLists.addAll(entities); | |
| } |
| .contingencyLists(entity.getContingencyLists().stream() | ||
| .map(c -> new ParametersContingencyListDTO( | ||
| parametersContingenciesService.toDTO(c.getContingenciesIds()), | ||
| c.getDescription(), | ||
| c.isActivated())) | ||
| .toList()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .contingencyLists(entity.getContingencyLists().stream() | |
| .map(c -> new ParametersContingencyListDTO( | |
| parametersContingenciesService.toDTO(c.getContingenciesIds()), | |
| c.getDescription(), | |
| c.isActivated())) | |
| .toList()) | |
| .contingencyLists(Optional.of(entity.getContingencyLists().stream() | |
| .map(c -> new ParametersContingencyListDTO( | |
| parametersContingenciesService.toDTO(c.getContingenciesIds()), | |
| c.getDescription(), | |
| c.isActivated())) | |
| .toList()) | |
| .filter(list -> !list.isEmpty()) // if empty list return null | |
| .orElse(null)) |
To satisfy roundtrip consistance between dto <-> entity, if not test create/get a params will be failed
| @@ -0,0 +1,20 @@ | |||
| package org.gridsuite.securityanalysis.server.dto; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| package org.gridsuite.securityanalysis.server.dto; | |
| /** | |
| * Copyright (c) 2026, 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.securityanalysis.server.dto; |
| @CollectionTable( | ||
| name = "parameters_contingency_list_contingencies", | ||
| joinColumns = @JoinColumn(name = "contingency_list_id") | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @CollectionTable( | |
| name = "parameters_contingency_list_contingencies", | |
| joinColumns = @JoinColumn(name = "contingency_list_id") | |
| ) | |
| @CollectionTable( | |
| name = "parameters_contingency_lists_contingency_list", | |
| joinColumns = @JoinColumn(name = "parameters_contingency_lists_id") | |
| foreignKey = @ForeignKey(name = "parameters_contingency_lists_id_fk") | |
| ) |
|
|
||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.UUID) | ||
| @Column(name = "contingency_list_id") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @Column(name = "contingency_list_id") | |
| @Column(name = "id") |
| @@ -0,0 +1,63 @@ | |||
| package org.gridsuite.securityanalysis.server.service; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| package org.gridsuite.securityanalysis.server.service; | |
| /** | |
| Copyright (c) 2026, 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.securityanalysis.server.service; |
| this.restTemplate = restTemplate; | ||
| } | ||
|
|
||
| public String getContingenciesName(UUID contingenciesId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better with a bulk fetch with a list of uuid and make the signature more generic, for example
Map<UUID, String> getElementNames(List elementUuids)
| * @author Caroline Jeandat {@literal <caroline.jeandat at rte-france.com>} | ||
| */ | ||
| @Service | ||
| public class ParametersContingenciesService { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure we need a dedicated service just for mapping
PR Summary
Still to do: