Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/root-network-in-controller' into…
Browse files Browse the repository at this point in the history
… root-network-computation-endpoints
  • Loading branch information
LE SAULNIER Kevin committed Jan 8, 2025
2 parents 1bba141 + 89dabd9 commit f847961
Show file tree
Hide file tree
Showing 20 changed files with 104 additions and 35 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<groupId>org.gridsuite</groupId>
<artifactId>gridsuite-study-server</artifactId>
<version>2.11.0-SNAPSHOT</version>
<version>2.12.0-SNAPSHOT</version>

<packaging>jar</packaging>
<name>Study Server</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ private StudyConstants() {
public static final String HEADER_IMPORT_PARAMETERS = "importParameters";
public static final String HEADER_MESSAGE = "message";
public static final String HEADER_USER_ID = "userId";
public static final String HEADER_ERROR_MESSAGE = "x-exception-message";
public static final String QUERY_PARAM_ONLY_STASHED = "onlyStashed";
public static final String QUERY_PARAM_STASHED = "stashed";
public static final String QUERY_PARAM_ACTIVATED = "activated";
Expand Down
19 changes: 19 additions & 0 deletions src/main/java/org/gridsuite/study/server/StudyController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,25 @@ public ResponseEntity<List<ReportLog>> getNodeReportLogs(@Parameter(description
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getReportLogs(reportId, messageFilter, severityLevels));
}

@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/report/{reportId}/aggregated-severities", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get node report severities")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The node report severities"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
public ResponseEntity<Set<String>> getNodeReportAggregatedSeverities(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid,
@Parameter(description = "reportId") @PathVariable("reportId") UUID reportId) {
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getNodeReportAggregatedSeverities(reportId));
}

@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/report/aggregated-severities", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get the report severities of the given node and all its parents")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report severities of the node and all its parent"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
public ResponseEntity<Set<String>> getParentNodesAggregatedReportSeverities(@Parameter(description = "Study uuid") @PathVariable("studyUuid") UUID studyUuid,
@Parameter(description = "node id") @PathVariable("nodeUuid") UUID nodeUuid) {
studyService.assertIsStudyAndNodeExist(studyUuid, nodeUuid);
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getParentNodesAggregatedReportSeverities(nodeUuid, studyService.getStudyFirstRootNetworkUuid(studyUuid)));
}

@GetMapping(value = "/studies/{studyUuid}/nodes/{nodeUuid}/report/logs", produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "Get the report logs of the given node and all its parents")
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The report logs of the node and all its parent"), @ApiResponse(responseCode = "404", description = "The study/node is not found")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public class LimitViolationInfos {

private String subjectId;

private String locationId;

private Double limit;

private String limitName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.util.Strings;
import org.gridsuite.study.server.StudyConstants;
import org.gridsuite.study.server.dto.*;
import org.gridsuite.study.server.dto.caseimport.CaseImportAction;
import org.gridsuite.study.server.dto.caseimport.CaseImportReceiver;
Expand Down Expand Up @@ -164,7 +165,7 @@ public Consumer<Message<String>> consumeBuildFailed() {

// send notification
UUID studyUuid = networkModificationTreeService.getStudyUuidForNodeId(receiverObj.getNodeUuid());
notificationService.emitNodeBuildFailed(studyUuid, receiverObj.getNodeUuid(), message.getHeaders().get(HEADER_MESSAGE, String.class));
notificationService.emitNodeBuildFailed(studyUuid, receiverObj.getNodeUuid(), message.getHeaders().get(StudyConstants.HEADER_ERROR_MESSAGE, String.class));
} catch (JsonProcessingException e) {
LOGGER.error(e.toString());
}
Expand Down Expand Up @@ -409,7 +410,7 @@ public Consumer<Message<String>> consumeCaseImportFailed() {
*/
public void consumeCalculationFailed(Message<String> msg, ComputationType computationType) {
String receiver = msg.getHeaders().get(HEADER_RECEIVER, String.class);
String errorMessage = msg.getHeaders().get(HEADER_MESSAGE, String.class);
String errorMessage = msg.getHeaders().get(StudyConstants.HEADER_ERROR_MESSAGE, String.class);
String userId = msg.getHeaders().get(HEADER_USER_ID, String.class);
UUID resultUuid = null;
// resultUuid is only used for the voltage initialization computation, I don't know why
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,12 @@ public UUID duplicateReport(@NonNull UUID id) {
return UUID.randomUUID();
}
}

public Set<String> getReportAggregatedSeverities(@NonNull UUID id) {
var path = UriComponentsBuilder.fromPath("{id}/aggregated-severities").buildAndExpand(id).toUriString();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
return restTemplate.exchange(this.getReportsServerURI() + path, HttpMethod.GET, new HttpEntity<>(headers), new ParameterizedTypeReference<Set<String>>() {
}).getBody();
}
}
16 changes: 16 additions & 0 deletions src/main/java/org/gridsuite/study/server/service/StudyService.java
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,22 @@ public List<ReportLog> getReportLogs(String reportId, String messageFilter, Set<
return reportService.getReportLogs(UUID.fromString(reportId), messageFilter, severityLevels);
}

