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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Updated CI-Pipeline to run task `Deploy` and `Staging` only for `Main` [#1403](https://github.com/ie3-institute/PowerSystemDataModel/issues/1403)
- Extend `GermanVoltageLevelUtils` with more synonymousIds [#143](https://github.com/ie3-institute/PowerSystemDataModel/issues/143)
- Change spotless to use googleJavaFormat('1.28.0') [#1409](https://github.com/ie3-institute/PowerSystemDataModel/issues/1409)

## [8.1.0] - 2025-07-25

Expand Down
2 changes: 1 addition & 1 deletion gradle/scripts/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ spotless {
//sets a license header, removes unused imports and formats conforming to the google java format
java {
removeUnusedImports() // removes any unused imports
googleJavaFormat('1.13.0')
googleJavaFormat('1.28.0')
licenseHeader ie3LicHead
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public FailedValidationException(String message) {
super(message);
}

/** @param exceptions List of exceptions, which must not be empty */
/**
* @param exceptions List of exceptions, which must not be empty
*/
public FailedValidationException(List<? extends Exception> exceptions) {
super("Validation failed due to:\n " + ExceptionUtils.combineExceptions(exceptions));
}
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/edu/ie3/datamodel/graph/SubGridGate.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ public static SubGridGate fromTransformer3W(
return switch (inferiorPort) {
case B -> new SubGridGate(transformer, transformer.getNodeA(), transformer.getNodeB());
case C -> new SubGridGate(transformer, transformer.getNodeA(), transformer.getNodeC());
default -> throw new IllegalArgumentException(
"Only port "
+ ConnectorPort.B
+ " or "
+ ConnectorPort.C
+ " can be "
+ "chosen as inferior port.");
default ->
throw new IllegalArgumentException(
"Only port "
+ ConnectorPort.B
+ " or "
+ ConnectorPort.C
+ " can be "
+ "chosen as inferior port.");
};
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/edu/ie3/datamodel/io/DbGridMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public String toString() {
return GRID_NAME_COLUMN + "=" + gridName + ", " + GRID_UUID_COLUMN + "=" + uuid.toString();
}

/** @return Stream with grid uuid */
/**
* @return Stream with grid uuid
*/
public Stream<String> getStreamForQuery() {
return Stream.of(quote(uuid.toString(), "'"));
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/edu/ie3/datamodel/io/SqlUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ private static String beginQueryCreateTable(String schemaName, String tableName)
return "CREATE TABLE " + schemaName + "." + tableName + "\n(\n";
}

/** @return query to create a SQL table for a grid */
/**
* @return query to create a SQL table for a grid
*/
public static String queryCreateGridTable(String schemaName) {
return beginQueryCreateTable(schemaName, DbGridMetadata.GRID_TABLE_COLUMN)
+ "\tuuid uuid PRIMARY KEY,\n\tname TEXT NOT NULL\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ public void shutdown() {
cluster.disconnect();
}

/** @return the bucket name */
/**
* @return the bucket name
*/
public String getBucketName() {
return bucketName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ public ComparableQuantity<Power> calculateMaxPower(
Function<BdewLoadValues, Double> valueExtractor =
switch (loadProfile) {
case H0, H25, P25, S25 ->
// maximum dynamization factor is on day 366 (leap year) or day 365 (regular year).
// The difference between day 365 and day 366 is negligible, thus pick 366
v -> BdewLoadValues.dynamization(v.getMaxValue(true), 366);
// maximum dynamization factor is on day 366 (leap year) or day 365 (regular year).
// The difference between day 365 and day 366 is negligible, thus pick 366
v -> BdewLoadValues.dynamization(v.getMaxValue(true), 366);
default -> v -> v.getMaxValue(false);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@ protected IdCoordinateFactory() {
super(IdCoordinateInput.class);
}

/** @return the field id for the coordinate id */
/**
* @return the field id for the coordinate id
*/
public abstract String getIdField();

/** @return the field id for the coordinate latitude */
/**
* @return the field id for the coordinate latitude
*/
public abstract String getLatField();

/** @return the field id for the coordinate longitude */
/**
* @return the field id for the coordinate longitude
*/
public abstract String getLonField();
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class EntityPersistenceNamingStrategy {

private static final String UUID_STRING =
"[a-zA-Z0-9]{8}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{4}-[a-zA-Z0-9]{12}";

/**
* Regex to match the naming convention of a source for an individual time series. The column
* scheme is accessible via the named capturing group "columnScheme". The time series' UUID is
Expand Down
118 changes: 62 additions & 56 deletions src/main/java/edu/ie3/datamodel/io/processor/Processor.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ protected String processMethodResult(
StringBuilder resultStringBuilder = new StringBuilder();

switch (method.returnType()) {
// primitives (Boolean, Character, Byte, Short, Integer, Long, Float, Double, String,
// primitives (Boolean, Character, Byte, Short, Integer, Long, Float, Double, String,
case "UUID",
"boolean",
"int",
Expand All @@ -230,43 +230,46 @@ protected String processMethodResult(
"DayOfWeek",
"Season",
"ChargingPointType",
"EvcsLocationType" -> resultStringBuilder.append(methodReturnObject.toString());
case "Quantity", "ComparableQuantity" -> resultStringBuilder.append(
handleQuantity((Quantity<?>) methodReturnObject, fieldName));
"EvcsLocationType" ->
resultStringBuilder.append(methodReturnObject.toString());
case "Quantity", "ComparableQuantity" ->
resultStringBuilder.append(handleQuantity((Quantity<?>) methodReturnObject, fieldName));
case "Optional" ->
// only quantity optionals are expected here!
// if optional and present, unpack value and call this method again, if not present return
// an empty string as by convention null == missing value == "" when persisting data
resultStringBuilder.append(
((Optional<?>) methodReturnObject)
.map(
o -> {
if (o instanceof Quantity<?> quantity) {
return Try.of(
() -> handleQuantity(quantity, fieldName),
EntityProcessorException.class);
} else if (o instanceof UniqueEntity entity) {
return Try.of(entity::getUuid, EntityProcessorException.class);
} else {
return Failure.of(
new EntityProcessorException(
"Handling of "
+ o.getClass().getSimpleName()
+ ".class instance wrapped into Optional is currently not supported by entity processors!"));
}
})
.orElse(Success.of("")) // (in case of empty optional)
.getOrThrow());
case "ZonedDateTime" -> resultStringBuilder.append(
processZonedDateTime((ZonedDateTime) methodReturnObject));
case "OperationTime" -> resultStringBuilder.append(
processOperationTime((OperationTime) methodReturnObject, fieldName));
case "VoltageLevel" -> resultStringBuilder.append(
processVoltageLevel((VoltageLevel) methodReturnObject, fieldName));
case "Point", "LineString" -> resultStringBuilder.append(
geoJsonWriter.write((Geometry) methodReturnObject));
case "LoadProfile", "BdewStandardLoadProfile", "RandomLoadProfile" -> resultStringBuilder
.append(((LoadProfile) methodReturnObject).getKey());
// only quantity optionals are expected here!
// if optional and present, unpack value and call this method again, if not present return
// an empty string as by convention null == missing value == "" when persisting data
resultStringBuilder.append(
((Optional<?>) methodReturnObject)
.map(
o -> {
if (o instanceof Quantity<?> quantity) {
return Try.of(
() -> handleQuantity(quantity, fieldName),
EntityProcessorException.class);
} else if (o instanceof UniqueEntity entity) {
return Try.of(entity::getUuid, EntityProcessorException.class);
} else {
return Failure.of(
new EntityProcessorException(
"Handling of "
+ o.getClass().getSimpleName()
+ ".class instance wrapped into Optional is currently not supported by entity processors!"));
}
})
.orElse(Success.of("")) // (in case of empty optional)
.getOrThrow());
case "ZonedDateTime" ->
resultStringBuilder.append(processZonedDateTime((ZonedDateTime) methodReturnObject));
case "OperationTime" ->
resultStringBuilder.append(
processOperationTime((OperationTime) methodReturnObject, fieldName));
case "VoltageLevel" ->
resultStringBuilder.append(
processVoltageLevel((VoltageLevel) methodReturnObject, fieldName));
case "Point", "LineString" ->
resultStringBuilder.append(geoJsonWriter.write((Geometry) methodReturnObject));
case "LoadProfile", "BdewStandardLoadProfile", "RandomLoadProfile" ->
resultStringBuilder.append(((LoadProfile) methodReturnObject).getKey());
case "AssetTypeInput",
"BmTypeInput",
"ChpTypeInput",
Expand All @@ -283,32 +286,35 @@ protected String processMethodResult(
"Transformer2WTypeInput",
"Transformer3WTypeInput",
"WecTypeInput",
"EmInput" -> resultStringBuilder.append(((UniqueEntity) methodReturnObject).getUuid());
case "OperatorInput" -> resultStringBuilder.append(
((OperatorInput) methodReturnObject).getId().equalsIgnoreCase("NO_OPERATOR_ASSIGNED")
? ""
: ((OperatorInput) methodReturnObject).getUuid());
"EmInput" ->
resultStringBuilder.append(((UniqueEntity) methodReturnObject).getUuid());
case "OperatorInput" ->
resultStringBuilder.append(
((OperatorInput) methodReturnObject).getId().equalsIgnoreCase("NO_OPERATOR_ASSIGNED")
? ""
: ((OperatorInput) methodReturnObject).getUuid());
case "EvCharacteristicInput",
"OlmCharacteristicInput",
"WecCharacteristicInput",
"CosPhiFixed",
"CosPhiP",
"QV",
"ReactivePowerCharacteristic",
"CharacteristicInput" -> resultStringBuilder.append(
((CharacteristicInput<?, ?>) methodReturnObject).serialize());
case "InputModelType" -> resultStringBuilder.append(
((CongestionResult.InputModelType) methodReturnObject).type);
default -> throw new EntityProcessorException(
"Unable to process value for attribute/field '"
+ fieldName
+ "' and method return type '"
+ method.returnType()
+ "' for method with name '"
+ method.name()
+ "' in in entity model "
+ getRegisteredClass().getSimpleName()
+ ".class.");
"CharacteristicInput" ->
resultStringBuilder.append(((CharacteristicInput<?, ?>) methodReturnObject).serialize());
case "InputModelType" ->
resultStringBuilder.append(((CongestionResult.InputModelType) methodReturnObject).type);
default ->
throw new EntityProcessorException(
"Unable to process value for attribute/field '"
+ fieldName
+ "' and method return type '"
+ method.returnType()
+ "' for method with name '"
+ method.name()
+ "' in in entity model "
+ getRegisteredClass().getSimpleName()
+ ".class.");
}

return resultStringBuilder.toString();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
/** InfluxDB Sink for result and time series data */
public class InfluxDbSink implements OutputDataSink {
public static final Logger log = LoggerFactory.getLogger(InfluxDbSink.class);

/** Field name for time */
private static final String FIELD_NAME_TIME = "time";

/** Field name for input model uuid field in result entities */
private static final String FIELD_NAME_INPUT = "inputModel";

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/edu/ie3/datamodel/io/sink/SqlSink.java
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ private String writeOneLine(String[] entries, String[] addParams) {

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

/** @return insertion order for unique entities */
/**
* @return insertion order for unique entities
*/
private static List<Class<?>> hierarchicInsert() {
List<Class<?>> sortedInsert = new ArrayList<>();
sortedInsert.add(AssetTypeInput.class); // 1. Types
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/edu/ie3/datamodel/io/source/EntitySource.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ protected static CsvDataSource getBuildInSource(Class<?> clazz, String subdirect
connector =
new CsvFileConnector(jarFileSystem.getPath(array[1]), clazz::getResourceAsStream);
}
default -> throw new SourceException(
"Protocol " + url.getProtocol() + " is nor supported!");
default ->
throw new SourceException("Protocol " + url.getProtocol() + " is nor supported!");
}

return new CsvDataSource(",", connector, new FileNamingStrategy());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
public class CouchbaseWeatherSource extends WeatherSource {
private static final Logger logger = LoggerFactory.getLogger(CouchbaseWeatherSource.class);
private static final String DEFAULT_TIMESTAMP_PATTERN = "yyyy-MM-dd'T'HH:mm:ssxxx";

/** The start of the document key, comparable to a table name in relational databases */
private static final String DEFAULT_KEY_PREFIX = "weather";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ private String createQueryForValueBefore(
+ " < ?"
+ "ORDER BY time DESC LIMIT 1;";
}

/**
* Creates a base query to retrieve all time keys before a given time for given time series with
* the following pattern: <br>
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/edu/ie3/datamodel/models/OperationTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ public class OperationTime implements Serializable {

/** Date of operation start */
private ZonedDateTime startDate;

/** Date of operation end */
private ZonedDateTime endDate;

/** Is the operation time frame limited? */
private boolean isLimited;

Expand All @@ -42,17 +44,23 @@ protected OperationTime(ZonedDateTime startDate, ZonedDateTime endDate, boolean
/** Constructor for OperationTime without limitations (= always on) */
private OperationTime() {}

/** @return an OperationTime without time limitations (= always on) */
/**
* @return an OperationTime without time limitations (= always on)
*/
public static OperationTime notLimited() {
return new OperationTime();
}

/** @return date of operation start, if present */
/**
* @return date of operation start, if present
*/
public Optional<ZonedDateTime> getStartDate() {
return Optional.ofNullable(startDate);
}

/** @return date of operation end, if present */
/**
* @return date of operation end, if present
*/
public Optional<ZonedDateTime> getEndDate() {
return Optional.ofNullable(endDate);
}
Expand Down Expand Up @@ -119,7 +127,9 @@ public String toString() {
+ '}';
}

/** @return OperationTimeBuilder instance */
/**
* @return OperationTimeBuilder instance
*/
public static OperationTimeBuilder builder() {
return new OperationTimeBuilder();
}
Expand Down
Loading