Skip to content

Add an endpoint sharing a composite modification of a node - #1070

Open
flomillot wants to merge 4 commits into
mainfrom
feat/share-composite-modification
Open

Add an endpoint sharing a composite modification of a node#1070
flomillot wants to merge 4 commits into
mainfrom
feat/share-composite-modification

Conversation

@flomillot

Copy link
Copy Markdown
Contributor

Adds POST /v1/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications/{modificationUuid}/share?name=&description=&parentDirectoryUuid=, which moves a composite modification of a node out of the study into a directory of GridExplore, and replaces it in the node by a reference to this now shared modification.

The write permission on the target directory and the uniqueness of the name are checked before anything is moved. The composite is then extracted by the network modification server — keeping its uuid — stored as a MODIFICATION element of the directory server, and referenced from the node.

Since the applied modifications are left unchanged, the node is not invalidated: only the modifications update notifications are emitted, so the front refetches the list.

Requires gridsuite/network-modification-server#874.

The composite modification is moved out of the study into a directory of
GridExplore, where it becomes a shared modification, and is replaced in the
node by a reference to it. Since the applied modifications are left
unchanged, the node does not need to be rebuilt.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown

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: 289f1ad7-d94d-47f4-808f-b8ca20b854b5


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.

@GhilesA GhilesA 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.

Just apply the sonar recommandation on QUERY_PARAM_GROUP_UUID

notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids);
}
notificationService.emitElementUpdated(studyUuid, userId);
}

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.

missing catch in case of failures midway !
we have to handle the rollback in case of error

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.

In theory I agree with you but doesn't seem like it's what we do usually in the application. Can you show me where it's done actually in the service, as an exemple ? I mostly see logs.

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
// does not need to be rebuilt
UUID sharedCompositeUuid = networkModificationService.extractCompositeModificationToShare(groupUuid, modificationUuid, name);
directoryService.createElement(parentDirectoryUuid, description, sharedCompositeUuid, name, DirectoryService.MODIFICATION, userId);
directoryService.createsReferencesToSharedComposites(List.of(sharedCompositeUuid), userId, nodeUuid);

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.

if directory server fails to create element and the fails to createsReferencesToSharedComposites
=> orphaned directory element !

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.

Yes, and it's already the case everywhere in Study serverr, see insertCompositeNetworkModifications for instance., which is pretty close.
The rollback is actually not managed in Study server unlike in Explore server (cf executeWithRollback).
I think it need a dedicated technical story.

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.

No dedicated technical story needed here IMO so wrapping createsReferencesToSharedComposites + extractCompositeModificationToShare in a try/catch right after createElement with directoryService.deleteElement in the catch, is enough

@flomillot flomillot Aug 20, 2026

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.

I'll ask a TL about it, because if we do it we should do something like in explore server which is not a quick fix.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@flomillot
flomillot requested a review from ghazwarhili August 20, 2026 09:33
Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
* by a reference to it, so that it can be stored as an element in the directory server.
* @return the uuid of the extracted composite modification
*/
public UUID extractCompositeModificationToShare(@NonNull UUID groupUuid, @NonNull UUID modificationUuid, @NonNull String 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.

why return UUID ?
the implementation of extractCompositeModificationToShare in NetworkModificationRepository return uuid which is always equal to modificationUuid (the composite entity keeps its own id only its container changes )

@flomillot flomillot Aug 20, 2026

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.

It's an API good practice, when you use a POST you always return the ID or the created element.
I hesitated to return the reference modification ID but actually what we create and the most important is the shared modification.

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.

But indeed we don't use this a lot, so maybe I should not return anything.

@GhilesA
GhilesA self-requested a review August 20, 2026 12:54
}

@PostMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/network-modifications/{modificationUuid}/share")
@Operation(summary = "Move a composite modification of the node into a directory, replacing it by a reference to it")

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.

it is about moving or extract or share ?

@operation(summary = "Extract the composite modification and replace it with a reference") it is better ? what do you think

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.

Well when you share a modification you extract it from the node and move it into the directory so all three.
I prefer move for API description however.

@flomillot
flomillot requested a review from ghazwarhili August 20, 2026 14:50
The network modification server does not return it anymore, the composite
modification keeping its uuid when extracted.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@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