public Set<String> getNodeReportAggregatedSeverities(UUID reportId) {
return reportService.getReportAggregatedSeverities(reportId);
}

public Set<String> getParentNodesAggregatedReportSeverities(UUID nodeUuid, UUID rootNetworkUuid) {
List<UUID> nodeIds = nodesTree(nodeUuid);
Set<String> severities = new HashSet<>();
Map<UUID, UUID> modificationReportsMap = networkModificationTreeService.getModificationReports(nodeUuid, rootNetworkUuid);

for (UUID nodeId : nodeIds) {
UUID reportId = modificationReportsMap.getOrDefault(nodeId, networkModificationTreeService.getReportUuid(nodeId, rootNetworkUuid));
severities.addAll(reportService.getReportAggregatedSeverities(reportId));
}
return severities;
}

@Transactional(readOnly = true)
public List<ReportLog> getParentNodesReportLogs(UUID nodeUuid, UUID rootNetworkUuid, String messageFilter, Set<String> severityLevels) {
List<UUID> nodeIds = nodesTree(nodeUuid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public enum RemoteServiceName {
SENSITIVITY_ANALYSIS_SERVER,
SHORTCIRCUIT_SERVER,
SINGLE_LINE_DIAGRAM_SERVER,
SPREADSHEET_CONFIG_SERVER,
STATE_ESTIMATION_ORCHESTRATOR_SERVER,
STATE_ESTIMATION_SERVER,
STUDY_CONFIG_SERVER,
STUDY_NOTIFICATION_SERVER,
STUDY_SERVER,
TIMESERIES_SERVER,
Expand Down
41 changes: 20 additions & 21 deletions src/main/resources/config/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ spring:
name: study-server
main:
allow-circular-references: true

cloud:
function:
definition: "consumeSaResult;consumeSaStopped;consumeSaFailed;consumeSaCancelFailed;\
Expand Down Expand Up @@ -32,35 +31,35 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.cancelfailed
group: studySaCancelFailedGroup
consumeSaFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.failed
group: studySaFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sa.run.dlx
group: dlq
consumeDsResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.result
group: studyDsResultGroup
consumeDsStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.stopped
group: studyDsStoppedGroup
consumeDsFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.failed
group: studyDsFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}ds.run.dlx
group: dlq
consumeBuildResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.result
group: studyBuildResultGroup
consumeBuildStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.stopped
group: studyBuildStoppedGroup
consumeBuildFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.failed
group: studyBuildFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}build.run.dlx
group: dlq
consumeLoadFlowResult-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.result
group: studyLoadFlowResultGroup
consumeLoadFlowStopped-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.stopped
group: studyLoadFlowStoppedGroup
consumeLoadFlowFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.failed
group: studyLoadFlowFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.run.dlx
group: dlq
consumeLoadFlowCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}loadflow.cancelfailed
group: studyLoadFlowCancelFailedGroup
Expand All @@ -71,8 +70,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.stopped
group: studySensitivityAnalysisStoppedGroup
consumeSensitivityAnalysisFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.failed
group: studySensitivityAnalysisFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.run.dlx
group: dlq
consumeSensitivityAnalysisCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}sensitivityanalysis.cancelfailed
group: studySensitivityAnalysisCancelFailedGroup
Expand All @@ -83,8 +82,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.stopped
group: studyNonEvacuatedEnergyStoppedGroup
consumeNonEvacuatedEnergyFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.failed
group: studyNonEvacuatedEnergyFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.run.dlx
group: dlq
consumeNonEvacuatedEnergyCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}nonEvacuatedEnergy.cancelfailed
group: studyNonEvacuatedEnergyCancelFailedGroup
Expand All @@ -95,8 +94,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.stopped
group: studyShortCircuitAnalysisStoppedGroup
consumeShortCircuitAnalysisFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.failed
group: studyShortCircuitAnalysisFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.run.dlx
group: dlq
consumeShortCircuitAnalysisCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}shortcircuitanalysis.cancelfailed
group: studyShortCircuitAnalysisCancelFailedGroup
Expand All @@ -107,8 +106,8 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.stopped
group: studyVoltageInitStoppedGroup
consumeVoltageInitFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.failed
group: studyVoltageInitFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.run.dlx
group: dlq
consumeVoltageInitCancelFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}voltageinit.cancelfailed
group: studyVoltageInitCancelFailedGroup
Expand All @@ -119,14 +118,14 @@ spring:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.stopped
group: studyStateEstimationStoppedGroup
consumeStateEstimationFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.failed
group: studyStateEstimationFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}stateestimation.run.dlx
group: dlq
consumeCaseImportSucceeded-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.succeeded
group: studyCaseImportSucceededGroup
consumeCaseImportFailed-in-0:
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.failed
group: studyCaseImportFailedGroup
destination: ${powsybl-ws.rabbitmq.destination.prefix:}case.import.start.dlx
group: dlq
output-bindings: publishStudyUpdate-out-0;publishElementUpdate-out-0

