From abbf14567195cc79a92d948da09a1207205ead70 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Fri, 20 Mar 2020 15:18:09 +0100 Subject: [PATCH 1/4] Add methods to get all geo data Signed-off-by: Geoffroy Jamgotchian --- .../powsybl/geodata/server/GeoDataController.java | 14 ++++++++++++++ .../com/powsybl/geodata/server/GeoDataService.java | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java index c779ee81..3c64751b 100755 --- a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java +++ b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java @@ -49,6 +49,13 @@ private static Set toCountrySet(@RequestParam(required = false) List> getSubstations() { + return ResponseEntity.ok().body(geoDataService.getSubstations()); + } + + @GetMapping(value = "/substations/{networkUuid}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get substations geographical data", response = List.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "Substations geographical data")}) public ResponseEntity> getSubstations(@RequestParam UUID networkUuid, @@ -60,6 +67,13 @@ public ResponseEntity> getSubstations(@RequestParam UUID } @GetMapping(value = "/lines", produces = MediaType.APPLICATION_JSON_VALUE) + @ApiOperation(value = "Get all lines geographical data", response = List.class) + @ApiResponses(value = {@ApiResponse(code = 200, message = "All lines geographical data")}) + public ResponseEntity> getLines() { + return ResponseEntity.ok().body(geoDataService.getLines()); + } + + @GetMapping(value = "/lines/{networkUuid}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get lines geographical data", response = List.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "Lines geographical data")}) public ResponseEntity> getLines(@RequestParam UUID networkUuid, diff --git a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java index 418447e5..0d7d9f91 100755 --- a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java +++ b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java @@ -60,6 +60,11 @@ private Map readSubstationGeoDataFromDb(Set return substationsGeoDataDB; } + List getSubstations() { + LOGGER.info("Loading all substations geo data"); + return new ArrayList<>(readSubstationGeoDataFromDb(null).values()); + } + List getSubstations(Network network, Set countries) { LOGGER.info("Loading substations geo data for countries {} of network '{}'", countries, network.getId()); @@ -236,6 +241,12 @@ void saveLines(List linesGeoData) { lineRepository.saveAll(linesEntities); } + List getLines() { + LOGGER.info("Loading all lines geo data"); + + return new ArrayList<>(lineCustomRepository.getLines().values()); + } + List getLines(Network network, Set countries) { LOGGER.info("Loading lines geo data for countries {} of network '{}'", countries, network.getId()); From 5a4c3a8371a4e40ce965ef31754c11d749b53c23 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Fri, 20 Mar 2020 15:20:38 +0100 Subject: [PATCH 2/4] Add blank line Signed-off-by: Geoffroy Jamgotchian --- .../src/main/java/com/powsybl/geodata/server/GeoDataService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java index 0d7d9f91..ffa497e5 100755 --- a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java +++ b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataService.java @@ -62,6 +62,7 @@ private Map readSubstationGeoDataFromDb(Set List getSubstations() { LOGGER.info("Loading all substations geo data"); + return new ArrayList<>(readSubstationGeoDataFromDb(null).values()); } From d1a580e19feccc225383fa1f114c5d86951d7ea4 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Fri, 20 Mar 2020 15:33:07 +0100 Subject: [PATCH 3/4] Fix Signed-off-by: Geoffroy Jamgotchian --- .../geodata/server/GeoDataController.java | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java index 3c64751b..741e40b0 100755 --- a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java +++ b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java @@ -48,39 +48,27 @@ private static Set toCountrySet(@RequestParam(required = false) List> getSubstations() { - return ResponseEntity.ok().body(geoDataService.getSubstations()); - } - @GetMapping(value = "/substations/{networkUuid}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get substations geographical data", response = List.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "Substations geographical data")}) - public ResponseEntity> getSubstations(@RequestParam UUID networkUuid, + public ResponseEntity> getSubstations(@RequestParam(required = false) UUID networkUuid, @RequestParam(required = false) List countries) { Set countrySet = toCountrySet(countries); Network network = networkStoreService.getNetwork(networkUuid); - List substations = geoDataService.getSubstations(network, countrySet); + List substations = networkUuid != null ? geoDataService.getSubstations(network, countrySet) + : geoDataService.getSubstations(); return ResponseEntity.ok().body(substations); } - @GetMapping(value = "/lines", produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(value = "Get all lines geographical data", response = List.class) - @ApiResponses(value = {@ApiResponse(code = 200, message = "All lines geographical data")}) - public ResponseEntity> getLines() { - return ResponseEntity.ok().body(geoDataService.getLines()); - } - @GetMapping(value = "/lines/{networkUuid}", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get lines geographical data", response = List.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "Lines geographical data")}) - public ResponseEntity> getLines(@RequestParam UUID networkUuid, + public ResponseEntity> getLines(@RequestParam(required = false) UUID networkUuid, @RequestParam(required = false) List countries) { Set countrySet = toCountrySet(countries); Network network = networkStoreService.getNetwork(networkUuid); - List lines = geoDataService.getLines(network, countrySet); + List lines = networkUuid != null ? geoDataService.getLines(network, countrySet) + : geoDataService.getLines(); return ResponseEntity.ok().body(lines); } From d70681158e521469056ce38d68b2267924ee3fd7 Mon Sep 17 00:00:00 2001 From: Geoffroy Jamgotchian Date: Fri, 20 Mar 2020 15:34:27 +0100 Subject: [PATCH 4/4] Fix Signed-off-by: Geoffroy Jamgotchian --- .../java/com/powsybl/geodata/server/GeoDataController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java index 741e40b0..01e9595f 100755 --- a/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java +++ b/geo-data-server/src/main/java/com/powsybl/geodata/server/GeoDataController.java @@ -48,7 +48,7 @@ private static Set toCountrySet(@RequestParam(required = false) List> getSubstations(@RequestParam(required = false) UUID networkUuid, @@ -60,7 +60,7 @@ public ResponseEntity> getSubstations(@RequestParam(requ return ResponseEntity.ok().body(substations); } - @GetMapping(value = "/lines/{networkUuid}", produces = MediaType.APPLICATION_JSON_VALUE) + @GetMapping(value = "/lines", produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Get lines geographical data", response = List.class) @ApiResponses(value = {@ApiResponse(code = 200, message = "Lines geographical data")}) public ResponseEntity> getLines(@RequestParam(required = false) UUID networkUuid,