Skip to content

copy cut paste reference modification and add ref with target infos - #1058

Open
souissimai wants to merge 23 commits into
mainfrom
reference-modification-actions
Open

copy cut paste reference modification and add ref with target infos#1058
souissimai wants to merge 23 commits into
mainfrom
reference-modification-actions

Conversation

@souissimai

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
@coderabbitai

This comment was marked as low quality.

@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

🧹 Nitpick comments (1)
src/main/java/org/gridsuite/study/server/service/StudyService.java (1)

2167-2175: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Add regression coverage for reference registration.

src/test/java/org/gridsuite/study/server/rootnetworks/ModificationToExcludeTest.java verifies exclusion mappings but not the new directory-server side effect. Add a test that stubs networkModificationService.getReferences(...) and verifies directoryService.createsReferencesToSharedComposites(...) receives the shared element UUID and targetNodeUuid. Cover multiple references and an empty result.

🤖 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/study/server/service/StudyService.java` around
lines 2167 - 2175, Add regression tests in ModificationToExcludeTest for the
reference-registration flow around createReferencesToSharedComposites: stub
networkModificationService.getReferences(...) and verify
directoryService.createsReferencesToSharedComposites(...) is called with each
shared element UUID and targetNodeUuid, covering multiple references and an
empty result with no calls.
🤖 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/study/server/service/StudyService.java`:
- Around line 2161-2165: The workflow around
networkModificationService.duplicateModifications must not depend on the local
transaction for remote directory-server writes. Make
createReferencesToSharedComposites idempotent and retryable, or track each
completed reference and compensate both those references and the duplicated
modifications on failure before propagating the error.

---

Nitpick comments:
In `@src/main/java/org/gridsuite/study/server/service/StudyService.java`:
- Around line 2167-2175: Add regression tests in ModificationToExcludeTest for
the reference-registration flow around createReferencesToSharedComposites: stub
networkModificationService.getReferences(...) and verify
directoryService.createsReferencesToSharedComposites(...) is called with each
shared element UUID and targetNodeUuid, covering multiple references and an
empty result with no calls.
🪄 Autofix

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 Plus

Run ID: b24090fe-464b-40e8-9a61-63b234061fd4

📥 Commits

Reviewing files that changed from the base of the PR and between fcd627b and dab4a3f.

📒 Files selected for processing (1)
  • src/main/java/org/gridsuite/study/server/service/StudyService.java

Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
SOUISSI Maissa (Externe) added 3 commits August 12, 2026 22:16
SOUISSI Maissa (Externe)
fix
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>

@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

🤖 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/test/java/org/gridsuite/study/server/NetworkModificationTest.java`:
- Around line 2346-2350: Update the reference lookup stubs and verifications in
the affected duplication tests to match the expected original and copied UUID
query values explicitly, rather than accepting any uuids parameter. Verify each
duplication operation performs exactly one lookup with its correct UUIDs,
including the cases currently using aggregate counts, while preserving the
existing no-reference response behavior.
🪄 Autofix

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 Plus

Run ID: 172843bd-b608-4798-9bac-0691ad90f60c

📥 Commits

Reviewing files that changed from the base of the PR and between a421f4a and 11e5328.

📒 Files selected for processing (1)
  • src/test/java/org/gridsuite/study/server/NetworkModificationTest.java

Comment on lines +2346 to +2350
// no shared-composite reference among the duplicated modifications
wireMockServer.stubFor(WireMock.get(WireMock.urlPathEqualTo("/v1/references"))
.willReturn(WireMock.ok()
.withBody(mapper.writeValueAsString(Map.of()))
.withHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Assert the UUIDs used in each reference lookup.

The /v1/references stubs match any query, and the verifications accept any uuids value. These tests can pass when the service omits an ID, sends the wrong original or copied ID, or sends an empty value. At Line 2405, the aggregate count across two duplications also does not prove that each operation performs one lookup. Match the expected UUIDs for each request and verify the count per duplication operation.

Also applies to: 2405-2405, 2452-2457, 2475-2475, 2512-2515, 2538-2538

🤖 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/study/server/NetworkModificationTest.java` around
lines 2346 - 2350, Update the reference lookup stubs and verifications in the
affected duplication tests to match the expected original and copied UUID query
values explicitly, rather than accepting any uuids parameter. Verify each
duplication operation performs exactly one lookup with its correct UUIDs,
including the cases currently using aggregate counts, while preserving the
existing no-reference response behavior.

souissimai and others added 6 commits August 13, 2026 10:00
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Comment thread src/main/java/org/gridsuite/study/server/service/DirectoryService.java Outdated
Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
souissimai and others added 5 commits August 19, 2026 15:35
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
@coderabbitai

coderabbitai Bot commented Aug 21, 2026

Copy link
Copy Markdown

Warning

Your free Security trial is over. An organization admin can activate billing to continue.

