Skip to content

add composite names#839

Open
AbdelHedhili wants to merge 9 commits into
mainfrom
add_composite_names
Open

add composite names#839
AbdelHedhili wants to merge 9 commits into
mainfrom
add_composite_names

Conversation

@AbdelHedhili

@AbdelHedhili AbdelHedhili commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

composite modification will now always have a name.

an endpoint is added in order to update it.

Signed-off-by: HEDHILI Abdelsalem <hedhiliabd@gm0winl1147.bureau.si.interne>
@AbdelHedhili AbdelHedhili self-assigned this Jun 22, 2026
@coderabbitai

This comment was marked as low quality.

coderabbitai[bot]

This comment was marked as low quality.

Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java (1)

145-145: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Apply the requested name in the single-composite fast path.

This method now requires name, but when modificationUuids contains exactly one composite the early return above skips the new naming logic entirely. That means this create path preserves the source composite name instead of the caller-supplied one.

Minimal fix
         if (copyEntities.size() == 1 && copyEntities.getFirst() instanceof CompositeModificationEntity single) {
+            single.setName(name);
             return modificationRepository.save(single).getId();
         }

Also applies to: 162-165

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`
at line 145, The single-composite early return in
createNetworkCompositeModification is bypassing the caller-supplied name, so
update that fast path to apply the provided name before returning. Use the
existing createNetworkCompositeModification flow and the composite-copy logic
around modificationUuids so the one-item case still creates a renamed composite
instead of preserving the source name.
🧹 Nitpick comments (1)
src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java (1)

333-346: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the new update-time rename path.

This test only exercises modifications_uuids. The new name parameter on PUT /{uuid} is never sent or asserted, so a broken rename implementation would still pass the suite. Please add at least one rename-only or rename+reorder assertion here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java`
around lines 333 - 346, The CompositeControllerTest update path only validates
modifications_uuids and does not cover the new name parameter on the PUT flow.
Extend this test around the existing composite modification update/get
assertions to send a rename through CompositeController’s PUT /{uuid} handling
(either rename-only or rename plus reorder), then assert the returned composite
metadata reflects the updated name. Use the existing compositeModificationUuid,
mockMvc, and updatedMap/updatedCompositeContent checks to verify the rename path
is exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/main/java/org/gridsuite/modification/server/CompositeController.java`:
- Around line 127-131: The `updateNetworkCompositeModification` endpoint is
incorrectly reading `modifications_uuids` from a request parameter, which shifts
a potentially large UUID list into the URL. Update
`CompositeController.updateNetworkCompositeModification` to keep the UUID list
in the request body instead of `@RequestParam`, and adjust the service
invocation so the controller still passes the same `modificationUuids` data from
the body-based contract.

---

Outside diff comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Line 145: The single-composite early return in
createNetworkCompositeModification is bypassing the caller-supplied name, so
update that fast path to apply the provided name before returning. Use the
existing createNetworkCompositeModification flow and the composite-copy logic
around modificationUuids so the one-item case still creates a renamed composite
instead of preserving the source name.

---

Nitpick comments:
In
`@src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java`:
- Around line 333-346: The CompositeControllerTest update path only validates
modifications_uuids and does not cover the new name parameter on the PUT flow.
Extend this test around the existing composite modification update/get
assertions to send a rename through CompositeController’s PUT /{uuid} handling
(either rename-only or rename plus reorder), then assert the returned composite
metadata reflects the updated name. Use the existing compositeModificationUuid,
mockMvc, and updatedMap/updatedCompositeContent checks to verify the rename path
is exercised.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 60568464-a571-4702-857a-350a752ba575

📥 Commits

Reviewing files that changed from the base of the PR and between fde6a24 and 4487956.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/modification/server/CompositeController.java
  • src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
  • src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java
  • src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java

Comment thread src/main/java/org/gridsuite/modification/server/CompositeController.java Outdated
@Mathieu-Deharbe Mathieu-Deharbe self-assigned this Jun 24, 2026
@Mathieu-Deharbe Mathieu-Deharbe removed their request for review June 24, 2026 09:25
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
return ResponseEntity.ok().body(networkModificationService.createNetworkCompositeModification(modificationUuids));
public ResponseEntity<UUID> createNetworkCompositeModification(@Parameter(description = "Composite modifications name", required = true) @RequestParam("name") String name,
@RequestBody List<UUID> modificationUuids) {
return ResponseEntity.ok().body(networkModificationService.createNetworkCompositeModification(modificationUuids, name == null ? "" : name));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Add NonNull ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually it is already required so I don't see the point of the null (Abdel added it but he is absent). I remove it : 3cacc3c

Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>
}

public void updateCompositeModification(@NonNull UUID compositeUuid, String name) {
ModificationEntity modificationEntity = modificationRepository.findById(compositeUuid)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Use CompositeModificationRepository

@Mathieu-Deharbe Mathieu-Deharbe Jun 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Done for update and replace oo. And removed the is instance test : 3cacc3c

Comment thread src/main/java/org/gridsuite/modification/server/CompositeController.java Outdated
Signed-off-by: Mathieu DEHARBE <mathieu.deharbe@rte-france.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/java/org/gridsuite/modification/server/CompositeController.java (1)

124-131: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Drop the JSON consumes constraint from rename-only updates.

Line 124 now maps an endpoint with no @RequestBody; clients sending PUT /{uuid}?name=... without Content-Type: application/json can hit 415 Unsupported Media Type before Line 130 is reached.

Suggested fix
-    `@PutMapping`(value = "/{uuid}", consumes = MediaType.APPLICATION_JSON_VALUE)
+    `@PutMapping`(value = "/{uuid}")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/main/java/org/gridsuite/modification/server/CompositeController.java`
around lines 124 - 131, The update endpoint in
CompositeController.updateNetworkCompositeModification is rename-only and does
not accept a request body, so the JSON consumes constraint is causing
unnecessary 415 responses for clients using PUT with only the name query
parameter. Remove the MediaType.APPLICATION_JSON_VALUE consumes declaration from
the `@PutMapping` on updateNetworkCompositeModification so the endpoint can be
called without a Content-Type header, while still delegating to
networkModificationService.updateCompositeModification as before.
src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java (1)

