Skip to content
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 @@ -51,22 +51,24 @@ private static Set<Country> toCountrySet(@RequestParam(required = false) List<St
@GetMapping(value = "/substations", 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<List<SubstationGeoData>> getSubstations(@RequestParam UUID networkUuid,
public ResponseEntity<List<SubstationGeoData>> getSubstations(@RequestParam(required = false) UUID networkUuid,
@RequestParam(required = false) List<String> countries) {
Set<Country> countrySet = toCountrySet(countries);
Network network = networkStoreService.getNetwork(networkUuid);
List<SubstationGeoData> substations = geoDataService.getSubstations(network, countrySet);
List<SubstationGeoData> 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 lines geographical data", response = List.class)
@ApiResponses(value = {@ApiResponse(code = 200, message = "Lines geographical data")})
public ResponseEntity<List<LineGeoData>> getLines(@RequestParam UUID networkUuid,
public ResponseEntity<List<LineGeoData>> getLines(@RequestParam(required = false) UUID networkUuid,
@RequestParam(required = false) List<String> countries) {
Set<Country> countrySet = toCountrySet(countries);
Network network = networkStoreService.getNetwork(networkUuid);
List<LineGeoData> lines = geoDataService.getLines(network, countrySet);
List<LineGeoData> lines = networkUuid != null ? geoDataService.getLines(network, countrySet)
: geoDataService.getLines();
return ResponseEntity.ok().body(lines);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ private Map<String, SubstationGeoData> readSubstationGeoDataFromDb(Set<Country>
return substationsGeoDataDB;
}

List<SubstationGeoData> getSubstations() {
LOGGER.info("Loading all substations geo data");

return new ArrayList<>(readSubstationGeoDataFromDb(null).values());
}

List<SubstationGeoData> getSubstations(Network network, Set<Country> countries) {
LOGGER.info("Loading substations geo data for countries {} of network '{}'", countries, network.getId());

Expand Down Expand Up @@ -236,6 +242,12 @@ void saveLines(List<LineGeoData> linesGeoData) {
lineRepository.saveAll(linesEntities);
}

List<LineGeoData> getLines() {
LOGGER.info("Loading all lines geo data");

return new ArrayList<>(lineCustomRepository.getLines().values());
}

List<LineGeoData> getLines(Network network, Set<Country> countries) {
LOGGER.info("Loading lines geo data for countries {} of network '{}'", countries, network.getId());

Expand Down