Skip to content

Endpoint to get modifications from composite together with the modifications not found#775

Merged
FranckLecuyer merged 10 commits intomainfrom
get_composite_modifications_with_error_checking
Mar 24, 2026
Merged

Endpoint to get modifications from composite together with the modifications not found#775
FranckLecuyer merged 10 commits intomainfrom
get_composite_modifications_with_error_checking

Conversation

@FranckLecuyer
Copy link
Contributor

PR Summary

Add new endpoint to get modifications from composite modifications, together with the composite modifications not found.

…gether with the composite modifications not found.

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
FranckLecuyer and others added 7 commits March 9, 2026 10:20
…ations_with_error_checking

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>

# Conflicts:
#	src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java
…ations_with_error_checking

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>

# Conflicts:
#	src/main/java/org/gridsuite/modification/server/NetworkModificationController.java
#	src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java
Copy link
Contributor

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

I think we can simplify a lot the code by adding a method to the repository and removing the metadata

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
@coderabbitai

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

Signed-off-by: Franck LECUYER <franck.lecuyer@rte-france.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/main/java/org/gridsuite/modification/server/repositories/ModificationRepository.java (1)

81-82: ⚠️ Potential issue | 🟠 Major

Existence check still excludes empty composites.

On Line 81, existence is derived from the sub-modification join table, so a valid composite with zero children is reported as missing. Query the composite entity/table directly instead.

Suggested fix
-    `@Query`(value = "SELECT DISTINCT cast(id AS VARCHAR) FROM composite_modification_sub_modifications WHERE id IN (?1)", nativeQuery = true)
+    `@Query`("SELECT c.id FROM CompositeModificationEntity c WHERE c.id IN (?1)")
     Set<UUID> findExistingCompositeModificationIds(List<UUID> compositeIds);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/main/java/org/gridsuite/modification/server/repositories/ModificationRepository.java`
around lines 81 - 82, The current repository method
findExistingCompositeModificationIds queries the join table
composite_modification_sub_modifications, which omits composites that have no
sub-modifications; change the query to select IDs directly from the composite
entity/table (the composite modification table, e.g., composite_modification)
using the provided compositeIds parameter so empty composites are included in
the existence check; update the `@Query` on findExistingCompositeModificationIds
to query the composite table by id IN (?1) and return the Set<UUID>.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/ModificationRepository.java`:
- Around line 81-82: The current repository method
findExistingCompositeModificationIds queries the join table
composite_modification_sub_modifications, which omits composites that have no
sub-modifications; change the query to select IDs directly from the composite
entity/table (the composite modification table, e.g., composite_modification)
using the provided compositeIds parameter so empty composites are included in
the existence check; update the `@Query` on findExistingCompositeModificationIds
to query the composite table by id IN (?1) and return the Set<UUID>.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 20618273-84ba-4ee3-a938-e4b47ea7bd6b

📥 Commits

Reviewing files that changed from the base of the PR and between 4bde5f8 and a8cde7a.

📒 Files selected for processing (2)
  • src/main/java/org/gridsuite/modification/server/repositories/ModificationRepository.java
  • src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java

@sonarqubecloud
Copy link

Copy link
Contributor

@antoinebhs antoinebhs left a comment

Choose a reason for hiding this comment

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

Code ok 👍

@FranckLecuyer FranckLecuyer merged commit 5bfaf54 into main Mar 24, 2026
4 checks passed
@FranckLecuyer FranckLecuyer deleted the get_composite_modifications_with_error_checking branch March 24, 2026 09:45
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