@@ -447,7 +447,7 @@ public void duplicateStudyAsync(BasicStudyInfos basicStudyInfos, UUID sourceStud
447
447
StudyEntity duplicatedStudy = duplicateStudy (basicStudyInfos , sourceStudyUuid , userId );
448
448
449
449
getStudyRootNetworks (duplicatedStudy .getId ()).forEach (rootNetworkEntity ->
450
- reindexStudy (duplicatedStudy , rootNetworkEntity .getId ())
450
+ reindexRootNetwork (duplicatedStudy , rootNetworkEntity .getId ())
451
451
);
452
452
} catch (Exception e ) {
453
453
LOGGER .error (e .toString (), e );
@@ -1289,14 +1289,14 @@ public void invalidateStateEstimationStatusOnAllNodes(UUID studyUuid) {
1289
1289
stateEstimationService .invalidateStateEstimationStatus (rootNetworkNodeInfoService .getComputationResultUuids (studyUuid , STATE_ESTIMATION ));
1290
1290
}
1291
1291
1292
- private StudyEntity updateStudyIndexationStatus (StudyEntity studyEntity , StudyIndexationStatus indexationStatus ) {
1293
- studyEntity .setIndexationStatus (indexationStatus );
1294
- notificationService .emitStudyIndexationStatusChanged (studyEntity .getId (), indexationStatus );
1292
+ private StudyEntity updateRootNetworkIndexationStatus (StudyEntity studyEntity , RootNetworkEntity rootNetworkEntity , RootNetworkIndexationStatus indexationStatus ) {
1293
+ rootNetworkEntity .setIndexationStatus (indexationStatus );
1294
+ notificationService .emitRootNetworkIndexationStatusChanged (studyEntity . getId (), rootNetworkEntity .getId (), indexationStatus );
1295
1295
return studyEntity ;
1296
1296
}
1297
1297
1298
- public StudyEntity updateStudyIndexationStatus (UUID studyUuid , StudyIndexationStatus indexationStatus ) {
1299
- return updateStudyIndexationStatus (studyRepository .findById (studyUuid ).orElseThrow (() -> new StudyException (STUDY_NOT_FOUND )), indexationStatus );
1298
+ public StudyEntity updateRootNetworkIndexationStatus (UUID studyUuid , UUID rootNetworkUuid , RootNetworkIndexationStatus indexationStatus ) {
1299
+ return updateRootNetworkIndexationStatus (studyRepository .findById (studyUuid ).orElseThrow (() -> new StudyException (STUDY_NOT_FOUND )), rootNetworkService . getRootNetwork ( rootNetworkUuid ). orElseThrow (() -> new StudyException ( ROOT_NETWORK_NOT_FOUND )), indexationStatus );
1300
1300
}
1301
1301
1302
1302
private StudyEntity saveStudyThenCreateBasicTree (UUID studyUuid , NetworkInfos networkInfos ,
@@ -1316,7 +1316,6 @@ private StudyEntity saveStudyThenCreateBasicTree(UUID studyUuid, NetworkInfos ne
1316
1316
.voltageInitParametersUuid (voltageInitParametersUuid )
1317
1317
.securityAnalysisParametersUuid (securityAnalysisParametersUuid )
1318
1318
.sensitivityAnalysisParametersUuid (sensitivityAnalysisParametersUuid )
1319
- .indexationStatus (StudyIndexationStatus .INDEXED )
1320
1319
.voltageInitParameters (new StudyVoltageInitParametersEntity ())
1321
1320
.networkVisualizationParametersUuid (networkVisualizationParametersUuid )
1322
1321
.dynamicSecurityAnalysisParametersUuid (dynamicSecurityAnalysisParametersUuid )
@@ -1932,37 +1931,39 @@ public void restoreNodes(UUID studyId, List<UUID> nodeIds, UUID anchorNodeId) {
1932
1931
networkModificationTreeService .restoreNode (studyId , nodeIds , anchorNodeId );
1933
1932
}
1934
1933
1935
- private void reindexStudy (StudyEntity study , UUID rootNetworkUuid ) {
1934
+ private void reindexRootNetwork (StudyEntity study , UUID rootNetworkUuid ) {
1936
1935
CreatedStudyBasicInfos studyInfos = toCreatedStudyBasicInfos (study );
1937
- // reindex study in elasticsearch
1936
+ // reindex root network for study in elasticsearch
1938
1937
studyInfosService .recreateStudyInfos (studyInfos );
1938
+ RootNetworkEntity rootNetwork = rootNetworkService .getRootNetwork (rootNetworkUuid ).orElseThrow (() -> new StudyException (ROOT_NETWORK_NOT_FOUND ));
1939
1939
1940
1940
// Reset indexation status
1941
- updateStudyIndexationStatus (study , StudyIndexationStatus .INDEXING_ONGOING );
1941
+ updateRootNetworkIndexationStatus (study , rootNetwork , RootNetworkIndexationStatus .INDEXING_ONGOING );
1942
1942
try {
1943
1943
networkConversionService .reindexStudyNetworkEquipments (rootNetworkService .getNetworkUuid (rootNetworkUuid ));
1944
- updateStudyIndexationStatus (study , StudyIndexationStatus .INDEXED );
1944
+ updateRootNetworkIndexationStatus (study , rootNetwork , RootNetworkIndexationStatus .INDEXED );
1945
1945
} catch (Exception e ) {
1946
1946
// Allow to retry indexation
1947
- updateStudyIndexationStatus (study , StudyIndexationStatus .NOT_INDEXED );
1947
+ updateRootNetworkIndexationStatus (study , rootNetwork , RootNetworkIndexationStatus .NOT_INDEXED );
1948
1948
throw e ;
1949
1949
}
1950
1950
LOGGER .info ("Study with id = '{}' has been reindexed" , study .getId ());
1951
1951
}
1952
1952
1953
1953
@ Transactional
1954
- public void reindexStudy (UUID studyUuid , UUID rootNetworkUuid ) {
1955
- reindexStudy (studyRepository .findById (studyUuid ).orElseThrow (() -> new StudyException (STUDY_NOT_FOUND )), rootNetworkUuid );
1954
+ public void reindexRootNetwork (UUID studyUuid , UUID rootNetworkUuid ) {
1955
+ reindexRootNetwork (studyRepository .findById (studyUuid ).orElseThrow (() -> new StudyException (STUDY_NOT_FOUND )), rootNetworkUuid );
1956
1956
}
1957
1957
1958
1958
@ Transactional
1959
- public StudyIndexationStatus getStudyIndexationStatus (UUID studyUuid , UUID rootNetworkUuid ) {
1959
+ public RootNetworkIndexationStatus getRootNetworkIndexationStatus (UUID studyUuid , UUID rootNetworkUuid ) {
1960
1960
StudyEntity study = studyRepository .findById (studyUuid ).orElseThrow (() -> new StudyException (STUDY_NOT_FOUND ));
1961
- if (study .getIndexationStatus () == StudyIndexationStatus .INDEXED
1961
+ RootNetworkEntity rootNetwork = rootNetworkService .getRootNetwork (rootNetworkUuid ).orElseThrow (() -> new StudyException (ROOT_NETWORK_NOT_FOUND ));
1962
+ if (rootNetwork .getIndexationStatus () == RootNetworkIndexationStatus .INDEXED
1962
1963
&& !networkConversionService .checkStudyIndexationStatus (rootNetworkService .getNetworkUuid (rootNetworkUuid ))) {
1963
- updateStudyIndexationStatus (study , StudyIndexationStatus .NOT_INDEXED );
1964
+ updateRootNetworkIndexationStatus (study , rootNetwork , RootNetworkIndexationStatus .NOT_INDEXED );
1964
1965
}
1965
- return study .getIndexationStatus ();
1966
+ return rootNetwork .getIndexationStatus ();
1966
1967
}
1967
1968
1968
1969
@ Transactional
0 commit comments