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 d534bbdbf..fbdbf9bbf 100644 --- a/src/main/java/org/gridsuite/study/server/notification/NotificationService.java +++ b/src/main/java/org/gridsuite/study/server/notification/NotificationService.java @@ -12,6 +12,7 @@ import org.gridsuite.study.server.networkmodificationtree.dto.InsertMode; import org.gridsuite.study.server.notification.dto.NetworkImpactsInfos; import org.gridsuite.study.server.notification.dto.StudyAlert; +import org.gridsuite.study.server.notification.dto.StudyParametersInfos; import org.gridsuite.study.server.utils.annotations.PostCompletion; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -165,6 +166,19 @@ public void emitStudyChanged(UUID studyUuid, UUID nodeUuid, String updateType) { .build()); } + @PostCompletion + public void emitStudyParamsChanged(UUID studyUuid, String updateType, StudyParametersInfos studyParametersInfos) { + //todo: update type: comment c'est géré en front? + try { + sendUpdateMessage(MessageBuilder.withPayload(objectMapper.writeValueAsString(studyParametersInfos)) + .setHeader(HEADER_STUDY_UUID, studyUuid) + .setHeader(HEADER_UPDATE_TYPE, updateType) + .build()); + } catch (JsonProcessingException e) { + LOGGER.error("Unable to notify on study alert", e); + } + } + public void emitStudyCreationError(UUID studyUuid, String userId, String errorMessage) { sendUpdateMessage(MessageBuilder.withPayload("") .setHeader(HEADER_STUDY_UUID, studyUuid) diff --git a/src/main/java/org/gridsuite/study/server/notification/dto/StudyParametersInfos.java b/src/main/java/org/gridsuite/study/server/notification/dto/StudyParametersInfos.java new file mode 100644 index 000000000..f50513d94 --- /dev/null +++ b/src/main/java/org/gridsuite/study/server/notification/dto/StudyParametersInfos.java @@ -0,0 +1,14 @@ +/** + * Copyright (c) 2024, RTE (http://www.rte-france.com) + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +package org.gridsuite.study.server.notification.dto; + +/** + * @author AJELLAL Ali + */ +public record StudyParametersInfos(String name, String provider) { +} 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 7e3c802ac..3ff6ca7e4 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -39,6 +39,7 @@ import org.gridsuite.study.server.networkmodificationtree.entities.NodeEntity; import org.gridsuite.study.server.notification.NotificationService; import org.gridsuite.study.server.notification.dto.NetworkImpactsInfos; +import org.gridsuite.study.server.notification.dto.StudyParametersInfos; import org.gridsuite.study.server.repository.*; import org.gridsuite.study.server.repository.nonevacuatedenergy.NonEvacuatedEnergyParametersEntity; import org.gridsuite.study.server.repository.voltageinit.StudyVoltageInitParametersEntity; @@ -803,6 +804,7 @@ public void setSecurityAnalysisParametersValues(UUID studyUuid, String parameter StudyEntity studyEntity = studyRepository.findById(studyUuid).orElseThrow(() -> new StudyException(STUDY_NOT_FOUND)); createOrUpdateSecurityAnalysisParameters(studyUuid, studyEntity, parameters); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitStudyParamsChanged(studyUuid, "study", new StudyParametersInfos("SecurityAnalysis", null)); } public NonEvacuatedEnergyParametersInfos getNonEvacuatedEnergyParametersInfos(UUID studyUuid) { @@ -828,6 +830,7 @@ public boolean setLoadFlowParameters(UUID studyUuid, String parameters, String u notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_NON_EVACUATED_ENERGY_STATUS); notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_DYNAMIC_SIMULATION_STATUS); notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitStudyParamsChanged(studyUuid, "study", new StudyParametersInfos("LoadFlow", null)); return userProfileIssue; } @@ -858,6 +861,8 @@ public void updateLoadFlowProvider(UUID studyUuid, String provider, String userI loadflowService.updateLoadFlowProvider(studyEntity.getLoadFlowParametersUuid(), provider); invalidateLoadFlowStatusOnAllNodes(studyUuid); notificationService.emitStudyChanged(studyUuid, null, NotificationService.UPDATE_TYPE_LOADFLOW_STATUS); + notificationService.emitStudyParamsChanged(studyUuid, "study", new StudyParametersInfos("LoadFlow", provider)); + }); } @@ -928,6 +933,8 @@ public void setShortCircuitParameters(UUID studyUuid, @Nullable String shortCirc studyRepository.save(studyEntity); } notificationService.emitElementUpdated(studyUuid, userId); + notificationService.emitStudyParamsChanged(studyUuid, "study", new StudyParametersInfos("SecurityAnalysis", null)); + } @Transactional