Skip to content

Fix params notification. #609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
*/
public record StudyParametersInfos(String name, String provider) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand Down Expand Up @@ -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));

});
}

Expand Down Expand Up @@ -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
Expand Down
Loading