Skip to content

Commit 6a491b0

Browse files
committed
Merge branch 'dev' into ms/#1226-change-SubgridContainer-to-be-in-line-with-the-galvanical-seperation
# Conflicts: # CHANGELOG.md
2 parents 66a9db7 + 40ca41a commit 6a491b0

38 files changed

+361
-307
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased/Snapshot]
88

9+
### Added
10+
- Extend Validation to EnergyManagement Systems. [#1356](https://github.com/ie3-institute/PowerSystemDataModel/issues/1356)
11+
912
### Fixed
1013
- Fixed handling of `CongestionResult.InputModelType` in `EntityProcessor` [#1325](https://github.com/ie3-institute/PowerSystemDataModel/issues/1325)
1114
- Fixed em fields in input models [#1331](https://github.com/ie3-institute/PowerSystemDataModel/issues/1331)
@@ -14,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1417
### Changed
1518
- Updated dependabot workflow and added CODEOWNERS [#1328](https://github.com/ie3-institute/PowerSystemDataModel/issues/1328)
1619
- Extend azimuth angle range to [-180°, 180°] for PV inputs [#1330](https://github.com/ie3-institute/PowerSystemDataModel/issues/1330)
20+
- Improved error messages when reading and validating an invalid grid [#1354](https://github.com/ie3-institute/PowerSystemDataModel/issues/1354)
1721
- Changed `SubgridContainer` to represent galvanically seperated grids [#1226](https://github.com/ie3-institute/PowerSystemDataModel/issues/1226)
1822

1923
## [7.0.0] - 2025-05-08

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'signing'
66
id 'pmd' // code check, working on source code
77
id 'com.diffplug.spotless' version '7.1.0' //code format
8-
id 'com.github.spotbugs' version '6.2.1' // code check, working on byte code
8+
id 'com.github.spotbugs' version '6.2.2' // code check, working on byte code
99
id 'de.undercouch.download' version '5.6.0'
1010
id 'kr.motd.sphinx' version '2.10.1' // documentation generation
1111
id 'jacoco' // java code coverage plugin

src/main/java/edu/ie3/datamodel/exceptions/DuplicateEntitiesException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public DuplicateEntitiesException(
1919
this(
2020
"The following exception(s) occurred while checking the uniqueness of '"
2121
+ entityName
22-
+ "' entities: "
23-
+ ExceptionUtils.getMessages(exceptions));
22+
+ "' entities: \n"
23+
+ ExceptionUtils.combineExceptions(exceptions));
2424
}
2525
}

src/main/java/edu/ie3/datamodel/exceptions/FailedValidationException.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public FailedValidationException(String message) {
2323

2424
/** @param exceptions List of exceptions, which must not be empty */
2525
public FailedValidationException(List<? extends Exception> exceptions) {
26-
super(
27-
"Validation failed due to: \n" + ExceptionUtils.getMessages(exceptions), exceptions.get(0));
26+
super("Validation failed due to:\n " + ExceptionUtils.combineExceptions(exceptions));
2827
}
2928
}

src/main/java/edu/ie3/datamodel/exceptions/InvalidEntityException.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ public class InvalidEntityException extends ValidationException {
1313
private static final long serialVersionUID = 809496087520306374L;
1414

1515
public InvalidEntityException(String faultDescription, UniqueEntity invalidEntity) {
16-
super("Entity is invalid because of: \n" + faultDescription + " [" + invalidEntity + "]");
16+
super("Entity is invalid because of: " + faultDescription + " [" + invalidEntity + "]");
1717
}
1818

1919
public InvalidEntityException(
2020
String faultDescription, Throwable cause, UniqueEntity invalidEntity) {
21-
super(
22-
"Entity is invalid because of: \n" + faultDescription + " [" + invalidEntity + "]", cause);
21+
super("Entity is invalid because of: " + faultDescription + " [" + invalidEntity + "]", cause);
2322
}
2423

2524
public InvalidEntityException(String message, Throwable cause) {

src/main/java/edu/ie3/datamodel/exceptions/SourceException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ public SourceException(final String message) {
3232
}
3333

3434
public SourceException(String message, List<? extends Exception> exceptions) {
35-
super(message + " " + ExceptionUtils.getMessages(exceptions), exceptions.get(0));
35+
super(message + "\n " + ExceptionUtils.combineExceptions(exceptions));
3636
}
3737
}

src/main/java/edu/ie3/datamodel/io/factory/Factory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Try<R, FactoryException> get(D data) {
7373
* {@link Failure}
7474
*/
7575
public Try<R, FactoryException> get(Try<D, ?> data) {
76-
return data.transformF(FactoryException::new).flatMap(this::get);
76+
return data.transformF(e -> new FactoryException(e.getMessage(), e)).flatMap(this::get);
7777
}
7878

7979
/**

src/main/java/edu/ie3/datamodel/io/processor/ProcessorProvider.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package edu.ie3.datamodel.io.processor;
77

88
import edu.ie3.datamodel.exceptions.EntityProcessorException;
9-
import edu.ie3.datamodel.exceptions.FailureException;
109
import edu.ie3.datamodel.exceptions.ProcessorProviderException;
1110
import edu.ie3.datamodel.io.processor.input.InputEntityProcessor;
1211
import edu.ie3.datamodel.io.processor.result.ResultEntityProcessor;
@@ -313,25 +312,22 @@ public static Collection<EntityProcessor<? extends Entity>> allResultEntityProce
313312
Value,
314313
Value>>
315314
allTimeSeriesProcessors() throws EntityProcessorException {
316-
try {
317-
return Try.scanStream(
318-
TimeSeriesProcessor.eligibleKeys.stream()
319-
.map(
320-
key ->
321-
Try.of(
322-
() ->
323-
new TimeSeriesProcessor<>(
324-
(Class<TimeSeries<TimeSeriesEntry<Value>, Value, Value>>)
325-
key.getTimeSeriesClass(),
326-
(Class<TimeSeriesEntry<Value>>) key.getEntryClass(),
327-
(Class<Value>) key.getValueClass()),
328-
EntityProcessorException.class)),
329-
"list of processors")
330-
.getOrThrow()
331-
.collect(Collectors.toMap(TimeSeriesProcessor::getRegisteredKey, Function.identity()));
332-
} catch (FailureException e) {
333-
throw new EntityProcessorException(e.getCause());
334-
}
315+
return Try.scanStream(
316+
TimeSeriesProcessor.eligibleKeys.stream()
317+
.map(
318+
key ->
319+
Try.of(
320+
() ->
321+
new TimeSeriesProcessor<>(
322+
(Class<TimeSeries<TimeSeriesEntry<Value>, Value, Value>>)
323+
key.getTimeSeriesClass(),
324+
(Class<TimeSeriesEntry<Value>>) key.getEntryClass(),
325+
(Class<Value>) key.getValueClass()),
326+
EntityProcessorException.class)),
327+
"time series processors",
328+
EntityProcessorException::new)
329+
.getOrThrow()
330+
.collect(Collectors.toMap(TimeSeriesProcessor::getRegisteredKey, Function.identity()));
335331
}
336332

337333
@SuppressWarnings("unchecked cast")

src/main/java/edu/ie3/datamodel/io/source/EntitySource.java

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,12 @@ protected static <E extends Entity, D extends EntityData> Stream<E> getEntities(
204204
* @return a stream of the entity data wrapped in a {@link Try}
205205
*/
206206
protected static Stream<Try<EntityData, SourceException>> buildEntityData(
207-
Class<? extends Entity> entityClass, DataSource dataSource) {
208-
return Try.of(() -> dataSource.getSourceData(entityClass), SourceException.class)
209-
.convert(
210-
data ->
211-
data.map(
212-
fieldsToAttributes ->
213-
new Try.Success<>(new EntityData(fieldsToAttributes, entityClass))),
214-
exception -> Stream.of(Failure.of(exception)));
207+
Class<? extends Entity> entityClass, DataSource dataSource) throws SourceException {
208+
return dataSource
209+
.getSourceData(entityClass)
210+
.map(
211+
fieldsToAttributes ->
212+
new Try.Success<>(new EntityData(fieldsToAttributes, entityClass)));
215213
}
216214

217215
/**
@@ -227,7 +225,8 @@ protected static Stream<Try<EntityData, SourceException>> buildEntityData(
227225
protected static <E extends EntityData> Stream<Try<E, SourceException>> buildEntityData(
228226
Class<? extends Entity> entityClass,
229227
DataSource dataSource,
230-
WrappedFunction<EntityData, E> converter) {
228+
WrappedFunction<EntityData, E> converter)
229+
throws SourceException {
231230
return buildEntityData(entityClass, dataSource).map(converter);
232231
}
233232

@@ -356,9 +355,7 @@ Function<Pair<E, T>, R> enrichFunction(
356355
*/
357356
protected static <S, E extends Exception> Stream<S> unpack(
358357
Stream<Try<S, E>> inputStream, Class<S> clazz) throws SourceException {
359-
return Try.scanStream(inputStream, clazz.getSimpleName())
360-
.transformF(SourceException::new)
361-
.getOrThrow();
358+
return Try.scanStream(inputStream, clazz.getSimpleName(), SourceException::new).getOrThrow();
362359
}
363360

364361
/**
@@ -376,16 +373,14 @@ protected static <E extends EntityData, R> Try<R, SourceException> extractFuncti
376373
return entityData.flatMap(
377374
data ->
378375
Try.of(() -> data.getUUID(fieldName), FactoryException.class)
376+
.flatMap(entityUuid -> extractFunction(entityUuid, entities))
379377
.transformF(
380378
exception ->
381379
new SourceException(
382-
"Extracting UUID field "
380+
"Extracting UUID for field '"
383381
+ fieldName
384-
+ " from entity data "
385-
+ entityData
386-
+ " failed.",
387-
exception))
388-
.flatMap(entityUuid -> extractFunction(entityUuid, entities)));
382+
+ "' failed. Caused by: "
383+
+ exception.getMessage())));
389384
}
390385

391386
/**
@@ -396,13 +391,13 @@ protected static <E extends EntityData, R> Try<R, SourceException> extractFuncti
396391
* @return a try of the {@link Entity}
397392
* @param <T> type of entity
398393
*/
399-
protected static <T> Try<T, SourceException> extractFunction(UUID uuid, Map<UUID, T> entityMap) {
394+
protected static <T> Try<T, FactoryException> extractFunction(UUID uuid, Map<UUID, T> entityMap) {
400395
return Optional.ofNullable(entityMap.get(uuid))
401396
// We either find a matching entity for given UUID, thus return a success
402-
.map(entity -> Try.of(() -> entity, SourceException.class))
397+
.map(entity -> Try.of(() -> entity, FactoryException.class))
403398
// ... or find no matching entity, returning a failure.
404399
.orElse(
405-
new Failure<>(new SourceException("Entity with uuid " + uuid + " was not provided.")));
400+
new Failure<>(new FactoryException("Entity with uuid " + uuid + " was not provided.")));
406401
}
407402

408403
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

src/main/java/edu/ie3/datamodel/io/source/GraphicSource.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public void validate() throws ValidationException {
5959
Stream.of(
6060
validate(NodeGraphicInput.class, dataSource, nodeGraphicInputFactory),
6161
validate(LineGraphicInput.class, dataSource, lineGraphicInputFactory)),
62-
"Validation")
63-
.transformF(FailedValidationException::new)
62+
"Validation",
63+
FailedValidationException::new)
6464
.getOrThrow();
6565
}
6666

@@ -95,11 +95,13 @@ public GraphicElements getGraphicElements(Map<UUID, NodeInput> nodes, Map<UUID,
9595
Try<Set<LineGraphicInput>, SourceException> lineGraphics =
9696
Try.of(() -> getLineGraphicInput(lines), SourceException.class);
9797

98-
List<SourceException> exceptions = Try.getExceptions(List.of(nodeGraphics, lineGraphics));
98+
List<SourceException> exceptions = Try.getExceptions(nodeGraphics, lineGraphics);
9999

100100
if (!exceptions.isEmpty()) {
101101
throw new GraphicSourceException(
102-
exceptions.size() + " error(s) occurred while initializing graphic elements. ",
102+
"Exception(s) occurred in "
103+
+ exceptions.size()
104+
+ " input file(s) while initializing graphic elements. ",
103105
exceptions);
104106
} else {
105107
// if everything is fine, return a GraphicElements instance

0 commit comments

Comments
 (0)