powsybl:
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/gridsuite/study/server/LoadFlowTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class LoadFlowTest {
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";
private static final String LOADFLOW_RESULT_DESTINATION = "loadflow.result";
private static final String LOADFLOW_STOPPED_DESTINATION = "loadflow.stopped";
private static final String LOADFLOW_FAILED_DESTINATION = "loadflow.failed";
private static final String LOADFLOW_FAILED_DESTINATION = "loadflow.run.dlx";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.*;

import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
import static org.gridsuite.study.server.StudyConstants.HEADER_ERROR_MESSAGE;
import static org.gridsuite.study.server.StudyConstants.QUERY_PARAM_RECEIVER;
import static org.gridsuite.study.server.utils.ImpactUtils.createModificationResultWithElementImpact;
import static org.gridsuite.study.server.utils.MatcherCreatedStudyBasicInfos.createMatcherCreatedStudyBasicInfos;
Expand Down Expand Up @@ -263,7 +264,7 @@ void setup(final MockWebServer server) {
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", DEFAULT_BUILD_RESULT, "destination", "build.result"))
.willReturn(WireMock.ok())).getId();
buildFailedStubId = wireMockServer.stubFor(WireMock.post(WireMock.urlPathEqualTo("/v1/networks/" + NETWORK_UUID_2_STRING + "/build"))
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", "", "destination", "build.failed", "message", ERROR_MESSAGE))
.withPostServeAction(POST_ACTION_SEND_INPUT, Map.of("payload", "", "destination", "build.run.dlx", HEADER_ERROR_MESSAGE, ERROR_MESSAGE))
.willReturn(WireMock.ok())).getId();
buildErrorStubId = wireMockServer.stubFor(WireMock.post(WireMock.urlPathEqualTo("/v1/networks/" + NETWORK_UUID_3_STRING + "/build"))
.willReturn(WireMock.serverError())).getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class NonEvacuatedEnergyTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String NON_EVACUATED_ENERGY_RESULT_DESTINATION = "nonEvacuatedEnergy.result";
private static final String NON_EVACUATED_ENERGY_STOPPED_DESTINATION = "nonEvacuatedEnergy.stopped";
private static final String NON_EVACUATED_ENERGY_FAILED_DESTINATION = "nonEvacuatedEnergy.failed";
private static final String NON_EVACUATED_ENERGY_FAILED_DESTINATION = "nonEvacuatedEnergy.run.dlx";
@Autowired
private RootNetworkNodeInfoService rootNetworkNodeInfoService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class SecurityAnalysisTest {
private final String studyUpdateDestination = "study.update";
private final String saResultDestination = "sa.result";
private final String saStoppedDestination = "sa.stopped";
private final String saFailedDestination = "sa.failed";
private final String saFailedDestination = "sa.run.dlx";
@Autowired
private RootNetworkNodeInfoService rootNetworkNodeInfoService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ class SensitivityAnalysisTest {
private static final String ELEMENT_UPDATE_DESTINATION = "element.update";
private static final String SENSITIVITY_ANALYSIS_RESULT_DESTINATION = "sensitivityanalysis.result";
private static final String SENSITIVITY_ANALYSIS_STOPPED_DESTINATION = "sensitivityanalysis.stopped";
private static final String SENSITIVITY_ANALYSIS_FAILED_DESTINATION = "sensitivityanalysis.failed";
private static final String SENSITIVITY_ANALYSIS_FAILED_DESTINATION = "sensitivityanalysis.run.dlx";

private static final byte[] SENSITIVITY_RESULTS_AS_CSV = {0x00, 0x01};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class ShortCircuitTest implements WithAssertions {
private final String elementUpdateDestination = "element.update";
private final String shortCircuitAnalysisResultDestination = "shortcircuitanalysis.result";
private final String shortCircuitAnalysisStoppedDestination = "shortcircuitanalysis.stopped";
private final String shortCircuitAnalysisFailedDestination = "shortcircuitanalysis.failed";
private final String shortCircuitAnalysisFailedDestination = "shortcircuitanalysis.run.dlx";
@Autowired
private StudyService studyService;
@Autowired
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class StateEstimationTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String ESTIM_RESULT_JSON_DESTINATION = "stateestimation.result";
private static final String ESTIM_STOPPED_DESTINATION = "stateestimation.stopped";
private static final String ESTIM_FAILED_DESTINATION = "stateestimation.failed";
private static final String ESTIM_FAILED_DESTINATION = "stateestimation.run.dlx";

@Autowired
private MockMvc mockMvc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class StudyControllerDynamicSimulationTest {
private static final String STUDY_UPDATE_DESTINATION = "study.update";
private static final String DS_RESULT_DESTINATION = "ds.result";
private static final String DS_STOPPED_DESTINATION = "ds.stopped";
private static final String DS_FAILED_DESTINATION = "ds.failed";
private static final String DS_FAILED_DESTINATION = "ds.run.dlx";

@BeforeEach
public void setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/gridsuite/study/server/StudyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ private void sendCaseImportFailedMessage(String requestPath, String errorMessage
String receiverUrlString = matcher.group(1);
input.send(MessageBuilder.withPayload("").setHeader("receiver", URLDecoder.decode(receiverUrlString, StandardCharsets.UTF_8))
.setHeader("errorMessage", errorMessage)
.build(), "case.import.failed");
.build(), "case.import.start.dlx");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class VoltageInitTest {
private final String studyUpdateDestination = "study.update";
private final String voltageInitResultDestination = "voltageinit.result";
private final String voltageInitStoppedDestination = "voltageinit.stopped";
private final String voltageInitFailedDestination = "voltageinit.failed";
private final String voltageInitFailedDestination = "voltageinit.run.dlx";
private final String voltageInitCancelFailedDestination = "voltageinit.cancelfailed";
private final String elementUpdateDestination = "element.update";
@Autowired
Expand Down
Loading

0 comments on commit f847961

Please sign in to comment.