Skip to content

Conversation

@carojeandat
Copy link
Contributor

@carojeandat carojeandat commented Feb 5, 2026

PR Summary

Still to do:

  • return null name when the contingency list no longer exists
  • add tests

Comment on lines +40 to +43
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'

Comment on lines +58 to +61
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines +115 to +116
contingencyLists.clear();
contingencyLists.addAll(entities);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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);
}

Comment on lines +115 to +120
.contingencyLists(entity.getContingencyLists().stream()
.map(c -> new ParametersContingencyListDTO(
parametersContingenciesService.toDTO(c.getContingenciesIds()),
c.getDescription(),
c.isActivated()))
.toList())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;

Comment on lines +27 to +30
@CollectionTable(
name = "parameters_contingency_list_contingencies",
joinColumns = @JoinColumn(name = "contingency_list_id")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Column(name = "contingency_list_id")
@Column(name = "id")

@@ -0,0 +1,63 @@
package org.gridsuite.securityanalysis.server.service;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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) {
Copy link
Contributor

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 {
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants