Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
616ce6d
Improving column name validation
staudtMarius Nov 8, 2023
0263252
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Nov 8, 2023
065e15b
Some improvements.
staudtMarius Nov 13, 2023
651d9d1
fmt
staudtMarius Nov 13, 2023
fdbe8a8
Some small changes.
staudtMarius Nov 14, 2023
b9153fe
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Nov 16, 2023
c8dc981
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
sebastian-peter Nov 21, 2023
f5319cb
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Nov 24, 2023
ad379c2
Implementing requested changes.
staudtMarius Nov 24, 2023
7ae0a77
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Nov 27, 2023
9890512
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Nov 29, 2023
f37d7b6
Implementing requested changes.
staudtMarius Dec 5, 2023
ed659b4
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Dec 5, 2023
1bc5488
Some improvements.
staudtMarius Dec 5, 2023
f8783fa
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
staudtMarius Dec 14, 2023
3cc295c
Removed unused import
sebastian-peter Jan 4, 2024
779a60b
Merge branch 'dev' into ms/#849-column-name-validation-should-only-ru…
sebastian-peter Jan 4, 2024
1bdc06f
Adapted to changes in dev
sebastian-peter Jan 4, 2024
e50da82
Headline check is now obsolete
sebastian-peter Jan 4, 2024
d210341
Removing unnecessary parameters
sebastian-peter Jan 4, 2024
82249ef
Better JavaDoc
sebastian-peter Jan 4, 2024
cf15f4d
Additional test case
sebastian-peter Jan 4, 2024
18429bc
Renaming method, since "additional fields" already exist with a diffe…
sebastian-peter Jan 4, 2024
84695c8
found fields -> actual fields
sebastian-peter Jan 4, 2024
721bbad
Refactoring validation handling
sebastian-peter Jan 5, 2024
80104d0
Rolling back changes that will be fixed with #981
sebastian-peter Jan 5, 2024
e1d5e51
Removing unused methods from Try again
sebastian-peter Jan 5, 2024
13f034b
Fixing codacy issues
sebastian-peter Jan 5, 2024
440a426
Adapting documentation to changed spelling of cosPhiRated
sebastian-peter Jan 5, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Adding JavaDoc to `EntitySource.safeMapGet` [#828](https://github.com/ie3-institute/PowerSystemDataModel/issues/828)
- Abstracting some methods in `ValidationUtils` [#852](https://github.com/ie3-institute/PowerSystemDataModel/issues/852)
- `EmInput` should not be connected to the grid [#955](https://github.com/ie3-institute/PowerSystemDataModel/issues/955)
- Enhancing the error message for coordinate sources with invalid column names [#670](https://github.com/ie3-institute/PowerSystemDataModel/issues/670)
- Allowing for additional unused columns in sources [#839](https://github.com/ie3-institute/PowerSystemDataModel/issues/839)
- Improving column name validation to only run once per source [#849](https://github.com/ie3-institute/PowerSystemDataModel/issues/849)

## [4.1.0] - 2023-11-02

Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/bm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Type Model
+---------------------+---------+------------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+---------------------+---------+------------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+---------------------+---------+------------------------------------------------------------+
| etaConv | % | Efficiency of the assets inverter |
+---------------------+---------+------------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/chp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Type Model
+-------------+---------+---------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+-------------+---------+---------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+-------------+---------+---------------------------------------------------------+
| pThermal | kW | Rated thermal power (at rated electrical power) |
+-------------+---------+---------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/ev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Type Model
+-------------+----------+---------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+-------------+----------+---------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+-------------+----------+---------------------------------------------------------+

Entity Model
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/fixedfeedin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Attributes, Units and Remarks
+------------------+---------+--------------------------------------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+------------------+---------+--------------------------------------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+------------------+---------+--------------------------------------------------------------------------------------+

Caveats
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/hp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Type Model
+-------------+---------+---------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+-------------+---------+---------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+-------------+---------+---------------------------------------------------------+
| pThermal | kW | Rated thermal power (at rated electrical power) |
+-------------+---------+---------------------------------------------------------+
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/load.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Attributes, Units and Remarks
+---------------------+---------+--------------------------------------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+---------------------+---------+--------------------------------------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+---------------------+---------+--------------------------------------------------------------------------------------+

Caveats
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/pv.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Detailed model of a photovoltaic power plant.
+------------------+---------+--------------------------------------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+------------------+---------+--------------------------------------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+------------------+---------+--------------------------------------------------------------------------------------+

Caveats
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/storage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Type Model
+---------------------+---------+---------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+---------------------+---------+---------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+---------------------+---------+---------------------------------------------------------+
| pMax | kW | | Maximum permissible active power |
| | | | infeed or consumption |
Expand Down
2 changes: 1 addition & 1 deletion docs/readthedocs/models/input/participant/wec.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Type Model
+------------------+---------+----------------------------------------------------------------------+
| sRated | kVA | Rated apparent power |
+------------------+---------+----------------------------------------------------------------------+
| cosphiRated | -- | Rated power factor |
| cosPhiRated | -- | Rated power factor |
+------------------+---------+----------------------------------------------------------------------+
| cpCharacteristic | -- | Wind velocity dependent :ref:`Betz factors<wec_cp_characteristic>`. |
+------------------+---------+----------------------------------------------------------------------+
Expand Down
4 changes: 2 additions & 2 deletions docs/uml/main/input/SystemDatamodelConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ package models {
- capex: ComparableQuantity<Currency> [€]
- opex: ComparableQuantity<EnergyPrice> [€/MWh]
- sRated: ComparableQuantity<Power> [kVA]
- cosphiRated: Double
- cosPhiRated: Double
}
SystemParticipantTypeInput --|> AssetTypeInput

Expand Down Expand Up @@ -206,7 +206,7 @@ package models {

class FixedFeedInInput {
- sRated: ComparableQuantity<Power> [kVA]
- cosphiRated: double
- cosPhiRated: double
}
FixedFeedInInput --|> SystemParticipantInput

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package edu.ie3.datamodel.exceptions;

/** Is thrown, when an something went wrong during entity creation process in a EntityFactory */
/** Is thrown, when something went wrong during entity creation process in a EntityFactory */
public class FactoryException extends RuntimeException {
public FactoryException(final String message, final Throwable cause) {
super(message, cause);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public FailedValidationException(String message, Throwable throwable) {
super(message, throwable);
}

public FailedValidationException(Throwable throwable) {
super(throwable);
}

public FailedValidationException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ protected ValidationException(String s) {
super(s);
}

protected ValidationException(Throwable throwable) {
super(throwable);
}

protected ValidationException(String s, Throwable throwable) {
super(s, throwable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@
import com.couchbase.client.java.Cluster;
import com.couchbase.client.java.ClusterOptions;
import com.couchbase.client.java.Collection;
import com.couchbase.client.java.json.JsonObject;
import com.couchbase.client.java.kv.GetResult;
import com.couchbase.client.java.kv.MutationResult;
import com.couchbase.client.java.query.QueryResult;
import java.time.Duration;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

/**
Expand Down Expand Up @@ -56,6 +60,28 @@ public CouchbaseConnector(
cluster = Cluster.connect(url, clusterOptions);
}

/** Returns the option for a set of found fields. */
@SuppressWarnings("unchecked")
public Optional<Set<String>> getSourceFields() {
String query =
"SELECT ARRAY_DISTINCT(ARRAY_AGG(v)) AS column FROM "
+ bucketName
+ " b UNNEST OBJECT_NAMES(b) AS v";
cluster.bucket(bucketName).waitUntilReady(Duration.ofSeconds(30));

QueryResult queryResult = query(query).join();
JsonObject jsonObject = queryResult.rowsAsObject().get(0);
Object columns = jsonObject.toMap().get("column");

Set<String> set = new HashSet<>();

if (columns != null) {
set.addAll((List<String>) columns);
}

return Optional.of(set);
}

/**
* Return the couchbase java sdk equivalent of a session - a collection - to the previously set
* bucket
Expand Down
26 changes: 10 additions & 16 deletions src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,28 +168,22 @@ public synchronized <C extends UniqueEntity> void closeEntityWriter(Class<C> clz
*/
public BufferedReader initReader(Class<? extends UniqueEntity> clz)
throws FileNotFoundException, ConnectorException {
try {
Path filePath =
fileNamingStrategy
.getFilePath(clz)
.orElseThrow(
() ->
new ConnectorException(
"Cannot find a naming strategy for class '"
+ clz.getSimpleName()
+ "'."));
return initReader(filePath);
} catch (ConnectorException e) {
throw new ConnectorException(
"Cannot initialize reader for entity '" + clz.getSimpleName() + "'.", e);
}
Path filePath =
fileNamingStrategy
.getFilePath(clz)
.orElseThrow(
() ->
new ConnectorException(
"Cannot find a naming strategy for class '" + clz.getSimpleName() + "'."));
return initReader(filePath);
}

/**
* Initializes a file reader for the given file name. Use {@link
* CsvFileConnector#initReader(Class)} for files that actually correspond to concrete entities.
*
* @param filePath sub directory tree starting from base folder, including file name
* @param filePath path of file starting from base folder, including file name but not file
* extension
* @return the reader that contains information about the file to be read in
* @throws FileNotFoundException if no file with the provided file name can be found
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class InfluxDbConnector implements DataConnector {
return maps;
};

private final String databaseName;
private final String scenarioName;
private final InfluxDB session;

Expand Down Expand Up @@ -77,6 +78,7 @@ public InfluxDbConnector(
*/
public InfluxDbConnector(
InfluxDB session, String scenarioName, String databaseName, boolean createDb) {
this.databaseName = databaseName;
this.scenarioName = scenarioName;
this.session = session;

Expand Down Expand Up @@ -107,6 +109,21 @@ public InfluxDbConnector(String url, String databaseName) {
this(url, databaseName, NO_SCENARIO, true, InfluxDB.LogLevel.NONE, BatchOptions.DEFAULTS);
}

/** Returns the option for fields found in the source. */
public Optional<Set<String>> getSourceFields() {
QueryResult tagKeys = session.query(new Query("SHOW TAG KEYS ON " + databaseName));
Map<String, Set<Map<String, String>>> tagResults = parseQueryResult(tagKeys);

QueryResult fieldKeys = session.query(new Query("SHOW FIELD KEYS ON " + databaseName));
Map<String, Set<Map<String, String>>> fieldResults = parseQueryResult(fieldKeys);

Set<String> set = new HashSet<>();
tagResults.values().forEach(v -> v.stream().map(m -> m.get("tagKey")).forEach(set::add));
fieldResults.values().forEach(v -> v.stream().map(m -> m.get("fieldKey")).forEach(set::add));

return Optional.of(set);
}

/**
* Create the database of this connector if it doesn't exist yet
*
Expand Down
Loading