Skip to content

Add loaded status by root network - #1072

Open
ghazwarhili wants to merge 13 commits into
mainfrom
add-loaded-status-by-root-network
Open

Add loaded status by root network#1072
ghazwarhili wants to merge 13 commits into
mainfrom
add-loaded-status-by-root-network

Conversation

@ghazwarhili

@ghazwarhili ghazwarhili commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

PR Summary

NetworkLoadStatus enum (LOADED, LOADING, UNLOADED) and a network_load_status column on root_network (migration, default LOADED for existing rows)
Two new supervision endpoints:

  • GET /supervision/studies/loaded — study is returned if at least one of its root networks is LOADED
  • GET /supervision/studies/unloaded — study is returned only if all of its root networks are UNLOADED

invalidateStudyRootNetwork gained a skipElementUpdatedNotification parameter, letting a caller unbuild/clean up a root network without firing the element.update notification that bumps lastModificationDate in directory-server

new root network -> LOADED ==> Entity default set once the network import has actually succeeded
LOADED/UNLOADED -> LOADING ==> recreateNetwork (reopening a study whose network was unloaded)
LOADING -> LOADED ==> Async case-import success (ConsumerService, NETWORK_RECREATION)
LOADING -> UNLOADED ==> Case-import failure
LOADED -> UNLOADED ==> invalidateStudyRootNetwork

DELETE /supervision/studies/{id}/invalidate -> for each root network: unbuild all nodes, delete the network from network-store, networkLoadStatus -> UNLOADED, called with skipElementUpdatedNotification=true so no element.update message is sent lastModificationDate in directory-server is untouched

GET /supervision/studies/unloaded will now include this study once every root network is UNLOADED

@coderabbitai

coderabbitai Bot commented Aug 25, 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: 79363976-c484-4873-b72f-9910c4898c20


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.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
72.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

public enum NetworkLoadStatus {
LOADED,
UNLOADED,
LOADING,

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.

to remove

private RootNetworkIndexationStatus indexationStatus = RootNetworkIndexationStatus.NOT_INDEXED;

@Enumerated(EnumType.STRING)
@Column(name = "network_load_status")

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.

Suggested change
@Column(name = "network_load_status")
@Column(name = "load_status")

/**
* @author Ghazwa Rehili <ghazwa.rehili at rte-france.com>
*/
public enum NetworkLoadStatus {

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.

Suggested change
public enum NetworkLoadStatus {
public enum RootNetworkLoadStatus {

@Enumerated(EnumType.STRING)
@Column(name = "network_load_status")
@Builder.Default
private NetworkLoadStatus networkLoadStatus = NetworkLoadStatus.LOADED;

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.

Suggested change
private NetworkLoadStatus networkLoadStatus = NetworkLoadStatus.LOADED;
private NetworkLoadStatus loadStatus = NetworkLoadStatus.LOADED;

removeReimportCaseActivity(studyUuid, rootNetworkUuid);
}
if (!success && caseImportAction == CaseImportAction.NETWORK_RECREATION) {
rootNetworkService.updateNetworkLoadStatusIfCurrent(rootNetworkUuid, NetworkLoadStatus.LOADING, NetworkLoadStatus.UNLOADED);

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.

Too complicated. Just set to LOADED after network recreation

if (receiver.getCaseImportAction() == CaseImportAction.ROOT_NETWORK_MODIFICATION) {
removeReimportCaseActivity(receiver.getStudyUuid(), receiver.getRootNetworkUuid());
}
if (receiver.getCaseImportAction() == CaseImportAction.NETWORK_RECREATION) {

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.

Here it's a fail. Just set to UNLOADED if UNLOADING

}

@Transactional
public void updateNetworkLoadStatusIfCurrent(UUID rootNetworkUuid, NetworkLoadStatus expectedCurrentStatus, NetworkLoadStatus networkLoadStatus) {

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.

To remove


persistNetwork(rootNetworkInfos, studyUuid, null, userId, importParametersToUse, CaseImportAction.NETWORK_RECREATION, reportId);
notificationService.emitElementUpdated(studyUuid, userId);
rootNetworkService.updateNetworkLoadStatus(rootNetworkInfos.getId(), NetworkLoadStatus.LOADING);

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.

All changes here to remove. We don't use LOADING

RootNetworkEntity rootNetworkEntity = rootNetworkService.getRootNetwork(rootNetworkUuid).orElseThrow(() -> new StudyException(NOT_FOUND, "Root network not found"));

rootNetworkService.updateNetwork(rootNetworkEntity, networkInfos);
rootNetworkEntity.setNetworkLoadStatus(NetworkLoadStatus.LOADED);

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 do you need this ?

.toList();
CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new)).join();
notificationService.emitElementUpdated(studyUuid, userId);
boolean allRootNetworkLoaded = rootNetworkIds.stream()

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 "at least one network is loaded", then you notify. Not needed to be all LOADED

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