souissimai and others added 4 commits August 21, 2026 17:29
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Comment on lines +15 to +18
* @param referenceId uuid of the referenced shared composite
* @param containerId uuid of the composite containing the reference, null if the modification-reference is at the root level
*/
public record ReferenceData(UUID modificationUuid, UUID referenceId, UUID containerId) {

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.

I think this is clearer :

Suggested change
* @param referenceId uuid of the referenced shared composite
* @param containerId uuid of the composite containing the reference, null if the modification-reference is at the root level
*/
public record ReferenceData(UUID modificationUuid, UUID referenceId, UUID containerId) {
* @param sharedCompositeId uuid of the referenced shared composite
* @param containerId uuid of the composite containing the reference, null if the modification-reference is at the root level
*/
public record ReferenceData(UUID modificationUuid, UUID sharedCompositeId, UUID containerId) {

Comment thread src/main/java/org/gridsuite/study/server/service/DirectoryService.java Outdated
Comment thread src/main/java/org/gridsuite/study/server/service/DirectoryService.java Outdated
SOUISSI Maissa (Externe) added 2 commits August 26, 2026 03:49
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
SOUISSI Maissa (Externe)
fix
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>

@Mathieu-Deharbe Mathieu-Deharbe left a comment

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.

Only small remarks but I didn't validate yet because I need to test one last time after the conflict solving.

Comment thread src/main/java/org/gridsuite/study/server/service/RebuildNodeService.java Outdated
Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java
Comment on lines +1820 to +1826
List<UUID> targetChildrenUuids = networkModificationTreeService.getChildrenUuids(targetNodeUuid);
Map<UUID, List<UUID>> originChildrenUuidsByNode = originNodesTouched.stream()
.collect(Collectors.toMap(Function.identity(), networkModificationTreeService::getChildrenUuids, (a, b) -> a, LinkedHashMap::new));

notificationService.emitStartModificationEquipmentNotification(studyUuid, targetNodeUuid, targetChildrenUuids, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS);
originChildrenUuidsByNode.forEach((originNodeUuid, children) ->
notificationService.emitStartModificationEquipmentNotification(studyUuid, originNodeUuid, children, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS));

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.

That part about notifications could probably be extracted for clarity, but we will see in the refacto.

Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
Collectors.mapping(ModificationMoveOrCopyInfos::modificationUuid, Collectors.toList())));
}

private boolean hasModificationSource(ModificationContainerInfos source) {

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.

Given that the cource may not be a modification and no data here involves a modification :

Suggested change
private boolean hasModificationSource(ModificationContainerInfos source) {
private boolean hasSource(ModificationContainerInfos source) {

or

Suggested change
private boolean hasModificationSource(ModificationContainerInfos source) {
private boolean sourceDefined(ModificationContainerInfos source) {

Comment thread src/main/java/org/gridsuite/study/server/service/StudyService.java Outdated
Comment on lines +2028 to +2030
private void createReferencesToSharedComposites(List<ReferenceData> referenceTargets, List<UUID> modificationsUuids,
Map<UUID, UUID> mappingModificationsUuids, String userId, UUID targetNodeUuid) {
Set<UUID> requestedUuids = new HashSet<>(modificationsUuids);

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.

I don't think these are targets :

Suggested change
private void createReferencesToSharedComposites(List<ReferenceData> referenceTargets, List<UUID> modificationsUuids,
Map<UUID, UUID> mappingModificationsUuids, String userId, UUID targetNodeUuid) {
Set<UUID> requestedUuids = new HashSet<>(modificationsUuids);
private void createReferencesToSharedComposites(List<ReferenceData> references, List<UUID> modificationsUuids,
Map<UUID, UUID> mappingModificationsUuids, String userId, UUID targetNodeUuid) {
Set<UUID> requestedUuids = new HashSet<>(modificationsUuids);

I understand the function but this is very convoluted and looks like the data could be stored in mappingModificationsUuids when buildModificationsUuidMapping is called. With a specific mapping structure we could probably simplify these functions and comments. modificationsUuids would be removed etc...

I am not asking you to do this here but could you reference this in the refacto ticket ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

here we create refernce for list of copied modification , gourped by source container, exact !to refactor ! created ticket

return mappingModificationsUuids;
}

private void copyModificationsToExclude(UUID originNodeUuid, UUID targetNodeUuid, Map<UUID, UUID> mappingModificationsUuids) {

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.

You should remove the original copyModificationsToExclude function now useless; Anyway this will all be removed by Florent ticket about applicability.

Comment thread src/test/java/org/gridsuite/study/server/RebuildNodeServiceTest.java Outdated
SOUISSI Maissa (Externe) added 2 commits August 26, 2026 20:21
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
Signed-off-by: SOUISSI Maissa (Externe) <souissimai@gm0winl878.bureau.si.interne>
@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.

2 participants