Skip to content

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

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

copy cut paste reference modification and add ref with target infos#1058
souissimai wants to merge 18 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

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f691bf35-6a16-486b-8287-84be4dcc94a1

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1bab8d03-e8e2-4222-a20c-4480e710aa19

📥 Commits

Reviewing files that changed from the base of the PR and between 2d449d6 and 6a4fcce.

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

📝 Walkthrough

Walkthrough

duplicateNetworkModifications now retrieves modification references and registers shared-composite references for the destination node after duplication and exclusion mapping.

Changes

Network duplication

Layer / File(s) Summary
Register shared composite references
src/main/java/org/gridsuite/study/server/service/StudyService.java
The duplication workflow retrieves references, extracts referenced modification IDs, and registers them with the directory service for the target node and user.
Validate reference lookups
src/test/java/org/gridsuite/study/server/NetworkModificationTest.java
Duplication tests stub empty reference responses and verify lookup counts for same-study, child-mapping, and cross-study duplication.
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive The description contains only a template comment and does not provide a meaningful summary of the changes. Replace the template with a concise summary of reference modification copying, cutting, pasting, and target information support.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title identifies the main change: copying, cutting, pasting reference modifications, and adding target information.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@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 on lines +2131 to +2138
private void updateReferencesToSharedComposites(Map<UUID, UUID> referenceTargets, String userId, UUID originNodeUuid, UUID targetNodeUuid) {
directoryService.updateReferencesToSharedComposites(
referenceTargets.keySet().stream().toList(),
userId,
originNodeUuid,
targetNodeUuid
);
}

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.

This would only work when the target is a node. When it is a composite, the updating will need to change the referenceType which might be STUDY_NODE or become a NETWORK_MODIFICATION inside a composite. Same problem if the origin is a composite and the target is the root of a node.

referenceTargets contains its "mother" composite as value in the pair if there is one, null otherwise.

(groupUuid, modificationApplicationContexts) -> {
NetworkModificationsResult networkModificationResults = networkModificationService.duplicateModifications(groupUuid, Pair.of(modificationsUuids, modificationApplicationContexts));
copyModificationsToExclude(originNodeUuid, targetNodeUuid, modificationsUuids, networkModificationResults);
createReferencesToSharedComposites(networkModificationService.getReferences(modificationsUuids), userId, targetNodeUuid);

@Mathieu-Deharbe Mathieu-Deharbe Aug 18, 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.

This seems to work but it probably won't when the duplicated modificationsUuids contain composites who contain reference modifications. Those will be duplicated too and references will have to be created for them as well, not just for modificationsUuids.

So I think that we need a recursive version of networkModificationService.getReferences.

There is a TODO in netmod server about this :

// TODO GRD-4785 : for now shared modification are only at the root level and can't be inside composites, so the composite uuid is set to null
        // but when it will be the case a specific function will have to be done in order to fetch the composite containing the modificationReference (if there is one)

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 3 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>
@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