Skip to content
Merged
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased/Snapshot]

### Added

### Fixed

### Changed
- `SqlIdCoordinateSource.createCooridinateValue` now throws an exception when the coordinate can not be built [#911](https://github.com/ie3-institute/PowerSystemDataModel/issues/911)

## [4.0.0] - 2023-08-01

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,27 +173,18 @@ public List<CoordinateDistance> getClosestCoordinates(

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

private Optional<CoordinateValue> createCoordinateValue(Map<String, String> fieldToValues) {
private CoordinateValue createCoordinateValue(Map<String, String> fieldToValues) {
fieldToValues.remove("distance");

SimpleFactoryData simpleFactoryData = new SimpleFactoryData(fieldToValues, Pair.class);
Optional<Pair<Integer, Point>> pair = factory.get(simpleFactoryData).getData();

if (pair.isEmpty()) {
return Optional.empty();
} else {
Pair<Integer, Point> data = pair.get();
return Optional.of(new CoordinateValue(data.getKey(), data.getValue()));
}
Pair<Integer, Point> pair = factory.get(simpleFactoryData).getOrThrow();
return new CoordinateValue(pair.getKey(), pair.getValue());
}

private List<CoordinateValue> executeQueryToList(
String query, SqlDataSource.AddParams addParams) {
return dataSource
.executeQuery(query, addParams)
.map(this::createCoordinateValue)
.flatMap(Optional::stream)
.toList();
return dataSource.executeQuery(query, addParams).map(this::createCoordinateValue).toList();
}

/**
Expand Down