158-160: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Apply the requested name in the single-composite shortcut.

When modificationUuids contains one composite, Line 159 returns the cloned composite without applying the new name, so the create endpoint can return a composite with the source name instead of the requested name.

Suggested fix
         if (copyEntities.size() == 1 && copyEntities.getFirst() instanceof CompositeModificationEntity single) {
+            single.setName(name);
             return modificationRepository.save(single).getId();
         }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`
around lines 158 - 160, The single-composite shortcut in
NetworkModificationRepository is returning the cloned
CompositeModificationEntity before the requested name is applied. Update the
save path in this branch so the copied entity gets the new name from the create
request before calling modificationRepository.save. Make sure the same name
application logic used for the general copyEntities flow is also applied when
copyEntities contains exactly one composite, so the returned id corresponds to a
composite with the requested name.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Around line 172-182: The replace flow in NetworkModificationRepository
currently drops unresolved UUIDs by filtering nulls when building copyEntities,
which can let partial replacements succeed silently. Update the clone/reorder
logic around modificationRepository.findAllByIdIn and copyEntities so every
requested UUID must resolve, and if any UUID is missing, fail the replace
operation with an error instead of proceeding with a partial list.

---

Outside diff comments:
In `@src/main/java/org/gridsuite/modification/server/CompositeController.java`:
- Around line 124-131: The update endpoint in
CompositeController.updateNetworkCompositeModification is rename-only and does
not accept a request body, so the JSON consumes constraint is causing
unnecessary 415 responses for clients using PUT with only the name query
parameter. Remove the MediaType.APPLICATION_JSON_VALUE consumes declaration from
the `@PutMapping` on updateNetworkCompositeModification so the endpoint can be
called without a Content-Type header, while still delegating to
networkModificationService.updateCompositeModification as before.

In
`@src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java`:
- Around line 158-160: The single-composite shortcut in
NetworkModificationRepository is returning the cloned
CompositeModificationEntity before the requested name is applied. Update the
save path in this branch so the copied entity gets the new name from the create
request before calling modificationRepository.save. Make sure the same name
application logic used for the general copyEntities flow is also applied when
copyEntities contains exactly one composite, so the returned id corresponds to a
composite with the requested name.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5e8c0756-f3d3-411c-8b22-09c7d57ff7a0

📥 Commits

Reviewing files that changed from the base of the PR and between ab05f7a and 3cacc3c.

📒 Files selected for processing (4)
  • src/main/java/org/gridsuite/modification/server/CompositeController.java
  • src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java
  • src/main/java/org/gridsuite/modification/server/service/NetworkModificationService.java
  • src/test/java/org/gridsuite/modification/server/CompositeControllerTest.java

@sonarqubecloud

Copy link
Copy Markdown

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.

3 participants