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 c45cf2aa3..6c2e0cacf 100644 --- a/src/main/java/org/gridsuite/study/server/controller/StudyController.java +++ b/src/main/java/org/gridsuite/study/server/controller/StudyController.java @@ -457,6 +457,18 @@ public ResponseEntity getVoltageLevelSwitches( return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getVoltageLevelSwitches(nodeUuid, rootNetworkUuid, voltageLevelId, inUpstreamBuiltParentNode)); } + @GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/topology") + @Operation(summary = "get the topology for a given network and a given voltage level") + @ApiResponse(responseCode = "200", description = "The topology of given voltage level") + public ResponseEntity getVoltageLevelTopology( + @PathVariable("studyUuid") UUID studyUuid, + @PathVariable("rootNetworkUuid") UUID rootNetworkUuid, + @PathVariable("nodeUuid") UUID nodeUuid, + @PathVariable("voltageLevelId") String voltageLevelId, + @Parameter(description = "Should get in upstream built node ?") @RequestParam(value = "inUpstreamBuiltParentNode", required = false, defaultValue = "false") boolean inUpstreamBuiltParentNode) { + return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(studyService.getVoltageLevelTopology(nodeUuid, rootNetworkUuid, voltageLevelId, inUpstreamBuiltParentNode)); + } + @GetMapping(value = "/studies/{studyUuid}/root-networks/{rootNetworkUuid}/nodes/{nodeUuid}/network/voltage-levels/{voltageLevelId}/substation-id") @Operation(summary = "get the substation ID for a given network and a given voltage level") @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "The substation Id for a voltageLevel")}) diff --git a/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java b/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java index 80be0e55e..ef6049065 100644 --- a/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java +++ b/src/main/java/org/gridsuite/study/server/service/NetworkMapService.java @@ -267,6 +267,20 @@ public String getVoltageLevelSwitches(UUID networkUuid, String variantId, }, networkUuid, voltageLevelId).getBody(); } + public String getVoltageLevelTopology(UUID networkUuid, String variantId, + String voltageLevelId, + String topologyPath) { + UriComponentsBuilder builder = UriComponentsBuilder.fromPath(DELIMITER + NETWORK_MAP_API_VERSION + + "/networks/{networkUuid}/voltage-levels/{voltageLevelId}/" + topologyPath); + if (!StringUtils.isBlank(variantId)) { + builder = builder.queryParam(QUERY_PARAM_VARIANT_ID, variantId); + } + + return restTemplate.exchange(networkMapServerBaseUri + builder.build().toUriString(), HttpMethod.GET, null, + new ParameterizedTypeReference() { + }, networkUuid, voltageLevelId).getBody(); + } + public void setNetworkMapServerBaseUri(String networkMapServerBaseUri) { this.networkMapServerBaseUri = networkMapServerBaseUri; } 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 c5b89334c..ff8f5221f 100644 --- a/src/main/java/org/gridsuite/study/server/service/StudyService.java +++ b/src/main/java/org/gridsuite/study/server/service/StudyService.java @@ -1841,6 +1841,14 @@ public String getVoltageLevelSwitches(UUID nodeUuid, UUID rootNetworkUuid, Strin return networkMapService.getVoltageLevelSwitches(networkUuid, variantId, voltageLevelId, switchesPath); } + public String getVoltageLevelTopology(UUID nodeUuid, UUID rootNetworkUuid, String voltageLevelId, + String topologyPath) { + UUID networkUuid = rootNetworkService.getNetworkUuid(rootNetworkUuid); + String variantId = networkModificationTreeService.getVariantId(nodeUuid, rootNetworkUuid); + + return networkMapService.getVoltageLevelTopology(networkUuid, variantId, voltageLevelId, topologyPath); + } + public String getVoltageLevelSubstationId(UUID studyUuid, UUID nodeUuid, UUID rootNetworkUuid, String voltageLevelId, boolean inUpstreamBuiltParentNode) { UUID nodeUuidToSearchIn = getNodeUuidToSearchIn(nodeUuid, rootNetworkUuid, inUpstreamBuiltParentNode); return getVoltageLevelSubstationId(nodeUuidToSearchIn, rootNetworkUuid, voltageLevelId); @@ -1856,6 +1864,11 @@ public String getVoltageLevelSwitches(UUID nodeUuid, UUID rootNetworkUuid, Strin return getVoltageLevelSwitches(nodeUuidToSearchIn, rootNetworkUuid, voltageLevelId, "switches"); } + public String getVoltageLevelTopology(UUID nodeUuid, UUID rootNetworkUuid, String voltageLevelId, boolean inUpstreamBuiltParentNode) { + UUID nodeUuidToSearchIn = getNodeUuidToSearchIn(nodeUuid, rootNetworkUuid, inUpstreamBuiltParentNode); + return getVoltageLevelTopology(nodeUuidToSearchIn, rootNetworkUuid, voltageLevelId, "topology"); + } + @Transactional public void buildNode(@NonNull UUID studyUuid, @NonNull UUID nodeUuid, @NonNull UUID rootNetworkUuid, @NonNull String userId) { buildNode(studyUuid, nodeUuid, rootNetworkUuid, userId, null);