From aa44950adcf82262cf3d777cfa0e1fdd7f67e1b1 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 24 Apr 2025 11:36:46 +0200 Subject: [PATCH 01/18] Refactoring: setUp. Signed-off-by: AAJELLAL --- .../NetworkModificationTreeService.java | 17 +++++ .../service/RootNetworkNodeInfoService.java | 73 +++++++++++++++++++ .../study/server/service/StudyService.java | 48 +++++++++++- 3 files changed, 136 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index a8b853c3d..3d09f3d8a 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -816,6 +816,23 @@ public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boole notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); } + @Transactional + // old name: invalidateBuildOfNodeOnly + public void unbuild(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + final List changedNodes = new ArrayList<>(); + changedNodes.add(nodeUuid); + UUID studyId = self.getStudyUuidForNodeId(nodeUuid); + + nodesRepository.findById(nodeUuid).ifPresent(nodeEntity -> { + if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION) && rootNetworkService.exists(rootNetworkUuid)) { + rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, invalidateNodeInfos, changedNodes); + } + } + ); + + notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); + } + private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, List changedNodes, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { nodesRepository.findAllByParentNodeIdNode(nodeUuid) diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 0f2733506..774be2753 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -259,6 +259,39 @@ public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUu } } + //old name : invalidateRootNetworkNodeInfoProper + public void unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, InvalidateNodeInfos invalidateNodeInfos, List changedNodes) { + RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); + // No need to invalidate a node with a status different of "BUILT" + if (rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { + + fillUnbuildRootNetworkNodeInfos(nodeUuid, rootNetworUuid, invalidateNodeInfos); + invalidateRootNetworkNodeInfoBuildStatus(nodeUuid, rootNetworkNodeInfoEntity, changedNodes); + + rootNetworkNodeInfoEntity.setLoadFlowResultUuid(null); + rootNetworkNodeInfoEntity.setSecurityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setSensitivityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setNonEvacuatedEnergyResultUuid(null); + rootNetworkNodeInfoEntity.setShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setOneBusShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSimulationResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSecurityAnalysisResultUuid(null); + //TODO: add more checks for Voltage init + rootNetworkNodeInfoEntity.setVoltageInitResultUuid(null); + rootNetworkNodeInfoEntity.setStateEstimationResultUuid(null); + + // we want to keep only voltage initialization report if deleteVoltageInitResults is false + Map computationReports = rootNetworkNodeInfoEntity.getComputationReports() + .entrySet() + .stream() + .filter(entry -> VOLTAGE_INITIALIZATION.name().equals(entry.getKey())) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + // Update the computation reports in the repository + rootNetworkNodeInfoEntity.setComputationReports(computationReports); + } + } + private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, boolean deleteVoltageInitResults) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); @@ -298,6 +331,46 @@ private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, Invali .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); } + //oldName: fillInvalidateNodeInfos + private void fillUnbuildRootNetworkNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); + + // we want to delete associated report and variant in this case + rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); + invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); + + // TODO: we want to delete associated computation reports except for voltage initialization : only if deleteVoltageInitResults is true + rootNetworkNodeInfoEntity.getComputationReports().forEach((key, value) -> { + invalidateNodeInfos.addReportUuid(value); + }); + + fillComputationResultUuid(rootNetworkNodeInfoEntity, invalidateNodeInfos); + } + + private void fillComputationResultUuid(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, LOAD_FLOW)) + .ifPresent(invalidateNodeInfos::addLoadFlowResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SECURITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addSecurityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SENSITIVITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addSensitivityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, NON_EVACUATED_ENERGY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addNonEvacuatedEnergyResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SHORT_CIRCUIT)) + .ifPresent(invalidateNodeInfos::addShortCircuitAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SHORT_CIRCUIT_ONE_BUS)) + .ifPresent(invalidateNodeInfos::addOneBusShortCircuitAnalysisResultUuid); + //TODO: add more checks later for voltage init + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, VOLTAGE_INITIALIZATION)) + .ifPresent(invalidateNodeInfos::addVoltageInitResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, DYNAMIC_SIMULATION)) + .ifPresent(invalidateNodeInfos::addDynamicSimulationResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, DYNAMIC_SECURITY_ANALYSIS)) + .ifPresent(invalidateNodeInfos::addDynamicSecurityAnalysisResultUuid); + Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, STATE_ESTIMATION)) + .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); + } + public Optional getRootNetworkNodeInfo(UUID nodeUuid, UUID rootNetworkUuid) { return rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworkUuid); } diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 11d549084..c04838981 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1600,7 +1600,8 @@ private void assertCanBuildNode(@NonNull UUID studyUuid, @NonNull UUID rootNetwo @Transactional public void unbuildNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { - invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); + // invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); + unbuildStudyNode(studyUuid, nodeUuid, rootNetworkUuid); emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); } @@ -1638,7 +1639,8 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); } else { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) + //invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) + unbuildStudyNode(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId()) ); } notificationService.emitElementUpdated(studyUuid, userId); @@ -1724,6 +1726,48 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, } } + //OldName: invalidateBuild + public void unbuildStudyNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + AtomicReference startTime = new AtomicReference<>(null); + startTime.set(System.nanoTime()); + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); + + networkModificationTreeService.unbuild(nodeUuid, rootNetworkUuid, invalidateNodeInfos); + deleteNodeResults(invalidateNodeInfos); + + if (startTime.get() != null) { + LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + } + } + + public void deleteNodeResults(InvalidateNodeInfos invalidateNodeInfos) { + CompletableFuture executeInParallel = CompletableFuture.allOf( + studyServerExecutionService.runAsync(() -> reportService.deleteReports(invalidateNodeInfos.getReportUuids())), + studyServerExecutionService.runAsync(() -> loadflowService.deleteLoadFlowResults(invalidateNodeInfos.getLoadFlowResultUuids())), + studyServerExecutionService.runAsync(() -> securityAnalysisService.deleteSecurityAnalysisResults(invalidateNodeInfos.getSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> sensitivityAnalysisService.deleteSensitivityAnalysisResults(invalidateNodeInfos.getSensitivityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> nonEvacuatedEnergyService.deleteNonEvacuatedEnergyResults(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> voltageInitService.deleteVoltageInitResults(invalidateNodeInfos.getVoltageInitResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSimulationService.deleteResults(invalidateNodeInfos.getDynamicSimulationResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSecurityAnalysisService.deleteResults(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> stateEstimationService.deleteStateEstimationResults(invalidateNodeInfos.getStateEstimationResultUuids())), + studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())) + ); + try { + executeInParallel.get(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new StudyException(INVALIDATE_BUILD_FAILED, e.getMessage()); + } catch (Exception e) { + throw new StudyException(INVALIDATE_BUILD_FAILED, e.getMessage()); + } + + } + private void updateStatuses(UUID studyUuid, UUID nodeUuid) { updateStatuses(studyUuid, nodeUuid, true); } From 1d4de9146f31d2d11209daf030b271addad8d18f Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 24 Apr 2025 11:51:09 +0200 Subject: [PATCH 02/18] fix merge conflict Signed-off-by: AAJELLAL --- .../service/NetworkModificationTreeService.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 242d34da2..868a0f996 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -904,9 +904,20 @@ public void unbuild(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos inv } ); + handleElasticsearchNodeModifications(nodeUuid, rootNetworkUuid, invalidateNodeInfos); notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); } + private void handleElasticsearchNodeModifications(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + // when manually invalidating a single node, if this node does not have any built children + // we need to invalidate indexed modifications up to it's last built parent, not included + if (!hasAnyBuiltChildren(getNodeEntity(nodeUuid), rootNetworkUuid)) { + // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch + NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); + fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + } + } + private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, List changedNodes, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { nodesRepository.findAllByParentNodeIdNode(nodeUuid) From 734df7fc9ebb021a065407624c4d6319cf3e591f Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Thu, 24 Apr 2025 17:59:43 +0200 Subject: [PATCH 03/18] refacto stashedNode Signed-off-by: AAJELLAL --- .../study/server/service/StudyService.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 7c6f9efd9..39a066c21 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1769,6 +1769,24 @@ public void deleteNodeResults(InvalidateNodeInfos invalidateNodeInfos) { } + //OldName: invalidateBuild part 2 + // this is used to unbuild the node and its children + public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + AtomicReference startTime = new AtomicReference<>(null); + startTime.set(System.nanoTime()); + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); + + //TODO: change invalidateBuild methode later + networkModificationTreeService.invalidateBuild(nodeUuid, rootNetworkUuid, false, invalidateNodeInfos, true); + deleteNodeResults(invalidateNodeInfos); + + if (startTime.get() != null) { + LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + } + } + private void updateStatuses(UUID studyUuid, UUID nodeUuid) { updateStatuses(studyUuid, nodeUuid, true); } @@ -1957,9 +1975,7 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateBuild(studyUuid, nodeId, rootNetworkEntity.getId(), false, !invalidateChildrenBuild, true) - ); + unbuildStashedNode(studyUuid, nodeId, invalidateChildrenBuild); networkModificationTreeService.doStashNode(nodeId, stashChildren); if (startTime.get() != null) { @@ -1970,6 +1986,23 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String notificationService.emitElementUpdated(studyUuid, userId); } + public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildren) { + //two case scenario: + // one node stashed -> unbuild the node + // a node and its children are stashed -> unbuild all of them + boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); + List studyRootNetworks = getStudyRootNetworks(studyUuid); + if (invalidateChildrenBuild) { + studyRootNetworks.forEach(rootNetworkEntity -> { + unbuildNodeTree(studyUuid, nodeId, rootNetworkEntity.getId()); + }); + } else { + studyRootNetworks.forEach(rootNetworkEntity -> { + unbuildStudyNode(studyUuid, nodeId, rootNetworkEntity.getId()); + }); + } + } + public List> getStashedNodes(UUID studyId) { return networkModificationTreeService.getStashedNodes(studyId); } From e3f34af1a8868a8d43b79759a6919fda428b6954 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Mon, 28 Apr 2025 15:14:48 +0200 Subject: [PATCH 04/18] Rename node unbuilding methods Signed-off-by: Slimane AMAR --- .../study/server/StudyController.java | 2 +- .../NetworkModificationTreeService.java | 38 +++---- .../service/RootNetworkNodeInfoService.java | 100 ++++++++++-------- .../study/server/service/StudyService.java | 50 ++++----- 4 files changed, 99 insertions(+), 91 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/StudyController.java b/src/main/java/org/gridsuite/study/server/StudyController.java index 909490895..db21d10e5 100644 --- a/src/main/java/org/gridsuite/study/server/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/StudyController.java @@ -1536,7 +1536,7 @@ public ResponseEntity buildNode(@Parameter(description = "Study uuid") @Pa public ResponseEntity unbuildNode(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "rootNetworkUuid") @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, @Parameter(description = "nodeUuid") @PathVariable("nodeUuid") UUID nodeUuid) { - studyService.unbuildNode(studyUuid, nodeUuid, rootNetworkUuid); + studyService.unbuildStudyNode(studyUuid, nodeUuid, rootNetworkUuid); return ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 868a0f996..ed7907440 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -816,6 +816,20 @@ private void fillIndexedModificationsInfosToInvalidate(InvalidateNodeInfos inval } } + @Transactional + // old name: invalidateBuildOfNodeOnly + public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { + NodeEntity nodeEntity = getNodeEntity(nodeUuid); + + InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid); + + fillIndexedModificationsInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); + + notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), List.of(nodeUuid), rootNetworkUuid); + + return invalidateNodeInfos; + } + @Transactional // method used when moving a node to invalidate it without impacting other nodes public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { @@ -890,30 +904,12 @@ && hasAnyBuiltChildren(child, rootNetworkUuid, checkedChildren)) { return false; } - @Transactional - // old name: invalidateBuildOfNodeOnly - public void unbuild(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { - final List changedNodes = new ArrayList<>(); - changedNodes.add(nodeUuid); - UUID studyId = self.getStudyUuidForNodeId(nodeUuid); - - nodesRepository.findById(nodeUuid).ifPresent(nodeEntity -> { - if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION) && rootNetworkService.exists(rootNetworkUuid)) { - rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, invalidateNodeInfos, changedNodes); - } - } - ); - - handleElasticsearchNodeModifications(nodeUuid, rootNetworkUuid, invalidateNodeInfos); - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); - } - - private void handleElasticsearchNodeModifications(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + private void fillIndexedModificationsInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { // when manually invalidating a single node, if this node does not have any built children // we need to invalidate indexed modifications up to it's last built parent, not included - if (!hasAnyBuiltChildren(getNodeEntity(nodeUuid), rootNetworkUuid)) { + if (!hasAnyBuiltChildren(nodeEntity, rootNetworkUuid)) { // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch - NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); + NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeEntity.getIdNode(), rootNetworkUuid); fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } } diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 774be2753..91c1cbeab 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -224,6 +224,42 @@ public void fillDeleteNodeInfo(UUID nodeUuid, DeleteNodeInfos deleteNodeInfos) { }); } + //old name : invalidateRootNetworkNodeInfoProper + public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid) { + RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); + + // No need to invalidate a node with a status different of "BUILT" + if (!rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { + return new InvalidateNodeInfos(); + } + + InvalidateNodeInfos invalidateNodeInfos = getInvalidationInfos(rootNetworkNodeInfoEntity); + + invalidateBuildStatus(rootNetworkNodeInfoEntity); + + invalidateComputationResults(rootNetworkNodeInfoEntity); + + return invalidateNodeInfos; + } + + private static void invalidateComputationResults(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + rootNetworkNodeInfoEntity.setLoadFlowResultUuid(null); + rootNetworkNodeInfoEntity.setSecurityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setSensitivityAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setNonEvacuatedEnergyResultUuid(null); + rootNetworkNodeInfoEntity.setShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setOneBusShortCircuitAnalysisResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSimulationResultUuid(null); + rootNetworkNodeInfoEntity.setDynamicSecurityAnalysisResultUuid(null); + //TODO: add more checks for Voltage init + rootNetworkNodeInfoEntity.setVoltageInitResultUuid(null); + rootNetworkNodeInfoEntity.setStateEstimationResultUuid(null); + + // Update the computation reports in the repository + //TODO: add more checks for Voltage init + rootNetworkNodeInfoEntity.setModificationReports(new HashMap<>()); + } + public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, List changedNodes, boolean deleteVoltageInitResults) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); @@ -259,37 +295,21 @@ public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUu } } - //old name : invalidateRootNetworkNodeInfoProper - public void unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, InvalidateNodeInfos invalidateNodeInfos, List changedNodes) { - RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); - // No need to invalidate a node with a status different of "BUILT" - if (rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { + //oldName: fillInvalidateNodeInfos + private InvalidateNodeInfos getInvalidationInfos(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); - fillUnbuildRootNetworkNodeInfos(nodeUuid, rootNetworUuid, invalidateNodeInfos); - invalidateRootNetworkNodeInfoBuildStatus(nodeUuid, rootNetworkNodeInfoEntity, changedNodes); + rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); - rootNetworkNodeInfoEntity.setLoadFlowResultUuid(null); - rootNetworkNodeInfoEntity.setSecurityAnalysisResultUuid(null); - rootNetworkNodeInfoEntity.setSensitivityAnalysisResultUuid(null); - rootNetworkNodeInfoEntity.setNonEvacuatedEnergyResultUuid(null); - rootNetworkNodeInfoEntity.setShortCircuitAnalysisResultUuid(null); - rootNetworkNodeInfoEntity.setOneBusShortCircuitAnalysisResultUuid(null); - rootNetworkNodeInfoEntity.setDynamicSimulationResultUuid(null); - rootNetworkNodeInfoEntity.setDynamicSecurityAnalysisResultUuid(null); - //TODO: add more checks for Voltage init - rootNetworkNodeInfoEntity.setVoltageInitResultUuid(null); - rootNetworkNodeInfoEntity.setStateEstimationResultUuid(null); + invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); - // we want to keep only voltage initialization report if deleteVoltageInitResults is false - Map computationReports = rootNetworkNodeInfoEntity.getComputationReports() - .entrySet() - .stream() - .filter(entry -> VOLTAGE_INITIALIZATION.name().equals(entry.getKey())) - .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + rootNetworkNodeInfoEntity.getComputationReports().forEach((key, value) -> + invalidateNodeInfos.addReportUuid(value) + ); - // Update the computation reports in the repository - rootNetworkNodeInfoEntity.setComputationReports(computationReports); - } + fillComputationResultUuids(rootNetworkNodeInfoEntity, invalidateNodeInfos); + + return invalidateNodeInfos; } private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, @@ -331,23 +351,7 @@ private void fillInvalidateNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, Invali .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); } - //oldName: fillInvalidateNodeInfos - private void fillUnbuildRootNetworkNodeInfos(UUID nodeUuid, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { - RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); - - // we want to delete associated report and variant in this case - rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); - invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); - - // TODO: we want to delete associated computation reports except for voltage initialization : only if deleteVoltageInitResults is true - rootNetworkNodeInfoEntity.getComputationReports().forEach((key, value) -> { - invalidateNodeInfos.addReportUuid(value); - }); - - fillComputationResultUuid(rootNetworkNodeInfoEntity, invalidateNodeInfos); - } - - private void fillComputationResultUuid(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { + private void fillComputationResultUuids(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, LOAD_FLOW)) .ifPresent(invalidateNodeInfos::addLoadFlowResultUuid); Optional.ofNullable(getComputationResultUuid(rootNetworkNodeInfoEntity, SECURITY_ANALYSIS)) @@ -371,6 +375,7 @@ private void fillComputationResultUuid(RootNetworkNodeInfoEntity rootNetworkNode .ifPresent(invalidateNodeInfos::addStateEstimationResultUuid); } + // TODO : Remove optionnal and throws ROOT_NETWORK_NOT_FOUND exception public Optional getRootNetworkNodeInfo(UUID nodeUuid, UUID rootNetworkUuid) { return rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworkUuid); } @@ -421,6 +426,13 @@ private void addLink(NetworkModificationNodeInfoEntity nodeInfoEntity, RootNetwo rootNetworkNodeInfoRepository.save(rootNetworkNodeInfoEntity); } + //oldName: invalidateRootNetworkNodeInfoBuildStatus + private static void invalidateBuildStatus(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + rootNetworkNodeInfoEntity.setNodeBuildStatus(NodeBuildStatusEmbeddable.from(BuildStatus.NOT_BUILT)); + rootNetworkNodeInfoEntity.setVariantId(UUID.randomUUID().toString()); + rootNetworkNodeInfoEntity.setModificationReports(new HashMap<>(Map.of(rootNetworkNodeInfoEntity.getNodeInfo().getId(), UUID.randomUUID()))); + } + private static void invalidateRootNetworkNodeInfoBuildStatus(UUID nodeUuid, RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, List changedNodes) { if (!rootNetworkNodeInfoEntity.getNodeBuildStatus().toDto().isBuilt()) { return; diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 39a066c21..992a49557 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1599,9 +1599,8 @@ private void assertCanBuildNode(@NonNull UUID studyUuid, @NonNull UUID rootNetwo } @Transactional - public void unbuildNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { - // invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); - unbuildStudyNode(studyUuid, nodeUuid, rootNetworkUuid); + public void unbuildStudyNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { + unbuildNode(studyUuid, nodeUuid, rootNetworkUuid); emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); } @@ -1639,8 +1638,7 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); } else { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - //invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) - unbuildStudyNode(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId()) + invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) ); } notificationService.emitElementUpdated(studyUuid, userId); @@ -1728,35 +1726,36 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, } //OldName: invalidateBuild - public void unbuildStudyNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNode(nodeUuid, rootNetworkUuid); invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); - networkModificationTreeService.unbuild(nodeUuid, rootNetworkUuid, invalidateNodeInfos); - deleteNodeResults(invalidateNodeInfos); + deleteInvalidationInfos(invalidateNodeInfos); if (startTime.get() != null) { LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, - TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); } } - public void deleteNodeResults(InvalidateNodeInfos invalidateNodeInfos) { + public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { CompletableFuture executeInParallel = CompletableFuture.allOf( - studyServerExecutionService.runAsync(() -> reportService.deleteReports(invalidateNodeInfos.getReportUuids())), - studyServerExecutionService.runAsync(() -> loadflowService.deleteLoadFlowResults(invalidateNodeInfos.getLoadFlowResultUuids())), - studyServerExecutionService.runAsync(() -> securityAnalysisService.deleteSecurityAnalysisResults(invalidateNodeInfos.getSecurityAnalysisResultUuids())), - studyServerExecutionService.runAsync(() -> sensitivityAnalysisService.deleteSensitivityAnalysisResults(invalidateNodeInfos.getSensitivityAnalysisResultUuids())), - studyServerExecutionService.runAsync(() -> nonEvacuatedEnergyService.deleteNonEvacuatedEnergyResults(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids())), - studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getShortCircuitAnalysisResultUuids())), - studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids())), - studyServerExecutionService.runAsync(() -> voltageInitService.deleteVoltageInitResults(invalidateNodeInfos.getVoltageInitResultUuids())), - studyServerExecutionService.runAsync(() -> dynamicSimulationService.deleteResults(invalidateNodeInfos.getDynamicSimulationResultUuids())), - studyServerExecutionService.runAsync(() -> dynamicSecurityAnalysisService.deleteResults(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids())), - studyServerExecutionService.runAsync(() -> stateEstimationService.deleteStateEstimationResults(invalidateNodeInfos.getStateEstimationResultUuids())), - studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())) + studyServerExecutionService.runAsync(() -> networkModificationService.deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), invalidateNodeInfos.getNetworkUuid())), + studyServerExecutionService.runAsync(() -> networkStoreService.deleteVariants(invalidateNodeInfos.getNetworkUuid(), invalidateNodeInfos.getVariantIds())), + studyServerExecutionService.runAsync(() -> reportService.deleteReports(invalidateNodeInfos.getReportUuids())), + studyServerExecutionService.runAsync(() -> loadflowService.deleteLoadFlowResults(invalidateNodeInfos.getLoadFlowResultUuids())), + studyServerExecutionService.runAsync(() -> securityAnalysisService.deleteSecurityAnalysisResults(invalidateNodeInfos.getSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> sensitivityAnalysisService.deleteSensitivityAnalysisResults(invalidateNodeInfos.getSensitivityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> nonEvacuatedEnergyService.deleteNonEvacuatedEnergyResults(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> shortCircuitService.deleteShortCircuitAnalysisResults(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> voltageInitService.deleteVoltageInitResults(invalidateNodeInfos.getVoltageInitResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSimulationService.deleteResults(invalidateNodeInfos.getDynamicSimulationResultUuids())), + studyServerExecutionService.runAsync(() -> dynamicSecurityAnalysisService.deleteResults(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids())), + studyServerExecutionService.runAsync(() -> stateEstimationService.deleteStateEstimationResults(invalidateNodeInfos.getStateEstimationResultUuids())) ); try { executeInParallel.get(); @@ -1779,7 +1778,7 @@ public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) //TODO: change invalidateBuild methode later networkModificationTreeService.invalidateBuild(nodeUuid, rootNetworkUuid, false, invalidateNodeInfos, true); - deleteNodeResults(invalidateNodeInfos); + deleteInvalidationInfos(invalidateNodeInfos); if (startTime.get() != null) { LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, @@ -1974,6 +1973,7 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); + boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); unbuildStashedNode(studyUuid, nodeId, invalidateChildrenBuild); networkModificationTreeService.doStashNode(nodeId, stashChildren); @@ -1998,7 +1998,7 @@ public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildre }); } else { studyRootNetworks.forEach(rootNetworkEntity -> { - unbuildStudyNode(studyUuid, nodeId, rootNetworkEntity.getId()); + unbuildNode(studyUuid, nodeId, rootNetworkEntity.getId()); }); } } From 457ef475feb6e84b6b8ab18f187af868a784bbf5 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Mon, 28 Apr 2025 17:55:37 +0200 Subject: [PATCH 05/18] Unbuild a subtree Signed-off-by: Slimane AMAR --- .../study/server/dto/InvalidateNodeInfos.java | 37 +++++++--- .../NetworkModificationTreeService.java | 74 ++++++++++++++++--- .../study/server/service/StudyService.java | 39 +++++----- .../server/service/SupervisionService.java | 2 +- 4 files changed, 112 insertions(+), 40 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java index aca6b1b5e..f74503b6c 100644 --- a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java @@ -24,29 +24,24 @@ public class InvalidateNodeInfos { private UUID networkUuid; - private List reportUuids = new ArrayList<>(); + private List nodeUuids = new ArrayList<>(); + private List groupUuids = new ArrayList<>(); + private List reportUuids = new ArrayList<>(); private List variantIds = new ArrayList<>(); private List loadFlowResultUuids = new ArrayList<>(); - private List securityAnalysisResultUuids = new ArrayList<>(); - private List sensitivityAnalysisResultUuids = new ArrayList<>(); private List nonEvacuatedEnergyResultUuids = new ArrayList<>(); - private List shortCircuitAnalysisResultUuids = new ArrayList<>(); private List oneBusShortCircuitAnalysisResultUuids = new ArrayList<>(); - private List voltageInitResultUuids = new ArrayList<>(); + private List stateEstimationResultUuids = new ArrayList<>(); private List dynamicSimulationResultUuids = new ArrayList<>(); private List dynamicSecurityAnalysisResultUuids = new ArrayList<>(); - private List stateEstimationResultUuids = new ArrayList<>(); - - private List groupUuids = new ArrayList<>(); - public void addReportUuid(UUID reportUuid) { reportUuids.add(reportUuid); } @@ -98,4 +93,28 @@ public void addStateEstimationResultUuid(UUID stateEstimationResultUuid) { public void addGroupUuid(List groupUuids) { this.groupUuids.addAll(groupUuids); } + + public void addNodeUuid(UUID nodeUuid) { + this.groupUuids.add(nodeUuid); + } + + public void add(InvalidateNodeInfos invalidateNodeInfos) { + nodeUuids.addAll(invalidateNodeInfos.getNodeUuids()); + groupUuids.addAll(invalidateNodeInfos.getGroupUuids()); + + reportUuids.addAll(invalidateNodeInfos.getReportUuids()); + variantIds.addAll(invalidateNodeInfos.getVariantIds()); + + loadFlowResultUuids.addAll(invalidateNodeInfos.getLoadFlowResultUuids()); + securityAnalysisResultUuids.addAll(invalidateNodeInfos.getSecurityAnalysisResultUuids()); + sensitivityAnalysisResultUuids.addAll(invalidateNodeInfos.getSensitivityAnalysisResultUuids()); + nonEvacuatedEnergyResultUuids.addAll(invalidateNodeInfos.getNonEvacuatedEnergyResultUuids()); + shortCircuitAnalysisResultUuids.addAll(invalidateNodeInfos.getShortCircuitAnalysisResultUuids()); + oneBusShortCircuitAnalysisResultUuids.addAll(invalidateNodeInfos.getOneBusShortCircuitAnalysisResultUuids()); + voltageInitResultUuids.addAll(invalidateNodeInfos.getVoltageInitResultUuids()); + stateEstimationResultUuids.addAll(invalidateNodeInfos.getStateEstimationResultUuids()); + + dynamicSimulationResultUuids.addAll(invalidateNodeInfos.getDynamicSimulationResultUuids()); + dynamicSecurityAnalysisResultUuids.addAll(invalidateNodeInfos.getDynamicSecurityAnalysisResultUuids()); + } } diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index ed7907440..f96f0e0a5 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -788,7 +788,7 @@ public void invalidateBuild(UUID nodeUuid, UUID rootNetworkUuid, boolean invalid changedNodes.add(nodeUuid); UUID studyId = self.getStudyUuidForNodeId(nodeUuid); nodesRepository.findById(nodeUuid).ifPresent(nodeEntity -> { - fillIndexedModificationsInfosToInvalidate(invalidateNodeInfos, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); + fillIndexedNodeInfosToInvalidate(invalidateNodeInfos, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); if (rootNetworkService.exists(rootNetworkUuid)) { if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { rootNetworkNodeInfoService.invalidateRootNetworkNodeInfoProper(nodeUuid, rootNetworkUuid, invalidateNodeInfos, invalidateOnlyChildrenBuildStatus, changedNodes, deleteVoltageInitResults); @@ -800,7 +800,7 @@ public void invalidateBuild(UUID nodeUuid, UUID rootNetworkUuid, boolean invalid notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); } - private void fillIndexedModificationsInfosToInvalidate(InvalidateNodeInfos invalidateNodeInfos, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNodeInfos, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { // when invalidating node // we need to invalidate indexed modifications up to it's last built parent, not included boolean isNodeBuilt = self.getNodeBuildStatus(nodeUuid, rootNetworkUuid).isBuilt(); @@ -809,10 +809,10 @@ private void fillIndexedModificationsInfosToInvalidate(InvalidateNodeInfos inval } if (isNodeBuilt && invalidateOnlyChildrenBuildStatus) { - fillIndexedModificationsInfosToInvalidate(nodeUuid, false, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(nodeUuid, false, invalidateNodeInfos); } else { NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } } @@ -823,13 +823,33 @@ public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), List.of(nodeUuid), rootNetworkUuid); return invalidateNodeInfos; } + @Transactional + // old name: invalidateBuild + public InvalidateNodeInfos unbuildNodeTree(UUID nodeUuid, UUID rootNetworkUuid) { + NodeEntity nodeEntity = getNodeEntity(nodeUuid); + + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + + // First node + if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { + invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid); + fillIndexedNodeTreeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); + } + + invalidateNodeInfos.add(unbuildChildrenNodes(nodeUuid, rootNetworkUuid)); + + notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), invalidateNodeInfos.getNodeUuids().stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + + return invalidateNodeInfos; + } + @Transactional // method used when moving a node to invalidate it without impacting other nodes public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { @@ -849,7 +869,7 @@ public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boole if (!hasAnyBuiltChildren(getNodeEntity(nodeUuid), rootNetworkUuid)) { // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeUuid, rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); @@ -904,16 +924,48 @@ && hasAnyBuiltChildren(child, rootNetworkUuid, checkedChildren)) { return false; } - private void fillIndexedModificationsInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + private void fillIndexedNodeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { // when manually invalidating a single node, if this node does not have any built children // we need to invalidate indexed modifications up to it's last built parent, not included - if (!hasAnyBuiltChildren(nodeEntity, rootNetworkUuid)) { - // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch + if (hasAnyBuiltChildren(nodeEntity, rootNetworkUuid)) { + return; + } + + // when invalidating nodes, we need to get last built parent to invalidate all its children modifications in elasticsearch + NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeEntity.getIdNode(), rootNetworkUuid); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + } + + // OldName: fillIndexedModificationsInfosToInvalidate + // For subTree + private void fillIndexedNodeTreeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { + // when invalidating node + // we need to invalidate indexed modifications up to it's last built parent, not included + boolean isNodeBuilt = self.getNodeBuildStatus(nodeEntity.getIdNode(), rootNetworkUuid).isBuilt(); + if (!isNodeBuilt && !hasAnyBuiltChildren(getNodeEntity(nodeEntity.getIdNode()), rootNetworkUuid)) { + return; + } + + // TODO check invalidateOnlyChildrenBuildStatus + if (isNodeBuilt) { + fillIndexedNodeInfosToInvalidate(nodeEntity.getIdNode(), false, invalidateNodeInfos); + } else { NodeEntity closestNodeWithParentHavingBuiltDescendent = getSubTreeToInvalidateIndexedModifications(nodeEntity.getIdNode(), rootNetworkUuid); - fillIndexedModificationsInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); + fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } } + // OldName: invalidateChildrenBuildStatus + private InvalidateNodeInfos unbuildChildrenNodes(UUID nodeUuid, UUID rootNetworkUuid) { + InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); + nodesRepository.findAllByParentNodeIdNode(nodeUuid) + .forEach(child -> { + invalidateNodeInfos.add(rootNetworkNodeInfoService.unbuildRootNetworkNode(child.getIdNode(), rootNetworkUuid)); + invalidateNodeInfos.add(unbuildChildrenNodes(child.getIdNode(), rootNetworkUuid)); + }); + return invalidateNodeInfos; + } + private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, List changedNodes, InvalidateNodeInfos invalidateNodeInfos, boolean deleteVoltageInitResults) { nodesRepository.findAllByParentNodeIdNode(nodeUuid) @@ -1053,7 +1105,7 @@ public long countBuiltNodes(UUID studyUuid, UUID rootNetworkUuid) { return nodes.stream().filter(n -> self.getNodeBuildStatus(n.getIdNode(), rootNetworkUuid).isBuilt()).count(); } - private void fillIndexedModificationsInfosToInvalidate(UUID parentNodeUuid, boolean includeParentNode, InvalidateNodeInfos invalidateNodeInfos) { + private void fillIndexedNodeInfosToInvalidate(UUID parentNodeUuid, boolean includeParentNode, InvalidateNodeInfos invalidateNodeInfos) { List nodesToInvalidate = new ArrayList<>(); if (includeParentNode) { nodesToInvalidate.add(parentNodeUuid); diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index a1f0e1aa6..6c544449d 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1724,7 +1724,8 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, } } - //OldName: invalidateBuild + // OldName: invalidateBuild part 1 + // Only one node private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); @@ -1740,6 +1741,24 @@ private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { } } + // OldName: invalidateBuild part 2 + // This is used to unbuild the node and its children + @Transactional + public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + AtomicReference startTime = new AtomicReference<>(null); + startTime.set(System.nanoTime()); + + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNodeTree(nodeUuid, rootNetworkUuid); + invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); + + deleteInvalidationInfos(invalidateNodeInfos); + + if (startTime.get() != null) { + LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, + TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); + } + } + public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { CompletableFuture executeInParallel = CompletableFuture.allOf( studyServerExecutionService.runAsync(() -> networkModificationService.deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), invalidateNodeInfos.getNetworkUuid())), @@ -1767,24 +1786,6 @@ public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { } - //OldName: invalidateBuild part 2 - // this is used to unbuild the node and its children - public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { - AtomicReference startTime = new AtomicReference<>(null); - startTime.set(System.nanoTime()); - InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); - invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); - - //TODO: change invalidateBuild methode later - networkModificationTreeService.invalidateBuild(nodeUuid, rootNetworkUuid, false, invalidateNodeInfos, true); - deleteInvalidationInfos(invalidateNodeInfos); - - if (startTime.get() != null) { - LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, - TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); - } - } - private void updateStatuses(UUID studyUuid, UUID nodeUuid) { updateStatuses(studyUuid, nodeUuid, true); } diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index 0674bcd59..d9048ac38 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -323,7 +323,7 @@ public void invalidateAllNodesBuilds(UUID studyUuid) { UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); //TODO: to parallelize ? studyService.getExistingBasicRootNetworkInfos(studyUuid).forEach(rootNetwork -> - studyService.invalidateBuild(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid(), false, false, true) + studyService.unbuildNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) ); LOGGER.trace("Nodes builds deletion for study {} in : {} seconds", studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); From a4d35362703a687b0d33aada3789b318b1d88e29 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 11:55:44 +0200 Subject: [PATCH 06/18] handle stashNode an change the stashChildren description. Signed-off-by: AAJELLAL --- .../server/controller/StudyController.java | 2 +- .../study/server/service/StudyService.java | 28 ++++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/controller/StudyController.java b/src/main/java/org/gridsuite/study/server/controller/StudyController.java index 00e0e492e..6c52f0994 100644 --- a/src/main/java/org/gridsuite/study/server/controller/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/controller/StudyController.java @@ -1369,7 +1369,7 @@ public ResponseEntity deleteNode(@Parameter(description = "study uuid") @P @ApiResponse(responseCode = "404", description = "The study or the node not found")}) public ResponseEntity stashNode(@Parameter(description = "study uuid") @PathVariable("studyUuid") UUID studyUuid, @Parameter(description = "id of child to delete (move to trash)") @PathVariable("id") UUID nodeId, - @Parameter(description = "stashChildren") @RequestParam(value = "stashChildren", defaultValue = "false") boolean stashChildren, + @Parameter(description = "to stash a node with its children") @RequestParam(value = "stashChildren", defaultValue = "false") boolean stashChildren, @RequestHeader(HEADER_USER_ID) String userId) { studyService.stashNode(studyUuid, nodeId, stashChildren, userId); return ResponseEntity.ok().build(); diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 6c544449d..56ea5fa52 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1972,8 +1972,9 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - unbuildStashedNode(studyUuid, nodeId, invalidateChildrenBuild); + //boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); + // invalidateBuild(studyUuid, nodeId, rootNetworkEntity.getId(), false, !invalidateChildrenBuild, true) + unbuildStashedNode(studyUuid, nodeId, stashChildren); networkModificationTreeService.doStashNode(nodeId, stashChildren); if (startTime.get() != null) { @@ -1988,17 +1989,18 @@ public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildre //two case scenario: // one node stashed -> unbuild the node // a node and its children are stashed -> unbuild all of them - boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - List studyRootNetworks = getStudyRootNetworks(studyUuid); - if (invalidateChildrenBuild) { - studyRootNetworks.forEach(rootNetworkEntity -> { - unbuildNodeTree(studyUuid, nodeId, rootNetworkEntity.getId()); - }); - } else { - studyRootNetworks.forEach(rootNetworkEntity -> { - unbuildNode(studyUuid, nodeId, rootNetworkEntity.getId()); - }); - } + boolean unbuildChildren = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); + List studyRootNetworks = getStudyRootNetworks(studyUuid).stream() + .map(RootNetworkEntity::getId) + .toList(); + + studyRootNetworks.forEach(rootNetworkId -> { + if (unbuildChildren) { + unbuildNodeTree(studyUuid, nodeId, rootNetworkId); + } else { + unbuildNode(studyUuid, nodeId, rootNetworkId); + } + }); } public List> getStashedNodes(UUID studyId) { From 92df06bb19bde393d7a8f54917e26973ce277c55 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 14:12:54 +0200 Subject: [PATCH 07/18] handle stashNode an change the stashChildren description. Signed-off-by: AAJELLAL --- .../study/server/service/StudyService.java | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 56ea5fa52..b76ec2233 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1743,7 +1743,6 @@ private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { // OldName: invalidateBuild part 2 // This is used to unbuild the node and its children - @Transactional public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); @@ -1972,9 +1971,20 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - //boolean invalidateChildrenBuild = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - // invalidateBuild(studyUuid, nodeId, rootNetworkEntity.getId(), false, !invalidateChildrenBuild, true) - unbuildStashedNode(studyUuid, nodeId, stashChildren); + boolean unbuildChildren = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); + List rootNetworkUuids = getStudyRootNetworks(studyUuid).stream() + .map(RootNetworkEntity::getId) + .toList(); + + if (!unbuildChildren) { + rootNetworkUuids.forEach(rootNetworkId -> + unbuildNodeTree(studyUuid, nodeId, rootNetworkId)); + } else { + rootNetworkUuids.forEach(rootNetworkId -> + unbuildNode(studyUuid, nodeId, rootNetworkId) + ); + } + networkModificationTreeService.doStashNode(nodeId, stashChildren); if (startTime.get() != null) { @@ -1985,24 +1995,6 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String notificationService.emitElementUpdated(studyUuid, userId); } - public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildren) { - //two case scenario: - // one node stashed -> unbuild the node - // a node and its children are stashed -> unbuild all of them - boolean unbuildChildren = stashChildren || networkModificationTreeService.hasModifications(nodeId, false); - List studyRootNetworks = getStudyRootNetworks(studyUuid).stream() - .map(RootNetworkEntity::getId) - .toList(); - - studyRootNetworks.forEach(rootNetworkId -> { - if (unbuildChildren) { - unbuildNodeTree(studyUuid, nodeId, rootNetworkId); - } else { - unbuildNode(studyUuid, nodeId, rootNetworkId); - } - }); - } - public List> getStashedNodes(UUID studyId) { return networkModificationTreeService.getStashedNodes(studyId); } From 6651fac95a063d684e171b96a0ed6a46642bc80b Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 14:24:22 +0200 Subject: [PATCH 08/18] Refactoring the moveStudyNode. Signed-off-by: AAJELLAL --- .../gridsuite/study/server/service/StudyService.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index b76ec2233..9e69503d5 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1622,22 +1622,22 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod List oldChildren = null; checkStudyContainsNode(studyUuid, nodeToMoveUuid); checkStudyContainsNode(studyUuid, referenceNodeUuid); - boolean shouldInvalidateChildren = networkModificationTreeService.hasModifications(nodeToMoveUuid, false); + boolean shouldUnbuildChildren = networkModificationTreeService.hasModifications(nodeToMoveUuid, false); - //Invalidating previous children if necessary - if (shouldInvalidateChildren) { + //Unbuild previous children if necessary + if (shouldUnbuildChildren) { oldChildren = networkModificationTreeService.getChildrenByParentUuid(nodeToMoveUuid); } networkModificationTreeService.moveStudyNode(nodeToMoveUuid, referenceNodeUuid, insertMode); - //Invalidating moved node or new children if necessary - if (shouldInvalidateChildren) { + //Unbuilding moved node or new children if necessary + if (shouldUnbuildChildren) { updateStatuses(studyUuid, nodeToMoveUuid, false, true, true); oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); } else { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateBuild(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId(), false, true, true) + unbuildNode(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId()) ); } notificationService.emitElementUpdated(studyUuid, userId); From 63a003ebab417a5f9a141d2355738a53c8e78b21 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Tue, 29 Apr 2025 14:22:29 +0200 Subject: [PATCH 09/18] Use sets in InvalidateNodeInfos Signed-off-by: Slimane AMAR --- .../study/server/dto/InvalidateNodeInfos.java | 96 +++++++++++++++---- .../NetworkModificationTreeService.java | 6 +- .../service/RootNetworkNodeInfoService.java | 6 +- .../study/server/service/StudyService.java | 5 +- .../server/service/SupervisionService.java | 2 +- 5 files changed, 85 insertions(+), 30 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java index f74503b6c..0314e5b7b 100644 --- a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java @@ -10,37 +10,93 @@ import lombok.NoArgsConstructor; import lombok.Setter; -import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.UUID; /** * @author Nicolas Noir */ - @NoArgsConstructor -@Getter -@Setter public class InvalidateNodeInfos { + @Getter + @Setter private UUID networkUuid; - private List nodeUuids = new ArrayList<>(); - private List groupUuids = new ArrayList<>(); + private Set nodeUuids = new HashSet<>(); + private Set groupUuids = new HashSet<>(); + + private Set reportUuids = new HashSet<>(); + private Set variantIds = new HashSet<>(); + + private Set loadFlowResultUuids = new HashSet<>(); + private Set securityAnalysisResultUuids = new HashSet<>(); + private Set sensitivityAnalysisResultUuids = new HashSet<>(); + private Set nonEvacuatedEnergyResultUuids = new HashSet<>(); + private Set shortCircuitAnalysisResultUuids = new HashSet<>(); + private Set oneBusShortCircuitAnalysisResultUuids = new HashSet<>(); + private Set voltageInitResultUuids = new HashSet<>(); + private Set stateEstimationResultUuids = new HashSet<>(); + + private Set dynamicSimulationResultUuids = new HashSet<>(); + private Set dynamicSecurityAnalysisResultUuids = new HashSet<>(); - private List reportUuids = new ArrayList<>(); - private List variantIds = new ArrayList<>(); + public List getNodeUuids() { + return nodeUuids.stream().toList(); + } + + public List getGroupUuids() { + return groupUuids.stream().toList(); + } - private List loadFlowResultUuids = new ArrayList<>(); - private List securityAnalysisResultUuids = new ArrayList<>(); - private List sensitivityAnalysisResultUuids = new ArrayList<>(); - private List nonEvacuatedEnergyResultUuids = new ArrayList<>(); - private List shortCircuitAnalysisResultUuids = new ArrayList<>(); - private List oneBusShortCircuitAnalysisResultUuids = new ArrayList<>(); - private List voltageInitResultUuids = new ArrayList<>(); - private List stateEstimationResultUuids = new ArrayList<>(); + public List getReportUuids() { + return reportUuids.stream().toList(); + } - private List dynamicSimulationResultUuids = new ArrayList<>(); - private List dynamicSecurityAnalysisResultUuids = new ArrayList<>(); + public List getVariantIds() { + return variantIds.stream().toList(); + } + + public List getLoadFlowResultUuids() { + return loadFlowResultUuids.stream().toList(); + } + + public List getSecurityAnalysisResultUuids() { + return securityAnalysisResultUuids.stream().toList(); + } + + public List getSensitivityAnalysisResultUuids() { + return sensitivityAnalysisResultUuids.stream().toList(); + } + + public List getNonEvacuatedEnergyResultUuids() { + return nonEvacuatedEnergyResultUuids.stream().toList(); + } + + public List getShortCircuitAnalysisResultUuids() { + return shortCircuitAnalysisResultUuids.stream().toList(); + } + + public List getOneBusShortCircuitAnalysisResultUuids() { + return oneBusShortCircuitAnalysisResultUuids.stream().toList(); + } + + public List getVoltageInitResultUuids() { + return voltageInitResultUuids.stream().toList(); + } + + public List getStateEstimationResultUuids() { + return stateEstimationResultUuids.stream().toList(); + } + + public List getDynamicSimulationResultUuids() { + return dynamicSimulationResultUuids.stream().toList(); + } + + public List getDynamicSecurityAnalysisResultUuids() { + return dynamicSecurityAnalysisResultUuids.stream().toList(); + } public void addReportUuid(UUID reportUuid) { reportUuids.add(reportUuid); @@ -51,7 +107,7 @@ public void addVariantId(String variantId) { } public void addLoadFlowResultUuid(UUID loadFlowResultUuid) { - getLoadFlowResultUuids().add(loadFlowResultUuid); + loadFlowResultUuids.add(loadFlowResultUuid); } public void addSecurityAnalysisResultUuid(UUID securityAnalysisResultUuid) { @@ -90,7 +146,7 @@ public void addStateEstimationResultUuid(UUID stateEstimationResultUuid) { stateEstimationResultUuids.add(stateEstimationResultUuid); } - public void addGroupUuid(List groupUuids) { + public void addGroupUuids(List groupUuids) { this.groupUuids.addAll(groupUuids); } diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index f96f0e0a5..c4108a810 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -977,7 +977,6 @@ private void invalidateChildrenBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, @Transactional public void updateNodeBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, NodeBuildStatus nodeBuildStatus) { - List changedNodes = new ArrayList<>(); UUID studyId = self.getStudyUuidForNodeId(nodeUuid); RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoService.getRootNetworkNodeInfo(nodeUuid, rootNetworkUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); NodeEntity nodeEntity = getNodeEntity(nodeUuid); @@ -1003,8 +1002,7 @@ public void updateNodeBuildStatus(UUID nodeUuid, UUID rootNetworkUuid, NodeBuild } rootNetworkNodeInfoEntity.setNodeBuildStatus(newNodeStatus); - changedNodes.add(nodeUuid); - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes, rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, List.of(nodeUuid), rootNetworkUuid); } @Transactional(readOnly = true) @@ -1111,7 +1109,7 @@ private void fillIndexedNodeInfosToInvalidate(UUID parentNodeUuid, boolean inclu nodesToInvalidate.add(parentNodeUuid); } nodesToInvalidate.addAll(getChildren(parentNodeUuid)); - invalidateNodeInfos.addGroupUuid( + invalidateNodeInfos.addGroupUuids( networkModificationNodeInfoRepository.findAllById(nodesToInvalidate).stream() .map(NetworkModificationNodeInfoEntity::getModificationGroupUuid).toList() ); diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 91c1cbeab..66c401726 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -235,7 +235,7 @@ public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetwor InvalidateNodeInfos invalidateNodeInfos = getInvalidationInfos(rootNetworkNodeInfoEntity); - invalidateBuildStatus(rootNetworkNodeInfoEntity); + invalidateBuildStatus(rootNetworkNodeInfoEntity, invalidateNodeInfos); invalidateComputationResults(rootNetworkNodeInfoEntity); @@ -427,10 +427,12 @@ private void addLink(NetworkModificationNodeInfoEntity nodeInfoEntity, RootNetwo } //oldName: invalidateRootNetworkNodeInfoBuildStatus - private static void invalidateBuildStatus(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + private static void invalidateBuildStatus(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { rootNetworkNodeInfoEntity.setNodeBuildStatus(NodeBuildStatusEmbeddable.from(BuildStatus.NOT_BUILT)); rootNetworkNodeInfoEntity.setVariantId(UUID.randomUUID().toString()); rootNetworkNodeInfoEntity.setModificationReports(new HashMap<>(Map.of(rootNetworkNodeInfoEntity.getNodeInfo().getId(), UUID.randomUUID()))); + + invalidateNodeInfos.addNodeUuid(rootNetworkNodeInfoEntity.getNodeInfo().getIdNode()); } private static void invalidateRootNetworkNodeInfoBuildStatus(UUID nodeUuid, RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, List changedNodes) { diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 56ea5fa52..8bd5f6ace 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1743,8 +1743,7 @@ private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { // OldName: invalidateBuild part 2 // This is used to unbuild the node and its children - @Transactional - public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + public void unbuildStudyTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); @@ -1996,7 +1995,7 @@ public void unbuildStashedNode(UUID studyUuid, UUID nodeId, boolean stashChildre studyRootNetworks.forEach(rootNetworkId -> { if (unbuildChildren) { - unbuildNodeTree(studyUuid, nodeId, rootNetworkId); + unbuilStudyTree(studyUuid, nodeId, rootNetworkId); } else { unbuildNode(studyUuid, nodeId, rootNetworkId); } diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index d9048ac38..3755b0eff 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -323,7 +323,7 @@ public void invalidateAllNodesBuilds(UUID studyUuid) { UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); //TODO: to parallelize ? studyService.getExistingBasicRootNetworkInfos(studyUuid).forEach(rootNetwork -> - studyService.unbuildNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) + studyService.unbuildStudyTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) ); LOGGER.trace("Nodes builds deletion for study {} in : {} seconds", studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); From 1eeb82e56694ed738b08e7ba2b275a1139b355ab Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 15:01:42 +0200 Subject: [PATCH 10/18] Refactoring the root network update.. Signed-off-by: AAJELLAL --- .../org/gridsuite/study/server/service/StudyService.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 9e69503d5..d1feaf774 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -382,11 +382,10 @@ public void modifyRootNetwork(UUID studyUuid, RootNetworkInfos rootNetworkInfos, private void postRootNetworkUpdate(UUID studyUuid, UUID rootNetworkUuid, boolean updateCase) { if (updateCase) { Optional rootNetworkModificationRequestEntityOpt = rootNetworkService.getRootNetworkRequest(rootNetworkUuid); - if (rootNetworkModificationRequestEntityOpt.isPresent()) { - rootNetworkService.deleteRootNetworkRequest(rootNetworkModificationRequestEntityOpt.get()); - } + rootNetworkModificationRequestEntityOpt.ifPresent(rootNetworkService::deleteRootNetworkRequest); UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); - invalidateBuild(studyUuid, rootNodeUuid, rootNetworkUuid, false, false, true); + + unbuildNodeTree(studyUuid, rootNodeUuid, rootNetworkUuid); notificationService.emitRootNetworkUpdated(studyUuid, rootNetworkUuid); } else { notificationService.emitRootNetworksUpdated(studyUuid); From f281dd3336b7aaa2b66abdf041bae2f2c252f8a1 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Tue, 29 Apr 2025 15:05:43 +0200 Subject: [PATCH 11/18] Fix stash test Signed-off-by: Slimane AMAR --- .../java/org/gridsuite/study/server/service/StudyService.java | 2 +- .../org/gridsuite/study/server/service/SupervisionService.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 9e69503d5..b3bbb2969 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1976,7 +1976,7 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String .map(RootNetworkEntity::getId) .toList(); - if (!unbuildChildren) { + if (unbuildChildren) { rootNetworkUuids.forEach(rootNetworkId -> unbuildNodeTree(studyUuid, nodeId, rootNetworkId)); } else { diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index 3755b0eff..d9048ac38 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -323,7 +323,7 @@ public void invalidateAllNodesBuilds(UUID studyUuid) { UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); //TODO: to parallelize ? studyService.getExistingBasicRootNetworkInfos(studyUuid).forEach(rootNetwork -> - studyService.unbuildStudyTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) + studyService.unbuildNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) ); LOGGER.trace("Nodes builds deletion for study {} in : {} seconds", studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); From 7a05ae9a8fb91b112bee8263d5d3d0e442831ab0 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 15:07:53 +0200 Subject: [PATCH 12/18] Refactoring the root network update.. Signed-off-by: AAJELLAL --- .../java/org/gridsuite/study/server/service/StudyService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index d1feaf774..a81e7ff21 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1975,7 +1975,7 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String .map(RootNetworkEntity::getId) .toList(); - if (!unbuildChildren) { + if (unbuildChildren) { rootNetworkUuids.forEach(rootNetworkId -> unbuildNodeTree(studyUuid, nodeId, rootNetworkId)); } else { From 18c5469278555544b9650926865b93a8eab3e872 Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 15:28:52 +0200 Subject: [PATCH 13/18] Refactor testUpdateRootNetworkConsumer to remove invalidateBuild Signed-off-by: AAJELLAL --- .../study/server/rootnetworks/RootNetworkTest.java | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java index 13925b9ee..dc6eccc36 100644 --- a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java +++ b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java @@ -713,9 +713,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // send message to consumer Mockito.doNothing().when(caseService).disableCaseExpiration(NEW_CASE_UUID); - Mockito.doNothing().when(studyService).invalidateBuild(studyUuid, rootNode.getIdNode(), rootNetworkUuid, false, - false, - true); + Mockito.doNothing().when(studyService).unbuildNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); messageConsumer.accept(new GenericMessage<>("", headers)); // get study from database and check new root network has been updated with new case @@ -737,9 +735,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // check that old case has been deleted successfully assertFalse(caseService.caseExists(oldCaseUuid)); //assert invalidate Build node has been called on root node - Mockito.verify(studyService, Mockito.times(1)).invalidateBuild(studyUuid, rootNode.getIdNode(), rootNetworkUuid, false, - false, - true); + Mockito.verify(studyService, Mockito.times(1)).unbuildNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); } @Test From a76c5da11c5533aa6135bd41754486cbef8d4e7a Mon Sep 17 00:00:00 2001 From: AAJELLAL Date: Tue, 29 Apr 2025 18:24:00 +0200 Subject: [PATCH 14/18] Fix test. Signed-off-by: AAJELLAL --- src/test/java/org/gridsuite/study/server/StudyTest.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index bf557961d..4ebfd33e7 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -2681,6 +2681,8 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, */ //nodeUpdated assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub); + } } From 486346222ea9ba75a40a50bd5001ca66f722c681 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Sun, 4 May 2025 16:19:50 +0200 Subject: [PATCH 15/18] Remove updateStatuses method (first one) Signed-off-by: Slimane AMAR --- .../controller/SupervisionController.java | 2 +- .../study/server/dto/InvalidateNodeInfos.java | 2 +- .../notification/NotificationService.java | 2 +- .../NetworkModificationTreeService.java | 16 +-- .../service/RootNetworkNodeInfoService.java | 18 +-- .../study/server/service/StudyService.java | 54 +++++---- .../server/service/SupervisionService.java | 2 +- .../study/server/NetworkModificationTest.java | 59 +--------- .../server/NetworkModificationTreeTest.java | 41 ++++++- .../org/gridsuite/study/server/StudyTest.java | 110 ++++++++---------- 10 files changed, 143 insertions(+), 163 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java b/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java index 0f55b436b..ed445d8b2 100644 --- a/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java +++ b/src/main/java/org/gridsuite/study/server/controller/SupervisionController.java @@ -150,7 +150,7 @@ public ResponseEntity reindexStudy(@Parameter(description = "study uuid") @Operation(summary = "Invalidate node builds for the given study") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "all built nodes for the given study have been invalidated")}) public ResponseEntity invalidateAllNodesBuilds(@PathVariable("studyUuid") UUID studyUuid) { - supervisionService.invalidateAllNodesBuilds(studyUuid); + supervisionService.unbuildAllNodes(studyUuid); return ResponseEntity.ok().build(); } diff --git a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java index 0314e5b7b..0b58c6be4 100644 --- a/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java +++ b/src/main/java/org/gridsuite/study/server/dto/InvalidateNodeInfos.java @@ -151,7 +151,7 @@ public void addGroupUuids(List groupUuids) { } public void addNodeUuid(UUID nodeUuid) { - this.groupUuids.add(nodeUuid); + this.nodeUuids.add(nodeUuid); } public void add(InvalidateNodeInfos invalidateNodeInfos) { diff --git a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java index 042b27933..115175d63 100644 --- a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java +++ b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java @@ -326,7 +326,7 @@ public void emitSubtreeInserted(UUID studyUuid, UUID parentNodeSubtreeInserted, } @PostCompletion - public void emitNodeBuildStatusUpdated(UUID studyUuid, Collection nodes, UUID rootNetworkUuid) { + public void emitNodeBuildStatusUpdated(UUID studyUuid, List nodes, UUID rootNetworkUuid) { sendStudyUpdateMessage(studyUuid, NODE_BUILD_STATUS_UPDATED, MessageBuilder.withPayload("") .setHeader(HEADER_NODES, nodes) .setHeader(HEADER_ROOT_NETWORK_UUID, rootNetworkUuid) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 10e20d136..855636a9e 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -802,7 +802,7 @@ public void invalidateBuild(UUID nodeUuid, UUID rootNetworkUuid, boolean invalid } }); - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); } private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNodeInfos, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { @@ -826,7 +826,7 @@ private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNode public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); - InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid); + InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, true); fillIndexedNodeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); @@ -837,20 +837,22 @@ public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { @Transactional // old name: invalidateBuild - public InvalidateNodeInfos unbuildNodeTree(UUID nodeUuid, UUID rootNetworkUuid) { + public InvalidateNodeInfos unbuildNodeTree(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); // First node if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { - invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid); + invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, !invalidateOnlyChildrenBuildStatus); fillIndexedNodeTreeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); } invalidateNodeInfos.add(unbuildChildrenNodes(nodeUuid, rootNetworkUuid)); - notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), invalidateNodeInfos.getNodeUuids().stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + if (!invalidateNodeInfos.getNodeUuids().isEmpty()) { + notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), invalidateNodeInfos.getNodeUuids().stream().toList(), rootNetworkUuid); + } return invalidateNodeInfos; } @@ -877,7 +879,7 @@ public void invalidateBuildOfNodeOnly(UUID nodeUuid, UUID rootNetworkUuid, boole fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } - notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().collect(Collectors.toList()), rootNetworkUuid); + notificationService.emitNodeBuildStatusUpdated(studyId, changedNodes.stream().distinct().toList(), rootNetworkUuid); } /** @@ -965,7 +967,7 @@ private InvalidateNodeInfos unbuildChildrenNodes(UUID nodeUuid, UUID rootNetwork InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); nodesRepository.findAllByParentNodeIdNode(nodeUuid) .forEach(child -> { - invalidateNodeInfos.add(rootNetworkNodeInfoService.unbuildRootNetworkNode(child.getIdNode(), rootNetworkUuid)); + invalidateNodeInfos.add(rootNetworkNodeInfoService.unbuildRootNetworkNode(child.getIdNode(), rootNetworkUuid, true)); invalidateNodeInfos.add(unbuildChildrenNodes(child.getIdNode(), rootNetworkUuid)); }); return invalidateNodeInfos; diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 66c401726..0b9d27762 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -225,7 +225,7 @@ public void fillDeleteNodeInfo(UUID nodeUuid, DeleteNodeInfos deleteNodeInfos) { } //old name : invalidateRootNetworkNodeInfoProper - public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid) { + public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, boolean withInvalidationBuildStatus) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); // No need to invalidate a node with a status different of "BUILT" @@ -233,9 +233,13 @@ public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetwor return new InvalidateNodeInfos(); } - InvalidateNodeInfos invalidateNodeInfos = getInvalidationInfos(rootNetworkNodeInfoEntity); + InvalidateNodeInfos invalidateNodeInfos = getInvalidationComputationInfos(rootNetworkNodeInfoEntity); - invalidateBuildStatus(rootNetworkNodeInfoEntity, invalidateNodeInfos); + if (withInvalidationBuildStatus) { + rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); + invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); + invalidateBuildStatus(rootNetworkNodeInfoEntity, invalidateNodeInfos); + } invalidateComputationResults(rootNetworkNodeInfoEntity); @@ -257,7 +261,7 @@ private static void invalidateComputationResults(RootNetworkNodeInfoEntity rootN // Update the computation reports in the repository //TODO: add more checks for Voltage init - rootNetworkNodeInfoEntity.setModificationReports(new HashMap<>()); + rootNetworkNodeInfoEntity.setComputationReports(new HashMap<>()); } public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUuid, InvalidateNodeInfos invalidateNodeInfos, boolean invalidateOnlyChildrenBuildStatus, @@ -296,13 +300,9 @@ public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUu } //oldName: fillInvalidateNodeInfos - private InvalidateNodeInfos getInvalidationInfos(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { + private InvalidateNodeInfos getInvalidationComputationInfos(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); - rootNetworkNodeInfoEntity.getModificationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value)); - - invalidateNodeInfos.addVariantId(rootNetworkNodeInfoEntity.getVariantId()); - rootNetworkNodeInfoEntity.getComputationReports().forEach((key, value) -> invalidateNodeInfos.addReportUuid(value) ); diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 6eb8616a9..4d20e65ca 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1530,7 +1530,7 @@ public void createNetworkModification(UUID studyUuid, String createModificationA } } // invalidate all nodeUuid children - updateStatuses(studyUuid, nodeUuid); + unbuildNodeTree(studyUuid, nodeUuid, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1543,7 +1543,7 @@ public void updateNetworkModification(UUID studyUuid, String updateModificationA notificationService.emitStartModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS); try { networkModificationService.updateModification(updateModificationAttributes, modificationUuid); - updateStatuses(studyUuid, nodeUuid, false); + updateStatuses(studyUuid, nodeUuid, false, true, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1619,7 +1619,6 @@ private void assertCanBuildNode(@NonNull UUID studyUuid, @NonNull UUID rootNetwo @Transactional public void unbuildStudyNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { unbuildNode(studyUuid, nodeUuid, rootNetworkUuid); - emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); } public void stopBuild(@NonNull UUID nodeUuid, UUID rootNetworkUuid) { @@ -1632,7 +1631,9 @@ public void duplicateStudyNode(UUID sourceStudyUuid, UUID targetStudyUuid, UUID checkStudyContainsNode(targetStudyUuid, referenceNodeUuid); UUID duplicatedNodeUuid = networkModificationTreeService.duplicateStudyNode(nodeToCopyUuid, referenceNodeUuid, insertMode); boolean invalidateBuild = networkModificationTreeService.hasModifications(nodeToCopyUuid, false); - updateStatuses(targetStudyUuid, duplicatedNodeUuid, true, invalidateBuild, true); + if (invalidateBuild) { + updateStatuses(targetStudyUuid, duplicatedNodeUuid, true, true, true); + } notificationService.emitElementUpdated(targetStudyUuid, userId); } @@ -1655,9 +1656,7 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod updateStatuses(studyUuid, nodeToMoveUuid, false, true, true); oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); } else { - getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - unbuildNode(studyUuid, nodeToMoveUuid, rootNetworkEntity.getId()) - ); + unbuildNode(studyUuid, nodeToMoveUuid); } notificationService.emitElementUpdated(studyUuid, userId); } @@ -1754,29 +1753,47 @@ private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { deleteInvalidationInfos(invalidateNodeInfos); + emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); + if (startTime.get() != null) { LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); } } + private void unbuildNode(UUID studyUuid, UUID nodeUuid) { + getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> + unbuildNode(studyUuid, nodeUuid, rootNetworkEntity.getId())); + } + // OldName: invalidateBuild part 2 // This is used to unbuild the node and its children public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + unbuildNodeTree(studyUuid, nodeUuid, rootNetworkUuid, false); + } + + private void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNodeTree(nodeUuid, rootNetworkUuid); + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNodeTree(nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); deleteInvalidationInfos(invalidateNodeInfos); + emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); + if (startTime.get() != null) { LOGGER.trace("unbuild node '{}' of study '{}' : {} seconds", nodeUuid, studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); } } + private void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { + getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> + unbuildNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); + } + public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { CompletableFuture executeInParallel = CompletableFuture.allOf( studyServerExecutionService.runAsync(() -> networkModificationService.deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), invalidateNodeInfos.getNetworkUuid())), @@ -1804,14 +1821,6 @@ public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { } - private void updateStatuses(UUID studyUuid, UUID nodeUuid) { - updateStatuses(studyUuid, nodeUuid, true); - } - - private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { - updateStatuses(studyUuid, nodeUuid, invalidateOnlyChildrenBuildStatus, true, true); - } - private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus, boolean invalidateBuild, boolean deleteVoltageInitResults) { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> { UUID rootNetworkUuid = rootNetworkEntity.getId(); @@ -1820,9 +1829,7 @@ private void updateStatuses(UUID studyUuid, UUID nodeUuid, boolean invalidateOnl } private void updateStatuses(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus, boolean invalidateBuild, boolean deleteVoltageInitResults) { - if (invalidateBuild) { - invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus, false, deleteVoltageInitResults); - } + invalidateBuild(studyUuid, nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus, false, deleteVoltageInitResults); emitAllComputationStatusChanged(studyUuid, nodeUuid, rootNetworkUuid); } @@ -1841,7 +1848,6 @@ public void deleteNetworkModifications(UUID studyUuid, UUID nodeUuid, List studyEntity.getRootNetworks().forEach(rootNetworkEntity -> { rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkEntity.getId(), new HashSet<>(modificationsUuids), true); }); - updateStatuses(studyUuid, nodeUuid, false, false, false); } finally { notificationService.emitEndDeletionEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1858,7 +1864,7 @@ public void stashNetworkModifications(UUID studyUuid, UUID nodeUuid, List } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.stashModifications(groupId, modificationsUuids); - updateStatuses(studyUuid, nodeUuid, false); + updateStatuses(studyUuid, nodeUuid, false, true, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1875,7 +1881,7 @@ public void updateNetworkModificationsActivation(UUID studyUuid, UUID nodeUuid, } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.updateModificationsActivation(groupId, modificationsUuids, activated); - updateStatuses(studyUuid, nodeUuid, false); + updateStatuses(studyUuid, nodeUuid, false, true, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1909,7 +1915,7 @@ public void restoreNetworkModifications(UUID studyUuid, UUID nodeUuid, List startTime = new AtomicReference<>(); startTime.set(System.nanoTime()); UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java index a81d176d8..0098c89ae 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTest.java @@ -636,7 +636,6 @@ void testLocalBuildValue() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, rootNetworkUuid).getGlobalBuildStatus()); @@ -655,7 +654,6 @@ void testLocalBuildValue() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNode2Uuid, rootNetworkUuid).getGlobalBuildStatus()); @@ -707,7 +705,6 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -729,7 +726,6 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -757,7 +753,9 @@ void testNetworkModificationSwitch(final MockWebServer server) throws Exception NetworkImpactsInfos expectedPayload = NetworkImpactsInfos.builder().impactedSubstationsIds(substationsSet).build(); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); - checkSwitchModificationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid, modificationNode2Uuid), expectedPayload); + checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid, expectedPayload); + checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); + checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); modificationBody = Pair.of(bodyJson, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNode1Uuid, NETWORK_UUID))); wireMockUtils.verifyNetworkModificationPostWithVariant(stubPostId, getModificationContextJsonString(mapper, modificationBody)); @@ -807,7 +805,6 @@ void testNetworkModificationEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(bodyJson, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -828,7 +825,6 @@ void testNetworkModificationEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -879,7 +875,6 @@ void testCreateGenerator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -892,7 +887,6 @@ void testCreateGenerator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -957,7 +951,6 @@ void testCreateShuntsCompensator() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1022,7 +1015,6 @@ void testCreateLine() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1035,7 +1027,6 @@ void testCreateLine() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); modificationBody = Pair.of(createLineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNode2Uuid, NETWORK_UUID))); @@ -1107,7 +1098,6 @@ void testCreateTwoWindingsTransformer() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1120,7 +1110,6 @@ void testCreateTwoWindingsTransformer() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1184,7 +1173,6 @@ void deleteModificationRequest() throws Exception { .andExpect(status().isOk()); wireMockUtils.verifyDeleteRequest(stubId, "/v1/network-modifications", false, Map.of("uuids", WireMock.equalTo(modificationUuid.toString()))); checkEquipmentDeletingMessagesReceived(studyUuid, modificationNode.getId()); - checkUpdateModelsStatusMessagesReceived(studyUuid, modificationNode.getId()); checkEquipmentDeletingFinishedMessagesReceived(studyUuid, modificationNode.getId()); stubId = wireMockServer.stubFor(WireMock.delete(WireMock.urlPathMatching("/v1/network-modifications.*")) @@ -1232,7 +1220,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1261,7 +1248,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1290,7 +1276,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1319,7 +1304,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1346,7 +1330,6 @@ void testUpdateLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1386,7 +1369,6 @@ void testCreateLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1399,7 +1381,6 @@ void testCreateLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1461,7 +1442,6 @@ void testModifyLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1474,7 +1454,6 @@ void testModifyLoad() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1521,7 +1500,6 @@ void testModifyEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1534,7 +1512,6 @@ void testModifyEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid2)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid2); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1584,7 +1561,6 @@ void testCreateSubstation() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1597,7 +1573,6 @@ void testCreateSubstation() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1658,7 +1633,6 @@ void testCreateVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1671,7 +1645,6 @@ void testCreateVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1734,7 +1707,6 @@ void testLineSplitWithVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1798,7 +1770,6 @@ void testLineAttachToVoltageLevel() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1834,7 +1805,6 @@ void testLinesAttachToSplitLines() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1892,7 +1862,6 @@ void testScaling(ModificationType scalingType) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -1948,7 +1917,6 @@ void testDeleteVoltageLevelOnline() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(createDeleteVoltageLevelOnlineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -2001,7 +1969,6 @@ void testDeleteAttachingline() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); Pair> modificationBody = Pair.of(createDeleteAttachingLineAttributes, List.of(rootNetworkNodeInfoService.getNetworkModificationApplicationContext(firstRootNetworkUuid, modificationNodeUuid, NETWORK_UUID))); @@ -2362,7 +2329,6 @@ void testDeleteEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2375,7 +2341,6 @@ void testDeleteEquipment() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2467,7 +2432,7 @@ void testNodesInvalidation(final MockWebServer server) throws Exception { .andExpect(status().isOk()); wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode2Uuid, modificationNode3Uuid)); + checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode3Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode2Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2531,7 +2496,6 @@ void testRemoveLoadFlowComputationReport(final MockWebServer server) throws Exce .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNode1Uuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNode1Uuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2579,7 +2543,6 @@ void testUpdateOfBuildStatus() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); @@ -2604,7 +2567,6 @@ void testUpdateOfBuildStatus() throws Exception { checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2622,7 +2584,6 @@ void testUpdateOfBuildStatus() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_WARNING, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2640,7 +2601,6 @@ void testUpdateOfBuildStatus() throws Exception { checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkEquipmentMessagesReceived(studyNameUserIdUuid, modificationNodeUuid, expectedPayload); - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); assertEquals(BuildStatus.BUILT_WITH_ERROR, networkModificationTreeService.getNodeBuildStatus(modificationNodeUuid, firstRootNetworkUuid).getGlobalBuildStatus()); @@ -2850,16 +2810,6 @@ private void checkEquipmentDeletingMessagesReceived(UUID studyNameUserIdUuid, UU assertEquals(NotificationService.MODIFICATIONS_DELETING_IN_PROGRESS, headersStudyUpdate.get(NotificationService.HEADER_UPDATE_TYPE)); } - private void checkSwitchModificationMessagesReceived(UUID studyNameUserIdUuid, List nodeUuids, - NetworkImpactsInfos expectedPayload) throws Exception { - assertFalse(nodeUuids.isEmpty()); - - checkEquipmentMessagesReceived(studyNameUserIdUuid, nodeUuids, expectedPayload); - - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, nodeUuids); - checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuids.get(0)); - } - private void checkEquipmentUpdatingMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { // assert that the broker message has been sent for updating study type Message messageStudyUpdate = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); @@ -2989,7 +2939,6 @@ void testCreateModificationWithErrors() throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); - checkNodesInvalidationMessagesReceived(studyNameUserIdUuid, List.of(modificationNodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkEquipmentUpdatingFinishedMessagesReceived(studyNameUserIdUuid, modificationNodeUuid); checkElementUpdatedMessageSent(studyNameUserIdUuid, userId); diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java index 07cb830bf..c48c7c1fc 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationTreeTest.java @@ -768,14 +768,26 @@ private void deleteNode(UUID studyUuid, List child, boolean delete } private void stashNode(UUID studyUuid, AbstractNode child, boolean stashChildren, Set expectedStash, String userId) throws Exception { + NetworkModificationNode networkModificationNode = (NetworkModificationNode) child; + boolean nodeIsBuilt = networkModificationNode.getNodeBuildStatus().isBuilt(); + mockMvc.perform(post("/v1/studies/{studyUuid}/tree/nodes/{id}/stash?stashChildren={stash}", studyUuid, child.getId(), stashChildren).header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkElementUpdatedMessageSent(studyUuid, userId); - //first message is node build status being reset and then is the node deleted - var message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); - assertEquals(NODE_BUILD_STATUS_UPDATED, message.getHeaders().get(HEADER_UPDATE_TYPE)); + Message message; + + // first message is node build status being reset + if (nodeIsBuilt) { + message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); + assertEquals(NODE_BUILD_STATUS_UPDATED, message.getHeaders().get(HEADER_UPDATE_TYPE)); + } + + // computing status + checkUpdateModelsStatusMessagesReceived(); + + // node deleted message message = output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION); Collection stashedId = (Collection) message.getHeaders().get(NotificationService.HEADER_NODES); assertNotNull(stashedId); @@ -1649,4 +1661,27 @@ private void checkNodeAliasUpdateMessageReceived(UUID studyUuid) { assertEquals(studyUuid, headersStudyUpdate.get(NotificationService.HEADER_STUDY_UUID)); assertEquals(NotificationService.UPDATE_SPREADSHEET_NODE_ALIASES, headersStudyUpdate.get(NotificationService.HEADER_UPDATE_TYPE)); } + + private void checkUpdateModelsStatusMessagesReceived() { + //loadflow_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //securityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //sensitivityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //sensitivityAnalysisonEvacuated_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //shortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //oneBusShortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //dynamicSimulation_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //dynamicSecurityAnalysis_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //voltageInit_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + //stateEstimation_status + assertNotNull(output.receive(TIMEOUT, STUDY_UPDATE_DESTINATION)); + } } diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index 4ebfd33e7..a48791b18 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -1642,7 +1642,6 @@ private void testDuplicateStudy(final MockWebServer mockWebServer, UUID study1Uu .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1659,7 +1658,6 @@ private void testDuplicateStudy(final MockWebServer mockWebServer, UUID study1Uu .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1948,7 +1946,6 @@ void testCutAndPasteNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -1964,7 +1961,6 @@ void testCutAndPasteNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, userId)) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2281,7 +2277,6 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2297,7 +2292,6 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2317,7 +2311,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(node2.getId())).count()); // duplicate the node1 after node2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, userId); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study1Uuid, node1, node2.getId(), InsertMode.AFTER, true, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study1Uuid); @@ -2328,7 +2322,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { .count()); // duplicate the node2 before node1 - UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, userId); + UUID duplicatedNodeUuid2 = duplicateNode(study1Uuid, study1Uuid, node2, node1.getId(), InsertMode.BEFORE, true, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); assertEquals(1, allNodes.stream() .filter(nodeEntity -> nodeEntity.getParentNode() != null @@ -2338,7 +2332,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { //now the tree looks like root -> modificationNode -> duplicatedNode2 -> node1 -> node2 -> duplicatedNode1 //duplicate node1 in a new branch starting from duplicatedNode2 - UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, userId); + UUID duplicatedNodeUuid3 = duplicateNode(study1Uuid, study1Uuid, node1, duplicatedNodeUuid2, InsertMode.CHILD, true, userId); allNodes = networkModificationTreeService.getAllNodes(study1Uuid); //expect to have modificationNode as a parent assertEquals(1, allNodes.stream() @@ -2373,7 +2367,7 @@ void testDuplicateNode(final MockWebServer mockWebServer) throws Exception { // Test Built status when duplicating an empty node UUID rootNetworkUuid = studyTestUtils.getOneRootNetworkUuid(study1Uuid); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId(), rootNetworkUuid).getGlobalBuildStatus()); - duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, userId); + duplicateNode(study1Uuid, study1Uuid, emptyNode, node3.getId(), InsertMode.BEFORE, false, userId); assertEquals(BuildStatus.BUILT, networkModificationTreeService.getNodeBuildStatus(node3.getId(), rootNetworkUuid).getGlobalBuildStatus()); } @@ -2408,7 +2402,7 @@ void testDuplicateSubtree(final MockWebServer server) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId(), node3.getId())); + checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node3.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2430,7 +2424,6 @@ void testDuplicateSubtree(final MockWebServer server) throws Exception { .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2550,7 +2543,6 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node1.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node1.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node1.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node1.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2566,7 +2558,6 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E .header(USER_ID_HEADER, "userId")) .andExpect(status().isOk()); checkEquipmentCreatingMessagesReceived(study1Uuid, node2.getId()); - checkNodeBuildStatusUpdatedMessageReceived(study1Uuid, List.of(node2.getId())); checkUpdateModelsStatusMessagesReceived(study1Uuid, node2.getId()); checkEquipmentUpdatingFinishedMessagesReceived(study1Uuid, node2.getId()); checkElementUpdatedMessageSent(study1Uuid, userId); @@ -2578,7 +2569,7 @@ void testDuplicateNodeBetweenStudies(final MockWebServer mockWebServer) throws E assertEquals(0, allNodes.stream().filter(nodeEntity -> nodeEntity.getParentNode() != null && nodeEntity.getParentNode().getIdNode().equals(study2Node2.getId())).count()); // duplicate the node1 from study 1 after node2 from study 2 - UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, userId); + UUID duplicatedNodeUuid = duplicateNode(study1Uuid, study2Uuid, node1, study2Node2.getId(), InsertMode.AFTER, true, userId); //node2 should now have 1 child allNodes = networkModificationTreeService.getAllNodes(study2Uuid); @@ -2616,38 +2607,40 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, assertEquals(nodeToCopy.getId(), message.getHeaders().get(NotificationService.HEADER_MOVED_NODE)); assertEquals(insertMode.name(), message.getHeaders().get(NotificationService.HEADER_INSERT_MODE)); - if (nodeHasModifications) { - /* - * invalidating old children - */ - IntStream.rangeClosed(1, childCount).forEach(i -> { - //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //loadflow_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //securityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //nonEvacuatedEnergy_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //shortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //oneBusShortCircuitAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSimulation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //dynamicSecurityAnalysis_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //voltageInit_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //stateEstimation_status - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - }); + /* + * invalidating moving node + */ + //nodeUpdated + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //loadflow_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //securityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //sensitivityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //sensitivityAnalysisonEvacuated_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //shortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //oneBusShortCircuitAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //dynamicSimulation_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //dynamicSecurityAnalysis_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //voltageInit_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + //stateEstimation_status + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + + if (!nodeHasModifications) { + return; + } - /* - * invalidating new children - */ + /* + * invalidating old children + */ + IntStream.rangeClosed(1, childCount).forEach(i -> { //nodeUpdated assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //loadflow_status @@ -2656,7 +2649,7 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //sensitivityAnalysis_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - //sensitivityAnalysisonEvacuated_status + //nonEvacuatedEnergy_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //shortCircuitAnalysis_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); @@ -2670,23 +2663,15 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //stateEstimation_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + }); - if (wasBuilt) { - // 1 request for cut node and its children, 1 request for paste node and its children - wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 2); - } - } else { - /* - * Invalidating moved node - */ - //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); - wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub); - + if (wasBuilt) { + // 1 request for cut node and its children, 1 request for paste node and its children + wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 2); } } - private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkModificationNode nodeToCopy, UUID referenceNodeUuid, InsertMode insertMode, String userId) throws Exception { + private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkModificationNode nodeToCopy, UUID referenceNodeUuid, InsertMode insertMode, boolean checkMessagesForStatusModels, String userId) throws Exception { List allNodesBeforeDuplication = networkModificationTreeService.getAllNodes(targetStudyUuid).stream().map(NodeEntity::getIdNode).collect(Collectors.toList()); UUID stubGetCountUuid = wireMockUtils.stubNetworkModificationCountGet(nodeToCopy.getModificationGroupUuid().toString(), EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid()) ? 0 : 1); @@ -2714,7 +2699,10 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo if (!EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid())) { output.receive(TIMEOUT, studyUpdateDestination); // nodeUpdated } - checkUpdateModelsStatusMessagesReceived(targetStudyUuid, nodesAfterDuplication.get(0)); + + if (checkMessagesForStatusModels) { + checkUpdateModelsStatusMessagesReceived(targetStudyUuid, nodesAfterDuplication.get(0)); + } checkElementUpdatedMessageSent(targetStudyUuid, userId); wireMockUtils.verifyNetworkModificationCountsGet(stubGetCountUuid, nodeToCopy.getModificationGroupUuid().toString()); From 0dff4883763b93540bd829da87da7747f33a2eb6 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Sun, 4 May 2025 16:42:02 +0200 Subject: [PATCH 16/18] Renaming Signed-off-by: Slimane AMAR --- .../NetworkModificationTreeService.java | 16 +++++----- .../service/RootNetworkNodeInfoService.java | 2 +- .../study/server/service/StudyService.java | 32 +++++++++---------- .../server/service/SupervisionService.java | 2 +- .../server/rootnetworks/RootNetworkTest.java | 4 +-- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 855636a9e..315cc574d 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -823,10 +823,10 @@ private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNode @Transactional // old name: invalidateBuildOfNodeOnly - public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { + public InvalidateNodeInfos invalidateNode(UUID nodeUuid, UUID rootNetworkUuid) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); - InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, true); + InvalidateNodeInfos invalidateNodeInfos = rootNetworkNodeInfoService.invalidateRootNetworkNode(nodeUuid, rootNetworkUuid, true); fillIndexedNodeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); @@ -837,18 +837,18 @@ public InvalidateNodeInfos unbuildNode(UUID nodeUuid, UUID rootNetworkUuid) { @Transactional // old name: invalidateBuild - public InvalidateNodeInfos unbuildNodeTree(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + public InvalidateNodeInfos invalidateNodeTree(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); // First node if (nodeEntity.getType().equals(NodeType.NETWORK_MODIFICATION)) { - invalidateNodeInfos = rootNetworkNodeInfoService.unbuildRootNetworkNode(nodeUuid, rootNetworkUuid, !invalidateOnlyChildrenBuildStatus); + invalidateNodeInfos = rootNetworkNodeInfoService.invalidateRootNetworkNode(nodeUuid, rootNetworkUuid, !invalidateOnlyChildrenBuildStatus); fillIndexedNodeTreeInfosToInvalidate(nodeEntity, rootNetworkUuid, invalidateNodeInfos); } - invalidateNodeInfos.add(unbuildChildrenNodes(nodeUuid, rootNetworkUuid)); + invalidateNodeInfos.add(invalidateChildrenNodes(nodeUuid, rootNetworkUuid)); if (!invalidateNodeInfos.getNodeUuids().isEmpty()) { notificationService.emitNodeBuildStatusUpdated(nodeEntity.getStudy().getId(), invalidateNodeInfos.getNodeUuids().stream().toList(), rootNetworkUuid); @@ -963,12 +963,12 @@ private void fillIndexedNodeTreeInfosToInvalidate(NodeEntity nodeEntity, UUID ro } // OldName: invalidateChildrenBuildStatus - private InvalidateNodeInfos unbuildChildrenNodes(UUID nodeUuid, UUID rootNetworkUuid) { + private InvalidateNodeInfos invalidateChildrenNodes(UUID nodeUuid, UUID rootNetworkUuid) { InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); nodesRepository.findAllByParentNodeIdNode(nodeUuid) .forEach(child -> { - invalidateNodeInfos.add(rootNetworkNodeInfoService.unbuildRootNetworkNode(child.getIdNode(), rootNetworkUuid, true)); - invalidateNodeInfos.add(unbuildChildrenNodes(child.getIdNode(), rootNetworkUuid)); + invalidateNodeInfos.add(rootNetworkNodeInfoService.invalidateRootNetworkNode(child.getIdNode(), rootNetworkUuid, true)); + invalidateNodeInfos.add(invalidateChildrenNodes(child.getIdNode(), rootNetworkUuid)); }); return invalidateNodeInfos; } diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 0b9d27762..6a7b5cc6d 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -225,7 +225,7 @@ public void fillDeleteNodeInfo(UUID nodeUuid, DeleteNodeInfos deleteNodeInfos) { } //old name : invalidateRootNetworkNodeInfoProper - public InvalidateNodeInfos unbuildRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, boolean withInvalidationBuildStatus) { + public InvalidateNodeInfos invalidateRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, boolean withInvalidationBuildStatus) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); // No need to invalidate a node with a status different of "BUILT" diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 4d20e65ca..3193ed582 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -391,7 +391,7 @@ private void postRootNetworkUpdate(UUID studyUuid, UUID rootNetworkUuid, boolean rootNetworkModificationRequestEntityOpt.ifPresent(rootNetworkService::deleteRootNetworkRequest); UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); - unbuildNodeTree(studyUuid, rootNodeUuid, rootNetworkUuid); + invalidateNodeTree(studyUuid, rootNodeUuid, rootNetworkUuid); notificationService.emitRootNetworkUpdated(studyUuid, rootNetworkUuid); } else { notificationService.emitRootNetworksUpdated(studyUuid); @@ -1530,7 +1530,7 @@ public void createNetworkModification(UUID studyUuid, String createModificationA } } // invalidate all nodeUuid children - unbuildNodeTree(studyUuid, nodeUuid, true); + invalidateNodeTree(studyUuid, nodeUuid, true); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1618,7 +1618,7 @@ private void assertCanBuildNode(@NonNull UUID studyUuid, @NonNull UUID rootNetwo @Transactional public void unbuildStudyNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid) { - unbuildNode(studyUuid, nodeUuid, rootNetworkUuid); + invalidateNode(studyUuid, nodeUuid, rootNetworkUuid); } public void stopBuild(@NonNull UUID nodeUuid, UUID rootNetworkUuid) { @@ -1656,7 +1656,7 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod updateStatuses(studyUuid, nodeToMoveUuid, false, true, true); oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); } else { - unbuildNode(studyUuid, nodeToMoveUuid); + invalidateNode(studyUuid, nodeToMoveUuid); } notificationService.emitElementUpdated(studyUuid, userId); } @@ -1744,11 +1744,11 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, // OldName: invalidateBuild part 1 // Only one node - private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + private void invalidateNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNode(nodeUuid, rootNetworkUuid); + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.invalidateNode(nodeUuid, rootNetworkUuid); invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); deleteInvalidationInfos(invalidateNodeInfos); @@ -1761,22 +1761,22 @@ private void unbuildNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { } } - private void unbuildNode(UUID studyUuid, UUID nodeUuid) { + private void invalidateNode(UUID studyUuid, UUID nodeUuid) { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - unbuildNode(studyUuid, nodeUuid, rootNetworkEntity.getId())); + invalidateNode(studyUuid, nodeUuid, rootNetworkEntity.getId())); } // OldName: invalidateBuild part 2 // This is used to unbuild the node and its children - public void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { - unbuildNodeTree(studyUuid, nodeUuid, rootNetworkUuid, false); + public void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkUuid, false); } - private void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); - InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.unbuildNodeTree(nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); + InvalidateNodeInfos invalidateNodeInfos = networkModificationTreeService.invalidateNodeTree(nodeUuid, rootNetworkUuid, invalidateOnlyChildrenBuildStatus); invalidateNodeInfos.setNetworkUuid(rootNetworkService.getNetworkUuid(rootNetworkUuid)); deleteInvalidationInfos(invalidateNodeInfos); @@ -1789,9 +1789,9 @@ private void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid } } - private void unbuildNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - unbuildNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); } public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { @@ -2003,10 +2003,10 @@ public void stashNode(UUID studyUuid, UUID nodeId, boolean stashChildren, String if (unbuildChildren) { rootNetworkUuids.forEach(rootNetworkId -> - unbuildNodeTree(studyUuid, nodeId, rootNetworkId)); + invalidateNodeTree(studyUuid, nodeId, rootNetworkId)); } else { rootNetworkUuids.forEach(rootNetworkId -> - unbuildNode(studyUuid, nodeId, rootNetworkId) + invalidateNode(studyUuid, nodeId, rootNetworkId) ); } diff --git a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java index a37ecd5d6..af16ee658 100644 --- a/src/main/java/org/gridsuite/study/server/service/SupervisionService.java +++ b/src/main/java/org/gridsuite/study/server/service/SupervisionService.java @@ -323,7 +323,7 @@ public void unbuildAllNodes(UUID studyUuid) { UUID rootNodeUuid = networkModificationTreeService.getStudyRootNodeUuid(studyUuid); //TODO: to parallelize ? studyService.getExistingBasicRootNetworkInfos(studyUuid).forEach(rootNetwork -> - studyService.unbuildNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) + studyService.invalidateNodeTree(studyUuid, rootNodeUuid, rootNetwork.rootNetworkUuid()) ); LOGGER.trace("Nodes builds deletion for study {} in : {} seconds", studyUuid, TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime.get())); diff --git a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java index dc6eccc36..65b2a85fd 100644 --- a/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java +++ b/src/test/java/org/gridsuite/study/server/rootnetworks/RootNetworkTest.java @@ -713,7 +713,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // send message to consumer Mockito.doNothing().when(caseService).disableCaseExpiration(NEW_CASE_UUID); - Mockito.doNothing().when(studyService).unbuildNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); + Mockito.doNothing().when(studyService).invalidateNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); messageConsumer.accept(new GenericMessage<>("", headers)); // get study from database and check new root network has been updated with new case @@ -735,7 +735,7 @@ void testUpdateRootNetworkConsumer() throws Exception { // check that old case has been deleted successfully assertFalse(caseService.caseExists(oldCaseUuid)); //assert invalidate Build node has been called on root node - Mockito.verify(studyService, Mockito.times(1)).unbuildNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); + Mockito.verify(studyService, Mockito.times(1)).invalidateNodeTree(studyUuid, rootNode.getIdNode(), rootNetworkUuid); } @Test From c9e12452946a6528a7e5553d4a37ed7a3252b1e4 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Sun, 4 May 2025 19:01:52 +0200 Subject: [PATCH 17/18] Remove updateStatuses method (last one) Signed-off-by: Slimane AMAR --- .../study/server/service/StudyService.java | 31 ++++++++++--------- .../study/server/NetworkModificationTest.java | 11 +------ .../server/NetworkModificationUnitTest.java | 3 +- .../org/gridsuite/study/server/StudyTest.java | 16 +++++----- .../study/server/VoltageInitTest.java | 2 +- 5 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 3193ed582..6b05d67f5 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1543,7 +1543,7 @@ public void updateNetworkModification(UUID studyUuid, String updateModificationA notificationService.emitStartModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids, NotificationService.MODIFICATIONS_UPDATING_IN_PROGRESS); try { networkModificationService.updateModification(updateModificationAttributes, modificationUuid); - updateStatuses(studyUuid, nodeUuid, false, true, true); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1632,7 +1632,7 @@ public void duplicateStudyNode(UUID sourceStudyUuid, UUID targetStudyUuid, UUID UUID duplicatedNodeUuid = networkModificationTreeService.duplicateStudyNode(nodeToCopyUuid, referenceNodeUuid, insertMode); boolean invalidateBuild = networkModificationTreeService.hasModifications(nodeToCopyUuid, false); if (invalidateBuild) { - updateStatuses(targetStudyUuid, duplicatedNodeUuid, true, true, true); + invalidateNodeTree(targetStudyUuid, duplicatedNodeUuid, true); } notificationService.emitElementUpdated(targetStudyUuid, userId); } @@ -1653,8 +1653,8 @@ public void moveStudyNode(UUID studyUuid, UUID nodeToMoveUuid, UUID referenceNod //Unbuilding moved node or new children if necessary if (shouldUnbuildChildren) { - updateStatuses(studyUuid, nodeToMoveUuid, false, true, true); - oldChildren.forEach(child -> updateStatuses(studyUuid, child.getIdNode(), false, true, true)); + invalidateNodeTree(studyUuid, nodeToMoveUuid); + oldChildren.forEach(child -> invalidateNodeTree(studyUuid, child.getIdNode())); } else { invalidateNode(studyUuid, nodeToMoveUuid); } @@ -1688,12 +1688,11 @@ public void moveStudySubtree(UUID studyUuid, UUID parentNodeToMoveUuid, UUID ref getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> { UUID rootNetworkUuid = rootNetworkEntity.getId(); if (networkModificationTreeService.getNodeBuildStatus(parentNodeToMoveUuid, rootNetworkUuid).isBuilt()) { - updateStatuses(studyUuid, parentNodeToMoveUuid, false, true, true); + invalidateNodeTree(studyUuid, parentNodeToMoveUuid); } allChildren.stream() .filter(childUuid -> networkModificationTreeService.getNodeBuildStatus(childUuid, rootNetworkUuid).isBuilt()) - .forEach(childUuid -> updateStatuses(studyUuid, childUuid, false, true, true)); - + .forEach(childUuid -> invalidateNodeTree(studyUuid, childUuid)); }); notificationService.emitSubtreeMoved(studyUuid, parentNodeToMoveUuid, referenceNodeUuid); @@ -1789,6 +1788,10 @@ private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkU } } + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid) { + invalidateNodeTree(studyUuid, nodeUuid, false); + } + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> invalidateNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); @@ -1864,7 +1867,7 @@ public void stashNetworkModifications(UUID studyUuid, UUID nodeUuid, List } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.stashModifications(groupId, modificationsUuids); - updateStatuses(studyUuid, nodeUuid, false, true, true); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1881,7 +1884,7 @@ public void updateNetworkModificationsActivation(UUID studyUuid, UUID nodeUuid, } UUID groupId = networkModificationTreeService.getModificationGroupUuid(nodeUuid); networkModificationService.updateModificationsActivation(groupId, modificationsUuids, activated); - updateStatuses(studyUuid, nodeUuid, false, true, true); + invalidateNodeTree(studyUuid, nodeUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, childrenUuids); } @@ -1898,7 +1901,7 @@ public void updateNetworkModificationsActivationInRootNetwork(UUID studyUuid, UU throw new StudyException(NOT_ALLOWED); } rootNetworkNodeInfoService.updateModificationsToExclude(nodeUuid, rootNetworkUuid, modificationsUuids, activated); - updateStatuses(studyUuid, nodeUuid, rootNetworkUuid, false, true, true); + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkUuid); } finally { notificationService.emitEndModificationEquipmentNotification(studyUuid, nodeUuid, Optional.of(rootNetworkUuid), childrenUuids); } @@ -1915,7 +1918,7 @@ public void restoreNetworkModifications(UUID studyUuid, UUID nodeUuid, List nodeIds, boolean deleteChildr } if (invalidateChildrenBuild) { - childrenNodes.forEach(nodeEntity -> updateStatuses(studyUuid, nodeEntity.getIdNode(), false, true, true)); + childrenNodes.forEach(nodeEntity -> invalidateNodeTree(studyUuid, nodeEntity.getIdNode())); } } @@ -2124,7 +2127,7 @@ private void emitNetworkModificationImpactsForAllRootNetworks(List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } private void checkUpdateEquipmentModificationMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(nodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuid); } @@ -2821,7 +2813,6 @@ private void checkEquipmentUpdatingMessagesReceived(UUID studyNameUserIdUuid, UU } private void checkUpdateEquipmentCreationMessagesReceived(UUID studyNameUserIdUuid, UUID nodeUuid) { - checkNodesBuildStatusUpdatedMessageReceived(studyNameUserIdUuid, List.of(nodeUuid)); checkUpdateModelsStatusMessagesReceived(studyNameUserIdUuid, nodeUuid); } diff --git a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java index 98c2cf885..ff47d4145 100644 --- a/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java +++ b/src/test/java/org/gridsuite/study/server/NetworkModificationUnitTest.java @@ -40,6 +40,7 @@ import java.util.List; import java.util.Map; +import java.util.TreeSet; import java.util.UUID; import java.util.stream.Collectors; @@ -217,7 +218,7 @@ private void checkUpdateBuildStateMessageReceived(UUID studyUuid, List nod MessageHeaders headersStatus = messageStatus.getHeaders(); assertEquals(studyUuid, headersStatus.get(NotificationService.HEADER_STUDY_UUID)); - assertEquals(nodeUuids, headersStatus.get(NotificationService.HEADER_NODES)); + assertEquals(new TreeSet<>(nodeUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } diff --git a/src/test/java/org/gridsuite/study/server/StudyTest.java b/src/test/java/org/gridsuite/study/server/StudyTest.java index a48791b18..d742c267d 100644 --- a/src/test/java/org/gridsuite/study/server/StudyTest.java +++ b/src/test/java/org/gridsuite/study/server/StudyTest.java @@ -1503,7 +1503,7 @@ private void checkNodeBuildStatusUpdatedMessageReceived(UUID studyUuid, List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } @@ -2611,7 +2611,9 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, * invalidating moving node */ //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + if (wasBuilt) { + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + } //loadflow_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //securityAnalysis_status @@ -2642,7 +2644,9 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, */ IntStream.rangeClosed(1, childCount).forEach(i -> { //nodeUpdated - assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + if (wasBuilt) { + assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); + } //loadflow_status assertNotNull(output.receive(TIMEOUT, studyUpdateDestination)); //securityAnalysis_status @@ -2666,8 +2670,7 @@ private void cutAndPasteNode(UUID studyUuid, NetworkModificationNode nodeToCopy, }); if (wasBuilt) { - // 1 request for cut node and its children, 1 request for paste node and its children - wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 2); + wireMockUtils.verifyNetworkModificationDeleteIndex(deleteModificationIndexStub, 1); } } @@ -2696,9 +2699,6 @@ private UUID duplicateNode(UUID sourceStudyUuid, UUID targetStudyUuid, NetworkMo assertEquals(1, nodesAfterDuplication.size()); output.receive(TIMEOUT, studyUpdateDestination); // nodeCreated - if (!EMPTY_MODIFICATION_GROUP_UUID.equals(nodeToCopy.getModificationGroupUuid())) { - output.receive(TIMEOUT, studyUpdateDestination); // nodeUpdated - } if (checkMessagesForStatusModels) { checkUpdateModelsStatusMessagesReceived(targetStudyUuid, nodesAfterDuplication.get(0)); diff --git a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java index 5b30c7dc2..27f9b2e26 100644 --- a/src/test/java/org/gridsuite/study/server/VoltageInitTest.java +++ b/src/test/java/org/gridsuite/study/server/VoltageInitTest.java @@ -737,7 +737,7 @@ private void checkNodesBuildStatusUpdatedMessageReceived(UUID studyUuid, List(nodesUuids), new TreeSet<>((List) headersStatus.get(NotificationService.HEADER_NODES))); assertEquals(NotificationService.NODE_BUILD_STATUS_UPDATED, headersStatus.get(NotificationService.HEADER_UPDATE_TYPE)); } From f31b0344f769ff19f7fe816e04408012929944c4 Mon Sep 17 00:00:00 2001 From: Slimane AMAR Date: Mon, 5 May 2025 14:33:41 +0200 Subject: [PATCH 18/18] Remove old comments Signed-off-by: Slimane AMAR --- .../NetworkModificationTreeService.java | 4 ---- .../service/RootNetworkNodeInfoService.java | 3 --- .../study/server/service/StudyService.java | 24 +++++++++---------- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java index 315cc574d..db97cc085 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkModificationTreeService.java @@ -822,7 +822,6 @@ private void fillIndexedNodeInfosToInvalidate(InvalidateNodeInfos invalidateNode } @Transactional - // old name: invalidateBuildOfNodeOnly public InvalidateNodeInfos invalidateNode(UUID nodeUuid, UUID rootNetworkUuid) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); @@ -836,7 +835,6 @@ public InvalidateNodeInfos invalidateNode(UUID nodeUuid, UUID rootNetworkUuid) { } @Transactional - // old name: invalidateBuild public InvalidateNodeInfos invalidateNodeTree(UUID nodeUuid, UUID rootNetworkUuid, boolean invalidateOnlyChildrenBuildStatus) { NodeEntity nodeEntity = getNodeEntity(nodeUuid); @@ -943,7 +941,6 @@ private void fillIndexedNodeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNe fillIndexedNodeInfosToInvalidate(closestNodeWithParentHavingBuiltDescendent.getIdNode(), true, invalidateNodeInfos); } - // OldName: fillIndexedModificationsInfosToInvalidate // For subTree private void fillIndexedNodeTreeInfosToInvalidate(NodeEntity nodeEntity, UUID rootNetworkUuid, InvalidateNodeInfos invalidateNodeInfos) { // when invalidating node @@ -962,7 +959,6 @@ private void fillIndexedNodeTreeInfosToInvalidate(NodeEntity nodeEntity, UUID ro } } - // OldName: invalidateChildrenBuildStatus private InvalidateNodeInfos invalidateChildrenNodes(UUID nodeUuid, UUID rootNetworkUuid) { InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); nodesRepository.findAllByParentNodeIdNode(nodeUuid) diff --git a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java index 6a7b5cc6d..f87d57163 100644 --- a/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java +++ b/src/main/java/org/gridsuite/study/server/service/RootNetworkNodeInfoService.java @@ -224,7 +224,6 @@ public void fillDeleteNodeInfo(UUID nodeUuid, DeleteNodeInfos deleteNodeInfos) { }); } - //old name : invalidateRootNetworkNodeInfoProper public InvalidateNodeInfos invalidateRootNetworkNode(UUID nodeUuid, UUID rootNetworUuid, boolean withInvalidationBuildStatus) { RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity = rootNetworkNodeInfoRepository.findByNodeInfoIdAndRootNetworkId(nodeUuid, rootNetworUuid).orElseThrow(() -> new StudyException(ROOT_NETWORK_NOT_FOUND)); @@ -299,7 +298,6 @@ public void invalidateRootNetworkNodeInfoProper(UUID nodeUuid, UUID rootNetworUu } } - //oldName: fillInvalidateNodeInfos private InvalidateNodeInfos getInvalidationComputationInfos(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity) { InvalidateNodeInfos invalidateNodeInfos = new InvalidateNodeInfos(); @@ -426,7 +424,6 @@ private void addLink(NetworkModificationNodeInfoEntity nodeInfoEntity, RootNetwo rootNetworkNodeInfoRepository.save(rootNetworkNodeInfoEntity); } - //oldName: invalidateRootNetworkNodeInfoBuildStatus private static void invalidateBuildStatus(RootNetworkNodeInfoEntity rootNetworkNodeInfoEntity, InvalidateNodeInfos invalidateNodeInfos) { rootNetworkNodeInfoEntity.setNodeBuildStatus(NodeBuildStatusEmbeddable.from(BuildStatus.NOT_BUILT)); rootNetworkNodeInfoEntity.setVariantId(UUID.randomUUID().toString()); diff --git a/src/main/java/org/gridsuite/study/server/service/StudyService.java b/src/main/java/org/gridsuite/study/server/service/StudyService.java index 6b05d67f5..116e7f2bb 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1741,8 +1741,7 @@ public void invalidateBuild(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, } } - // OldName: invalidateBuild part 1 - // Only one node + // Invalidate only one node private void invalidateNode(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { AtomicReference startTime = new AtomicReference<>(null); startTime.set(System.nanoTime()); @@ -1765,8 +1764,16 @@ private void invalidateNode(UUID studyUuid, UUID nodeUuid) { invalidateNode(studyUuid, nodeUuid, rootNetworkEntity.getId())); } - // OldName: invalidateBuild part 2 - // This is used to unbuild the node and its children + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid) { + invalidateNodeTree(studyUuid, nodeUuid, false); + } + + private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { + getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> + invalidateNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); + } + + // Invalidate the node and its children public void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid) { invalidateNodeTree(studyUuid, nodeUuid, rootNetworkUuid, false); } @@ -1788,15 +1795,6 @@ private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, UUID rootNetworkU } } - private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid) { - invalidateNodeTree(studyUuid, nodeUuid, false); - } - - private void invalidateNodeTree(UUID studyUuid, UUID nodeUuid, boolean invalidateOnlyChildrenBuildStatus) { - getStudyRootNetworks(studyUuid).forEach(rootNetworkEntity -> - invalidateNodeTree(studyUuid, nodeUuid, rootNetworkEntity.getId(), invalidateOnlyChildrenBuildStatus)); - } - public void deleteInvalidationInfos(InvalidateNodeInfos invalidateNodeInfos) { CompletableFuture executeInParallel = CompletableFuture.allOf( studyServerExecutionService.runAsync(() -> networkModificationService.deleteIndexedModifications(invalidateNodeInfos.getGroupUuids(), invalidateNodeInfos.getNetworkUuid())),