diff --git a/.gitignore b/.gitignore index 7cbb73c34..a99c96c97 100644 --- a/.gitignore +++ b/.gitignore @@ -242,4 +242,9 @@ docs/readthedocs/_build **/*.synctex.gz **/*.synctex(busy) -docs/javadoc \ No newline at end of file +### Metals ### +.metals/ +.bloop/ +project/**/metals.sbt + +docs/javadoc diff --git a/AUTHORS b/AUTHORS index 4c5ffecc5..4c0b256d1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,10 +1,14 @@ -Copyright (c) 2023, Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3) +Copyright (c) 2024, Institute of Energy Systems, Energy Efficiency and Energy Economics (ie3) All rights reserved. Lead Developers: - Johannes Hiry - Chris Kittl - Debopama Sen-Sarma + - Thomas Oberließen + - Daniel Feismann + - Johannes Bao + - Sebastian Peter Main Contributers: - Johannes Hiry - https://github.com/johanneshiry @@ -20,3 +24,8 @@ Main Contributers: - Marius Staudt - https://github.com/staudtMarius - Lara Roumeliotis - https://github.com/lararou - Vicky Bung - https://github.com/vickybung1 + - Daniel Feismann - https://github.com/danielfeismann + - Johannes Bao - https://github.com/jo-bao + - Julian Hohmann - https://github.com/julianhohmann + - Simon Huette - https://github.com/SimonHuette + - Pierre Petersmeier - http://github.com/pierrepetersmeier diff --git a/CHANGELOG.md b/CHANGELOG.md index 397ee653d..2348e5bb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased/Snapshot] ### Added +- Formatting Spotless Groovy import order [#960](https://github.com/ie3-institute/PowerSystemDataModel/issues/960) +- Implementing missing typical methods in `Try` [#970](https://github.com/ie3-institute/PowerSystemDataModel/issues/970) +- Added log warning when using `SwitchInputs` with `parallelDevices` parameter [#840](https://github.com/ie3-institute/PowerSystemDataModel/issues/840) +- Validation for `EvcsInput` [#1000](https://github.com/ie3-institute/PowerSystemDataModel/issues/1000) +- Scaling method in system participant copy builders [#1011](https://github.com/ie3-institute/PowerSystemDataModel/issues/1011) ### Fixed - Fixed Couchbase integration tests that randomly failed [#755](https://github.com/ie3-institute/PowerSystemDataModel/issues/755) +- Fixed hyperlink in line documentation [#965](https://github.com/ie3-institute/PowerSystemDataModel/issues/965) +- Fixed some tests no failing when they should [#958](https://github.com/ie3-institute/PowerSystemDataModel/issues/958) +- Fixed thermal-house-documentation [#873](https://github.com/ie3-institute/PowerSystemDataModel/issues/873) +- Fixed ElectricVehicle Documentation [#875](https://github.com/ie3-institute/PowerSystemDataModel/issues/875) +- Fixed Equal behavior of `ConnectorResult` [#1001](https://github.com/ie3-institute/PowerSystemDataModel/issues/1001) ### Changed - Changing from comparing strings to comparing uuids in `EntitySource.findFirstEntityByUuid` [#829](https://github.com/ie3-institute/PowerSystemDataModel/issues/829) - +- 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) +- Changes to Energy Management inputs: + - `EmInput` should not be connected to the grid [#955](https://github.com/ie3-institute/PowerSystemDataModel/issues/955) + - System participants now reference the em entity [#957](https://github.com/ie3-institute/PowerSystemDataModel/issues/957) +- 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) +- Refactored and abstracted `EntitySource`s and `EntityData` creation [#969](https://github.com/ie3-institute/PowerSystemDataModel/issues/969) +- Updated contributing.md [#737](https://github.com/ie3-institute/PowerSystemDataModel/issues/737) +- Don't throw exceptions for not yet implemented validations [#879](https://github.com/ie3-institute/PowerSystemDataModel/issues/879) +- `CsvDataSource` throws exceptions on error [#954](https://github.com/ie3-institute/PowerSystemDataModel/issues/954) ## [4.1.0] - 2023-11-02 @@ -37,6 +58,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Fixed wrong rated power unit hint [#804](https://github.com/ie3-institute/PowerSystemDataModel/issues/804) - Fixed wrong hash code generation of ConnectorResult [#817](https://github.com/ie3-institute/PowerSystemDataModel/issues/817) +- Fixed wrong path for timeSeriesMapping [#886](https://github.com/ie3-institute/PowerSystemDataModel/issues/886) ### Changed - Removing deprecated classes and methods [#540](https://github.com/ie3-institute/PowerSystemDataModel/issues/540) @@ -45,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Use nio paths instead of strings for file path [#723](https://github.com/ie3-institute/PowerSystemDataModel/issues/723) - Data source will throw an exceptions instead of returning an empty optionals [#707](https://github.com/ie3-institute/PowerSystemDataModel/issues/707) - Improving `ValidationUtils` [#758](https://github.com/ie3-institute/PowerSystemDataModel/issues/758) +- conversion from rst to markdown myst[#979](https://github.com/ie3-institute/PowerSystemDataModel/pull/985) ## [3.0.0] - 2023-02-16 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 613c30be6..02981e3ca 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,7 +16,7 @@ With this document we would like to give you some orientation on how you can con ## Testing and reporting bugs We really appreciate your usage of this project. Whenever you find a bug, it would be nice to check, if this isn't a feature to us. :wink: -You may find extensive information about the intended behaviour when you [Read the Docs](https://powersystemdatamodel.readthedocs.io/en/latest/) or within the [javadoc](https://ie3-institute.github.io/PowerSystemDataModel/javadoc/). +You may find extensive information about the intended behaviour when you [Read the Docs](https://powersystemdatamodel.readthedocs.io/en/latest/). If you still think it's a bug, please raise an [issue](https://guides.github.com/features/issues/) for us. Considering the following aspects in your inquiry, assists us in helping you: @@ -67,9 +67,6 @@ Before marking the pull request as 'ready to review', take these precautionary a `gradle finalizePR` summarizes all of these steps . ## For any doubts -... please contact -* Johannes (@johanneshiry), -* Debopama (@sensarmad) or -* Chris (@ckittl) +... please contact [us](AUTHORS) We are happy to help! :smiley: diff --git a/Jenkinsfile b/Jenkinsfile index cf2156d11..1a6029879 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -451,7 +451,6 @@ def constantBranchesProps() { [ string(defaultValue: '', description: '', name: 'deploy', trim: true) ]), - [$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false], [$class: 'ThrottleJobProperty', categories: [], limitOneJobWithMatchingParams: false, maxConcurrentPerNode: 0, maxConcurrentTotal: 0, paramsToUseForLimit: '', throttleEnabled: true, throttleOption: 'project'] ]) } diff --git a/build.gradle b/build.gradle index c0d3a0a32..12d31457b 100644 --- a/build.gradle +++ b/build.gradle @@ -4,8 +4,8 @@ plugins { id 'maven-publish' id 'signing' id 'pmd' // code check, working on source code - id 'com.diffplug.spotless' version '6.22.0' //code format - id 'com.github.spotbugs' version '5.2.3' // code check, working on byte code + id 'com.diffplug.spotless' version '6.25.0' //code format + id 'com.github.spotbugs' version '6.0.7' // code check, working on byte code id 'de.undercouch.download' version '5.5.0' id 'kr.motd.sphinx' version '2.10.1' // documentation generation id 'jacoco' // java code coverage plugin @@ -17,8 +17,8 @@ ext { //version (changing these should be considered thoroughly!) javaVersion = JavaVersion.VERSION_17 groovyVersion = "4.0" - groovyBinaryVersion = "4.0.15" - testcontainersVersion = '1.19.3' + groovyBinaryVersion = "4.0.18" + testcontainersVersion = '1.19.5' scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins } @@ -70,10 +70,10 @@ dependencies { // testing testImplementation "org.apache.groovy:groovy:$groovyBinaryVersion" - testImplementation 'org.junit.jupiter:junit-jupiter:5.10.1' + testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2' testImplementation "org.spockframework:spock-core:2.3-groovy-$groovyVersion" testImplementation 'org.objenesis:objenesis:3.3' // Mock creation with constructor parameters - testImplementation 'net.bytebuddy:byte-buddy:1.14.10' // Mocks of classes + testImplementation 'net.bytebuddy:byte-buddy:1.14.12' // Mocks of classes // testcontainers (docker framework for testing) testImplementation "org.testcontainers:testcontainers:$testcontainersVersion" @@ -83,17 +83,17 @@ dependencies { testImplementation "org.testcontainers:couchbase:$testcontainersVersion" // logging - implementation platform('org.apache.logging.log4j:log4j-bom:2.22.0') + implementation platform('org.apache.logging.log4j:log4j-bom:2.22.1') implementation 'org.apache.logging.log4j:log4j-api' // log4j implementation 'org.apache.logging.log4j:log4j-core' // log4j implementation 'org.apache.logging.log4j:log4j-slf4j-impl' // log4j -> slf4j // Databases - implementation 'org.influxdb:influxdb-java:2.23' - implementation 'com.couchbase.client:java-client:3.5.0' - runtimeOnly 'org.postgresql:postgresql:42.7.0' // postgresql jdbc driver required during runtime + implementation 'org.influxdb:influxdb-java:2.24' + implementation 'com.couchbase.client:java-client:3.5.3' + runtimeOnly 'org.postgresql:postgresql:42.7.2' // postgresql jdbc driver required during runtime - implementation 'commons-io:commons-io:2.15.0' // I/O functionalities + implementation 'commons-io:commons-io:2.15.1' // I/O functionalities implementation 'org.apache.commons:commons-compress:1.25.0' // I/O functionalities implementation 'org.apache.commons:commons-lang3:3.14.0' } diff --git a/docs/readthedocs/gettingstarted.md b/docs/readthedocs/gettingstarted.md new file mode 100644 index 000000000..92a2d54e4 --- /dev/null +++ b/docs/readthedocs/gettingstarted.md @@ -0,0 +1,47 @@ +# Getting started + +Welcome, dear fellow of bottom up power system modelling! +This section is meant to give you some help getting hands on our project. +If you feel, something is missing, please contact us! + +## Requirements + +Java > v 17 + +## Where to get + +Checkout latest from [GitHub](https://github.com/ie3-institute/PowerSystemDataModel) or use maven for dependency +management: + +### Stable releases + +On [Maven central](https://search.maven.org/artifact/com.github.ie3-institute/PowerSystemDataModel): + +```xml + + com.github.ie3-institute + PowerSystemDataModel + 2.1.0 + +``` + +### Snapshot releases + +Available on [OSS Sonatype](https://s01.oss.sonatype.org/). +Add the correct repository: + +```xml + + https://s01.oss.sonatype.org/content/repositories/snapshots + +``` + +and add the dependency: + +```xml + + com.github.ie3-institute + PowerSystemDataModel + 3.0-SNAPSHOT + +``` diff --git a/docs/readthedocs/gettingstarted.rst b/docs/readthedocs/gettingstarted.rst deleted file mode 100644 index 6115152b9..000000000 --- a/docs/readthedocs/gettingstarted.rst +++ /dev/null @@ -1,50 +0,0 @@ -############### -Getting started -############### -Welcome, dear fellow of bottom up power system modelling! -This section is meant to give you some help getting hands on our project. -If you feel, something is missing, please contact us! - -************ -Requirements -************ -Java > v 17 - -************ -Where to get -************ -Checkout latest from `GitHub `_ or use maven for dependency -management: - -Stable releases -=============== -On `Maven central `_: - -.. code-block:: xml - - - com.github.ie3-institute - PowerSystemDataModel - 2.1.0 - - -Snapshot releases -================= -Available on `OSS Sonatype `_. -Add the correct repository: - -.. code-block:: xml - - - https://s01.oss.sonatype.org/content/repositories/snapshots - - -and add the dependency: - -.. code-block:: xml - - - com.github.ie3-institute - PowerSystemDataModel - 3.0-SNAPSHOT - diff --git a/docs/readthedocs/index.md b/docs/readthedocs/index.md new file mode 100644 index 000000000..f73b866a1 --- /dev/null +++ b/docs/readthedocs/index.md @@ -0,0 +1,34 @@ +# Documentation of the PowerSystemDataModel + +Welcome to the documentation of the PowerSystemDataModel. +It provides an extensive data model capable of modelling energy systems with high granularity e.g. for bottom-up simulations. +Additionally, useful functions to process, augment and furnish model i/o information is provided. +Effective handling of geographic information related to power grids is also possible. + +```{toctree} +:caption: 'Contents:' +:maxdepth: 2 + +gettingstarted +models/models +io/basiciousage +``` + +## Contact the (Main) Maintainers + +If you feel, something this missing, wrong or misleading, please contact one of our main contributors: + +> - [@sensarmad](https://github.com/sensarmad) +> - [@t-ober](https://github.com/t-ober) +> - [@danielfeismann](https://github.com/danielfeismann) +> - [@sebastian-peter](https://github.com/sebastian-peter) +> - [@jo-bao](https://github.com/jo-bao) +> - [@julianhohmann](https://github.com/julianhohmann) + +Hat tip to all other contributors! + +# Indices and tables + +- {ref}`genindex` +- {ref}`modindex` +- {ref}`search` diff --git a/docs/readthedocs/index.rst b/docs/readthedocs/index.rst deleted file mode 100644 index edae434d4..000000000 --- a/docs/readthedocs/index.rst +++ /dev/null @@ -1,35 +0,0 @@ -Documentation of the PowerSystemDataModel -========================================= - -Welcome to the documentation of the PowerSystemDataModel. -It provides an extensive data model capable of modelling energy systems with high granularity e.g. for bottom-up simulations. -Additionally, useful functions to process, augment and furnish model i/o information is provided. -Effective handling of geographic information related to power grids is also possible. - -.. toctree:: - :maxdepth: 2 - :caption: Contents: - - gettingstarted - models/models - io/basiciousage - -Contact the (Main) Maintainers ------------------------------- -If you feel, something this missing, wrong or misleading, please contact one of our main contributors: - - * `@sensarmad `_ - * `@t-ober `_ - * `@danielfeismann `_ - * `@sebastian-peter `_ - * `@jo-bao `_ - * `@julianhohmann `_ - -Hat tip to all other contributors! - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/docs/readthedocs/io/csvfiles.md b/docs/readthedocs/io/csvfiles.md index e022918ad..34111a343 100644 --- a/docs/readthedocs/io/csvfiles.md +++ b/docs/readthedocs/io/csvfiles.md @@ -58,7 +58,7 @@ You may extend / alter the naming with pre- or suffix by calling `new EntityPers Let's spend a few more words on the individual time series: Those files are meant to carry different types of content - one might give information about wholesale market prices, the other is a record of power values provided by a real system. -To be able to understand, what's inside of the file, the *columnScheme* part of the file name gives insight of it's +To be able to understand, what's inside of the file, the *columnScheme* part of the file name gives insight of its content. The following keys are supported until now: diff --git a/docs/readthedocs/io/influxdb.rst b/docs/readthedocs/io/influxdb.md similarity index 66% rename from docs/readthedocs/io/influxdb.rst rename to docs/readthedocs/io/influxdb.md index 1bd69d48c..630705ffe 100644 --- a/docs/readthedocs/io/influxdb.rst +++ b/docs/readthedocs/io/influxdb.md @@ -1,33 +1,32 @@ -******** -InfluxDB -******** -`InfluxDB `_ is a time series database. As such, it can only -handle time based data like weather data or results. -The PowerSystemDataModel offers two interface implementations for InfluxDB 1.x: WeatherSource and OutputDataSink. - -Introduction to InfluxDB -======================== -InfluxDB is a NoSQL database as it is neither relational nor able to handle SQL queries, even though InfluxDB's own -QueryLanguage, `InfluxQL `_ is very similar to SQL. -InfluxDB persists data in *measurements*. A measurement is comparable to a table in a relational data model. It consists -of a *measurement name*, *fields*, *tags* and a *time column*. The measurement name is the equivalent of a table name. Fields -and tags are similar as they both hold data like columns in relational data. But while fields are supposed to hold -the actual data, tags should only hold metadata, which is why tag values can only be strings. Under default -configuration, one tag key can only hold 10 000 distinct tag values. This choice was made as tags are indexed and -supposed to be queried. Fields should only be queried if not avoidable. The time column is automatically provided, it -holds timestamps in `RFC3339 UTC `_, which for example looks like -"2020-06-22T10:14:50.52Z". The equivalent to a table row is a measurement point. It holds field and tag values as well -as the time. While the data values are optional, a timestamp is not. If no time is provided when persisting, the current -system time is used. - -Instantiating an InfluxDB DataConnector -======================================= -To instantiate an InfluxDbConnector a connection url, a database name and a scenario name should be provided. The -scenario name is used to build measurement names for results. -If none of those are provided, default values are used. - -.. code-block:: java - - InfluxDbConnector unparameterizedInfluxDb = new InfluxDbConnector(); - InfluxDbConnector defaultInfluxDb = new InfluxDbConnector(""http://localhost:8086/", "ie3_in", null); - unparameterizedInfluxDb.equals(defaultInfluxDb); //true \ No newline at end of file +# InfluxDB + +[InfluxDB](https://www.influxdata.com/products/influxdb-overview/) is a time series database. As such, it can only +handle time based data like weather data or results. +The PowerSystemDataModel offers two interface implementations for InfluxDB 1.x: WeatherSource and OutputDataSink. + +## Introduction to InfluxDB + +InfluxDB is a NoSQL database as it is neither relational nor able to handle SQL queries, even though InfluxDB's own +QueryLanguage, [InfluxQL](https://docs.influxdata.com/influxdb/v1.8/query_language/) is very similar to SQL. +InfluxDB persists data in *measurements*. A measurement is comparable to a table in a relational data model. It consists +of a *measurement name*, *fields*, *tags* and a *time column*. The measurement name is the equivalent of a table name. Fields +and tags are similar as they both hold data like columns in relational data. But while fields are supposed to hold +the actual data, tags should only hold metadata, which is why tag values can only be strings. Under default +configuration, one tag key can only hold 10 000 distinct tag values. This choice was made as tags are indexed and +supposed to be queried. Fields should only be queried if not avoidable. The time column is automatically provided, it +holds timestamps in [RFC3339 UTC](https://www.ietf.org/rfc/rfc3339.txt), which for example looks like +"2020-06-22T10:14:50.52Z". The equivalent to a table row is a measurement point. It holds field and tag values as well +as the time. While the data values are optional, a timestamp is not. If no time is provided when persisting, the current +system time is used. + +## Instantiating an InfluxDB DataConnector + +To instantiate an InfluxDbConnector a connection url, a database name and a scenario name should be provided. The +scenario name is used to build measurement names for results. +If none of those are provided, default values are used. + +```java +InfluxDbConnector unparameterizedInfluxDb = new InfluxDbConnector(); +InfluxDbConnector defaultInfluxDb = new InfluxDbConnector(""http://localhost:8086/", "ie3_in", null); +unparameterizedInfluxDb.equals(defaultInfluxDb); //true +``` diff --git a/docs/readthedocs/models/input/grid/gridcontainer.md b/docs/readthedocs/models/input/grid/gridcontainer.md index e40d20c5c..c39ab3386 100644 --- a/docs/readthedocs/models/input/grid/gridcontainer.md +++ b/docs/readthedocs/models/input/grid/gridcontainer.md @@ -37,17 +37,49 @@ A synoptic overview of both classes' attributes is given here: ## Attributes, Units and Remarks -| Attribute | Unit | Remarks | -|:------------------------|:-----|:--------------------------------------------------| -| gridName | -- | Human readable identifier | -| rawGrid | -- | see below | -| systemParticipants | -- | see below | -| graphics | -- | see below | -| subGridTopologyGraph | -- | topology of sub grids - only `JointGridContainer` | -| predominantVoltageLevel | -- | main voltage level - only `SubGridContainer` | -| subnet | -- | sub grid number - only `SubGridContainer` | +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + * - Attribute + - Unit + - Remarks + + * - gridName + - – + - Human readable identifier + + * - rawGrid + - – + - see below + + * - systemParticipants + - – + - see below + + * - graphics + - – + - see below + + * - subGridTopologyGraph + - – + - topology of sub grids - only + ``JointGridContainer`` + + * - predominantVoltageLevel + - – + - main voltage level - only + ``SubGridContainer`` + + * - subnet + - – + - sub grid number - only + ``SubGridContainer`` + +``` + ### RawGridElements This sub container simply holds: @@ -89,4 +121,4 @@ This sub container simply holds: ## Caveats Nothing - at least not known. -If you found something, please contact us! \ No newline at end of file +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/line.md b/docs/readthedocs/models/input/grid/line.md index 7c8facdf7..bd4a6f719 100644 --- a/docs/readthedocs/models/input/grid/line.md +++ b/docs/readthedocs/models/input/grid/line.md @@ -6,94 +6,475 @@ Representation of an AC line. ### Type Model -| Attribute | Unit | Remarks | -|:----------|:--------|:--------------------------------------------| -| uuid | -- | | -| id | -- | Human readable identifier | -| r | Ω / km | Phase resistance per length | -| x | Ω / km | Phase reactance per length | -| g | µS / km | Phase-to-ground conductance per length | -| b | µS / km | Phase-to-ground susceptance per length | -| iMax | A | Maximum permissible current | -| vRated | kV | Rated voltage | +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + * - Attribute + - Unit + - Remarks -A list with some standard line types can be found here: `Standard Line Types`_ + * - uuid + - – + - + * - id + - – + - Human readable identifier + + * - r + - Ω / km + - Phase resistance per length + + * - x + - Ω / km + - Phase resistance per length + + * - g + - µS / km + - Phase-to-ground conductance per length + + * - b + - µS / km + - Phase-to-ground conductance per length + + * - iMax + - A + - Maximum permissible current + + * - vRated + - kV + - Rated voltage + +``` + +A list with some standard line types can be found here: [Standard Line Types](#standard-line-types) ### Entity Model -| Attribute | Unit | Remarks | -|:------------------|:-----|:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| uuid | -- | | -| id | -- | Human readable identifier | -| operator | -- | | -| operationTime | -- | Timely restriction of operation | -| nodeA | -- | | -| nodeB | -- | | -| parallelDevices | -- | overall amount of parallel lines to automatically
construct (e.g. parallelDevices = 2 will build a
total of two lines using the specified parameters) | -| type | -- | | -| length | km | | -| geoPosition | -- | Line string of geographical locations describing the
position of the line | -| olmCharacteristic | -- | Characteristic of possible overhead line monitoring
Can be given in the form of `olm:{}`.
The pairs are wind velocity in x and permissible
loading in y. | +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - – + - + + * - id + - – + - Human readable identifier + + * - operator + - – + - + + * - operationTime + - – + - Timely restriction of operation + + * - nodeA + - – + - + + * - nodeB + - – + - + + * - parallelDevices + - – + - | overall amount of parallel lines to automatically construct + | (e.g. parallelDevices = 2 will build a total of two lines + | using the specified parameters) + + * - type + - – + - + + * - length + - km + - + * - geoPosition + - – + - Line string of geographical locations describing the + position of the line + * - olmCharacteristic + - – + - | Characteristic of possible overhead line monitoring Can be + | given in the form of ``olm:{}``. The pairs + | are wind velocity in x and permissible loading in y. + +``` ## Standard Line Types Following there are some standard line types with their source. A ``csv file`` containing the types listed below can be found -`here `_. This file can be used directly +[here](https://github.com/ie3-institute/PowerSystemDataModel/tree/dev/input/StandardAssetTypes). This file can be used directly for any simulation with ``simona``. -The lines which source is ``simBench`` are from `here `_. +The lines which source is ``simBench`` are from [here](https://simbench.de/en/download/datasets/). ### Overhead Lines Some standard overhead lines. -| uuid | b | g | iMax | id | r | vRated | x | source | -|:--------------------------------------|--------:|----:|--------:|--------------------:|---------:|-------:|---------:|:---------| -| 91617ab8-3de2-4fba-be45-a54473ba09a9 | 3.61283 | 0.0 | 1300.0 | LineType_1 | 0.08 | 380.0 | 0.32 | simBench | -| b3b231ae-a971-4432-80d7-4ce2f2a56a32 | 3.22799 | 0.0 | 1950.0 | LineType_4 | 0.033333 | 380.0 | 0.333333 | simBench | -| 24595f91-8295-41f8-a3d8-c9418d860d9c | 1.076 | 0.0 | 650.0 | LineType_6 | 0.1 | 380.0 | 1.0 | simBench | -| f0fc57ec-aa5a-4484-b870-be70a5428cbd | 6.45597 | 0.0 | 3900.0 | LineType_9 | 0.016667 | 380.0 | 0.166667 | simBench | -| ba70d8e7-b082-49bc-8c45-3c10e1236c3e | 8.60796 | 0.0 | 5200.0 | LineType_10 | 0.0125 | 380.0 | 0.125 | simBench | -| veee8eeed-62c9-4345-aa5a-3743fe32007d | 12.9119 | 0.0 | 7800.0 | LineType_11 | 0.008333 | 380.0 | 0.083333 | simBench | -| d2b16935-dcd7-44d2-8623-cec4c703ccdc | 17.2159 | 0.0 | 10400.0 | LineType_12 | 0.00625 | 380.0 | 0.0625 | simBench | -| a490c96e-6e90-485a-b0d7-adeb81fa09cd | 4.30398 | 0.0 | 2600.0 | LineType_2 | 0.025 | 220.0 | 0.25 | simBench | -| 5272bcbc-7d0e-4759-85fa-27943fd8d19c | 2.15199 | 0.0 | 1300.0 | LineType_3 | 0.05 | 220.0 | 0.5 | simBench | -| dd0bac07-de8d-4608-af36-b8ff2819f55a | 7.22566 | 0.0 | 2600.0 | LineType_5 | 0.04 | 220.0 | 0.16 | simBench | -| 64c1dcb5-57a5-4f35-b2bf-9ae4e6cc4943 | 1.80642 | 0.0 | 650.0 | LineType_7 | 0.16 | 220.0 | 0.64 | simBench | -| bdc83a85-c796-4bcb-8b79-8988dc2804f8 | 5.41925 | 0.0 | 1950.0 | LineType_8 | 0.053333 | 220.0 | 0.213333 | simBench | -| 3d75fb6b-f0be-4451-ab4c-7f00c0ebd619 | 2.8274 | 0.0 | 680.0 | Al/St_265/35 | 0.1095 | 110.0 | 0.296 | simBench | -| f5dcaf44-7a9a-4b85-89ba-5c15c04c5766 | 3.45575 | 0.0 | 105.0 | 15-AL1/3-ST1A 20.0 | 1.8769 | 20.0 | 0.409 | simBench | -| 9cbf484b-7256-4e7a-9c35-3e1049909aa0 | 3.53429 | 0.0 | 140.0 | 24-AL1/4-ST1A 20.0 | 1.2012 | 20.0 | 0.394 | simBench | -| 5b542a50-b0c2-4497-ba90-b2b31aafaa0b | 2.87456 | 0.0 | 170.0 | 34-AL1/6-ST1A 20.0 | 0.8342 | 20.0 | 0.382 | simBench | -| d594cd67-4459-44bc-9594-db710372db71 | 2.98451 | 0.0 | 210.0 | 48-AL1/8-ST1A 20.0 | 0.5939 | 20.0 | 0.372 | simBench | -| 305e60ad-cfd2-4127-9d83-8d9b21942d93 | 3.04734 | 0.0 | 290.0 | 70-AL1/11-ST1A 20.0 | 0.4132 | 20.0 | 0.36 | simBench | +```{eval-rst} +.. list-table:: + :widths: 11 11 11 11 11 11 11 11 11 + :header-rows: 0 + + + * - uuid + - b + - g + - iMax + - id + - r + - vRated + - x + - source + + * - 91617ab8-3de2-4fba-be45-a54473ba09a9 + - 3.61283 + - 0.0 + - 1300.0 + - LineType_1 + - 0.08 + - 380.0 + - 0.32 + - simBench + + * - b3b231ae-a971-4432-80d7-4ce2f2a56a32 + - 3.22799 + - 0.0 + - 1950.0 + - LineType_4 + - 0.033333 + - 380.0 + - 0.333333 + - simBench + + * - 24595f91-8295-41f8-a3d8-c9418d860d9c + - 1.076 + - 0.0 + - 650.0 + - LineType_6 + - 0.1 + - 380.0 + - 1.0 + - simBench + + * - f0fc57ec-aa5a-4484-b870-be70a5428cbd + - 6.45597 + - 0.0 + - 3900.0 + - LineType_9 + - 0.016667 + - 380.0 + - 0.166667 + - simBench + + * - ba70d8e7-b082-49bc-8c45-3c10e1236c3e + - 8.60796 + - 0.0 + - 5200.0 + - LineType_10 + - 0.0125 + - 380.0 + - 0.125 + - simBench + + * - veee8eeed-62c9-4345-aa5a-3743fe32007d + - 12.9119 + - 0.0 + - 7800.0 + - LineType_11 + - 0.008333 + - 380.0 + - 0.083333 + - simBench + + * - d2b16935-dcd7-44d2-8623-cec4c703ccdc + - 17.2159 + - 0.0 + - 10400.0 + - LineType_12 + - 0.00625 + - 380.0 + - 0.0625 + - simBench + + * - a490c96e-6e90-485a-b0d7-adeb81fa09cd + - 4.30398 + - 0.0 + - 2600.0 + - LineType_2 + - 0.025 + - 220.0 + - 0.25 + - simBench + + * - 5272bcbc-7d0e-4759-85fa-27943fd8d19c + - 2.15199 + - 0.0 + - 1300.0 + - LineType_3 + - 0.05 + - 220.0 + - 0.5 + - simBench + + * - dd0bac07-de8d-4608-af36-b8ff2819f55a + - 7.22566 + - 0.0 + - 2600.0 + - LineType_5 + - 0.04 + - 220.0 + - 0.16 + - simBench + + * - 64c1dcb5-57a5-4f35-b2bf-9ae4e6cc4943 + - 1.80642 + - 0.0 + - 650.0 + - LineType_7 + - 0.16 + - 220.0 + - 0.64 + - simBench + + * - bdc83a85-c796-4bcb-8b79-8988dc2804f8 + - 5.41925 + - 0.0 + - 1950.0 + - LineType_8 + - 0.053333 + - 220.0 + - 0.213333 + - simBench + + * - 3d75fb6b-f0be-4451-ab4c-7f00c0ebd619 + - 2.8274 + - 0.0 + - 680.0 + - Al/St_265/35 + - 0.1095 + - 110.0 + - 0.296 + - simBench + + * - 5b542a50-b0c2-4497-ba90-b2b31aafaa0b + - 2.87456 + - 0.0 + - 170.0 + - 34-AL1/6-ST1A 20.0 + - 0.8342 + - 20.0 + - 0.382 + - simBench + + * - d594cd67-4459-44bc-9594-db710372db71 + - 2.98451 + - 0.0 + - 210.0 + - 48-AL1/8-ST1A 20.0 + - 0.5939 + - 20.0 + - 0.372 + - simBench + + * - 305e60ad-cfd2-4127-9d83-8d9b21942d93 + - 3.04734 + - 0.0 + - 290.0 + - 70-AL1/11-ST1A 20.0 + - 0.4132 + - 20.0 + - 0.36 + - simBench +``` + ### Cables Some standard cables. -| uuid | b | g | iMax | id | r | vRated | x | source | -|:-------------------------------------|--------:|----:|------:|-----------------------------:|-------:|-------:|----------:|:---------| -| cc59abd4-770b-45d2-98c8-919c91f1ca4b | 58.7478 | 0.0 | 652.0 | 1x630_RM/50 | 0.122 | 110.0 | 0.122522 | simBench | -| 82ea1b98-2b21-48bd-841a-8d17d8ac20c9 | 59.3761 | 0.0 | 158.0 | NA2XS2Y 1x50 RM/25 12/20 kV | 0.64 | 20.0 | 0.145 | simBench | -| 4adef9e6-5e40-416d-8bd2-b6768d156c54 | 59.6903 | 0.0 | 220.0 | NA2XS2Y 1x70 RM/25 12/20 kV | 0.443 | 20.0 | 0.132 | simBench | -| d5c03484-59c2-44d5-a2ee-63a5a0d623b4 | 67.8584 | 0.0 | 252.0 | NA2XS2Y 1x95 RM/25 12/20 kV | 0.313 | 20.0 | 0.132 | simBench | -| 9c13909d-1dd1-4e2d-980b-55345bdf0fd0 | 72.2566 | 0.0 | 283.0 | NA2XS2Y 1x120 RM/25 12/20 kV | 0.253 | 20.0 | 0.119 | simBench | -| 36243493-eb31-4e81-bd13-b54ef59c4cbe | 78.5398 | 0.0 | 319.0 | NA2XS2Y 1x150 RM/25 12/20 kV | 0.206 | 20.0 | 0.116 | simBench | -| 437689f8-366d-4b04-b42d-d7a754db074b | 85.7655 | 0.0 | 362.0 | NA2XS2Y 1x185 RM/25 12/20 kV | 0.161 | 20.0 | 0.117 | simBench | -| b459115d-d4eb-47d4-b7ec-625339ee0dcc | 95.5044 | 0.0 | 421.0 | NA2XS2Y 1x240 RM/25 12/20 kV | 0.122 | 20.0 | 0.112 | simBench | -| 9aed5818-c037-4033-8d15-806c62d70b8f | 113.097 | 0.0 | 315.0 | NA2XS2Y 1x150 RM/25 6/10 kV | 0.206 | 10.0 | 0.11 | simBench | -| 60d37bc7-157a-4c32-b1b5-e74c10d70531 | 127.549 | 0.0 | 358.0 | NA2XS2Y 1x185 RM/25 6/10 kV | 0.161 | 10.0 | 0.11 | simBench | -| a3ced617-2ffd-4593-b8e9-bcad9a521aab | 143.257 | 0.0 | 416.0 | NA2XS2Y 1x240 RM/25 6/10 kV | 0.122 | 10.0 | 0.105 | simBench | -| f0484bb6-9d0d-4d13-bfbe-b83783b8352a | 150.796 | 0.0 | 471.0 | NA2XS2Y 1x300 RM/25 6/10 kV | 0.1 | 10.0 | 0.0974 | simBench | -| 6b223bc3-69e2-4eb8-a2c0-76be1cd2c998 | 169.646 | 0.0 | 535.0 | NA2XS2Y 1x400 RM/25 6/10 kV | 0.078 | 10.0 | 0.0942 | simBench | -| 65181464-230a-487b-978f-81e406e9eb22 | 260.752 | 0.0 | 270.0 | NAYY 4x150SE 0.6/1kV | 0.2067 | 0.4 | 0.0804248 | simBench | -| 1200d9eb-6d10-47f3-8543-abea43b128d3 | 273.319 | 0.0 | 357.0 | NAYY 4x240SE 0.6/1kV | 0.1267 | 0.4 | 0.0797965 | simBench | +```{eval-rst} +.. list-table:: + :widths: 11 11 11 11 11 11 11 11 11 + :header-rows: 0 + + + * - uuid + - b + - g + - iMax + - id + - r + - vRated + - x + - source + + * - cc59abd4-770b-45d2-98c8-919c91f1ca4b + - 58.7478 + - 0.0 + - 652.0 + - 1x630_RM/50 + - 0.122 + - 110.0 + - 0.122522 + - simBench + + * - 82ea1b98-2b21-48bd-841a-8d17d8ac20c9 + - 59.3761 + - 0.0 + - 158.0 + - NA2XS2Y 1x50 RM/25 12/20 kV + - 0.64 + - 20.0 + - 0.145 + - simBench + + * - 4adef9e6-5e40-416d-8bd2-b6768d156c54 + - 59.6903 + - 0.0 + - 220.0 + - NA2XS2Y 1x70 RM/25 12/20 kV + - 0.443 + - 20.0 + - 0.132 + - simBench + + * - d5c03484-59c2-44d5-a2ee-63a5a0d623b4 + - 67.8584 + - 0.0 + - 252.0 + - NA2XS2Y 1x95 RM/25 12/20 kV + - 0.313 + - 20.0 + - 0.132 + - simBench + + * - 9c13909d-1dd1-4e2d-980b-55345bdf0fd0 + - 72.2566 + - 0.0 + - 283.0 + - NA2XS2Y 1x120 RM/25 12/20 kV + - 0.253 + - 20.0 + - 0.119 + - simBench + + * - 36243493-eb31-4e81-bd13-b54ef59c4cbe + - 78.5398 + - 0.0 + - 319.0 + - NA2XS2Y 1x150 RM/25 12/20 kV + - 0.206 + - 20.0 + - 0.116 + - simBench + + * - 437689f8-366d-4b04-b42d-d7a754db074b + - 85.7655 + - 0.0 + - 362.0 + - NA2XS2Y 1x185 RM/25 12/20 kV + - 0.161 + - 20.0 + - 0.117 + - simBench + + * - b459115d-d4eb-47d4-b7ec-625339ee0dcc + - 95.5044 + - 0.0 + - 421.0 + - NA2XS2Y 1x240 RM/25 12/20 kV + - 0.122 + - 20.0 + - 0.112 + - simBench + + * - 9aed5818-c037-4033-8d15-806c62d70b8f + - 113.097 + - 0.0 + - 315.0 + - NA2XS2Y 1x150 RM/25 6/10 kV + - 0.206 + - 10.0 + - 0.11 + - simBench + + * - 60d37bc7-157a-4c32-b1b5-e74c10d70531 + - 127.549 + - 0.0 + - 358.0 + - NA2XS2Y 1x185 RM/25 6/10 kV + - 0.161 + - 10.0 + - 0.11 + - simBench + + * - a3ced617-2ffd-4593-b8e9-bcad9a521aab + - 143.257 + - 0.0 + - 416.0 + - NA2XS2Y 1x240 RM/25 6/10 kV + - 0.122 + - 10.0 + - 0.105 + - simBench + + * - f0484bb6-9d0d-4d13-bfbe-b83783b8352a + - 150.796 + - 0.0 + - 471.0 + - NA2XS2Y 1x300 RM/25 6/10 kV + - 0.1 + - 10.0 + - 0.0974 + - simBench + + * - 6b223bc3-69e2-4eb8-a2c0-76be1cd2c998 + - 169.646 + - 0.0 + - 535.0 + - NA2XS2Y 1x400 RM/25 6/10 kV + - 0.078 + - 10.0 + - 0.0942 + - simBench + + * - 65181464-230a-487b-978f-81e406e9eb22 + - 260.752 + - 0.0 + - 270.0 + - NAYY 4x150SE 0.6/1kV + - 0.2067 + - 0.4 + - 0.0804248 + - simBench + + * - 1200d9eb-6d10-47f3-8543-abea43b128d3 + - 273.319 + - 0.0 + - 357.0 + - NAYY 4x240SE 0.6/1kV + - 0.1267 + - 0.4 + - 0.0797965 + - simBench +``` ## Caveats diff --git a/docs/readthedocs/models/input/grid/linegraphic.md b/docs/readthedocs/models/input/grid/linegraphic.md new file mode 100644 index 000000000..d97d695ab --- /dev/null +++ b/docs/readthedocs/models/input/grid/linegraphic.md @@ -0,0 +1,41 @@ +(line-graphic-model)= + +# Schematic Line Graphic + +Schematic drawing information for a line model. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - graphicLayer + - -- + - | Human readable identifier of the graphic layer to draw + | this element on + + * - path + - -- + - Line string of coordinates describing the drawing + + * - line + - -- + - Reference to the physical line model + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/linegraphic.rst b/docs/readthedocs/models/input/grid/linegraphic.rst deleted file mode 100644 index f187ed05a..000000000 --- a/docs/readthedocs/models/input/grid/linegraphic.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. _line_graphic_model: - -Schematic Line Graphic ----------------------- -Schematic drawing information for a line model. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+--------------+------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==============+======+===========================================================+ -| uuid | -- | | -+--------------+------+-----------------------------------------------------------+ -| graphicLayer | -- | | Human readable identifier of the graphic layer to draw | -| | | | this element on | -+--------------+------+-----------------------------------------------------------+ -| path | -- | Line string of coordinates describing the drawing | -+--------------+------+-----------------------------------------------------------+ -| line | -- | Reference to the physical line model | -+--------------+------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/measurementunit.md b/docs/readthedocs/models/input/grid/measurementunit.md new file mode 100644 index 000000000..0d00d0f3a --- /dev/null +++ b/docs/readthedocs/models/input/grid/measurementunit.md @@ -0,0 +1,62 @@ +(measurement-unit-model)= + +# Measurement Unit + +Representation of a measurement unit placed at a node. +It can be used to mark restrictive access to simulation results to e.g. control algorithms. +The measured information are indicated by boolean fields. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - vMag + - -- + - Voltage magnitude measurements are available + + * - vAng + - -- + - Voltage angle measurements are available + + * - p + - -- + - Active power measurements are available + + * - q + - -- + - Reactive power measurements are available + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/measurementunit.rst b/docs/readthedocs/models/input/grid/measurementunit.rst deleted file mode 100644 index 56cada24f..000000000 --- a/docs/readthedocs/models/input/grid/measurementunit.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. _measurement_unit_model: - -Measurement Unit ----------------- -Representation of a measurement unit placed at a node. -It can be used to mark restrictive access to simulation results to e.g. control algorithms. -The measured information are indicated by boolean fields. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------------+------+----------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+======+==============================================+ -| uuid | -- | | -+---------------+------+----------------------------------------------+ -| id | -- | Human readable identifier | -+---------------+------+----------------------------------------------+ -| operator | -- | | -+---------------+------+----------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------+------+----------------------------------------------+ -| node | -- | | -+---------------+------+----------------------------------------------+ -| vMag | -- | Voltage magnitude measurements are available | -+---------------+------+----------------------------------------------+ -| vAng | -- | Voltage angle measurements are available | -+---------------+------+----------------------------------------------+ -| p | -- | Active power measurements are available | -+---------------+------+----------------------------------------------+ -| q | -- | Reactive power measurements are available | -+---------------+------+----------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/node.md b/docs/readthedocs/models/input/grid/node.md new file mode 100644 index 000000000..f60c0d21a --- /dev/null +++ b/docs/readthedocs/models/input/grid/node.md @@ -0,0 +1,62 @@ +(node-model)= + +# Node + +Representation of an electrical node, with no further distinction into bus bar, auxiliary node or others. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - vTarget + - p.u. + - Target voltage magnitude to be used by voltage regulation entities + + * - slack + - -- + - | Boolean indicator, if this nodes serves as a slack node in power + | flow calculation + + * - geoPosition + - -- + - Geographical location + + * - voltLvl + - -- + - Information of the voltage level (id and nominal voltage) + + * - subnet + - -- + - Sub grid number + +``` + +## Caveats + +System participants, that need to have geographical locations, inherit the position from the node. +If the overall location does not play a big role, you are able to use the default location with +{code}`NodeInput#DEFAULT_GEO_POSITION` being located on TU Dortmund university's campus ([See on OpenStreetMaps](https://www.openstreetmap.org/search?query=51.4843281%2C%207.4116482#map=15/51.4843/7.4117)). diff --git a/docs/readthedocs/models/input/grid/node.rst b/docs/readthedocs/models/input/grid/node.rst deleted file mode 100644 index eedd8f42b..000000000 --- a/docs/readthedocs/models/input/grid/node.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. _node_model: - -Node ----- -Representation of an electrical node, with no further distinction into bus bar, auxiliary node or others. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------------+------+--------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+======+====================================================================+ -| uuid | -- | | -+---------------+------+--------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+---------------+------+--------------------------------------------------------------------+ -| operator | -- | | -+---------------+------+--------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------+------+--------------------------------------------------------------------+ -| vTarget | p.u. | Target voltage magnitude to be used by voltage regulation entities | -+---------------+------+--------------------------------------------------------------------+ -| slack | -- | | Boolean indicator, if this nodes serves as a slack node in power | -| | | | flow calculation | -+---------------+------+--------------------------------------------------------------------+ -| geoPosition | -- | Geographical location | -+---------------+------+--------------------------------------------------------------------+ -| voltLvl | -- | Information of the voltage level (id and nominal voltage) | -+---------------+------+--------------------------------------------------------------------+ -| subnet | -- | Sub grid number | -+---------------+------+--------------------------------------------------------------------+ - -Caveats -^^^^^^^ -System participants, that need to have geographical locations, inherit the position from the node. -If the overall location does not play a big role, you are able to use the default location with -:code:`NodeInput#DEFAULT_GEO_POSITION` being located on TU Dortmund university's campus (`See on OpenStreetMaps `_). diff --git a/docs/readthedocs/models/input/grid/nodegraphic.md b/docs/readthedocs/models/input/grid/nodegraphic.md new file mode 100644 index 000000000..6bb73c0ef --- /dev/null +++ b/docs/readthedocs/models/input/grid/nodegraphic.md @@ -0,0 +1,45 @@ +(node-graphic-model)= + +# Schematic Node Graphic + +Schematic drawing information for a node model. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - graphicLayer + - -- + - | Human readable identifier of the graphic layer to draw + | this element on + + * - path + - -- + - Line string of coordinates describing the drawing, e.g. for bus bars + + * - point + - -- + - Alternative to line string, only drawing a point coordinate + + * - node + - -- + - Reference to the physical node model + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/nodegraphic.rst b/docs/readthedocs/models/input/grid/nodegraphic.rst deleted file mode 100644 index afdbb1c9a..000000000 --- a/docs/readthedocs/models/input/grid/nodegraphic.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _node_graphic_model: - -Schematic Node Graphic ----------------------- -Schematic drawing information for a node model. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+--------------+------+----------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==============+======+======================================================================+ -| uuid | -- | | -+--------------+------+----------------------------------------------------------------------+ -| graphicLayer | -- | | Human readable identifier of the graphic layer to draw | -| | | | this element on | -+--------------+------+----------------------------------------------------------------------+ -| path | -- | Line string of coordinates describing the drawing, e.g. for bus bars | -+--------------+------+----------------------------------------------------------------------+ -| point | -- | Alternative to line string, only drawing a point coordinate | -+--------------+------+----------------------------------------------------------------------+ -| node | -- | Reference to the physical node model | -+--------------+------+----------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/switch.md b/docs/readthedocs/models/input/grid/switch.md new file mode 100644 index 000000000..a4ab706cc --- /dev/null +++ b/docs/readthedocs/models/input/grid/switch.md @@ -0,0 +1,53 @@ +(switch-model)= + +# Switch + +Model of an ideal switch connecting two node models of the same voltage level + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - nodeA + - -- + - + + * - nodeB + - -- + - + + * - closed + - -- + - true, if the switch is closed + + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/switch.rst b/docs/readthedocs/models/input/grid/switch.rst deleted file mode 100644 index c41346886..000000000 --- a/docs/readthedocs/models/input/grid/switch.rst +++ /dev/null @@ -1,31 +0,0 @@ -.. _switch_model: - -Switch ------- -Model of an ideal switch connecting two node models of the same voltage level - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------------+------+---------------------------------+ -| Attribute | Unit | Remarks | -+===============+======+=================================+ -| uuid | -- | | -+---------------+------+---------------------------------+ -| id | -- | Human readable identifier | -+---------------+------+---------------------------------+ -| operator | -- | | -+---------------+------+---------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------+------+---------------------------------+ -| nodeA | -- | | -+---------------+------+---------------------------------+ -| nodeB | -- | | -+---------------+------+---------------------------------+ -| closed | -- | true, if the switch is closed | -+---------------+------+---------------------------------+ - - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/grid/transformer2w.md b/docs/readthedocs/models/input/grid/transformer2w.md index a213b09dc..6e4ef7c6f 100644 --- a/docs/readthedocs/models/input/grid/transformer2w.md +++ b/docs/readthedocs/models/input/grid/transformer2w.md @@ -10,66 +10,347 @@ It is assumed, that node A is the node with higher voltage. All impedances and admittances are given with respect to the higher voltage side. As obvious, the parameter can be used in T- as in 𝜋-equivalent circuit representations. -| Attribute | Unit | Remarks | -|:----------|:-----|:--------------------------------------------------------| -| id | | Human readable identifier | -| rSc | Ω | Short circuit resistance | -| xSc | Ω | Short circuit reactance | -| gM | nS | No load conductance | -| bM | nS | No load susceptance | -| sRated | kVA | Rated apparent power | -| vRatedA | kV | Rated voltage at higher voltage terminal | -| vRatedB | kV | Rated voltage at lower voltage terminal | -| dV | % | Voltage magnitude increase per tap position | -| dPhi | ° | Voltage angle increase per tap position | -| tapSide | | true, if tap changer is installed on lower voltage side | -| tapNeutr | | Neutral tap position | -| tapMin | | Minimum tap position | -| tapMax | | Maximum tap position | - -A list with some standard transformer types can be found here: `Standard Two Winding Transformer Types`_ +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + * - Attribute + - Unit + - Remarks + + * - id + - + - Human readable identifier + + * - rSc + - Ω + - Short circuit resistance + + * - xSc + - Ω + - Short circuit reactance + + * - gM + - nS + - No load conductance + + * - bM + - nS + - No load susceptance + + * - sRated + - kVA + - Rated apparent power + + * - vRatedA + - kV + - Rated voltage at higher voltage terminal + + * - vRatedB + - kV + - Rated voltage at lower voltage terminal + + * - dV + - % + - Voltage magnitude increase per tap position + + * - dPhi + - ° + - Voltage angle increase per tap position + + * - tapSide + - + - true, if tap changer is installed on lower voltage + side + + * - tapNeutr + - + - Neutral tap position + + * - tapMin + - + - Minimum tap position + + * - tapMax + - + - Maximum tap position +``` + +A list with some standard transformer types can be found here: [Standard Two Winding Transformer Types](#standard-two-winding-transformer-types) ### Entity Model -| Attribute | Unit | Remarks | -|:----------------|:-----|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| uuid | -- | | -| id | -- | Human readable identifier | -| operator | -- | | -| operationTime | -- | Timely restriction of operation | -| nodeA | -- | Higher voltage node | -| nodeB | -- | Lower voltage node | -| parallelDevices | -- | overall amount of parallel transformers to automatically
construct (e.g. parallelDevices = 2 will build a
total of two transformers using the specified parameters) | -| type | -- | | -| tapPos | -- | Current position of the tap changer | -| autoTap | -- | true, if there is a tap regulation apparent and active | +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + * - Attribute + - Unit + - Remarks -## Standard Two Winding Transformer Types + * - uuid + - – + - + * - id + - – + - Human readable identifier -Following there are some standard two winding transformer types with their source. A ``csv file`` containing the types listed -below can be found `here `_. This -file can be used directly for any simulation with ``simona``. -The transformers which source is ``simBench`` are from `here `_. + * - operator + - – + - + + * - operationTime + - – + - Timely restriction of operation + + * - nodeA + - – + - Higher voltage node + + * - nodeB + - – + - Lower voltage node + * - parallelDevices + - – + - | overall amount of parallel transformers to automatically + | construct (e.g. parallelDevices = 2 will build a total of + | two transformers using the specified parameters) -| uuid | bM | dPhi | dV | gM | id | rSc | sRated | tapMax | tapMin | tapNeutr | tapSide | vRatedA | vRatedB | xSc | source | -|:-------------------------------------|--------------------:|-----:|----:|-------------------:|------------------------------------:|--------------------:|---------:|-------:|-------:|---------:|--------:|--------:|--------:|-------------------:|:---------| -| 5a890aae-b9c9-4ebf-8a49-8850ae9df402 | 219.43184927638458 | 0.0 | 1.0 | 1731.3019390581715 | Typ_x_380/220 | 0.6016666666666666 | 600000.0 | 16 | -16 | 0 | false | 380.0 | 220.0 | 44.51926783240413 | simBench | -| 03159c0d-126e-47cc-9871-066870df3a3f | 1193.4686938790917 | 0.0 | 1.0 | 831.0249307479223 | 350MVA_380/110 | 1.0608979591836734 | 350000.0 | 16 | -16 | 0 | false | 380.0 | 110.0 | 9 0.75951402093402 | simBench | -| 7cb289cb-e6af-4470-9c68-e5a91978a5e7 | 2013.800484464662 | 0.0 | 1.0 | 1446.280991735537 | 300MVA_220/110 | 0.20704444444444442 | 300000.0 | 16 | -16 | 0 | false | 220.0 | 110.0 | 19.358892855688435 | simBench | -| 73644bc6-78cf-4882-9837-e6508cab092d | 867.7685950413226 | 0.0 | 1.5 | 1157.0247933884295 | 25 MVA 110/20 kV YNd5 | 1.9843999999999997 | 25000.0 | 9 | -9 | 0 | false | 110.0 | 20.0 | 58.04608993412045 | simBench | -| 6935ae26-374a-4c24-aeee-6d5760d6ddf3 | 720.4791642215993 | 0.0 | 1.5 | 1487.603305785124 | 40 MVA 110/20 kV YNd5 | 1.0285 | 40000.0 | 9 | -9 | 0 | false | 110.0 | 20.0 | 48.994205909984906 | simBench | -| b49db20f-b8b5-4265-8318-f669b9d121e9 | 1015.6886939330394 | 0.0 | 1.5 | 1818.181818181818 | 63 MVA 110/10 kV YNd5 | .6146031746031745 | 63000.0 | 9 | -9 | 0 | false | 110.0 | 10.0 | 34.56596500037509 | simBench | -| 0843b836-cee4-4a8c-81a4-098400fe91cf | 24.495101551166183 | 0.0 | 2.5 | 2999.9999999999995 | 0.4 MVA 20/0.4 kV Dyn5 ASEA | 11.999999999999998 | 400.0 | 2 | -2 | 0 | false | 20.0 | 0.4 | 58.787753826796276 | simBench | -| a8f3aeea-ef4d-4f3c-bb07-09a0a86766c1 | 9.591746452043322 | 0.0 | 2.5 | 1149.9999999999998 | 0.16 MVA 20/0.4 kV DOTE 160/20 SGB | 36.71874999999999 | 160.0 | 2 | -2 | 0 | false | 20.0 | 0.4 | 93.01469452961452 | simBench | -| 0644c120-a247-425f-bbe4-31b153f7f440 | 16.583241729259253 | 0.0 | 2.5 | 2199.9999999999995 | 0.25 MVA 20/0.4 kV Dyn5 ASEA | 21.119999999999997 | 250.0 | 2 | -2 | 0 | false | 20.0 | 0.4 | 93.6479876986153 | simBench | -| bdf22ee4-deba-41f4-a187-ae00638a6880 | 36.47380569074435 | 0.0 | 2.5 | 4125.0 | 0.63 MVA 20/0.4 kV Dyn5 ASEA | 6.953892668178382 | 630.0 | 2 | -2 | 0 | false | 20.0 | 0.4 | 37.45518044666632 | simBench | -| a0cbd90a-4e9f-47db-8dca-041d3a288f77 | 145.8952227629774 | 0.0 | 2.5 | 16500.0 | 0.63 MVA 10/0.4 kV Dyn5 ASEA | 1.7384731670445954 | 630.0 | 2 | -2 | 0 | false | 10.0 | 0.4 | 9.36379511166658 | simBench | + * - type + - – + - + * - tapPos + - – + - Current position of the tap changer + + * - autoTap + - – + - true, if there is a tap regulation apparent and active +``` + +## Standard Two Winding Transformer Types + + +Following there are some standard two winding transformer types with their source. A ``csv file`` containing the types listed +below can be found [here](https://github.com/ie3-institute/PowerSystemDataModel/tree/dev/input/StandardAssetTypes). This +file can be used directly for any simulation with ``simona``. +The transformers which source is ``simBench`` are from [here](https://simbench.de/en/download/datasets/). +```{eval-rst} +.. list-table:: + :widths: 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 + :header-rows: 0 + + * - uuid + - bM + - dPhi + - dV + - gM + - id + - rSc + - sRated + - tapMax + - tapMin + - tapNeutr + - tapSide + - vRatedA + - vRatedB + - xSc + - source + + * - 5a890aae-b9c9-4ebf-8a49-8850ae9df402 + - 219.43184927638458 + - 0.0 + - 1.0 + - 1731.3019390581715 + - Typ_x_380/220 + - 0.6016666666666666 + - 600000.0 + - 16 + - -16 + - 0 + - false + - 380.0 + - 220.0 + - 44.51926783240413 + - simBench + + * - 03159c0d-126e-47cc-9871-066870df3a3f + - 1193.4686938790917 + - 0.0 + - 1.0 + - 831.0249307479223 + - 350MVA_380/110 + - 1.0608979591836734 + - 350000.0 + - 16 + - -16 + - 0 + - false + - 380.0 + - 110.0 + - 90.75951402093402 + - simBench + + * - 7cb289cb-e6af-4470-9c68-e5a91978a5e7 + - 2013.800484464662 + - 0.0 + - 1.0 + - 1446.280991735537 + - 300MVA_220/110 + - 0.20704444444444442 + - 300000.0 + - 16 + - -16 + - 0 + - false + - 220.0 + - 110.0 + - 19.358892855688435 + - simBench + + * - 73644bc6-78cf-4882-9837-e6508cab092d + - 867.7685950413226 + - 0.0 + - 1.5 + - 1157.0247933884295 + - 25 MVA 110/20 kV YNd5 + - 1.9843999999999997 + - 25000.0 + - 9 + - -9 + - 0 + - false + - 110.0 + - 20.0 + - 58.04608993412045 + - simBench + + * - 6935ae26-374a-4c24-aeee-6d5760d6ddf3 + - 720.4791642215993 + - 0.0 + - 1.5 + - 1487.603305785124 + - 40 MVA 110/20 kV YNd5 + - 1.0285 + - 40000.0 + - 9 + - -9 + - 0 + - false + - 110.0 + - 20.0 + - 48.994205909984906 + - simBench + + * - b49db20f-b8b5-4265-8318-f669b9d121e9 + - 1015.6886939330394 + - 0.0 + - 1.5 + - 1818.181818181818 + - 63 MVA 110/10 kV YNd5 + - 0.6146031746031745 + - 63000.0 + - 9 + - -9 + - 0 + - false + - 110.0 + - 10.0 + - 34.56596500037509 + - simBench + + * - 0843b836-cee4-4a8c-81a4-098400fe91cf + - 24.495101551166183 + - 0.0 + - 2.5 + - 2999.9999999999995 + - 0.4 MVA 20/0.4 kV Dyn5 ASEA + - 11.999999999999998 + - 400.0 + - 2 + - -2 + - 0 + - false + - 20.0 + - 0.4 + - 58.787753826796276 + - simBench + + * - a8f3aeea-ef4d-4f3c-bb07-09a0a86766c1 + - 9.591746452043322 + - 0.0 + - 2.5 + - 1149.9999999999998 + - 0.16 MVA 20/0.4 kV DOTE 160/20 SGB + - 36.71874999999999 + - 160.0 + - 2 + - -2 + - 0 + - false + - 20.0 + - 0.4 + - 93.01469452961452 + - simBench + + * - 0644c120-a247-425f-bbe4-31b153f7f440 + - 16.583241729259253 + - 0.0 + - 2.5 + - 2199.9999999999995 + - 0.25 MVA 20/0.4 kV Dyn5 ASEA + - 21.119999999999997 + - 250.0 + - 2 + - -2 + - 0 + - false + - 20.0 + - 0.4 + - 93.6479876986153 + - simBench + + * - bdf22ee4-deba-41f4-a187-ae00638a6880 + - 36.47380569074435 + - 0.0 + - 2.5 + - 4125.0 + - 0.63 MVA 20/0.4 kV Dyn5 ASEA + - 6.953892668178382 + - 630.0 + - 2 + - -2 + - 0 + - false + - 20.0 + - 0.4 + - 37.45518044666632 + - simBench + + * - a0cbd90a-4e9f-47db-8dca-041d3a288f77 + - 145.8952227629774 + - 0.0 + - 2.5 + - 16500.0 + - 0.63 MVA 10/0.4 kV Dyn5 ASEA + - 1.7384731670445954 + - 630.0 + - 2 + - -2 + - 0 + - false + - 10.0 + - 0.4 + - 9.36379511166658 + - simBench +``` ## Caveats diff --git a/docs/readthedocs/models/input/grid/transformer3w.md b/docs/readthedocs/models/input/grid/transformer3w.md new file mode 100644 index 000000000..15575c78c --- /dev/null +++ b/docs/readthedocs/models/input/grid/transformer3w.md @@ -0,0 +1,186 @@ +(transformer3w-model)= + +# Three Winding Transformer + +Model of a three winding transformer. +It is assumed, that node A is the node with highest, node B with intermediate and node C with lowest voltage. + +The assumed mathematical model is inspired by *ABB Schaltanlagenhanbuch* [^cite_gremmel1999], but with the addition of a +central phase-to-ground admittance, cf. following picture. + +```{figure} ../../../_static/figures/ecdTransformer3w.png +--- +align: center +name: Equivalent circuit diagram of a three winding transformer +--- +"Star like" T-equivalent circuit diagram of a three winding transformer +``` + +## Attributes, Units and Remarks + +### Type Model + +All impedances and admittances are given with respect to the higher voltage side. + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - + - + + * - id + - + - Human readable identifier + + * - rScA + - Ω + - Short circuit resistance in branch A + + * - rScB + - Ω + - Short circuit resistance in branch B + + * - rScC + - Ω + - Short circuit resistance in branch C + + * - xScA + - Ω + - Short circuit reactance in branch A + + * - xScB + - Ω + - Short circuit reactance in branch B + + * - xScC + - Ω + - Short circuit reactance in branch C + + * - gM + - nS + - No load conductance + + * - bM + - nS + - No load susceptance + + * - sRatedA + - kVA + - Rated apparent power of branch A + + * - sRatedB + - kVA + - Rated apparent power of branch B + + * - sRatedC + - kVA + - Rated apparent power of branch C + + * - vRatedA + - kV + - Rated voltage at higher node A + + * - vRatedB + - kV + - Rated voltage at higher node B + + * - vRatedC + - kV + - Rated voltage at higher node C + + * - dV + - % + - Voltage magnitude increase per tap position + + * - dPhi + - ° + - Voltage angle increase per tap position + + * - tapNeutr + - + - Neutral tap position + + * - tapMin + - + - Minimum tap position + + * - tapMax + - + - Maximum tap position + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - nodeA + - -- + - Higher voltage node + + * - nodeB + - -- + - Intermediate voltage node + + * - nodeC + - -- + - Lowest voltage node + + * - parallelDevices + - -- + - | overall amount of parallel transformers to automatically + | construct (e.g. parallelDevices = 2 will build a + | total of two transformers using the specified parameters) + + * - type + - -- + - + + * - tapPos + - -- + - Current position of the tap changer + + * - autoTap + - -- + - true, if there is a tap regulation apparent and active + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! + +[^cite_gremmel1999]: Gremmel, H., Ed., Schaltanlagen. Cornelsen Verlag, 1999, Vol. 10, isbn: 3-464-48235-9. diff --git a/docs/readthedocs/models/input/grid/transformer3w.rst b/docs/readthedocs/models/input/grid/transformer3w.rst deleted file mode 100644 index 1e62a7463..000000000 --- a/docs/readthedocs/models/input/grid/transformer3w.rst +++ /dev/null @@ -1,106 +0,0 @@ -.. _transformer3w_model: - -Three Winding Transformer -------------------------- -Model of a three winding transformer. -It is assumed, that node A is the node with highest, node B with intermediate and node C with lowest voltage. - -The assumed mathematical model is inspired by *ABB Schaltanlagenhanbuch* [Gremmel1999]_, but with the addition of a -central phase-to-ground admittance, cf. following picture. - -.. figure:: ../../../_static/figures/ecdTransformer3w.png - :align: center - :alt: Equivalent circuit diagram of a three winding transformer - - "Star like" T-equivalent circuit diagram of a three winding transformer - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" -All impedances and admittances are given with respect to the higher voltage side. - -+-----------+------+---------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===========+======+=========================================================+ -| uuid | | | -+-----------+------+---------------------------------------------------------+ -| id | | Human readable identifier | -+-----------+------+---------------------------------------------------------+ -| rScA | Ω | Short circuit resistance in branch A | -+-----------+------+---------------------------------------------------------+ -| rScB | Ω | Short circuit resistance in branch B | -+-----------+------+---------------------------------------------------------+ -| rScC | Ω | Short circuit resistance in branch C | -+-----------+------+---------------------------------------------------------+ -| xScA | Ω | Short circuit reactance in branch A | -+-----------+------+---------------------------------------------------------+ -| xScB | Ω | Short circuit reactance in branch B | -+-----------+------+---------------------------------------------------------+ -| xScC | Ω | Short circuit reactance in branch C | -+-----------+------+---------------------------------------------------------+ -| gM | nS | No load conductance | -+-----------+------+---------------------------------------------------------+ -| bM | nS | No load susceptance | -+-----------+------+---------------------------------------------------------+ -| sRatedA | kVA | Rated apparent power of branch A | -+-----------+------+---------------------------------------------------------+ -| sRatedB | kVA | Rated apparent power of branch B | -+-----------+------+---------------------------------------------------------+ -| sRatedC | kVA | Rated apparent power of branch C | -+-----------+------+---------------------------------------------------------+ -| vRatedA | kV | Rated voltage at higher node A | -+-----------+------+---------------------------------------------------------+ -| vRatedB | kV | Rated voltage at higher node B | -+-----------+------+---------------------------------------------------------+ -| vRatedC | kV | Rated voltage at higher node C | -+-----------+------+---------------------------------------------------------+ -| dV | % | Voltage magnitude increase per tap position | -+-----------+------+---------------------------------------------------------+ -| dPhi | ° | Voltage angle increase per tap position | -+-----------+------+---------------------------------------------------------+ -| tapNeutr | | Neutral tap position | -+-----------+------+---------------------------------------------------------+ -| tapMin | | Minimum tap position | -+-----------+------+---------------------------------------------------------+ -| tapMax | | Maximum tap position | -+-----------+------+---------------------------------------------------------+ - -Entity Model -"""""""""""" - -+-----------------+------+------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=================+======+============================================================+ -| uuid | -- | | -+-----------------+------+------------------------------------------------------------+ -| id | -- | Human readable identifier | -+-----------------+------+------------------------------------------------------------+ -| operator | -- | | -+-----------------+------+------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+-----------------+------+------------------------------------------------------------+ -| nodeA | -- | Higher voltage node | -+-----------------+------+------------------------------------------------------------+ -| nodeB | -- | Intermediate voltage node | -+-----------------+------+------------------------------------------------------------+ -| nodeC | -- | Lowest voltage node | -+-----------------+------+------------------------------------------------------------+ -| parallelDevices | -- | | overall amount of parallel transformers to automatically | -| | | | construct (e.g. parallelDevices = 2 will build a | -| | | | total of two transformers using the specified parameters)| -+-----------------+------+------------------------------------------------------------+ -| type | -- | | -+-----------------+------+------------------------------------------------------------+ -| tapPos | -- | Current position of the tap changer | -+-----------------+------+------------------------------------------------------------+ -| autoTap | -- | true, if there is a tap regulation apparent and active | -+-----------------+------+------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! - -.. [Gremmel1999] Gremmel, H., Ed., Schaltanlagen. Cornelsen Verlag, 1999, Vol. 10, isbn: 3-464-48235-9. \ No newline at end of file diff --git a/docs/readthedocs/models/input/operator.md b/docs/readthedocs/models/input/operator.md new file mode 100644 index 000000000..dc560f18d --- /dev/null +++ b/docs/readthedocs/models/input/operator.md @@ -0,0 +1,46 @@ +(operator-model)= + +# Operator + +This is a simple identifier object, representing a natural or legal person that is the owner or responsible person +having control over one or more physical entitites. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + +``` + +(operator-example)= + +## Application example + +```{code-block} java +:linenos: true + +OperatorInput profBroccoli = new OperatorInput( + UUID.fromString("f15105c4-a2de-4ab8-a621-4bc98e372d92"), + "Univ.-Prof. Dr. rer. hort. Klaus-Dieter Brokkoli" + ) +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/operator.rst b/docs/readthedocs/models/input/operator.rst deleted file mode 100644 index 64d067a8d..000000000 --- a/docs/readthedocs/models/input/operator.rst +++ /dev/null @@ -1,33 +0,0 @@ -.. _operator_model: - -Operator --------- -This is a simple identifier object, representing a natural or legal person that is the owner or responsible person -having control over one or more physical entitites. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+-----------+------+---------------------------+ -| Attribute | Unit | Remarks | -+===========+======+===========================+ -| uuid | -- | | -+-----------+------+---------------------------+ -| id | -- | Human readable identifier | -+-----------+------+---------------------------+ - -.. _operator_example: - -Application example -^^^^^^^^^^^^^^^^^^^ -.. code-block:: java - :linenos: - - OperatorInput profBroccoli = new OperatorInput( - UUID.fromString("f15105c4-a2de-4ab8-a621-4bc98e372d92"), - "Univ.-Prof. Dr. rer. hort. Klaus-Dieter Brokkoli" - ) - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/bm.md b/docs/readthedocs/models/input/participant/bm.md new file mode 100644 index 000000000..ff1854e10 --- /dev/null +++ b/docs/readthedocs/models/input/participant/bm.md @@ -0,0 +1,121 @@ +(bm-model)= + +# Biomass plant + +Model of a biomass power plant. + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - activePowerGradient + - % / h + - Maximum permissible rate of change of power + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - etaConv + - % + - Efficiency of the assets inverter + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - marketReaction + - -- + - | Whether to adapt output based on (volatile) + | market price or not + + * - costControlled + - -- + - | Whether to adapt output based on the difference + | between production costs and fixed feed in tariff or not + + * - feedInTariff + - € / MWh + - Fixed feed in tariff + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/bm.rst b/docs/readthedocs/models/input/participant/bm.rst deleted file mode 100644 index 5314251e4..000000000 --- a/docs/readthedocs/models/input/participant/bm.rst +++ /dev/null @@ -1,66 +0,0 @@ -.. _bm_model: - -Biomass plant -------------- -Model of a biomass power plant. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" - -+---------------------+---------+------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=====================+=========+============================================================+ -| uuid | -- | | -+---------------------+---------+------------------------------------------------------------+ -| id | -- | Human readable identifier | -+---------------------+---------+------------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+---------------------+---------+------------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+---------------------+---------+------------------------------------------------------------+ -| activePowerGradient | % / h | Maximum permissible rate of change of power | -+---------------------+---------+------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+---------------------+---------+------------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+---------------------+---------+------------------------------------------------------------+ -| etaConv | % | Efficiency of the assets inverter | -+---------------------+---------+------------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| marketReaction | -- | | Whether to adapt output based on (volatile) | -| | | | market price or not | -+------------------+---------+--------------------------------------------------------------------------------------+ -| costControlled | -- | | Whether to adapt output based on the difference | -| | | | between production costs and fixed feed in tariff or not | -+------------------+---------+--------------------------------------------------------------------------------------+ -| feedInTariff | € / MWh | Fixed feed in tariff | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/chp.md b/docs/readthedocs/models/input/participant/chp.md new file mode 100644 index 000000000..ad4ff729e --- /dev/null +++ b/docs/readthedocs/models/input/participant/chp.md @@ -0,0 +1,128 @@ +(chp-model)= + +# Combined Heat and Power Plant + +Combined heat and power plant. + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - etaEl + - % + - Efficiency of the electrical inverter + + * - etaThermal + - % + - Thermal efficiency of the system + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - pThermal + - kW + - Rated thermal power (at rated electrical power) + + * - pOwn + - kW + - Needed self-consumption + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - thermalBus + - -- + - Connection point to the thermal system + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - thermalStorage + - -- + - Reference to thermal storage + + * - marketReaction + - -- + - | Whether to adapt output based on (volatile) + | market price or not + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/chp.rst b/docs/readthedocs/models/input/participant/chp.rst deleted file mode 100644 index 14cd2fd46..000000000 --- a/docs/readthedocs/models/input/participant/chp.rst +++ /dev/null @@ -1,69 +0,0 @@ -.. _chp_model: - -Combined Heat and Power Plant ------------------------------ -Combined heat and power plant. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" - -+-------------+---------+---------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=============+=========+=========================================================+ -| uuid | -- | | -+-------------+---------+---------------------------------------------------------+ -| id | -- | Human readable identifier | -+-------------+---------+---------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+-------------+---------+---------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+-------------+---------+---------------------------------------------------------+ -| etaEl | % | Efficiency of the electrical inverter | -+-------------+---------+---------------------------------------------------------+ -| etaThermal | % | Thermal efficiency of the system | -+-------------+---------+---------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+-------------+---------+---------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+-------------+---------+---------------------------------------------------------+ -| pThermal | kW | Rated thermal power (at rated electrical power) | -+-------------+---------+---------------------------------------------------------+ -| pOwn | kW | Needed self-consumption | -+-------------+---------+---------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| thermalBus | -- | Connection point to the thermal system | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| thermalStorage | -- | Reference to thermal storage | -+------------------+---------+--------------------------------------------------------------------------------------+ -| marketReaction | -- | | Whether to adapt output based on (volatile) | -| | | | market price or not | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/cylindricalstorage.md b/docs/readthedocs/models/input/participant/cylindricalstorage.md new file mode 100644 index 000000000..5e3b8d40c --- /dev/null +++ b/docs/readthedocs/models/input/participant/cylindricalstorage.md @@ -0,0 +1,64 @@ +(cylindricalstorage-model)= + +# Cylindrical Thermal Storage + +Model of a cylindrical thermal storage using a fluent to store thermal energy. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - thermalBus + - -- + - Connection point to the thermal system + + * - storageVolumeLvl + - m³ + - Overall available storage volume + + * - storageVolumeLvlMin + - m³ + - Minimum permissible storage volume + + * - inletTemp + - °C + - Temperature of the inlet + + * - returnTemp + - °C + - Temperature of the outlet + + * - c + - kWh / (K :math:`\cdot` m³) + - Specific heat capacity of the storage medium + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/cylindricalstorage.rst b/docs/readthedocs/models/input/participant/cylindricalstorage.rst deleted file mode 100644 index feaed6c3d..000000000 --- a/docs/readthedocs/models/input/participant/cylindricalstorage.rst +++ /dev/null @@ -1,36 +0,0 @@ -.. _cylindricalstorage_model: - -Cylindrical Thermal Storage --------------------------------- -Model of a cylindrical thermal storage using a fluent to store thermal energy. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------------------+----------------------------+----------------------------------------------+ -| Attribute | Unit | Remarks | -+=====================+============================+==============================================+ -| uuid | -- | | -+---------------------+----------------------------+----------------------------------------------+ -| id | -- | Human readable identifier | -+---------------------+----------------------------+----------------------------------------------+ -| operator | -- | | -+---------------------+----------------------------+----------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------------+----------------------------+----------------------------------------------+ -| thermalBus | -- | Connection point to the thermal system | -+---------------------+----------------------------+----------------------------------------------+ -| storageVolumeLvl | m³ | Overall available storage volume | -+---------------------+----------------------------+----------------------------------------------+ -| storageVolumeLvlMin | m³ | Minimum permissible storage volume | -+---------------------+----------------------------+----------------------------------------------+ -| inletTemp | °C | Temperature of the inlet | -+---------------------+----------------------------+----------------------------------------------+ -| returnTemp | °C | Temperature of the outlet | -+---------------------+----------------------------+----------------------------------------------+ -| c | kWh / (K :math:`\cdot` m³) | Specific heat capacity of the storage medium | -+---------------------+----------------------------+----------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/em.md b/docs/readthedocs/models/input/participant/em.md new file mode 100644 index 000000000..3e842e612 --- /dev/null +++ b/docs/readthedocs/models/input/participant/em.md @@ -0,0 +1,50 @@ +(em_model)= + +# Energy Management Unit + +A model of an Energy Management Unit that controls the power of connected system participants. +Participants are connected to an EM each via their `em` field. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - controlStrategy + - -- + - String representation (e.g. name) of a control strategy + + * - parentEm + - -- + - | Reference to a superior Energy Management Unit that is controlling this EM. + | Field can be empty or missing, if this EM itself is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/ev.md b/docs/readthedocs/models/input/participant/ev.md new file mode 100644 index 000000000..036a92312 --- /dev/null +++ b/docs/readthedocs/models/input/participant/ev.md @@ -0,0 +1,107 @@ +(ev-model)= + +# Electric Vehicle + +Model of an electric vehicle, that is occasionally connected to the grid via an [electric vehicle charging system](evcs.md#electric-vehicle-charging-station). + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - eStorage + - kWh + - Available battery capacity + + * - eCons + - kWh / km + - Energy consumption per driven kilometre + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +The {code}`node` attribute only marks the vehicles home connection point. +The actual connection to the grid is always given through {code}`EvcsInput`'s relation. diff --git a/docs/readthedocs/models/input/participant/ev.rst b/docs/readthedocs/models/input/participant/ev.rst deleted file mode 100644 index cd98d6d86..000000000 --- a/docs/readthedocs/models/input/participant/ev.rst +++ /dev/null @@ -1,55 +0,0 @@ -.. _ev_model: - -Electric Vehicle ------------------------------ -Model of an electric vehicle, that is occasionally connected to the grid via an :ref:`electric vehicle charging system`. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" -+-------------+----------+---------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=============+==========+=========================================================+ -| uuid | -- | | -+-------------+----------+---------------------------------------------------------+ -| id | -- | Human readable identifier | -+-------------+----------+---------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+-------------+----------+---------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+-------------+----------+---------------------------------------------------------+ -| eStorage | kWh | Available battery capacity | -+-------------+----------+---------------------------------------------------------+ -| eCons | kWh / km | Energy consumption per driven kilometre | -+-------------+----------+---------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+-------------+----------+---------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+-------------+----------+---------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+---------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+=================================+ -| uuid | -- | | -+------------------+---------+---------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+---------------------------------+ -| operator | -- | | -+------------------+---------+---------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+---------------------------------+ -| node | -- | | -+------------------+---------+---------------------------------+ -| type | -- | | -+------------------+---------+---------------------------------+ - -Caveats -^^^^^^^ -The :code:`node` attribute only marks the vehicles home connection point. -The actual connection to the grid is always given through :code:`EvcsInput`'s relation. diff --git a/docs/readthedocs/models/input/participant/evcs.md b/docs/readthedocs/models/input/participant/evcs.md new file mode 100644 index 000000000..b97def9c3 --- /dev/null +++ b/docs/readthedocs/models/input/participant/evcs.md @@ -0,0 +1,262 @@ +(evcs-model)= + +# Electric Vehicle Charging Station + +Model of a charging station for electric vehicles. This model only covers the basic characteristics of a charging +station and has some limitations outlined below. + +## Model Definition + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - :ref:`Charging point type` (valid for all installed points) + + * - chargingPoints + - -- + - no of installed charging points @ the specific station + + * - cosPhiRated + - -- + - Rated power factor + + * - locationType + - -- + - :ref:`Charging station location types` + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +### Type Model + +In contrast to other models, electric vehicle charging station types are not configured via separate type file or table, +but 'inline' of a charging station entry. This is justified by the fact, that the station type (in contrast to e.g. +the type of a wind energy converter) only consists of a few, more or less standardized parameters, that are (most of the +time) equal for all manufacturers. Hence, to simplify the type model handling, types are provided either by a string +literal of their id or by providing a custom one. See [Charging point types](evcs.md#charging-point-types) for details of on +available standard types and how to use custom types. + +The actual model definition for charging point types looks as follows: + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - id + - -- + - Human readable identifier + + * - sRated + - kVA + - Rated apparent power + + * - electricCurrentType + - -- + - Electric current type + + * - synonymousIds + - -- + - Set of alternative human readable identifiers + +``` + +(evcs-point-types)= + +## Charging Point Types + +### Available Standard Types + +To simplify the application of electric vehicle charging stations, some common standard types are available out-of-the-box. +They can either by used code wise or directly from database or file input by referencing their id or one of their +synonymous ids. All standard types can be found in {code}`edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils`. + +```{eval-rst} +.. list-table:: + :widths: 25 25 25 25 + :header-rows: 0 + + + * - id + - synonymous ids + - sRated in kVA + - electric current type + + * - HouseholdSocket + - household, hhs, schuko-simple + - 2.3 + - AC + + * - BlueHouseholdSocket + - bluehousehold, bhs, schuko-camping + - 3.6 + - AC + + * - Cee16ASocket + - cee16 + - 11 + - AC + + * - Cee32ASocket + - cee32 + - 22 + - AC + + * - Cee63ASocket + - cee63 + - 43 + - AC + + * - ChargingStationType1 + - cst1, stationtype1, cstype1 + - 7.2 + - AC + + * - ChargingStationType2 + - cst2, stationtype2, cstype2 + - 43 + - AC + + * - ChargingStationCcsComboType1 + - csccs1, csccscombo1 + - 11 + - DC + + * - ChargingStationCcsComboType2 + - csccs2, csccscombo2 + - 50 + - DC + + * - TeslaSuperChargerV1 + - tesla1, teslav1, supercharger1, supercharger + - 135 + - DC + + * - TeslaSuperChargerV2 + - tesla2, teslav2, supercharger2 + - 150 + - DC + + * - TeslaSuperChargerV3 + - tesla3, teslav3, supercharger3 + - 250 + - DC + + +``` + +### Custom Types + +While the provided standard types should be suitable for most scenarios, providing an individual type for a specific +scenario might be necessary. To do so, a custom type can be provided instead of a common id. This custom type is tested +against the following regex {code}`(\w+\d*)\s*\(\s*(\d+\.?\d+)\s*\|\s*(AC|DC)\s*\)`, or more generally, the custom +type string has to be in the following syntax: + +``` +(|) e.g. FastCharger(50|DC) or SlowCharger(2.5|AC) +``` + +Please note, that in accordance with {code}`edu.ie3.datamodel.models.StandardUnits` the apparent power is expected to +be in kVA! + +### Limitations + +- the available charging types are currently limited to only some common standard charging point types and not configurable + via a type file or table. Nevertheless, providing custom types is possible using the syntax explained above. + If there is additional need for a more granular type configuration via type file please contact us. +- each charging station can hold one or more charging points. If more than one charging point is available + all attributes (e.g. {code}`sRated` or {code}`connectionType`) are considered to be equal for all connection + points + +(location-types)= + +## Location types + +Evcs location types describe the type of charging location of a charging station. Parsing of these types is case-insensitive +and underscores and minuses are ignored, that means "charginghubtown" is parsed as type {code}`CHARGING_HUB_TOWN`. + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - type name + - public/private + - description + + * - HOME + - private + - Charging at home + + * - WORK + - private + - Charging at work + + * - CUSTOMER_PARKING + - public + - Charging at store parking lots + + * - STREET + - public + - Charging at street side + + * - CHARGING_HUB_TOWN + - public + - Charging at hub in town + + * - CHARGING_HUB_HIGHWAY + - public + - Charging at hub out of town + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/evcs.rst b/docs/readthedocs/models/input/participant/evcs.rst deleted file mode 100644 index 251003c20..000000000 --- a/docs/readthedocs/models/input/participant/evcs.rst +++ /dev/null @@ -1,149 +0,0 @@ -.. _evcs_model: - -Electric Vehicle Charging Station ---------------------------------- -Model of a charging station for electric vehicles. This model only covers the basic characteristics of a charging -station and has some limitations outlined below. - -Model Definition -^^^^^^^^^^^^^^^^ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | :ref:`Charging point type` (valid for all installed points) | -+------------------+---------+--------------------------------------------------------------------------------------+ -| chargingPoints | -- | no of installed charging points @ the specific station | -+------------------+---------+--------------------------------------------------------------------------------------+ -| cosPhiRated | -- | Rated power factor | -+------------------+---------+--------------------------------------------------------------------------------------+ -| locationType | -- | :ref:`Charging station location types` | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Type Model -"""""""""""" -In contrast to other models, electric vehicle charging station types are not configured via separate type file or table, -but 'inline' of a charging station entry. This is justified by the fact, that the station type (in contrast to e.g. -the type of a wind energy converter) only consists of a few, more or less standardized parameters, that are (most of the -time) equal for all manufacturers. Hence, to simplify the type model handling, types are provided either by a string -literal of their id or by providing a custom one. See :ref:`Charging point types` for details of on -available standard types and how to use custom types. - -The actual model definition for charging point types looks as follows: - -+------------------------+---------+--------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+========================+=========+================================================================================+ -| id | -- | Human readable identifier | -+------------------------+---------+--------------------------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+------------------------+---------+--------------------------------------------------------------------------------+ -| electricCurrentType | -- | Electric current type | -+------------------------+---------+--------------------------------------------------------------------------------+ -|synonymousIds | -- | Set of alternative human readable identifiers | -+------------------------+---------+--------------------------------------------------------------------------------+ - -.. _evcs_point_types: - -Charging Point Types -^^^^^^^^^^^^^^^^^^^^ -Available Standard Types -"""""""""""""""""""""""" -To simplify the application of electric vehicle charging stations, some common standard types are available out-of-the-box. -They can either by used code wise or directly from database or file input by referencing their id or one of their -synonymous ids. All standard types can be found in :code:`edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils`. - -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| id | synonymous ids | sRated in kVA | electric current type | -+===============================+===============================================+===============+=======================+ -| HouseholdSocket | household, hhs, schuko-simple | 2.3 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| BlueHouseholdSocket | bluehousehold, bhs, schuko-camping | 3.6 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| Cee16ASocket | cee16 | 11 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| Cee32ASocket | cee32 | 22 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| Cee63ASocket | cee63 | 43 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| ChargingStationType1 | cst1, stationtype1, cstype1 | 7.2 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| ChargingStationType2 | cst2, stationtype2, cstype2 | 43 | AC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| ChargingStationCcsComboType1 | csccs1, csccscombo1 | 11 | DC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| ChargingStationCcsComboType2 | csccs2, csccscombo2 | 50 | DC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| TeslaSuperChargerV1 | tesla1, teslav1, supercharger1, supercharger | 135 | DC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| TeslaSuperChargerV2 | tesla2, teslav2, supercharger2 | 150 | DC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ -| TeslaSuperChargerV3 | tesla3, teslav3, supercharger3 | 250 | DC | -+-------------------------------+-----------------------------------------------+---------------+-----------------------+ - - -Custom Types -"""""""""""" -While the provided standard types should be suitable for most scenarios, providing an individual type for a specific -scenario might be necessary. To do so, a custom type can be provided instead of a common id. This custom type is tested -against the following regex :code:`(\w+\d*)\s*\(\s*(\d+\.?\d+)\s*\|\s*(AC|DC)\s*\)`, or more generally, the custom -type string has to be in the following syntax:: - - (|) e.g. FastCharger(50|DC) or SlowCharger(2.5|AC) - -Please note, that in accordance with :code:`edu.ie3.datamodel.models.StandardUnits` the apparent power is expected to -be in kVA! - -Limitations -""""""""""" - -- the available charging types are currently limited to only some common standard charging point types and not configurable - via a type file or table. Nevertheless, providing custom types is possible using the syntax explained above. - If there is additional need for a more granular type configuration via type file please contact us. -- each charging station can hold one or more charging points. If more than one charging point is available - all attributes (e.g. :code:`sRated` or :code:`connectionType`) are considered to be equal for all connection - points - -.. _location_types: - -Location types -^^^^^^^^^^^^^^ - -Evcs location types describe the type of charging location of a charging station. Parsing of these types is case-insensitive -and underscores and minuses are ignored, that means "charginghubtown" is parsed as type :code:`CHARGING_HUB_TOWN`. - -+-------------------------------+-------------------+----------------------------------+ -| type name | public/private | description | -+===============================+===================+==================================+ -| HOME | private | Charging at home | -+-------------------------------+-------------------+----------------------------------+ -| WORK | private | Charging at work | -+-------------------------------+-------------------+----------------------------------+ -| CUSTOMER_PARKING | public | Charging at store parking lots | -+-------------------------------+-------------------+----------------------------------+ -| STREET | public | Charging at street side | -+-------------------------------+-------------------+----------------------------------+ -| CHARGING_HUB_TOWN | public | Charging at hub in town | -+-------------------------------+-------------------+----------------------------------+ -| CHARGING_HUB_HIGHWAY | public | Charging at hub out of town | -+-------------------------------+-------------------+----------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/fixedfeedin.md b/docs/readthedocs/models/input/participant/fixedfeedin.md new file mode 100644 index 000000000..2098271de --- /dev/null +++ b/docs/readthedocs/models/input/participant/fixedfeedin.md @@ -0,0 +1,63 @@ +(fixed-feed-in-model)= + +# Fixed Feed In Facility + +Model of a facility, that provides constant power feed in, as no further information about the actual behaviour of the +model can be derived. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/fixedfeedin.rst b/docs/readthedocs/models/input/participant/fixedfeedin.rst deleted file mode 100644 index f317d5534..000000000 --- a/docs/readthedocs/models/input/participant/fixedfeedin.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. _fixed_feed_in_model: - -Fixed Feed In Facility ----------------------- -Model of a facility, that provides constant power feed in, as no further information about the actual behaviour of the -model can be derived. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+------------------+---------+--------------------------------------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/general.md b/docs/readthedocs/models/input/participant/general.md new file mode 100644 index 000000000..7dd45d438 --- /dev/null +++ b/docs/readthedocs/models/input/participant/general.md @@ -0,0 +1,45 @@ +# General Remarks on Participant Models + +(participant-general-q-characteristic)= + +## Reactive Power Characteristics + +Reactive power characteristics are designed to describe reactive power control behaviour of the models. +In Germany, system operators can require system participants to follow certain characteristics specified in the +operators technical requirements and individually selected per connected asset. + +Currently three different characteristics are implemented: + +### Fixed Power Factor + +Active and reactive power are coupled by a time-independent power factor. +It can be parsed from {code}`cosPhiFixed:{(0.0, 0.95)}` (exemplary). + +### Active Power Dependent Power Factor + +The power factor is determined based on the current active power feed in or consumption. +The characteristic in the figure below would be described by the three coordinates (0.0, 1.0), (0.9,1.0) and (1.0, 0.95). +Alternatively it can be parsed from {code}`cosPhiP:{(0.0, 1.0),(0.9,1.0),(1.0, 0.95)}`. + +```{figure} ../../../_static/figures/cosPhiP.png +--- +align: center +name: Active power dependent power factor +--- +Exemplary active power dependent power factor +``` + +### Reactive Power as Function of Nodal Voltage Magnitude + +The reactive power is directly derived in accordance to the nodal voltage magnitude. +The characteristic in the figure below would be described by the three coordinates (0.92, -1), (0.97, 0.0), (1.03, 0.0) +and (1.08, 1.0). +Alternatively it can be parsed from {code}`qV:{(0.92, -1),(0.97, 0.0),(1.03, 0.0),(1.08, 1.0)}`. + +```{figure} ../../../_static/figures/qv.png +--- +align: center +name: Reactive power as function of nodal voltage magnitude +--- +Exemplary reactive power as function of nodal voltage magnitude +``` \ No newline at end of file diff --git a/docs/readthedocs/models/input/participant/general.rst b/docs/readthedocs/models/input/participant/general.rst deleted file mode 100644 index 6ebb861ea..000000000 --- a/docs/readthedocs/models/input/participant/general.rst +++ /dev/null @@ -1,42 +0,0 @@ -General Remarks on Participant Models -------------------------------------- - -.. _participant_general_q_characteristic: - -Reactive Power Characteristics -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Reactive power characteristics are designed to describe reactive power control behaviour of the models. -In Germany, system operators can require system participants to follow certain characteristics specified in the -operators technical requirements and individually selected per connected asset. - -Currently three different characteristics are implemented: - -Fixed Power Factor -"""""""""""""""""" -Active and reactive power are coupled by a time-independent power factor. -It can be parsed from :code:`cosPhiFixed:{(0.0, 0.95)}` (exemplary). - -Active Power Dependent Power Factor -""""""""""""""""""""""""""""""""""" -The power factor is determined based on the current active power feed in or consumption. -The characteristic in the figure below would be described by the three coordinates (0.0, 1.0), (0.9,1.0) and (1.0, 0.95). -Alternatively it can be parsed from :code:`cosPhiP:{(0.0, 1.0),(0.9,1.0),(1.0, 0.95)}`. - -.. figure:: ../../../_static/figures/cosPhiP.png - :align: center - :alt: Active power dependent power factor - - Exemplary active power dependent power factor - -Reactive Power as Function of Nodal Voltage Magnitude -""""""""""""""""""""""""""""""""""""""""""""""""""""" -The reactive power is directly derived in accordance to the nodal voltage magnitude. -The characteristic in the figure below would be described by the three coordinates (0.92, -1), (0.97, 0.0), (1.03, 0.0) -and (1.08, 1.0). -Alternatively it can be parsed from :code:`qV:{(0.92, -1),(0.97, 0.0),(1.03, 0.0),(1.08, 1.0)}`. - -.. figure:: ../../../_static/figures/qv.png - :align: center - :alt: Reactive power as function of nodal voltage magnitude - - Exemplary reactive power as function of nodal voltage magnitude \ No newline at end of file diff --git a/docs/readthedocs/models/input/participant/hp.md b/docs/readthedocs/models/input/participant/hp.md new file mode 100644 index 000000000..71c8a1608 --- /dev/null +++ b/docs/readthedocs/models/input/participant/hp.md @@ -0,0 +1,108 @@ +(hp-model)= + +# Heat Pump + +Model of a heat pump. + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - pThermal + - kW + - Rated thermal power (at rated electrical power) + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - thermalBus + - -- + - Connection point to the thermal system + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/hp.rst b/docs/readthedocs/models/input/participant/hp.rst deleted file mode 100644 index e28cc3c52..000000000 --- a/docs/readthedocs/models/input/participant/hp.rst +++ /dev/null @@ -1,59 +0,0 @@ -.. _hp_model: - -Heat Pump ---------- -Model of a heat pump. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" - -+-------------+---------+---------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=============+=========+=========================================================+ -| uuid | -- | | -+-------------+---------+---------------------------------------------------------+ -| id | -- | Human readable identifier | -+-------------+---------+---------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+-------------+---------+---------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+-------------+---------+---------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+-------------+---------+---------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+-------------+---------+---------------------------------------------------------+ -| pThermal | kW | Rated thermal power (at rated electrical power) | -+-------------+---------+---------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| thermalBus | -- | Connection point to the thermal system | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ - - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/load.md b/docs/readthedocs/models/input/participant/load.md new file mode 100644 index 000000000..c31f71549 --- /dev/null +++ b/docs/readthedocs/models/input/participant/load.md @@ -0,0 +1,95 @@ +(load-model)= + +# Load + +Model of (mainly) domestic loads. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - loadProfile + - -- + - :ref:`Load profile` as model behaviour + + * - dsm + - -- + - Whether the load is able to follow demand side management signals + + * - eConsAnnual + - kWh + - Annual energy consumption + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! + +(load-lp)= + +## Load Profiles + +The {code}`LoadProfile` is an interface, that forces its implementing classes to have a {code}`String` *key* +and being able to parse a {code}`String` to a {code}`LoadProfile`. +Its only purpose is to give note, which load profile has to be used by the simulation. +The actual profile has to be provided by the simulation itself. +If no matching standard load profile is known, {code}`LoadProfile#NO_LOAD_PROFILE` can be used. + +To assist the user in marking the desired load profile, the enum {code}`BdewLoadProfile` provides a collection of +commonly known German standard electricity load profiles, defined by the bdew (Bundesverband der Energie- und +Wasserwirtschaft; engl. Federal Association of the Energy and Water Industry). For more details see +[the corresponding website (German only)](https://www.bdew.de/energie/standardlastprofile-strom/). + +Furthermore there are {code}`TemperatureDependantLoadProfiles` which can be used to note usage of load profiles for night heating storages or heat pumps for example. +The profiles rely on the VDN description for interruptable loads. +For more details see [here (German only)](https://www.bdew.de/media/documents/LPuVe-Praxisleitfaden.pdf). +{code}`NbwTemperatureDependantLoadProfiles` provides sample temperature dependant load profiles that can be used. +The `NbwTemperatureDependantLoadProfiles` consists of load profiles "ep1" for heat pumps and "ez2" for night storage heating. diff --git a/docs/readthedocs/models/input/participant/load.rst b/docs/readthedocs/models/input/participant/load.rst deleted file mode 100644 index f2aa5aa23..000000000 --- a/docs/readthedocs/models/input/participant/load.rst +++ /dev/null @@ -1,60 +0,0 @@ -.. _load_model: - -Load ----- -Model of (mainly) domestic loads. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=====================+=========+======================================================================================+ -| uuid | -- | | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| loadProfile | -- | :ref:`Load profile` as model behaviour | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| dsm | -- | Whether the load is able to follow demand side management signals | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| eConsAnnual | kWh | Annual energy consumption | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+---------------------+---------+--------------------------------------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+---------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! - -.. _load_lp: - -Load Profiles -^^^^^^^^^^^^^^^^^^^^^^ -The :code:`LoadProfile` is an interface, that forces it's implementing classes to have a :code:`String` *key* -and being able to parse a :code:`String` to a :code:`LoadProfile`. -Its only purpose is to give note, which load profile has to be used by the simulation. -The actual profile has to be provided by the simulation itself. -If no matching standard load profile is known, :code:`LoadProfile#NO_LOAD_PROFILE` can be used. - -To assist the user in marking the desired load profile, the enum :code:`BdewLoadProfile` provides a collection of -commonly known German standard electricity load profiles, defined by the bdew (Bundesverband der Energie- und -Wasserwirtschaft; engl. Federal Association of the Energy and Water Industry). For more details see -`the corresponding website (German only) `_. - -Furthermore there are :code:`TemperatureDependantLoadProfiles` which can be used to note usage of load profiles for night heating storages or heat pumps for example. -The profiles rely on the VDN description for interruptable loads. -For more details see `here (German only) `_. -:code:`NbwTemperatureDependantLoadProfiles` provides sample temperature dependant load profiles that can be used. -The `NbwTemperatureDependantLoadProfiles` consists of load profiles "ep1" for heat pumps and "ez2" for night storage heating. diff --git a/docs/readthedocs/models/input/participant/pv.md b/docs/readthedocs/models/input/participant/pv.md new file mode 100644 index 000000000..0746f0023 --- /dev/null +++ b/docs/readthedocs/models/input/participant/pv.md @@ -0,0 +1,90 @@ +(pv-model)= + +# Photovoltaic Power Plant + +Detailed model of a photovoltaic power plant. + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - albedo + - -- + - `Albedo `_ of the plant's surrounding + + * - azimuth + - ° + - | Inclination in a compass direction + | South = 0°, West = 90°, East = -90° + + * - etaConv + - % + - Efficiency of the assets inverter + + * - elevationAngle + - ° + - Tilted inclination from horizontal [0°, 90°] + + * - kG + - -- + - Generator correction factor merging technical influences + + * - kT + - -- + - Temperature correction factor merging thermal influences + + * - marketReaction + - -- + - | Whether to adapt output based on (volatile) + | market price or not + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/pv.rst b/docs/readthedocs/models/input/participant/pv.rst deleted file mode 100644 index 3308f9c6b..000000000 --- a/docs/readthedocs/models/input/participant/pv.rst +++ /dev/null @@ -1,46 +0,0 @@ -.. _pv_model: - -Photovoltaic Power Plant ------------------------- -Detailed model of a photovoltaic power plant. - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| albedo | -- | `Albedo `_ of the plant's surrounding | -+------------------+---------+--------------------------------------------------------------------------------------+ -| azimuth | ° | | Inclination in a compass direction | -| | | | South = 0°, West = 90°, East = -90° | -+------------------+---------+--------------------------------------------------------------------------------------+ -| etaConv | % | Efficiency of the assets inverter | -+------------------+---------+--------------------------------------------------------------------------------------+ -| elevationAngle | ° | Tilted inclination from horizontal [0°, 90°] | -+------------------+---------+--------------------------------------------------------------------------------------+ -| kG | -- | Generator correction factor merging technical influences | -+------------------+---------+--------------------------------------------------------------------------------------+ -| kT | -- | Temperature correction factor merging thermal influences | -+------------------+---------+--------------------------------------------------------------------------------------+ -| marketReaction | -- | | Whether to adapt output based on (volatile) | -| | | | market price or not | -+------------------+---------+--------------------------------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+------------------+---------+--------------------------------------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/storage.md b/docs/readthedocs/models/input/participant/storage.md new file mode 100644 index 000000000..dc4d4857d --- /dev/null +++ b/docs/readthedocs/models/input/participant/storage.md @@ -0,0 +1,135 @@ +(storage-model)= + +# Electrical Energy Storage + +Model of an ideal electrical battery energy storage. + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - eStorage + - kWh + - Battery capacity + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - pMax + - kW + - | Maximum permissible active power + | infeed or consumption + + * - activePowerGradient + - % / h + - Maximum permissible rate of change of power + + * - eta + - % + - Efficiency of the electrical inverter + + * - dod + - % + - | Maximum permissible depth of discharge. 80 % dod + | is equivalent to a state of charge of 20 %. + + * - lifeTime + - h + - Permissible hours of full use + + * - lifeCycle + - -- + - Permissible amount of full cycles + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - behaviour + - -- + - | Foreseen operation strategy of the storage. + | Eligible input: *"market"*, *"grid"*, *"self"* + + +``` + +## Caveats + +The field {code}`behaviour` will be removed in version 1.x, as this is an information, that is only important to a +smaller sub set of simulation applications. diff --git a/docs/readthedocs/models/input/participant/storage.rst b/docs/readthedocs/models/input/participant/storage.rst deleted file mode 100644 index 19d768a30..000000000 --- a/docs/readthedocs/models/input/participant/storage.rst +++ /dev/null @@ -1,74 +0,0 @@ -.. _storage_model: - -Electrical Energy Storage -------------------------- -Model of an ideal electrical battery energy storage. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" - -+---------------------+---------+---------------------------------------------------------+ -| Attribute | Unit | Remarks | -+=====================+=========+=========================================================+ -| uuid | -- | | -+---------------------+---------+---------------------------------------------------------+ -| id | -- | Human readable identifier | -+---------------------+---------+---------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+---------------------+---------+---------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+---------------------+---------+---------------------------------------------------------+ -| eStorage | kWh | Battery capacity | -+---------------------+---------+---------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+---------------------+---------+---------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+---------------------+---------+---------------------------------------------------------+ -| pMax | kW | | Maximum permissible active power | -| | | | infeed or consumption | -+---------------------+---------+---------------------------------------------------------+ -| activePowerGradient | % / h | Maximum permissible rate of change of power | -+---------------------+---------+---------------------------------------------------------+ -| eta | % | Efficiency of the electrical inverter | -+---------------------+---------+---------------------------------------------------------+ -| dod | % | | Maximum permissible depth of discharge. 80 % dod | -| | | | is equivalent to a state of charge of 20 %. | -+---------------------+---------+---------------------------------------------------------+ -| lifeTime | h | Permissible hours of full use | -+---------------------+---------+---------------------------------------------------------+ -| lifeCycle | -- | Permissible amount of full cycles | -+---------------------+---------+---------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| behaviour | -- | | Foreseen operation strategy of the storage. | -| | | | Eligible input: *"market"*, *"grid"*, *"self"* | -+------------------+---------+--------------------------------------------------------------------------------------+ - - -Caveats -^^^^^^^ -The field :code:`behaviour` will be removed in version 1.x, as this is an information, that is only important to a -smaller sub set of simulation applications. diff --git a/docs/readthedocs/models/input/participant/thermalbus.md b/docs/readthedocs/models/input/participant/thermalbus.md new file mode 100644 index 000000000..87cad5dd8 --- /dev/null +++ b/docs/readthedocs/models/input/participant/thermalbus.md @@ -0,0 +1,45 @@ +(thermal-bus-model)= + +# Thermal Bus + +A coupling point to thermal system - equivalent to [electrical node](../grid/node.md#node) +. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - bus + - -- + - Connection point to the thermal system + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/thermalbus.rst b/docs/readthedocs/models/input/participant/thermalbus.rst deleted file mode 100644 index 8b0a6300e..000000000 --- a/docs/readthedocs/models/input/participant/thermalbus.rst +++ /dev/null @@ -1,26 +0,0 @@ -.. _thermal_bus_model: - -Thermal Bus ------------ -A coupling point to thermal system - equivalent to :ref:`electrical node `. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------------+------+----------------------------------------+ -| Attribute | Unit | Remarks | -+===============+======+========================================+ -| uuid | -- | | -+---------------+------+----------------------------------------+ -| id | -- | Human readable identifier | -+---------------+------+----------------------------------------+ -| operator | -- | | -+---------------+------+----------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+---------------+------+----------------------------------------+ -| bus | -- | Connection point to the thermal system | -+---------------+------+----------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/thermalhouse.md b/docs/readthedocs/models/input/participant/thermalhouse.md new file mode 100644 index 000000000..15e5fd54c --- /dev/null +++ b/docs/readthedocs/models/input/participant/thermalhouse.md @@ -0,0 +1,65 @@ +(thermal-house-model)= + +# Thermal House Model + +Model for the thermal behaviour of a building. +This reflects a simple shoe box with transmission losses + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - bus + - -- + - Thermal bus, the model is connected to + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - ethLosses + - kW / K + - Thermal losses + + * - ethCapa + - kWh / K + - Thermal capacity + + * - targetTemperature + - °C + - Desired target temperature + + * - upperTemperatureLimit + - °C + - Upper temperature boundary + + * - lowerTemperatureLimit + - °C + - Lower temperature boundary + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/thermalhouse.rst b/docs/readthedocs/models/input/participant/thermalhouse.rst deleted file mode 100644 index c5ff9b947..000000000 --- a/docs/readthedocs/models/input/participant/thermalhouse.rst +++ /dev/null @@ -1,35 +0,0 @@ -.. _thermal_house_model: - -Thermal House Model -------------------- -Model for the thermal behaviour of a building. -This reflects a simple shoe box with transmission losses - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+-----------------------+---------+---------------------------------+ -| Attribute | Unit | Remarks | -+=======================+=========+=================================+ -| uuid | -- | | -+-----------------------+---------+---------------------------------+ -| id | -- | Human readable identifier | -+-----------------------+---------+---------------------------------+ -| operator | -- | | -+-----------------------+---------+---------------------------------+ -| operationTime | -- | Timely restriction of operation | -+-----------------------+---------+---------------------------------+ -| ethLosses | kW / K | Thermal losses | -+-----------------------+---------+---------------------------------+ -| ethCapa | kWh / K | Thermal capacity | -+-----------------------+---------+---------------------------------+ -| targetTemperature | °C | Desired target temperature | -+-----------------------+---------+---------------------------------+ -| upperTemperatureLimit | °C | Upper temperature boundary | -+-----------------------+---------+---------------------------------+ -| lowerTemperatureLimit | °C | Lower temperature boundary | -+-----------------------+---------+---------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/input/participant/wec.md b/docs/readthedocs/models/input/participant/wec.md new file mode 100644 index 000000000..862cbbdcd --- /dev/null +++ b/docs/readthedocs/models/input/participant/wec.md @@ -0,0 +1,127 @@ +(wec-model)= + +# Wind Energy Converter + +Model of a wind energy converter. + +## Attributes, Units and Remarks + +### Type Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - capex + - € + - Capital expenditure to purchase one entity of this type + + * - opex + - € / MWh + - | Operational expenditure to operate one entity of + | this type + + * - sRated + - kVA + - Rated apparent power + + * - cosPhiRated + - -- + - Rated power factor + + * - cpCharacteristic + - -- + - Wind velocity dependent :ref:`Betz factors`. + + * - etaConv + - % + - Efficiency of the assets inverter + + * - rotorArea + - m² + - Area the rotor covers + + * - hubHeight + - m + - Height of the rotor hub + +``` + +### Entity Model + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - + + * - id + - -- + - Human readable identifier + + * - operator + - -- + - + + * - operationTime + - -- + - Timely restriction of operation + + * - node + - -- + - + + * - qCharacteristics + - -- + - :ref:`Reactive power characteristic` to follow + + * - type + - -- + - + + * - marketReaction + - -- + - | Whether to adapt output based on (volatile) + | market price or not + + * - em + - -- + - | UUID reference to an :ref:`Energy Management Unit` that is controlling + | this system participant. Field can be empty or missing, if this participant + | is not controlled. + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! + +(wec-cp-characteristic)= + +## Betz Characteristic + +A collection of wind velocity to Betz factor pairs to be applied in +[Betz's law](https://en.wikipedia.org/wiki/Betz's_law) to determine the wind energy coming onto the rotor area. diff --git a/docs/readthedocs/models/input/participant/wec.rst b/docs/readthedocs/models/input/participant/wec.rst deleted file mode 100644 index d0769d92e..000000000 --- a/docs/readthedocs/models/input/participant/wec.rst +++ /dev/null @@ -1,72 +0,0 @@ -.. _wec_model: - -Wind Energy Converter ---------------------- -Model of a wind energy converter. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Type Model -"""""""""" - -+------------------+---------+----------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================+ -| uuid | -- | | -+------------------+---------+----------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+----------------------------------------------------------------------+ -| capex | € | Capital expenditure to purchase one entity of this type | -+------------------+---------+----------------------------------------------------------------------+ -| opex | € / MWh | | Operational expenditure to operate one entity of | -| | | | this type | -+------------------+---------+----------------------------------------------------------------------+ -| sRated | kVA | Rated apparent power | -+------------------+---------+----------------------------------------------------------------------+ -| cosphiRated | -- | Rated power factor | -+------------------+---------+----------------------------------------------------------------------+ -| cpCharacteristic | -- | Wind velocity dependent :ref:`Betz factors`. | -+------------------+---------+----------------------------------------------------------------------+ -| etaConv | % | Efficiency of the assets inverter | -+------------------+---------+----------------------------------------------------------------------+ -| rotorArea | m² | Area the rotor covers | -+------------------+---------+----------------------------------------------------------------------+ -| hubHeight | m | Height of the rotor hub | -+------------------+---------+----------------------------------------------------------------------+ - -Entity Model -"""""""""""" - -+------------------+---------+--------------------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+==================+=========+======================================================================================+ -| uuid | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| id | -- | Human readable identifier | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operator | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| operationTime | -- | Timely restriction of operation | -+------------------+---------+--------------------------------------------------------------------------------------+ -| node | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| qCharacteristics | -- | :ref:`Reactive power characteristic` to follow | -+------------------+---------+--------------------------------------------------------------------------------------+ -| type | -- | | -+------------------+---------+--------------------------------------------------------------------------------------+ -| marketReaction | -- | | Whether to adapt output based on (volatile) | -| | | | market price or not | -+------------------+---------+--------------------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! - -.. _wec_cp_characteristic: - -Betz Characteristic -^^^^^^^^^^^^^^^^^^^ -A collection of wind velocity to Betz factor pairs to be applied in -`Betz's law `_ to determine the wind energy coming onto the rotor area. diff --git a/docs/readthedocs/models/models.md b/docs/readthedocs/models/models.md index c0e70ab78..dbb2b1ab8 100644 --- a/docs/readthedocs/models/models.md +++ b/docs/readthedocs/models/models.md @@ -18,22 +18,26 @@ We designed the models in a way, that does not allow for adaptions of the repres objects. Thereby you can be sure, that your models are *thread-safe* and no unwanted or unobserved changes are made. -**Copyable**
+**Clonability**
With the general design principle of immutability, entity modifications (e.g. updates of field values) can become hard and annoying. To avoid generating methods to update each field value, we provide an adapted version of the [Builder pattern](https://en.wikipedia.org/wiki/Builder_pattern/) to make entity modifications as easy as possible. -Each entity holds it's own copy builder class, which follows the same inheritance as the entity class itself. With a -call of `.copy()` on an entity instance a builder instance is returned, that allows for modification of fields and -can be terminated with `.build()` which will return an instance of the entity with modified field values as required. -For the moment, this pattern is only implemented for a small amount of `AssetInput` entities (all entities held by a -`GridContainer` except thermal units to be precise), but we plan to extend this capability to all input entities in the -future. +Each entity holds its own copy builder class, which follows the same inheritance as the entity class itself. With a +call of `.copy()` on an entity instance a builder instance is returned, which allows for modification of fields and +can be terminated with `.build()`. This will return an instance of the entity with modified field values as indicated. +For the moment, this pattern is only implemented for a limited set of entities, but we plan to extend this capability +to all input entities in the future. + +**Scaling entity properties**
+Using the copy builders (as described above) we provide a convenience method that helps with scaling system +participants and respective type inputs. Scaling entities tries to preserve proportions that are related to power. +This means that capacity, consumption etc. are scaled with the same factor as power. **Single Point of Truth**
Throughout all models you can be sure, that no information is given twice, reducing the possibility to have ambiguous information in your simulation set up. "Missing" information can be received through the grids relational information - e.g. if you intend to model a wind -energy converter in detail, you may find information of it's geographical location in the model of it's common +energy converter in detail, you may find information of its geographical location in the model of its common coupling point ([node](/models/input/grid/node)). **Harmonized Units System**
@@ -135,6 +139,7 @@ input/participant/wec input/participant/thermalbus input/participant/thermalhouse input/participant/cylindricalstorage +input/participant/em ``` ### Additional Data diff --git a/docs/readthedocs/models/result/grid/connector.md b/docs/readthedocs/models/result/grid/connector.md new file mode 100644 index 000000000..6417c5a14 --- /dev/null +++ b/docs/readthedocs/models/result/grid/connector.md @@ -0,0 +1,51 @@ +(connector-result)= + +# Connector + +Representation of all kinds of connectors. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - iAMag + - ampere + - A stands for sending node + + * - iAAng + - degree + - + + * - iBMag + - ampere + - B stands for receiving node + + * - iBAng + - degree + - + +``` + +## Caveats + +Groups all available connectors i.e. lines, switches and transformers diff --git a/docs/readthedocs/models/result/grid/connector.rst b/docs/readthedocs/models/result/grid/connector.rst deleted file mode 100644 index c3749eef6..000000000 --- a/docs/readthedocs/models/result/grid/connector.rst +++ /dev/null @@ -1,30 +0,0 @@ -.. _connector_result: - -Connector ---------- -Representation of all kinds of connectors. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| iAMag | ampere | A stands for sending node | -+---------------+----------------+----------------------------------------------------------+ -| iAAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iBMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iBAng | degree | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Groups all available connectors i.e. lines, switches and transformers diff --git a/docs/readthedocs/models/result/grid/line.md b/docs/readthedocs/models/result/grid/line.md new file mode 100644 index 000000000..21efaa9d6 --- /dev/null +++ b/docs/readthedocs/models/result/grid/line.md @@ -0,0 +1,52 @@ +(line-result)= + +# Line + +Representation of an AC line. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - iAMag + - ampere + - A stands for sending node + + * - iAAng + - degree + - + + * - iBMag + - ampere + - B stands for receiving node + + * - iBAng + - degree + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/line.rst b/docs/readthedocs/models/result/grid/line.rst deleted file mode 100644 index bea516141..000000000 --- a/docs/readthedocs/models/result/grid/line.rst +++ /dev/null @@ -1,31 +0,0 @@ -.. _line_result: - -Line ----- -Representation of an AC line. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| iAMag | ampere | A stands for sending node | -+---------------+----------------+----------------------------------------------------------+ -| iAAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iBMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iBAng | degree | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/node.md b/docs/readthedocs/models/result/grid/node.md new file mode 100644 index 000000000..0e7049baf --- /dev/null +++ b/docs/readthedocs/models/result/grid/node.md @@ -0,0 +1,44 @@ +(node-result)= + +# Node + +Representation of an electrical node, with no further distinction into bus bar, auxiliary node or others. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - vMag + - p.u. + - + + * - vAng + - degree + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/node.rst b/docs/readthedocs/models/result/grid/node.rst deleted file mode 100644 index 26129af2f..000000000 --- a/docs/readthedocs/models/result/grid/node.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _node_result: - -Node ----- -Representation of an electrical node, with no further distinction into bus bar, auxiliary node or others. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| vMag | p.u. | | -+---------------+----------------+----------------------------------------------------------+ -| vAng | degree | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/switch.md b/docs/readthedocs/models/result/grid/switch.md new file mode 100644 index 000000000..c17342691 --- /dev/null +++ b/docs/readthedocs/models/result/grid/switch.md @@ -0,0 +1,40 @@ +(switch-result)= + +# Switch + +Representation of electrical switches. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - closed + - boolean + - status of the switching device + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/switch.rst b/docs/readthedocs/models/result/grid/switch.rst deleted file mode 100644 index aa11cda90..000000000 --- a/docs/readthedocs/models/result/grid/switch.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. _switch_result: - -Switch ------- -Representation of electrical switches. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| closed | boolean | status of the switching device | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/grid/transformer.md b/docs/readthedocs/models/result/grid/transformer.md new file mode 100644 index 000000000..c75bfa2f6 --- /dev/null +++ b/docs/readthedocs/models/result/grid/transformer.md @@ -0,0 +1,55 @@ +(transformer-result)= + +# Transformer + +Representation of transformers. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - iAMag + - ampere + - A stands for sending node + + * - iAAng + - degree + - + + * - iBMag + - ampere + - B stands for receiving node + + * - iBAng + - degree + - + + * - tapPos + - -- + - + +``` + +## Caveats + +Groups common information to both 2W and 3W transformers. diff --git a/docs/readthedocs/models/result/grid/transformer.rst b/docs/readthedocs/models/result/grid/transformer.rst deleted file mode 100644 index 5246368bf..000000000 --- a/docs/readthedocs/models/result/grid/transformer.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. _transformer_result: - -Transformer ------------ -Representation of transformers. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| iAMag | ampere | A stands for sending node | -+---------------+----------------+----------------------------------------------------------+ -| iAAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iBMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iBAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| tapPos | -- | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Groups common information to both 2W and 3W transformers. diff --git a/docs/readthedocs/models/result/grid/transformer2w.md b/docs/readthedocs/models/result/grid/transformer2w.md new file mode 100644 index 000000000..58201162c --- /dev/null +++ b/docs/readthedocs/models/result/grid/transformer2w.md @@ -0,0 +1,55 @@ +(transformer2w-result)= + +# Two Winding Transformer + +Representation of two winding transformers. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - iAMag + - ampere + - A stands for sending node + + * - iAAng + - degree + - + + * - iBMag + - ampere + - B stands for receiving node + + * - iBAng + - degree + - + + * - tapPos + - -- + - + +``` + +## Caveats + +Assumption: Node A is the node at higher voltage. diff --git a/docs/readthedocs/models/result/grid/transformer2w.rst b/docs/readthedocs/models/result/grid/transformer2w.rst deleted file mode 100644 index 772a5efc6..000000000 --- a/docs/readthedocs/models/result/grid/transformer2w.rst +++ /dev/null @@ -1,32 +0,0 @@ -.. _transformer2W_result: - -Two Winding Transformer ------------------------ -Representation of two winding transformers. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| iAMag | ampere | A stands for sending node | -+---------------+----------------+----------------------------------------------------------+ -| iAAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iBMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iBAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| tapPos | -- | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Assumption: Node A is the node at higher voltage. diff --git a/docs/readthedocs/models/result/grid/transformer3w.md b/docs/readthedocs/models/result/grid/transformer3w.md new file mode 100644 index 000000000..917bc59e7 --- /dev/null +++ b/docs/readthedocs/models/result/grid/transformer3w.md @@ -0,0 +1,64 @@ +(transformer3w-result)= + +# Three Winding Transformer + +Representation of three winding transformers. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - ZonedDateTime + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - iAMag + - ampere + - A stands for sending node + + * - iAAng + - degree + - + + * - iBMag + - ampere + - B stands for receiving node + + * - iBAng + - degree + - + + * - iCMag + - ampere + - B stands for receiving node + + * - iCAng + - degree + - + + * - tapPos + - -- + - + +``` + +## Caveats + +Assumption: Node A is the node at highest voltage and Node B is at intermediate voltage. +For model specifications please check corresponding input model documentation. diff --git a/docs/readthedocs/models/result/grid/transformer3w.rst b/docs/readthedocs/models/result/grid/transformer3w.rst deleted file mode 100644 index e218042a9..000000000 --- a/docs/readthedocs/models/result/grid/transformer3w.rst +++ /dev/null @@ -1,37 +0,0 @@ -.. _transformer3W_result: - -Three Winding Transformer -------------------------- -Representation of three winding transformers. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+----------------+----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+================+==========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+----------------+----------------------------------------------------------+ -| time | ZonedDateTime | date and time for the produced result | -+---------------+----------------+----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+----------------+----------------------------------------------------------+ -| iAMag | ampere | A stands for sending node | -+---------------+----------------+----------------------------------------------------------+ -| iAAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iBMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iBAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| iCMag | ampere | B stands for receiving node | -+---------------+----------------+----------------------------------------------------------+ -| iCAng | degree | | -+---------------+----------------+----------------------------------------------------------+ -| tapPos | -- | | -+---------------+----------------+----------------------------------------------------------+ - -Caveats -^^^^^^^ -Assumption: Node A is the node at highest voltage and Node B is at intermediate voltage. -For model specifications please check corresponding input model documentation. diff --git a/docs/readthedocs/models/result/participant/bm.md b/docs/readthedocs/models/result/participant/bm.md new file mode 100644 index 000000000..39d9554f0 --- /dev/null +++ b/docs/readthedocs/models/result/participant/bm.md @@ -0,0 +1,44 @@ +(bm-result)= + +# Biomass plant + +Result of a biomass power plant. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/bm.rst b/docs/readthedocs/models/result/participant/bm.rst deleted file mode 100644 index 7460fda46..000000000 --- a/docs/readthedocs/models/result/participant/bm.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _bm_result: - -Biomass plant -------------- -Result of a biomass power plant. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/chp.md b/docs/readthedocs/models/result/participant/chp.md new file mode 100644 index 000000000..1f3dba2a5 --- /dev/null +++ b/docs/readthedocs/models/result/participant/chp.md @@ -0,0 +1,48 @@ +(chp-result)= + +# Combined Heat and Power Plant + +Result of a combined heat and power plant. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + + * - qDot + - MW + - Thermal power + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/chp.rst b/docs/readthedocs/models/result/participant/chp.rst deleted file mode 100644 index 2c4f76898..000000000 --- a/docs/readthedocs/models/result/participant/chp.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _chp_result: - -Combined Heat and Power Plant ------------------------------ -Result of a combined heat and power plant. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ -| qDot | MW | Thermal power | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/cylindricalstorage.md b/docs/readthedocs/models/result/participant/cylindricalstorage.md new file mode 100644 index 000000000..c028628c2 --- /dev/null +++ b/docs/readthedocs/models/result/participant/cylindricalstorage.md @@ -0,0 +1,48 @@ +(cylindricalstorage-result)= + +# Cylindrical Thermal Storage + +Result of a cylindrical thermal storage using a fluent to store thermal energy. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - energy + - MWh + - + + * - qDot + - MW + - heat demand of the sink + + * - fillLevel + - -- + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/cylindricalstorage.rst b/docs/readthedocs/models/result/participant/cylindricalstorage.rst deleted file mode 100644 index 4b4dff95a..000000000 --- a/docs/readthedocs/models/result/participant/cylindricalstorage.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _cylindricalstorage_result: - -Cylindrical Thermal Storage ---------------------------- -Result of a cylindrical thermal storage using a fluent to store thermal energy. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+===========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+-----------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+-----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+-----------------------------------------------------------+ -| energy | MWh | | -+---------------+---------+-----------------------------------------------------------+ -| qDot | MW | heat demand of the sink | -+---------------+---------+-----------------------------------------------------------+ -| fillLevel | -- | | -+---------------+---------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/em.md b/docs/readthedocs/models/result/participant/em.md new file mode 100644 index 000000000..7cc9977e3 --- /dev/null +++ b/docs/readthedocs/models/result/participant/em.md @@ -0,0 +1,45 @@ +(em-result)= + +# Energy Management + +Result of an energy management entity. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - active power output + + * - q + - MW + - reactive power output + + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/em.rst b/docs/readthedocs/models/result/participant/em.rst deleted file mode 100644 index 90f47b1cb..000000000 --- a/docs/readthedocs/models/result/participant/em.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _em_result: - -Energy Management ------------------ -Result of an energy management entity. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+----------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+============================================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+----------------------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+----------------------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+----------------------------------------------------------------------------+ -| p | MW | active power output | -+---------------+---------+----------------------------------------------------------------------------+ -| q | MW | reactive power output | -+---------------+---------+----------------------------------------------------------------------------+ - - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! - diff --git a/docs/readthedocs/models/result/participant/ev.md b/docs/readthedocs/models/result/participant/ev.md new file mode 100644 index 000000000..05ba1e447 --- /dev/null +++ b/docs/readthedocs/models/result/participant/ev.md @@ -0,0 +1,48 @@ +(ev-result)= + +# Electric Vehicle + +Result of an electric vehicle, that is occasionally connected to the grid via an [electric vehicle charging system](evcs.md#electric-vehicle-charging-station). + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + + * - soc + - % + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/ev.rst b/docs/readthedocs/models/result/participant/ev.rst deleted file mode 100644 index f164588d1..000000000 --- a/docs/readthedocs/models/result/participant/ev.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _ev_result: - -Electric Vehicle ----------------- -Result of an electric vehicle, that is occasionally connected to the grid via an :ref:`electric vehicle charging station`. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ -| soc | % | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/evcs.md b/docs/readthedocs/models/result/participant/evcs.md new file mode 100644 index 000000000..48af32b5a --- /dev/null +++ b/docs/readthedocs/models/result/participant/evcs.md @@ -0,0 +1,44 @@ +(evcs-result)= + +# Electric Vehicle Charging Station + +This model is currently only a dummy implementation of an electric vehicle charging station. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/evcs.rst b/docs/readthedocs/models/result/participant/evcs.rst deleted file mode 100644 index 6e5a22136..000000000 --- a/docs/readthedocs/models/result/participant/evcs.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _evcs_result: - -Electric Vehicle Charging Station ---------------------------------- -This model is currently only a dummy implementation of an electric vehicle charging station. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! \ No newline at end of file diff --git a/docs/readthedocs/models/result/participant/fixedfeedin.md b/docs/readthedocs/models/result/participant/fixedfeedin.md new file mode 100644 index 000000000..9cf5f64de --- /dev/null +++ b/docs/readthedocs/models/result/participant/fixedfeedin.md @@ -0,0 +1,45 @@ +(fixed-feed-in-result)= + +# Fixed Feed In Facility + +Result of a facility, that provides constant power feed in, as no further information about the actual behaviour of the +model can be derived. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/fixedfeedin.rst b/docs/readthedocs/models/result/participant/fixedfeedin.rst deleted file mode 100644 index baabec0e0..000000000 --- a/docs/readthedocs/models/result/participant/fixedfeedin.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. _fixed_feed_in_result: - -Fixed Feed In Facility ----------------------- -Result of a facility, that provides constant power feed in, as no further information about the actual behaviour of the -model can be derived. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/flexoption.md b/docs/readthedocs/models/result/participant/flexoption.md new file mode 100644 index 000000000..34039e082 --- /dev/null +++ b/docs/readthedocs/models/result/participant/flexoption.md @@ -0,0 +1,48 @@ +(flexoption-result)= + +# Flexibility Option + +Result of a flexibility option. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - pRef + - MW + - active power that was suggested for regular usage by the system participant + + * - pMin + - MW + - active minimal power that was determined by the system participant + + * - pMax + - MW + - active maximum power that was determined by the system participant + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/flexoption.rst b/docs/readthedocs/models/result/participant/flexoption.rst deleted file mode 100644 index e2abe9547..000000000 --- a/docs/readthedocs/models/result/participant/flexoption.rst +++ /dev/null @@ -1,30 +0,0 @@ -.. _flexoption_result: - -Flexibility Option ------------------- -Result of a flexibility option. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+----------------------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+============================================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+----------------------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+----------------------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+----------------------------------------------------------------------------+ -| pRef | MW | active power that was suggested for regular usage by the system participant| -+---------------+---------+----------------------------------------------------------------------------+ -| pMin | MW | active minimal power that was determined by the system participant | -+---------------+---------+----------------------------------------------------------------------------+ -| pMax | MW | active maximum power that was determined by the system participant | -+---------------+---------+----------------------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! - diff --git a/docs/readthedocs/models/result/participant/hp.md b/docs/readthedocs/models/result/participant/hp.md new file mode 100644 index 000000000..437dde0cb --- /dev/null +++ b/docs/readthedocs/models/result/participant/hp.md @@ -0,0 +1,48 @@ +(hp-result)= + +# Heat Pump + +Result of a heat pump. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + + * - qDot + - MW + - Thermal power + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/hp.rst b/docs/readthedocs/models/result/participant/hp.rst deleted file mode 100644 index 5c51b59c4..000000000 --- a/docs/readthedocs/models/result/participant/hp.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _hp_result: - -Heat Pump ---------- -Result of a heat pump. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ -| qDot | MW | Thermal power | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! \ No newline at end of file diff --git a/docs/readthedocs/models/result/participant/load.md b/docs/readthedocs/models/result/participant/load.md new file mode 100644 index 000000000..8e0f40912 --- /dev/null +++ b/docs/readthedocs/models/result/participant/load.md @@ -0,0 +1,44 @@ +(load-result)= + +# Load + +Result of (mainly) domestic loads. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/load.rst b/docs/readthedocs/models/result/participant/load.rst deleted file mode 100644 index 62b275d70..000000000 --- a/docs/readthedocs/models/result/participant/load.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _load_result: - -Load ----- -Result of (mainly) domestic loads. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! \ No newline at end of file diff --git a/docs/readthedocs/models/result/participant/pv.md b/docs/readthedocs/models/result/participant/pv.md new file mode 100644 index 000000000..38df0239d --- /dev/null +++ b/docs/readthedocs/models/result/participant/pv.md @@ -0,0 +1,44 @@ +(pv-result)= + +# Photovoltaic Power Plant + +Result of a photovoltaic power plant. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/pv.rst b/docs/readthedocs/models/result/participant/pv.rst deleted file mode 100644 index e7e3b8d75..000000000 --- a/docs/readthedocs/models/result/participant/pv.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _pv_result: - -Photovoltaic Power Plant ------------------------- -Result of a photovoltaic power plant. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/storage.md b/docs/readthedocs/models/result/participant/storage.md new file mode 100644 index 000000000..cb2d8ded0 --- /dev/null +++ b/docs/readthedocs/models/result/participant/storage.md @@ -0,0 +1,48 @@ +(storage-result)= + +# Electrical Energy Storage + +Result of an electrochemical storage + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + + * - soc + - -- + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/storage.rst b/docs/readthedocs/models/result/participant/storage.rst deleted file mode 100644 index 486535f83..000000000 --- a/docs/readthedocs/models/result/participant/storage.rst +++ /dev/null @@ -1,29 +0,0 @@ -.. _storage_result: - -Electrical Energy Storage -------------------------- -Result of an electrochemical storage - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ -| soc | -- | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/systemparticipant.md b/docs/readthedocs/models/result/participant/systemparticipant.md new file mode 100644 index 000000000..54dabb959 --- /dev/null +++ b/docs/readthedocs/models/result/participant/systemparticipant.md @@ -0,0 +1,45 @@ +(system-participant-result)= + +# System Participant + +Groups together all system participants such as PV, Storage etc. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/systemparticipant.rst b/docs/readthedocs/models/result/participant/systemparticipant.rst deleted file mode 100644 index 3393ba87b..000000000 --- a/docs/readthedocs/models/result/participant/systemparticipant.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. _system_participant_result: - -System Participant ------------------- -Groups together all system participants such as PV, Storage etc. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalhouse.md b/docs/readthedocs/models/result/participant/thermalhouse.md new file mode 100644 index 000000000..af594039c --- /dev/null +++ b/docs/readthedocs/models/result/participant/thermalhouse.md @@ -0,0 +1,45 @@ +(thermal-house-result)= + +# Thermal House + +Model for the thermal behaviour of a building. +This reflects a simple shoe box with transmission losses + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - qDot + - MW + - thermal heat demand of the sink + + * - indoorTemperature + - °C + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalhouse.rst b/docs/readthedocs/models/result/participant/thermalhouse.rst deleted file mode 100644 index 194302251..000000000 --- a/docs/readthedocs/models/result/participant/thermalhouse.rst +++ /dev/null @@ -1,28 +0,0 @@ -.. _thermal_house_result: - -Thermal House -------------- -Model for the thermal behaviour of a building. -This reflects a simple shoe box with transmission losses - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+-------------------+---------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===================+=========+===========================================================+ -| uuid | -- | uuid for the result entity | -+-------------------+---------+-----------------------------------------------------------+ -| time | -- | date and time for the produced result | -+-------------------+---------+-----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+-------------------+---------+-----------------------------------------------------------+ -| qDot | MW | thermal heat demand of the sink | -+-------------------+---------+-----------------------------------------------------------+ -| indoorTemperature | °C | | -+-------------------+---------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalsink.md b/docs/readthedocs/models/result/participant/thermalsink.md new file mode 100644 index 000000000..26ae65631 --- /dev/null +++ b/docs/readthedocs/models/result/participant/thermalsink.md @@ -0,0 +1,40 @@ +(thermal-sink-result)= + +# Thermal Sink + +Result of a thermal sink. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - qDot + - MW + - thermal heat demand + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalsink.rst b/docs/readthedocs/models/result/participant/thermalsink.rst deleted file mode 100644 index f761eea14..000000000 --- a/docs/readthedocs/models/result/participant/thermalsink.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. _thermal_sink_result: - -Thermal Sink ------------- -Result of a thermal sink. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+===========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+-----------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+-----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+-----------------------------------------------------------+ -| qDot | MW | thermal heat demand | -+---------------+---------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalstorage.md b/docs/readthedocs/models/result/participant/thermalstorage.md new file mode 100644 index 000000000..1ec9958e7 --- /dev/null +++ b/docs/readthedocs/models/result/participant/thermalstorage.md @@ -0,0 +1,44 @@ +(thermal-storage-result)= + +# Thermal Storage + +Result of a thermal storage. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - energy + - MWh + - + + * - qDot + - MW + - heat flowing in + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalstorage.rst b/docs/readthedocs/models/result/participant/thermalstorage.rst deleted file mode 100644 index b64a285a2..000000000 --- a/docs/readthedocs/models/result/participant/thermalstorage.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _thermal_storage_result: - -Thermal Storage ---------------- -Result of a thermal storage. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+===========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+-----------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+-----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+-----------------------------------------------------------+ -| energy | MWh | | -+---------------+---------+-----------------------------------------------------------+ -| qDot | MW | heat flowing in | -+---------------+---------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalunit.md b/docs/readthedocs/models/result/participant/thermalunit.md new file mode 100644 index 000000000..624aeb38b --- /dev/null +++ b/docs/readthedocs/models/result/participant/thermalunit.md @@ -0,0 +1,40 @@ +(thermal-unit-result)= + +# Thermal Unit + +Result of a thermal unit. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - qDot + - MW + - thermal power exchanged + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/thermalunit.rst b/docs/readthedocs/models/result/participant/thermalunit.rst deleted file mode 100644 index 0d33cdd9d..000000000 --- a/docs/readthedocs/models/result/participant/thermalunit.rst +++ /dev/null @@ -1,25 +0,0 @@ -.. _thermal_unit_result: - -Thermal Unit ------------- -Result of a thermal unit. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+-----------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+===========================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+-----------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+-----------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+-----------------------------------------------------------+ -| qDot | MW | thermal power exchanged | -+---------------+---------+-----------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/wec.md b/docs/readthedocs/models/result/participant/wec.md new file mode 100644 index 000000000..cc04169b7 --- /dev/null +++ b/docs/readthedocs/models/result/participant/wec.md @@ -0,0 +1,44 @@ +(wec-result)= + +# Wind Energy Converter + +Result of a wind turbine. + +## Attributes, Units and Remarks + +```{eval-rst} +.. list-table:: + :widths: 33 33 33 + :header-rows: 0 + + + * - Attribute + - Unit + - Remarks + + * - uuid + - -- + - uuid for the result entity + + * - time + - -- + - date and time for the produced result + + * - inputModel + - -- + - uuid for the associated input model + + * - p + - MW + - + + * - q + - MVAr + - + +``` + +## Caveats + +Nothing - at least not known. +If you found something, please contact us! diff --git a/docs/readthedocs/models/result/participant/wec.rst b/docs/readthedocs/models/result/participant/wec.rst deleted file mode 100644 index 9e56a9b85..000000000 --- a/docs/readthedocs/models/result/participant/wec.rst +++ /dev/null @@ -1,27 +0,0 @@ -.. _wec_result: - -Wind Energy Converter ---------------------- -Result of a wind turbine. - -Attributes, Units and Remarks -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+---------------+---------+--------------------------------------------------------------+ -| Attribute | Unit | Remarks | -+===============+=========+==============================================================+ -| uuid | -- | uuid for the result entity | -+---------------+---------+--------------------------------------------------------------+ -| time | -- | date and time for the produced result | -+---------------+---------+--------------------------------------------------------------+ -| inputModel | -- | uuid for the associated input model | -+---------------+---------+--------------------------------------------------------------+ -| p | MW | | -+---------------+---------+--------------------------------------------------------------+ -| q | MVAr | | -+---------------+---------+--------------------------------------------------------------+ - -Caveats -^^^^^^^ -Nothing - at least not known. -If you found something, please contact us! \ No newline at end of file diff --git a/docs/readthedocs/requirements.txt b/docs/readthedocs/requirements.txt index 6e3fa7773..cb581e840 100644 --- a/docs/readthedocs/requirements.txt +++ b/docs/readthedocs/requirements.txt @@ -1,6 +1,6 @@ commonmark==0.9.1 recommonmark==0.7.1 Sphinx==7.2.6 -sphinx-rtd-theme==1.3.0 +sphinx-rtd-theme==2.0.0 myst-parser==2.0.0 markdown-it-py==3.0.0 diff --git a/docs/uml/main/EntitySourceClassDiagram.puml b/docs/uml/main/EntitySourceClassDiagram.puml index a160bc739..56ac69c40 100644 --- a/docs/uml/main/EntitySourceClassDiagram.puml +++ b/docs/uml/main/EntitySourceClassDiagram.puml @@ -3,12 +3,21 @@ note "Assuming all classes to implement \nthe abstract methods of their interfaces\n\n" as generalNotes abstract class EntitySource { - - DataSource dataSource - - Set buildNodeAssetEntities(Class, EntityFactory, Collection, Collection, ConcurrentMap, LongAdder>) - - Set buildNodeAssetEntities(Class, EntityFactory, Collection, Collection) - - Set buildAssetInputEntities(Class, EntityFactory, Collection) - - Set buildAssetInputEntities(Class, EntityFactory) + # DataSource dataSource + # {static} Try enrichEntityData(E, String, Map, BiFunction) + # {static} Try enrichEntityData(E, String, Map, String, Map, TriFunction) + # {static} Try getLinkedEntity(EntityData, String, Map) + # {static} Try optionallyEnrichEntityData(E, String, Map, T, BiFunction) + # Stream> buildNodeAssetEntities(Class, Map, Map) + # {static} Stream> nodeAssetInputEntityDataStream(Stream>, Map) + # Stream> buildAssetInputEntities(Class, Map) + # {static} Stream> assetInputEntityDataStream(Stream>, Map) + # Stream> buildEntityData(Class) + # {static} Map unpackMap(Stream>, Class) throws SourceException + # {static} Set unpackSet(Stream>, Class) throws SourceException + # {static} Stream unpackSet(Stream>, Class) throws SourceException } + EntitySource <|-- GraphicSource EntitySource <|-- RawGridSource EntitySource <|-- ResultEntitySource @@ -21,12 +30,13 @@ class GraphicSource { - RawGridSource rawGridSource - LineGraphicInputFactory lineGraphicInputFactory - NodeGraphicInputFactory nodeGraphicInputFactory - - GraphicSource(TypeSource, RawGridSource, DataSource) - - Optional getGraphicElements() - - Set getNodeGraphicInput() - - Set getNodeGraphicInput(Set) - - Set getLineGraphicInput() - - Set getLineGraphicInput(Set) + + GraphicSource(TypeSource, RawGridSource, DataSource) + + GraphicElements getGraphicElements() throws SourceException + + GraphicElements getGraphicElements(Map, Map) throws SourceException + + Set getNodeGraphicInput() throws SourceException + + Set getNodeGraphicInput(Map) throws SourceException + + Set getLineGraphicInput() throws SourceException + + Set getLineGraphicInput(Map) throws SourceException } class RawGridSource { @@ -37,19 +47,21 @@ class RawGridSource { - Transformer3WInputFactory transformer3WInputFactory - SwitchInputFactory switchInputFactory - MeasurementUnitInputFactory measurementUnitInputFactory - - Optional getGridData() - - Set getNodes() - - Set getNodes(Set) - - Set getLines() - - Set getLines(Set, Set, Set) - - Set get2WTransformers() - - Set get2WTransformers(Set, Set, Set) - - Set get3WTransformers() - - Set get3WTransformers(Set, Set, Set) - - Set getSwitches() - - Set getSwitches(Set, Set) - - Set getMeasurementUnits() - - Set getMeasurementUnits(Set, Set) + + RawGridSource(TypeSource typeSource, DataSource dataSource) + + RawGridElements getGridData() throws SourceException + + RawGridElements getGridData(Map, Map, Map) throws SourceException + + Map getNodes() throws SourceException + + Map getNodes(Map) throws SourceException + + Map getLines() throws SourceException + + Map getLines(Map, Map, Set) throws SourceException + + Set get2WTransformers() throws SourceException + + Set get2WTransformers(Map, Map, Set) throws SourceException + + Set get3WTransformers() throws SourceException + + Set get3WTransformers(Map, Map, Set) throws SourceException + + Set getSwitches() throws SourceException + + Set getSwitches(Map, Map) throws SourceException + + Set getMeasurementUnits() throws SourceException + + Set getMeasurementUnits(Map, Map) throws SourceException } class ResultEntitySource { @@ -59,27 +71,27 @@ class ResultEntitySource { - NodeResultFactory nodeResultFactory - ConnectorResultFactory connectorResultFactory - FlexOptionsResultFactory flexOptionsResultFactory - - ResultEntitySource(DataSource) - - ResultEntitySource(DataSource, String) - - Set getNodeResults() - - Set getSwitchResults() - - Set getLineResults() - - Set getTransformer2WResultResults() - - Set getTransformer3WResultResults() - - Set getFlexOptionsResults() - - Set getLoadResults() - - Set getPvResults() - - Set getFixedFeedInResults() - - Set getBmResults() - - Set getChpResults() - - Set getWecResults() - - Set getStorageResults() - - Set getEvcsResults() - - Set getEvResults() - - Set getHpResults() - - Set getCylindricalStorageResult() - - Set getThermalHouseResults() - - Set getEmResults() + + ResultEntitySource(DataSource) + + ResultEntitySource(DataSource, String) + + Set getNodeResults() throws SourceException + + Set getSwitchResults() throws SourceException + + Set getLineResults() throws SourceException + + Set getTransformer2WResultResults() throws SourceException + + Set getTransformer3WResultResults() throws SourceException + + Set getFlexOptionsResults() throws SourceException + + Set getLoadResults() throws SourceException + + Set getPvResults() throws SourceException + + Set getFixedFeedInResults() throws SourceException + + Set getBmResults() throws SourceException + + Set getChpResults() throws SourceException + + Set getWecResults() throws SourceException + + Set getStorageResults() throws SourceException + + Set getEvcsResults() throws SourceException + + Set getEvResults() throws SourceException + + Set getHpResults() throws SourceException + + Set getCylindricalStorageResult() throws SourceException + + Set getThermalHouseResults() throws SourceException + + Set getEmResults() throws SourceException } class SystemParticipantSource{ @@ -96,28 +108,29 @@ class SystemParticipantSource{ - StorageInputFactory storageInputFactory - WecInputFactory wecInputFactory - EvcsInputFactory evcsInputFactory - - SystemParticipantSource(TypeSource, ThermalSource, RawGridSource, DataSource) - - Optional getSystemParticipants() - - Set getBmPlants() - - Set getBmPlants(Set, Set, Set) - - Set getChpPlants() - - Set getChpPlants(Set, Set, Set, Set, Set) - - Set getEvs() - - Set getEvs(Set, Set, Set) - - Set getEvCS() - - Set getEvCS(Set, Set) - - Set getFixedFeedIns() - - Set getFixedFeedIns(Set, Set) - - Set getHeatPumps() - - Set getHeatPumps(Set, Set, Set, Set) - - Set getLoads() - - Set getLoads(Set, Set) - - Set getPvPlants() - - Set getPvPlants(Set, Set) - - Set getStorages() - - Set getStorages(Set, Set, Set) - - Set getWecPlants() - - Set getWecPlants(Set, Set, Set) + + SystemParticipantSource(TypeSource, ThermalSource, RawGridSource, DataSource) + + SystemParticipants getSystemParticipants() throws SourceException + + SystemParticipants getSystemParticipants(Map, Map) throws SourceException + + Set getBmPlants() throws SourceException + + Set getBmPlants(Map, Map, Set) throws SourceException + + Set getChpPlants() throws SourceException + + Set getChpPlants(Map, Map, Set, Map, Set) throws SourceException + + Set getEvs() throws SourceException + + Set getEvs(Map, Map, Set) throws SourceException + + Set getEvcs() throws SourceException + + Set getEvcs(Map, Map) throws SourceException + + Set getFixedFeedIns() throws SourceException + + Set getFixedFeedIns(Map, Map) throws SourceException + + Set getHeatPumps() throws SourceException + + Set getHeatPumps(Map, Map, Set, Map) throws SourceException + + Set getLoads() throws SourceException + + Set getLoads(Map, Map) throws SourceException + + Set getPvPlants() throws SourceException + + Set getPvPlants(Map, Map) throws SourceException + + Set getStorages() throws SourceException + + Set getStorages(Map, Map, Set) throws SourceException + + Set getWecPlants() throws SourceException + + Set getWecPlants(Map, Map, Set) throws SourceException } class ThermalSource { @@ -125,15 +138,15 @@ class ThermalSource { - ThermalBusInputFactory thermalBusInputFactory - CylindricalStorageInputFactory cylindricalStorageInputFactory - ThermalHouseInputFactory thermalHouseInputFactory - - ThermalSource(TypeSource, DataSource) - - Set getThermalBuses() - - Set getThermalBuses(Set) - - Set getThermalStorages() - - Set getThermalStorages(Set, Set) - - Set getThermalHouses() - - Set getThermalHouses(Set, Set) - - Set getCylindricStorages() - - Set getCylindricStorages(Set, Set) + + ThermalSource(TypeSource, DataSource) + + Map getThermalBuses() throws SourceException + + Map getThermalBuses(Map) throws SourceException + + Set getThermalStorages() throws SourceException + + Set getThermalStorages(Map, Map) throws SourceException + + Set getThermalHouses() throws SourceException + + Set getThermalHouses(Map, Map) throws SourceException + + Set getCylindricStorages() throws SourceException + + Set getCylindricStorages(Map, Map) throws SourceException } class TypeSource { @@ -142,16 +155,16 @@ class TypeSource { - LineTypeInputFactory lineTypeInputFactory - Transformer3WTypeInputFactory transformer3WTypeInputFactory - SystemParticipantTypeInputFactory systemParticipantTypeInputFactory - - TypeSource(DataSource) - - Set getTransformer2WTypes() - - Set getTransformer3WTypes() - - Set getOperators() - - Set getLineTypes() - - Set getBmTypes() - - Set getChpTypes() - - Set getHpTypes() - - Set getStorageTypes() - - Set getWecTypes() - - Set getEvTypes() + + TypeSource(DataSource) + + Map getTransformer2WTypes() throws SourceException + + Map getTransformer3WTypes() throws SourceException + + Map getOperators() throws SourceException + + Map getLineTypes() throws SourceException + + Map getBmTypes() throws SourceException + + Map getChpTypes() throws SourceException + + Map getHpTypes() throws SourceException + + Map getStorageTypes() throws SourceException + + Map getWecTypes() throws SourceException + + Map getEvTypes() throws SourceException } @enduml \ No newline at end of file diff --git a/docs/uml/main/input/ModelContainerConcept.puml b/docs/uml/main/input/ModelContainerConcept.puml index e96c699e8..2583a8fc9 100644 --- a/docs/uml/main/input/ModelContainerConcept.puml +++ b/docs/uml/main/input/ModelContainerConcept.puml @@ -42,7 +42,7 @@ package models.input.container { class SystemParticipants { - bmPlants: Set - chpPlants: Set - - evCS: Set + - evcs: Set - evs: Set - fixedFeedIns: Set - heatPumps: Set diff --git a/docs/uml/main/input/SystemDatamodelConcept.puml b/docs/uml/main/input/SystemDatamodelConcept.puml index 5e666732f..d588e1256 100644 --- a/docs/uml/main/input/SystemDatamodelConcept.puml +++ b/docs/uml/main/input/SystemDatamodelConcept.puml @@ -119,7 +119,7 @@ package models { - capex: ComparableQuantity [€] - opex: ComparableQuantity [€/MWh] - sRated: ComparableQuantity [kVA] - - cosphiRated: Double + - cosPhiRated: Double } SystemParticipantTypeInput --|> AssetTypeInput @@ -206,7 +206,7 @@ package models { class FixedFeedInInput { - sRated: ComparableQuantity [kVA] - - cosphiRated: double + - cosPhiRated: double } FixedFeedInInput --|> SystemParticipantInput diff --git a/gradle/scripts/spotbugs.gradle b/gradle/scripts/spotbugs.gradle index 3b7f48f79..db8419336 100644 --- a/gradle/scripts/spotbugs.gradle +++ b/gradle/scripts/spotbugs.gradle @@ -1,21 +1,26 @@ // spotBugs is a code check tool, working on byte code +// workaround because imports do not work in files that are only included by build.gradle +def classLoader = plugins['com.github.spotbugs'].class.classLoader +def SpotBugsEffort = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Effort' ) +def SpotBugsConfidence = classLoader.findLoadedClass( 'com.github.spotbugs.snom.Confidence' ) + spotbugs{ ignoreFailures = true // dont let the build fail on rule violations - effort = 'max' - reportLevel = 'high' + effort = SpotBugsEffort.valueOf("MAX") + reportLevel = SpotBugsConfidence.valueOf("HIGH") } spotbugsMain{ reports{ - html.enabled = false - xml.enabled = true + html.required.set(false) + xml.required.set(true) } } spotbugsTest{ reports{ - html.enabled = false - xml.enabled = true + html.required.set(false) + xml.required.set(true) } } diff --git a/gradle/scripts/spotless.gradle b/gradle/scripts/spotless.gradle index 29ea009b7..7d547fb29 100644 --- a/gradle/scripts/spotless.gradle +++ b/gradle/scripts/spotless.gradle @@ -17,19 +17,18 @@ spotless { /* cf. https://github.com/diffplug/spotless/tree/master/plugin-gradle */ groovy { + importOrder('\\#', '', 'java') licenseHeader ie3LicHead // the Groovy Eclipse formatter extends the Java Eclipse formatter, // so it formats Java files by default (unless `excludeJava` is used). - // FIXME rolled back greclipse version https://github.com/diffplug/spotless/issues/1860 - greclipse('4.27').configFile('greclipse.properties') + greclipse().configFile('greclipse.properties') indentWithSpaces 2 } groovyGradle { // same as groovy, but for .gradle (defaults to '*.gradle') target '*.gradle', 'gradle/scripts/*.gradle' - // FIXME rolled back greclipse version https://github.com/diffplug/spotless/issues/1860 - greclipse('4.27') + greclipse() indentWithSpaces 2 } diff --git a/src/main/java/edu/ie3/datamodel/exceptions/DuplicateEntitiesException.java b/src/main/java/edu/ie3/datamodel/exceptions/DuplicateEntitiesException.java new file mode 100644 index 000000000..c8c2ac7da --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/exceptions/DuplicateEntitiesException.java @@ -0,0 +1,27 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.exceptions; + +import edu.ie3.datamodel.models.UniqueEntity; +import edu.ie3.datamodel.utils.ExceptionUtils; +import java.util.Collection; + +public class DuplicateEntitiesException extends ValidationException { + + protected DuplicateEntitiesException(String s) { + super(s); + } + + protected DuplicateEntitiesException(String s, String entities) { + super(s + entities); + } + + public DuplicateEntitiesException(String fieldName, Collection entities) { + this( + "The following entities have duplicate '" + fieldName + "': ", + ExceptionUtils.combine(entities)); + } +} diff --git a/src/main/java/edu/ie3/datamodel/exceptions/FactoryException.java b/src/main/java/edu/ie3/datamodel/exceptions/FactoryException.java index 75c0467f3..0a51c09bf 100644 --- a/src/main/java/edu/ie3/datamodel/exceptions/FactoryException.java +++ b/src/main/java/edu/ie3/datamodel/exceptions/FactoryException.java @@ -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); diff --git a/src/main/java/edu/ie3/datamodel/exceptions/FailedValidationException.java b/src/main/java/edu/ie3/datamodel/exceptions/FailedValidationException.java index 0fc60cd13..b1cc6386b 100644 --- a/src/main/java/edu/ie3/datamodel/exceptions/FailedValidationException.java +++ b/src/main/java/edu/ie3/datamodel/exceptions/FailedValidationException.java @@ -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); } diff --git a/src/main/java/edu/ie3/datamodel/exceptions/ValidationException.java b/src/main/java/edu/ie3/datamodel/exceptions/ValidationException.java index e74d70696..22eaa2ad0 100644 --- a/src/main/java/edu/ie3/datamodel/exceptions/ValidationException.java +++ b/src/main/java/edu/ie3/datamodel/exceptions/ValidationException.java @@ -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); } diff --git a/src/main/java/edu/ie3/datamodel/io/connectors/CouchbaseConnector.java b/src/main/java/edu/ie3/datamodel/io/connectors/CouchbaseConnector.java index 41638207b..ffeaf86fb 100644 --- a/src/main/java/edu/ie3/datamodel/io/connectors/CouchbaseConnector.java +++ b/src/main/java/edu/ie3/datamodel/io/connectors/CouchbaseConnector.java @@ -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; /** @@ -56,6 +60,28 @@ public CouchbaseConnector( cluster = Cluster.connect(url, clusterOptions); } + /** Returns the option for a set of found fields. */ + @SuppressWarnings("unchecked") + public Optional> 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 set = new HashSet<>(); + + if (columns != null) { + set.addAll((List) columns); + } + + return Optional.of(set); + } + /** * Return the couchbase java sdk equivalent of a session - a collection - to the previously set * bucket diff --git a/src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java b/src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java index 71147a7db..3250a862d 100644 --- a/src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java +++ b/src/main/java/edu/ie3/datamodel/io/connectors/CsvFileConnector.java @@ -42,12 +42,12 @@ public class CsvFileConnector implements DataConnector { private final Map timeSeriesWriters = new HashMap<>(); private final FileNamingStrategy fileNamingStrategy; - private final Path baseDirectoryName; + private final Path baseDirectory; private static final String FILE_ENDING = ".csv"; - public CsvFileConnector(Path baseDirectoryName, FileNamingStrategy fileNamingStrategy) { - this.baseDirectoryName = baseDirectoryName; + public CsvFileConnector(Path baseDirectory, FileNamingStrategy fileNamingStrategy) { + this.baseDirectory = baseDirectory; this.fileNamingStrategy = fileNamingStrategy; } @@ -61,7 +61,7 @@ public synchronized BufferedCsvWriter getOrInitWriter( /* If it is not available, build and register one */ try { CsvFileDefinition fileDefinition = buildFileDefinition(clz, headerElements, csvSep); - BufferedCsvWriter newWriter = initWriter(baseDirectoryName, fileDefinition); + BufferedCsvWriter newWriter = initWriter(baseDirectory, fileDefinition); entityWriters.put(clz, newWriter); return newWriter; @@ -81,7 +81,7 @@ BufferedCsvWriter getOrInitWriter(T timeSeries, String[] headerElements, String /* If it is not available, build and register one */ try { CsvFileDefinition fileDefinition = buildFileDefinition(timeSeries, headerElements, csvSep); - BufferedCsvWriter newWriter = initWriter(baseDirectoryName, fileDefinition); + BufferedCsvWriter newWriter = initWriter(baseDirectory, fileDefinition); timeSeriesWriters.put(timeSeries.getUuid(), newWriter); return newWriter; @@ -159,42 +159,15 @@ public synchronized void closeEntityWriter(Class clz } /** - * Initializes a file reader for the given class that should be read in. The expected file name is - * determined based on {@link FileNamingStrategy} of the this {@link CsvFileConnector} instance + * Initializes a file reader for the given file name. * - * @param clz the class of the entity that should be read - * @return the reader that contains information about the file to be read in - * @throws FileNotFoundException If the matching file cannot be found - */ - public BufferedReader initReader(Class 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); - } - } - - /** - * 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 */ public BufferedReader initReader(Path filePath) throws FileNotFoundException { - File fullPath = baseDirectoryName.resolve(filePath.toString() + FILE_ENDING).toFile(); + File fullPath = baseDirectory.resolve(filePath.toString() + FILE_ENDING).toFile(); return new BufferedReader( new InputStreamReader(new FileInputStream(fullPath), StandardCharsets.UTF_8), 16384); } @@ -234,10 +207,9 @@ public BufferedReader initReader(Path filePath) throws FileNotFoundException { * @return A set of relative paths to time series files, with respect to the base folder path */ private Set getIndividualTimeSeriesFilePaths() { - Path baseDirectoryPath = baseDirectoryName.resolve(baseDirectoryName); - try (Stream pathStream = Files.walk(baseDirectoryPath)) { + try (Stream pathStream = Files.walk(baseDirectory)) { return pathStream - .map(baseDirectoryPath::relativize) + .map(baseDirectory::relativize) .filter( path -> { Path withoutEnding = @@ -254,18 +226,6 @@ private Set getIndividualTimeSeriesFilePaths() { } } - /** - * Initialises a reader to get grip on the file that contains mapping information between - * coordinate id and actual coordinate - * - * @return A {@link BufferedReader} - * @throws FileNotFoundException If the file is not present - */ - public BufferedReader initIdCoordinateReader() throws FileNotFoundException { - Path filePath = Path.of(fileNamingStrategy.getIdCoordinateEntityName()); - return initReader(filePath); - } - /** * Builds a new file definition consisting of file name and head line elements * diff --git a/src/main/java/edu/ie3/datamodel/io/connectors/InfluxDbConnector.java b/src/main/java/edu/ie3/datamodel/io/connectors/InfluxDbConnector.java index 685e16614..f96fb621a 100644 --- a/src/main/java/edu/ie3/datamodel/io/connectors/InfluxDbConnector.java +++ b/src/main/java/edu/ie3/datamodel/io/connectors/InfluxDbConnector.java @@ -38,6 +38,7 @@ public class InfluxDbConnector implements DataConnector { return maps; }; + private final String databaseName; private final String scenarioName; private final InfluxDB session; @@ -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; @@ -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> getSourceFields() { + QueryResult tagKeys = session.query(new Query("SHOW TAG KEYS ON " + databaseName)); + Map>> tagResults = parseQueryResult(tagKeys); + + QueryResult fieldKeys = session.query(new Query("SHOW FIELD KEYS ON " + databaseName)); + Map>> fieldResults = parseQueryResult(fieldKeys); + + Set 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 * diff --git a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java index c958a2d9b..8f874087d 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/EntityData.java @@ -24,12 +24,14 @@ import tech.units.indriya.ComparableQuantity; /** - * Internal API Contains data that is needed by an {@link EntityFactory} to generate an entity + * Data used by {@link EntityFactory} to create an instance of an entity than can be created based + * only on a mapping of fieldName to value. This class can be used whenever no additional data is + * needed, but also functions as a parent class for extensions. * * @version 0.1 * @since 28.01.20 */ -public abstract class EntityData extends FactoryData { +public class EntityData extends FactoryData { private static final Logger logger = LoggerFactory.getLogger(EntityData.class); private static final GeoJsonReader geoJsonReader = new GeoJsonReader(); @@ -39,11 +41,20 @@ public abstract class EntityData extends FactoryData { * @param fieldsToAttributes attribute map: field name to value * @param entityClass class of the entity to be created with this data */ - protected EntityData( + public EntityData( Map fieldsToAttributes, Class entityClass) { super(fieldsToAttributes, entityClass); } + /** + * Creates a new EntityData object based on a given {@link FactoryData} object + * + * @param factoryData The factory data object to use attributes of + */ + protected EntityData(FactoryData factoryData) { + super(factoryData.getFieldsToValues(), factoryData.getTargetClass()); + } + @Override @SuppressWarnings("unchecked cast") public Class getTargetClass() { diff --git a/src/main/java/edu/ie3/datamodel/io/factory/Factory.java b/src/main/java/edu/ie3/datamodel/io/factory/Factory.java index 0428701ec..9daff0c2d 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/Factory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/Factory.java @@ -6,10 +6,13 @@ package edu.ie3.datamodel.io.factory; import edu.ie3.datamodel.exceptions.FactoryException; +import edu.ie3.datamodel.exceptions.FailedValidationException; +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.io.source.SourceValidator; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.*; +import edu.ie3.util.StringUtils; import java.util.*; -import java.util.function.IntFunction; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,7 +26,7 @@ * @param Type of the intended return type (might differ slightly from target class (cf. {@link * edu.ie3.datamodel.io.factory.timeseries.TimeBasedValueFactory})). */ -public abstract class Factory { +public abstract class Factory implements SourceValidator { public static final Logger log = LoggerFactory.getLogger(Factory.class); private final List> supportedClasses; @@ -48,15 +51,10 @@ public List> getSupportedClasses() { public Try get(D data) { isSupportedClass(data.getTargetClass()); - // magic: case-insensitive get/set calls on set strings - final List> allFields = getFields(data); - try { - validateParameters(data, allFields.toArray((IntFunction[]>) Set[]::new)); - // build the model return Success.of(buildModel(data)); - } catch (FactoryException e) { + } catch (FactoryException | IllegalArgumentException e) { return Failure.of( new FactoryException( "An error occurred when creating instance of " @@ -108,68 +106,98 @@ private void isSupportedClass(Class desiredClass) { * Returns list of sets of attribute names that the entity requires to be built. At least one of * these sets needs to be delivered for entity creation to be successful. * - * @param data EntityData (or subclass) containing the data + * @param entityClass class that can be used to specify the fields that are returned * @return list of possible attribute sets */ - protected abstract List> getFields(D data); + protected abstract List> getFields(Class entityClass); /** - * Validates the factory specific constructor parameters in two ways. 1) the biggest set of the - * provided field sets is compared against fields the class implements. If this test passes then - * we know for sure that the field names at least in the biggest constructor are equal to the - * provided factory strings 2) if 1) passes, the provided entity data (which is equal to the data - * e.g. read from the outside) is compared to all available constructor parameters provided by the - * fieldSets Array. If we find exactly one constructor, that matches the field names we can - * proceed. Otherwise a detailed exception message is thrown. + * Method to find and return additional fields that were found in a source and are not used by the + * data model. This method will return the minimal unused fields among all field sets, meaning + * that the set of actual fields is compared to the field set with the least unused fields. * - * @param data the entity containing at least the entity class as well a mapping of the provided - * field name strings to its value (e.g. a headline of a csv to column values) - * @param fieldSets a set containing all available constructor combinations as field names - * @return the index of the set in the fieldSets array that fits the provided entity data + * @param actualFields found in the source + * @param validFieldSets that contains at least all fields found in the source + * @return a set of unused fields */ - protected int validateParameters(D data, Set... fieldSets) { - Map fieldsToValues = data.getFieldsToValues(); + protected Set getUnusedFields( + Set actualFields, List> validFieldSets) { + // checking for additional fields + // and returning the set with the least additional fields + return validFieldSets.stream() + .map( + s -> { + Set set = new HashSet<>(actualFields); + set.removeAll(s); + return set; + }) + .min(Comparator.comparing(Collection::size)) + .orElse(Collections.emptySet()); + } - // get all sets that match the fields to attributes + /** + * Method for validating the actual fields. The actual fields need to fully contain at least one + * of the sets returned by {@link #getFields(Class)}. If the actual fields don't contain all + * necessary fields, an {@link FactoryException} with a detail message is thrown. If the actual + * fields contain more fields than necessary, these fields are ignored. + * + * @param actualFields that were found + * @param entityClass of the build data + * @return either an exception wrapped by a {@link Failure} or an empty success + */ + public Try validate( + Set actualFields, Class entityClass) { + List> fieldSets = getFields(entityClass); + Set harmonizedActualFields = toCamelCase(actualFields); + + // comparing the actual fields to a list of possible fields (allows additional fields) + // if not all fields were found in a set, this set is filtered out + // all other fields are saved as a list + // allows snake, camel and mixed cases List> validFieldSets = - Arrays.stream(fieldSets).filter(x -> x.equals(fieldsToValues.keySet())).toList(); + fieldSets.stream().filter(harmonizedActualFields::containsAll).toList(); - if (validFieldSets.size() == 1) { - // if we can identify a unique parameter set for a constructor, we take it and return the - // index - Set validFieldSet = validFieldSets.get(0); - return Arrays.asList(fieldSets).indexOf(validFieldSet); - } else { + if (validFieldSets.isEmpty()) { // build the exception string with extensive debug information - String providedFieldMapString = - fieldsToValues.keySet().stream() - .map(key -> key + " -> " + fieldsToValues.get(key)) - .collect(Collectors.joining(",\n")); - - String providedKeysString = "[" + String.join(", ", fieldsToValues.keySet()) + "]"; + String providedKeysString = "[" + String.join(", ", actualFields) + "]"; String possibleOptions = getFieldsString(fieldSets).toString(); - throw new FactoryException( - "The provided fields " - + providedKeysString - + " with data \n{" - + providedFieldMapString - + "}" - + " are invalid for instance of " - + data.getTargetClass().getSimpleName() - + ". \nThe following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of '" - + data.getTargetClass().getSimpleName() - + "' are possible (NOT case-sensitive!):\n" - + possibleOptions); + return Failure.of( + new FailedValidationException( + "The provided fields " + + providedKeysString + + " are invalid for instance of '" + + entityClass.getSimpleName() + + "'. \nThe following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of '" + + entityClass.getSimpleName() + + "' are possible (NOT case-sensitive!):\n" + + possibleOptions)); + } else { + Set unused = getUnusedFields(harmonizedActualFields, validFieldSets); + + if (!unused.isEmpty()) { + log.debug( + "The following additional fields were found for entity class of '{}': {}", + entityClass.getSimpleName(), + unused); + } + + return Success.empty(); } } - protected static StringBuilder getFieldsString(Set... fieldSets) { + protected static StringBuilder getFieldsString(List> fieldSets) { StringBuilder possibleOptions = new StringBuilder(); - for (int i = 0; i < fieldSets.length; i++) { - Set fieldSet = fieldSets[i]; - String option = i + ": [" + String.join(", ", fieldSet) + "]\n"; + for (int i = 0; i < fieldSets.size(); i++) { + Set fieldSet = fieldSets.get(i); + String option = + i + + ": [" + + String.join(", ", fieldSet) + + "] or [" + + String.join(", ", toSnakeCase(fieldSet)) + + "]\n"; possibleOptions.append(option); } return possibleOptions; @@ -177,12 +205,12 @@ protected static StringBuilder getFieldsString(Set... fieldSets) { /** * Creates a new set of attribute names from given list of attributes. This method should always - * be used when returning attribute sets, i.e. through {@link #getFields(FactoryData)}. + * be used when returning attribute sets, i.e. through {@link #getFields(Class)}. * * @param attributes attribute names * @return new set exactly containing attribute names */ - protected TreeSet newSet(String... attributes) { + protected static TreeSet newSet(String... attributes) { TreeSet set = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); set.addAll(Arrays.asList(attributes)); return set; @@ -197,10 +225,28 @@ protected TreeSet newSet(String... attributes) { * @param more attribute names to expand given set with * @return new set exactly containing given attribute set plus additional attributes */ - protected TreeSet expandSet(Set attributeSet, String... more) { + protected static TreeSet expandSet(Set attributeSet, String... more) { TreeSet newSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); newSet.addAll(attributeSet); newSet.addAll(Arrays.asList(more)); return newSet; } + + protected static Set toSnakeCase(Set set) { + TreeSet newSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + newSet.addAll(set.stream().map(StringUtils::camelCaseToSnakeCase).toList()); + return newSet; + } + + protected static Set toCamelCase(Set set) { + TreeSet newSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + newSet.addAll(set.stream().map(StringUtils::snakeCaseToCamelCase).toList()); + return newSet; + } + + protected static Set toLowerCase(Set set) { + TreeSet newSet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); + newSet.addAll(set.stream().map(String::toLowerCase).toList()); + return newSet; + } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java b/src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java index 95886864e..6ed7dcb7e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/FactoryData.java @@ -18,10 +18,8 @@ public abstract class FactoryData { protected FactoryData(Map fieldsToAttributes, Class targetClass) { // this does the magic: case-insensitive get/set calls on keys - TreeMap insensitiveFieldsToAttributes = - new TreeMap<>(String.CASE_INSENSITIVE_ORDER); - insensitiveFieldsToAttributes.putAll(fieldsToAttributes); - this.fieldsToAttributes = insensitiveFieldsToAttributes; + this.fieldsToAttributes = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); + this.fieldsToAttributes.putAll(fieldsToAttributes); this.targetClass = targetClass; } @@ -137,29 +135,6 @@ field, getField(field)), } } - /** - * Parses and returns an array of UUIDs from field value of given field name. Throws {@link - * FactoryException} if field does not exist or parsing fails. - * - * @param field field name - * @return UUID - */ - public UUID[] getUUIDs(String field) { - try { - String fieldValue = getField(field); - if (fieldValue.trim().isEmpty()) return new UUID[0]; - - String[] uuidFields = fieldValue.split(" "); - return Arrays.stream(uuidFields).map(UUID::fromString).toArray(UUID[]::new); - } catch (IllegalArgumentException iae) { - throw new FactoryException( - String.format( - "Exception while trying to parse UUIDs of field \"%s\" with value \"%s\"", - field, getField(field)), - iae); - } - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityData.java deleted file mode 100644 index 267255c70..000000000 --- a/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityData.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * © 2021. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation -*/ -package edu.ie3.datamodel.io.factory; - -import edu.ie3.datamodel.models.UniqueEntity; -import java.util.Map; - -/** - * Data used by {@link SimpleEntityFactory} to create an instance of an entity than can be created - * based only on a mapping of fieldName to value. This class can be used whenever no additional data - * is needed, but should not be used as parent class for extensions. Use {@link EntityData} for - * extensions instead. - * - * @version 0.1 - * @since 28.01.20 - */ -public final class SimpleEntityData extends EntityData { - - public SimpleEntityData( - Map fieldsToAttributes, Class clazz) { - super(fieldsToAttributes, clazz); - } -} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityFactory.java deleted file mode 100644 index a420212c2..000000000 --- a/src/main/java/edu/ie3/datamodel/io/factory/SimpleEntityFactory.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * © 2021. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation -*/ -package edu.ie3.datamodel.io.factory; - -import edu.ie3.datamodel.models.UniqueEntity; - -/** - * Internal API Interface for Entities that can be build without any dependencies on other complex - * pojos - * - * @version 0.1 - * @since 28.01.20 - */ -public abstract class SimpleEntityFactory - extends EntityFactory { - - protected SimpleEntityFactory(Class... allowedClasses) { - super(allowedClasses); - } -} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityData.java index 614ca25cb..10f93153e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityData.java @@ -45,6 +45,18 @@ public AssetInputEntityData( this.operator = operator; } + /** + * Creates a new AssetInputEntityData object based on a given {@link EntityData} object and given + * operator + * + * @param entityData The entity data object to use attributes of + * @param operator The operator input to use + */ + public AssetInputEntityData(EntityData entityData, OperatorInput operator) { + super(entityData); + this.operator = operator; + } + public OperatorInput getOperatorInput() { return operator; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactory.java index 0da292f37..bfef41520 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactory.java @@ -25,8 +25,8 @@ public abstract class AssetInputEntityFactory { private static final String UUID = "uuid"; - private static final String OPERATES_FROM = "operatesfrom"; - private static final String OPERATES_UNTIL = "operatesuntil"; + private static final String OPERATES_FROM = "operatesFrom"; + private static final String OPERATES_UNTIL = "operatesUntil"; private static final String ID = "id"; protected AssetInputEntityFactory(Class... allowedClasses) { @@ -39,11 +39,11 @@ protected AssetInputEntityFactory(Class... allowedClasses) { *

The mandatory attributes required to create an {@link AssetInput} are enhanced with custom * attribute names that each subclass factory determines in {@link #getAdditionalFields()}. * - * @param data EntityData (or subclass) containing the data + * @param entityClass class of the entity * @return list of possible attribute sets */ @Override - protected List> getFields(D data) { + protected List> getFields(Class entityClass) { Set constructorParamsMin = newSet(UUID, ID); Set constructorParamsFrom = expandSet(constructorParamsMin, OPERATES_FROM); Set constructorParamsUntil = expandSet(constructorParamsMin, OPERATES_UNTIL); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityData.java index 758883595..4c795e89d 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityData.java @@ -42,6 +42,21 @@ public ConnectorInputEntityData( this.nodeB = nodeB; } + /** + * Creates a new ConnectorInputEntityData object based on a given {@link AssetInputEntityData} + * object and given nodes + * + * @param entityData The AssetInputEntityData object to enhance + * @param nodeA The first node to add + * @param nodeB The second node to add + */ + public ConnectorInputEntityData( + AssetInputEntityData entityData, NodeInput nodeA, NodeInput nodeB) { + super(entityData, entityData.getOperatorInput()); + this.nodeA = nodeA; + this.nodeB = nodeB; + } + public NodeInput getNodeA() { return nodeA; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityFactory.java index 4ef83352e..cc29c7e5e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/ConnectorInputEntityFactory.java @@ -29,7 +29,7 @@ abstract class ConnectorInputEntityFactory< * ConnectorInput}s. Thus, this attribute name declaration can be used in subclasses of {@link * ConnectorInputEntityFactory} */ - protected static final String PARALLEL_DEVICES = "paralleldevices"; + protected static final String PARALLEL_DEVICES = "parallelDevices"; protected ConnectorInputEntityFactory(Class... allowedClasses) { super(allowedClasses); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java index cd517423c..3b423465c 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/CylindricalStorageInputFactory.java @@ -18,10 +18,10 @@ public class CylindricalStorageInputFactory extends AssetInputEntityFactory { - private static final String STORAGE_VOLUME_LVL = "storagevolumelvl"; - private static final String STORAGE_VOLUME_LVL_MIN = "storagevolumelvlmin"; - private static final String INLET_TEMP = "inlettemp"; - private static final String RETURN_TEMP = "returntemp"; + private static final String STORAGE_VOLUME_LVL = "storageVolumeLvl"; + private static final String STORAGE_VOLUME_LVL_MIN = "storageVolumeLvlMin"; + private static final String INLET_TEMP = "inletTemp"; + private static final String RETURN_TEMP = "returnTemp"; private static final String C = "c"; public CylindricalStorageInputFactory() { diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/EmAssetInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/EmAssetInputEntityData.java new file mode 100644 index 000000000..d001c405e --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/EmAssetInputEntityData.java @@ -0,0 +1,70 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.factory.input; + +import edu.ie3.datamodel.models.UniqueEntity; +import edu.ie3.datamodel.models.input.EmInput; +import edu.ie3.datamodel.models.input.OperatorInput; +import java.util.Map; +import java.util.Objects; + +/** + * Data used for the construction of {@link edu.ie3.datamodel.models.input.AssetInput} entities + * which also require an EM attribute. This data object can include additional information about the + * {@link EmInput}, which cannot be provided through the attribute map as it is a complex shared + * entity. + */ +public class EmAssetInputEntityData extends AssetInputEntityData { + + private final EmInput emUnit; + + public EmAssetInputEntityData( + Map fieldsToAttributes, + Class entityClass, + EmInput emUnit) { + super(fieldsToAttributes, entityClass); + this.emUnit = emUnit; + } + + public EmAssetInputEntityData( + Map fieldsToAttributes, + Class entityClass, + OperatorInput operator, + EmInput emUnit) { + super(fieldsToAttributes, entityClass, operator); + this.emUnit = emUnit; + } + + /** + * Creates a new EmAssetInputEntityData object based on a given {@link AssetInputEntityData} + * object and given em unit + * + * @param entityData The entity data object to use attributes of + * @param emUnit The em input to use + */ + public EmAssetInputEntityData(AssetInputEntityData entityData, EmInput emUnit) { + super(entityData, entityData.getOperatorInput()); + this.emUnit = emUnit; + } + + public EmInput getEmUnit() { + return emUnit; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + EmAssetInputEntityData that = (EmAssetInputEntityData) o; + return Objects.equals(emUnit, that.emUnit); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), emUnit); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/LineInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/LineInputFactory.java index e0c1154d8..ff8769100 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/LineInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/LineInputFactory.java @@ -23,8 +23,8 @@ public class LineInputFactory extends ConnectorInputEntityFactory> { private static final String LENGTH = "length"; - private static final String GEO_POSITION = "geoposition"; - private static final String OLM_CHARACTERISTIC = "olmcharacteristic"; + private static final String GEO_POSITION = "geoPosition"; + private static final String OLM_CHARACTERISTIC = "olmCharacteristic"; public LineInputFactory() { super(LineInput.class); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/MeasurementUnitInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/MeasurementUnitInputFactory.java index 7ed27292f..e15f6f494 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/MeasurementUnitInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/MeasurementUnitInputFactory.java @@ -13,8 +13,8 @@ public class MeasurementUnitInputFactory extends AssetInputEntityFactory { - private static final String V_MAG = "vmag"; - private static final String V_ANG = "vang"; + private static final String V_MAG = "vMag"; + private static final String V_ANG = "vAng"; private static final String P = "p"; private static final String Q = "q"; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/NodeAssetInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/NodeAssetInputEntityData.java index bce3c4117..4916e78ad 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/NodeAssetInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/NodeAssetInputEntityData.java @@ -53,6 +53,18 @@ public NodeAssetInputEntityData( this.node = node; } + /** + * Creates a new NodeAssetInputEntityData object based on a given {@link AssetInputEntityData} + * object and given node + * + * @param assetInputEntityData The asset entity data object to use attributes of + * @param node input node + */ + public NodeAssetInputEntityData(AssetInputEntityData assetInputEntityData, NodeInput node) { + super(assetInputEntityData, assetInputEntityData.getOperatorInput()); + this.node = node; + } + public NodeInput getNode() { return node; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/NodeInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/NodeInputFactory.java index 1110d5d51..96aa8859d 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/NodeInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/NodeInputFactory.java @@ -16,10 +16,10 @@ import tech.units.indriya.ComparableQuantity; public class NodeInputFactory extends AssetInputEntityFactory { - private static final String V_TARGET = "vtarget"; + private static final String V_TARGET = "vTarget"; public static final String V_RATED = "vRated"; private static final String SLACK = "slack"; - private static final String GEO_POSITION = "geoposition"; + private static final String GEO_POSITION = "geoPosition"; public static final String VOLT_LVL = "voltLvl"; private static final String SUBNET = "subnet"; @@ -29,9 +29,7 @@ public NodeInputFactory() { @Override protected String[] getAdditionalFields() { - return new String[] { - V_TARGET, V_RATED.toLowerCase(), SLACK, GEO_POSITION, VOLT_LVL.toLowerCase(), SUBNET - }; + return new String[] {V_TARGET, V_RATED, SLACK, GEO_POSITION, VOLT_LVL, SUBNET}; } @Override diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/OperatorInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/OperatorInputFactory.java index 09dcdc881..706ba1250 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/OperatorInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/OperatorInputFactory.java @@ -5,14 +5,14 @@ */ package edu.ie3.datamodel.io.factory.input; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; -import edu.ie3.datamodel.io.factory.SimpleEntityData; import edu.ie3.datamodel.models.input.OperatorInput; import java.util.Collections; import java.util.List; import java.util.Set; -public class OperatorInputFactory extends EntityFactory { +public class OperatorInputFactory extends EntityFactory { private static final String ENTITY_UUID = "uuid"; private static final String ENTITY_ID = "id"; @@ -22,13 +22,13 @@ public OperatorInputFactory() { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set constructorParams = newSet(ENTITY_UUID, ENTITY_ID); return Collections.singletonList(constructorParams); } @Override - protected OperatorInput buildModel(SimpleEntityData data) { + protected OperatorInput buildModel(EntityData data) { return new OperatorInput(data.getUUID(ENTITY_UUID), data.getField(ENTITY_ID)); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/SwitchInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/SwitchInputFactory.java index 0506029a4..d716324cc 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/SwitchInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/SwitchInputFactory.java @@ -34,6 +34,18 @@ protected SwitchInput buildModel( OperatorInput operator, OperationTime operationTime) { final boolean closed = data.getBoolean(CLOSED); + + if (data.containsKey(PARALLEL_DEVICES)) { + String parallelDevices = data.getField(PARALLEL_DEVICES); + + log.warn( + "The SwitchInput with id `{}` specifies the unused parameter `parallelDevices` with a value of `{}`." + + " SwitchInputs do not need to specify `parallelDevices`, as its physical value depends on" + + " the electrotechnical context of where the switch is embedded.", + id, + parallelDevices); + } + return new SwitchInput(uuid, id, operator, operationTime, nodeA, nodeB, closed); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java index f60961cb6..6fab0fc61 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalHouseInputFactory.java @@ -18,8 +18,8 @@ public class ThermalHouseInputFactory extends AssetInputEntityFactory { - private static final String ETH_LOSSES = "ethlosses"; - private static final String ETH_CAPA = "ethcapa"; + private static final String ETH_LOSSES = "ethLosses"; + private static final String ETH_CAPA = "ethCapa"; private static final String TARGET_TEMPERATURE = "targetTemperature"; private static final String UPPER_TEMPERATURE_LIMIT = "upperTemperatureLimit"; private static final String LOWER_TEMPERATURE_LIMIT = "lowerTemperatureLimit"; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalUnitInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalUnitInputEntityData.java index b9b67f836..c936b58f9 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalUnitInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/ThermalUnitInputEntityData.java @@ -31,6 +31,18 @@ public ThermalUnitInputEntityData( this.busInput = busInput; } + /** + * Creates a new ThermalUnitInputEntityData object based on a given {@link AssetInputEntityData} + * object and a bus input + * + * @param entityData The AssetInputEntityData object to enhance + * @param busInput The thermal bus input + */ + public ThermalUnitInputEntityData(AssetInputEntityData entityData, ThermalBusInput busInput) { + super(entityData, entityData.getOperatorInput()); + this.busInput = busInput; + } + public ThermalBusInput getBusInput() { return busInput; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactory.java index 5b1909993..110f0572a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactory.java @@ -16,8 +16,8 @@ public class Transformer2WInputFactory extends ConnectorInputEntityFactory< Transformer2WInput, TypedConnectorInputEntityData> { - private static final String TAP_POS = "tappos"; - private static final String AUTO_TAP = "autotap"; + private static final String TAP_POS = "tapPos"; + private static final String AUTO_TAP = "autoTap"; public Transformer2WInputFactory() { super(Transformer2WInput.class); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputEntityData.java index 47da51e48..e53678f1a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputEntityData.java @@ -39,6 +39,19 @@ public Transformer3WInputEntityData( this.nodeC = nodeC; } + /** + * Creates a new Transformer3WInputEntityData object based on a given {@link + * TypedConnectorInputEntityData} object and given third node + * + * @param entityData The TypedConnectorInputEntityData object to enhance + * @param nodeC The third node + */ + public Transformer3WInputEntityData( + TypedConnectorInputEntityData entityData, NodeInput nodeC) { + super(entityData, entityData.getType()); + this.nodeC = nodeC; + } + public NodeInput getNodeC() { return nodeC; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactory.java index 59aec043b..c9987fe1f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactory.java @@ -15,8 +15,8 @@ public class Transformer3WInputFactory extends ConnectorInputEntityFactory { - private static final String TAP_POS = "tappos"; - private static final String AUTO_TAP = "autotap"; + private static final String TAP_POS = "tapPos"; + private static final String AUTO_TAP = "autoTap"; public Transformer3WInputFactory() { super(Transformer3WInput.class); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnectorInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnectorInputEntityData.java index 7f3a56f83..c70bb2231 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnectorInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnectorInputEntityData.java @@ -46,8 +46,8 @@ public TypedConnectorInputEntityData( } /** - * Creates a new TypedConnectorInputEntityData object for an operable connector input input that - * input that needs a type input as well + * Creates a new TypedConnectorInputEntityData object for an operable connector input that needs a + * type input as well * * @param fieldsToAttributes attribute map: field name to value * @param entityClass class of the entity to be created with this data @@ -67,6 +67,18 @@ public TypedConnectorInputEntityData( this.type = type; } + /** + * Creates a new TypedConnectorInputEntityData object based on a given {@link + * ConnectorInputEntityData} object and given type + * + * @param entityData The ConnectorInputEntityData object to enhance + * @param type type input + */ + public TypedConnectorInputEntityData(ConnectorInputEntityData entityData, T type) { + super(entityData, entityData.getNodeA(), entityData.getNodeB()); + this.type = type; + } + public T getType() { return type; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/GraphicInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/GraphicInputFactory.java index 4dfb98676..c3a5a058b 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/GraphicInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/GraphicInputFactory.java @@ -23,7 +23,7 @@ public abstract class GraphicInputFactory { private static final String UUID = "uuid"; - private static final String GRAPHIC_LAYER = "graphiclayer"; + private static final String GRAPHIC_LAYER = "graphicLayer"; private static final String PATH_LINE_STRING = "path"; protected GraphicInputFactory(Class... allowedClasses) { @@ -36,11 +36,11 @@ protected GraphicInputFactory(Class... allowedClasses) { *

The mandatory attributes required to create an {@link GraphicInput} are enhanced with custom * attribute names that each subclass factory determines in {@link #getAdditionalFields()}. * - * @param data EntityData (or subclass) containing the data + * @param entityClass class of the entity * @return list of possible attribute sets */ @Override - protected List> getFields(D data) { + protected List> getFields(Class entityClass) { Set constructorParamsMin = newSet(UUID, GRAPHIC_LAYER, PATH_LINE_STRING); final String[] additionalFields = getAdditionalFields(); constructorParamsMin = expandSet(constructorParamsMin, additionalFields); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/LineGraphicInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/LineGraphicInputEntityData.java index 41bcc8b6e..48b87b088 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/LineGraphicInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/LineGraphicInputEntityData.java @@ -31,6 +31,18 @@ public LineGraphicInputEntityData(Map fieldsToAttributes, LineIn this.line = line; } + /** + * Creates a new LineGraphicInputEntityData object based on a given {@link EntityData} object and + * a line + * + * @param entityData The EntityData object to enhance + * @param line Referenced electrical line + */ + public LineGraphicInputEntityData(EntityData entityData, LineInput line) { + super(entityData); + this.line = line; + } + public LineInput getLine() { return line; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/NodeGraphicInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/NodeGraphicInputEntityData.java index a1a213cd9..edba66b27 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/NodeGraphicInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/graphics/NodeGraphicInputEntityData.java @@ -31,6 +31,18 @@ public NodeGraphicInputEntityData(Map fieldsToAttributes, NodeIn this.node = node; } + /** + * Creates a new NodeGraphicInputEntityData object based on a given {@link EntityData} object and + * a node + * + * @param entityData The EntityData object to enhance + * @param node node input element of this graphic + */ + public NodeGraphicInputEntityData(EntityData entityData, NodeInput node) { + super(entityData); + this.node = node; + } + public NodeInput getNode() { return node; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/BmInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/BmInputFactory.java index 799837d3c..8a1c58b9e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/BmInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/BmInputFactory.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.BmInput; @@ -19,9 +20,9 @@ public class BmInputFactory extends SystemParticipantInputEntityFactory< BmInput, SystemParticipantTypedEntityData> { - private static final String MARKET_REACTION = "marketreaction"; - private static final String COST_CONTROLLED = "costcontrolled"; - private static final String FEED_IN_TARIFF = "feedintariff"; + private static final String MARKET_REACTION = "marketReaction"; + private static final String COST_CONTROLLED = "costControlled"; + private static final String FEED_IN_TARIFF = "feedInTariff"; public BmInputFactory() { super(BmInput.class); @@ -41,6 +42,7 @@ protected BmInput buildModel( ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); final BmTypeInput typeInput = data.getTypeInput(); final boolean marketReaction = data.getBoolean(MARKET_REACTION); final boolean costControlled = data.getBoolean(COST_CONTROLLED); @@ -54,6 +56,7 @@ protected BmInput buildModel( operationTime, node, qCharacteristics, + em, typeInput, marketReaction, costControlled, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputEntityData.java index 800102fb9..81c11572a 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputEntityData.java @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.factory.input.participant; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.ChpInput; @@ -21,10 +22,11 @@ public class ChpInputEntityData extends SystemParticipantTypedEntityData fieldsToAttributes, NodeInput node, + EmInput em, ChpTypeInput typeInput, ThermalBusInput thermalBusInput, ThermalStorageInput thermalStorageInput) { - super(fieldsToAttributes, ChpInput.class, node, typeInput); + super(fieldsToAttributes, ChpInput.class, node, em, typeInput); this.thermalBusInput = thermalBusInput; this.thermalStorageInput = thermalStorageInput; } @@ -33,10 +35,28 @@ public ChpInputEntityData( Map fieldsToAttributes, OperatorInput operator, NodeInput node, + EmInput em, ChpTypeInput typeInput, ThermalBusInput thermalBusInput, ThermalStorageInput thermalStorageInput) { - super(fieldsToAttributes, ChpInput.class, operator, node, typeInput); + super(fieldsToAttributes, ChpInput.class, operator, node, em, typeInput); + this.thermalBusInput = thermalBusInput; + this.thermalStorageInput = thermalStorageInput; + } + + /** + * Creates a new ChpInputEntityData object based on a given {@link + * SystemParticipantTypedEntityData} object and a thermal bus and storage input + * + * @param entityData The SystemParticipantTypedEntityData object to enhance + * @param thermalBusInput The thermal bus input + * @param thermalStorageInput The thermal storage input + */ + public ChpInputEntityData( + SystemParticipantTypedEntityData entityData, + ThermalBusInput thermalBusInput, + ThermalStorageInput thermalStorageInput) { + super(entityData, entityData.getTypeInput()); this.thermalBusInput = thermalBusInput; this.thermalStorageInput = thermalStorageInput; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactory.java index f04b85e86..d398f5a59 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactory.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.ChpInput; @@ -14,7 +15,7 @@ public class ChpInputFactory extends SystemParticipantInputEntityFactory { - private static final String MARKET_REACTION = "marketreaction"; + private static final String MARKET_REACTION = "marketReaction"; public ChpInputFactory() { super(ChpInput.class); @@ -34,6 +35,7 @@ protected ChpInput buildModel( ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); final boolean marketReaction = data.getBoolean(MARKET_REACTION); return new ChpInput( @@ -44,6 +46,7 @@ protected ChpInput buildModel( node, data.getThermalBusInput(), qCharacteristics, + em, data.getTypeInput(), data.getThermalStorageInput(), marketReaction); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java index f19475f96..3c4590d6e 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EmInputFactory.java @@ -5,67 +5,54 @@ */ package edu.ie3.datamodel.io.factory.input.participant; -import edu.ie3.datamodel.exceptions.ParsingException; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; -import edu.ie3.datamodel.models.ControlStrategy; +import edu.ie3.datamodel.io.factory.input.AssetInputEntityFactory; +import edu.ie3.datamodel.io.factory.input.EmAssetInputEntityData; import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.input.NodeInput; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.OperatorInput; -import edu.ie3.datamodel.models.input.system.EmInput; -import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; import java.util.UUID; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class EmInputFactory - extends SystemParticipantInputEntityFactory { - private static final Logger logger = LoggerFactory.getLogger(EmInputFactory.class); +public class EmInputFactory extends AssetInputEntityFactory { - private static final String CONNECTED_ASSETS = "connectedassets"; + private static final String CONTROL_STRATEGY = "controlStrategy"; - private static final String CONTROL_STRATEGY = "controlstrategy"; + public static final String PARENT_EM = "parentem"; public EmInputFactory() { super(EmInput.class); } + @Override + protected List> getFields(Class entityClass) { + List> fields = new ArrayList<>(super.getFields(entityClass)); + + List> withEm = + fields.stream().map(f -> (Set) expandSet(f, PARENT_EM)).toList(); + + fields.addAll(withEm); + + return fields; + } + @Override protected String[] getAdditionalFields() { - return new String[] {CONNECTED_ASSETS, CONTROL_STRATEGY}; + return new String[] {CONTROL_STRATEGY}; } @Override protected EmInput buildModel( - NodeAssetInputEntityData data, + EmAssetInputEntityData data, UUID uuid, String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { - ControlStrategy controlStrategy; - try { - controlStrategy = ControlStrategy.parse(data.getField(CONTROL_STRATEGY)); - } catch (ParsingException e) { - logger.warn( - "Cannot parse control strategy \"{}\" of energy management system \"{}\". Assign no control strategy instead.", - data.getField(CONTROL_STRATEGY), - id); - controlStrategy = ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY; - } - final UUID[] connectedAssets = data.getUUIDs(CONNECTED_ASSETS); + String controlStrategy = data.getField(CONTROL_STRATEGY); - if (connectedAssets.length == 0) - logger.warn("There are no connected assets for energy management system \"{}\".", id); + EmInput parentEm = data.getEmUnit(); - return new EmInput( - uuid, - id, - operator, - operationTime, - node, - qCharacteristics, - connectedAssets, - controlStrategy); + return new EmInput(uuid, id, operator, operationTime, controlStrategy, parentEm); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvInputFactory.java index 1f0f8e80c..b2d492ce5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvInputFactory.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.EvInput; @@ -35,7 +36,9 @@ protected EvInput buildModel( ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); + return new EvInput( - uuid, id, operator, operationTime, node, qCharacteristics, data.getTypeInput()); + uuid, id, operator, operationTime, node, qCharacteristics, em, data.getTypeInput()); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java index fb7419a75..a0bc9e9c0 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactory.java @@ -8,8 +8,8 @@ import edu.ie3.datamodel.exceptions.ChargingPointTypeException; import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.exceptions.ParsingException; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.EvcsInput; @@ -18,22 +18,23 @@ import edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils; import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationType; import edu.ie3.datamodel.models.input.system.type.evcslocation.EvcsLocationTypeUtils; +import java.util.UUID; /** - * Factory to create instances of {@link EvcsInput}s based on {@link NodeAssetInputEntityData} and - * additional fields. + * Factory to create instances of {@link EvcsInput}s based on {@link SystemParticipantEntityData} + * and additional fields. * * @version 0.1 * @since 26.07.20 */ public class EvcsInputFactory - extends SystemParticipantInputEntityFactory { + extends SystemParticipantInputEntityFactory { private static final String TYPE = "type"; - private static final String CHARGING_POINTS = "chargingpoints"; - private static final String COS_PHI_RATED = "cosphirated"; - private static final String LOCATION_TYPE = "locationtype"; - private static final String V2G_SUPPORT = "v2gsupport"; + private static final String CHARGING_POINTS = "chargingPoints"; + private static final String COS_PHI_RATED = "cosPhiRated"; + private static final String LOCATION_TYPE = "locationType"; + private static final String V2G_SUPPORT = "v2gSupport"; public EvcsInputFactory() { super(EvcsInput.class); @@ -46,14 +47,14 @@ protected String[] getAdditionalFields() { @Override protected EvcsInput buildModel( - NodeAssetInputEntityData data, - java.util.UUID uuid, + SystemParticipantEntityData data, + UUID uuid, String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { - + final EmInput em = data.getEm().orElse(null); final ChargingPointType type; try { type = ChargingPointTypeUtils.parse(data.getField(TYPE)); @@ -87,6 +88,7 @@ protected EvcsInput buildModel( operationTime, node, qCharacteristics, + em, type, chargingPoints, cosPhi, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactory.java index 03ff6636f..f0b6e28a9 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactory.java @@ -5,21 +5,22 @@ */ package edu.ie3.datamodel.io.factory.input.participant; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.FixedFeedInInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; +import java.util.UUID; import javax.measure.quantity.Power; import tech.units.indriya.ComparableQuantity; public class FixedFeedInInputFactory - extends SystemParticipantInputEntityFactory { + extends SystemParticipantInputEntityFactory { - private static final String S_RATED = "srated"; - private static final String COSPHI_RATED = "cosphirated"; + private static final String S_RATED = "sRated"; + private static final String COSPHI_RATED = "cosPhiRated"; public FixedFeedInInputFactory() { super(FixedFeedInInput.class); @@ -32,17 +33,18 @@ protected String[] getAdditionalFields() { @Override protected FixedFeedInInput buildModel( - NodeAssetInputEntityData data, - java.util.UUID uuid, + SystemParticipantEntityData data, + UUID uuid, String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); final ComparableQuantity sRated = data.getQuantity(S_RATED, StandardUnits.S_RATED); final double cosPhiRated = data.getDouble(COSPHI_RATED); return new FixedFeedInInput( - uuid, id, operator, operationTime, node, qCharacteristics, sRated, cosPhiRated); + uuid, id, operator, operationTime, node, qCharacteristics, em, sRated, cosPhiRated); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputEntityData.java index 38eacea63..83f01970f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputEntityData.java @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.factory.input.participant; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.HpInput; @@ -19,9 +20,10 @@ public class HpInputEntityData extends SystemParticipantTypedEntityData fieldsToAttributes, NodeInput node, + EmInput em, HpTypeInput typeInput, ThermalBusInput thermalBusInput) { - super(fieldsToAttributes, HpInput.class, node, typeInput); + super(fieldsToAttributes, HpInput.class, node, em, typeInput); this.thermalBusInput = thermalBusInput; } @@ -29,9 +31,23 @@ public HpInputEntityData( Map fieldsToAttributes, OperatorInput operator, NodeInput node, + EmInput em, HpTypeInput typeInput, ThermalBusInput thermalBusInput) { - super(fieldsToAttributes, HpInput.class, operator, node, typeInput); + super(fieldsToAttributes, HpInput.class, operator, node, em, typeInput); + this.thermalBusInput = thermalBusInput; + } + + /** + * Creates a new HpInputEntityData object based on a given {@link + * SystemParticipantTypedEntityData} object and given thermal bus input + * + * @param entityData The SystemParticipantTypedEntityData object to enhance + * @param thermalBusInput The thermal bus input + */ + public HpInputEntityData( + SystemParticipantTypedEntityData entityData, ThermalBusInput thermalBusInput) { + super(entityData, entityData.getTypeInput()); this.thermalBusInput = thermalBusInput; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputFactory.java index cd814e044..b01ede298 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/HpInputFactory.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.HpInput; @@ -33,6 +34,8 @@ protected HpInput buildModel( ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); + return new HpInput( uuid, id, @@ -41,6 +44,7 @@ protected HpInput buildModel( node, data.getThermalBusInput(), qCharacteristics, + em, data.getTypeInput()); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactory.java index eb86cefc3..6c1d295be 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactory.java @@ -6,14 +6,15 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.exceptions.ParsingException; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.LoadInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; import edu.ie3.datamodel.models.profile.LoadProfile; +import java.util.UUID; import javax.measure.quantity.Energy; import javax.measure.quantity.Power; import org.slf4j.Logger; @@ -21,14 +22,14 @@ import tech.units.indriya.ComparableQuantity; public class LoadInputFactory - extends SystemParticipantInputEntityFactory { + extends SystemParticipantInputEntityFactory { private static final Logger logger = LoggerFactory.getLogger(LoadInputFactory.class); - private static final String LOAD_PROFILE = "loadprofile"; + private static final String LOAD_PROFILE = "loadProfile"; private static final String DSM = "dsm"; - private static final String E_CONS_ANNUAL = "econsannual"; - private static final String S_RATED = "srated"; - private static final String COS_PHI = "cosphirated"; + private static final String E_CONS_ANNUAL = "eConsAnnual"; + private static final String S_RATED = "sRated"; + private static final String COS_PHI = "cosPhiRated"; public LoadInputFactory() { super(LoadInput.class); @@ -41,8 +42,8 @@ protected String[] getAdditionalFields() { @Override protected LoadInput buildModel( - NodeAssetInputEntityData data, - java.util.UUID uuid, + SystemParticipantEntityData data, + UUID uuid, String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, @@ -58,6 +59,7 @@ protected LoadInput buildModel( id); loadProfile = LoadProfile.DefaultLoadProfiles.NO_LOAD_PROFILE; } + final EmInput em = data.getEm().orElse(null); final boolean dsm = data.getBoolean(DSM); final ComparableQuantity eConsAnnual = data.getQuantity(E_CONS_ANNUAL, StandardUnits.ENERGY_IN); @@ -71,6 +73,7 @@ protected LoadInput buildModel( operationTime, node, qCharacteristics, + em, loadProfile, dsm, eConsAnnual, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/PvInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/PvInputFactory.java index 9812354e3..6cb13b79f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/PvInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/PvInputFactory.java @@ -5,29 +5,30 @@ */ package edu.ie3.datamodel.io.factory.input.participant; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.PvInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; +import java.util.UUID; import javax.measure.quantity.Angle; import javax.measure.quantity.Dimensionless; import javax.measure.quantity.Power; import tech.units.indriya.ComparableQuantity; public class PvInputFactory - extends SystemParticipantInputEntityFactory { + extends SystemParticipantInputEntityFactory { private static final String ALBEDO = "albedo"; private static final String AZIMUTH = "azimuth"; - private static final String ETA_CONV = "etaconv"; - private static final String ELEVATION_ANGLE = "elevationangle"; - private static final String KG = "kg"; - private static final String KT = "kt"; - private static final String MARKET_REACTION = "marketreaction"; - private static final String S_RATED = "srated"; - private static final String COS_PHI_RATED = "cosphirated"; + private static final String ETA_CONV = "etaConv"; + private static final String ELEVATION_ANGLE = "elevationAngle"; + private static final String KG = "kG"; + private static final String KT = "kT"; + private static final String MARKET_REACTION = "marketReaction"; + private static final String S_RATED = "sRated"; + private static final String COS_PHI_RATED = "cosPhiRated"; public PvInputFactory() { super(PvInput.class); @@ -42,13 +43,14 @@ protected String[] getAdditionalFields() { @Override protected PvInput buildModel( - NodeAssetInputEntityData data, - java.util.UUID uuid, + SystemParticipantEntityData data, + UUID uuid, String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); final double albedo = data.getDouble(ALBEDO); final ComparableQuantity azimuth = data.getQuantity(AZIMUTH, StandardUnits.AZIMUTH); final ComparableQuantity etaConv = @@ -68,6 +70,7 @@ protected PvInput buildModel( operationTime, node, qCharacteristics, + em, albedo, azimuth, etaConv, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactory.java index 04645c459..aea43ba85 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactory.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.StorageInput; @@ -35,7 +36,9 @@ protected StorageInput buildModel( ReactivePowerCharacteristic qCharacteristics, OperatorInput operator, OperationTime operationTime) { + final EmInput em = data.getEm().orElse(null); final StorageTypeInput typeInput = data.getTypeInput(); - return new StorageInput(uuid, id, operator, operationTime, node, qCharacteristics, typeInput); + return new StorageInput( + uuid, id, operator, operationTime, node, qCharacteristics, em, typeInput); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantEntityData.java new file mode 100644 index 000000000..971832be4 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantEntityData.java @@ -0,0 +1,113 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.factory.input.participant; + +import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; +import edu.ie3.datamodel.models.UniqueEntity; +import edu.ie3.datamodel.models.input.EmInput; +import edu.ie3.datamodel.models.input.NodeInput; +import edu.ie3.datamodel.models.input.OperatorInput; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +/** + * Data used for those classes of {@link + * edu.ie3.datamodel.models.input.system.SystemParticipantInput}, including an (optional) link to an + * {@link EmInput} entity. + */ +public class SystemParticipantEntityData extends NodeAssetInputEntityData { + + /** Energy management unit that is managing the system participant. Can be null. */ + private final EmInput em; + + /** + * Creates a new SystemParticipantEntityData object for an operated, always on system participant + * input + * + * @param fieldsToAttributes attribute map: field name to value + * @param entityClass class of the entity to be created with this data + * @param node input node + * @param em The energy management unit that is managing the system participant. Null, if the + * system participant is not managed. + */ + public SystemParticipantEntityData( + Map fieldsToAttributes, + Class entityClass, + NodeInput node, + EmInput em) { + super(fieldsToAttributes, entityClass, node); + this.em = em; + } + + public Optional getEm() { + return Optional.ofNullable(em); + } + + /** + * Creates a new SystemParticipantEntityData object for an operable system participant input + * + * @param fieldsToAttributes attribute map: field name to value + * @param entityClass class of the entity to be created with this data + * @param operator operator input + * @param node input node + * @param em The energy management unit that is managing the system participant. Null, if the + * system participant is not managed. + */ + public SystemParticipantEntityData( + Map fieldsToAttributes, + Class entityClass, + OperatorInput operator, + NodeInput node, + EmInput em) { + super(fieldsToAttributes, entityClass, operator, node); + this.em = em; + } + + /** + * Creates a new SystemParticipantEntityData object based on a given {@link + * NodeAssetInputEntityData} object and given energy management unit + * + * @param nodeAssetInputEntityData The node asset entity data object to use attributes of + * @param em The energy management unit that is managing the system participant. Null, if the + * system participant is not managed. + */ + public SystemParticipantEntityData( + NodeAssetInputEntityData nodeAssetInputEntityData, EmInput em) { + super(nodeAssetInputEntityData, nodeAssetInputEntityData.getNode()); + this.em = em; + } + + @Override + public String toString() { + return "SystemParticipantEntityData{" + + "em=" + + getEm().map(EmInput::toString).orElse("") + + ", node=" + + getNode().getUuid() + + ", operatorInput=" + + getOperatorInput().getUuid() + + ", fieldsToValues=" + + getFieldsToValues() + + ", targetClass=" + + getTargetClass() + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + SystemParticipantEntityData that = (SystemParticipantEntityData) o; + return getEm().equals(that.getEm()); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), getEm()); + } +} diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantInputEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantInputEntityFactory.java index 212f9db96..298bdfe92 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantInputEntityFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantInputEntityFactory.java @@ -26,21 +26,27 @@ * @version 0.1 * @since 28.01.20 */ -abstract class SystemParticipantInputEntityFactory< - T extends SystemParticipantInput, D extends NodeAssetInputEntityData> +public abstract class SystemParticipantInputEntityFactory< + T extends SystemParticipantInput, D extends SystemParticipantEntityData> extends AssetInputEntityFactory { - private static final String Q_CHARACTERISTICS = "qcharacteristics"; + private static final String Q_CHARACTERISTICS = "qCharacteristics"; + + public static final String EM = "em"; protected SystemParticipantInputEntityFactory(Class... allowedClasses) { super(allowedClasses); } @Override - protected List> getFields(D data) { - List> fields = super.getFields(data); + protected List> getFields(Class entityClass) { + List> fields = new ArrayList<>(super.getFields(entityClass)); for (Set set : fields) set.add(Q_CHARACTERISTICS); + List> withEm = fields.stream().map(f -> (Set) expandSet(f, EM)).toList(); + + fields.addAll(withEm); + return fields; } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantTypedEntityData.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantTypedEntityData.java index 5fcb3e00a..ab0bbe4b3 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantTypedEntityData.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/SystemParticipantTypedEntityData.java @@ -5,8 +5,8 @@ */ package edu.ie3.datamodel.io.factory.input.participant; -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.models.UniqueEntity; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.type.SystemParticipantTypeInput; @@ -22,7 +22,7 @@ * of the SystemParticipantInput */ public class SystemParticipantTypedEntityData - extends NodeAssetInputEntityData { + extends SystemParticipantEntityData { private final T typeInput; @@ -33,14 +33,17 @@ public class SystemParticipantTypedEntityData fieldsToAttributes, Class entityClass, NodeInput node, + EmInput em, T typeInput) { - super(fieldsToAttributes, entityClass, node); + super(fieldsToAttributes, entityClass, node, em); this.typeInput = typeInput; } @@ -52,6 +55,8 @@ public SystemParticipantTypedEntityData( * @param entityClass class of the entity to be created with this data * @param operator operator input * @param node input node + * @param em The energy management unit that is managing the system participant. Null, if the + * system participant is not managed. * @param typeInput type input */ public SystemParticipantTypedEntityData( @@ -59,16 +64,37 @@ public SystemParticipantTypedEntityData( Class entityClass, OperatorInput operator, NodeInput node, + EmInput em, T typeInput) { - super(fieldsToAttributes, entityClass, operator, node); + super(fieldsToAttributes, entityClass, operator, node, em); this.typeInput = typeInput; } + /** + * Creates a new SystemParticipantTypedEntityData object based on a given {@link + * SystemParticipantEntityData} object and given type input + * + * @param systemParticipantEntityData The system participant entity data object to use attributes + * of + * @param typeInput type input + */ + public SystemParticipantTypedEntityData( + SystemParticipantEntityData systemParticipantEntityData, T typeInput) { + super(systemParticipantEntityData, systemParticipantEntityData.getEm().orElse(null)); + this.typeInput = typeInput; + } + + public T getTypeInput() { + return typeInput; + } + @Override public String toString() { return "SystemParticipantTypedEntityData{" + "typeInput=" + typeInput.getUuid() + + ", em=" + + getEm().map(EmInput::toString).orElse("") + ", node=" + getNode().getUuid() + ", operatorInput=" @@ -93,8 +119,4 @@ public boolean equals(Object o) { public int hashCode() { return Objects.hash(super.hashCode(), getTypeInput()); } - - public T getTypeInput() { - return typeInput; - } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/WecInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/WecInputFactory.java index 83bbbdd43..5d8fbca71 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/input/participant/WecInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/input/participant/WecInputFactory.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.WecInput; @@ -16,7 +17,7 @@ public class WecInputFactory extends SystemParticipantInputEntityFactory< WecInput, SystemParticipantTypedEntityData> { - private static final String MARKET_REACTION = "marketreaction"; + private static final String MARKET_REACTION = "marketReaction"; public WecInputFactory() { super(WecInput.class); @@ -37,9 +38,10 @@ protected WecInput buildModel( OperatorInput operator, OperationTime operationTime) { WecTypeInput typeInput = data.getTypeInput(); + EmInput em = data.getEm().orElse(null); final boolean marketReaction = data.getBoolean(MARKET_REACTION); return new WecInput( - uuid, id, operator, operationTime, node, qCharacteristics, typeInput, marketReaction); + uuid, id, operator, operationTime, node, qCharacteristics, em, typeInput, marketReaction); } } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/ConnectorResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/ConnectorResultFactory.java index 9444350ab..16f5ee237 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/ConnectorResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/ConnectorResultFactory.java @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result; import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.result.connector.ConnectorResult; @@ -21,13 +21,13 @@ public class ConnectorResultFactory extends ResultEntityFactory { - private static final String IAMAG = "iamag"; - private static final String IAANG = "iaang"; - private static final String IBMAG = "ibmag"; - private static final String IBANG = "ibang"; - private static final String ICMAG = "icmag"; - private static final String ICANG = "icang"; - private static final String TAPPOS = "tappos"; + private static final String IAMAG = "iAMag"; + private static final String IAANG = "iAAng"; + private static final String IBMAG = "iBMag"; + private static final String IBANG = "iBAng"; + private static final String ICMAG = "iCMag"; + private static final String ICANG = "iCAng"; + private static final String TAPPOS = "tapPos"; public ConnectorResultFactory() { super(LineResult.class, Transformer2WResult.class, Transformer3WResult.class); @@ -44,12 +44,11 @@ public ConnectorResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData simpleEntityData) { + protected List> getFields(Class entityClass) { /// all result models have the same constructor except StorageResult Set minConstructorParams = newSet(TIME, INPUT_MODEL, IAMAG, IAANG, IBMAG, IBANG); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); - final Class entityClass = simpleEntityData.getTargetClass(); if (entityClass.equals(Transformer2WResult.class)) { minConstructorParams = newSet(TIME, INPUT_MODEL, IAMAG, IAANG, IBMAG, IBANG, TAPPOS); optionalFields = expandSet(minConstructorParams, ENTITY_UUID); @@ -63,7 +62,7 @@ protected List> getFields(SimpleEntityData simpleEntityData) { } @Override - protected ConnectorResult buildModel(SimpleEntityData data) { + protected ConnectorResult buildModel(EntityData data) { final Class entityClass = data.getTargetClass(); ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactory.java index 10ccfd1ba..76ef72988 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.result; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.result.system.FlexOptionsResult; import java.time.ZonedDateTime; @@ -15,9 +15,9 @@ public class FlexOptionsResultFactory extends ResultEntityFactory { - private static final String P_REF = "pref"; - private static final String P_MIN = "pmin"; - private static final String P_MAX = "pmax"; + private static final String P_REF = "pRef"; + private static final String P_MIN = "pMin"; + private static final String P_MAX = "pMax"; public FlexOptionsResultFactory() { super(FlexOptionsResult.class); @@ -34,7 +34,7 @@ public FlexOptionsResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet(TIME, INPUT_MODEL, P_REF, P_MIN, P_MAX); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); @@ -42,7 +42,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected FlexOptionsResult buildModel(SimpleEntityData data) { + protected FlexOptionsResult buildModel(EntityData data) { ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME)); UUID inputModelUuid = data.getUUID(INPUT_MODEL); ComparableQuantity pRef = data.getQuantity(P_REF, StandardUnits.ACTIVE_POWER_RESULT); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/NodeResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/NodeResultFactory.java index 9f4a9b016..0b75931d5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/NodeResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/NodeResultFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.result; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.result.NodeResult; import java.time.ZonedDateTime; @@ -15,8 +15,8 @@ import tech.units.indriya.ComparableQuantity; public class NodeResultFactory extends ResultEntityFactory { - private static final String VMAG = "vmag"; - private static final String VANG = "vang"; + private static final String VMAG = "vMag"; + private static final String VANG = "vAng"; public NodeResultFactory() { super(NodeResult.class); @@ -33,7 +33,7 @@ public NodeResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData entityData) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet(TIME, INPUT_MODEL, VMAG, VANG); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); @@ -41,7 +41,7 @@ protected List> getFields(SimpleEntityData entityData) { } @Override - protected NodeResult buildModel(SimpleEntityData data) { + protected NodeResult buildModel(EntityData data) { ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME)); UUID inputModelUuid = data.getUUID(INPUT_MODEL); ComparableQuantity vMagValue = diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/ResultEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/ResultEntityFactory.java index 15a815511..1b2bd2dc3 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/ResultEntityFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/ResultEntityFactory.java @@ -5,7 +5,8 @@ */ package edu.ie3.datamodel.io.factory.result; -import edu.ie3.datamodel.io.factory.SimpleEntityFactory; +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.util.TimeUtil; import java.time.ZoneId; @@ -18,7 +19,7 @@ * @version 0.1 * @since 11.02.20 */ -abstract class ResultEntityFactory extends SimpleEntityFactory { +abstract class ResultEntityFactory extends EntityFactory { protected static final String ENTITY_UUID = "uuid"; protected static final String TIME = "time"; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/SwitchResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/SwitchResultFactory.java index df24fe8ab..8d3f79252 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/SwitchResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/SwitchResultFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.result; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.result.connector.SwitchResult; import java.time.ZonedDateTime; import java.util.*; @@ -29,7 +29,7 @@ public SwitchResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet(TIME, INPUT_MODEL, CLOSED); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); @@ -38,7 +38,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected SwitchResult buildModel(SimpleEntityData data) { + protected SwitchResult buildModel(EntityData data) { Optional uuidOpt = data.containsKey(ENTITY_UUID) ? Optional.of(data.getUUID(ENTITY_UUID)) : Optional.empty(); ZonedDateTime time = timeUtil.toZonedDateTime(data.getField(TIME)); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactory.java index 62aa0dc03..717944687 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactory.java @@ -8,7 +8,7 @@ import static tech.units.indriya.unit.Units.PERCENT; import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.result.system.*; @@ -20,14 +20,14 @@ /** * Factory class for creating {@link SystemParticipantResult} entities from provided {@link - * SimpleEntityData} data objects. + * EntityData} data objects. */ public class SystemParticipantResultFactory extends ResultEntityFactory { private static final String POWER = "p"; private static final String REACTIVE_POWER = "q"; private static final String SOC = "soc"; - private static final String Q_DOT = "qdot"; + private static final String Q_DOT = "qDot"; public SystemParticipantResultFactory() { super( @@ -67,18 +67,17 @@ public SystemParticipantResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { /// all result models have the same constructor except StorageResult Set minConstructorParams = newSet(TIME, INPUT_MODEL, POWER, REACTIVE_POWER); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); - if (data.getTargetClass().equals(StorageResult.class) - || data.getTargetClass().equals(EvResult.class)) { + if (entityClass.equals(StorageResult.class) || entityClass.equals(EvResult.class)) { minConstructorParams = newSet(TIME, INPUT_MODEL, POWER, REACTIVE_POWER, SOC); optionalFields = expandSet(minConstructorParams, ENTITY_UUID); } - if (SystemParticipantWithHeatResult.class.isAssignableFrom(data.getTargetClass())) { + if (SystemParticipantWithHeatResult.class.isAssignableFrom(entityClass)) { minConstructorParams = expandSet(minConstructorParams, Q_DOT); optionalFields = expandSet(minConstructorParams, ENTITY_UUID); } @@ -87,7 +86,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected SystemParticipantResult buildModel(SimpleEntityData data) { + protected SystemParticipantResult buildModel(EntityData data) { Class entityClass = data.getTargetClass(); ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME)); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java index 2d3e2c77c..c43f6a268 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/result/ThermalResultFactory.java @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result; import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult; @@ -41,13 +41,13 @@ public ThermalResultFactory(String dtfPattern) { } @Override - protected List> getFields(SimpleEntityData simpleEntityData) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT); Set optionalFields = expandSet(minConstructorParams, ENTITY_UUID); - if (simpleEntityData.getTargetClass().equals(ThermalHouseResult.class)) { + if (entityClass.equals(ThermalHouseResult.class)) { minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT, INDOOR_TEMPERATURE); - } else if (simpleEntityData.getTargetClass().equals(CylindricalStorageResult.class)) { + } else if (entityClass.equals(CylindricalStorageResult.class)) { minConstructorParams = newSet(TIME, INPUT_MODEL, Q_DOT, ENERGY, FILL_LEVEL); } @@ -55,7 +55,7 @@ protected List> getFields(SimpleEntityData simpleEntityData) { } @Override - protected ThermalUnitResult buildModel(SimpleEntityData data) { + protected ThermalUnitResult buildModel(EntityData data) { Class clazz = data.getTargetClass(); ZonedDateTime zdtTime = timeUtil.toZonedDateTime(data.getField(TIME)); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactory.java index 18920df21..3dcb3e083 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactory.java @@ -20,10 +20,10 @@ public class CosmoIdCoordinateFactory extends IdCoordinateFactory { private static final String TID = "tid"; private static final String COORDINATE_ID = "id"; - private static final String LONG_GEO = "longgeo"; - private static final String LAT_GEO = "latgeo"; - private static final String LONG_ROT = "longrot"; - private static final String LAT_ROT = "latrot"; + private static final String LONG_GEO = "longGeo"; + private static final String LAT_GEO = "latGeo"; + private static final String LONG_ROT = "longRot"; + private static final String LAT_ROT = "latRot"; @Override protected Pair buildModel(SimpleFactoryData data) { @@ -34,7 +34,7 @@ protected Pair buildModel(SimpleFactoryData data) { } @Override - protected List> getFields(SimpleFactoryData data) { + protected List> getFields(Class entityClass) { return Collections.singletonList( newSet(TID, COORDINATE_ID, LONG_GEO, LAT_GEO, LONG_ROT, LAT_ROT)); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java index a95affade..f8d267187 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactory.java @@ -26,11 +26,11 @@ * value mapping in the typical PowerSystemDataModel (PSDM) column scheme */ public class CosmoTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { - private static final String DIFFUSE_IRRADIANCE = "diffuseirradiance"; - private static final String DIRECT_IRRADIANCE = "directirradiance"; + private static final String DIFFUSE_IRRADIANCE = "diffuseIrradiance"; + private static final String DIRECT_IRRADIANCE = "directIrradiance"; private static final String TEMPERATURE = "temperature"; - private static final String WIND_DIRECTION = "winddirection"; - private static final String WIND_VELOCITY = "windvelocity"; + private static final String WIND_DIRECTION = "windDirection"; + private static final String WIND_VELOCITY = "windVelocity"; public CosmoTimeBasedWeatherValueFactory(TimeUtil timeUtil) { super(timeUtil); @@ -50,11 +50,10 @@ public String getTimeFieldString() { } @Override - protected List> getFields(TimeBasedWeatherValueData data) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet( - UUID, - TIME, + COORDINATE_ID, DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactory.java index 454c73157..39843178c 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactory.java @@ -21,7 +21,7 @@ public class IconIdCoordinateFactory extends IdCoordinateFactory { private static final String COORDINATE_ID = "id"; private static final String LONG = "longitude"; private static final String LAT = "latitude"; - private static final String TYPE = "coordinatetype"; + private static final String TYPE = "coordinateType"; @Override protected Pair buildModel(SimpleFactoryData data) { @@ -32,7 +32,7 @@ protected Pair buildModel(SimpleFactoryData data) { } @Override - protected List> getFields(SimpleFactoryData data) { + protected List> getFields(Class entityClass) { return Collections.singletonList(newSet(COORDINATE_ID, LAT, LONG, TYPE)); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java index 1949bb2db..1181963be 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/IconTimeBasedWeatherValueFactory.java @@ -24,7 +24,7 @@ /** * Factory implementation of {@link TimeBasedWeatherValueFactory}, that is able to handle field to - * value mapping in the column scheme, ie3 uses to store it's data from German Federal + * value mapping in the column scheme, ie3 uses to store its data from German Federal * Weather Service's ICON-EU model */ public class IconTimeBasedWeatherValueFactory extends TimeBasedWeatherValueFactory { @@ -53,21 +53,16 @@ public String getTimeFieldString() { } @Override - protected List> getFields(TimeBasedWeatherValueData data) { + protected List> getFields(Class entityClass) { Set minParameters = newSet( - TIME, - DIFFUSE_IRRADIANCE, - DIRECT_IRRADIANCE, - TEMPERATURE, - WIND_VELOCITY_U, - WIND_VELOCITY_V); + DIFFUSE_IRRADIANCE, DIRECT_IRRADIANCE, TEMPERATURE, WIND_VELOCITY_U, WIND_VELOCITY_V); Set allParameters = expandSet( minParameters, "albrad", "asobs", - "aswdifus", + "aswdifuS", "tG", "u10m", "u20m", diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/SqlIdCoordinateFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/SqlIdCoordinateFactory.java index fb1d053f2..141d8dfd5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/SqlIdCoordinateFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/SqlIdCoordinateFactory.java @@ -39,7 +39,7 @@ protected Pair buildModel(SimpleFactoryData data) { } @Override - protected List> getFields(SimpleFactoryData data) { + protected List> getFields(Class entityClass) { return Collections.singletonList(newSet(COORDINATE_ID, COORDINATE)); } diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactory.java index f71a00940..243c3986f 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactory.java @@ -25,7 +25,7 @@ public class TimeBasedSimpleValueFactory /* Energy / Power */ private static final String ACTIVE_POWER = "p"; private static final String REACTIVE_POWER = "q"; - private static final String HEAT_DEMAND = "heatdemand"; + private static final String HEAT_DEMAND = "heatDemand"; private final TimeUtil timeUtil; @@ -87,24 +87,24 @@ protected TimeBasedValue buildModel(SimpleTimeBasedValueData data) { } @Override - protected List> getFields(SimpleTimeBasedValueData data) { + protected List> getFields(Class entityClass) { Set minConstructorParams = newSet(UUID, TIME); - if (EnergyPriceValue.class.isAssignableFrom(data.getTargetClass())) { + if (EnergyPriceValue.class.isAssignableFrom(entityClass)) { minConstructorParams.add(PRICE); - } else if (HeatAndSValue.class.isAssignableFrom(data.getTargetClass())) { + } else if (HeatAndSValue.class.isAssignableFrom(entityClass)) { minConstructorParams.addAll(Arrays.asList(ACTIVE_POWER, REACTIVE_POWER, HEAT_DEMAND)); - } else if (HeatAndPValue.class.isAssignableFrom(data.getTargetClass())) { + } else if (HeatAndPValue.class.isAssignableFrom(entityClass)) { minConstructorParams.addAll(Arrays.asList(ACTIVE_POWER, HEAT_DEMAND)); - } else if (HeatDemandValue.class.isAssignableFrom(data.getTargetClass())) { + } else if (HeatDemandValue.class.isAssignableFrom(entityClass)) { minConstructorParams.add(HEAT_DEMAND); - } else if (SValue.class.isAssignableFrom(data.getTargetClass())) { + } else if (SValue.class.isAssignableFrom(entityClass)) { minConstructorParams.addAll(Arrays.asList(ACTIVE_POWER, REACTIVE_POWER)); - } else if (PValue.class.isAssignableFrom(data.getTargetClass())) { + } else if (PValue.class.isAssignableFrom(entityClass)) { minConstructorParams.add(ACTIVE_POWER); } else { throw new FactoryException( - "The given factory cannot handle target class '" + data.getTargetClass() + "'."); + "The given factory cannot handle target class '" + entityClass + "'."); } return Collections.singletonList(minConstructorParams); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedWeatherValueFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedWeatherValueFactory.java index 4ad3b3348..254de4a74 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedWeatherValueFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeBasedWeatherValueFactory.java @@ -18,7 +18,7 @@ public abstract class TimeBasedWeatherValueFactory extends TimeBasedValueFactory { protected static final String UUID = "uuid"; protected static final String TIME = "time"; - protected static final String COORDINATE_ID = "coordinateid"; + protected static final String COORDINATE_ID = "coordinateId"; protected final TimeUtil timeUtil; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMappingFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMappingFactory.java index 64aa90af4..eec8c1ab5 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMappingFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMappingFactory.java @@ -5,8 +5,8 @@ */ package edu.ie3.datamodel.io.factory.timeseries; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; -import edu.ie3.datamodel.io.factory.SimpleEntityData; import edu.ie3.datamodel.io.source.TimeSeriesMappingSource; import java.util.Collections; import java.util.List; @@ -16,7 +16,7 @@ import java.util.stream.Stream; public class TimeSeriesMappingFactory - extends EntityFactory { + extends EntityFactory { private static final String UUID = "uuid"; private static final String PARTICIPANT = "participant"; private static final String TIME_SERIES = "timeSeries"; @@ -26,13 +26,13 @@ public TimeSeriesMappingFactory() { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { return Collections.singletonList( Stream.of(UUID, PARTICIPANT, TIME_SERIES).collect(Collectors.toSet())); } @Override - protected TimeSeriesMappingSource.MappingEntry buildModel(SimpleEntityData data) { + protected TimeSeriesMappingSource.MappingEntry buildModel(EntityData data) { UUID uuid = data.getUUID(UUID); UUID participant = data.getUUID(PARTICIPANT); UUID timeSeries = data.getUUID(TIME_SERIES); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMetaInformationFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMetaInformationFactory.java index fba7317a7..327f920eb 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMetaInformationFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/timeseries/TimeSeriesMetaInformationFactory.java @@ -5,8 +5,8 @@ */ package edu.ie3.datamodel.io.factory.timeseries; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; -import edu.ie3.datamodel.io.factory.SimpleEntityData; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; import edu.ie3.datamodel.io.naming.timeseries.IndividualTimeSeriesMetaInformation; import java.util.Collections; @@ -21,7 +21,7 @@ * mappings */ public class TimeSeriesMetaInformationFactory - extends EntityFactory { + extends EntityFactory { private static final String TIME_SERIES = "timeSeries"; private static final String COLUMN_SCHEME = "columnScheme"; @@ -30,13 +30,13 @@ public TimeSeriesMetaInformationFactory() { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { return Collections.singletonList( Stream.of(TIME_SERIES, COLUMN_SCHEME).collect(Collectors.toSet())); } @Override - protected IndividualTimeSeriesMetaInformation buildModel(SimpleEntityData data) { + protected IndividualTimeSeriesMetaInformation buildModel(EntityData data) { UUID timeSeries = data.getUUID(TIME_SERIES); ColumnScheme columnScheme = ColumnScheme.parse(data.getField(COLUMN_SCHEME)).orElseThrow(); return new IndividualTimeSeriesMetaInformation(timeSeries, columnScheme); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/AssetTypeInputEntityFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/AssetTypeInputEntityFactory.java index 13de960ee..a318f7621 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/AssetTypeInputEntityFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/AssetTypeInputEntityFactory.java @@ -5,7 +5,8 @@ */ package edu.ie3.datamodel.io.factory.typeinput; -import edu.ie3.datamodel.io.factory.SimpleEntityFactory; +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.models.input.AssetTypeInput; /** @@ -17,7 +18,7 @@ * @since 11.02.20 */ abstract class AssetTypeInputEntityFactory - extends SimpleEntityFactory { + extends EntityFactory { protected static final String ENTITY_UUID = "uuid"; protected static final String ENTITY_ID = "id"; diff --git a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactory.java index 609a11849..504d0f09c 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.typeinput; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.connector.type.LineTypeInput; import edu.ie3.util.quantities.interfaces.SpecificConductance; @@ -23,22 +23,22 @@ public class LineTypeInputFactory extends AssetTypeInputEntityFactory> getFields(SimpleEntityData entityData) { + protected List> getFields(Class entityClass) { Set constructorParams = newSet(ENTITY_UUID, ENTITY_ID, B, G, R, X, I_MAX, V_RATED); return Collections.singletonList(constructorParams); } @Override - protected LineTypeInput buildModel(SimpleEntityData data) { + protected LineTypeInput buildModel(EntityData data) { UUID uuid = data.getUUID(ENTITY_UUID); String id = data.getField(ENTITY_ID); ComparableQuantity b = diff --git a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactory.java index e0aa91bdf..014d7c69b 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactory.java @@ -7,7 +7,7 @@ import edu.ie3.datamodel.exceptions.FactoryException; import edu.ie3.datamodel.exceptions.ParsingException; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput; import edu.ie3.datamodel.models.input.system.type.*; @@ -27,35 +27,35 @@ public class SystemParticipantTypeInputFactory // SystemParticipantTypeInput parameters private static final String CAP_EX = "capex"; private static final String OP_EX = "opex"; - private static final String S_RATED = "srated"; - private static final String COS_PHI_RATED = "cosphirated"; + private static final String S_RATED = "sRated"; + private static final String COS_PHI_RATED = "cosPhiRated"; // required in multiple types - private static final String ETA_CONV = "etaconv"; - private static final String P_THERMAL = "pthermal"; - private static final String E_STORAGE = "estorage"; + private static final String ETA_CONV = "etaConv"; + private static final String P_THERMAL = "pThermal"; + private static final String E_STORAGE = "eStorage"; // EvTypeInput - private static final String E_CONS = "econs"; + private static final String E_CONS = "eCons"; // BmTypeInput - private static final String ACTIVE_POWER_GRADIENT = "activepowergradient"; + private static final String ACTIVE_POWER_GRADIENT = "activePowerGradient"; // WecTypeInput - private static final String ROTOR_AREA = "rotorarea"; - private static final String HUB_HEIGHT = "hubheight"; + private static final String ROTOR_AREA = "rotorArea"; + private static final String HUB_HEIGHT = "hubHeight"; // ChpTypeInput - private static final String ETA_EL = "etael"; - private static final String ETA_THERMAL = "etathermal"; - private static final String P_OWN = "pown"; + private static final String ETA_EL = "etaEl"; + private static final String ETA_THERMAL = "etaThermal"; + private static final String P_OWN = "pOwn"; // StorageTypeInput - private static final String P_MAX = "pmax"; + private static final String P_MAX = "pMax"; private static final String ETA = "eta"; private static final String DOD = "dod"; - private static final String LIFETIME = "lifetime"; - private static final String LIFECYCLE = "lifecycle"; + private static final String LIFETIME = "lifeTime"; + private static final String LIFECYCLE = "lifeCycle"; // WecTypeInput private static final String CP_CHARACTERISTIC = "cpCharacteristic"; @@ -71,24 +71,24 @@ public SystemParticipantTypeInputFactory() { } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set standardConstructorParams = newSet(ENTITY_UUID, ENTITY_ID, CAP_EX, OP_EX, S_RATED, COS_PHI_RATED); Set constructorParameters = null; - if (data.getTargetClass().equals(EvTypeInput.class)) { + if (entityClass.equals(EvTypeInput.class)) { constructorParameters = expandSet(standardConstructorParams, E_STORAGE, E_CONS); - } else if (data.getTargetClass().equals(HpTypeInput.class)) { + } else if (entityClass.equals(HpTypeInput.class)) { constructorParameters = expandSet(standardConstructorParams, P_THERMAL); - } else if (data.getTargetClass().equals(BmTypeInput.class)) { + } else if (entityClass.equals(BmTypeInput.class)) { constructorParameters = expandSet(standardConstructorParams, ACTIVE_POWER_GRADIENT, ETA_CONV); - } else if (data.getTargetClass().equals(WecTypeInput.class)) { + } else if (entityClass.equals(WecTypeInput.class)) { constructorParameters = expandSet(standardConstructorParams, CP_CHARACTERISTIC, ETA_CONV, ROTOR_AREA, HUB_HEIGHT); - } else if (data.getTargetClass().equals(ChpTypeInput.class)) { // into new file + } else if (entityClass.equals(ChpTypeInput.class)) { // into new file constructorParameters = expandSet(standardConstructorParams, ETA_EL, ETA_THERMAL, P_THERMAL, P_OWN); - } else if (data.getTargetClass().equals(StorageTypeInput.class)) { + } else if (entityClass.equals(StorageTypeInput.class)) { constructorParameters = expandSet( standardConstructorParams, @@ -105,7 +105,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected SystemParticipantTypeInput buildModel(SimpleEntityData data) { + protected SystemParticipantTypeInput buildModel(EntityData data) { UUID uuid = data.getUUID(ENTITY_UUID); String id = data.getField(ENTITY_ID); ComparableQuantity capEx = data.getQuantity(CAP_EX, StandardUnits.CAPEX); @@ -132,7 +132,7 @@ else if (data.getTargetClass().equals(StorageTypeInput.class)) } private SystemParticipantTypeInput buildEvTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, @@ -148,7 +148,7 @@ private SystemParticipantTypeInput buildEvTypeInput( } private SystemParticipantTypeInput buildHpTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, @@ -161,7 +161,7 @@ private SystemParticipantTypeInput buildHpTypeInput( } private SystemParticipantTypeInput buildBmTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, @@ -177,7 +177,7 @@ private SystemParticipantTypeInput buildBmTypeInput( } private SystemParticipantTypeInput buildWecTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, @@ -207,7 +207,7 @@ private SystemParticipantTypeInput buildWecTypeInput( } private SystemParticipantTypeInput buildChpTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, @@ -228,7 +228,7 @@ private SystemParticipantTypeInput buildChpTypeInput( } private SystemParticipantTypeInput buildStorageTypeInput( - SimpleEntityData data, + EntityData data, UUID uuid, String id, ComparableQuantity capEx, diff --git a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactory.java index a79236d49..8746d24d8 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.typeinput; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput; import java.util.Collections; @@ -17,26 +17,26 @@ public class Transformer2WTypeInputFactory extends AssetTypeInputEntityFactory { - private static final String R_SC = "rsc"; - private static final String X_SC = "xsc"; - private static final String S_RATED = "srated"; - private static final String V_RATED_A = "vrateda"; - private static final String V_RATED_B = "vratedb"; - private static final String G_M = "gm"; - private static final String B_M = "bm"; - private static final String D_V = "dv"; - private static final String D_PHI = "dphi"; - private static final String TAP_SIDE = "tapside"; - private static final String TAP_NEUTR = "tapneutr"; - private static final String TAP_MIN = "tapmin"; - private static final String TAP_MAX = "tapmax"; + private static final String R_SC = "rSc"; + private static final String X_SC = "xSc"; + private static final String S_RATED = "sRated"; + private static final String V_RATED_A = "vRatedA"; + private static final String V_RATED_B = "vRatedB"; + private static final String G_M = "gM"; + private static final String B_M = "bM"; + private static final String D_V = "dV"; + private static final String D_PHI = "dPhi"; + private static final String TAP_SIDE = "tapSide"; + private static final String TAP_NEUTR = "tapNeutr"; + private static final String TAP_MIN = "tapMin"; + private static final String TAP_MAX = "tapMax"; public Transformer2WTypeInputFactory() { super(Transformer2WTypeInput.class); } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set constructorParams = newSet( ENTITY_UUID, @@ -59,7 +59,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected Transformer2WTypeInput buildModel(SimpleEntityData data) { + protected Transformer2WTypeInput buildModel(EntityData data) { UUID uuid = data.getUUID(ENTITY_UUID); String id = data.getField(ENTITY_ID); ComparableQuantity rSc = data.getQuantity(R_SC, StandardUnits.RESISTANCE); diff --git a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactory.java b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactory.java index a51f2ec7b..5b45e0394 100644 --- a/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactory.java +++ b/src/main/java/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactory.java @@ -5,7 +5,7 @@ */ package edu.ie3.datamodel.io.factory.typeinput; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput; import java.util.Collections; @@ -17,32 +17,32 @@ public class Transformer3WTypeInputFactory extends AssetTypeInputEntityFactory { - private static final String S_RATED_A = "srateda"; - private static final String S_RATED_B = "sratedb"; - private static final String S_RATED_C = "sratedc"; - private static final String V_RATED_A = "vrateda"; - private static final String V_RATED_B = "vratedb"; - private static final String V_RATED_C = "vratedc"; - private static final String R_SC_A = "rsca"; - private static final String R_SC_B = "rscb"; - private static final String R_SC_C = "rscc"; - private static final String X_SC_A = "xsca"; - private static final String X_SC_B = "xscb"; - private static final String X_SC_C = "xscc"; - private static final String G_M = "gm"; - private static final String B_M = "bm"; - private static final String D_V = "dv"; - private static final String D_PHI = "dphi"; - private static final String TAP_NEUTR = "tapneutr"; - private static final String TAP_MIN = "tapmin"; - private static final String TAP_MAX = "tapmax"; + private static final String S_RATED_A = "sRatedA"; + private static final String S_RATED_B = "sRatedB"; + private static final String S_RATED_C = "sRatedC"; + private static final String V_RATED_A = "vRatedA"; + private static final String V_RATED_B = "vRatedB"; + private static final String V_RATED_C = "vRatedC"; + private static final String R_SC_A = "rScA"; + private static final String R_SC_B = "rScB"; + private static final String R_SC_C = "rScC"; + private static final String X_SC_A = "xScA"; + private static final String X_SC_B = "xScB"; + private static final String X_SC_C = "xScC"; + private static final String G_M = "gM"; + private static final String B_M = "bM"; + private static final String D_V = "dV"; + private static final String D_PHI = "dPhi"; + private static final String TAP_NEUTR = "tapNeutr"; + private static final String TAP_MIN = "tapMin"; + private static final String TAP_MAX = "tapMax"; public Transformer3WTypeInputFactory() { super(Transformer3WTypeInput.class); } @Override - protected List> getFields(SimpleEntityData data) { + protected List> getFields(Class entityClass) { Set constructorParams = newSet( ENTITY_UUID, @@ -71,7 +71,7 @@ protected List> getFields(SimpleEntityData data) { } @Override - protected Transformer3WTypeInput buildModel(SimpleEntityData data) { + protected Transformer3WTypeInput buildModel(EntityData data) { UUID uuid = data.getUUID(ENTITY_UUID); String id = data.getField(ENTITY_ID); ComparableQuantity sRatedA = data.getQuantity(S_RATED_A, StandardUnits.S_RATED); diff --git a/src/main/java/edu/ie3/datamodel/io/processor/Processor.java b/src/main/java/edu/ie3/datamodel/io/processor/Processor.java index 86bdcaf5c..d6438dfef 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/Processor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/Processor.java @@ -8,7 +8,6 @@ import edu.ie3.datamodel.exceptions.EntityProcessorException; import edu.ie3.datamodel.io.factory.input.NodeInputFactory; import edu.ie3.datamodel.io.processor.result.ResultEntityProcessor; -import edu.ie3.datamodel.models.ControlStrategy; import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; import edu.ie3.datamodel.models.UniqueEntity; @@ -238,10 +237,12 @@ protected String processMethodResult(Object methodReturnObject, Method method, S ((Optional) methodReturnObject) .map( o -> { - if (o instanceof Quantity) { + if (o instanceof Quantity quantity) { return Try.of( - () -> handleQuantity((Quantity) o, fieldName), + () -> handleQuantity(quantity, fieldName), EntityProcessorException.class); + } else if (o instanceof UniqueEntity entity) { + return Try.of(entity::getUuid, EntityProcessorException.class); } else { return Failure.of( new EntityProcessorException( @@ -276,8 +277,8 @@ protected String processMethodResult(Object methodReturnObject, Method method, S "TimeSeries", "Transformer2WTypeInput", "Transformer3WTypeInput", - "WecTypeInput" -> resultStringBuilder.append( - ((UniqueEntity) methodReturnObject).getUuid()); + "WecTypeInput", + "EmInput" -> resultStringBuilder.append(((UniqueEntity) methodReturnObject).getUuid()); case "OperatorInput" -> resultStringBuilder.append( ((OperatorInput) methodReturnObject).getId().equalsIgnoreCase("NO_OPERATOR_ASSIGNED") ? "" @@ -291,9 +292,6 @@ protected String processMethodResult(Object methodReturnObject, Method method, S "ReactivePowerCharacteristic", "CharacteristicInput" -> resultStringBuilder.append( ((CharacteristicInput) methodReturnObject).serialize()); - case "UUID[]" -> resultStringBuilder.append(processUUIDArray((UUID[]) methodReturnObject)); - case "ControlStrategy" -> resultStringBuilder.append( - ((ControlStrategy) methodReturnObject).getKey()); default -> throw new EntityProcessorException( "Unable to process value for attribute/field '" + fieldName @@ -374,12 +372,6 @@ protected String handleQuantity(Quantity quantity, String fieldName) protected abstract Try handleProcessorSpecificQuantity( Quantity quantity, String fieldName); - protected String processUUIDArray(UUID[] uuids) { - StringBuilder strb = new StringBuilder(); - for (UUID uuid : uuids) strb.append(uuid.toString()).append(" "); - return strb.toString().strip(); - } - /** * Handling of elements of type {@link OperationTime} * diff --git a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java index 398f404aa..971a81d22 100644 --- a/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java +++ b/src/main/java/edu/ie3/datamodel/io/processor/input/InputEntityProcessor.java @@ -23,7 +23,7 @@ import java.util.List; /** - * Processes all {@link InputEntity}s and it's child classes + * Processes all {@link InputEntity}s and its child classes * * @version 0.1 * @since 23.03.20 diff --git a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java index da67f99a0..530818677 100644 --- a/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java +++ b/src/main/java/edu/ie3/datamodel/io/sink/CsvFileSink.java @@ -170,7 +170,7 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants(); Set bmPlants = systemParticipants.getBmPlants(); Set chpPlants = systemParticipants.getChpPlants(); - Set evCS = systemParticipants.getEvCS(); + Set evcs = systemParticipants.getEvcs(); Set evs = systemParticipants.getEvs(); Set fixedFeedIns = systemParticipants.getFixedFeedIns(); Set heatPumps = systemParticipants.getHeatPumps(); @@ -178,7 +178,6 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { Set pvPlants = systemParticipants.getPvPlants(); Set storages = systemParticipants.getStorages(); Set wecPlants = systemParticipants.getWecPlants(); - Set emSystems = systemParticipants.getEmSystems(); // get graphic elements (just for better readability, we could also just get them directly // below) @@ -211,15 +210,14 @@ public void persistJointGrid(JointGridContainer jointGridContainer) { measurementUnits, bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, loads, pvPlants, storages, - wecPlants, - emSystems) + wecPlants) .flatMap(Collection::stream) .map(Extractor::extractOperator) .flatMap(Optional::stream) diff --git a/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java b/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java index 7c2f7b9f8..157ec6013 100644 --- a/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java +++ b/src/main/java/edu/ie3/datamodel/io/sink/InfluxDbSink.java @@ -155,7 +155,7 @@ private , V extends Value> Set transformToPo String valueClassName = timeSeries.getEntries().iterator().next().getValue().getClass().getSimpleName(); log.warn( - "I could not get a measurement name for TimeSeries value class {}. I am using it's value's simple name instead.", + "I could not get a measurement name for TimeSeries value class {}. I am using its value's simple name instead.", valueClassName); return transformToPoints(timeSeries, valueClassName); } diff --git a/src/main/java/edu/ie3/datamodel/io/source/DataSource.java b/src/main/java/edu/ie3/datamodel/io/source/DataSource.java index 0687e9e50..f05c0ae38 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/DataSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/DataSource.java @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.source; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.models.UniqueEntity; import java.util.*; import java.util.stream.Stream; @@ -12,6 +13,16 @@ /** Interface that include functionalities for data sources in the database table, csv file etc. */ public interface DataSource { + /** + * Method to retrieve the fields found in the source. + * + * @param entityClass class of the source + * @return an option for the found fields + */ + Optional> getSourceFields(Class entityClass) + throws SourceException; + /** Creates a stream of maps that represent the rows in the database */ - Stream> getSourceData(Class entityClass); + Stream> getSourceData(Class entityClass) + throws SourceException; } diff --git a/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java b/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java new file mode 100644 index 000000000..acca23634 --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/source/EnergyManagementSource.java @@ -0,0 +1,202 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.source; + +import static edu.ie3.datamodel.io.factory.input.participant.EmInputFactory.PARENT_EM; + +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData; +import edu.ie3.datamodel.io.factory.input.EmAssetInputEntityData; +import edu.ie3.datamodel.io.factory.input.participant.EmInputFactory; +import edu.ie3.datamodel.models.input.EmInput; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.datamodel.utils.Try; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class EnergyManagementSource extends EntitySource { + + private final TypeSource typeSource; + + private static final EmInputFactory emInputFactory = new EmInputFactory(); + + public EnergyManagementSource(TypeSource typeSource, DataSource dataSource) { + super(dataSource); + this.typeSource = typeSource; + } + + @Override + public void validate() throws ValidationException { + validate(EmInput.class, emInputFactory).getOrThrow(); + } + + /** + * Returns a unique set of {@link EmInput} instances. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as + * {@link EmInput#equals(Object)} is NOT restricted on the UUID of {@link EmInput}. + * + * @return a map of UUID to {@link EmInput} entities + */ + public Map getEmUnits() throws SourceException { + Map operators = typeSource.getOperators(); + return getEmUnits(operators); + } + + /** + * This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as + * {@link EmInput#equals(Object)} is NOT restricted on the UUID of {@link EmInput}. + * + *

In contrast to {@link #getEmUnits()} this method provides the ability to pass in an already + * existing set of {@link OperatorInput} entities, the {@link EmInput} instances depend on. Doing + * so, already loaded nodes can be recycled to improve performance and prevent unnecessary loading + * operations. + * + *

If something fails during the creation process a {@link SourceException} is thrown, else a + * set with all entities that has been able to be build is returned. + * + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @return a map of UUID to {@link EmInput} entities + */ + public Map getEmUnits(Map operators) throws SourceException { + return createEmInputs(buildAssetInputEntityData(EmInput.class, operators)); + } + + /** + * Since each EM can itself be controlled by another EM, it does not suffice to link {@link + * EmInput}s via {@link EntitySource#optionallyEnrichEntityData} as we do for system participants + * in {@link SystemParticipantSource}. Instead, we use a recursive approach, starting with EMs at + * root level (which are not EM-controlled themselves). + * + * @param assetEntityDataStream the data stream of {@link AssetInputEntityData} {@link Try} + * objects + * @return a map of UUID to {@link EmInput} entities + */ + private static Map createEmInputs( + Stream> assetEntityDataStream) + throws SourceException { + + // Split stream by failures and EMs that are themselves EM-controlled on one side, and EMs at + // root position (that have not failed so far) on the other side, which do not have parents per + // definition. + Map>> split = + assetEntityDataStream.collect( + Collectors.partitioningBy( + dataTry -> + dataTry + .map( + data -> + data.containsKey(PARENT_EM) && !data.getField(PARENT_EM).isBlank()) + .getOrElse(() -> true))); + + List> rootEmsEntityData = split.get(false); + List> others = split.get(true); + + // at the start, this is only root ems + Map allEms = + unpackMap( + rootEmsEntityData.stream() + .parallel() + .map( + entityDataTry -> + entityDataTry.map( + entityData -> new EmAssetInputEntityData(entityData, null))) + .map(emInputFactory::get), + EmInput.class); + + if (!others.isEmpty()) { + // there's more EM levels beyond root level. Build them recursively + Stream othersWithParentUuid = + // We try to keep the Tries as long as possible so that as many failures as possible can + // be reported. At this point however, we need to "unpack" (and throw, if applicable), + // because without valid parent EM UUID, we cannot proceed. + unpack( + others.stream() + .map( + dataTry -> + dataTry.flatMap( + data -> { + // we already filtered out those entities that do not have a parent, + // so the field should exist + String uuidString = data.getField(PARENT_EM); + return Try.of( + () -> UUID.fromString(uuidString), + IllegalArgumentException.class) + .transformF( + iae -> + new SourceException( + String.format( + "Exception while trying to parse UUID of field \"%s\" with value \"%s\"", + PARENT_EM, uuidString), + iae)) + // failed UUID parses are filtered out at this point. We save + // the parsed UUID with the asset data + .map( + parentUuid -> + new AssetDataAndValidParentUuid(data, parentUuid)); + })), + AssetDataAndValidParentUuid.class); + + allEms.putAll(createHierarchicalEmInputs(othersWithParentUuid, allEms)); + } + + return allEms; + } + + private static Map createHierarchicalEmInputs( + Stream assetEntityDataStream, Map lastLevelEms) + throws SourceException { + + // Split stream by assets whose parent is already built (which can be built at this level), and + // those whose parents are not built yet (which have to be built at some lower recursion level + // or not at all) + Map> split = + assetEntityDataStream.collect( + Collectors.partitioningBy(data -> lastLevelEms.containsKey(data.parentEm))); + + List toBeBuiltAtThisLevel = split.get(true); + List toBeBuiltAtNextLevel = split.get(false); + + if (toBeBuiltAtThisLevel.isEmpty()) { + // Since we only start a new recursion step if the asset data stream is not empty, there have + // to be EMs to be built at next level. This does not work if there's no EMs at the current + // recursion level. + throw new SourceException( + "EMs " + toBeBuiltAtNextLevel + " were assigned a parent EM that does not exist."); + } else { + // New EMs can be built at this level + Map newEms = + unpackMap( + toBeBuiltAtThisLevel.stream() + .map( + data -> { + // exists because we checked above + EmInput parentEm = lastLevelEms.get(data.parentEm); + return emInputFactory.get( + new EmAssetInputEntityData(data.entityData, parentEm)); + }), + EmInput.class); + + if (!toBeBuiltAtNextLevel.isEmpty()) { + // If there's more EMs left to build, the new EMs have to function as parents there + newEms.putAll(createHierarchicalEmInputs(toBeBuiltAtNextLevel.stream(), newEms)); + } + return newEms; + } + } + + /** + * Helper data record that holds an {@link AssetInputEntityData} and the UUID successfully parsed + * from {@link EmInputFactory#PARENT_EM} field + */ + private record AssetDataAndValidParentUuid(AssetInputEntityData entityData, UUID parentEm) {} +} diff --git a/src/main/java/edu/ie3/datamodel/io/source/EntitySource.java b/src/main/java/edu/ie3/datamodel/io/source/EntitySource.java index d1cfd5c70..e81ec101d 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/EntitySource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/EntitySource.java @@ -6,21 +6,23 @@ package edu.ie3.datamodel.io.source; import edu.ie3.datamodel.exceptions.FactoryException; +import edu.ie3.datamodel.exceptions.FailedValidationException; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.EntityFactory; -import edu.ie3.datamodel.io.factory.SimpleEntityData; import edu.ie3.datamodel.io.factory.input.AssetInputEntityData; -import edu.ie3.datamodel.io.factory.input.ConnectorInputEntityData; import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; -import edu.ie3.datamodel.io.factory.input.TypedConnectorInputEntityData; import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.input.*; -import edu.ie3.datamodel.models.result.ResultEntity; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.*; import java.util.*; +import java.util.function.BiFunction; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.apache.commons.lang3.function.TriFunction; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,208 +35,300 @@ public abstract class EntitySource { protected static final String OPERATOR = "operator"; protected static final String NODE = "node"; protected static final String TYPE = "type"; - protected static final String FIELDS_TO_VALUES_MAP = "fieldsToValuesMap"; - DataSource dataSource; + protected final DataSource dataSource; - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= - - protected String buildSkippingMessage( - String entityDesc, String entityUuid, String entityId, String missingElementsString) { - return "Skipping " - + entityDesc - + " with uuid " - + entityUuid - + " and id " - + entityId - + ". Not all required entities found or map is missing entity key!\nMissing elements:\n" - + missingElementsString; + protected EntitySource(DataSource dataSource) { + this.dataSource = dataSource; } - protected String safeMapGet(Map map, String key, String mapName) { - return Optional.ofNullable(map.get(key)) - .orElse( - "Key '" - + key - + "' not found" - + (mapName.isEmpty() ? "!" : " in map '" + mapName + "'!")); - } + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + public abstract void validate() throws ValidationException; /** - * Returns an {@link Optional} of the first {@link UniqueEntity} element of this collection - * matching the provided UUID or an empty {@code Optional} if no matching entity can be found. + * Method for validating a single source. * - * @param entityUuid uuid of the entity that should be looked for - * @param entities collection of entities that should be - * @param type of the entity that will be returned, derived from the provided collection - * @return either an optional containing the first entity that has the provided uuid or an empty - * optional if no matching entity with the provided uuid can be found + * @param entityClass class to be validated + * @param validator used to validate + * @param type of the class */ - protected Optional findFirstEntityByUuid( - UUID entityUuid, Collection entities) { - return entities.stream() - .parallel() - .filter(uniqueEntity -> uniqueEntity.getUuid().equals(entityUuid)) - .findFirst(); + protected final Try validate( + Class entityClass, SourceValidator validator) { + return Try.of(() -> dataSource.getSourceFields(entityClass), SourceException.class) + .transformF( + se -> + (ValidationException) + new FailedValidationException( + "Validation for entity " + + entityClass + + " failed because of an error related to its source.", + se)) + .flatMap( + fieldsOpt -> + fieldsOpt + .map(fields -> validator.validate(fields, entityClass)) + .orElse(Try.Success.empty())); } /** - * Checks if the requested type of asset can be found in the provided collection of types based on - * the provided fields to values mapping. The provided fields to values mapping needs to have one - * and only one field with key {@link #TYPE} and a corresponding UUID value. If the type can be - * found in the provided collection based on the UUID it is returned wrapped in a {@link Success}. - * Otherwise a {@link Failure} is returned and a warning is logged. + * Enhances given entity data with an entity from the given entity map. The linked entity is + * chosen by taking into account the UUID found by retrieving the field with given fieldName from + * entityData. * - * @param types a collection of types that should be used for searching - * @param fieldsToAttributes the field name to value mapping incl. the key {@link #TYPE} - * @param skippedClassString debug string of the class that will be skipping - * @param the type of the resulting type instance - * @return a {@link Success} containing the type or a {@link Failure} if the type cannot be found + * @param entityData The entity data to be enhanced, which also provides a link to another entity + * via UUID + * @param fieldName The field name of the field that provides the UUID of the linked entity + * @param linkedEntities A map of UUID to entities, of which one should be linked to given entity + * data + * @param createEntityData The function that creates the resulting entity data given entityData + * and the linked entity + * @param Type of input entity data + * @param Type of the linked entity + * @param Type of resulting entity data that combines the given entityData and linked entity + * @return {@link Try} to enhanced data */ - protected Try getAssetType( - Collection types, Map fieldsToAttributes, String skippedClassString) { + protected static + Try enrichEntityData( + E entityData, + String fieldName, + Map linkedEntities, + BiFunction createEntityData) { + return getLinkedEntity(entityData, fieldName, linkedEntities) + .map( + linkedEntity -> { + Map fieldsToAttributes = entityData.getFieldsToValues(); - Optional assetType = - Optional.ofNullable(fieldsToAttributes.get(TYPE)) - .flatMap(typeUuid -> findFirstEntityByUuid(UUID.fromString(typeUuid), types)); + // remove fields that are passed as objects to constructor + fieldsToAttributes.keySet().remove(fieldName); - // if the type is not present we return an empty element and - // log a warning - if (assetType.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - skippedClassString, - safeMapGet(fieldsToAttributes, "uuid", FIELDS_TO_VALUES_MAP), - safeMapGet(fieldsToAttributes, "id", FIELDS_TO_VALUES_MAP), - TYPE + ": " + safeMapGet(fieldsToAttributes, TYPE, FIELDS_TO_VALUES_MAP)); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - return new Success<>(assetType.get()); + // build resulting entity data + return createEntityData.apply(entityData, linkedEntity); + }); } /** - * Finds the required asset type and if present, adds it to the untyped entity data + * Enhances given entity data with two entities from the given entity maps. The linked entities + * are chosen by taking into account the UUIDs found by retrieving the fields with given + * fieldName1 and fieldName2 from entityData. * - * @param untypedEntityData Untyped entity data to enrich - * @param availableTypes Yet available asset types - * @param Type of the asset type + * @param entityData The entity data to be enhanced, which also provides links to two other + * entities via UUID + * @param fieldName1 The field name of the field that provides the UUID of the first linked entity + * @param linkedEntities1 The first map of UUID to entities, of which one should be linked to + * given entity data + * @param fieldName2 The field name of the field that provides the UUID of the second linked + * entity + * @param linkedEntities2 The second map of UUID to entities, of which one should be linked to + * given entity data + * @param createEntityData The function that creates the resulting entity data given entityData + * and the linked entities + * @param Type of input entity data + * @param Type of the first linked entity + * @param Type of the second linked entity + * @param Type of resulting entity data that combines the given entityData and two linked + * entities * @return {@link Try} to enhanced data */ - protected - Try, SourceException> findAndAddType( - ConnectorInputEntityData untypedEntityData, Collection availableTypes) { - Try assetTypeOption = - getAssetType( - availableTypes, - untypedEntityData.getFieldsToValues(), - untypedEntityData.getClass().getSimpleName()); - return assetTypeOption.map(assetType -> addTypeToEntityData(untypedEntityData, assetType)); + protected static < + E extends EntityData, T1 extends UniqueEntity, T2 extends UniqueEntity, R extends E> + Try enrichEntityData( + E entityData, + String fieldName1, + Map linkedEntities1, + String fieldName2, + Map linkedEntities2, + TriFunction createEntityData) { + return getLinkedEntity(entityData, fieldName1, linkedEntities1) + .flatMap( + linkedEntity1 -> + getLinkedEntity(entityData, fieldName2, linkedEntities2) + .map( + linkedEntity2 -> { + Map fieldsToAttributes = entityData.getFieldsToValues(); + + // remove fields that are passed as objects to constructor + fieldsToAttributes.keySet().remove(fieldName1); + fieldsToAttributes.keySet().remove(fieldName2); + + // build resulting entity data + return createEntityData.apply(entityData, linkedEntity1, linkedEntity2); + })); } /** - * Enriches the given, untyped entity data with the provided asset type + * Checks if the linked entity can be found in the provided map of entities. The linked entities + * are chosen by taking into account the UUIDs found by retrieving the fields with given + * fieldName1 and fieldName2 from entityData. * - * @param untypedEntityData Untyped entity data to enrich - * @param assetType Asset type to add - * @param Type of the asset type - * @return The enriched entity data + * @param entityData The entity data of the entity that provides a link to another entity via UUID + * @param fieldName The field name of the field that provides the UUID of the linked entity + * @param linkedEntities A map of UUID to entities, of which one should be linked to given entity + * data + * @param the type of the resulting linked entity instance + * @return a {@link Success} containing the entity or a {@link Failure} if the entity cannot be + * found */ - protected TypedConnectorInputEntityData addTypeToEntityData( - ConnectorInputEntityData untypedEntityData, T assetType) { - Map fieldsToAttributes = untypedEntityData.getFieldsToValues(); + protected static Try getLinkedEntity( + EntityData entityData, String fieldName, Map linkedEntities) { + + return Try.of(() -> entityData.getUUID(fieldName), FactoryException.class) + .transformF( + exception -> + new SourceException( + "Extracting UUID field " + + fieldName + + " from entity data " + + entityData.toString() + + " failed.", + exception)) + .flatMap( + entityUuid -> + getEntity(entityUuid, linkedEntities) + .transformF( + exception -> + new SourceException( + "Linked " + + fieldName + + " with UUID " + + entityUuid + + " was not found for entity " + + entityData, + exception))); + } - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(TYPE); + /** + * Enhances given entity data with an entity from the given entity map or the default value. The + * linked entity is possibly chosen by taking into account the UUID found by retrieving the field + * with given fieldName from entityData. If no entity is linked, the default value is used. + * + * @param entityData The entity data to be enhanced, which also might provide a link to another + * entity via UUID + * @param fieldName The field name of the field that might provide the UUID of the linked entity + * @param linkedEntities A map of UUID to entities, of which one should be linked to given entity + * data + * @param defaultEntity The default linked entity to use, if no actual linked entity could be + * found + * @param createEntityData The function that creates the resulting entity data given entityData + * and the linked entity (either retrieved from the map or the standard entity) + * @param Type of input entity data + * @param Type of the linked entity + * @param Type of resulting entity data that combines the given entityData and linked entity + * @return {@link Try} to enhanced data + */ + protected static + Try optionallyEnrichEntityData( + E entityData, + String fieldName, + Map linkedEntities, + T defaultEntity, + BiFunction createEntityData) { + return entityData + .getFieldOptional(fieldName) + .filter(s -> !s.isBlank()) + .map( + // Entity data includes a non-empty UUID String for the desired entity + uuidString -> + Try.of(() -> UUID.fromString(uuidString), IllegalArgumentException.class) + .transformF( + iae -> + // Parsing error still results in a failure, ... + new SourceException( + String.format( + "Exception while trying to parse UUID of field \"%s\" with value \"%s\"", + fieldName, uuidString), + iae)) + .flatMap( + entityUuid -> + getEntity(entityUuid, linkedEntities) + // ... as well as a provided entity UUID that does not match any + // given data + .transformF( + exception -> + new SourceException( + "Linked " + + fieldName + + " with UUID " + + entityUuid + + " was not found for entity " + + entityData, + exception)))) + .orElseGet( + () -> { + // No UUID was given (column does not exist, or field is empty). + // This is totally fine - we successfully return the default value + log.debug( + "Input source for class {} is missing the '{}' field. " + + "Default value '{}' is used.", + entityData.getTargetClass().getSimpleName(), + fieldName, + defaultEntity); + return new Try.Success<>(defaultEntity); + }) + .map( + linkedEntity -> { + Map fieldsToAttributes = entityData.getFieldsToValues(); - // build result object - return new TypedConnectorInputEntityData<>( - fieldsToAttributes, - untypedEntityData.getTargetClass(), - untypedEntityData.getOperatorInput(), - untypedEntityData.getNodeA(), - untypedEntityData.getNodeB(), - assetType); + // remove fields that are passed as objects to constructor + fieldsToAttributes.keySet().remove(fieldName); + + // build resulting entity data + return createEntityData.apply(entityData, linkedEntity); + }); } + private static Try getEntity(UUID uuid, Map entityMap) { + return Optional.ofNullable(entityMap.get(uuid)) + // We either find a matching entity for given UUID, thus return a success + .map(entity -> Try.of(() -> entity, SourceException.class)) + // ... or find no matching entity, returning a failure. + .orElse( + new Try.Failure<>( + new SourceException("Entity with uuid " + uuid + " was not provided."))); + } + + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /** - * Returns either the first instance of a {@link OperatorInput} in the provided collection of or - * {@link OperatorInput#NO_OPERATOR_ASSIGNED} + * Returns a stream of {@link Try} entities that can be built by using {@link + * NodeAssetInputEntityData} and their corresponding factory. * - * @param operators the collections of {@link OperatorInput}s that should be searched in - * @param operatorUuid the operator uuid that is requested - * @return either the first found instancen of {@link OperatorInput} or {@link - * OperatorInput#NO_OPERATOR_ASSIGNED} + * @param entityClass the entity class that should be build + * @param nodes a map of UUID to {@link NodeInput} entities that should be used to build the + * entities + * @param operators a map of UUID to {@link OperatorInput} entities should be used to build the + * entities + * @return stream of tries of the entities that has been built by the factory */ - protected OperatorInput getFirstOrDefaultOperator( - Collection operators, - Optional operatorUuid, - String entityClassName, - String requestEntityUuid) { - if (operatorUuid.isEmpty()) { - log.warn( - "Input source for class '{}' is missing the 'operator' field. " - + "This is okay, but you should consider fixing the file by adding the field. " - + "Defaulting to 'NO OPERATOR ASSIGNED'", - entityClassName); - return OperatorInput.NO_OPERATOR_ASSIGNED; - } else { - return findFirstEntityByUuid(operatorUuid.get(), operators) - .orElseGet( - () -> { - log.debug( - "Cannot find operator with uuid '{}' for element '{}' and uuid '{}'. Defaulting to 'NO OPERATOR ASSIGNED'.", - operatorUuid, - entityClassName, - requestEntityUuid); - return OperatorInput.NO_OPERATOR_ASSIGNED; - }); - } + protected Stream> buildNodeAssetEntityData( + Class entityClass, + Map operators, + Map nodes) { + return nodeAssetInputEntityDataStream(buildAssetInputEntityData(entityClass, operators), nodes); } /** * Returns a stream of tries of {@link NodeAssetInputEntityData} that can be used to build * instances of several subtypes of {@link UniqueEntity} by a corresponding {@link EntityFactory} - * that consumes this data. param assetInputEntityDataStream + * that consumes this data. * * @param assetInputEntityDataStream a stream consisting of {@link AssetInputEntityData} that is * enriched with {@link NodeInput} data - * @param nodes a collection of {@link NodeInput} entities that should be used to build the data + * @param nodes a map of UUID to {@link NodeInput} entities that should be used to build the data * @return stream of the entity data wrapped in a {@link Try} */ - protected Stream> nodeAssetInputEntityDataStream( - Stream assetInputEntityDataStream, Collection nodes) { + protected static Stream> + nodeAssetInputEntityDataStream( + Stream> assetInputEntityDataStream, + Map nodes) { return assetInputEntityDataStream .parallel() .map( - assetInputEntityData -> { - // get the raw data - Map fieldsToAttributes = assetInputEntityData.getFieldsToValues(); - // get the node of the entity - UUID nodeUuid = UUID.fromString(fieldsToAttributes.get(NODE)); - Optional node = findFirstEntityByUuid(nodeUuid, nodes); - - // if the node is not present we return an empty element and - // log a warning - if (node.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - assetInputEntityData.getTargetClass().getSimpleName(), - fieldsToAttributes.get("uuid"), - fieldsToAttributes.get("id"), - NODE + ": " + nodeUuid); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(NODE); - - return new Success<>( - new NodeAssetInputEntityData( - fieldsToAttributes, - assetInputEntityData.getTargetClass(), - assetInputEntityData.getOperatorInput(), - node.get())); - }); + assetInputEntityDataTry -> + assetInputEntityDataTry.flatMap( + assetInputEntityData -> + enrichEntityData( + assetInputEntityData, NODE, nodes, NodeAssetInputEntityData::new))); } /** @@ -243,115 +337,78 @@ protected Stream> nodeAssetInputE * consumes this data. * * @param entityClass the entity class that should be build - * @param operators a collection of {@link OperatorInput} entities that should be used to build + * @param operators a map of UUID to {@link OperatorInput} entities that should be used to build * the data - * @param type of the entity that should be build * @return stream of the entity data wrapped in a {@link Try} */ - protected Stream assetInputEntityDataStream( - Class entityClass, Collection operators) { - return dataSource - .getSourceData(entityClass) - .map( - fieldsToAttributes -> - assetInputEntityDataStream(entityClass, fieldsToAttributes, operators)); - } - - protected AssetInputEntityData assetInputEntityDataStream( - Class entityClass, - Map fieldsToAttributes, - Collection operators) { - - // get the operator of the entity - Optional operatorUuid = - Optional.ofNullable(fieldsToAttributes.get(OPERATOR)) - .filter(s -> !s.isBlank()) - .map(UUID::fromString); - OperatorInput operator = - getFirstOrDefaultOperator( - operators, - operatorUuid, - entityClass.getSimpleName(), - safeMapGet(fieldsToAttributes, "uuid", FIELDS_TO_VALUES_MAP)); - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().removeAll(new HashSet<>(Collections.singletonList(OPERATOR))); - - return new AssetInputEntityData(fieldsToAttributes, entityClass, operator); + protected Stream> buildAssetInputEntityData( + Class entityClass, Map operators) { + return assetInputEntityDataStream(buildEntityData(entityClass), operators); } /** - * Returns a stream of {@link SimpleEntityData} for result entity classes, using a - * fields-to-attributes map. + * Returns a stream of tries of {@link AssetInputEntityData} that can be used to build instances + * of several subtypes of {@link UniqueEntity} by a corresponding {@link EntityFactory} that + * consumes this data. * - * @param entityClass the entity class that should be build - * @param Type of the {@link ResultEntity} to expect - * @return stream of {@link SimpleEntityData} + * @param entityDataStream a stream consisting of {@link EntityData} that is enriched with {@link + * OperatorInput} data + * @param operators map of UUID to {@link OperatorInput} entities that should be used to build the + * data + * @return stream of the entity data wrapped in a {@link Try} */ - protected Stream simpleEntityDataStream( - Class entityClass) { - return dataSource - .getSourceData(entityClass) - .map(fieldsToAttributes -> new SimpleEntityData(fieldsToAttributes, entityClass)); - } - - protected Stream> assetInputEntityStream( - Class entityClass, - EntityFactory factory, - Collection operators) { - return assetInputEntityDataStream(entityClass, operators).map(factory::get); + protected static Stream> assetInputEntityDataStream( + Stream> entityDataStream, + Map operators) { + return entityDataStream + .parallel() + .map( + entityDataTry -> + entityDataTry.flatMap( + entityData -> + optionallyEnrichEntityData( + entityData, + OPERATOR, + operators, + OperatorInput.NO_OPERATOR_ASSIGNED, + AssetInputEntityData::new))); } /** - * Returns a stream of {@link Try} entities that can be build by using {@link - * NodeAssetInputEntityData} and their corresponding factory. + * Returns a stream of optional {@link EntityData} that can be used to build instances of several + * subtypes of {@link UniqueEntity} by a corresponding {@link EntityFactory} that consumes this + * data. * * @param entityClass the entity class that should be build - * @param factory the factory that should be used for the building process - * @param nodes a collection of {@link NodeInput} entities that should be used to build the - * entities - * @param operators a collection of {@link OperatorInput} entities should be used to build the - * entities - * @param Type of the {@link AssetInput} to expect - * @return stream of tries of the entities that has been built by the factory + * @return stream of the entity data wrapped in a {@link Try} */ - protected Stream> nodeAssetEntityStream( - Class entityClass, - EntityFactory factory, - Collection nodes, - Collection operators) { - return nodeAssetInputEntityDataStream(assetInputEntityDataStream(entityClass, operators), nodes) - .map(factory::get); + protected Stream> buildEntityData( + Class entityClass) { + + return Try.of(() -> dataSource.getSourceData(entityClass), SourceException.class) + .convert( + data -> + data.map( + fieldsToAttributes -> + new Success<>(new EntityData(fieldsToAttributes, entityClass))), + exception -> Stream.of(Failure.of(exception))); } - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - public Set> buildNodeAssetEntities( - Class entityClass, - EntityFactory factory, - Collection nodes, - Collection operators) { - return nodeAssetEntityStream(entityClass, factory, nodes, operators) - .collect(Collectors.toSet()); + protected static Map unpackMap( + Stream> inputStream, Class entityClass) throws SourceException { + return unpack(inputStream, entityClass) + .collect(Collectors.toMap(UniqueEntity::getUuid, Function.identity())); } - public Set> buildAssetInputEntities( - Class entityClass, - EntityFactory factory, - Collection operators) { - return assetInputEntityStream(entityClass, factory, operators).collect(Collectors.toSet()); + protected static Set unpackSet( + Stream> inputStream, Class entityClass) throws SourceException { + return unpack(inputStream, entityClass).collect(Collectors.toSet()); } - @SuppressWarnings("unchecked") - public Set> buildEntities( - Class entityClass, EntityFactory factory) { - return dataSource - .getSourceData(entityClass) - .map( - fieldsToAttributes -> { - SimpleEntityData data = new SimpleEntityData(fieldsToAttributes, entityClass); - return (Try) factory.get(data); - }) - .collect(Collectors.toSet()); + protected static Stream unpack( + Stream> inputStream, Class clazz) throws SourceException { + return Try.scanStream(inputStream, clazz.getSimpleName()) + .transformF(SourceException::new) + .getOrThrow(); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/GraphicSource.java b/src/main/java/edu/ie3/datamodel/io/source/GraphicSource.java index 2ecd52c59..e8a0cf7b0 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/GraphicSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/GraphicSource.java @@ -5,8 +5,10 @@ */ package edu.ie3.datamodel.io.source; +import edu.ie3.datamodel.exceptions.FailedValidationException; import edu.ie3.datamodel.exceptions.GraphicSourceException; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; import edu.ie3.datamodel.io.factory.input.graphics.LineGraphicInputEntityData; import edu.ie3.datamodel.io.factory.input.graphics.LineGraphicInputFactory; import edu.ie3.datamodel.io.factory.input.graphics.NodeGraphicInputEntityData; @@ -22,7 +24,6 @@ import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.*; import java.util.*; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -42,25 +43,51 @@ public class GraphicSource extends EntitySource { private final NodeGraphicInputFactory nodeGraphicInputFactory; public GraphicSource(TypeSource typeSource, RawGridSource rawGridSource, DataSource dataSource) { + super(dataSource); this.typeSource = typeSource; this.rawGridSource = rawGridSource; - this.dataSource = dataSource; this.lineGraphicInputFactory = new LineGraphicInputFactory(); this.nodeGraphicInputFactory = new NodeGraphicInputFactory(); } + @Override + public void validate() throws ValidationException { + Try.scanStream( + Stream.of( + validate(NodeGraphicInput.class, nodeGraphicInputFactory), + validate(LineGraphicInput.class, lineGraphicInputFactory)), + "Validation") + .transformF(FailedValidationException::new) + .getOrThrow(); + } + /** Returns the graphic elements of the grid or throws a {@link SourceException} */ public GraphicElements getGraphicElements() throws SourceException { // read all needed entities /// start with types and operators - Set operators = typeSource.getOperators(); - Set lineTypes = typeSource.getLineTypes(); + Map operators = typeSource.getOperators(); + Map lineTypes = typeSource.getLineTypes(); - Set nodes = rawGridSource.getNodes(operators); - Set lines = rawGridSource.getLines(nodes, lineTypes, operators); + Map nodes = rawGridSource.getNodes(operators); + Map lines = rawGridSource.getLines(operators, nodes, lineTypes); + return getGraphicElements(nodes, lines); + } + + /** + * Returns the graphic elements of the grid or throws a {@link SourceException}. + * + *

In contrast to {@link #getGraphicElements()}, this method provides the ability to pass in + * already existing input objects that this method depends on. Doing so, already loaded nodes and + * lines can be recycled to improve performance and prevent unnecessary loading operations. + * + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param lines a map of UUID to object- and uuid-unique {@link LineInput} entities + */ + public GraphicElements getGraphicElements(Map nodes, Map lines) + throws SourceException { Try, SourceException> nodeGraphics = Try.of(() -> getNodeGraphicInput(nodes), SourceException.class); Try, SourceException> lineGraphics = @@ -83,42 +110,36 @@ public GraphicElements getGraphicElements() throws SourceException { /** * If the set of {@link NodeInput} entities is not exhaustive for all available {@link * NodeGraphicInput} entities or if an error during the building process occurs a {@link - * SourceException} is thrown, else all entities that has been able to be built are returned. + * SourceException} is thrown, else all entities that have been able to be built, are returned. */ public Set getNodeGraphicInput() throws SourceException { return getNodeGraphicInput(rawGridSource.getNodes(typeSource.getOperators())); } - public Set getNodeGraphicInput(Set nodes) throws SourceException { - return Try.scanCollection( - buildNodeGraphicEntityData(nodes) - .map(nodeGraphicInputFactory::get) - .collect(Collectors.toSet()), - NodeGraphicInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Set getNodeGraphicInput(Map nodes) + throws SourceException { + return unpackSet( + buildNodeGraphicEntityData(nodes).map(nodeGraphicInputFactory::get), + NodeGraphicInput.class); } /** * If the set of {@link LineInput} entities is not exhaustive for all available {@link * LineGraphicInput} entities or if an error during the building process occurs a {@link - * SourceException} is thrown, else all entities that has been able to be built are returned. + * SourceException} is thrown, else all entities that have been able to be built are returned. */ public Set getLineGraphicInput() throws SourceException { - Set operators = typeSource.getOperators(); + Map operators = typeSource.getOperators(); return getLineGraphicInput( rawGridSource.getLines( - rawGridSource.getNodes(operators), typeSource.getLineTypes(), operators)); + operators, rawGridSource.getNodes(operators), typeSource.getLineTypes())); } - public Set getLineGraphicInput(Set lines) throws SourceException { - return Try.scanCollection( - buildLineGraphicEntityData(lines) - .map(lineGraphicInputFactory::get) - .collect(Collectors.toSet()), - LineGraphicInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Set getLineGraphicInput(Map lines) + throws SourceException { + return unpackSet( + buildLineGraphicEntityData(lines).map(lineGraphicInputFactory::get), + LineGraphicInput.class); } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -136,39 +157,18 @@ public Set getLineGraphicInput(Set lines) throws So * NodeGraphicInputEntityData} instance, a {@link Failure} is included in the stream and warning * is logged. * - * @param nodes a set of nodes with unique uuids + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities * @return a stream of tries of {@link NodeGraphicInput} entities */ protected Stream> buildNodeGraphicEntityData( - Set nodes) { - return dataSource - .getSourceData(NodeGraphicInput.class) - .map(fieldsToAttributes -> buildNodeGraphicEntityData(fieldsToAttributes, nodes)); - } - - protected Try buildNodeGraphicEntityData( - Map fieldsToAttributes, Set nodes) { - - // get the node of the entity - UUID nodeUuid = UUID.fromString(fieldsToAttributes.get(NODE)); - Optional node = findFirstEntityByUuid(nodeUuid, nodes); - - // if the node is not present we return a failure - // log a warning - if (node.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - NodeGraphicInput.class.getSimpleName(), - fieldsToAttributes.get("uuid"), - "no id (graphic entities don't have one)", - NODE + ": " + nodeUuid); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(NODE); - - return new Success<>(new NodeGraphicInputEntityData(fieldsToAttributes, node.get())); + Map nodes) { + return buildEntityData(NodeGraphicInput.class) + .map( + entityDataTry -> + entityDataTry.flatMap( + entityData -> + enrichEntityData( + entityData, NODE, nodes, NodeGraphicInputEntityData::new))); } /** @@ -183,38 +183,17 @@ protected Try buildNodeGraphicEntit * LineGraphicInputEntityData} instance, a {@link Failure} is included in the stream and warning * is logged. * - * @param lines a set of lines with unique uuids + * @param lines a map of UUID to object- and uuid-unique {@link LineInput} entities * @return a stream of tries of {@link LineGraphicInput} entities */ protected Stream> buildLineGraphicEntityData( - Set lines) { - return dataSource - .getSourceData(LineGraphicInput.class) - .map(fieldsToAttributes -> buildLineGraphicEntityData(fieldsToAttributes, lines)); - } - - protected Try buildLineGraphicEntityData( - Map fieldsToAttributes, Set lines) { - - // get the node of the entity - UUID lineUuid = UUID.fromString(fieldsToAttributes.get("line")); - Optional line = findFirstEntityByUuid(lineUuid, lines); - - // if the node is not present we return an empty element and - // log a warning - if (line.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - LineGraphicInput.class.getSimpleName(), - fieldsToAttributes.get("uuid"), - "no id (graphic entities don't have one)", - "line: " + lineUuid); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove("line"); - - return new Success<>(new LineGraphicInputEntityData(fieldsToAttributes, line.get())); + Map lines) { + return buildEntityData(LineGraphicInput.class) + .map( + entityDataTry -> + entityDataTry.flatMap( + entityData -> + enrichEntityData( + entityData, "line", lines, LineGraphicInputEntityData::new))); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java index a41232c53..560b2a909 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/IdCoordinateSource.java @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.source; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.util.geo.CoordinateDistance; import edu.ie3.util.geo.GeoUtils; import java.util.*; @@ -19,6 +20,13 @@ */ public interface IdCoordinateSource { + /** + * Method to retrieve the fields found in the source. + * + * @return an option for the found fields + */ + Optional> getSourceFields() throws SourceException; + /** * Get the matching coordinate for the given ID * @@ -126,7 +134,14 @@ default List restrictToBoundingBox( Point point = distance.getCoordinateB(); // check for bounding box - if (!topLeft && (point.getX() < coordinate.getX() && point.getY() > coordinate.getY())) { + if (coordinate.equalsExact(point, 1e-6)) { + // if current point is matching the given coordinate, we need to return only the current + // point + resultingDistances.clear(); + resultingDistances.add(distance); + return resultingDistances; + } else if (!topLeft + && (point.getX() < coordinate.getX() && point.getY() > coordinate.getY())) { resultingDistances.add(distance); topLeft = true; } else if (!topRight @@ -141,13 +156,6 @@ default List restrictToBoundingBox( && (point.getX() > coordinate.getX() && point.getY() < coordinate.getY())) { resultingDistances.add(distance); bottomRight = true; - } else if (coordinate.equalsExact(point, 1e-6)) { - // if current point is matching the given coordinate, we need to return only the current - // point - - resultingDistances.clear(); - resultingDistances.add(distance); - return resultingDistances; } else { other.add(distance); } diff --git a/src/main/java/edu/ie3/datamodel/io/source/RawGridSource.java b/src/main/java/edu/ie3/datamodel/io/source/RawGridSource.java index 70c228c96..1dc99ce50 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/RawGridSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/RawGridSource.java @@ -5,35 +5,24 @@ */ package edu.ie3.datamodel.io.source; -import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.exceptions.RawGridException; -import edu.ie3.datamodel.exceptions.SourceException; -import edu.ie3.datamodel.io.factory.EntityFactory; +import edu.ie3.datamodel.exceptions.*; import edu.ie3.datamodel.io.factory.input.*; import edu.ie3.datamodel.models.input.*; -import edu.ie3.datamodel.models.input.MeasurementUnitInput; -import edu.ie3.datamodel.models.input.NodeInput; -import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.connector.*; -import edu.ie3.datamodel.models.input.connector.LineInput; -import edu.ie3.datamodel.models.input.connector.SwitchInput; -import edu.ie3.datamodel.models.input.connector.Transformer2WInput; -import edu.ie3.datamodel.models.input.connector.Transformer3WInput; import edu.ie3.datamodel.models.input.connector.type.LineTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput; import edu.ie3.datamodel.models.input.container.RawGridElements; import edu.ie3.datamodel.utils.Try; -import edu.ie3.datamodel.utils.Try.*; +import edu.ie3.datamodel.utils.Try.Failure; import java.util.*; import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; /** - * Implementation that provides the capability to build entities that are hold by a {@link - * RawGridElements} as well as the {@link RawGridElements} container as well from different data - * sources e.g. .csv files or databases. + * Implementation that provides the capability to build entities held by {@link RawGridElements} as + * well as the {@link RawGridElements} container from different data sources e.g. .csv files or + * databases. * * @version 0.1 * @since 08.04.20 @@ -57,8 +46,8 @@ public class RawGridSource extends EntitySource { private final MeasurementUnitInputFactory measurementUnitInputFactory; public RawGridSource(TypeSource typeSource, DataSource dataSource) { + super(dataSource); this.typeSource = typeSource; - this.dataSource = dataSource; // init factories this.nodeInputFactory = new NodeInputFactory(); @@ -69,6 +58,21 @@ public RawGridSource(TypeSource typeSource, DataSource dataSource) { this.measurementUnitInputFactory = new MeasurementUnitInputFactory(); } + @Override + public void validate() throws ValidationException { + Try.scanStream( + Stream.of( + validate(NodeInput.class, nodeInputFactory), + validate(LineInput.class, lineInputFactory), + validate(Transformer2WInput.class, transformer2WInputFactory), + validate(Transformer3WInput.class, transformer3WInputFactory), + validate(SwitchInput.class, switchInputFactory), + validate(MeasurementUnitInput.class, measurementUnitInputFactory)), + "Validation") + .transformF(FailedValidationException::new) + .getOrThrow(); + } + /** * Should return either a consistent instance of {@link RawGridElements} or throw a {@link * SourceException}. The decision to throw a {@link SourceException} instead of returning the @@ -85,36 +89,71 @@ public RawGridSource(TypeSource typeSource, DataSource dataSource) { * e.g. in the sense that not duplicate UUIDs exist within all entities contained in the returning * instance. * - * @return either a valid, complete {@link RawGridElements} or throws a {@link SourceException} + * @return a valid, complete {@link RawGridElements} + * @throws SourceException on error */ public RawGridElements getGridData() throws SourceException { /* read all needed entities start with the types and operators */ - Set operators = typeSource.getOperators(); - Set lineTypes = typeSource.getLineTypes(); - Set transformer2WTypeInputs = typeSource.getTransformer2WTypes(); - Set transformer3WTypeInputs = typeSource.getTransformer3WTypes(); + Map operators = typeSource.getOperators(); + Map lineTypes = typeSource.getLineTypes(); + + /* assets */ + Map nodes = getNodes(operators); + Map lines = getLines(operators, nodes, lineTypes); + + return getGridData(operators, nodes, lines); + } + + /** + * Should return either a consistent instance of {@link RawGridElements} or throw a {@link + * SourceException}. The decision to throw a {@link SourceException} instead of returning the + * incomplete {@link RawGridElements} instance is motivated by the fact, that a {@link + * RawGridElements} is a container instance that depends on several other entities. Without being + * complete, it is useless for further processing. + * + *

Hence, whenever at least one entity {@link RawGridElements} depends on cannot be provided, + * {@link SourceException} should be thrown. The thrown exception should provide enough + * information to debug the error and fix the persistent data that has been failed to processed. + * + *

Furthermore, it is expected, that the specific implementation of this method ensures not + * only the completeness of the resulting {@link RawGridElements} instance, but also its validity + * e.g. in the sense that not duplicate UUIDs exist within all entities contained in the returning + * instance. + * + *

In contrast to {@link #getGridData()}, this method provides the ability to pass in already + * existing input objects that this method depends on. Doing so, already loaded operators, nodes + * and lines can be recycled to improve performance and prevent unnecessary loading operations. + * + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param lines a map of UUID to object- and uuid-unique {@link LineInput} entities + * @return a valid, complete {@link RawGridElements} + * @throws SourceException on error + */ + public RawGridElements getGridData( + Map operators, Map nodes, Map lines) + throws SourceException { + /* read all needed entities start with the types and operators */ + Map transformer2WTypeInputs = typeSource.getTransformer2WTypes(); + Map transformer3WTypeInputs = typeSource.getTransformer3WTypes(); /* assets */ - Set nodes = getNodes(operators); - Try, SourceException> lineInputs = - Try.of(() -> getLines(nodes, lineTypes, operators), SourceException.class); Try, SourceException> transformer2WInputs = Try.of( - () -> get2WTransformers(nodes, transformer2WTypeInputs, operators), + () -> get2WTransformers(operators, nodes, transformer2WTypeInputs), SourceException.class); Try, SourceException> transformer3WInputs = Try.of( - () -> get3WTransformers(nodes, transformer3WTypeInputs, operators), + () -> get3WTransformers(operators, nodes, transformer3WTypeInputs), SourceException.class); Try, SourceException> switches = - Try.of(() -> getSwitches(nodes, operators), SourceException.class); + Try.of(() -> getSwitches(operators, nodes), SourceException.class); Try, SourceException> measurementUnits = - Try.of(() -> getMeasurementUnits(nodes, operators), SourceException.class); + Try.of(() -> getMeasurementUnits(operators, nodes), SourceException.class); List exceptions = Try.getExceptions( - List.of( - lineInputs, transformer2WInputs, transformer3WInputs, switches, measurementUnits)); + List.of(transformer2WInputs, transformer3WInputs, switches, measurementUnits)); if (!exceptions.isEmpty()) { throw new RawGridException( @@ -124,8 +163,8 @@ public RawGridElements getGridData() throws SourceException { // getOrThrow should not throw an exception in this context, because all exception are // filtered and thrown before return new RawGridElements( - nodes, - lineInputs.getOrThrow(), + new HashSet<>(nodes.values()), + new HashSet<>(lines.values()), transformer2WInputs.getOrThrow(), transformer3WInputs.getOrThrow(), switches.getOrThrow(), @@ -134,23 +173,24 @@ public RawGridElements getGridData() throws SourceException { } /** - * Returns a unique set of {@link NodeInput} instances. + * Returns a unique set of {@link NodeInput} instances within a map by UUID. * *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link * java.util.UUID} uniqueness of the provided {@link NodeInput} which has to be checked manually, * as {@link NodeInput#equals(Object)} is NOT restricted on the uuid of {@link NodeInput}. * - * @return a set of object and uuid unique {@link NodeInput} entities + * @return a map of UUID to object- and uuid-unique {@link NodeInput} entities */ - public Set getNodes() throws SourceException { + public Map getNodes() throws SourceException { return getNodes(typeSource.getOperators()); } /** - * Returns a set of {@link NodeInput} instances. This set has to be unique in the sense of object - * uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided {@link - * NodeInput} which has to be checked manually, as {@link NodeInput#equals(Object)} is NOT - * restricted on the uuid of {@link NodeInput}. + * Returns a unique set of {@link NodeInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link NodeInput} which has to be checked manually, + * as {@link NodeInput#equals(Object)} is NOT restricted on the uuid of {@link NodeInput}. * *

In contrast to {@link #getNodes} this method provides the ability to pass in an already * existing set of {@link OperatorInput} entities, the {@link NodeInput} instances depend on. @@ -160,39 +200,35 @@ public Set getNodes() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @return a set of object and uuid unique {@link NodeInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @return a map of UUID to object- and uuid-unique {@link NodeInput} entities */ - public Set getNodes(Set operators) throws SourceException { - return Try.scanCollection( - assetInputEntityDataStream(NodeInput.class, operators) - .map(nodeInputFactory::get) - .collect(Collectors.toSet()), - NodeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getNodes(Map operators) throws SourceException { + return unpackMap( + buildAssetInputEntityData(NodeInput.class, operators).map(nodeInputFactory::get), + NodeInput.class); } /** - * Returns a unique set of {@link LineInput} instances. + * Returns a unique set of {@link LineInput} instances within a map by UUID. * *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link * java.util.UUID} uniqueness of the provided {@link LineInput} which has to be checked manually, * as {@link LineInput#equals(Object)} is NOT restricted on the uuid of {@link LineInput}. * - * @return a set of object and uuid unique {@link LineInput} entities + * @return a map of UUID to object- and uuid-unique {@link LineInput} entities */ - public Set getLines() throws SourceException { - Set operators = typeSource.getOperators(); - return getLines(getNodes(operators), typeSource.getLineTypes(), operators); + public Map getLines() throws SourceException { + Map operators = typeSource.getOperators(); + return getLines(operators, getNodes(operators), typeSource.getLineTypes()); } /** - * Returns a set of {@link LineInput} instances. This set has to be unique in the sense of object - * uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided {@link - * LineInput} which has to be checked manually, as {@link LineInput#equals(Object)} is NOT - * restricted on the uuid of {@link LineInput}. + * Returns a unique set of {@link LineInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link LineInput} which has to be checked manually, + * as {@link LineInput#equals(Object)} is NOT restricted on the uuid of {@link LineInput}. * *

In contrast to {@link #getNodes} this method provides the ability to pass in an already * existing set of {@link NodeInput}, {@link LineTypeInput} and {@link OperatorInput} entities, @@ -202,21 +238,20 @@ public Set getLines() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param lineTypeInputs a set of object and uuid unique {@link LineTypeInput} entities - * @return a set of object and uuid unique {@link LineInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param lineTypeInputs a map of UUID to object- and uuid-unique {@link LineTypeInput} entities + * @return a map of UUID to object- and uuid-unique {@link LineInput} entities */ - public Set getLines( - Set nodes, Set lineTypeInputs, Set operators) + public Map getLines( + Map operators, + Map nodes, + Map lineTypeInputs) throws SourceException { - return Try.scanCollection( - typedEntityStream(LineInput.class, lineInputFactory, nodes, operators, lineTypeInputs) - .collect(Collectors.toSet()), - LineInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackMap( + buildTypedEntityData(LineInput.class, operators, nodes, lineTypeInputs) + .map(lineInputFactory::get), + LineInput.class); } /** @@ -227,11 +262,11 @@ public Set getLines( * manually, as {@link Transformer2WInput#equals(Object)} is NOT restricted on the uuid of {@link * Transformer2WInput}. * - * @return a set of object and uuid unique {@link Transformer2WInput} entities + * @return a set of object- and uuid-unique {@link Transformer2WInput} entities */ public Set get2WTransformers() throws SourceException { - Set operators = typeSource.getOperators(); - return get2WTransformers(getNodes(operators), typeSource.getTransformer2WTypes(), operators); + Map operators = typeSource.getOperators(); + return get2WTransformers(operators, getNodes(operators), typeSource.getTransformer2WTypes()); } /** @@ -249,29 +284,21 @@ public Set get2WTransformers() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param transformer2WTypes a set of object and uuid unique {@link Transformer2WTypeInput} - * entities - * @return a set of object and uuid unique {@link Transformer2WInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param transformer2WTypes a map of UUID to object- and uuid-unique {@link + * Transformer2WTypeInput} entities + * @return a set of object- and uuid-unique {@link Transformer2WInput} entities */ public Set get2WTransformers( - Set nodes, - Set transformer2WTypes, - Set operators) + Map operators, + Map nodes, + Map transformer2WTypes) throws SourceException { - return Try.scanCollection( - typedEntityStream( - Transformer2WInput.class, - transformer2WInputFactory, - nodes, - operators, - transformer2WTypes) - .collect(Collectors.toSet()), - Transformer2WInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildTypedEntityData(Transformer2WInput.class, operators, nodes, transformer2WTypes) + .map(transformer2WInputFactory::get), + Transformer2WInput.class); } /** @@ -282,11 +309,11 @@ public Set get2WTransformers( * manually, as {@link Transformer3WInput#equals(Object)} is NOT restricted on the uuid of {@link * Transformer3WInput}. * - * @return a set of object and uuid unique {@link Transformer3WInput} entities + * @return a set of object- and uuid-unique {@link Transformer3WInput} entities */ public Set get3WTransformers() throws SourceException { - Set operators = typeSource.getOperators(); - return get3WTransformers(getNodes(operators), typeSource.getTransformer3WTypes(), operators); + Map operators = typeSource.getOperators(); + return get3WTransformers(operators, getNodes(operators), typeSource.getTransformer3WTypes()); } /** @@ -304,24 +331,24 @@ public Set get3WTransformers() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param transformer3WTypeInputs a set of object and uuid unique {@link Transformer3WTypeInput} - * entities - * @return a set of object and uuid unique {@link Transformer3WInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param transformer3WTypes a map of UUID to object- and uuid-unique {@link + * Transformer3WTypeInput} entities + * @return a set of object- and uuid-unique {@link Transformer3WInput} entities */ public Set get3WTransformers( - Set nodes, - Set transformer3WTypeInputs, - Set operators) + Map operators, + Map nodes, + Map transformer3WTypes) throws SourceException { - return Try.scanCollection( - buildTransformer3WEntities( - transformer3WInputFactory, nodes, transformer3WTypeInputs, operators), - Transformer3WInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + transformer3WEntityDataStream( + buildTypedEntityData( + Transformer3WInput.class, operators, nodes, transformer3WTypes), + nodes) + .map(transformer3WInputFactory::get), + Transformer3WInput.class); } /** @@ -332,11 +359,11 @@ public Set get3WTransformers( * manually, as {@link SwitchInput#equals(Object)} is NOT restricted on the uuid of {@link * SwitchInput}. * - * @return a set of object and uuid unique {@link SwitchInput} entities + * @return a set of object- and uuid-unique {@link SwitchInput} entities */ public Set getSwitches() throws SourceException { - Set operators = typeSource.getOperators(); - return getSwitches(getNodes(operators), operators); + Map operators = typeSource.getOperators(); + return getSwitches(operators, getNodes(operators)); } /** @@ -353,15 +380,15 @@ public Set getSwitches() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link SwitchInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @return a set of object- and uuid-unique {@link SwitchInput} entities */ - public Set getSwitches(Set nodes, Set operators) - throws SourceException { - return buildUntypedConnectorInputEntities( - SwitchInput.class, switchInputFactory, nodes, operators); + public Set getSwitches( + Map operators, Map nodes) throws SourceException { + return unpackSet( + buildUntypedEntityData(SwitchInput.class, operators, nodes).map(switchInputFactory::get), + SwitchInput.class); } /** @@ -372,11 +399,11 @@ public Set getSwitches(Set nodes, Set ope * manually, as {@link MeasurementUnitInput#equals(Object)} is NOT restricted on the uuid of * {@link MeasurementUnitInput}. * - * @return a set of object and uuid unique {@link MeasurementUnitInput} entities + * @return a set of object- and uuid-unique {@link MeasurementUnitInput} entities */ public Set getMeasurementUnits() throws SourceException { - Set operators = typeSource.getOperators(); - return getMeasurementUnits(getNodes(operators), operators); + Map operators = typeSource.getOperators(); + return getMeasurementUnits(operators, getNodes(operators)); } /** @@ -394,90 +421,84 @@ public Set getMeasurementUnits() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link MeasurementUnitInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @return a set of object- and uuid-unique {@link MeasurementUnitInput} entities */ public Set getMeasurementUnits( - Set nodes, Set operators) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities( - MeasurementUnitInput.class, measurementUnitInputFactory, nodes, operators), - MeasurementUnitInput.class) - .transformF(SourceException::new) - .getOrThrow(); + Map operators, Map nodes) throws SourceException { + return unpackSet( + buildNodeAssetEntityData(MeasurementUnitInput.class, operators, nodes) + .map(measurementUnitInputFactory::get), + MeasurementUnitInput.class); } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - public Set> buildNodeInputEntities( - Class entityClass, - EntityFactory factory, - Collection operators) { - return assetInputEntityDataStream(entityClass, operators) - .map(factory::get) - .collect(Collectors.toSet()); - } - - public Set buildUntypedConnectorInputEntities( - Class entityClass, - EntityFactory factory, - Collection nodes, - Collection operators) - throws SourceException { - return Try.scanCollection( - untypedConnectorInputEntityStream(entityClass, factory, nodes, operators) - .collect(Collectors.toSet()), - entityClass) - .transformF(SourceException::new) - .getOrThrow(); - } - public Set> buildTransformer3WEntities( - Transformer3WInputFactory transformer3WInputFactory, - Collection nodes, - Collection transformer3WTypeInputs, - Collection operators) { - return buildTransformer3WEntityData( - buildTypedConnectorEntityData( - buildUntypedConnectorInputEntityData( - assetInputEntityDataStream(Transformer3WInput.class, operators), nodes), - transformer3WTypeInputs), - nodes) - .map(transformer3WInputFactory::get) - .collect(Collectors.toSet()); + /** + * Enriches the Stream of tries on {@link Transformer3WInputEntityData} with the information of + * the internal node. + * + * @param typedConnectorEntityDataStream Stream of already typed input entity data + * @param nodes Yet available nodes + * @return A stream of {@link Try} on enriched data + */ + protected Stream> + transformer3WEntityDataStream( + Stream, SourceException>> + typedConnectorEntityDataStream, + Map nodes) { + return typedConnectorEntityDataStream + .parallel() + .map( + typedEntityDataOpt -> + typedEntityDataOpt.flatMap( + typeEntityData -> + enrichEntityData( + typeEntityData, "nodeC", nodes, Transformer3WInputEntityData::new))); } - public - Set> buildTypedEntities( + private + Stream, SourceException>> buildTypedEntityData( Class entityClass, - EntityFactory> factory, - Collection nodes, - Collection operators, - Collection types) { - return typedEntityStream(entityClass, factory, nodes, operators, types) - .collect(Collectors.toSet()); + Map operators, + Map nodes, + Map types) { + return typedConnectorEntityDataStream( + buildUntypedEntityData(entityClass, operators, nodes), types); } /** * Enriches the given untyped entity data with the equivalent asset type. If this is not possible, * a {@link Failure} is returned. * - * @param noTypeConnectorEntityDataStream Stream of untyped entity data + * @param connectorEntityDataStream Stream of untyped entity data * @param availableTypes Yet available asset types * @param Type of the asset type * @return Stream of {@link Try} to enhanced data */ protected - Stream, SourceException>> buildTypedConnectorEntityData( - Stream> noTypeConnectorEntityDataStream, - Collection availableTypes) { - return noTypeConnectorEntityDataStream + Stream, SourceException>> typedConnectorEntityDataStream( + Stream> connectorEntityDataStream, + Map availableTypes) { + return connectorEntityDataStream .parallel() .map( noTypeEntityDataOpt -> noTypeEntityDataOpt.flatMap( - noTypeEntityData -> findAndAddType(noTypeEntityData, availableTypes))); + noTypeEntityData -> + enrichEntityData( + noTypeEntityData, + TYPE, + availableTypes, + TypedConnectorInputEntityData::new))); + } + + public + Stream> buildUntypedEntityData( + Class entityClass, Map operators, Map nodes) { + return untypedConnectorEntityDataStream( + buildAssetInputEntityData(entityClass, operators), nodes); } /** @@ -488,165 +509,21 @@ Stream, SourceException>> buildTypedConnect * @param nodes A collection of known nodes * @return A stream on {@link Try} to matching {@link ConnectorInputEntityData} */ - protected Stream> - buildUntypedConnectorInputEntityData( - Stream assetInputEntityDataStream, Collection nodes) { + protected Stream> untypedConnectorEntityDataStream( + Stream> assetInputEntityDataStream, + Map nodes) { return assetInputEntityDataStream .parallel() .map( - assetInputEntityData -> - buildUntypedConnectorInputEntityData(assetInputEntityData, nodes)); - } - - /** - * Converts a single given {@link AssetInputEntityData} in connection with a collection of known - * {@link NodeInput}s to {@link ConnectorInputEntityData}. If this is not possible, a {@link - * Failure}. - * - * @param assetInputEntityData Input entity data to convert - * @param nodes A collection of known nodes - * @return A {@link Try} to matching {@link ConnectorInputEntityData} - */ - protected Try buildUntypedConnectorInputEntityData( - AssetInputEntityData assetInputEntityData, Collection nodes) { - // get the raw data - Map fieldsToAttributes = assetInputEntityData.getFieldsToValues(); - - // get the two connector nodes - UUID nodeAUuid = UUID.fromString(fieldsToAttributes.get(NODE_A)); - UUID nodeBUuid = UUID.fromString(fieldsToAttributes.get(NODE_B)); - Optional nodeA = findFirstEntityByUuid(nodeAUuid, nodes); - Optional nodeB = findFirstEntityByUuid(nodeBUuid, nodes); - - // if nodeA or nodeB are not present we return a failure and log a - // warning - if (nodeA.isEmpty() || nodeB.isEmpty()) { - String debugString = - Stream.of( - new AbstractMap.SimpleEntry<>(nodeA, NODE_A + ": " + nodeAUuid), - new AbstractMap.SimpleEntry<>(nodeB, NODE_B + ": " + nodeBUuid)) - .filter(entry -> entry.getKey().isEmpty()) - .map(AbstractMap.SimpleEntry::getValue) - .collect(Collectors.joining("\n")); - - String skippingMessage = - buildSkippingMessage( - assetInputEntityData.getTargetClass().getSimpleName(), - fieldsToAttributes.get("uuid"), - fieldsToAttributes.get("id"), - debugString); - - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().removeAll(new HashSet<>(Arrays.asList(NODE_A, NODE_B))); - - return new Success<>( - new ConnectorInputEntityData( - fieldsToAttributes, - assetInputEntityData.getTargetClass(), - assetInputEntityData.getOperatorInput(), - nodeA.get(), - nodeB.get())); - } - - private - Stream> typedEntityStream( - Class entityClass, - EntityFactory> factory, - Collection nodes, - Collection operators, - Collection types) { - return buildTypedConnectorEntityData( - buildUntypedConnectorInputEntityData( - assetInputEntityDataStream(entityClass, operators), nodes), - types) - .map(factory::get); - } - - public - Stream> untypedConnectorInputEntityStream( - Class entityClass, - EntityFactory factory, - Set nodes, - Set operators) { - return buildUntypedConnectorInputEntityData( - assetInputEntityDataStream(entityClass, operators), nodes) - .map(factory::get); - } - - private - Stream> untypedConnectorInputEntityStream( - Class entityClass, - EntityFactory factory, - Collection nodes, - Collection operators) { - return untypedConnectorInputEntityStream( - entityClass, factory, new HashSet<>(nodes), new HashSet<>(operators)); - } - - /** - * Enriches the Stream of tries on {@link Transformer3WInputEntityData} with the information of - * the internal node. - * - * @param typedConnectorEntityDataStream Stream of already typed input entity data - * @param nodes Yet available nodes - * @return A stream of {@link Try} on enriched data - */ - protected Stream> buildTransformer3WEntityData( - Stream, SourceException>> - typedConnectorEntityDataStream, - Collection nodes) { - return typedConnectorEntityDataStream - .parallel() - .map( - typedEntityDataOpt -> - typedEntityDataOpt.flatMap(typeEntityData -> addThirdNode(typeEntityData, nodes))); - } - - /** - * Enriches the third node to the already typed entity data of a three winding transformer. If no - * matching node can be found, return a {@link Failure}. - * - * @param typeEntityData Already typed entity data - * @param nodes Yet available nodes - * @return a {@link Try} to the enriched data - */ - protected Try addThirdNode( - TypedConnectorInputEntityData typeEntityData, - Collection nodes) { - - // get the raw data - Map fieldsToAttributes = typeEntityData.getFieldsToValues(); - - // get nodeC of the transformer - UUID nodeCUuid = UUID.fromString(fieldsToAttributes.get("nodeC")); - Optional nodeC = findFirstEntityByUuid(nodeCUuid, nodes); - - // if nodeC is not present we return a failure - // log a warning - if (nodeC.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - typeEntityData.getTargetClass().getSimpleName(), - fieldsToAttributes.get("uuid"), - fieldsToAttributes.get("id"), - "nodeC: " + nodeCUuid); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove("nodeC"); - - return new Success<>( - new Transformer3WInputEntityData( - fieldsToAttributes, - typeEntityData.getTargetClass(), - typeEntityData.getOperatorInput(), - typeEntityData.getNodeA(), - typeEntityData.getNodeB(), - nodeC.get(), - typeEntityData.getType())); + assetInputEntityDataTry -> + assetInputEntityDataTry.flatMap( + assetInputEntityData -> + enrichEntityData( + assetInputEntityData, + NODE_A, + nodes, + NODE_B, + nodes, + ConnectorInputEntityData::new))); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java b/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java index 87d9fcc21..e345e1796 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ResultEntitySource.java @@ -5,7 +5,11 @@ */ package edu.ie3.datamodel.io.source; -import edu.ie3.datamodel.io.factory.SimpleEntityFactory; +import edu.ie3.datamodel.exceptions.FailedValidationException; +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.io.factory.result.*; import edu.ie3.datamodel.models.result.NodeResult; import edu.ie3.datamodel.models.result.ResultEntity; @@ -16,9 +20,11 @@ import edu.ie3.datamodel.models.result.system.*; import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult; import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult; -import java.util.Optional; +import edu.ie3.datamodel.utils.Try; +import java.util.ArrayList; +import java.util.List; import java.util.Set; -import java.util.stream.Collectors; +import java.util.stream.Stream; /** * Interface that provides the capability to build entities of type {@link ResultEntity} container @@ -37,7 +43,7 @@ public class ResultEntitySource extends EntitySource { private final FlexOptionsResultFactory flexOptionsResultFactory; public ResultEntitySource(DataSource dataSource) { - this.dataSource = dataSource; + super(dataSource); // init factories this.systemParticipantResultFactory = new SystemParticipantResultFactory(); @@ -49,7 +55,7 @@ public ResultEntitySource(DataSource dataSource) { } public ResultEntitySource(DataSource dataSource, String dtfPattern) { - this.dataSource = dataSource; + super(dataSource); // init factories this.systemParticipantResultFactory = new SystemParticipantResultFactory(dtfPattern); @@ -60,6 +66,41 @@ public ResultEntitySource(DataSource dataSource, String dtfPattern) { this.flexOptionsResultFactory = new FlexOptionsResultFactory(); } + @Override + public void validate() throws ValidationException { + List> participantResults = + new ArrayList<>( + Stream.of( + LoadResult.class, + FixedFeedInResult.class, + BmResult.class, + PvResult.class, + ChpResult.class, + WecResult.class, + StorageResult.class, + EvcsResult.class, + EvResult.class, + HpResult.class, + EmResult.class) + .map(c -> validate(c, systemParticipantResultFactory)) + .toList()); + + participantResults.addAll( + List.of( + validate(ThermalHouseResult.class, thermalResultFactory), + validate(CylindricalStorageResult.class, thermalResultFactory), + validate(SwitchResult.class, switchResultFactory), + validate(NodeResult.class, nodeResultFactory), + validate(LineResult.class, connectorResultFactory), + validate(Transformer2WResult.class, connectorResultFactory), + validate(Transformer3WResult.class, connectorResultFactory), + validate(FlexOptionsResult.class, flexOptionsResultFactory))); + + Try.scanCollection(participantResults, Void.class) + .transformF(FailedValidationException::new) + .getOrThrow(); + } + /** * Returns a unique set of {@link NodeResult} instances. * @@ -69,7 +110,7 @@ public ResultEntitySource(DataSource dataSource, String dtfPattern) { * * @return a set of object and uuid unique {@link NodeResult} entities */ - public Set getNodeResults() { + public Set getNodeResults() throws SourceException { return getResultEntities(NodeResult.class, nodeResultFactory); } @@ -83,7 +124,7 @@ public Set getNodeResults() { * * @return a set of object and uuid unique {@link SwitchResult} entities */ - public Set getSwitchResults() { + public Set getSwitchResults() throws SourceException { return getResultEntities(SwitchResult.class, switchResultFactory); } @@ -96,7 +137,7 @@ public Set getSwitchResults() { * * @return a set of object and uuid unique {@link LineResult} entities */ - public Set getLineResults() { + public Set getLineResults() throws SourceException { return getResultEntities(LineResult.class, connectorResultFactory); } @@ -110,7 +151,7 @@ public Set getLineResults() { * * @return a set of object and uuid unique {@link Transformer2WResult} entities */ - public Set getTransformer2WResultResults() { + public Set getTransformer2WResultResults() throws SourceException { return getResultEntities(Transformer2WResult.class, connectorResultFactory); } @@ -124,7 +165,7 @@ public Set getTransformer2WResultResults() { * * @return a set of object and uuid unique {@link Transformer3WResult} entities */ - public Set getTransformer3WResultResults() { + public Set getTransformer3WResultResults() throws SourceException { return getResultEntities(Transformer3WResult.class, connectorResultFactory); } @@ -138,7 +179,7 @@ public Set getTransformer3WResultResults() { * * @return a set of object and uuid unique {@link FlexOptionsResult} entities */ - public Set getFlexOptionsResults() { + public Set getFlexOptionsResults() throws SourceException { return getResultEntities(FlexOptionsResult.class, flexOptionsResultFactory); } @@ -151,7 +192,7 @@ public Set getFlexOptionsResults() { * * @return a set of object and uuid unique {@link LoadResult} entities */ - public Set getLoadResults() { + public Set getLoadResults() throws SourceException { return getResultEntities(LoadResult.class, systemParticipantResultFactory); } @@ -164,7 +205,7 @@ public Set getLoadResults() { * * @return a set of object and uuid unique {@link PvResult} entities */ - public Set getPvResults() { + public Set getPvResults() throws SourceException { return getResultEntities(PvResult.class, systemParticipantResultFactory); } @@ -178,7 +219,7 @@ public Set getPvResults() { * * @return a set of object and uuid unique {@link FixedFeedInResult} entities */ - public Set getFixedFeedInResults() { + public Set getFixedFeedInResults() throws SourceException { return getResultEntities(FixedFeedInResult.class, systemParticipantResultFactory); } @@ -191,7 +232,7 @@ public Set getFixedFeedInResults() { * * @return a set of object and uuid unique {@link BmResult} entities */ - public Set getBmResults() { + public Set getBmResults() throws SourceException { return getResultEntities(BmResult.class, systemParticipantResultFactory); } @@ -204,7 +245,7 @@ public Set getBmResults() { * * @return a set of object and uuid unique {@link ChpResult} entities */ - public Set getChpResults() { + public Set getChpResults() throws SourceException { return getResultEntities(ChpResult.class, systemParticipantResultFactory); } @@ -217,7 +258,7 @@ public Set getChpResults() { * * @return a set of object and uuid unique {@link WecResult} entities */ - public Set getWecResults() { + public Set getWecResults() throws SourceException { return getResultEntities(WecResult.class, systemParticipantResultFactory); } @@ -231,7 +272,7 @@ public Set getWecResults() { * * @return a set of object and uuid unique {@link StorageResult} entities */ - public Set getStorageResults() { + public Set getStorageResults() throws SourceException { return getResultEntities(StorageResult.class, systemParticipantResultFactory); } @@ -244,7 +285,7 @@ public Set getStorageResults() { * * @return a set of object and uuid unique {@link EvcsResult} entities */ - public Set getEvcsResults() { + public Set getEvcsResults() throws SourceException { return getResultEntities(EvcsResult.class, systemParticipantResultFactory); } @@ -257,7 +298,7 @@ public Set getEvcsResults() { * * @return a set of object and uuid unique {@link EvResult} entities */ - public Set getEvResults() { + public Set getEvResults() throws SourceException { return getResultEntities(EvResult.class, systemParticipantResultFactory); } @@ -270,7 +311,7 @@ public Set getEvResults() { * * @return a set of object and uuid unique {@link HpResult} entities */ - public Set getHpResults() { + public Set getHpResults() throws SourceException { return getResultEntities(HpResult.class, systemParticipantResultFactory); } @@ -284,7 +325,7 @@ public Set getHpResults() { * * @return a set of object and uuid unique {@link CylindricalStorageResult} entities */ - public Set getCylindricalStorageResult() { + public Set getCylindricalStorageResult() throws SourceException { return getResultEntities(CylindricalStorageResult.class, thermalResultFactory); } @@ -298,7 +339,7 @@ public Set getCylindricalStorageResult() { * * @return a set of object and uuid unique {@link ThermalHouseResult} entities */ - public Set getThermalHouseResults() { + public Set getThermalHouseResults() throws SourceException { return getResultEntities(ThermalHouseResult.class, thermalResultFactory); } @@ -311,32 +352,28 @@ public Set getThermalHouseResults() { * * @return a set of object and uuid unique {@link EmResult} entities */ - public Set getEmResults() { + public Set getEmResults() throws SourceException { return getResultEntities(EmResult.class, systemParticipantResultFactory); } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - private Set getResultEntities( - Class entityClass, SimpleEntityFactory factory) { - return simpleEntityDataStream(entityClass) - .map( - entityData -> - factory - .get(entityData) - .getData() - .flatMap(loadResult -> cast(entityClass, loadResult))) - .flatMap(Optional::stream) - .collect(Collectors.toSet()); - } - private Optional cast( - Class entityClass, ResultEntity resultEntity) { - if (resultEntity.getClass().equals(entityClass)) { - // safe here as a) type is checked and b) csv data stream already filters non-fitting input - // data - return Optional.of(entityClass.cast(resultEntity)); - } else { - return Optional.empty(); - } + /** + * Build and cast entities to the correct type, since result factories outputs result entities of + * some general type. + * + * @param entityClass + * @param factory + * @return + * @param + */ + @SuppressWarnings("unchecked") + private Set getResultEntities( + Class entityClass, EntityFactory factory) + throws SourceException { + return unpackSet( + buildEntityData(entityClass) + .map(entityData -> factory.get(entityData).map(data -> (T) data)), + entityClass); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/SourceValidator.java b/src/main/java/edu/ie3/datamodel/io/source/SourceValidator.java new file mode 100644 index 000000000..e1c43c89f --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/io/source/SourceValidator.java @@ -0,0 +1,23 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.io.source; + +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.utils.Try; +import edu.ie3.datamodel.utils.Try.Failure; +import java.util.Set; + +public interface SourceValidator { + + /** + * Method for validating a data source. + * + * @param actualFields fields that were found in the source data + * @param entityClass that should be buildable from the source data + * @return either an exception wrapped by a {@link Failure} or an empty success + */ + Try validate(Set actualFields, Class entityClass); +} diff --git a/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java b/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java index d00f4e37a..873575e2c 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/SystemParticipantSource.java @@ -5,12 +5,10 @@ */ package edu.ie3.datamodel.io.source; -import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.exceptions.SourceException; -import edu.ie3.datamodel.exceptions.SystemParticipantsException; -import edu.ie3.datamodel.io.factory.EntityFactory; +import edu.ie3.datamodel.exceptions.*; import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData; import edu.ie3.datamodel.io.factory.input.participant.*; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.container.SystemParticipants; @@ -19,10 +17,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; import edu.ie3.datamodel.utils.Try; -import edu.ie3.datamodel.utils.Try.*; import java.util.*; -import java.util.Set; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -38,6 +33,7 @@ public class SystemParticipantSource extends EntitySource { private final TypeSource typeSource; private final RawGridSource rawGridSource; private final ThermalSource thermalSource; + private final EnergyManagementSource energyManagementSource; // factories private final BmInputFactory bmInputFactory; @@ -50,18 +46,19 @@ public class SystemParticipantSource extends EntitySource { private final StorageInputFactory storageInputFactory; private final WecInputFactory wecInputFactory; private final EvcsInputFactory evcsInputFactory; - private final EmInputFactory emInputFactory; public SystemParticipantSource( TypeSource typeSource, ThermalSource thermalSource, RawGridSource rawGridSource, + EnergyManagementSource energyManagementSource, DataSource dataSource) { + super(dataSource); this.typeSource = typeSource; this.rawGridSource = rawGridSource; this.thermalSource = thermalSource; - this.dataSource = dataSource; + this.energyManagementSource = energyManagementSource; // init factories this.bmInputFactory = new BmInputFactory(); @@ -74,7 +71,25 @@ public SystemParticipantSource( this.storageInputFactory = new StorageInputFactory(); this.wecInputFactory = new WecInputFactory(); this.evcsInputFactory = new EvcsInputFactory(); - this.emInputFactory = new EmInputFactory(); + } + + @Override + public void validate() throws ValidationException { + Try.scanStream( + Stream.of( + validate(BmInput.class, bmInputFactory), + validate(ChpInput.class, chpInputFactory), + validate(EvInput.class, evInputFactory), + validate(FixedFeedInInput.class, fixedFeedInInputFactory), + validate(HpInput.class, hpInputFactory), + validate(LoadInput.class, loadInputFactory), + validate(PvInput.class, pvInputFactory), + validate(StorageInput.class, storageInputFactory), + validate(WecInput.class, wecInputFactory), + validate(EvcsInput.class, evcsInputFactory)), + "Validation") + .transformF(FailedValidationException::new) + .getOrThrow(); } /** @@ -93,51 +108,84 @@ public SystemParticipantSource( * validity e.g. in the sense that not duplicate UUIDs exist within all entities contained in the * returning instance. * - * @return either a valid, complete {@link SystemParticipants} or throws a {@link SourceException} + * @return a valid, complete {@link SystemParticipants} + * @throws SourceException on error */ public SystemParticipants getSystemParticipants() throws SourceException { + Map operators = typeSource.getOperators(); + Map nodes = rawGridSource.getNodes(operators); + + return getSystemParticipants(operators, nodes); + } + + /** + * Should return either a consistent instance of {@link SystemParticipants} or throw a {@link + * SourceException}. The decision to throw a {@link SourceException} instead of returning the + * incomplete {@link SystemParticipants} instance is motivated by the fact, that a {@link + * SystemParticipants} is a container instance that depends on several other entities. Without + * being complete, it is useless for further processing. + * + *

Hence, whenever at least one entity {@link SystemParticipants} depends on cannot be + * provided, {@link SourceException} should be thrown. The thrown exception should provide enough + * information to debug the error and fix the persistent data that has been failed to processed. + * + *

Furthermore, it is expected, that the specific implementation of this method ensures not + * only the completeness of the resulting {@link SystemParticipants} instance, but also its + * validity e.g. in the sense that not duplicate UUIDs exist within all entities contained in the + * returning instance. + * + *

In contrast to {@link #getSystemParticipants()}, this method provides the ability to pass in + * already existing input objects that this method depends on. Doing so, already loaded operators + * and nodes can be recycled to improve performance and prevent unnecessary loading operations. + * + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @return a valid, complete {@link SystemParticipants} + * @throws SourceException on error + */ + public SystemParticipants getSystemParticipants( + Map operators, Map nodes) throws SourceException { + // read all needed entities /// start with types and operators - Set operators = typeSource.getOperators(); - Set bmTypes = typeSource.getBmTypes(); - Set chpTypes = typeSource.getChpTypes(); - Set evTypes = typeSource.getEvTypes(); - Set hpTypes = typeSource.getHpTypes(); - Set storageTypes = typeSource.getStorageTypes(); - Set wecTypes = typeSource.getWecTypes(); + Map bmTypes = typeSource.getBmTypes(); + Map chpTypes = typeSource.getChpTypes(); + Map evTypes = typeSource.getEvTypes(); + Map hpTypes = typeSource.getHpTypes(); + Map storageTypes = typeSource.getStorageTypes(); + Map wecTypes = typeSource.getWecTypes(); + Map emUnits = energyManagementSource.getEmUnits(); /// go on with the thermal assets - Set thermalBuses = thermalSource.getThermalBuses(operators); - Set thermalStorages = + Map thermalBuses = thermalSource.getThermalBuses(operators); + Map thermalStorages = thermalSource.getThermalStorages(operators, thermalBuses); - /// go on with the nodes - Set nodes = rawGridSource.getNodes(operators); Try, SourceException> fixedFeedInInputs = - Try.of(() -> getFixedFeedIns(nodes, operators), SourceException.class); + Try.of(() -> getFixedFeedIns(operators, nodes, emUnits), SourceException.class); Try, SourceException> pvInputs = - Try.of(() -> getPvPlants(nodes, operators), SourceException.class); + Try.of(() -> getPvPlants(operators, nodes, emUnits), SourceException.class); Try, SourceException> loads = - Try.of(() -> getLoads(nodes, operators), SourceException.class); + Try.of(() -> getLoads(operators, nodes, emUnits), SourceException.class); Try, SourceException> bmInputs = - Try.of(() -> getBmPlants(nodes, operators, bmTypes), SourceException.class); + Try.of(() -> getBmPlants(operators, nodes, emUnits, bmTypes), SourceException.class); Try, SourceException> storages = - Try.of(() -> getStorages(nodes, operators, storageTypes), SourceException.class); + Try.of(() -> getStorages(operators, nodes, emUnits, storageTypes), SourceException.class); Try, SourceException> wecInputs = - Try.of(() -> getWecPlants(nodes, operators, wecTypes), SourceException.class); + Try.of(() -> getWecPlants(operators, nodes, emUnits, wecTypes), SourceException.class); Try, SourceException> evs = - Try.of(() -> getEvs(nodes, operators, evTypes), SourceException.class); + Try.of(() -> getEvs(operators, nodes, emUnits, evTypes), SourceException.class); Try, SourceException> evcs = - Try.of(() -> getEvCS(nodes, operators), SourceException.class); + Try.of(() -> getEvcs(operators, nodes, emUnits), SourceException.class); Try, SourceException> chpInputs = Try.of( - () -> getChpPlants(nodes, operators, chpTypes, thermalBuses, thermalStorages), + () -> getChpPlants(operators, nodes, emUnits, chpTypes, thermalBuses, thermalStorages), SourceException.class); Try, SourceException> hpInputs = - Try.of(() -> getHeatPumps(nodes, operators, hpTypes, thermalBuses), SourceException.class); - Try, SourceException> emInputs = - Try.of(() -> getEmSystems(nodes, operators), SourceException.class); + Try.of( + () -> getHeatPumps(operators, nodes, emUnits, hpTypes, thermalBuses), + SourceException.class); List exceptions = Try.getExceptions( @@ -151,8 +199,7 @@ public SystemParticipants getSystemParticipants() throws SourceException { evs, evcs, chpInputs, - hpInputs, - emInputs)); + hpInputs)); if (!exceptions.isEmpty()) { throw new SystemParticipantsException( @@ -172,8 +219,7 @@ public SystemParticipants getSystemParticipants() throws SourceException { loads.getOrThrow(), pvInputs.getOrThrow(), storages.getOrThrow(), - wecInputs.getOrThrow(), - emInputs.getOrThrow()); + wecInputs.getOrThrow()); } } @@ -185,11 +231,12 @@ public SystemParticipants getSystemParticipants() throws SourceException { * manually, as {@link FixedFeedInInput#equals(Object)} is NOT restricted on the uuid of {@link * FixedFeedInInput}. * - * @return a set of object and uuid unique {@link FixedFeedInInput} entities + * @return a set of object- and uuid-unique {@link FixedFeedInInput} entities */ public Set getFixedFeedIns() throws SourceException { - Set operators = typeSource.getOperators(); - return getFixedFeedIns(rawGridSource.getNodes(operators), operators); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getFixedFeedIns(operators, rawGridSource.getNodes(operators), emUnits); } /** @@ -206,19 +253,18 @@ public Set getFixedFeedIns() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link FixedFeedInInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @return a set of object- and uuid-unique {@link FixedFeedInInput} entities */ - public Set getFixedFeedIns(Set nodes, Set operators) + public Set getFixedFeedIns( + Map operators, Map nodes, Map emUnits) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities( - FixedFeedInInput.class, fixedFeedInInputFactory, nodes, operators), - FixedFeedInInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildSystemParticipantEntityData(FixedFeedInInput.class, operators, nodes, emUnits) + .map(fixedFeedInInputFactory::get), + FixedFeedInInput.class); } /** @@ -228,11 +274,12 @@ public Set getFixedFeedIns(Set nodes, Set getPvPlants() throws SourceException { - Set operators = typeSource.getOperators(); - return getPvPlants(rawGridSource.getNodes(operators), operators); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getPvPlants(operators, rawGridSource.getNodes(operators), emUnits); } /** @@ -249,17 +296,18 @@ public Set getPvPlants() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link PvInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @return a set of object- and uuid-unique {@link PvInput} entities */ - public Set getPvPlants(Set nodes, Set operators) + public Set getPvPlants( + Map operators, Map nodes, Map emUnits) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities(PvInput.class, pvInputFactory, nodes, operators), PvInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildSystemParticipantEntityData(PvInput.class, operators, nodes, emUnits) + .map(pvInputFactory::get), + PvInput.class); } /** @@ -269,11 +317,12 @@ public Set getPvPlants(Set nodes, Set operato * java.util.UUID} uniqueness of the provided {@link LoadInput} which has to be checked manually, * as {@link LoadInput#equals(Object)} is NOT restricted on the uuid of {@link LoadInput}. * - * @return a set of object and uuid unique {@link LoadInput} entities + * @return a set of object- and uuid-unique {@link LoadInput} entities */ public Set getLoads() throws SourceException { - Set operators = typeSource.getOperators(); - return getLoads(rawGridSource.getNodes(operators), operators); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getLoads(operators, rawGridSource.getNodes(operators), emUnits); } /** @@ -290,18 +339,18 @@ public Set getLoads() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link LoadInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @return a set of object- and uuid-unique {@link LoadInput} entities */ - public Set getLoads(Set nodes, Set operators) + public Set getLoads( + Map operators, Map nodes, Map emUnits) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities(LoadInput.class, loadInputFactory, nodes, operators), - LoadInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildSystemParticipantEntityData(LoadInput.class, operators, nodes, emUnits) + .map(loadInputFactory::get), + LoadInput.class); } /** @@ -311,11 +360,12 @@ public Set getLoads(Set nodes, Set operator * java.util.UUID} uniqueness of the provided {@link EvcsInput} which has to be checked manually, * as {@link EvcsInput#equals(Object)} is NOT restricted on the uuid of {@link EvcsInput}. * - * @return a set of object and uuid unique {@link EvcsInput} entities + * @return a set of object- and uuid-unique {@link EvcsInput} entities */ - public Set getEvCS() throws SourceException { - Set operators = typeSource.getOperators(); - return getEvCS(rawGridSource.getNodes(operators), operators); + public Set getEvcs() throws SourceException { + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getEvcs(operators, rawGridSource.getNodes(operators), emUnits); } /** @@ -324,7 +374,7 @@ public Set getEvCS() throws SourceException { * EvcsInput} which has to be checked manually, as {@link EvcsInput#equals(Object)} is NOT * restricted on the uuid of {@link EvcsInput}. * - *

In contrast to {@link #getEvCS()} this method provides the ability to pass in an already + *

In contrast to {@link #getEvcs()} this method provides the ability to pass in an already * existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link EvcsInput} * instances depend on. Doing so, already loaded nodes can be recycled to improve performance and * prevent unnecessary loading operations. @@ -332,18 +382,18 @@ public Set getEvCS() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link EvcsInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @return a set of object- and uuid-unique {@link EvcsInput} entities */ - public Set getEvCS(Set nodes, Set operators) + public Set getEvcs( + Map operators, Map nodes, Map emUnits) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities(EvcsInput.class, evcsInputFactory, nodes, operators), - EvcsInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildSystemParticipantEntityData(EvcsInput.class, operators, nodes, emUnits) + .map(evcsInputFactory::get), + EvcsInput.class); } /** @@ -353,11 +403,13 @@ public Set getEvCS(Set nodes, Set operators * java.util.UUID} uniqueness of the provided {@link BmInput} which has to be checked manually, as * {@link BmInput#equals(Object)} is NOT restricted on the uuid of {@link BmInput}. * - * @return a set of object and uuid unique {@link BmInput} entities + * @return a set of object- and uuid-unique {@link BmInput} entities */ public Set getBmPlants() throws SourceException { - Set operators = typeSource.getOperators(); - return getBmPlants(rawGridSource.getNodes(operators), operators, typeSource.getBmTypes()); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getBmPlants( + operators, rawGridSource.getNodes(operators), emUnits, typeSource.getBmTypes()); } /** @@ -374,21 +426,22 @@ public Set getBmPlants() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param types a set of object and uuid unique {@link BmTypeInput} entities - * @return a set of object and uuid unique {@link BmInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link BmTypeInput} entities + * @return a set of object- and uuid-unique {@link BmInput} entities */ public Set getBmPlants( - Set nodes, Set operators, Set types) + Map operators, + Map nodes, + Map emUnits, + Map types) throws SourceException { - return Try.scanCollection( - buildTypedSystemParticipantEntities( - BmInput.class, bmInputFactory, nodes, operators, types), - BmInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildTypedSystemParticipantEntityData(BmInput.class, operators, nodes, emUnits, types) + .map(bmInputFactory::get), + BmInput.class); } /** @@ -399,11 +452,13 @@ public Set getBmPlants( * manually, as {@link StorageInput#equals(Object)} is NOT restricted on the uuid of {@link * StorageInput}. * - * @return a set of object and uuid unique {@link StorageInput} entities + * @return a set of object- and uuid-unique {@link StorageInput} entities */ public Set getStorages() throws SourceException { - Set operators = typeSource.getOperators(); - return getStorages(rawGridSource.getNodes(operators), operators, typeSource.getStorageTypes()); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getStorages( + operators, rawGridSource.getNodes(operators), emUnits, typeSource.getStorageTypes()); } /** @@ -420,21 +475,23 @@ public Set getStorages() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param types a set of object and uuid unique {@link StorageTypeInput} entities - * @return a set of object and uuid unique {@link StorageInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} that should be + * used for the returning instances + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link StorageTypeInput} entities + * @return a set of object- and uuid-unique {@link StorageInput} entities */ public Set getStorages( - Set nodes, Set operators, Set types) + Map operators, + Map nodes, + Map emUnits, + Map types) throws SourceException { - return Try.scanCollection( - buildTypedSystemParticipantEntities( - StorageInput.class, storageInputFactory, nodes, operators, types), - StorageInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildTypedSystemParticipantEntityData(StorageInput.class, operators, nodes, emUnits, types) + .map(storageInputFactory::get), + StorageInput.class); } /** @@ -444,11 +501,13 @@ public Set getStorages( * java.util.UUID} uniqueness of the provided {@link WecInput} which has to be checked manually, * as {@link WecInput#equals(Object)} is NOT restricted on the uuid of {@link WecInput}. * - * @return a set of object and uuid unique {@link WecInput} entities + * @return a set of object- and uuid-unique {@link WecInput} entities */ public Set getWecPlants() throws SourceException { - Set operators = typeSource.getOperators(); - return getWecPlants(rawGridSource.getNodes(operators), operators, typeSource.getWecTypes()); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getWecPlants( + operators, rawGridSource.getNodes(operators), emUnits, typeSource.getWecTypes()); } /** @@ -465,21 +524,22 @@ public Set getWecPlants() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param types a set of object and uuid unique {@link WecTypeInput} entities - * @return a set of object and uuid unique {@link WecInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link WecTypeInput} entities + * @return a set of object- and uuid-unique {@link WecInput} entities */ public Set getWecPlants( - Set nodes, Set operators, Set types) + Map operators, + Map nodes, + Map emUnits, + Map types) throws SourceException { - return Try.scanCollection( - buildTypedSystemParticipantEntities( - WecInput.class, wecInputFactory, nodes, operators, types), - WecInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildTypedSystemParticipantEntityData(WecInput.class, operators, nodes, emUnits, types) + .map(wecInputFactory::get), + WecInput.class); } /** @@ -489,11 +549,12 @@ public Set getWecPlants( * java.util.UUID} uniqueness of the provided {@link EvInput} which has to be checked manually, as * {@link EvInput#equals(Object)} is NOT restricted on the uuid of {@link EvInput}. * - * @return a set of object and uuid unique {@link EvInput} entities + * @return a set of object- and uuid-unique {@link EvInput} entities */ public Set getEvs() throws SourceException { - Set operators = typeSource.getOperators(); - return getEvs(rawGridSource.getNodes(operators), operators, typeSource.getEvTypes()); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + return getEvs(operators, rawGridSource.getNodes(operators), emUnits, typeSource.getEvTypes()); } /** @@ -510,69 +571,32 @@ public Set getEvs() throws SourceException { *

If something fails during the creation process a {@link SourceException} is thrown, else a * set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @param types a set of object and uuid unique {@link EvTypeInput} entities - * @return a set of object and uuid unique {@link EvInput} entities + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link EvTypeInput} entities + * @return a set of object- and uuid-unique {@link EvInput} entities */ public Set getEvs( - Set nodes, Set operators, Set types) - throws SourceException { - return Try.scanCollection( - buildTypedSystemParticipantEntities( - EvInput.class, evInputFactory, nodes, operators, types), - EvInput.class) - .transformF(SourceException::new) - .getOrThrow(); - } - - /** - * Returns a unique set of {@link EmInput} instances. - * - *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link - * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as - * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. - * - * @return a set of object and uuid unique {@link EmInput} entities - */ - public Set getEmSystems() throws SourceException { - Set operators = typeSource.getOperators(); - return getEmSystems(rawGridSource.getNodes(operators), operators); - } - - /** - * This set has to be unique in the sense of object uniqueness but also in the sense of {@link - * java.util.UUID} uniqueness of the provided {@link EmInput} which has to be checked manually, as - * {@link EmInput#equals(Object)} is NOT restricted on the uuid of {@link EmInput}. - * - *

In contrast to {@link #getHeatPumps()} this method provides the ability to pass in an - * already existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link - * EmInput} instances depend on. Doing so, already loaded nodes can be recycled to improve - * performance and prevent unnecessary loading operations. - * - *

If something fails during the creation process a {@link SourceException} is thrown, else a - * set with all entities that has been able to be build is returned. - * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param nodes a set of object and uuid unique {@link NodeInput} entities - * @return a set of object and uuid unique {@link EmInput} entities - */ - public Set getEmSystems(Set nodes, Set operators) + Map operators, + Map nodes, + Map emUnits, + Map types) throws SourceException { - return Try.scanCollection( - buildNodeAssetEntities(EmInput.class, emInputFactory, nodes, operators), EmInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + buildTypedSystemParticipantEntityData(EvInput.class, operators, nodes, emUnits, types) + .map(evInputFactory::get), + EvInput.class); } public Set getChpPlants() throws SourceException { - Set operators = typeSource.getOperators(); - Set thermalBuses = thermalSource.getThermalBuses(operators); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); + Map thermalBuses = thermalSource.getThermalBuses(operators); return getChpPlants( - rawGridSource.getNodes(operators), operators, + rawGridSource.getNodes(operators), + emUnits, typeSource.getChpTypes(), thermalBuses, thermalSource.getThermalStorages(operators, thermalBuses)); @@ -587,27 +611,41 @@ public Set getChpPlants() throws SourceException { * *

If the set with {@link OperatorInput} is not exhaustive, the corresponding operator is set * to {@link OperatorInput#NO_OPERATOR_ASSIGNED} + * + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link ChpTypeInput} entities + * @param thermalBuses a map of UUID to object- and uuid-unique {@link ThermalBusInput} entities + * @param thermalStorages a map of UUID to object- and uuid-unique {@link ThermalStorageInput} + * entities + * @return a set of object- and uuid-unique {@link ChpInput} entities */ public Set getChpPlants( - Set nodes, - Set operators, - Set types, - Set thermalBuses, - Set thermalStorages) + Map operators, + Map nodes, + Map emUnits, + Map types, + Map thermalBuses, + Map thermalStorages) throws SourceException { - return Try.scanCollection( - buildChpInputEntities( - chpInputFactory, nodes, operators, types, thermalBuses, thermalStorages), - ChpInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + chpEntityStream( + buildTypedSystemParticipantEntityData( + ChpInput.class, operators, nodes, emUnits, types), + thermalStorages, + thermalBuses) + .map(chpInputFactory::get), + ChpInput.class); } public Set getHeatPumps() throws SourceException { - Set operators = typeSource.getOperators(); + Map operators = typeSource.getOperators(); + Map emUnits = energyManagementSource.getEmUnits(operators); return getHeatPumps( - rawGridSource.getNodes(operators), operators, + rawGridSource.getNodes(operators), + emUnits, typeSource.getHpTypes(), thermalSource.getThermalBuses()); } @@ -621,357 +659,169 @@ public Set getHeatPumps() throws SourceException { * *

If the set with {@link OperatorInput} is not exhaustive, the corresponding operator is set * to {@link OperatorInput#NO_OPERATOR_ASSIGNED} + * + * @param operators a map of UUID to object- and uuid-unique {@link OperatorInput} entities + * @param nodes a map of UUID to object- and uuid-unique {@link NodeInput} entities + * @param emUnits a map of UUID to object- and uuid-unique {@link EmInput} entities + * @param types a map of UUID to object- and uuid-unique {@link HpTypeInput} entities + * @param thermalBuses a map of UUID to object- and uuid-unique {@link ThermalBusInput} entities + * @return a set of object- and uuid-unique {@link HpInput} entities */ public Set getHeatPumps( - Set nodes, - Set operators, - Set types, - Set thermalBuses) + Map operators, + Map nodes, + Map emUnits, + Map types, + Map thermalBuses) throws SourceException { - return Try.scanCollection( - buildHpInputEntities(hpInputFactory, nodes, operators, types, thermalBuses), - HpInput.class) - .transformF(SourceException::new) - .getOrThrow(); + return unpackSet( + hpEntityStream( + buildTypedSystemParticipantEntityData( + HpInput.class, operators, nodes, emUnits, types), + thermalBuses) + .map(hpInputFactory::get), + HpInput.class); } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - private - Set> buildTypedSystemParticipantEntities( - Class entityClass, - EntityFactory> factory, - Collection nodes, - Collection operators, - Collection types) { - return typedSystemParticipantEntityStream(entityClass, factory, nodes, operators, types) - .collect(Collectors.toSet()); - } - - private Set> buildChpInputEntities( - ChpInputFactory factory, - Collection nodes, - Collection operators, - Collection chpTypes, - Collection thermalBuses, - Collection thermalStorages) { - return chpInputStream(factory, nodes, operators, chpTypes, thermalBuses, thermalStorages) - .collect(Collectors.toSet()); - } + private static Stream> chpEntityStream( + Stream, SourceException>> + typedEntityDataStream, + Map thermalStorages, + Map thermalBuses) { - private Set> buildHpInputEntities( - HpInputFactory factory, - Collection nodes, - Collection operators, - Collection types, - Collection thermalBuses) { - return hpInputStream(factory, nodes, operators, types, thermalBuses) - .collect(Collectors.toSet()); + return typedEntityDataStream + .parallel() + .map( + typedEntityDataOpt -> + typedEntityDataOpt.flatMap( + typedEntityData -> + enrichEntityData( + typedEntityData, + THERMAL_BUS, + thermalBuses, + THERMAL_STORAGE, + thermalStorages, + ChpInputEntityData::new))); } - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - /** - * Constructs a stream of {@link SystemParticipantInput} entities wrapped in {@link Try}'s. + * Enriches a given stream of {@link SystemParticipantTypedEntityData} tries with a type of {@link + * ThermalBusInput} based on the provided collection of buses and the fields to values mapping + * inside the already provided {@link SystemParticipantTypedEntityData} instance. * - * @param entityClass the class of the entities that should be built - * @param factory the corresponding factory that is capable of building this entities - * @param nodes the nodes that should be considered for these entities - * @param operators the operators that should be considered for these entities - * @param types the types that should be considered for these entities - * @param the type of the resulting entity - * @param the type of the type model of the resulting entity - * @return a stream of tries being either empty or holding an instance of a {@link - * SystemParticipantInput} of the requested entity class + * @param typedEntityDataStream the data stream of {@link SystemParticipantTypedEntityData} tries + * @param thermalBuses the thermal buses that should be used for enrichment and to build {@link + * HpInputEntityData} + * @return stream of tries of {@link HpInputEntityData} instances */ - private - Stream> typedSystemParticipantEntityStream( - Class entityClass, - EntityFactory> factory, - Collection nodes, - Collection operators, - Collection types) { - return buildTypedSystemParticipantEntityData( - nodeAssetInputEntityDataStream( - assetInputEntityDataStream(entityClass, operators), nodes), - types) - .map(factory::get); - } - - private Stream> chpInputStream( - ChpInputFactory factory, - Collection nodes, - Collection operators, - Collection types, - Collection thermalBuses, - Collection thermalStorages) { - return buildChpEntityData( - buildTypedEntityData( - nodeAssetInputEntityDataStream( - assetInputEntityDataStream(ChpInput.class, operators), nodes), - types), - thermalStorages, - thermalBuses) - .map(factory::get); - } + private static Stream> hpEntityStream( + Stream, SourceException>> + typedEntityDataStream, + Map thermalBuses) { - private Stream> hpInputStream( - HpInputFactory factory, - Collection nodes, - Collection operators, - Collection types, - Collection thermalBuses) { - return buildHpEntityData( - buildTypedEntityData( - nodeAssetInputEntityDataStream( - assetInputEntityDataStream(HpInput.class, operators), nodes), - types), - thermalBuses) - .map(factory::get); + return typedEntityDataStream + .parallel() + .map( + typedEntityDataOpt -> + typedEntityDataOpt.flatMap( + typedEntityData -> + enrichEntityData( + typedEntityData, THERMAL_BUS, thermalBuses, HpInputEntityData::new))); } /** - * Enriches a given stream of {@link NodeAssetInputEntityData} {@link Try} objects with a type of - * {@link SystemParticipantTypeInput} based on the provided collection of types and the fields to - * values mapping that inside the already provided {@link NodeAssetInputEntityData} instance. + * Constructs a stream of {@link SystemParticipantTypedEntityData} wrapped in {@link Try}'s. * - * @param nodeAssetEntityDataStream the data stream of {@link NodeAssetInputEntityData} {@link - * Try} objects - * @param types the types that should be used for enrichment and to build {@link - * SystemParticipantTypedEntityData} from - * @param the type of the provided entity types as well as the type parameter of the resulting - * {@link SystemParticipantTypedEntityData} - * @return a stream of tries of {@link SystemParticipantTypedEntityData} instances + * @param entityClass the class of the entities that should be built + * @param operators the operators that should be considered for these entities + * @param nodes the nodes that should be considered for these entities + * @param types the types that should be considered for these entities + * @param the type of the type model of the resulting entity + * @return a stream of tries holding an instance of a {@link SystemParticipantTypedEntityData} */ private Stream, SourceException>> buildTypedSystemParticipantEntityData( - Stream> nodeAssetEntityDataStream, - Collection types) { - return nodeAssetEntityDataStream - .parallel() - .map( - nodeAssetInputEntityDataOpt -> - nodeAssetInputEntityDataOpt.flatMap( - nodeAssetInputEntityData -> - buildTypedSystemParticipantEntityData(nodeAssetInputEntityData, types))); - } - - protected - Try, SourceException> - buildTypedSystemParticipantEntityData( - NodeAssetInputEntityData nodeAssetInputEntityData, Collection types) { - return getAssetType( - types, - nodeAssetInputEntityData.getFieldsToValues(), - nodeAssetInputEntityData.getClass().getSimpleName()) - .map( - // if the optional is present, transform and return to the data, - // otherwise return an empty optional - assetType -> { - Map fieldsToAttributes = nodeAssetInputEntityData.getFieldsToValues(); - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(TYPE); - - return new SystemParticipantTypedEntityData<>( - fieldsToAttributes, - nodeAssetInputEntityData.getTargetClass(), - nodeAssetInputEntityData.getOperatorInput(), - nodeAssetInputEntityData.getNode(), - assetType); - }); + Class entityClass, + Map operators, + Map nodes, + Map emUnits, + Map types) { + return typedSystemParticipantEntityStream( + buildSystemParticipantEntityData(entityClass, operators, nodes, emUnits), types); } /** - * Enriches a given stream of {@link NodeAssetInputEntityData} tries with a type of {@link - * SystemParticipantTypeInput} based on the provided collection of types and the fields to values - * mapping that inside the already provided {@link NodeAssetInputEntityData} instance. + * Enriches a given stream of {@link SystemParticipantEntityData} {@link Try} objects with a type + * of {@link SystemParticipantTypeInput} based on the provided collection of types and the fields + * to values mapping that inside the already provided {@link SystemParticipantEntityData} + * instance. * - * @param nodeAssetEntityDataStream the data stream of {@link NodeAssetInputEntityData} tries + * @param systemParticipantEntityDataStream the data stream of {@link SystemParticipantEntityData} + * {@link Try} objects * @param types the types that should be used for enrichment and to build {@link * SystemParticipantTypedEntityData} from * @param the type of the provided entity types as well as the type parameter of the resulting * {@link SystemParticipantTypedEntityData} * @return a stream of tries of {@link SystemParticipantTypedEntityData} instances */ - private - Stream, SourceException>> buildTypedEntityData( - Stream> nodeAssetEntityDataStream, - Collection types) { - return nodeAssetEntityDataStream + private static + Stream, SourceException>> + typedSystemParticipantEntityStream( + Stream> + systemParticipantEntityDataStream, + Map types) { + return systemParticipantEntityDataStream .parallel() .map( - nodeAssetInputEntityDataOpt -> - nodeAssetInputEntityDataOpt.flatMap( - nodeAssetInputEntityData -> - buildTypedEntityData(nodeAssetInputEntityData, types))); - } - - protected - Try, SourceException> buildTypedEntityData( - NodeAssetInputEntityData nodeAssetInputEntityData, Collection types) { - return getAssetType( - types, - nodeAssetInputEntityData.getFieldsToValues(), - nodeAssetInputEntityData.getClass().getSimpleName()) - .map( - // if the optional is present, transform and return to the data, - // otherwise return an empty optional - assetType -> { - Map fieldsToAttributes = nodeAssetInputEntityData.getFieldsToValues(); - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(TYPE); - - return new SystemParticipantTypedEntityData<>( - fieldsToAttributes, - nodeAssetInputEntityData.getTargetClass(), - nodeAssetInputEntityData.getOperatorInput(), - nodeAssetInputEntityData.getNode(), - assetType); - }); + participantEntityDataTry -> + participantEntityDataTry.flatMap( + participantEntityData -> + enrichEntityData( + participantEntityData, + TYPE, + types, + SystemParticipantTypedEntityData::new))); + } + + private Stream> + buildSystemParticipantEntityData( + Class entityClass, + Map operators, + Map nodes, + Map emUnits) { + return systemParticipantEntityStream( + buildNodeAssetEntityData(entityClass, operators, nodes), emUnits); } /** - * Enriches a given stream of {@link SystemParticipantTypedEntityData} tries with a type of {@link - * ThermalBusInput} based on the provided collection of buses and the fields to values mapping - * inside the already provided {@link SystemParticipantTypedEntityData} instance. + * Enriches a given stream of {@link NodeAssetInputEntityData} {@link Try} objects with a type of + * {@link EmInput} based on the provided collection of EMs and the fields to values mapping that + * inside the already provided {@link NodeAssetInputEntityData} instance. * - * @param typedEntityDataStream the data stream of {@link SystemParticipantTypedEntityData} tries - * @param thermalBuses the thermal buses that should be used for enrichment and to build {@link - * HpInputEntityData} - * @return stream of tries of {@link HpInputEntityData} instances + * @param nodeAssetEntityDataStream the data stream of {@link NodeAssetInputEntityData} {@link + * Try} objects + * @param emUnits the energy management units that should be used for enrichment and to build + * {@link SystemParticipantEntityData} from + * @return a stream of tries of {@link SystemParticipantEntityData} instances */ - private Stream> buildHpEntityData( - Stream, SourceException>> - typedEntityDataStream, - Collection thermalBuses) { - - return typedEntityDataStream - .parallel() - .map( - typedEntityDataOpt -> - typedEntityDataOpt.flatMap( - typedEntityData -> buildHpEntityData(typedEntityData, thermalBuses))); - } - - protected Try buildHpEntityData( - SystemParticipantTypedEntityData typedEntityData, - Collection thermalBuses) { - // get the raw data - Map fieldsToAttributes = typedEntityData.getFieldsToValues(); - - // get the thermal bus input for this chp unit and try to built the entity data - Optional hpInputEntityDataOpt = - Optional.ofNullable(fieldsToAttributes.get(THERMAL_BUS)) - .flatMap( - thermalBusUuid -> - thermalBuses.stream() - .filter( - storage -> - storage.getUuid().toString().equalsIgnoreCase(thermalBusUuid)) - .findFirst() - .map( - thermalBus -> { - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().remove(THERMAL_BUS); - - return new HpInputEntityData( - fieldsToAttributes, - typedEntityData.getOperatorInput(), - typedEntityData.getNode(), - typedEntityData.getTypeInput(), - thermalBus); - })); - - // if the requested entity is not present we return an empty element and - // log a warning - if (hpInputEntityDataOpt.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - typedEntityData.getTargetClass().getSimpleName(), - safeMapGet(fieldsToAttributes, "uuid", FIELDS_TO_VALUES_MAP), - safeMapGet(fieldsToAttributes, "id", FIELDS_TO_VALUES_MAP), - "thermalBus: " + safeMapGet(fieldsToAttributes, THERMAL_BUS, FIELDS_TO_VALUES_MAP)); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - return new Success<>(hpInputEntityDataOpt.get()); - } - - private Stream> buildChpEntityData( - Stream, SourceException>> - typedEntityDataStream, - Collection thermalStorages, - Collection thermalBuses) { - - return typedEntityDataStream + private static Stream> + systemParticipantEntityStream( + Stream> nodeAssetEntityDataStream, + Map emUnits) { + return nodeAssetEntityDataStream .parallel() .map( - typedEntityDataOpt -> - typedEntityDataOpt.flatMap( - typedEntityData -> - buildChpEntityData(typedEntityData, thermalStorages, thermalBuses))); - } - - protected Try buildChpEntityData( - SystemParticipantTypedEntityData typedEntityData, - Collection thermalStorages, - Collection thermalBuses) { - - // get the raw data - Map fieldsToAttributes = typedEntityData.getFieldsToValues(); - - // get the thermal storage input for this chp unit - Optional thermalStorage = - Optional.ofNullable(fieldsToAttributes.get(THERMAL_STORAGE)) - .flatMap( - thermalStorageUuid -> - findFirstEntityByUuid(UUID.fromString(thermalStorageUuid), thermalStorages)); - - // get the thermal bus input for this chp unit - Optional thermalBus = - Optional.ofNullable(fieldsToAttributes.get("thermalBus")) - .flatMap( - thermalBusUuid -> - findFirstEntityByUuid(UUID.fromString(thermalBusUuid), thermalBuses)); - - // if the thermal storage or the thermal bus are not present we return an - // empty element and log a warning - if (thermalStorage.isEmpty() || thermalBus.isEmpty()) { - StringBuilder sB = new StringBuilder(); - if (thermalStorage.isEmpty()) { - sB.append("thermalStorage: ") - .append(safeMapGet(fieldsToAttributes, THERMAL_STORAGE, FIELDS_TO_VALUES_MAP)); - } - if (thermalBus.isEmpty()) { - sB.append("\nthermalBus: ") - .append(safeMapGet(fieldsToAttributes, THERMAL_BUS, FIELDS_TO_VALUES_MAP)); - } - - String skippingMessage = - buildSkippingMessage( - typedEntityData.getTargetClass().getSimpleName(), - safeMapGet(fieldsToAttributes, "uuid", FIELDS_TO_VALUES_MAP), - safeMapGet(fieldsToAttributes, "id", FIELDS_TO_VALUES_MAP), - sB.toString()); - return new Failure<>(new SourceException("Failure due to: " + skippingMessage)); - } - - // remove fields that are passed as objects to constructor - fieldsToAttributes - .keySet() - .removeAll(new HashSet<>(Arrays.asList("thermalBus", "thermalStorage"))); - - return new Success<>( - new ChpInputEntityData( - fieldsToAttributes, - typedEntityData.getOperatorInput(), - typedEntityData.getNode(), - typedEntityData.getTypeInput(), - thermalBus.get(), - thermalStorage.get())); + nodeAssetInputEntityDataTry -> + nodeAssetInputEntityDataTry.flatMap( + nodeAssetInputEntityData -> + optionallyEnrichEntityData( + nodeAssetInputEntityData, + SystemParticipantInputEntityFactory.EM, + emUnits, + null, + SystemParticipantEntityData::new))); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java index 48384565f..c83aa4e36 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/ThermalSource.java @@ -5,18 +5,19 @@ */ package edu.ie3.datamodel.io.source; -import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.exceptions.FailureException; -import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.*; import edu.ie3.datamodel.io.factory.input.*; +import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput; import edu.ie3.datamodel.models.input.thermal.ThermalBusInput; import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput; import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; import edu.ie3.datamodel.utils.Try; -import edu.ie3.datamodel.utils.Try.*; -import java.util.*; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -38,33 +39,47 @@ public class ThermalSource extends EntitySource { private final ThermalHouseInputFactory thermalHouseInputFactory; public ThermalSource(TypeSource typeSource, DataSource dataSource) { + super(dataSource); this.typeSource = typeSource; - this.dataSource = dataSource; this.thermalBusInputFactory = new ThermalBusInputFactory(); this.cylindricalStorageInputFactory = new CylindricalStorageInputFactory(); this.thermalHouseInputFactory = new ThermalHouseInputFactory(); } + @Override + public void validate() throws ValidationException { + Try.scanStream( + Stream.of( + validate(ThermalBusInput.class, thermalBusInputFactory), + validate(CylindricalStorageInput.class, cylindricalStorageInputFactory), + validate(ThermalHouseInput.class, thermalHouseInputFactory)), + "Validation") + .transformF(FailedValidationException::new) + .getOrThrow(); + } + /** - * Returns a unique set of {@link ThermalBusInput} instances. + * Returns a unique set of {@link ThermalBusInput} instances within a map by UUID. * *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link * java.util.UUID} uniqueness of the provided {@link ThermalBusInput} which has to be checked * manually, as {@link ThermalBusInput#equals(Object)} is NOT restricted on the uuid of {@link * ThermalBusInput}. * - * @return a set of object and uuid unique {@link ThermalBusInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalBusInput} entities */ - public Set getThermalBuses() throws SourceException { + public Map getThermalBuses() throws SourceException { return getThermalBuses(typeSource.getOperators()); } /** - * Returns a set of {@link ThermalBusInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link ThermalBusInput} which has to be checked manually, as {@link - * ThermalBusInput#equals(Object)} is NOT restricted on the uuid of {@link ThermalBusInput}. + * Returns a unique set of {@link ThermalBusInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link ThermalBusInput} which has to be checked + * manually, as {@link ThermalBusInput#equals(Object)} is NOT restricted on the uuid of {@link + * ThermalBusInput}. * *

In contrast to {@link #getThermalBuses()} this interface provides the ability to pass in an * already existing set of {@link OperatorInput} entities, the {@link ThermalBusInput} instances @@ -74,31 +89,31 @@ public Set getThermalBuses() throws SourceException { *

If something fails during the creation process it's up to the concrete implementation of an * empty set or a set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @return a set of object and uuid unique {@link ThermalBusInput} entities + * @param operators a set of object- and uuid-unique {@link OperatorInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalBusInput} entities */ - public Set getThermalBuses(Set operators) throws SourceException { - return Try.scanCollection( - buildAssetInputEntities(ThermalBusInput.class, thermalBusInputFactory, operators), - ThermalBusInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getThermalBuses(Map operators) + throws SourceException { + return unpackMap( + buildAssetInputEntityData(ThermalBusInput.class, operators) + .map(thermalBusInputFactory::get), + ThermalBusInput.class); } /** * Returns a unique set of instances of all entities implementing the {@link ThermalStorageInput} - * abstract class. + * abstract class within a map by UUID. * *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link * java.util.UUID} uniqueness of the provided {@link ThermalStorageInput} which has to be checked * manually, as {@link ThermalStorageInput#equals(Object)} is NOT restricted on the uuid of {@link * ThermalStorageInput}. * - * @return a set of object and uuid unique {@link ThermalStorageInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalStorageInput} entities */ - public Set getThermalStorages() throws SourceException { - return new HashSet<>(getCylindricStorages()); + public Map getThermalStorages() throws SourceException { + return getCylindricalStorages().stream() + .collect(Collectors.toMap(UniqueEntity::getUuid, Function.identity())); } /** @@ -116,15 +131,15 @@ public Set getThermalStorages() throws SourceException { *

If something fails during the creation process it's up to the concrete implementation of an * empty set or a set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param thermalBuses a set of object and uuid unique {@link ThermalBusInput} that should be used - * for the returning instances - * @return a set of object and uuid unique {@link ThermalStorageInput} entities + * @param operators a set of object- and uuid-unique {@link OperatorInput} entities + * @param thermalBuses a set of object- and uuid-unique {@link ThermalBusInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalStorageInput} entities */ - public Set getThermalStorages( - Set operators, Set thermalBuses) throws SourceException { - return new HashSet<>(getCylindricStorages(operators, thermalBuses)); + public Map getThermalStorages( + Map operators, Map thermalBuses) + throws SourceException { + return getCylindricalStorages(operators, thermalBuses).stream() + .collect(Collectors.toMap(UniqueEntity::getUuid, Function.identity())); } /** @@ -135,19 +150,22 @@ public Set getThermalStorages( * manually, as {@link ThermalHouseInput#equals(Object)} is NOT restricted on the uuid of {@link * ThermalHouseInput}. * - * @return a set of object and uuid unique {@link ThermalHouseInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalHouseInput} entities */ - public Set getThermalHouses() throws SourceException { - return buildThermalHouseInputEntities(thermalHouseInputFactory) - .transformF(SourceException::new) - .getOrThrow(); + public Map getThermalHouses() throws SourceException { + Map operators = typeSource.getOperators(); + Map thermalBuses = getThermalBuses(); + + return getThermalHouses(operators, thermalBuses); } /** - * Returns a set of {@link ThermalHouseInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link ThermalHouseInput} which has to be checked manually, as {@link - * ThermalHouseInput#equals(Object)} is NOT restricted on the uuid of {@link ThermalHouseInput}. + * Returns a set of {@link ThermalHouseInput} instances. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link ThermalHouseInput} which has to be checked + * manually, as {@link ThermalHouseInput#equals(Object)} is NOT restricted on the uuid of {@link + * ThermalHouseInput}. * *

In contrast to {@link #getThermalHouses()} this interface provides the ability to pass in an * already existing set of {@link OperatorInput} entities, the {@link ThermalHouseInput} instances @@ -157,17 +175,18 @@ public Set getThermalHouses() throws SourceException { *

If something fails during the creation process it's up to the concrete implementation of an * empty set or a set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param thermalBuses a set of object and uuid unique {@link ThermalBusInput} that should be used - * for the returning instances - * @return a set of object and uuid unique {@link ThermalHouseInput} entities + * @param operators a set of object- and uuid-unique {@link OperatorInput} entities + * @param thermalBuses a set of object- and uuid-unique {@link ThermalBusInput} entities + * @return a map of UUID to object- and uuid-unique {@link ThermalHouseInput} entities */ - public Set getThermalHouses( - Set operators, Set thermalBuses) throws SourceException { - return buildThermalHouseInputEntities(thermalHouseInputFactory, operators, thermalBuses) - .transformF(SourceException::new) - .getOrThrow(); + public Map getThermalHouses( + Map operators, Map thermalBuses) + throws SourceException { + return unpackMap( + thermalUnitInputEntityDataStream( + buildAssetInputEntityData(ThermalHouseInput.class, operators), thermalBuses) + .map(thermalHouseInputFactory::get), + ThermalHouseInput.class); } /** @@ -178,22 +197,24 @@ public Set getThermalHouses( * checked manually, as {@link CylindricalStorageInput#equals(Object)} is NOT restricted on the * uuid of {@link CylindricalStorageInput}. * - * @return a set of object and uuid unique {@link CylindricalStorageInput} entities + * @return a set of object- and uuid-unique {@link CylindricalStorageInput} entities */ - public Set getCylindricStorages() throws SourceException { - return buildCylindricalStorageInputEntities(cylindricalStorageInputFactory) - .transformF(SourceException::new) - .getOrThrow(); + public Set getCylindricalStorages() throws SourceException { + Map operators = typeSource.getOperators(); + Map thermalBuses = getThermalBuses(); + + return getCylindricalStorages(operators, thermalBuses); } /** - * Returns a set of {@link CylindricalStorageInput} instances. This set has to be unique in the - * sense of object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the - * provided {@link CylindricalStorageInput} which has to be checked manually, as {@link - * CylindricalStorageInput#equals(Object)} is NOT restricted on the uuid of {@link - * CylindricalStorageInput}. + * Returns a set of {@link CylindricalStorageInput} instances. * - *

In contrast to {@link #getCylindricStorages()} this interface provides the ability to pass + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * java.util.UUID} uniqueness of the provided {@link CylindricalStorageInput} which has to be + * checked manually, as {@link CylindricalStorageInput#equals(Object)} is NOT restricted on the + * uuid of {@link CylindricalStorageInput}. + * + *

In contrast to {@link #getCylindricalStorages()} this interface provides the ability to pass * in an already existing set of {@link OperatorInput} entities, the {@link * CylindricalStorageInput} instances depend on. Doing so, already loaded nodes can be recycled to * improve performance and prevent unnecessary loading operations. @@ -201,113 +222,45 @@ public Set getCylindricStorages() throws SourceExceptio *

If something fails during the creation process it's up to the concrete implementation of an * empty set or a set with all entities that has been able to be build is returned. * - * @param operators a set of object and uuid unique {@link OperatorInput} that should be used for - * the returning instances - * @param thermalBuses a set of object and uuid unique {@link ThermalBusInput} that should be used - * for the returning instances - * @return a set of object and uuid unique {@link CylindricalStorageInput} entities + * @param operators a set of object- and uuid-unique {@link OperatorInput} entities + * @param thermalBuses a set of object- and uuid-unique {@link ThermalBusInput} entities + * @return a set of object- and uuid-unique {@link CylindricalStorageInput} entities */ - public Set getCylindricStorages( - Set operators, Set thermalBuses) throws SourceException { - return Try.scanCollection( - buildCylindricalStorageInputEntities( - cylindricalStorageInputFactory, operators, thermalBuses), - CylindricalStorageInput.class) - .transformF(SourceException::new) - .getOrThrow(); - } - - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - - protected Stream> - buildThermalUnitInputEntityData( - AssetInputEntityData assetInputEntityData, Collection thermalBuses) { - - // get the raw data - Map fieldsToAttributes = assetInputEntityData.getFieldsToValues(); - - // get the thermal bus input for this chp unit - String thermalBusUuid = fieldsToAttributes.get("thermalbus"); - Optional thermalBus = - thermalBuses.stream() - .filter(storage -> storage.getUuid().toString().equalsIgnoreCase(thermalBusUuid)) - .findFirst(); - - // remove fields that are passed as objects to constructor - fieldsToAttributes.keySet().removeAll(new HashSet<>(Collections.singletonList("thermalbus"))); - - // if the type is not present we return an empty element and - // log a warning - if (thermalBus.isEmpty()) { - String skippingMessage = - buildSkippingMessage( - assetInputEntityData.getTargetClass().getSimpleName(), - fieldsToAttributes.get("uuid"), - fieldsToAttributes.get("id"), - "thermalBus: " + thermalBusUuid); - return Stream.of(new Failure<>(new SourceException("Failure due to: " + skippingMessage))); - } - - return Stream.of( - new Success<>( - new ThermalUnitInputEntityData( - assetInputEntityData.getFieldsToValues(), - assetInputEntityData.getTargetClass(), - assetInputEntityData.getOperatorInput(), - thermalBus.get()))); - } - - public Try, FailureException> buildThermalHouseInputEntities( - ThermalHouseInputFactory factory) throws SourceException { - Set thermalBuses = getThermalBuses(); - - return Try.scanCollection( - assetInputEntityDataStream(ThermalHouseInput.class, typeSource.getOperators()) - .flatMap( - assetInputEntityData -> - buildThermalUnitInputEntityData(assetInputEntityData, thermalBuses) - .map(factory::get)) - .collect(Collectors.toSet()), - ThermalHouseInput.class); - } - - public Try, FailureException> buildThermalHouseInputEntities( - ThermalHouseInputFactory factory, - Collection operators, - Collection thermalBuses) { - return Try.scanCollection( - assetInputEntityDataStream(ThermalHouseInput.class, operators) - .flatMap( - assetInputEntityData -> - buildThermalUnitInputEntityData(assetInputEntityData, thermalBuses) - .map(factory::get)) - .collect(Collectors.toSet()), - ThermalHouseInput.class); - } - - public Try, FailureException> buildCylindricalStorageInputEntities( - CylindricalStorageInputFactory factory) throws SourceException { - Set thermalBuses = getThermalBuses(); - - return Try.scanCollection( - assetInputEntityDataStream(CylindricalStorageInput.class, typeSource.getOperators()) - .flatMap( - assetInputEntityData -> - buildThermalUnitInputEntityData(assetInputEntityData, thermalBuses) - .map(factory::get)) - .collect(Collectors.toSet()), + public Set getCylindricalStorages( + Map operators, Map thermalBuses) + throws SourceException { + return unpackSet( + thermalUnitInputEntityDataStream( + buildAssetInputEntityData(CylindricalStorageInput.class, operators), thermalBuses) + .map(cylindricalStorageInputFactory::get), CylindricalStorageInput.class); } - public Set> buildCylindricalStorageInputEntities( - CylindricalStorageInputFactory factory, - Collection operators, - Collection thermalBuses) { - return assetInputEntityDataStream(CylindricalStorageInput.class, operators) - .flatMap( - assetInputEntityData -> - buildThermalUnitInputEntityData(assetInputEntityData, thermalBuses) - .map(factory::get)) - .collect(Collectors.toSet()); + /** + * Enriches a given stream of {@link AssetInputEntityData} {@link Try} objects with a type of + * {@link ThermalBusInput} based on the provided collection of types and the fields to values + * mapping that inside the already provided {@link AssetInputEntityData} instance. + * + * @param assetInputEntityDataStream the data stream of {@link AssetInputEntityData} {@link Try} + * objects + * @param thermalBuses the thermal buses that should be used for enrichment and to build {@link + * ThermalUnitInputEntityData} from + * @return a stream of tries of {@link ThermalUnitInputEntityData} instances + */ + private static Stream> + thermalUnitInputEntityDataStream( + Stream> assetInputEntityDataStream, + Map thermalBuses) { + return assetInputEntityDataStream + .parallel() + .map( + assetInputEntityDataTry -> + assetInputEntityDataTry.flatMap( + assetInputEntityData -> + enrichEntityData( + assetInputEntityData, + "thermalbus", + thermalBuses, + ThermalUnitInputEntityData::new))); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/TimeSeriesMappingSource.java b/src/main/java/edu/ie3/datamodel/io/source/TimeSeriesMappingSource.java index 09d4530f9..d580bc2d2 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/TimeSeriesMappingSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/TimeSeriesMappingSource.java @@ -6,15 +6,13 @@ package edu.ie3.datamodel.io.source; import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.timeseries.TimeSeriesMappingFactory; import edu.ie3.datamodel.models.input.InputEntity; import edu.ie3.datamodel.utils.Try; import edu.ie3.datamodel.utils.Try.*; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; -import java.util.UUID; +import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -24,7 +22,7 @@ */ public abstract class TimeSeriesMappingSource { - private final TimeSeriesMappingFactory mappingFactory; + protected final TimeSeriesMappingFactory mappingFactory; protected TimeSeriesMappingSource() { this.mappingFactory = new TimeSeriesMappingFactory(); @@ -35,7 +33,7 @@ protected TimeSeriesMappingSource() { * * @return That mapping */ - public Map getMapping() { + public Map getMapping() throws SourceException { return getMappingSourceData() .map(this::createMappingEntry) .filter(Try::isSuccess) @@ -50,7 +48,7 @@ public Map getMapping() { * @param modelIdentifier Identifier of the model * @return An {@link Optional} to the time series identifier */ - public Optional getTimeSeriesUuid(UUID modelIdentifier) { + public Optional getTimeSeriesUuid(UUID modelIdentifier) throws SourceException { return Optional.ofNullable(getMapping().get(modelIdentifier)); } @@ -59,13 +57,16 @@ public Optional getTimeSeriesUuid(UUID modelIdentifier) { * * @return Stream of maps */ - public abstract Stream> getMappingSourceData(); + public abstract Stream> getMappingSourceData() throws SourceException; + + /** Returns the option for fields found in the source */ + public abstract Optional> getSourceFields() throws SourceException; // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- private Try createMappingEntry( Map fieldToValues) { - SimpleEntityData entityData = new SimpleEntityData(fieldToValues, MappingEntry.class); + EntityData entityData = new EntityData(fieldToValues, MappingEntry.class); return mappingFactory.get(entityData); } diff --git a/src/main/java/edu/ie3/datamodel/io/source/TypeSource.java b/src/main/java/edu/ie3/datamodel/io/source/TypeSource.java index a7412cedc..bc1fac824 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/TypeSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/TypeSource.java @@ -5,19 +5,30 @@ */ package edu.ie3.datamodel.io.source; +import edu.ie3.datamodel.exceptions.FactoryException; +import edu.ie3.datamodel.exceptions.FailedValidationException; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.io.factory.EntityData; +import edu.ie3.datamodel.io.factory.EntityFactory; import edu.ie3.datamodel.io.factory.input.OperatorInputFactory; import edu.ie3.datamodel.io.factory.typeinput.LineTypeInputFactory; import edu.ie3.datamodel.io.factory.typeinput.SystemParticipantTypeInputFactory; import edu.ie3.datamodel.io.factory.typeinput.Transformer2WTypeInputFactory; import edu.ie3.datamodel.io.factory.typeinput.Transformer3WTypeInputFactory; +import edu.ie3.datamodel.models.input.AssetTypeInput; +import edu.ie3.datamodel.models.input.InputEntity; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.connector.type.LineTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput; import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput; import edu.ie3.datamodel.models.input.system.type.*; import edu.ie3.datamodel.utils.Try; -import java.util.Set; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Stream; /** * Interface that provides the capability to build entities of type {@link @@ -36,7 +47,7 @@ public class TypeSource extends EntitySource { private final SystemParticipantTypeInputFactory systemParticipantTypeInputFactory; public TypeSource(DataSource dataSource) { - this.dataSource = dataSource; + super(dataSource); this.operatorInputFactory = new OperatorInputFactory(); this.transformer2WTypeInputFactory = new Transformer2WTypeInputFactory(); @@ -45,160 +56,190 @@ public TypeSource(DataSource dataSource) { this.systemParticipantTypeInputFactory = new SystemParticipantTypeInputFactory(); } + @Override + public void validate() throws ValidationException { + List> participantResults = + new ArrayList<>( + Stream.of( + EvTypeInput.class, + HpTypeInput.class, + BmTypeInput.class, + WecTypeInput.class, + ChpTypeInput.class, + StorageTypeInput.class) + .map(c -> validate(c, systemParticipantTypeInputFactory)) + .toList()); + + participantResults.addAll( + List.of( + validate(OperatorInput.class, operatorInputFactory), + validate(LineTypeInput.class, lineTypeInputFactory), + validate(Transformer2WTypeInput.class, transformer2WTypeInputFactory), + validate(Transformer3WTypeInput.class, transformer3WTypeInputFactory))); + + Try.scanCollection(participantResults, Void.class) + .transformF(FailedValidationException::new) + .getOrThrow(); + } + /** - * Returns a set of {@link Transformer2WTypeInput} instances. This set has to be unique in the - * sense of object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the - * provided {@link Transformer2WTypeInput} which has to be checked manually, as {@link - * Transformer2WTypeInput#equals(Object)} is NOT restricted on the uuid of {@link - * Transformer2WTypeInput}. + * Returns a set of {@link Transformer2WTypeInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link Transformer2WTypeInput} which has to be checked + * manually, as {@link Transformer2WTypeInput#equals(Object)} is NOT restricted on the uuid of + * {@link Transformer2WTypeInput}. * - * @return a set of object and uuid unique {@link Transformer2WTypeInput} entities + * @return a map of UUID to object- and uuid-unique {@link Transformer2WTypeInput} entities */ - public Set getTransformer2WTypes() throws SourceException { - return Try.scanCollection( - buildEntities(Transformer2WTypeInput.class, transformer2WTypeInputFactory), - Transformer2WTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getTransformer2WTypes() throws SourceException { + return unpackMap( + buildEntityData(Transformer2WTypeInput.class).map(transformer2WTypeInputFactory::get), + Transformer2WTypeInput.class); } /** - * Returns a set of {@link OperatorInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link OperatorInput} which has to be checked manually, as {@link OperatorInput#equals(Object)} - * is NOT restricted on the uuid of {@link OperatorInput}. + * Returns a set of {@link OperatorInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link OperatorInput} which has to be checked manually, as + * {@link OperatorInput#equals(Object)} is NOT restricted on the uuid of {@link OperatorInput}. * - * @return a set of object and uuid unique {@link OperatorInput} entities + * @return a map of UUID to object- and uuid-unique {@link OperatorInput} entities */ - public Set getOperators() throws SourceException { - return Try.scanCollection( - buildEntities(OperatorInput.class, operatorInputFactory), OperatorInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getOperators() throws SourceException { + return unpackMap( + buildEntityData(OperatorInput.class).map(operatorInputFactory::get), OperatorInput.class); } /** - * Returns a set of {@link LineTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link LineTypeInput} which has to be checked manually, as {@link LineTypeInput#equals(Object)} - * is NOT restricted on the uuid of {@link LineTypeInput}. + * Returns a set of {@link LineTypeInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link LineTypeInput} which has to be checked manually, as + * {@link LineTypeInput#equals(Object)} is NOT restricted on the uuid of {@link LineTypeInput}. * - * @return a set of object and uuid unique {@link LineTypeInput} entities + * @return a map of UUID to object- and uuid-unique {@link LineTypeInput} entities */ - public Set getLineTypes() throws SourceException { - return Try.scanCollection( - buildEntities(LineTypeInput.class, lineTypeInputFactory), LineTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getLineTypes() throws SourceException { + return unpackMap( + buildEntityData(LineTypeInput.class).map(lineTypeInputFactory::get), LineTypeInput.class); } /** - * Returns a set of {@link Transformer3WTypeInput} instances. This set has to be unique in the - * sense of object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the - * provided {@link Transformer3WTypeInput} which has to be checked manually, as {@link - * Transformer3WTypeInput#equals(Object)} is NOT restricted on the uuid of {@link - * Transformer3WTypeInput}. + * Returns a set of {@link Transformer3WTypeInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link Transformer3WTypeInput} which has to be checked + * manually, as {@link Transformer3WTypeInput#equals(Object)} is NOT restricted on the uuid of + * {@link Transformer3WTypeInput}. * - * @return a set of object and uuid unique {@link Transformer3WTypeInput} entities + * @return a map of UUID to object- and uuid-unique {@link Transformer3WTypeInput} entities */ - public Set getTransformer3WTypes() throws SourceException { - return Try.scanCollection( - buildEntities(Transformer3WTypeInput.class, transformer3WTypeInputFactory), - Transformer3WTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getTransformer3WTypes() throws SourceException { + return unpackMap( + buildEntityData(Transformer3WTypeInput.class).map(transformer3WTypeInputFactory::get), + Transformer3WTypeInput.class); } /** - * Returns a set of {@link BmTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link BmTypeInput} which has to be checked manually, as {@link BmTypeInput#equals(Object)} is - * NOT restricted on the uuid of {@link BmTypeInput}. + * Returns a set of {@link BmTypeInput} instances within a map by UUID. + * + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link BmTypeInput} which has to be checked manually, as + * {@link BmTypeInput#equals(Object)} is NOT restricted on the uuid of {@link BmTypeInput}. * - * @return a set of object and uuid unique {@link BmTypeInput} entities + * @return a map of UUID to object- and uuid-unique {@link BmTypeInput} entities */ - public Set getBmTypes() throws SourceException { - return Try.scanCollection( - buildEntities(BmTypeInput.class, systemParticipantTypeInputFactory), BmTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getBmTypes() throws SourceException { + return unpackMap( + buildEntities(BmTypeInput.class, systemParticipantTypeInputFactory), BmTypeInput.class); } /** - * Returns a set of {@link ChpTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link ChpTypeInput} which has to be checked manually, as {@link ChpTypeInput#equals(Object)} - * is NOT restricted on the uuid of {@link ChpTypeInput}. + * Returns a set of {@link ChpTypeInput} instances within a map by UUID. * - * @return a set of object and uuid unique {@link ChpTypeInput} entities + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link ChpTypeInput} which has to be checked manually, as + * {@link ChpTypeInput#equals(Object)} is NOT restricted on the uuid of {@link ChpTypeInput}. + * + * @return a map of UUID to object- and uuid-unique {@link ChpTypeInput} entities */ - public Set getChpTypes() throws SourceException { - return Try.scanCollection( - buildEntities(ChpTypeInput.class, systemParticipantTypeInputFactory), - ChpTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getChpTypes() throws SourceException { + return unpackMap( + buildEntities(ChpTypeInput.class, systemParticipantTypeInputFactory), ChpTypeInput.class); } /** - * Returns a set of {@link HpTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link HpTypeInput} which has to be checked manually, as {@link HpTypeInput#equals(Object)} is - * NOT restricted on the uuid of {@link HpTypeInput}. + * Returns a set of {@link HpTypeInput} instances within a map by UUID. * - * @return a set of object and uuid unique {@link HpTypeInput} entities + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link HpTypeInput} which has to be checked manually, as + * {@link HpTypeInput#equals(Object)} is NOT restricted on the uuid of {@link HpTypeInput}. + * + * @return a map of UUID to object- and uuid-unique {@link HpTypeInput} entities */ - public Set getHpTypes() throws SourceException { - return Try.scanCollection( - buildEntities(HpTypeInput.class, systemParticipantTypeInputFactory), HpTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getHpTypes() throws SourceException { + return unpackMap( + buildEntities(HpTypeInput.class, systemParticipantTypeInputFactory), HpTypeInput.class); } /** - * Returns a set of {@link StorageTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link StorageTypeInput} which has to be checked manually, as {@link - * StorageTypeInput#equals(Object)} is NOT restricted on the uuid of {@link StorageTypeInput}. + * Returns a set of {@link StorageTypeInput} instances within a map by UUID. * - * @return a set of object and uuid unique {@link StorageTypeInput} entities + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link StorageTypeInput} which has to be checked manually, as + * {@link StorageTypeInput#equals(Object)} is NOT restricted on the uuid of {@link + * StorageTypeInput}. + * + * @return a map of UUID to object- and uuid-unique {@link StorageTypeInput} entities */ - public Set getStorageTypes() throws SourceException { - return Try.scanCollection( - buildEntities(StorageTypeInput.class, systemParticipantTypeInputFactory), - StorageTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getStorageTypes() throws SourceException { + return unpackMap( + buildEntities(StorageTypeInput.class, systemParticipantTypeInputFactory), + StorageTypeInput.class); } /** - * Returns a set of {@link WecTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link WecTypeInput} which has to be checked manually, as {@link WecTypeInput#equals(Object)} - * is NOT restricted on the uuid of {@link WecTypeInput}. + * Returns a set of {@link WecTypeInput} instances within a map by UUID. * - * @return a set of object and uuid unique {@link WecTypeInput} entities + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link WecTypeInput} which has to be checked manually, as + * {@link WecTypeInput#equals(Object)} is NOT restricted on the uuid of {@link WecTypeInput}. + * + * @return a map of UUID to object- and uuid-unique {@link WecTypeInput} entities */ - public Set getWecTypes() throws SourceException { - return Try.scanCollection( - buildEntities(WecTypeInput.class, systemParticipantTypeInputFactory), - WecTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getWecTypes() throws SourceException { + return unpackMap( + buildEntities(WecTypeInput.class, systemParticipantTypeInputFactory), WecTypeInput.class); } /** - * Returns a set of {@link EvTypeInput} instances. This set has to be unique in the sense of - * object uniqueness but also in the sense of {@link java.util.UUID} uniqueness of the provided - * {@link EvTypeInput} which has to be checked manually, as {@link EvTypeInput#equals(Object)} is - * NOT restricted on the uuid of {@link EvTypeInput}. + * Returns a set of {@link EvTypeInput} instances within a map by UUID. * - * @return a set of object and uuid unique {@link EvTypeInput} entities + *

This set has to be unique in the sense of object uniqueness but also in the sense of {@link + * UUID} uniqueness of the provided {@link EvTypeInput} which has to be checked manually, as + * {@link EvTypeInput#equals(Object)} is NOT restricted on the uuid of {@link EvTypeInput}. + * + * @return a map of UUID to object- and uuid-unique {@link EvTypeInput} entities */ - public Set getEvTypes() throws SourceException { - return Try.scanCollection( - buildEntities(EvTypeInput.class, systemParticipantTypeInputFactory), EvTypeInput.class) - .transformF(SourceException::new) - .getOrThrow(); + public Map getEvTypes() throws SourceException { + return unpackMap( + buildEntities(EvTypeInput.class, systemParticipantTypeInputFactory), EvTypeInput.class); + } + + /** + * Build and cast entities to the correct type, since {@link SystemParticipantTypeInputFactory} + * outputs {@link SystemParticipantTypeInput} of general type. + * + * @param entityClass The class of type input entity to build + * @param factory The factory to use to build the entity + * @return a stream of {@link Try}s containing the desired entities + * @param The type of AssetType to return + */ + @SuppressWarnings("unchecked") + private Stream> buildEntities( + Class entityClass, EntityFactory factory) { + return buildEntityData(entityClass).map(data -> (Try) factory.get(data)); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/WeatherSource.java b/src/main/java/edu/ie3/datamodel/io/source/WeatherSource.java index 31f5150f0..990c43db7 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/WeatherSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/WeatherSource.java @@ -40,6 +40,15 @@ protected WeatherSource( this.weatherFactory = weatherFactory; } + /** + * Method to retrieve the fields found in the source. + * + * @param entityClass class of the source + * @return an option for fields found in the source + */ + public abstract Optional> getSourceFields( + Class entityClass) throws SourceException; + // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- public abstract Map> getWeather( diff --git a/src/main/java/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSource.java b/src/main/java/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSource.java index abfaca204..5f48a9666 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/couchbase/CouchbaseWeatherSource.java @@ -10,6 +10,7 @@ import com.couchbase.client.java.json.JsonObject; import com.couchbase.client.java.kv.GetResult; import com.couchbase.client.java.query.QueryResult; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.connectors.CouchbaseConnector; import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueData; import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueFactory; @@ -18,6 +19,7 @@ import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; import edu.ie3.datamodel.models.value.WeatherValue; +import edu.ie3.datamodel.utils.Try; import edu.ie3.util.interval.ClosedInterval; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; @@ -59,7 +61,8 @@ public CouchbaseWeatherSource( IdCoordinateSource coordinateSource, String coordinateIdColumnName, TimeBasedWeatherValueFactory weatherFactory, - String timeStampPattern) { + String timeStampPattern) + throws SourceException { this( connector, coordinateSource, @@ -88,12 +91,31 @@ public CouchbaseWeatherSource( String coordinateIdColumnName, String keyPrefix, TimeBasedWeatherValueFactory weatherFactory, - String timeStampPattern) { + String timeStampPattern) + throws SourceException { super(idCoordinateSource, weatherFactory); this.connector = connector; this.coordinateIdColumnName = coordinateIdColumnName; this.keyPrefix = keyPrefix; this.timeStampPattern = timeStampPattern; + + // validating + Try.of(() -> getSourceFields(WeatherValue.class), SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + weatherFactory + .validate(fields, WeatherValue.class) + .transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); + } + + @Override + public Optional> getSourceFields(Class entityClass) { + return connector.getSourceFields(); } @Override diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java index 9a355e746..b627872d4 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvDataSource.java @@ -5,12 +5,14 @@ */ package edu.ie3.datamodel.io.source.csv; -import edu.ie3.datamodel.exceptions.ConnectorException; import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.connectors.CsvFileConnector; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.source.DataSource; import edu.ie3.datamodel.models.UniqueEntity; +import edu.ie3.datamodel.utils.Try; +import edu.ie3.datamodel.utils.Try.Failure; +import edu.ie3.datamodel.utils.Try.Success; import edu.ie3.datamodel.utils.validation.ValidationUtils; import edu.ie3.util.StringUtils; import java.io.BufferedReader; @@ -46,6 +48,8 @@ public class CsvDataSource implements DataSource { protected final String csvSep; protected final CsvFileConnector connector; + private final FileNamingStrategy fileNamingStrategy; + /** * @deprecated ensures downward compatibility with old csv data format. Can be removed when * support for old csv format is removed. * @@ -56,17 +60,38 @@ public class CsvDataSource implements DataSource { public CsvDataSource(String csvSep, Path folderPath, FileNamingStrategy fileNamingStrategy) { this.csvSep = csvSep; this.connector = new CsvFileConnector(folderPath, fileNamingStrategy); + this.fileNamingStrategy = fileNamingStrategy; } @Override - public Stream> getSourceData(Class entityClass) { - return buildStreamWithFieldsToAttributesMap(entityClass, connector); + public Optional> getSourceFields(Class entityClass) + throws SourceException { + return getSourceFields(getFilePath(entityClass).getOrThrow()); } - // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /** + * @param filePath path of file starting from base folder, including file name but not file + * extension + * @return The source field names as a set, if file exists + * @throws SourceException on error while reading the source file + */ + public Optional> getSourceFields(Path filePath) throws SourceException { + try (BufferedReader reader = connector.initReader(filePath)) { + return Optional.of( + Arrays.stream(parseCsvRow(reader.readLine(), csvSep)).collect(Collectors.toSet())); + } catch (FileNotFoundException e) { + // A file not existing can be acceptable in many cases, and is handled elsewhere. + log.debug("The source for the given entity couldn't be found! Cause: {}", e.getMessage()); + return Optional.empty(); + } catch (IOException e) { + throw new SourceException("Error while trying to read source", e); + } + } - public BufferedReader createReader(Path filePath) throws FileNotFoundException { - return connector.initReader(filePath); + @Override + public Stream> getSourceData(Class entityClass) + throws SourceException { + return buildStreamWithFieldsToAttributesMap(entityClass, true).getOrThrow(); } // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- @@ -255,25 +280,24 @@ protected Predicate> isPresentCollectIfNot( }; } + public FileNamingStrategy getNamingStrategy() { + return fileNamingStrategy; + } + /** - * Tries to open a file reader from the connector based on the provided entity class and hands it - * over for further processing. + * Tries to open a file reader based on the provided entity class and hands it over for further + * processing. * * @param entityClass the entity class that should be build and that is used to get the * corresponding reader - * @param connector the connector that should be used to get the reader from * @return a parallel stream of maps, where each map represents one row of the csv file with the * mapping (fieldName to fieldValue) */ - protected Stream> buildStreamWithFieldsToAttributesMap( - Class entityClass, CsvFileConnector connector) { - try { - return buildStreamWithFieldsToAttributesMap(entityClass, connector.initReader(entityClass)); - } catch (FileNotFoundException | ConnectorException e) { - log.warn( - "Unable to find file for entity '{}': {}", entityClass.getSimpleName(), e.getMessage()); - } - return Stream.empty(); + protected Try>, SourceException> buildStreamWithFieldsToAttributesMap( + Class entityClass, boolean allowFileNotExisting) { + return getFilePath(entityClass) + .flatMap( + path -> buildStreamWithFieldsToAttributesMap(entityClass, path, allowFileNotExisting)); } /** @@ -282,22 +306,15 @@ protected Stream> buildStreamWithFieldsToAttributesMap( * the returning stream is a parallel stream, the order of the elements cannot be guaranteed. * * @param entityClass the entity class that should be build - * @param bufferedReader the reader to use - * @return a parallel stream of maps, where each map represents one row of the csv file with the - * mapping (fieldName to fieldValue) + * @param filePath the path of the file to read + * @return a try containing either a parallel stream of maps, where each map represents one row of + * the csv file with the mapping (fieldName to fieldValue) or an exception */ - protected Stream> buildStreamWithFieldsToAttributesMap( - Class entityClass, BufferedReader bufferedReader) { - try (BufferedReader reader = bufferedReader) { + protected Try>, SourceException> buildStreamWithFieldsToAttributesMap( + Class entityClass, Path filePath, boolean allowFileNotExisting) { + try (BufferedReader reader = connector.initReader(filePath)) { final String[] headline = parseCsvRow(reader.readLine(), csvSep); - // sanity check for headline - if (!Arrays.asList(headline).contains("uuid")) { - throw new SourceException( - "The first line does not contain a field named 'uuid'. Is the headline valid?\nProvided headline: " - + String.join(", ", headline)); - } - // by default try-with-resources closes the reader directly when we leave this method (which // is wanted to avoid a lock on the file), but this causes a closing of the stream as well. // As we still want to consume the data at other places, we start a new stream instead of @@ -305,17 +322,31 @@ protected Stream> buildStreamWithFieldsToAttributesMap( Collection> allRows = csvRowFieldValueMapping(reader, headline); return distinctRowsWithLog( - allRows, fieldToValues -> fieldToValues.get("uuid"), entityClass.getSimpleName(), "UUID") - .parallelStream(); + allRows, + fieldToValues -> fieldToValues.get("uuid"), + entityClass.getSimpleName(), + "UUID") + .map(Set::parallelStream); + } catch (FileNotFoundException e) { + if (allowFileNotExisting) { + log.warn("Unable to find file '{}': {}", filePath, e.getMessage()); + return Success.of(Stream.empty()); + } else { + return Failure.of(new SourceException("Unable to find file '" + filePath + "'.", e)); + } } catch (IOException e) { - log.warn( - "Cannot read file to build entity '{}': {}", entityClass.getSimpleName(), e.getMessage()); - } catch (SourceException e) { - log.error( - "Cannot read file to build entity '{}': {}", entityClass.getSimpleName(), e.getMessage()); + return Failure.of( + new SourceException( + "Cannot read file to build entity '" + entityClass.getSimpleName() + "'", e)); } + } - return Stream.empty(); + private Try getFilePath(Class entityClass) { + return Try.from( + fileNamingStrategy.getFilePath(entityClass), + () -> + new SourceException( + "Cannot find a naming strategy for class '" + entityClass.getSimpleName() + "'.")); } protected List> csvRowFieldValueMapping( @@ -344,10 +375,10 @@ protected List> csvRowFieldValueMapping( * debug String) * @param keyDescriptor Colloquial descriptor of the key, that is meant to be unique (for debug * String) - * @return either a set containing only unique rows or an empty set if at least two rows with the - * same UUID but different field values exist + * @return a try of either a set containing only unique rows or an exception if at least two rows + * with the same UUID but different field values exist */ - protected Set> distinctRowsWithLog( + protected Try>, SourceException> distinctRowsWithLog( Collection> allRows, final Function, String> keyExtractor, String entityDescriptor, @@ -371,18 +402,19 @@ protected Set> distinctRowsWithLog( allRowsSet.removeAll(distinctIdSet); String affectedCoordinateIds = allRowsSet.stream().map(keyExtractor).collect(Collectors.joining(",\n")); - log.error( - """ - '{}' entities with duplicated {} key, but different field values found! Please review the corresponding input file! - Affected primary keys: - {}""", - entityDescriptor, - keyDescriptor, - affectedCoordinateIds); - // if this happens, we return an empty set to prevent further processing - return new HashSet<>(); + + // if this happens, we return a failure + return Failure.of( + new SourceException( + "'" + + entityDescriptor + + "' entities with duplicated " + + keyDescriptor + + " key, but different field " + + "values found! Please review the corresponding input file! Affected primary keys: " + + affectedCoordinateIds)); } - return allRowsSet; + return Success.of(allRowsSet); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java index d7f293f0f..46241e10d 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSource.java @@ -6,14 +6,17 @@ package edu.ie3.datamodel.io.source.csv; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; import edu.ie3.datamodel.io.factory.SimpleFactoryData; import edu.ie3.datamodel.io.factory.timeseries.IdCoordinateFactory; import edu.ie3.datamodel.io.source.IdCoordinateSource; import edu.ie3.datamodel.utils.Try; +import edu.ie3.datamodel.utils.Try.Failure; import edu.ie3.util.geo.CoordinateDistance; import edu.ie3.util.geo.GeoUtils; import java.io.BufferedReader; import java.io.IOException; +import java.nio.file.Path; import java.util.*; import java.util.function.Function; import java.util.stream.Collectors; @@ -62,13 +65,13 @@ public CsvIdCoordinateSource(IdCoordinateFactory factory, CsvDataSource dataSour * @return Mapping from coordinate id to coordinate */ private Map setupIdToCoordinateMap() throws SourceException { - return Try.scanStream( - buildStreamWithFieldsToAttributesMap() - .map(fieldToValues -> new SimpleFactoryData(fieldToValues, Pair.class)) - .map(factory::get), - "Pair") - .transform( - s -> s.collect(Collectors.toMap(Pair::getKey, Pair::getValue)), SourceException::new) + return buildStreamWithFieldsToAttributesMap() + .map( + data -> + data.map(fieldToValues -> new SimpleFactoryData(fieldToValues, Pair.class)) + .map(factory::get)) + .flatMap(s -> Try.scanStream(s, "Pair").transformF(SourceException::new)) + .map(s -> s.collect(Collectors.toMap(Pair::getKey, Pair::getValue))) .getOrThrow(); } @@ -86,6 +89,12 @@ private Map invert(Map map) { return inv; } + @Override + public Optional> getSourceFields() throws SourceException { + Path filePath = Path.of(dataSource.getNamingStrategy().getIdCoordinateEntityName()); + return dataSource.getSourceFields(filePath); + } + @Override public Optional getCoordinate(int id) { return Optional.ofNullable(idToCoordinate.get(id)); @@ -158,10 +167,15 @@ public int getCoordinateCount() { * * @return Stream with mappings from field identifiers to attributes */ - protected Stream> buildStreamWithFieldsToAttributesMap() { - try (BufferedReader reader = dataSource.connector.initIdCoordinateReader()) { + protected Try>, SourceException> + buildStreamWithFieldsToAttributesMap() { + Path filePath = Path.of(dataSource.getNamingStrategy().getIdCoordinateEntityName()); + try (BufferedReader reader = dataSource.connector.initReader(filePath)) { final String[] headline = dataSource.parseCsvRow(reader.readLine(), dataSource.csvSep); + // validating read file + factory.validate(Set.of(headline), Pair.class).getOrThrow(); + // by default try-with-resources closes the reader directly when we leave this method (which // is wanted to avoid a lock on the file), but this causes a closing of the stream as well. // As we still want to consume the data at other places, we start a new stream instead of @@ -171,7 +185,7 @@ protected Stream> buildStreamWithFieldsToAttributesMap() { Function, String> idExtractor = fieldToValues -> fieldToValues.get(factory.getIdField()); - Set> withDistinctCoordinateId = + Try>, SourceException> withDistinctCoordinateId = dataSource.distinctRowsWithLog( allRows, idExtractor, COORDINATE_ID_MAPPING, "coordinate id"); Function, String> coordinateExtractor = @@ -179,13 +193,18 @@ protected Stream> buildStreamWithFieldsToAttributesMap() { fieldToValues .get(factory.getLatField()) .concat(fieldToValues.get(factory.getLonField())); - return dataSource - .distinctRowsWithLog( - withDistinctCoordinateId, coordinateExtractor, COORDINATE_ID_MAPPING, "coordinate") - .parallelStream(); + + return withDistinctCoordinateId + .flatMap( + set -> + dataSource.distinctRowsWithLog( + set, coordinateExtractor, COORDINATE_ID_MAPPING, "coordinate")) + .map(Set::parallelStream); } catch (IOException e) { - log.error("Cannot read the file for coordinate id to coordinate mapping.", e); + return Failure.of( + new SourceException("Cannot read the file for coordinate id to coordinate mapping.", e)); + } catch (ValidationException ve) { + return Failure.of(new SourceException("Creating stream failed due to failed validation", ve)); } - return Stream.empty(); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java index 2fa9e0f2a..294f5b808 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvJointGridContainerSource.java @@ -8,17 +8,19 @@ import edu.ie3.datamodel.exceptions.FileException; import edu.ie3.datamodel.exceptions.InvalidGridException; import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; import edu.ie3.datamodel.io.naming.DefaultDirectoryHierarchy; import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.source.*; -import edu.ie3.datamodel.models.input.container.GraphicElements; -import edu.ie3.datamodel.models.input.container.JointGridContainer; -import edu.ie3.datamodel.models.input.container.RawGridElements; -import edu.ie3.datamodel.models.input.container.SystemParticipants; +import edu.ie3.datamodel.models.input.NodeInput; +import edu.ie3.datamodel.models.input.OperatorInput; +import edu.ie3.datamodel.models.input.connector.LineInput; +import edu.ie3.datamodel.models.input.connector.type.LineTypeInput; +import edu.ie3.datamodel.models.input.container.*; import edu.ie3.datamodel.utils.Try; import java.nio.file.Path; -import java.util.List; +import java.util.*; /** Convenience class for cases where all used data comes from CSV sources */ public class CsvJointGridContainerSource { @@ -48,17 +50,38 @@ public static JointGridContainer read( TypeSource typeSource = new TypeSource(dataSource); RawGridSource rawGridSource = new RawGridSource(typeSource, dataSource); ThermalSource thermalSource = new ThermalSource(typeSource, dataSource); + EnergyManagementSource emSource = new EnergyManagementSource(typeSource, dataSource); SystemParticipantSource systemParticipantSource = - new SystemParticipantSource(typeSource, thermalSource, rawGridSource, dataSource); + new SystemParticipantSource(typeSource, thermalSource, rawGridSource, emSource, dataSource); GraphicSource graphicSource = new GraphicSource(typeSource, rawGridSource, dataSource); + /* validating sources */ + try { + typeSource.validate(); + rawGridSource.validate(); + systemParticipantSource.validate(); + graphicSource.validate(); + } catch (ValidationException ve) { + throw new SourceException("Could not read source because validation failed", ve); + } + + /* Loading basic inputs that are used multiple times */ + Map operators = typeSource.getOperators(); + + Map lineTypes = typeSource.getLineTypes(); + + Map nodes = rawGridSource.getNodes(operators); + Map lines = rawGridSource.getLines(operators, nodes, lineTypes); + /* Loading models */ Try rawGridElements = - Try.of(rawGridSource::getGridData, SourceException.class); + Try.of(() -> rawGridSource.getGridData(operators, nodes, lines), SourceException.class); Try systemParticipants = - Try.of(systemParticipantSource::getSystemParticipants, SourceException.class); + Try.of( + () -> systemParticipantSource.getSystemParticipants(operators, nodes), + SourceException.class); Try graphicElements = - Try.of(graphicSource::getGraphicElements, SourceException.class); + Try.of(() -> graphicSource.getGraphicElements(nodes, lines), SourceException.class); List exceptions = Try.getExceptions(List.of(rawGridElements, systemParticipants, graphicElements)); diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesMappingSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesMappingSource.java index c6affdb71..4f1065dd7 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesMappingSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesMappingSource.java @@ -5,10 +5,14 @@ */ package edu.ie3.datamodel.io.source.csv; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.naming.FileNamingStrategy; import edu.ie3.datamodel.io.source.TimeSeriesMappingSource; +import edu.ie3.datamodel.utils.Try; import java.nio.file.Path; import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Stream; public class CsvTimeSeriesMappingSource extends TimeSeriesMappingSource { @@ -16,13 +20,31 @@ public class CsvTimeSeriesMappingSource extends TimeSeriesMappingSource { private final CsvDataSource dataSource; public CsvTimeSeriesMappingSource( - String csvSep, Path gridFolderPath, FileNamingStrategy fileNamingStrategy) { + String csvSep, Path gridFolderPath, FileNamingStrategy fileNamingStrategy) + throws SourceException { this.dataSource = new CsvDataSource(csvSep, gridFolderPath, fileNamingStrategy); + + // validating + Try.of(this::getSourceFields, SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + mappingFactory + .validate(fields, MappingEntry.class) + .transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); + } + + @Override + public Stream> getMappingSourceData() throws SourceException { + return dataSource.buildStreamWithFieldsToAttributesMap(MappingEntry.class, true).getOrThrow(); } @Override - public Stream> getMappingSourceData() { - return dataSource.buildStreamWithFieldsToAttributesMap( - MappingEntry.class, dataSource.connector); + public Optional> getSourceFields() throws SourceException { + return dataSource.getSourceFields(MappingEntry.class); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSource.java index 4b8d55604..49d6f83e5 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSource.java @@ -6,7 +6,6 @@ package edu.ie3.datamodel.io.source.csv; import edu.ie3.datamodel.exceptions.FactoryException; -import edu.ie3.datamodel.exceptions.FailureException; import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation; import edu.ie3.datamodel.io.factory.timeseries.*; @@ -18,9 +17,6 @@ import edu.ie3.datamodel.utils.TimeSeriesUtils; import edu.ie3.datamodel.utils.Try; import edu.ie3.util.interval.ClosedInterval; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.IOException; import java.nio.file.Path; import java.time.ZonedDateTime; import java.util.*; @@ -128,7 +124,8 @@ public Optional getValue(ZonedDateTime time) { /** * Attempts to read a time series with given unique identifier and file path. Single entries are - * obtained entries with the help of {@code fieldToValueFunction}. + * obtained entries with the help of {@code fieldToValueFunction}. If the file does not exist, an + * empty Stream is returned. * * @param timeSeriesUuid unique identifier of the time series * @param filePath path to the file to read @@ -142,21 +139,14 @@ protected IndividualTimeSeries buildIndividualTimeSeries( Path filePath, Function, Try, FactoryException>> fieldToValueFunction) throws SourceException { - try (BufferedReader reader = dataSource.connector.initReader(filePath)) { - Try>, FailureException> timeBasedValues = - Try.scanStream( - dataSource - .buildStreamWithFieldsToAttributesMap(TimeBasedValue.class, reader) - .map(fieldToValueFunction), - "TimeBasedValue"); - return new IndividualTimeSeries<>( - timeSeriesUuid, new HashSet<>(timeBasedValues.getOrThrow().toList())); - } catch (FileNotFoundException e) { - throw new SourceException("Unable to find a file with path '" + filePath + "'.", e); - } catch (IOException e) { - throw new SourceException("Error during reading of file'" + filePath + "'.", e); - } catch (FailureException e) { - throw new SourceException("Unable to build individual time series. ", e.getCause()); - } + Try>, SourceException> timeBasedValues = + dataSource + .buildStreamWithFieldsToAttributesMap(TimeBasedValue.class, filePath, false) + .flatMap( + stream -> + Try.scanStream(stream.map(fieldToValueFunction), "TimeBasedValue") + .transformF(SourceException::new)); + return new IndividualTimeSeries<>( + timeSeriesUuid, new HashSet<>(timeBasedValues.getOrThrow().toList())); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvWeatherSource.java b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvWeatherSource.java index 1997edbd1..57b2b736f 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/csv/CsvWeatherSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/csv/CsvWeatherSource.java @@ -5,6 +5,8 @@ */ package edu.ie3.datamodel.io.source.csv; +import edu.ie3.datamodel.exceptions.SourceException; +import edu.ie3.datamodel.exceptions.ValidationException; import edu.ie3.datamodel.io.connectors.CsvFileConnector; import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation; import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueData; @@ -19,6 +21,8 @@ import edu.ie3.datamodel.models.value.Value; import edu.ie3.datamodel.models.value.WeatherValue; import edu.ie3.datamodel.utils.TimeSeriesUtils; +import edu.ie3.datamodel.utils.Try; +import edu.ie3.datamodel.utils.Try.Failure; import edu.ie3.util.interval.ClosedInterval; import java.io.BufferedReader; import java.io.FileNotFoundException; @@ -52,7 +56,8 @@ public CsvWeatherSource( Path folderPath, FileNamingStrategy fileNamingStrategy, IdCoordinateSource idCoordinateSource, - TimeBasedWeatherValueFactory weatherFactory) { + TimeBasedWeatherValueFactory weatherFactory) + throws SourceException { super(idCoordinateSource, weatherFactory); this.dataSource = new CsvDataSource(csvSep, folderPath, fileNamingStrategy); coordinateToTimeSeries = getWeatherTimeSeries(); @@ -60,6 +65,12 @@ public CsvWeatherSource( // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + /** Returns an empty optional for now. */ + @Override + public Optional> getSourceFields(Class entityClass) { + return Optional.empty(); + } + @Override public Map> getWeather( ClosedInterval timeInterval) { @@ -120,7 +131,8 @@ protected IndividualTimeSeries mergeTimeSeries( // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - private Map> getWeatherTimeSeries() { + private Map> getWeatherTimeSeries() + throws SourceException { /* Get only weather time series meta information */ Collection weatherCsvMetaInformation = dataSource @@ -138,7 +150,8 @@ private Map> getWeatherTimeSeries() { */ private Map> readWeatherTimeSeries( Set weatherMetaInformation, - CsvFileConnector connector) { + CsvFileConnector connector) + throws SourceException { final Map> weatherTimeSeries = new HashMap<>(); Function, Optional>> fieldToValueFunction = this::buildWeatherValue; @@ -146,7 +159,8 @@ private Map> readWeatherTimeSeries( for (CsvIndividualTimeSeriesMetaInformation data : weatherMetaInformation) { // we need a reader for each file try (BufferedReader reader = connector.initReader(data.getFullFilePath())) { - buildStreamWithFieldsToAttributesMap(TimeBasedValue.class, reader) + buildStreamWithFieldsToAttributesMap(reader) + .getOrThrow() .map(fieldToValueFunction) .flatMap(Optional::stream) .collect(Collectors.groupingBy(tbv -> tbv.getValue().getCoordinate())) @@ -166,19 +180,27 @@ private Map> readWeatherTimeSeries( } }); } catch (FileNotFoundException e) { - log.error("Cannot read file {}. File not found!", data.getFullFilePath()); + throw new SourceException( + "Cannot read file " + data.getFullFilePath() + ". File not found!", e); } catch (IOException e) { - log.error("Cannot read file {}. Exception: {}", data.getFullFilePath(), e); + throw new SourceException("Cannot read file " + data.getFullFilePath() + ".", e); + } catch (ValidationException e) { + throw new SourceException("Validation failed for file " + data.getFullFilePath() + ".", e); } } return weatherTimeSeries; } - private Stream> buildStreamWithFieldsToAttributesMap( - Class entityClass, BufferedReader bufferedReader) { + private Try>, SourceException> buildStreamWithFieldsToAttributesMap( + BufferedReader bufferedReader) throws ValidationException { + Class entityClass = TimeBasedValue.class; + try (BufferedReader reader = bufferedReader) { final String[] headline = dataSource.parseCsvRow(reader.readLine(), dataSource.csvSep); + // validating read file + weatherFactory.validate(Set.of(headline), WeatherValue.class).getOrThrow(); + // by default try-with-resources closes the reader directly when we leave this method (which // is wanted to avoid a lock on the file), but this causes a closing of the stream as well. // As we still want to consume the data at other places, we start a new stream instead of @@ -194,14 +216,12 @@ private Stream> buildStreamWithFieldsToAttributesMap( return dataSource .distinctRowsWithLog( allRows, timeCoordinateIdExtractor, entityClass.getSimpleName(), "UUID") - .parallelStream(); - + .map(Set::parallelStream); } catch (IOException e) { - log.warn( - "Cannot read file to build entity '{}': {}", entityClass.getSimpleName(), e.getMessage()); + return Failure.of( + new SourceException( + "Cannot read file to build entity '" + entityClass.getSimpleName() + "'.", e)); } - - return Stream.empty(); } /** diff --git a/src/main/java/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSource.java b/src/main/java/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSource.java index de3269b61..c35227155 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSource.java @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.source.influxdb; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.connectors.InfluxDbConnector; import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueData; import edu.ie3.datamodel.io.factory.timeseries.TimeBasedWeatherValueFactory; @@ -47,9 +48,27 @@ public class InfluxDbWeatherSource extends WeatherSource { public InfluxDbWeatherSource( InfluxDbConnector connector, IdCoordinateSource idCoordinateSource, - TimeBasedWeatherValueFactory weatherValueFactory) { + TimeBasedWeatherValueFactory weatherValueFactory) + throws SourceException { super(idCoordinateSource, weatherValueFactory); this.connector = connector; + + Try.of(() -> getSourceFields(WeatherValue.class), SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + weatherFactory + .validate(fields, WeatherValue.class) + .transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); + } + + @Override + public Optional> getSourceFields(Class entityClass) { + return connector.getSourceFields(); } @Override @@ -159,8 +178,7 @@ private Stream>> optTimeBasedValueStream( fieldToValue.entrySet().stream() .collect( Collectors.toMap( - entry -> - StringUtils.snakeCaseToCamelCase(entry.getKey()).toLowerCase(), + entry -> StringUtils.snakeCaseToCamelCase(entry.getKey()), Map.Entry::getValue)); /* Add a random UUID if necessary */ @@ -225,6 +243,6 @@ private String createCoordinateConstraintString(int coordinateId) { */ protected Stream> filterEmptyOptionals( Stream>> elements) { - return elements.flatMap(Optional::stream).map(TimeBasedValue.class::cast); + return elements.flatMap(Optional::stream); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlDataSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlDataSource.java index 9cd4e413f..237b09a36 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlDataSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlDataSource.java @@ -108,6 +108,37 @@ protected List getDbTables(String schemaPattern, String tableNamePattern return tableNames; } + @Override + public Optional> getSourceFields(Class entityClass) { + String tableName = databaseNamingStrategy.getEntityName(entityClass).orElseThrow(); + return getSourceFields(tableName); + } + + /** + * Method that uses the table name to retrieve all field names. + * + * @param tableName to be used + * @return an option for a set of found fields + */ + public Optional> getSourceFields(String tableName) { + try { + ResultSet rs = + connector.getConnection().getMetaData().getColumns(null, null, tableName, null); + Set columnNames = new HashSet<>(); + + while (rs.next()) { + String name = rs.getString("COLUMN_NAME"); + columnNames.add(StringUtils.snakeCaseToCamelCase(name)); + } + + return Optional.of(columnNames); + } catch (SQLException e) { + log.warn("The table '{}' couldn't be read and therefore not be validated!", tableName, e); + // FIXME only return empty if table not found. Throw exception if error occurred + return Optional.empty(); + } + } + @Override public Stream> getSourceData(Class entityClass) { String explicitTableName = databaseNamingStrategy.getEntityName(entityClass).orElseThrow(); @@ -122,7 +153,7 @@ public Stream> getSourceData(Class e *

(We cannot use {@link java.util.function.Function} here because it throws SQLException). */ @FunctionalInterface - interface AddParams { + protected interface AddParams { /** * Enhance a PreparedStatement by inserting parameters for wildcards * diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java index 9736d8beb..0703deb48 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlIdCoordinateSource.java @@ -7,12 +7,14 @@ import static edu.ie3.datamodel.io.source.sql.SqlDataSource.createBaseQueryString; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.connectors.SqlConnector; import edu.ie3.datamodel.io.factory.SimpleFactoryData; import edu.ie3.datamodel.io.factory.timeseries.SqlIdCoordinateFactory; import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy; import edu.ie3.datamodel.io.source.IdCoordinateSource; import edu.ie3.datamodel.models.value.CoordinateValue; +import edu.ie3.datamodel.utils.Try; import edu.ie3.util.geo.CoordinateDistance; import edu.ie3.util.geo.GeoUtils; import java.sql.Array; @@ -40,19 +42,33 @@ public class SqlIdCoordinateSource implements IdCoordinateSource { private final String queryForBoundingBox; private final String queryForNearestPoints; + private final String coordinateTableName; private final SqlDataSource dataSource; private final SqlIdCoordinateFactory factory; public SqlIdCoordinateSource( - SqlIdCoordinateFactory factory, String coordinateTableName, SqlDataSource dataSource) { + SqlIdCoordinateFactory factory, String coordinateTableName, SqlDataSource dataSource) + throws SourceException { this.factory = factory; this.dataSource = dataSource; + this.coordinateTableName = coordinateTableName; String dbIdColumnName = dataSource.getDbColumnName(factory.getIdField(), coordinateTableName); String dbPointColumnName = dataSource.getDbColumnName(factory.getCoordinateField(), coordinateTableName); + // validating table + Try.of(this::getSourceFields, SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + factory.validate(fields, Pair.class).transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); + // setup queries this.basicQuery = createBaseQueryString(dataSource.schemaName, coordinateTableName); this.queryForPoint = createQueryForPoint(dbIdColumnName); @@ -76,13 +92,19 @@ public SqlIdCoordinateSource( SqlConnector connector, String schemaName, String coordinateTableName, - SqlIdCoordinateFactory factory) { + SqlIdCoordinateFactory factory) + throws SourceException { this( factory, coordinateTableName, new SqlDataSource(connector, schemaName, new DatabaseNamingStrategy())); } + @Override + public Optional> getSourceFields() { + return dataSource.getSourceFields(coordinateTableName); + } + @Override public Optional getCoordinate(int id) { List values = executeQueryToList(queryForPoint, ps -> ps.setInt(1, id)); diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMappingSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMappingSource.java index 65f65f436..6b37bd173 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMappingSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMappingSource.java @@ -7,34 +7,57 @@ import static edu.ie3.datamodel.io.source.sql.SqlDataSource.createBaseQueryString; +import edu.ie3.datamodel.exceptions.SourceException; import edu.ie3.datamodel.io.connectors.SqlConnector; import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy; import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy; import edu.ie3.datamodel.io.source.TimeSeriesMappingSource; +import edu.ie3.datamodel.utils.Try; import java.util.Map; +import java.util.Optional; +import java.util.Set; import java.util.stream.Stream; public class SqlTimeSeriesMappingSource extends TimeSeriesMappingSource { private final EntityPersistenceNamingStrategy entityPersistenceNamingStrategy; private final String queryFull; + private final String tableName; private final SqlDataSource dataSource; public SqlTimeSeriesMappingSource( SqlConnector connector, String schemaName, - EntityPersistenceNamingStrategy entityPersistenceNamingStrategy) { + EntityPersistenceNamingStrategy entityPersistenceNamingStrategy) + throws SourceException { this.dataSource = new SqlDataSource( connector, schemaName, new DatabaseNamingStrategy(entityPersistenceNamingStrategy)); this.entityPersistenceNamingStrategy = entityPersistenceNamingStrategy; - final String tableName = + this.tableName = entityPersistenceNamingStrategy.getEntityName(MappingEntry.class).orElseThrow(); this.queryFull = createBaseQueryString(schemaName, tableName); + + Try.of(this::getSourceFields, SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + mappingFactory + .validate(fields, MappingEntry.class) + .transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); } @Override public Stream> getMappingSourceData() { return dataSource.executeQuery(queryFull); } + + @Override + public Optional> getSourceFields() throws SourceException { + return dataSource.getSourceFields(tableName); + } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMetaInformationSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMetaInformationSource.java index ad01ebe62..f0144b986 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMetaInformationSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesMetaInformationSource.java @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.source.sql; import edu.ie3.datamodel.io.connectors.SqlConnector; -import edu.ie3.datamodel.io.factory.SimpleEntityData; +import edu.ie3.datamodel.io.factory.EntityData; import edu.ie3.datamodel.io.factory.timeseries.TimeSeriesMetaInformationFactory; import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy; import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme; @@ -92,8 +92,8 @@ public Optional getTimeSeriesMetaInformatio private Optional createEntity( Map fieldToValues) { - SimpleEntityData entityData = - new SimpleEntityData(fieldToValues, IndividualTimeSeriesMetaInformation.class); + EntityData entityData = + new EntityData(fieldToValues, IndividualTimeSeriesMetaInformation.class); return mappingFactory.get(entityData).getData(); } } diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSource.java index 126aefae5..f3c029aba 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSource.java @@ -18,6 +18,7 @@ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; import edu.ie3.datamodel.models.value.Value; import edu.ie3.datamodel.utils.TimeSeriesUtils; +import edu.ie3.datamodel.utils.Try; import edu.ie3.util.interval.ClosedInterval; import java.sql.Timestamp; import java.time.ZonedDateTime; @@ -50,7 +51,8 @@ public SqlTimeSeriesSource( SqlDataSource sqlDataSource, UUID timeSeriesUuid, Class valueClass, - TimeBasedSimpleValueFactory factory) { + TimeBasedSimpleValueFactory factory) + throws SourceException { super(valueClass, factory); this.dataSource = sqlDataSource; @@ -63,6 +65,16 @@ public SqlTimeSeriesSource( final String tableName = sqlDataSource.databaseNamingStrategy.getTimeSeriesEntityName(columnScheme); + Try.of(() -> dataSource.getSourceFields(tableName), SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + factory.validate(fields, valueClass).transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); + String dbTimeColumnName = sqlDataSource.getDbColumnName(factory.getTimeFieldString(), tableName); @@ -88,7 +100,8 @@ public SqlTimeSeriesSource( DatabaseNamingStrategy namingStrategy, UUID timeSeriesUuid, Class valueClass, - TimeBasedSimpleValueFactory factory) { + TimeBasedSimpleValueFactory factory) + throws SourceException { this( new SqlDataSource(connector, schemaName, namingStrategy), timeSeriesUuid, @@ -130,7 +143,8 @@ private static SqlTimeSeriesSource create( DatabaseNamingStrategy namingStrategy, UUID timeSeriesUuid, Class valClass, - String timePattern) { + String timePattern) + throws SourceException { TimeBasedSimpleValueFactory valueFactory = new TimeBasedSimpleValueFactory<>(valClass, timePattern); return new SqlTimeSeriesSource<>( diff --git a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlWeatherSource.java b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlWeatherSource.java index d2aab44e1..37ac91c2e 100644 --- a/src/main/java/edu/ie3/datamodel/io/source/sql/SqlWeatherSource.java +++ b/src/main/java/edu/ie3/datamodel/io/source/sql/SqlWeatherSource.java @@ -16,6 +16,7 @@ import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries; import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue; import edu.ie3.datamodel.models.value.WeatherValue; +import edu.ie3.datamodel.utils.Try; import edu.ie3.util.interval.ClosedInterval; import java.sql.*; import java.time.ZonedDateTime; @@ -30,6 +31,7 @@ public class SqlWeatherSource extends WeatherSource { private static final String WHERE = " WHERE "; private final String factoryCoordinateFieldName; + private final String tableName; /** * Queries that are available within this source. Motivation to have them as field value is to @@ -54,10 +56,24 @@ public SqlWeatherSource( IdCoordinateSource idCoordinateSource, String schemaName, String weatherTableName, - TimeBasedWeatherValueFactory weatherFactory) { + TimeBasedWeatherValueFactory weatherFactory) + throws SourceException { super(idCoordinateSource, weatherFactory); this.factoryCoordinateFieldName = weatherFactory.getCoordinateIdFieldString(); this.dataSource = new SqlDataSource(connector, schemaName, new DatabaseNamingStrategy()); + this.tableName = weatherTableName; + + Try.of(() -> getSourceFields(WeatherValue.class), SourceException.class) + .flatMap( + fieldsOpt -> + fieldsOpt + .map( + fields -> + weatherFactory + .validate(fields, WeatherValue.class) + .transformF(SourceException::new)) + .orElse(Try.Success.empty())) + .getOrThrow(); String dbTimeColumnName = dataSource.getDbColumnName(weatherFactory.getTimeFieldString(), weatherTableName); @@ -75,6 +91,11 @@ public SqlWeatherSource( schemaName, weatherTableName, dbTimeColumnName, dbCoordinateIdColumnName); } + @Override + public Optional> getSourceFields(Class entityClass) { + return dataSource.getSourceFields(tableName); + } + @Override public Map> getWeather( ClosedInterval timeInterval) throws SourceException { diff --git a/src/main/java/edu/ie3/datamodel/models/ControlStrategy.java b/src/main/java/edu/ie3/datamodel/models/ControlStrategy.java deleted file mode 100644 index 61ad82ddf..000000000 --- a/src/main/java/edu/ie3/datamodel/models/ControlStrategy.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * © 2022. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation -*/ -package edu.ie3.datamodel.models; - -import edu.ie3.datamodel.exceptions.ParsingException; -import java.io.Serializable; -import java.util.Arrays; - -public interface ControlStrategy extends Serializable { - String getKey(); - - static ControlStrategy parse(String key) throws ParsingException { - if (key == null || key.isEmpty()) - return ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY; - - String filterKey = key.toLowerCase().replace("-", "_"); - return Arrays.stream(EmControlStrategy.values()) - .filter(profile -> profile.getKey().equals(filterKey)) - .findFirst() - .orElseThrow( - () -> new ParsingException("Cannot parse \"" + key + "\" to a valid control strategy")); - } - - enum DefaultControlStrategies implements ControlStrategy { - NO_CONTROL_STRATEGY; - - @Override - public String getKey() { - return "No control strategy assigned"; - } - } -} diff --git a/src/main/java/edu/ie3/datamodel/models/EmControlStrategy.java b/src/main/java/edu/ie3/datamodel/models/EmControlStrategy.java deleted file mode 100644 index ffb216a35..000000000 --- a/src/main/java/edu/ie3/datamodel/models/EmControlStrategy.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * © 2022. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation -*/ -package edu.ie3.datamodel.models; - -import java.util.Arrays; -import java.util.Locale; -import java.util.stream.Collectors; - -public enum EmControlStrategy implements ControlStrategy { - SELF_OPTIMIZATION("self_optimization"); - - private final String key; - - EmControlStrategy(String key) { - this.key = key.toLowerCase(Locale.ROOT); - } - - public static EmControlStrategy get(String key) { - return Arrays.stream(EmControlStrategy.values()) - .filter(controlStrategy -> controlStrategy.key.equalsIgnoreCase(key)) - .findFirst() - .orElseThrow( - () -> - new IllegalArgumentException( - "No predefined energy management control strategy '" - + key - + "' found. Please provide one of the following keys: " - + Arrays.stream(EmControlStrategy.values()) - .map(EmControlStrategy::getKey) - .collect(Collectors.joining(", ")))); - } - - @Override - public String getKey() { - return key; - } - - @Override - public String toString() { - return "EmControlStrategy{" + "key='" + key + '\'' + '}'; - } -} diff --git a/src/main/java/edu/ie3/datamodel/models/StandardUnits.java b/src/main/java/edu/ie3/datamodel/models/StandardUnits.java index e8c8d96f7..35f98dcfe 100644 --- a/src/main/java/edu/ie3/datamodel/models/StandardUnits.java +++ b/src/main/java/edu/ie3/datamodel/models/StandardUnits.java @@ -78,8 +78,8 @@ public class StandardUnits { /** Voltage angle variation per tap (for transformers) in ° (arc degree) */ public static final Unit DPHI_TAP = DEGREE_GEOM; /** - * Gradient, with which a system participant can change it's set point (with regard to rated - * active power = rated apparent power * rated power factor) in %/h + * Gradient, with which a system participant can change its set point (with regard to rated active + * power = rated apparent power * rated power factor) in %/h */ public static final Unit ACTIVE_POWER_GRADIENT = PERCENT_PER_HOUR; /** Efficiency of a process in % */ diff --git a/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java index 907280676..6e3a558e4 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/AssetTypeInput.java @@ -43,4 +43,35 @@ public int hashCode() { public String toString() { return "AssetTypeInput{" + "uuid=" + getUuid() + ", id=" + id + "}"; } + + /** + * Abstract class for all builder that build child entities of abstract class {@link + * AssetTypeInput} + */ + public abstract static class AssetTypeInputCopyBuilder< + B extends AssetTypeInput.AssetTypeInputCopyBuilder> + extends UniqueEntityCopyBuilder { + + private String id; + + protected AssetTypeInputCopyBuilder(AssetTypeInput entity) { + super(entity); + this.id = entity.getId(); + } + + public B id(String id) { + this.id = id; + return thisInstance(); + } + + protected String getId() { + return id; + } + + @Override + public abstract AssetTypeInput build(); + + @Override + protected abstract B thisInstance(); + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/EmInput.java b/src/main/java/edu/ie3/datamodel/models/input/EmInput.java new file mode 100644 index 000000000..1376caa1c --- /dev/null +++ b/src/main/java/edu/ie3/datamodel/models/input/EmInput.java @@ -0,0 +1,139 @@ +/* + * © 2022. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation +*/ +package edu.ie3.datamodel.models.input; + +import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.UniqueEntity; +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +public class EmInput extends AssetInput { + + /** Reference to the control strategy to be used for this model */ + private final String controlStrategy; + + /** + * Optional UUID of the parent {@link EmInput} that is controlling this em unit. If null, this em + * unit is not em-controlled. + */ + private final EmInput parentEm; + + /** + * Constructor for an operated energy management system + * + * @param uuid of the input entity + * @param id of the asset + * @param operator of the asset + * @param operationTime time for which the entity is operated + * @param emControlStrategy the control strategy + * @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable. + */ + public EmInput( + UUID uuid, + String id, + OperatorInput operator, + OperationTime operationTime, + String emControlStrategy, + EmInput parentEm) { + super(uuid, id, operator, operationTime); + this.controlStrategy = emControlStrategy; + this.parentEm = parentEm; + } + + /** + * Constructor for an operated energy management system + * + * @param uuid of the input entity + * @param id of the asset + * @param emControlStrategy the control strategy + * @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable. + */ + public EmInput(UUID uuid, String id, String emControlStrategy, EmInput parentEm) { + super(uuid, id); + this.controlStrategy = emControlStrategy; + this.parentEm = parentEm; + } + + public String getControlStrategy() { + return controlStrategy; + } + + public Optional getParentEm() { + return Optional.ofNullable(parentEm); + } + + @Override + public EmInputCopyBuilder copy() { + return new EmInputCopyBuilder(this); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof EmInput emInput)) return false; + if (!super.equals(o)) return false; + return Objects.equals(controlStrategy, emInput.controlStrategy) + && Objects.equals(parentEm, emInput.parentEm); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), controlStrategy, parentEm); + } + + @Override + public String toString() { + return "EmInput{" + + "uuid=" + + getUuid() + + ", id='" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", controlStrategy=" + + getControlStrategy() + + ", parentEm=" + + getParentEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("") + + '}'; + } + + public static class EmInputCopyBuilder extends AssetInputCopyBuilder { + + private String controlStrategy; + + private EmInput parentEm; + + protected EmInputCopyBuilder(EmInput entity) { + super(entity); + this.controlStrategy = entity.getControlStrategy(); + this.parentEm = entity.parentEm; + } + + public EmInputCopyBuilder controlStrategy(String controlStrategy) { + this.controlStrategy = controlStrategy; + return this; + } + + public EmInputCopyBuilder parentEm(EmInput parentEm) { + this.parentEm = parentEm; + return thisInstance(); + } + + @Override + public EmInput build() { + return new EmInput( + getUuid(), getId(), getOperator(), getOperationTime(), controlStrategy, parentEm); + } + + @Override + protected EmInputCopyBuilder thisInstance() { + return this; + } + } +} diff --git a/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java b/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java index f5b68d97e..6b2b01efa 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/connector/Transformer3WInput.java @@ -79,7 +79,7 @@ public Transformer3WInput( * transformer (here: that not holds node A in its grid). * *

Then, the internal node becomes a virtual representation of a slack node for the grid and - * allows for power flow calculations based on it's 'close-to-T-equivalent' representation + * allows for power flow calculations based on its 'close-to-T-equivalent' representation * * @param uuid of the input entity * @param id of the asset diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/SystemParticipants.java b/src/main/java/edu/ie3/datamodel/models/input/container/SystemParticipants.java index ae90f50c4..5080722c2 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/container/SystemParticipants.java +++ b/src/main/java/edu/ie3/datamodel/models/input/container/SystemParticipants.java @@ -16,7 +16,7 @@ public class SystemParticipants implements InputContainer { private final Set bmPlants; private final Set chpPlants; - private final Set evCS; + private final Set evcs; private final Set evs; private final Set fixedFeedIns; private final Set heatPumps; @@ -24,23 +24,21 @@ public class SystemParticipants implements InputContainer pvPlants; private final Set storages; private final Set wecPlants; - private final Set emSystems; public SystemParticipants( Set bmPlants, Set chpPlants, - Set evCS, + Set evcs, Set evs, Set fixedFeedIns, Set heatPumps, Set loads, Set pvPlants, Set storages, - Set wecPlants, - Set emSystems) { + Set wecPlants) { this.bmPlants = bmPlants; this.chpPlants = chpPlants; - this.evCS = evCS; + this.evcs = evcs; this.evs = evs; this.fixedFeedIns = fixedFeedIns; this.heatPumps = heatPumps; @@ -48,7 +46,6 @@ public SystemParticipants( this.pvPlants = pvPlants; this.storages = storages; this.wecPlants = wecPlants; - this.emSystems = emSystems; } /** @@ -65,9 +62,9 @@ public SystemParticipants(Collection systemParticipants) { systemParticipants.stream() .flatMap(participants -> participants.chpPlants.stream()) .collect(Collectors.toSet()); - this.evCS = + this.evcs = systemParticipants.stream() - .flatMap(participants -> participants.evCS.stream()) + .flatMap(participants -> participants.evcs.stream()) .collect(Collectors.toSet()); this.evs = systemParticipants.stream() @@ -97,10 +94,6 @@ public SystemParticipants(Collection systemParticipants) { systemParticipants.stream() .flatMap(participants -> participants.wecPlants.stream()) .collect(Collectors.toSet()); - this.emSystems = - systemParticipants.stream() - .flatMap(participants -> participants.emSystems.stream()) - .collect(Collectors.toSet()); } /** @@ -122,7 +115,7 @@ public SystemParticipants(List systemParticipants) { .filter(ChpInput.class::isInstance) .map(ChpInput.class::cast) .collect(Collectors.toSet()); - this.evCS = + this.evcs = systemParticipants.parallelStream() .filter(EvcsInput.class::isInstance) .map(EvcsInput.class::cast) @@ -162,11 +155,6 @@ public SystemParticipants(List systemParticipants) { .filter(WecInput.class::isInstance) .map(WecInput.class::cast) .collect(Collectors.toSet()); - this.emSystems = - systemParticipants.parallelStream() - .filter(EmInput.class::isInstance) - .map(EmInput.class::cast) - .collect(Collectors.toSet()); } @Override @@ -174,7 +162,7 @@ public final List allEntitiesAsList() { List allEntities = new ArrayList<>(); allEntities.addAll(bmPlants); allEntities.addAll(chpPlants); - allEntities.addAll(evCS); + allEntities.addAll(evcs); allEntities.addAll(evs); allEntities.addAll(fixedFeedIns); allEntities.addAll(heatPumps); @@ -182,7 +170,6 @@ public final List allEntitiesAsList() { allEntities.addAll(pvPlants); allEntities.addAll(storages); allEntities.addAll(wecPlants); - allEntities.addAll(emSystems); return Collections.unmodifiableList(allEntities); } @@ -201,8 +188,8 @@ public Set getChpPlants() { } /** @return unmodifiable Set of all ev charging stations in this grid */ - public Set getEvCS() { - return Collections.unmodifiableSet(evCS); + public Set getEvcs() { + return Collections.unmodifiableSet(evcs); } /** @return unmodifiable Set of all electric vehicles in this grid */ @@ -240,17 +227,13 @@ public Set getWecPlants() { return Collections.unmodifiableSet(wecPlants); } - public Set getEmSystems() { - return Collections.unmodifiableSet(emSystems); - } - @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof SystemParticipants that)) return false; return Objects.equals(bmPlants, that.bmPlants) && Objects.equals(chpPlants, that.chpPlants) - && Objects.equals(evCS, that.evCS) + && Objects.equals(evcs, that.evcs) && Objects.equals(evs, that.evs) && Objects.equals(fixedFeedIns, that.fixedFeedIns) && Objects.equals(heatPumps, that.heatPumps) @@ -265,7 +248,7 @@ public int hashCode() { return Objects.hash( bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, @@ -287,7 +270,7 @@ public static class SystemParticipantsCopyBuilder implements InputContainerCopyBuilder { private Set bmPlants; private Set chpPlants; - private Set evCS; + private Set evcs; private Set evs; private Set fixedFeedIns; private Set heatPumps; @@ -295,7 +278,6 @@ public static class SystemParticipantsCopyBuilder private Set pvPlants; private Set storages; private Set wecPlants; - private Set emSystems; /** * Constructor for {@link SystemParticipantsCopyBuilder} @@ -305,7 +287,7 @@ public static class SystemParticipantsCopyBuilder protected SystemParticipantsCopyBuilder(SystemParticipants systemParticipants) { this.bmPlants = systemParticipants.bmPlants; this.chpPlants = systemParticipants.chpPlants; - this.evCS = systemParticipants.evCS; + this.evcs = systemParticipants.evcs; this.evs = systemParticipants.evs; this.fixedFeedIns = systemParticipants.fixedFeedIns; this.heatPumps = systemParticipants.heatPumps; @@ -313,7 +295,6 @@ protected SystemParticipantsCopyBuilder(SystemParticipants systemParticipants) { this.pvPlants = systemParticipants.pvPlants; this.storages = systemParticipants.storages; this.wecPlants = systemParticipants.wecPlants; - this.emSystems = systemParticipants.emSystems; } /** @@ -341,11 +322,11 @@ public SystemParticipantsCopyBuilder chpPlants(Set chpPlants) { /** * Method to alter {@link EvcsInput} * - * @param evCS set of altered biomass electric vehicle charging stations + * @param evcs set of altered biomass electric vehicle charging stations * @return this instance of {@link SystemParticipantsCopyBuilder} */ - public SystemParticipantsCopyBuilder evCS(Set evCS) { - this.evCS = evCS; + public SystemParticipantsCopyBuilder evcs(Set evcs) { + this.evcs = evcs; return this; } @@ -426,31 +407,19 @@ public SystemParticipantsCopyBuilder wecPlants(Set wecPlants) { return this; } - /** - * Method to alter {@link EmInput} - * - * @param emSystems set of altered energy management systems - * @return this instance of {@link SystemParticipantsCopyBuilder} - */ - public SystemParticipantsCopyBuilder emSystems(Set emSystems) { - this.emSystems = emSystems; - return this; - } - @Override public SystemParticipants build() { return new SystemParticipants( bmPlants, chpPlants, - evCS, + evcs, evs, fixedFeedIns, heatPumps, loads, pvPlants, storages, - wecPlants, - emSystems); + wecPlants); } } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java index 3b6d277cc..b3616bc70 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java +++ b/src/main/java/edu/ie3/datamodel/models/input/container/ThermalGrid.java @@ -10,6 +10,7 @@ import edu.ie3.datamodel.models.input.thermal.ThermalInput; import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput; import java.util.*; +import java.util.stream.Collectors; /** * Container object to denote a fully connected thermal "grid". As there are currently no branch @@ -108,6 +109,18 @@ public ThermalGridCopyBuilder storages(Set storages) { return this; } + public ThermalGridCopyBuilder scale(Double factor) { + houses( + houses.stream() + .map(house -> house.copy().scale(factor).build()) + .collect(Collectors.toSet())); + storages( + storages.stream() + .map(storage -> storage.copy().scale(factor).build()) + .collect(Collectors.toSet())); + return this; + } + @Override public ThermalGrid build() { return new ThermalGrid(bus, houses, storages); diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java index ec6003abe..9ddb9533d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java @@ -8,6 +8,7 @@ import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -39,6 +40,7 @@ public class BmInput extends SystemParticipantInput implements HasType { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of BM * @param marketReaction Is this asset market oriented? * @param costControlled Does this plant increase the output power if the revenues exceed the @@ -52,11 +54,12 @@ public BmInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, BmTypeInput type, boolean marketReaction, boolean costControlled, ComparableQuantity feedInTariff) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; this.marketReaction = marketReaction; this.costControlled = costControlled; @@ -70,6 +73,7 @@ public BmInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of BM * @param marketReaction Is this asset market oriented? * @param costControlled Does this plant increase the output power if the revenues exceed the @@ -81,11 +85,12 @@ public BmInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, BmTypeInput type, boolean marketReaction, boolean costControlled, ComparableQuantity feedInTariff) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.type = type; this.marketReaction = marketReaction; this.costControlled = costControlled; @@ -144,8 +149,9 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' - + "type=" + + "', em=" + + getEm() + + ", type=" + type.getUuid() + ", marketReaction=" + marketReaction @@ -199,6 +205,12 @@ public BmInputCopyBuilder feedInTariff(ComparableQuantity feedInTar return this; } + @Override + public BmInputCopyBuilder scale(Double factor) { + this.type = this.type.copy().scale(factor).build(); + return this; + } + @Override public BmInput build() { return new BmInput( @@ -208,6 +220,7 @@ public BmInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), type, marketReaction, costControlled, diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java index 422817ecb..f68d842a1 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java @@ -9,6 +9,7 @@ import edu.ie3.datamodel.io.extractor.HasThermalStorage; import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -41,6 +42,7 @@ public class ChpInput extends SystemParticipantInput * @param thermalBus The thermal bus, this model is connected to (normally equal to the thermal * bus of the provided thermal storage!) * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of CHP * @param thermalStorage Thermal storage model * @param marketReaction Is this asset market oriented? @@ -53,10 +55,11 @@ public ChpInput( NodeInput node, ThermalBusInput thermalBus, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChpTypeInput type, ThermalStorageInput thermalStorage, boolean marketReaction) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.thermalBus = thermalBus; this.type = type; this.thermalStorage = thermalStorage; @@ -72,6 +75,7 @@ public ChpInput( * @param thermalBus The thermal bus, this model is connected to (normally equal to the thermal * bus of the provided thermal storage!) * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of CHP * @param thermalStorage Thermal storage model * @param marketReaction Is this asset market oriented? @@ -82,10 +86,11 @@ public ChpInput( NodeInput node, ThermalBusInput thermalBus, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChpTypeInput type, ThermalStorageInput thermalStorage, boolean marketReaction) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.thermalBus = thermalBus; this.type = type; this.thermalStorage = thermalStorage; @@ -145,7 +150,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", thermalBus=" + thermalBus.getUuid() + ", type=" @@ -190,6 +196,7 @@ public ChpInput build() { getNode(), thermalBus, getqCharacteristics(), + getEm(), type, thermalStorage, marketReaction); @@ -215,6 +222,12 @@ public ChpInputCopyBuilder marketReaction(boolean marketReaction) { return this; } + @Override + public ChpInputCopyBuilder scale(Double factor) { + this.type = this.type.copy().scale(factor).build(); + return this; + } + @Override protected ChpInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java deleted file mode 100644 index eeac609aa..000000000 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EmInput.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * © 2022. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation -*/ -package edu.ie3.datamodel.models.input.system; - -import edu.ie3.datamodel.models.ControlStrategy; -import edu.ie3.datamodel.models.EmControlStrategy; -import edu.ie3.datamodel.models.OperationTime; -import edu.ie3.datamodel.models.input.NodeInput; -import edu.ie3.datamodel.models.input.OperatorInput; -import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; -import java.util.Arrays; -import java.util.Objects; -import java.util.UUID; - -public class EmInput extends SystemParticipantInput { - - /** Reference via UUID to all SystemParticipantInputs connected to this model */ - private final UUID[] connectedAssets; - - /** Reference to the control strategy to be used for this model */ - private final ControlStrategy controlStrategy; - /** - * Constructor for an operated energy management system - * - * @param uuid of the input entity - * @param id of the asset - * @param operator of the asset - * @param operationTime time for which the entity is operated - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic - * @param connectedAssets array of all connected assets - * @param controlStrategy control strategy used for this model - */ - public EmInput( - UUID uuid, - String id, - OperatorInput operator, - OperationTime operationTime, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - ControlStrategy controlStrategy) { - super(uuid, id, operator, operationTime, node, qCharacteristics); - this.connectedAssets = connectedAssets; - this.controlStrategy = controlStrategy; - } - - /** - * Constructor for an operated energy management system - * - * @param uuid of the input entity - * @param id of the asset - * @param operator of the asset - * @param operationTime time for which the entity is operated - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic - * @param connectedAssets array of all connected assets - * @param emControlStrategy {@link edu.ie3.datamodel.models.EmControlStrategy} control strategy - * key - */ - public EmInput( - UUID uuid, - String id, - OperatorInput operator, - OperationTime operationTime, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - String emControlStrategy) { - super(uuid, id, operator, operationTime, node, qCharacteristics); - this.connectedAssets = connectedAssets; - this.controlStrategy = EmControlStrategy.get(emControlStrategy); - } - - /** - * Constructor for an operated energy management system - * - * @param uuid of the input entity - * @param id of the asset - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic - * @param connectedAssets array of all connected assets - * @param controlStrategy control strategy used for this model - */ - public EmInput( - UUID uuid, - String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - ControlStrategy controlStrategy) { - super(uuid, id, node, qCharacteristics); - this.connectedAssets = connectedAssets; - this.controlStrategy = controlStrategy; - } - - /** - * Constructor for an operated energy management system - * - * @param uuid of the input entity - * @param id of the asset - * @param node the asset is connected to - * @param qCharacteristics description of a reactive power characteristic - * @param connectedAssets array of all connected assets - * @param emControlStrategy {@link edu.ie3.datamodel.models.EmControlStrategy} control strategy - * key - */ - public EmInput( - UUID uuid, - String id, - NodeInput node, - ReactivePowerCharacteristic qCharacteristics, - UUID[] connectedAssets, - String emControlStrategy) { - super(uuid, id, node, qCharacteristics); - this.connectedAssets = connectedAssets; - this.controlStrategy = EmControlStrategy.get(emControlStrategy); - } - - public UUID[] getConnectedAssets() { - return connectedAssets; - } - - public ControlStrategy getControlStrategy() { - return controlStrategy; - } - - @Override - public EmInputCopyBuilder copy() { - return new EmInputCopyBuilder(this); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof EmInput emInput)) return false; - if (!super.equals(o)) return false; - return Arrays.equals(connectedAssets, emInput.connectedAssets) - && controlStrategy == emInput.controlStrategy; - } - - @Override - public int hashCode() { - return Objects.hash(super.hashCode(), Arrays.hashCode(connectedAssets), controlStrategy); - } - - @Override - public String toString() { - return "EmInput{" - + "uuid=" - + getUuid() - + ", id='" - + getId() - + ", operator=" - + getOperator().getUuid() - + ", operationTime=" - + getOperationTime() - + ", node=" - + getNode().getUuid() - + ", qCharacteristics='" - + getqCharacteristics() - + ", connectedAssets=" - + Arrays.toString(connectedAssets) - + ", controlStrategy=" - + controlStrategy - + '}'; - } - - public static class EmInputCopyBuilder - extends SystemParticipantInputCopyBuilder { - - private UUID[] connectedAssets; - - private ControlStrategy controlStrategy; - - protected EmInputCopyBuilder(EmInput entity) { - super(entity); - this.connectedAssets = entity.getConnectedAssets(); - this.controlStrategy = entity.getControlStrategy(); - } - - public EmInputCopyBuilder connectedAssets(UUID[] connectedAssets) { - this.connectedAssets = connectedAssets; - return this; - } - - public EmInputCopyBuilder controlStrategy(ControlStrategy controlStrategy) { - this.controlStrategy = controlStrategy; - return this; - } - - @Override - public EmInput build() { - return new EmInput( - getUuid(), - getId(), - getOperator(), - getOperationTime(), - getNode(), - getqCharacteristics(), - connectedAssets, - controlStrategy); - } - - @Override - protected EmInputCopyBuilder thisInstance() { - return this; - } - } -} diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java index 5f2edeae9..0ddb4b21c 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -28,6 +29,7 @@ public class EvInput extends SystemParticipantInput implements HasType { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of EV */ public EvInput( @@ -37,8 +39,9 @@ public EvInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, EvTypeInput type) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; } @@ -49,6 +52,7 @@ public EvInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of EV */ public EvInput( @@ -56,8 +60,9 @@ public EvInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, EvTypeInput type) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.type = type; } @@ -98,7 +103,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", type=" + type.getUuid() + '}'; @@ -121,6 +127,17 @@ private EvInputCopyBuilder(EvInput entity) { this.type = entity.getType(); } + public EvInputCopyBuilder type(EvTypeInput type) { + this.type = type; + return this; + } + + @Override + public EvInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public EvInput build() { return new EvInput( @@ -130,14 +147,10 @@ public EvInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), type); } - public EvInputCopyBuilder type(EvTypeInput type) { - this.type = type; - return this; - } - @Override protected EvInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java index c8f02ed38..6bc40adfb 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java @@ -6,6 +6,7 @@ package edu.ie3.datamodel.models.input.system; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -38,6 +39,7 @@ public class EvcsInput extends SystemParticipantInput { * @param operationTime Time for which the entity is operated * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param chargingPoints number of charging points available at this charging station * @param cosPhiRated rated cos phi @@ -51,12 +53,13 @@ public EvcsInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChargingPointType type, int chargingPoints, double cosPhiRated, EvcsLocationType locationType, boolean v2gSupport) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; this.chargingPoints = chargingPoints; this.cosPhiRated = cosPhiRated; @@ -71,6 +74,7 @@ public EvcsInput( * @param operationTime Time for which the entity is operated * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param cosPhiRated rated cos phi * @param locationType the location type @@ -83,6 +87,7 @@ public EvcsInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChargingPointType type, double cosPhiRated, EvcsLocationType locationType, @@ -94,6 +99,7 @@ public EvcsInput( operationTime, node, qCharacteristics, + em, type, 1, cosPhiRated, @@ -105,6 +111,7 @@ public EvcsInput( * @param id Human readable identifier * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param chargingPoints number of charging points available at this charging station * @param cosPhiRated rated cos phi @@ -116,12 +123,13 @@ public EvcsInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChargingPointType type, int chargingPoints, double cosPhiRated, EvcsLocationType locationType, boolean v2gSupport) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.type = type; this.chargingPoints = chargingPoints; this.cosPhiRated = cosPhiRated; @@ -134,6 +142,7 @@ public EvcsInput( * @param id Human readable identifier * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type type of the charging points available to this charging station * @param cosPhiRated rated cos phi * @param locationType the location type @@ -144,11 +153,12 @@ public EvcsInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ChargingPointType type, double cosPhiRated, EvcsLocationType locationType, boolean v2gSupport) { - this(uuid, id, node, qCharacteristics, type, 1, cosPhiRated, locationType, v2gSupport); + this(uuid, id, node, qCharacteristics, em, type, 1, cosPhiRated, locationType, v2gSupport); } public ChargingPointType getType() { @@ -196,11 +206,20 @@ public int hashCode() { @Override public String toString() { return "EvcsInput{" - + "id='" - + getId() - + '\'' - + ", uuid=" + + "uuid=" + getUuid() + + ", id=" + + getId() + + ", operator=" + + getOperator().getUuid() + + ", operationTime=" + + getOperationTime() + + ", node=" + + getNode().getUuid() + + ", qCharacteristics='" + + getqCharacteristics() + + "', em=" + + getEm() + ", type=" + type + ", chargingPoints=" @@ -209,12 +228,9 @@ public String toString() { + cosPhiRated + ", locationType=" + locationType - + ", node=" - + getNode() - + "} " + ", v2gSupport=" + getV2gSupport() - + super.toString(); + + '}'; } /** @@ -267,6 +283,12 @@ public EvcsInputCopyBuilder v2gSupport(boolean v2gSupport) { return this; } + @Override + public EvcsInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public EvcsInput build() { return new EvcsInput( @@ -276,6 +298,7 @@ public EvcsInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), type, chargingPoints, cosPhiRated, diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java index 16ba19dc7..d0580202f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -31,6 +32,7 @@ public class FixedFeedInInput extends SystemParticipantInput { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param sRated Rated apparent power * @param cosPhiRated Power factor */ @@ -41,9 +43,10 @@ public FixedFeedInInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.sRated = sRated.to(StandardUnits.S_RATED); this.cosPhiRated = cosPhiRated; } @@ -55,6 +58,7 @@ public FixedFeedInInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param sRated Rated apparent power * @param cosPhiRated Power factor */ @@ -63,9 +67,10 @@ public FixedFeedInInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.sRated = sRated.to(StandardUnits.S_RATED); this.cosPhiRated = cosPhiRated; } @@ -110,7 +115,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", sRated=" + sRated + ", cosphiRated=" @@ -138,6 +144,22 @@ private FixedFeedInInputCopyBuilder(FixedFeedInInput entity) { this.cosPhiRated = entity.getCosPhiRated(); } + public FixedFeedInInputCopyBuilder sRated(ComparableQuantity sRated) { + this.sRated = sRated; + return this; + } + + public FixedFeedInInputCopyBuilder cosPhiRated(double cosPhiRated) { + this.cosPhiRated = cosPhiRated; + return this; + } + + @Override + public FixedFeedInInputCopyBuilder scale(Double factor) { + sRated(sRated.multiply(factor)); + return this; + } + @Override public FixedFeedInInput build() { return new FixedFeedInInput( @@ -147,20 +169,11 @@ public FixedFeedInInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), sRated, cosPhiRated); } - public FixedFeedInInputCopyBuilder sRated(ComparableQuantity sRated) { - this.sRated = sRated; - return this; - } - - public FixedFeedInInputCopyBuilder cosPhiRated(double cosPhiRated) { - this.cosPhiRated = cosPhiRated; - return this; - } - @Override protected FixedFeedInInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java index ef5bf7fea..bd1aff3e2 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java @@ -8,6 +8,7 @@ import edu.ie3.datamodel.io.extractor.HasThermalBus; import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -33,6 +34,7 @@ public class HpInput extends SystemParticipantInput implements HasType, HasTherm * @param node the asset is connected to * @param thermalBus The thermal bus, this model is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of HP */ public HpInput( @@ -43,8 +45,9 @@ public HpInput( NodeInput node, ThermalBusInput thermalBus, ReactivePowerCharacteristic qCharacteristics, + EmInput em, HpTypeInput type) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.thermalBus = thermalBus; this.type = type; } @@ -57,6 +60,7 @@ public HpInput( * @param node the asset is connected to * @param thermalBus The thermal bus, this model is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of HP */ public HpInput( @@ -65,8 +69,9 @@ public HpInput( NodeInput node, ThermalBusInput thermalBus, ReactivePowerCharacteristic qCharacteristics, + EmInput em, HpTypeInput type) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.thermalBus = thermalBus; this.type = type; } @@ -113,7 +118,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", type=" + type.getUuid() + ", thermalBus=" @@ -140,6 +146,22 @@ private HpInputCopyBuilder(HpInput entity) { this.thermalBus = entity.getThermalBus(); } + public HpInputCopyBuilder type(HpTypeInput type) { + this.type = type; + return this; + } + + public HpInputCopyBuilder thermalBus(ThermalBusInput thermalBus) { + this.thermalBus = thermalBus; + return this; + } + + @Override + public HpInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public HpInput build() { return new HpInput( @@ -150,19 +172,10 @@ public HpInput build() { getNode(), thermalBus, getqCharacteristics(), + getEm(), type); } - public HpInputCopyBuilder type(HpTypeInput type) { - this.type = type; - return this; - } - - public HpInputCopyBuilder thermalBus(ThermalBusInput thermalBus) { - this.thermalBus = thermalBus; - return this; - } - @Override protected HpInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java index 9f320d851..924af0c89 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.exceptions.ParsingException; import edu.ie3.datamodel.models.*; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -47,6 +48,7 @@ public class LoadInput extends SystemParticipantInput { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param loadProfile Load profile to use for this model * @param dsm True, if demand side management is activated for this load * @param eConsAnnual Annually consumed energy (typically in kWh) @@ -60,12 +62,13 @@ public LoadInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, LoadProfile loadProfile, boolean dsm, ComparableQuantity eConsAnnual, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.loadProfile = loadProfile; this.dsm = dsm; this.eConsAnnual = eConsAnnual.to(StandardUnits.ENERGY_IN); @@ -82,6 +85,7 @@ public LoadInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param loadProfileKey Load profile key corresponding to {@link * edu.ie3.datamodel.models.profile.BdewStandardLoadProfile} or {@link * edu.ie3.datamodel.models.profile.NbwTemperatureDependantLoadProfile} @@ -97,6 +101,7 @@ public LoadInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, String loadProfileKey, boolean dsm, ComparableQuantity eConsAnnual, @@ -111,6 +116,7 @@ public LoadInput( operationTime, node, qCharacteristics, + em, LoadProfile.parse(loadProfileKey), dsm, eConsAnnual, @@ -125,6 +131,7 @@ public LoadInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param loadProfile Standard load profile to use for this model * @param dsm True, if demand side management is activated for this load * @param eConsAnnual Annually consumed energy (typically in kWh) @@ -136,12 +143,13 @@ public LoadInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, LoadProfile loadProfile, boolean dsm, ComparableQuantity eConsAnnual, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.loadProfile = loadProfile; this.dsm = dsm; this.eConsAnnual = eConsAnnual.to(StandardUnits.ENERGY_IN); @@ -156,6 +164,7 @@ public LoadInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param loadProfileKey load profile key corresponding to {@link * edu.ie3.datamodel.models.profile.BdewStandardLoadProfile} or {@link * edu.ie3.datamodel.models.profile.NbwTemperatureDependantLoadProfile} @@ -169,6 +178,7 @@ public LoadInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, String loadProfileKey, boolean dsm, ComparableQuantity eConsAnnual, @@ -180,6 +190,7 @@ public LoadInput( id, node, qCharacteristics, + em, LoadProfile.parse(loadProfileKey), dsm, eConsAnnual, @@ -243,7 +254,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", dsm=" + dsm + ", eConsAnnual=" @@ -305,6 +317,13 @@ public LoadInputCopyBuilder cosPhiRated(double cosPhiRated) { return this; } + @Override + public LoadInputCopyBuilder scale(Double factor) { + eConsAnnual(eConsAnnual.multiply(factor)); + sRated(sRated.multiply(factor)); + return this; + } + @Override public LoadInput build() { return new LoadInput( @@ -314,6 +333,7 @@ public LoadInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), loadProfile, dsm, eConsAnnual, diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java index 49a68253f..47812390f 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/PvInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.models.OperationTime; import edu.ie3.datamodel.models.StandardUnits; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -48,6 +49,7 @@ public class PvInput extends SystemParticipantInput { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param albedo Albedo value (typically a value between 0 and 1) * @param azimuth Inclination in a compass direction (typically °: South 0◦; West 90◦; East -90◦) * @param etaConv Efficiency of converter (typically in %) @@ -65,6 +67,7 @@ public PvInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, double albedo, ComparableQuantity azimuth, ComparableQuantity etaConv, @@ -74,7 +77,7 @@ public PvInput( boolean marketReaction, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.albedo = albedo; this.azimuth = azimuth.to(StandardUnits.AZIMUTH); this.etaConv = etaConv.to(StandardUnits.EFFICIENCY); @@ -93,6 +96,7 @@ public PvInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param albedo Albedo value (typically a value between 0 and 1) * @param azimuth Inclination in a compass direction (typically °: South 0◦; West 90◦; East -90◦) * @param etaConv Efficiency of converter (typically in %) @@ -108,6 +112,7 @@ public PvInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, double albedo, ComparableQuantity azimuth, ComparableQuantity etaConv, @@ -117,7 +122,7 @@ public PvInput( boolean marketReaction, ComparableQuantity sRated, double cosPhiRated) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.albedo = albedo; this.azimuth = azimuth.to(StandardUnits.AZIMUTH); this.etaConv = etaConv.to(StandardUnits.EFFICIENCY); @@ -215,7 +220,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", albedo=" + albedo + ", azimuth=" @@ -315,6 +321,12 @@ public PvInputCopyBuilder cosPhiRated(double cosPhiRated) { return this; } + @Override + public PvInputCopyBuilder scale(Double factor) { + this.sRated = this.sRated.multiply(factor); + return this; + } + @Override public PvInput build() { return new PvInput( @@ -324,6 +336,7 @@ public PvInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), albedo, azimuth, etaConv, diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java index 26726cb03..ec4cc3ddc 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/StorageInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -28,6 +29,7 @@ public class StorageInput extends SystemParticipantInput implements HasType { * @param operationTime time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic for integrated inverter + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of storage */ public StorageInput( @@ -37,8 +39,9 @@ public StorageInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, StorageTypeInput type) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; } @@ -49,6 +52,7 @@ public StorageInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of storage */ public StorageInput( @@ -56,8 +60,9 @@ public StorageInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, StorageTypeInput type) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.type = type; } @@ -98,7 +103,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", type=" + type.getUuid() + '}'; @@ -121,6 +127,17 @@ private StorageInputCopyBuilder(StorageInput entity) { this.type = entity.getType(); } + public StorageInputCopyBuilder type(StorageTypeInput type) { + this.type = type; + return this; + } + + @Override + public StorageInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public StorageInput build() { return new StorageInput( @@ -130,14 +147,10 @@ public StorageInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), type); } - public StorageInputCopyBuilder type(StorageTypeInput type) { - this.type = type; - return this; - } - @Override protected StorageInputCopyBuilder thisInstance() { return this; diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java index 9fa4a00a6..223dffe44 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/SystemParticipantInput.java @@ -7,7 +7,9 @@ import edu.ie3.datamodel.io.extractor.HasNodes; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.input.AssetInput; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -22,6 +24,12 @@ public abstract class SystemParticipantInput extends AssetInput implements HasNo /** Description of a reactive power characteristic. For details see further documentation */ private final ReactivePowerCharacteristic qCharacteristics; + /** + * Optional {@link EmInput} that is controlling this system participant. If null, this system + * participant is not em-controlled. + */ + private final EmInput em; + /** * Constructor for an operated system participant * @@ -31,6 +39,7 @@ public abstract class SystemParticipantInput extends AssetInput implements HasNo * @param operationTime Time for which the entity is operated * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. */ protected SystemParticipantInput( UUID uuid, @@ -38,10 +47,12 @@ protected SystemParticipantInput( OperatorInput operator, OperationTime operationTime, NodeInput node, - ReactivePowerCharacteristic qCharacteristics) { + ReactivePowerCharacteristic qCharacteristics, + EmInput em) { super(uuid, id, operator, operationTime); this.node = node; this.qCharacteristics = qCharacteristics; + this.em = em; } /** @@ -51,20 +62,30 @@ protected SystemParticipantInput( * @param id of the asset * @param node that the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. */ protected SystemParticipantInput( - UUID uuid, String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics) { + UUID uuid, + String id, + NodeInput node, + ReactivePowerCharacteristic qCharacteristics, + EmInput em) { super(uuid, id); this.node = node; this.qCharacteristics = qCharacteristics; + this.em = em; + } + + public NodeInput getNode() { + return node; } public ReactivePowerCharacteristic getqCharacteristics() { return qCharacteristics; } - public NodeInput getNode() { - return node; + public Optional getEm() { + return Optional.ofNullable(em); } @Override @@ -81,12 +102,13 @@ public boolean equals(Object o) { if (!(o instanceof SystemParticipantInput that)) return false; if (!super.equals(o)) return false; return Objects.equals(node, that.node) - && Objects.equals(qCharacteristics, that.qCharacteristics); + && Objects.equals(qCharacteristics, that.qCharacteristics) + && Objects.equals(em, that.em); } @Override public int hashCode() { - return Objects.hash(super.hashCode(), node, qCharacteristics); + return Objects.hash(super.hashCode(), node, qCharacteristics, em); } @Override @@ -104,7 +126,8 @@ public String toString() { + node.getUuid() + ", qCharacteristics='" + qCharacteristics - + '\'' + + "', em=" + + getEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("") + '}'; } @@ -121,11 +144,13 @@ public abstract static class SystemParticipantInputCopyBuilder< private NodeInput node; private ReactivePowerCharacteristic qCharacteristics; + private EmInput em; protected SystemParticipantInputCopyBuilder(SystemParticipantInput entity) { super(entity); this.node = entity.getNode(); this.qCharacteristics = entity.getqCharacteristics(); + this.em = entity.getEm().orElse(null); } public B node(NodeInput node) { @@ -138,6 +163,11 @@ public B qCharacteristics(ReactivePowerCharacteristic qCharacteristics) { return thisInstance(); } + public B em(EmInput em) { + this.em = em; + return thisInstance(); + } + protected NodeInput getNode() { return node; } @@ -146,6 +176,21 @@ protected ReactivePowerCharacteristic getqCharacteristics() { return qCharacteristics; } + /** @return The {@link EmInput} controlling this system participant. CAN BE NULL. */ + public EmInput getEm() { + return em; + } + + /** + * Scales the input entity in a way that tries to preserve proportions that are related to + * power. This means that capacity, consumption etc. are scaled with the same factor. Related + * properties associated with the input type (if applicable) are scaled as well. + * + * @param factor The factor to scale with + * @return A copy builder with scaled relevant properties + */ + public abstract B scale(Double factor); + @Override public abstract SystemParticipantInput build(); diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java index d5c5122d5..949708f66 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/WecInput.java @@ -7,6 +7,7 @@ import edu.ie3.datamodel.io.extractor.HasType; import edu.ie3.datamodel.models.OperationTime; +import edu.ie3.datamodel.models.input.EmInput; import edu.ie3.datamodel.models.input.NodeInput; import edu.ie3.datamodel.models.input.OperatorInput; import edu.ie3.datamodel.models.input.system.characteristic.ReactivePowerCharacteristic; @@ -31,6 +32,7 @@ public class WecInput extends SystemParticipantInput implements HasType { * @param operationTime Time for which the entity is operated * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of this WEC * @param marketReaction Is this asset market oriented? */ @@ -41,9 +43,10 @@ public WecInput( OperationTime operationTime, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, WecTypeInput type, boolean marketReaction) { - super(uuid, id, operator, operationTime, node, qCharacteristics); + super(uuid, id, operator, operationTime, node, qCharacteristics, em); this.type = type; this.marketReaction = marketReaction; } @@ -55,6 +58,7 @@ public WecInput( * @param id of the asset * @param node the asset is connected to * @param qCharacteristics Description of a reactive power characteristic + * @param em The {@link EmInput} controlling this system participant. Null, if not applicable. * @param type of this WEC * @param marketReaction Is this asset market oriented? */ @@ -63,9 +67,10 @@ public WecInput( String id, NodeInput node, ReactivePowerCharacteristic qCharacteristics, + EmInput em, WecTypeInput type, boolean marketReaction) { - super(uuid, id, node, qCharacteristics); + super(uuid, id, node, qCharacteristics, em); this.type = type; this.marketReaction = marketReaction; } @@ -112,7 +117,8 @@ public String toString() { + getNode().getUuid() + ", qCharacteristics='" + getqCharacteristics() - + '\'' + + "', em=" + + getEm() + ", type=" + type.getUuid() + ", marketReaction=" @@ -139,6 +145,12 @@ private WecInputCopyBuilder(WecInput entity) { this.marketReaction = entity.isMarketReaction(); } + @Override + public WecInputCopyBuilder scale(Double factor) { + type(type.copy().scale(factor).build()); + return this; + } + @Override public WecInput build() { return new WecInput( @@ -148,6 +160,7 @@ public WecInput build() { getOperationTime(), getNode(), getqCharacteristics(), + getEm(), type, marketReaction); } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java index ad150174a..b3cd3c7ce 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/BmTypeInput.java @@ -55,6 +55,11 @@ public ComparableQuantity getEtaConv() { return etaConv; } + @Override + public BmTypeInputCopyBuilder copy() { + return new BmTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -89,4 +94,65 @@ public String toString() { + etaConv + '}'; } + + /** + * A builder pattern based approach to create copies of {@link BmTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link BmTypeInput} + */ + public static class BmTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity activePowerGradient; + private ComparableQuantity etaConv; + + private BmTypeInputCopyBuilder(BmTypeInput entity) { + super(entity); + this.activePowerGradient = entity.getActivePowerGradient(); + this.etaConv = entity.getEtaConv(); + } + + public BmTypeInputCopyBuilder setActivePowerGradient( + ComparableQuantity activePowerGradient) { + this.activePowerGradient = activePowerGradient; + return this; + } + + public BmTypeInputCopyBuilder setEtaConv(ComparableQuantity etaConv) { + this.etaConv = etaConv; + return this; + } + + public ComparableQuantity getActivePowerGradient() { + return activePowerGradient; + } + + public ComparableQuantity getEtaConv() { + return etaConv; + } + + @Override + public BmTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + return this; + } + + @Override + public BmTypeInput build() { + return new BmTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + activePowerGradient, + getsRated(), + getCosPhiRated(), + etaConv); + } + + @Override + protected BmTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java index d4d1f6abe..498d577c0 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/ChpTypeInput.java @@ -71,6 +71,11 @@ public ComparableQuantity getpOwn() { return pOwn; } + @Override + public ChpTypeInputCopyBuilder copy() { + return new ChpTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -112,4 +117,90 @@ public String toString() { + pOwn + '}'; } + + /** + * A builder pattern based approach to create copies of {@link ChpTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link ChpTypeInput} + */ + public static class ChpTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity etaEl; + private ComparableQuantity etaThermal; + private ComparableQuantity pThermal; + private ComparableQuantity pOwn; + + private ChpTypeInputCopyBuilder(ChpTypeInput entity) { + super(entity); + this.etaEl = entity.getEtaEl(); + this.etaThermal = entity.getEtaThermal(); + this.pThermal = entity.getpThermal(); + this.pOwn = entity.getpOwn(); + } + + public ChpTypeInputCopyBuilder setEtaEl(ComparableQuantity etaEl) { + this.etaEl = etaEl; + return this; + } + + public ChpTypeInputCopyBuilder setEtaThermal(ComparableQuantity etaThermal) { + this.etaThermal = etaThermal; + return this; + } + + public ChpTypeInputCopyBuilder setpThermal(ComparableQuantity pThermal) { + this.pThermal = pThermal; + return this; + } + + public ChpTypeInputCopyBuilder setpOwn(ComparableQuantity pOwn) { + this.pOwn = pOwn; + return this; + } + + public ComparableQuantity getEtaEl() { + return etaEl; + } + + public ComparableQuantity getEtaThermal() { + return etaThermal; + } + + public ComparableQuantity getpThermal() { + return pThermal; + } + + public ComparableQuantity getpOwn() { + return pOwn; + } + + @Override + public ChpTypeInput.ChpTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + setpThermal(getpThermal().multiply(factor)); + setpOwn(getpOwn().multiply(factor)); + return this; + } + + @Override + public ChpTypeInput build() { + return new ChpTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + etaEl, + etaThermal, + getsRated(), + getCosPhiRated(), + pThermal, + pOwn); + } + + @Override + protected ChpTypeInput.ChpTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java index 465a1ae90..0402b026d 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/EvTypeInput.java @@ -54,6 +54,11 @@ public ComparableQuantity geteCons() { return eCons; } + @Override + public EvTypeInputCopyBuilder copy() { + return new EvTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -88,4 +93,66 @@ public String toString() { + eCons + '}'; } + + /** + * A builder pattern based approach to create copies of {@link EvTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link EvTypeInput} + */ + public static class EvTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity eStorage; + private ComparableQuantity eCons; + + private EvTypeInputCopyBuilder(EvTypeInput entity) { + super(entity); + this.eStorage = entity.geteStorage(); + this.eCons = entity.geteCons(); + } + + public EvTypeInputCopyBuilder seteStorage(ComparableQuantity eStorage) { + this.eStorage = eStorage; + return this; + } + + public EvTypeInputCopyBuilder seteCons(ComparableQuantity eCons) { + this.eCons = eCons; + return this; + } + + public ComparableQuantity geteStorage() { + return eStorage; + } + + public ComparableQuantity geteCons() { + return eCons; + } + + @Override + public EvTypeInput.EvTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + seteStorage(geteStorage().multiply(factor)); + seteCons(geteCons().multiply(factor)); + return this; + } + + @Override + public EvTypeInput build() { + return new EvTypeInput( + getUuid(), + getId(), + getCapex(), + getOpex(), + eStorage, + eCons, + getsRated(), + getCosPhiRated()); + } + + @Override + protected EvTypeInput.EvTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java index fb2532413..4b5edeeb5 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/HpTypeInput.java @@ -44,6 +44,11 @@ public ComparableQuantity getpThermal() { return pThermal; } + @Override + public HpTypeInputCopyBuilder copy() { + return new HpTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -76,4 +81,47 @@ public String toString() { + pThermal + '}'; } + + /** + * A builder pattern based approach to create copies of {@link HpTypeInput} entities with altered + * field values. For detailed field descriptions refer to java docs of {@link HpTypeInput} + */ + public static class HpTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity pThermal; + + private HpTypeInputCopyBuilder(HpTypeInput entity) { + super(entity); + this.pThermal = entity.getpThermal(); + } + + public HpTypeInputCopyBuilder setpThermal(ComparableQuantity pThermal) { + this.pThermal = pThermal; + return this; + } + + public ComparableQuantity getpThermal() { + return pThermal; + } + + @Override + public HpTypeInput.HpTypeInputCopyBuilder scale(Double factor) { + setCapex(getCapex().multiply(factor)); + setsRated(getsRated().multiply(factor)); + setpThermal(getpThermal().multiply(factor)); + return this; + } + + @Override + public HpTypeInput build() { + return new HpTypeInput( + getUuid(), getId(), getCapex(), getOpex(), getsRated(), getCosPhiRated(), pThermal); + } + + @Override + protected HpTypeInput.HpTypeInputCopyBuilder thisInstance() { + return this; + } + } } diff --git a/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java b/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java index 4358631b9..29892b868 100644 --- a/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java +++ b/src/main/java/edu/ie3/datamodel/models/input/system/type/StorageTypeInput.java @@ -101,6 +101,11 @@ public ComparableQuantity getActivePowerGradient() { return activePowerGradient; } + @Override + public StorageTypeInputCopyBuilder copy() { + return new StorageTypeInputCopyBuilder(this); + } + @Override public boolean equals(Object o) { if (this == o) return true; @@ -152,4 +157,128 @@ public String toString() { + lifeCycle + '}'; } + + /** + * A builder pattern based approach to create copies of {@link StorageTypeInput} entities with + * altered field values. For detailed field descriptions refer to java docs of {@link + * StorageTypeInput} + */ + public static class StorageTypeInputCopyBuilder + extends SystemParticipantTypeInputCopyBuilder { + + private ComparableQuantity eStorage; + private ComparableQuantity pMax; + private ComparableQuantity activePowerGradient; + private ComparableQuantity eta; + private ComparableQuantity dod; + private ComparableQuantity

+ * + * @param obj an object to be tested for equality + * @return {@code true} if the other object is "equal to" this object otherwise {@code false} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + return obj instanceof Success other && Objects.equals(data, other.data); + } + + /** + * Returns the hash code of the value. + * + * @return hash code value of the value + */ + @Override + public int hashCode() { + return Objects.hashCode(data); + } } /** Implementation of {@link Try} class. This class is used to present a failed try. */ @@ -382,6 +495,26 @@ public Try transform( return Failure.of(failureFunc.apply(exception)); } + @Override + public U convert(Function successFunc, Function failureFunc) { + return failureFunc.apply(exception); + } + + @Override + public T getOrElse(Supplier defaultData) { + return defaultData.get(); + } + + @Override + public Try orElse(Supplier> defaultTry) { + return defaultTry.get(); + } + + @Override + public Optional toOptional() { + return Optional.empty(); + } + /** Returns the thrown exception. */ public E get() { return exception; @@ -409,6 +542,37 @@ public static Failure of(E exception) { public static Failure ofVoid(E exception) { return new Failure<>(exception); } + + /** + * Indicates whether some other object is "equal to" this {@code Failure}. The other object is + * considered equal if: + * + *
    + *
  • it is also a {@code Failure} and; + *
  • the exceptions are "equal to" each other via {@code equals()}. + *
+ * + * @param obj an object to be tested for equality + * @return {@code true} if the other object is "equal to" this object otherwise {@code false} + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + + return obj instanceof Failure other && Objects.equals(exception, other.exception); + } + + /** + * Returns the hash code of the exception. + * + * @return hash code value of the exception + */ + @Override + public int hashCode() { + return Objects.hashCode(exception); + } } /** diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ConnectorValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ConnectorValidationUtils.java index 640e38426..dddf51f61 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ConnectorValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ConnectorValidationUtils.java @@ -15,7 +15,6 @@ import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput; import edu.ie3.datamodel.models.input.container.SubGridContainer; import edu.ie3.datamodel.utils.Try; -import edu.ie3.datamodel.utils.Try.*; import edu.ie3.util.geo.GeoUtils; import edu.ie3.util.quantities.QuantityUtil; import java.util.ArrayList; @@ -44,8 +43,12 @@ private ConnectorValidationUtils() { } /** - * Validates a connector if:
- * - it is not null
+ * Validates a connector if: + * + *
    + *
  • it is not null + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -73,25 +76,25 @@ protected static List> check(ConnectorInput co } else if (SwitchInput.class.isAssignableFrom(connector.getClass())) { exceptions.add(checkSwitch((SwitchInput) connector)); } else { - exceptions.add( - new Failure<>( - new InvalidEntityException( - "Validation failed due to: ", buildNotImplementedException(connector)))); + logNotImplemented(connector); } return exceptions; } /** - * Validates a line if:
- * - {@link ConnectorValidationUtils#checkLineType(LineTypeInput)} confirms valid type properties - *
- * - it does not connect the same node
- * - it connects nodes in the same subnet
- * - it connects nodes in the same voltage level
- * - its line length has a positive value
- * - its length equals the sum of calculated distances between points of LineString
- * - its coordinates of start and end point equal coordinates of nodes + * Validates a line if: + * + *
    + *
  • {@link ConnectorValidationUtils#checkLineType(LineTypeInput)} confirms valid type + * properties + *
  • it does not connect the same node + *
  • it connects nodes in the same subnet + *
  • it connects nodes in the same voltage level + *
  • its line length has a positive value + *
  • its length equals the sum of calculated distances between points of LineString + *
  • its coordinates of start and end point equal coordinates of nodes + *
* * @param line Line to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -116,14 +119,17 @@ private static List> checkLine(LineInput line) } /** - * Validates a line type if:
- * - it is not null
- * - B is greater/equal to 0 (Phase-to-ground susceptance per length)
- * - G is greater/equal to 0 (Phase-to-ground conductance per length)
- * - R is greater 0 (Phase resistance per length)
- * - X is greater 0 (Phase reactance per length)
- * - iMax is greater 0 (Maximum permissible current)
- * - vRated is greater 0 (Rated voltage) + * Validates a line type if: + * + *
    + *
  • it is not null + *
  • B is greater/equal to 0 (Phase-to-ground susceptance per length) + *
  • G is greater/equal to 0 (Phase-to-ground conductance per length) + *
  • R is greater 0 (Phase resistance per length) + *
  • X is greater 0 (Phase reactance per length) + *
  • iMax is greater 0 (Maximum permissible current) + *
  • vRated is greater 0 (Rated voltage) + *
* * @param lineType Line type to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -150,13 +156,16 @@ protected static List> checkLineType(LineTypeI } /** - * Validates a transformer2W if:
- * - {@link ConnectorValidationUtils#checkTransformer2WType(Transformer2WTypeInput)} confirms a - * valid type properties
- * - its tap position is within bounds
- * - it connects different subnets
- * - it connects different voltage levels
- * - its rated voltages match the voltages at the nodes + * Validates a transformer2W if: + * + *
    + *
  • {@link ConnectorValidationUtils#checkTransformer2WType(Transformer2WTypeInput)} confirms + * a valid type properties + *
  • its tap position is within bounds + *
  • it connects different subnets + *
  • it connects different voltage levels + *
  • its rated voltages match the voltages at the nodes + *
* * @param transformer2W Transformer2W to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -180,19 +189,22 @@ private static List> checkTransformer2W( } /** - * Validates a transformer2W type if:
- * - it is not null
- * - rSc is greater 0 (short circuit resistance)
- * - xSc is greater 0 (short circuit impedance)
- * - gM is greater/equal to 0 (no load conductance)
- * - bM is less/equal to 0 (no load susceptance)
- * - sRated is greater 0 (rated apparent power)
- * - vRatedA is greater 0 (rated voltage at higher voltage terminal)
- * - vRatedB is greater 0 (rated voltage at lower voltage terminal)
- * - dV is between 0% and 100% (voltage magnitude increase per tap position
- * - dPhi is greater/equal to 0 (voltage angle increase per tap position)
- * - neutral tap position is between min and max tap position
- * - minimum tap position is smaller than maximum tap position + * Validates a transformer2W type if: + * + *
    + *
  • it is not null + *
  • rSc is greater 0 (short circuit resistance) + *
  • xSc is greater 0 (short circuit impedance) + *
  • gM is greater/equal to 0 (no load conductance) + *
  • bM is less/equal to 0 (no load susceptance) + *
  • sRated is greater 0 (rated apparent power) + *
  • vRatedA is greater 0 (rated voltage at higher voltage terminal) + *
  • vRatedB is greater 0 (rated voltage at lower voltage terminal) + *
  • dV is between 0% and 100% (voltage magnitude increase per tap position + *
  • dPhi is greater/equal to 0 (voltage angle increase per tap position) + *
  • neutral tap position is between min and max tap position + *
  • minimum tap position is smaller than maximum tap position + *
* * @param transformer2WType Transformer2W type to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -233,13 +245,16 @@ protected static List> checkTransformer2WType( } /** - * Validates a transformer3W if:
- * - {@link ConnectorValidationUtils#checkTransformer3WType(Transformer3WTypeInput)} confirm a - * valid type
- * - its tap position is within bounds
- * - it connects different subnets
- * - it connects different voltage levels
- * - its rated voltages match the voltages at the nodes + * Validates a transformer3W if: + * + *
    + *
  • {@link ConnectorValidationUtils#checkTransformer3WType(Transformer3WTypeInput)} confirm a + * valid type + *
  • its tap position is within bounds + *
  • it connects different subnets + *
  • it connects different voltage levels + *
  • its rated voltages match the voltages at the nodes + *
* * @param transformer3W Transformer3W to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -284,18 +299,21 @@ private static List> checkTransformer3W( } /** - * Validates a transformer3W type if:
- * - it is not null
- * - rScA, rScB, rScC are greater 0 (short circuit resistance in branches A,B,C)
- * - xScA, xScB, xScC are greater 0 (short circuit impedance in branches A,B,C)
- * - gM is greater/equal to 0 (no load conductance)
- * - bM is less/equal to 0 (no load susceptance)
- * - sRatedA, sRatedB, sRatedC are greater 0 (rated apparent power in branches A,B,C)
- * - vRatedA, vRatedB, vRatedC are greater 0 (rated voltage at higher node A,B,C)
- * - dV is between 0% and 100% (voltage magnitude increase per tap position
- * - dPhi is greater/equal to 0 (voltage angle increase per tap position)
- * - neutral tap position is between min and max tap position
- * - minimum tap position is smaller than maximum tap position
+ * Validates a transformer3W type if: + * + *
    + *
  • it is not null + *
  • rScA, rScB, rScC are greater 0 (short circuit resistance in branches A,B,C) + *
  • xScA, xScB, xScC are greater 0 (short circuit impedance in branches A,B,C) + *
  • gM is greater/equal to 0 (no load conductance) + *
  • bM is less/equal to 0 (no load susceptance) + *
  • sRatedA, sRatedB, sRatedC are greater 0 (rated apparent power in branches A,B,C) + *
  • vRatedA, vRatedB, vRatedC are greater 0 (rated voltage at higher node A,B,C) + *
  • dV is between 0% and 100% (voltage magnitude increase per tap position + *
  • dPhi is greater/equal to 0 (voltage angle increase per tap position) + *
  • neutral tap position is between min and max tap position + *
  • minimum tap position is smaller than maximum tap position + *
* * @param transformer3WType Transformer type to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -342,8 +360,11 @@ protected static List> checkTransformer3WType( } /** - * Validates a switch if:
- * - its connected nodes are in the same voltage level + * Validates a switch if: + * + *
    + *
  • its connected nodes are in the same voltage level + *
* * @param switchInput Switch to validate * @return a try object either containing an {@link InvalidEntityException} or an empty Success diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/GraphicValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/GraphicValidationUtils.java index e47eadf61..845be81d2 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/GraphicValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/GraphicValidationUtils.java @@ -21,9 +21,12 @@ private GraphicValidationUtils() { } /** - * Validates a graphic input if:
- * - it is not null
- * - its graphic layer is not null
+ * Validates a graphic input if: + * + *
    + *
  • it is not null + *
  • its graphic layer is not null + *
* *

A "distribution" method, that forwards the check request to specific implementations to * fulfill the checking task, based on the class of the given object. @@ -59,8 +62,11 @@ protected static List> check(GraphicInput grap } /** - * Validates a line graphic input if:
- * - its path is not null + * Validates a line graphic input if: + * + *

    + *
  • its path is not null + *
* * @param lineGraphicInput LineGraphicInput to validate */ @@ -74,9 +80,12 @@ private static Try checkLineGraphicInput( } /** - * Validates a node graphic input if:
- * - its node is not null
- * - its point is not null + * Validates a node graphic input if: + * + *
    + *
  • its node is not null + *
  • its point is not null + *
* * @param nodeGraphicInput NodeGraphicInput to validate */ diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java index 1ef47aeb5..40bf50e49 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/GridContainerValidationUtils.java @@ -5,10 +5,8 @@ */ package edu.ie3.datamodel.utils.validation; -import edu.ie3.datamodel.exceptions.InvalidEntityException; -import edu.ie3.datamodel.exceptions.InvalidGridException; -import edu.ie3.datamodel.exceptions.UnsafeEntityException; -import edu.ie3.datamodel.exceptions.ValidationException; +import edu.ie3.datamodel.exceptions.*; +import edu.ie3.datamodel.models.UniqueEntity; import edu.ie3.datamodel.models.input.AssetInput; import edu.ie3.datamodel.models.input.MeasurementUnitInput; import edu.ie3.datamodel.models.input.NodeInput; @@ -24,14 +22,6 @@ public class GridContainerValidationUtils extends ValidationUtils { - private static String duplicateUuidsString(String simpleName, Optional exceptionString) { - return "The provided entities in '" - + simpleName - + "' contains duplicate UUIDs. " - + "This is not allowed!\nDuplicated uuids:\n\n" - + exceptionString; - } - /** Private Constructor as this class is not meant to be instantiated */ private GridContainerValidationUtils() { throw new IllegalStateException("Don't try and instantiate a Utility class."); @@ -52,18 +42,10 @@ private GridContainerValidationUtils() { return List.of(isNull); } - List> exceptions = new ArrayList<>(); - /* sanity check to ensure distinct UUIDs */ - Optional exceptionString = - checkForDuplicateUuids(new HashSet<>(gridContainer.allEntitiesAsList())); - exceptions.add( - Try.ofVoid( - exceptionString.isPresent(), - () -> - new InvalidGridException( - duplicateUuidsString( - gridContainer.getClass().getSimpleName(), exceptionString)))); + List> exceptions = + new ArrayList<>( + checkForDuplicates(gridContainer.allEntitiesAsList(), UniqueEntity::getUuid)); exceptions.addAll(checkRawGridElements(gridContainer.getRawGrid())); exceptions.addAll( @@ -98,18 +80,10 @@ private GridContainerValidationUtils() { return List.of(isNull); } - List> exceptions = new ArrayList<>(); - /* sanity check to ensure distinct UUIDs */ - Optional exceptionString = - checkForDuplicateUuids(new HashSet<>(rawGridElements.allEntitiesAsList())); - exceptions.add( - Try.ofVoid( - exceptionString.isPresent(), - () -> - new InvalidGridException( - duplicateUuidsString( - rawGridElements.getClass().getSimpleName(), exceptionString)))); + List> exceptions = + new ArrayList<>( + checkForDuplicates(rawGridElements.allEntitiesAsList(), UniqueEntity::getUuid)); /* Checking nodes */ Set nodes = rawGridElements.getNodes(); @@ -143,7 +117,7 @@ private GridContainerValidationUtils() { }); /* Checking switches - * Because of the fact, that a transformer with switch gear in "upstream" direction has it's corresponding node in + * Because of the fact, that a transformer with switch gear in "upstream" direction has its corresponding node in * upper grid connected to a switch, instead of to the transformer directly: Collect all nodes at the end of the * upstream switch chain and add them to the set of allowed nodes */ HashSet validSwitchNodes = new HashSet<>(nodes); @@ -183,18 +157,18 @@ private GridContainerValidationUtils() { * Checks the validity of type ids of every entity. * * @param rawGridElements the raw grid elements - * @return a list of try objects either containing an {@link UnsafeEntityException} or an empty - * Success + * @return a list of try objects either containing an {@link DuplicateEntitiesException} or an + * empty Success */ - protected static List> checkRawGridTypeIds( + protected static List> checkRawGridTypeIds( RawGridElements rawGridElements) { - List> exceptions = new ArrayList<>(); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getNodes())); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getLines())); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getTransformer2Ws())); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getTransformer3Ws())); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getSwitches())); - exceptions.addAll(ValidationUtils.checkIds(rawGridElements.getMeasurementUnits())); + List> exceptions = new ArrayList<>(); + exceptions.addAll(checkForDuplicates(rawGridElements.getNodes(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(rawGridElements.getLines(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(rawGridElements.getTransformer2Ws(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(rawGridElements.getTransformer3Ws(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(rawGridElements.getSwitches(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(rawGridElements.getMeasurementUnits(), AssetInput::getId)); return exceptions; } @@ -217,23 +191,14 @@ protected static List> checkRawGridTypeIds( return List.of(isNull); } - List> exceptions = new ArrayList<>(); - // sanity check for distinct uuids - Optional exceptionString = - ValidationUtils.checkForDuplicateUuids( - new HashSet<>(systemParticipants.allEntitiesAsList())); - exceptions.add( - Try.ofVoid( - exceptionString.isPresent(), - () -> - new InvalidGridException( - duplicateUuidsString( - systemParticipants.getClass().getSimpleName(), exceptionString)))); + List> exceptions = + new ArrayList<>( + checkForDuplicates(systemParticipants.allEntitiesAsList(), UniqueEntity::getUuid)); exceptions.addAll(checkSystemParticipants(systemParticipants.getBmPlants(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getChpPlants(), nodes)); - exceptions.addAll(checkSystemParticipants(systemParticipants.getEvCS(), nodes)); + exceptions.addAll(checkSystemParticipants(systemParticipants.getEvcs(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getFixedFeedIns(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getHeatPumps(), nodes)); exceptions.addAll(checkSystemParticipants(systemParticipants.getLoads(), nodes)); @@ -274,23 +239,22 @@ protected static List> checkRawGridTypeIds( * Checks the validity of type ids of every entity. * * @param systemParticipants the system participants - * @return a list of try objects either containing an {@link UnsafeEntityException} or an empty - * Success + * @return a list of try objects either containing an {@link DuplicateEntitiesException} or an + * empty Success */ - protected static List> checkSystemParticipantsTypeIds( + protected static List> checkSystemParticipantsTypeIds( SystemParticipants systemParticipants) { - List> exceptions = new ArrayList<>(); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getBmPlants())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getChpPlants())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getEvCS())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getEvs())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getFixedFeedIns())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getHeatPumps())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getLoads())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getPvPlants())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getStorages())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getWecPlants())); - exceptions.addAll(ValidationUtils.checkIds(systemParticipants.getEmSystems())); + List> exceptions = new ArrayList<>(); + exceptions.addAll(checkForDuplicates(systemParticipants.getBmPlants(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getChpPlants(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getEvcs(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getEvs(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getFixedFeedIns(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getHeatPumps(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getLoads(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getPvPlants(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getStorages(), AssetInput::getId)); + exceptions.addAll(checkForDuplicates(systemParticipants.getWecPlants(), AssetInput::getId)); return exceptions; } @@ -312,18 +276,10 @@ protected static List> checkSystemParticipantsT return List.of(isNull); } - List> exceptions = new ArrayList<>(); - // sanity check for distinct uuids - Optional exceptionString = - checkForDuplicateUuids(new HashSet<>(graphicElements.allEntitiesAsList())); - exceptions.add( - Try.ofVoid( - exceptionString.isPresent(), - () -> - new InvalidGridException( - duplicateUuidsString( - graphicElements.getClass().getSimpleName(), exceptionString)))); + List> exceptions = + new ArrayList<>( + checkForDuplicates(graphicElements.allEntitiesAsList(), UniqueEntity::getUuid)); graphicElements .getNodeGraphics() diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/MeasurementUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/MeasurementUnitValidationUtils.java index 318cfd13f..dd51e33a7 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/MeasurementUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/MeasurementUnitValidationUtils.java @@ -19,9 +19,12 @@ private MeasurementUnitValidationUtils() { } /** - * Validates a measurement unit if:
- * - it is not null
- * - any values are measured + * Validates a measurement unit if: + * + *
    + *
  • it is not null + *
  • any values are measured + *
* * @param measurementUnit Measurement unit to validate * @return a try object either containing an {@link ValidationException} or an empty Success diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/NodeValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/NodeValidationUtils.java index 37f948c95..98a78bc9b 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/NodeValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/NodeValidationUtils.java @@ -24,12 +24,15 @@ private NodeValidationUtils() { } /** - * Validates a node if:
- * - it is not null
- * - voltage level is not null and valid
- * - target voltage is larger than zero and smaller than two
- * - subnet number is larger than zero
- * - geoPosition is not null + * Validates a node if: + * + *
    + *
  • it is not null + *
  • voltage level is not null and valid + *
  • target voltage is larger than zero and smaller than two + *
  • subnet number is larger than zero + *
  • geoPosition is not null + *
* * @param node Node to validate * @return a list of try objects either containing an {@link ValidationException} or an empty diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtils.java index b2e0bc896..04c969c34 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtils.java @@ -8,7 +8,6 @@ import static edu.ie3.datamodel.models.StandardUnits.*; import edu.ie3.datamodel.exceptions.InvalidEntityException; -import edu.ie3.datamodel.exceptions.NotImplementedException; import edu.ie3.datamodel.exceptions.TryException; import edu.ie3.datamodel.models.input.InputEntity; import edu.ie3.datamodel.models.input.system.*; @@ -31,9 +30,12 @@ private SystemParticipantValidationUtils() { } /** - * Validates a system participant if:
- * - it is not null
- * - its qCharacteristics are not null + * Validates a system participant if: + * + *
    + *
  • it is not null + *
  • its qCharacteristics are not null + *
* *

A "distribution" method, that forwards the check request to specific implementations to * fulfill the checking task, based on the class of the given object. @@ -81,26 +83,24 @@ protected static List> check( } else if (WecInput.class.isAssignableFrom(systemParticipant.getClass())) { exceptions.addAll(checkWec((WecInput) systemParticipant)); } else if (EvcsInput.class.isAssignableFrom(systemParticipant.getClass())) { - exceptions.add( - Try.ofVoid(SystemParticipantValidationUtils::checkEvcs, NotImplementedException.class) - .transformF(e -> new InvalidEntityException(e.getMessage(), e.getCause()))); + exceptions.addAll(checkEvcs((EvcsInput) systemParticipant)); } else { - exceptions.add( - new Failure<>( - new InvalidEntityException( - "Validation failed due to: ", buildNotImplementedException(systemParticipant)))); + logNotImplemented(systemParticipant); } return exceptions; } /** - * Validates a system participant type if:
- * - it is not null
- * - capex is not null and not negative
- * - opex is not null and not negative
- * - sRated is not null and not negative
- * - cosphiRated is between zero and one + * Validates a system participant type if: + * + *

    + *
  • it is not null + *
  • capex is not null and not negative + *
  • opex is not null and not negative + *
  • sRated is not null and not negative + *
  • cosphiRated is between zero and one + *
* *

A "distribution" method, that forwards the check request to specific implementations to * fulfill the checking task, based on the class of the given object. @@ -167,11 +167,7 @@ protected static List> checkType( } else if (WecTypeInput.class.isAssignableFrom(systemParticipantTypeInput.getClass())) { exceptions.addAll(checkWecType((WecTypeInput) systemParticipantTypeInput)); } else { - exceptions.add( - new Failure<>( - new InvalidEntityException( - buildNotImplementedException(systemParticipantTypeInput).getMessage(), - systemParticipantTypeInput))); + logNotImplemented(systemParticipantTypeInput); } return exceptions; @@ -179,8 +175,11 @@ protected static List> checkType( /** * Validates a bmInput if:
- * - {@link SystemParticipantValidationUtils#checkBmType(BmTypeInput)} confirms a valid type - * properties
+ * + *

    + *
  • {@link SystemParticipantValidationUtils#checkBmType(BmTypeInput)} confirms a valid type + * properties + *
* * @param bmInput BmInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -191,9 +190,12 @@ private static List> checkBm(BmInput bmInput) } /** - * Validates a bmTypeInput if:
- * - its active power gradient is not negative
- * - its efficiency of assets inverter is between 0% and 100% + * Validates a bmTypeInput if: + * + *
    + *
  • its active power gradient is not negative# + *
  • its efficiency of assets inverter is between 0% and 100% + *
* * @param bmTypeInput BmTypeInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -211,9 +213,12 @@ private static List> checkBmType(BmTypeInput b } /** - * Validates a chpInput if:
- * - {@link SystemParticipantValidationUtils#checkChpType(ChpTypeInput)} confirms a valid type - * properties + * Validates a chpInput if: + * + *
    + *
  • {@link SystemParticipantValidationUtils#checkChpType(ChpTypeInput)} confirms a valid type + * properties + *
* * @param chpInput ChpInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -224,11 +229,14 @@ private static List> checkChp(ChpInput chpInpu } /** - * Validates a chpTypeInput if:
- * - its efficiency of the electrical inverter is between 0% and 100%
- * - its thermal efficiency of the system is between 0% and 100%
- * - its rated thermal power is positive
- * - its needed self-consumption is not negative + * Validates a chpTypeInput if: + * + *
    + *
  • its efficiency of the electrical inverter is between 0% and 100% + *
  • its thermal efficiency of the system is between 0% and 100% + *
  • its rated thermal power is positive + *
  • its needed self-consumption is not negative + *
* * @param chpTypeInput ChpTypeInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -250,9 +258,12 @@ private static List> checkChpType(ChpTypeInput } /** - * Validates a EvInput if:
- * - {@link SystemParticipantValidationUtils#checkEvType(EvTypeInput)} confirms a valid type - * properties + * Validates a EvInput if: + * + *
    + *
  • {@link SystemParticipantValidationUtils#checkEvType(EvTypeInput)} confirms a valid type + * properties + *
* * @param evInput EvInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -263,9 +274,12 @@ private static List> checkEv(EvInput evInput) } /** - * Validates a EvTypeInput if:
- * - its available battery capacity is positive
- * - its energy consumption per driven kilometre is positive + * Validates a EvTypeInput if: + * + *
    + *
  • its available battery capacity is positive + *
  • its energy consumption per driven kilometre is positive + *
* * @param evTypeInput EvTypeInput to validate * @return a try object either containing an {@link InvalidEntityException} or an empty Success @@ -279,9 +293,12 @@ private static Try checkEvType(EvTypeInput evTypeI } /** - * Validates a FixedFeedInInput if:
- * - its rated apparent power is not negative
- * - its rated power factor is between 0 and 1 + * Validates a FixedFeedInInput if: + * + *
    + *
  • its rated apparent power is not negative + *
  • its rated power factor is between 0 and 1 + *
* * @param fixedFeedInInput FixedFeedInInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -298,9 +315,12 @@ private static List> checkFixedFeedIn( } /** - * Validates a HpInput if:
- * - {@link SystemParticipantValidationUtils#checkHpType(HpTypeInput)} confirms a valid type - * properties + * Validates a HpInput if: + * + *
    + *
  • {@link SystemParticipantValidationUtils#checkHpType(HpTypeInput)} confirms a valid type + * properties + *
* * @param hpInput HpInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -311,8 +331,11 @@ private static List> checkHp(HpInput hpInput) } /** - * Validates a HpTypeInput if:
- * - its rated thermal power is positive + * Validates a HpTypeInput if: + * + *
    + *
  • its rated thermal power is positive + *
* * @param hpTypeInput HpTypeInput to validate * @return a try object either containing an {@link InvalidEntityException} or an empty Success @@ -326,11 +349,14 @@ private static Try checkHpType(HpTypeInput hpTypeI } /** - * Validates a LoadInput if:
- * - its standard load profile is not null
- * - its rated apparent power is not negative
- * - its annual energy consumption is not negative
- * - its rated power factor is between 0 and 1 + * Validates a LoadInput if: + * + *
    + *
  • its standard load profile is not null + *
  • its rated apparent power is not negative + *
  • its annual energy consumption is not negative + *
  • its rated power factor is between 0 and 1 + *
* * @param loadInput LoadInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -359,13 +385,16 @@ private static List> checkLoad(LoadInput loadI } /** - * Validates a PvInput if:
- * - its rated apparent power is not negative
- * - its albedo value of the plant's surrounding is between 0 and 1
- * - its inclination in a compass direction (azimuth) is between -90° and 90°
- * - its efficiency of the asset's inverter (etaConv) is between 0% and 100%
- * - its tilted inclination from horizontal (elevation angle) is between 0° and 90°
- * - its rated power factor is between 0 and 1 + * Validates a PvInput if: + * + *
    + *
  • its rated apparent power is not negative + *
  • its albedo value of the plant's surrounding is between 0 and 1 + *
  • its inclination in a compass direction (azimuth) is between -90° and 90° + *
  • its efficiency of the asset's inverter (etaConv) is between 0% and 100% + *
  • its tilted inclination from horizontal (elevation angle) is between 0° and 90° + *
  • its rated power factor is between 0 and 1 + *
* * @param pvInput PvInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -431,9 +460,12 @@ private static void checkElevationAngle(PvInput pvInput) throws InvalidEntityExc } /** - * Validates a StorageInput if:
- * - {@link SystemParticipantValidationUtils#checkStorageType(StorageTypeInput)} confirms a valid - * type properties + * Validates a StorageInput if: + * + *
    + *
  • {@link SystemParticipantValidationUtils#checkStorageType(StorageTypeInput)} confirms a + * valid type properties + *
* * @param storageInput StorageInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -444,14 +476,17 @@ private static List> checkStorage(StorageInput } /** - * Validates a StorageTypeInput if:
- * - its permissible amount of full cycles is not negative
- * - its efficiency of the electrical converter is between 0% and 100%
- * - its maximum permissible depth of discharge is between 0% and 100%
- * - its active power gradient is not negative
- * - its battery capacity is positive
- * - its maximum permissible active power (in-feed or consumption) is not negative
- * - its permissible hours of full use is not negative + * Validates a StorageTypeInput if: + * + *
    + *
  • its permissible amount of full cycles is not negative + *
  • its efficiency of the electrical converter is between 0% and 100% + *
  • its maximum permissible depth of discharge is between 0% and 100% + *
  • its active power gradient is not negative + *
  • its battery capacity is positive + *
  • its maximum permissible active power (in-feed or consumption) is not negative + *
  • its permissible hours of full use is not negative + *
* * @param storageTypeInput StorageTypeInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -498,9 +533,12 @@ private static List> checkStorageType( } /** - * Validates a WecInput if:
- * - {@link SystemParticipantValidationUtils#checkWecType(WecTypeInput)} confirms a valid type - * properties + * Validates a WecInput if: + * + *
    + *
  • {@link SystemParticipantValidationUtils#checkWecType(WecTypeInput)} confirms a valid type + * properties + *
* * @param wecInput WecInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -511,10 +549,13 @@ private static List> checkWec(WecInput wecInpu } /** - * Validates a WecTypeInput if:
- * - its efficiency of the assets converter is between 0% and 100%
- * - its rotor area is not negative
- * - its height of the rotor hub is not negative + * Validates a WecTypeInput if: + * + *
    + *
  • its efficiency of the assets converter is between 0% and 100% + *
  • its rotor area is not negative + *
  • its height of the rotor hub is not negative + *
* * @param wecTypeInput WecTypeInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -532,11 +573,36 @@ private static List> checkWecType(WecTypeInput wecTypeInput)); } - /** Validates a EvcsInput */ - private static void checkEvcs() { - throw new NotImplementedException( - String.format( - "Validation of '%s' is currently not supported.", EvcsInput.class.getSimpleName())); + /** + * Validates a EvcsInput if: + * + *
    + *
  • its number of charging points is < 1 + *
  • its rated power factor is between 0 and 1 + *
  • its rated apparent power is not negative + *
+ * + * @param evcsInput EvcsInput to validate + * @return a list of try objects either containing an {@link InvalidEntityException} or an empty + * Success + */ + private static List> checkEvcs(EvcsInput evcsInput) { + Try.VoidSupplier chargingPointValidation = + () -> { + if (evcsInput.getChargingPoints() < 1) + throw new InvalidEntityException( + "Invalid number of charging points: '" + + evcsInput.getChargingPoints() + + "'. At least one charging point is needed.", + evcsInput); + }; + + return Try.ofVoid( + InvalidEntityException.class, + chargingPointValidation, + () -> checkRatedPowerFactor(evcsInput, evcsInput.getCosPhiRated()), + () -> + detectNegativeQuantities(new Quantity[] {evcsInput.getType().getsRated()}, evcsInput)); } /** diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java index 8dd2b39f0..704567699 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ThermalUnitValidationUtils.java @@ -5,7 +5,6 @@ */ package edu.ie3.datamodel.utils.validation; -import edu.ie3.datamodel.exceptions.FailedValidationException; import edu.ie3.datamodel.exceptions.InvalidEntityException; import edu.ie3.datamodel.exceptions.ValidationException; import edu.ie3.datamodel.models.input.thermal.*; @@ -23,8 +22,12 @@ private ThermalUnitValidationUtils() { } /** - * Validates a thermal unit if:
- * - it is not null
+ * Validates a thermal unit if: + * + *
    + *
  • it is not null + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -48,18 +51,19 @@ private ThermalUnitValidationUtils() { } else if (ThermalStorageInput.class.isAssignableFrom(thermalUnitInput.getClass())) { exceptions.addAll(checkThermalStorage((ThermalStorageInput) thermalUnitInput)); } else { - exceptions.add( - new Failure<>( - new FailedValidationException( - buildNotImplementedException(thermalUnitInput).getMessage()))); + logNotImplemented(thermalUnitInput); } return exceptions; } /** - * Validates a thermalSinkInput if:
- * - it is not null
+ * Validates a thermalSinkInput if: + * + *
    + *
  • it is not null + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -81,18 +85,19 @@ private ThermalUnitValidationUtils() { if (ThermalHouseInput.class.isAssignableFrom(thermalSinkInput.getClass())) { exceptions.addAll(checkThermalHouse((ThermalHouseInput) thermalSinkInput)); } else { - exceptions.add( - new Failure<>( - new FailedValidationException( - buildNotImplementedException(thermalSinkInput).getMessage()))); + logNotImplemented(thermalSinkInput); } return exceptions; } /** - * Validates a thermalStorageInput if:
- * - it is not null
+ * Validates a thermalStorageInput if: + * + *
    + *
  • it is not null + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -115,22 +120,22 @@ private ThermalUnitValidationUtils() { if (CylindricalStorageInput.class.isAssignableFrom(thermalStorageInput.getClass())) { exceptions.addAll(checkCylindricalStorage((CylindricalStorageInput) thermalStorageInput)); } else { - exceptions.add( - new Failure<>( - new FailedValidationException( - buildNotImplementedException(thermalStorageInput).getMessage()))); + logNotImplemented(thermalStorageInput); } return exceptions; } /** - * Validates a thermalHouseInput if:
- * - it is not null
- * - its thermal losses are not negative
- * - its thermal capacity is positive
- * - its upper temperature limit is higher than the lower temperature limit
- * - its target temperature lies between the upper und lower limit temperatures + * Validates a thermalHouseInput if: + * + *
    + *
  • it is not null + *
  • its thermal losses are not negative + *
  • its thermal capacity is positive + *
  • its upper temperature limit is higher than the lower temperature limit + *
  • its target temperature lies between the upper und lower limit temperatures + *
* * @param thermalHouseInput ThermalHouseInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty @@ -172,13 +177,16 @@ private static List> checkThermalHouse( } /** - * Validates a cylindricalStorageInput if:
- * - it is not null
- * - its available storage volume is positive
- * - its minimum permissible storage volume is positive and not greater than the available storage - * volume
- * - its inlet temperature is equal/greater than the outlet temperature
- * - its specific heat capacity is positive + * Validates a cylindricalStorageInput if: + * + *
    + *
  • it is not null + *
  • its available storage volume is positive + *
  • its minimum permissible storage volume is positive and not greater than the available + * storage volume + *
  • its inlet temperature is equal/greater than the outlet temperature + *
  • its specific heat capacity is positive + *
* * @param cylindricalStorageInput CylindricalStorageInput to validate * @return a list of try objects either containing an {@link InvalidEntityException} or an empty diff --git a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java index c09607a0d..23f9d078e 100644 --- a/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java +++ b/src/main/java/edu/ie3/datamodel/utils/validation/ValidationUtils.java @@ -41,17 +41,14 @@ protected ValidationUtils() { } /** - * Creates a new {@link NotImplementedException}, if there is no check available for the class of - * the given object + * Logs a warning, if there is no check available for the class of the given object. * - * @param obj Object, that cannot be checked - * @return Exception with predefined error string + * @param obj object, that cannot be checked */ - protected static NotImplementedException buildNotImplementedException(Object obj) { - return new NotImplementedException( - String.format( - "Cannot validate object of class '%s', as no routine is implemented.", - obj.getClass().getSimpleName())); + protected static void logNotImplemented(Object obj) { + logger.warn( + "Cannot validate object of class '{}', as no routine is implemented.", + obj.getClass().getSimpleName()); } /** @@ -74,9 +71,7 @@ public static void check(Object obj) throws ValidationException { } else if (AssetTypeInput.class.isAssignableFrom(obj.getClass())) { exceptions.addAll(checkAssetType((AssetTypeInput) obj)); } else { - exceptions.add( - new Failure<>( - new FailedValidationException(buildNotImplementedException(obj).getMessage()))); + logNotImplemented(obj); } List list = @@ -89,11 +84,15 @@ public static void check(Object obj) throws ValidationException { } /** - * Validates an asset if:
- * - it is not null
- * - its id is not null
- * - its operation time is not null
- * - in case operation time is limited, start time is before end time
+ * Validates an asset if: + * + *
    + *
  • it is not null + *
  • its id is not null + *
  • its operation time is not null + *
  • in case operation time is limited, start time is before end time + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -156,18 +155,19 @@ else if (SystemParticipantInput.class.isAssignableFrom(assetInput.getClass())) else if (ThermalUnitInput.class.isAssignableFrom(assetInput.getClass())) exceptions.addAll(ThermalUnitValidationUtils.check((ThermalUnitInput) assetInput)); else { - exceptions.add( - new Failure<>( - new FailedValidationException( - buildNotImplementedException(assetInput).getMessage()))); + logNotImplemented(assetInput); } return exceptions; } /** - * Validates an asset type if:
- * - it is not null
+ * Validates an asset type if: + * + *
    + *
  • it is not null + *
+ * * A "distribution" method, that forwards the check request to specific implementations to fulfill * the checking task, based on the class of the given object. * @@ -207,43 +207,12 @@ else if (SystemParticipantTypeInput.class.isAssignableFrom(assetTypeInput.getCla exceptions.addAll( SystemParticipantValidationUtils.checkType((SystemParticipantTypeInput) assetTypeInput)); else { - exceptions.add( - new Failure<>( - new FailedValidationException( - buildNotImplementedException(assetTypeInput).getMessage()))); + logNotImplemented(assetTypeInput); } return exceptions; } - /** - * Checks the validity of the ids for a given set of {@link AssetInput}. - * - * @param inputs a set of asset inputs - * @return a list of try objects either containing an {@link UnsafeEntityException} or an empty - * Success - */ - protected static List> checkIds( - Set inputs) { - List ids = new ArrayList<>(); - List> exceptions = new ArrayList<>(); - - inputs.forEach( - input -> { - String id = input.getId(); - if (!ids.contains(id)) { - ids.add(id); - } else { - exceptions.add( - new Failure<>( - new UnsafeEntityException( - "There is already an entity with the id " + id, input))); - } - }); - - return exceptions; - } - /** * Checks, if the given object is null. If so, an {@link InvalidEntityException} wrapped in a * {@link Failure} is returned. @@ -327,20 +296,6 @@ protected static void detectMalformedQuantities( } } - /** - * Determines if the provided set only contains elements with distinct UUIDs - * - * @param entities the set that should be checked - * @return true if all UUIDs of the provided entities are unique, false otherwise - */ - private static boolean distinctUuids(Set entities) { - return entities.stream() - .filter(distinctByKey(UniqueEntity::getUuid)) - .collect(Collectors.toSet()) - .size() - == entities.size(); - } - /** * Predicate that can be used to filter elements based on a given Function * @@ -354,38 +309,38 @@ public static Predicate distinctByKey(Function keyExtractor } /** - * Checks if the provided set of unique entities only contains elements with distinct UUIDs and - * either returns a string with duplicated UUIDs or an empty optional otherwise. + * Method to check for duplicate fields in a set of {@link UniqueEntity}. * - * @param entities the entities that should be checkd for UUID uniqueness - * @return either a string wrapped in an optional with duplicate UUIDs or an empty optional + * @param entities to be checked + * @param supplier for the field + * @return a list of {@link Try}. + * @param type of the {@link UniqueEntity} + * @param type of the field */ - protected static Optional checkForDuplicateUuids(Set entities) { - if (distinctUuids(entities)) { - return Optional.empty(); - } - String duplicationsString = - entities.stream() - .collect(Collectors.groupingBy(UniqueEntity::getUuid, Collectors.counting())) - .entrySet() - .stream() - .filter(entry -> entry.getValue() > 1) - .map( - entry -> { - String duplicateEntitiesString = - entities.stream() - .filter(entity -> entity.getUuid().equals(entry.getKey())) - .map(UniqueEntity::toString) - .collect(Collectors.joining("\n - ")); - - return entry.getKey() - + ": " - + entry.getValue() - + "\n - " - + duplicateEntitiesString; - }) - .collect(Collectors.joining("\n\n")); + protected static + List> checkForDuplicates( + Collection entities, FieldSupplier supplier) { + Map> duplicates = + entities.stream().collect(Collectors.groupingBy(supplier::getField)); + + return duplicates.entrySet().stream() + .filter(e -> e.getValue().size() > 1) + .map( + duplicate -> + Failure.ofVoid( + new DuplicateEntitiesException( + duplicate.getKey().getClass().getSimpleName(), duplicate.getValue()))) + .collect(Collectors.toList()); + } - return Optional.of(duplicationsString); + /** + * Supplier for unique entity fields that returns a field of type F given an entity of type E. + * + * @param type of unique entity + * @param type of field + */ + @FunctionalInterface + protected interface FieldSupplier { + F getField(E entity); } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/connectors/CsvFileConnectorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/connectors/CsvFileConnectorTest.groovy index 3b8eede71..4898da785 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/connectors/CsvFileConnectorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/connectors/CsvFileConnectorTest.groovy @@ -6,11 +6,11 @@ package edu.ie3.datamodel.io.connectors import edu.ie3.datamodel.exceptions.ConnectorException -import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation -import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.csv.CsvFileDefinition +import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation import edu.ie3.datamodel.io.naming.DefaultDirectoryHierarchy import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy +import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.NodeInput @@ -32,6 +32,9 @@ class CsvFileConnectorTest extends Specification { @Shared Path tmpDirectory + @Shared + FileNamingStrategy fileNamingStrategy + @Shared CsvFileConnector cfc @@ -43,7 +46,8 @@ class CsvFileConnectorTest extends Specification { def setupSpec() { tmpDirectory = Files.createTempDirectory("psdm_csv_file_connector_") - cfc = new CsvFileConnector(tmpDirectory, new FileNamingStrategy()) + fileNamingStrategy = new FileNamingStrategy() + cfc = new CsvFileConnector(tmpDirectory, fileNamingStrategy) def gridPaths = [Path.of("node_input.csv")] timeSeriesPaths = [ "its_pq_53990eea-1b5d-47e8-9134-6d8de36604bf.csv", @@ -110,11 +114,8 @@ class CsvFileConnectorTest extends Specification { } def "The csv file connector throws an Exception, if the foreseen file cannot be found"() { - given: - def cfc = new CsvFileConnector(tmpDirectory, new FileNamingStrategy(new EntityPersistenceNamingStrategy(), new DefaultDirectoryHierarchy(tmpDirectory, "test"))) - when: - cfc.initReader(NodeInput) + cfc.initReader(tmpDirectory.resolve("path-does-not-exist")) then: thrown(FileNotFoundException) @@ -122,7 +123,8 @@ class CsvFileConnectorTest extends Specification { def "The csv file connector initializes a reader without Exception, if the foreseen file is apparent"() { when: - cfc.initReader(NodeInput) + def filePath = fileNamingStrategy.getFilePath(NodeInput).orElseThrow() + cfc.initReader(filePath) then: noExceptionThrown() diff --git a/src/test/groovy/edu/ie3/datamodel/io/csv/BufferedCsvWriterTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/csv/BufferedCsvWriterTest.groovy index bf5239b83..a5d799849 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/csv/BufferedCsvWriterTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/csv/BufferedCsvWriterTest.groovy @@ -23,9 +23,12 @@ class BufferedCsvWriterTest extends Specification { } def cleanupSpec() { - FileIOUtils.deleteRecursively(tmpDirectory) + try { + FileIOUtils.deleteRecursively(tmpDirectory) + } catch (IOException e) { + throw new FileException("Unable to delete recursively.", e) + } } - def "The convenience constructor of the BufferedCsvWriter class works as expected."() { given: def baseDirectory = tmpDirectory diff --git a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy index 9db59b4e9..c380d2418 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/extractor/ExtractorTest.groovy @@ -7,7 +7,6 @@ package edu.ie3.datamodel.io.extractor import edu.ie3.datamodel.exceptions.ExtractorException import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput import edu.ie3.datamodel.models.input.system.FixedFeedInInput import edu.ie3.test.common.GridTestData as gtd import edu.ie3.test.common.SystemParticipantTestData as sptd @@ -146,7 +145,7 @@ class ExtractorTest extends Specification { given: def sampleFixedFeedInput = new FixedFeedInInput(UUID.fromString("717af017-cc69-406f-b452-e022d7fb516a"), "test_fixedFeedInInput", OperatorInput.NO_OPERATOR_ASSIGNED, - sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, + sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.em.orElse(null), sptd.fixedFeedInInput.sRated,sptd.fixedFeedInInput.cosPhiRated) expect: Extractor.extractElements(sampleFixedFeedInput) as Set == [ diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/FactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/FactoryTest.groovy new file mode 100644 index 000000000..33f657aed --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/FactoryTest.groovy @@ -0,0 +1,101 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.factory + +import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.utils.Try +import spock.lang.Shared +import spock.lang.Specification + +class FactoryTest extends Specification { + @Shared + private final DummyFactory factory = new DummyFactory(String) + + + def "A Factory can return unused fields correctly"() { + when: + def unused = factory.getUnusedFields(actualFields as Set, validFieldSets) + + then: + unused == expected as Set + + where: + actualFields | validFieldSets | expected + [ + "uuid", + "id", + "time", + "value_1" + ] | [ + ["uuid", "value_1"] as Set, + ["id", "time", "value_1"] as Set + ] | ["uuid"] + [ + "uuid", + "id", + "time", + "value_1", + "value_2", + "value_3" + ] | [ + ["uuid", "value_1", "value_3"] as Set, + ["id", "time", "value_1"] as Set + ] | ["id", "time", "value_2"] + [ + "uuid", + "id", + "time", + "value_1" + ] | [ + [ + "uuid", + "id", + "time", + "value_1", + "value_2" + ] as Set, + [ + "uuid", + "id", + "time", + "value_1", + "value_3" + ] as Set + ] | [] + } + + def "A Factory should allow additional fields"() { + given: + def actualFields = DummyFactory.newSet("uuid", "id", "time", "value_1", "value_2", "value_3") + + when: + def result = Try.ofVoid(() -> factory.validate(actualFields, String), FactoryException) + + then: + result.success + } + + + private class DummyFactory extends Factory { + + protected DummyFactory(Class... supportedClasses) { + super(supportedClasses) + } + + @Override + protected String buildModel(SimpleFactoryData data) { + return null + } + + @Override + protected List> getFields(Class entityClass) { + return [ + ["uuid", "value1", "value3"] as Set, + ["id", "time", "value1"] as Set + ] + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactoryTest.groovy index 424ad10ec..b460b909a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/AssetInputEntityFactoryTest.groovy @@ -274,31 +274,22 @@ class AssetInputEntityFactoryTest extends Specification implements FactoryTestHe } } - def "An AssetInputFactory should throw an exception on invalid or incomplete data "() { - given: "a system participant input type factory and model data" + def "An AssetInputFactory should throw an exception on invalid or incomplete fields"() { + given: def inputFactory = new TestAssetInputFactory() - Map parameter = [ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", - "operatesuntil": "2019-12-31T00:00:00+01:00[Europe/Berlin]" - ] - def inputClass = TestAssetInput + def actualFields = TestAssetInputFactory.newSet("uuid", "operates_from", "operates_until") when: - Try input = inputFactory.get(new AssetInputEntityData(parameter, inputClass)) + Try input = inputFactory.validate(actualFields, TestAssetInput) then: input.failure - input.exception.get().cause.message == - "The provided fields [operatesfrom, operatesuntil, uuid] with data \n" + - "{operatesfrom -> 2019-01-01T00:00:00+01:00[Europe/Berlin],\n" + - "operatesuntil -> 2019-12-31T00:00:00+01:00[Europe/Berlin],\n" + - "uuid -> 91ec3bcf-1777-4d38-af67-0bf7c9fa73c7} are invalid for instance of TestAssetInput. \n" + + input.exception.get().message == "The provided fields [operates_from, operates_until, uuid] are invalid for instance of 'TestAssetInput'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'TestAssetInput' are possible (NOT case-sensitive!):\n" + - "0: [id, uuid]\n" + - "1: [id, operatesfrom, uuid]\n" + - "2: [id, operatesuntil, uuid]\n" + - "3: [id, operatesfrom, operatesuntil, uuid]\n" + "0: [id, uuid] or [id, uuid]\n" + + "1: [id, operatesFrom, uuid] or [id, operates_from, uuid]\n" + + "2: [id, operatesUntil, uuid] or [id, operates_until, uuid]\n" + + "3: [id, operatesFrom, operatesUntil, uuid] or [id, operates_from, operates_until, uuid]\n" } private static class TestAssetInput extends AssetInput { diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/LineInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/LineInputFactoryTest.groovy index 067353976..8a0ed78b6 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/LineInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/LineInputFactoryTest.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.datamodel.io.factory.input +import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.NodeInput @@ -19,12 +22,9 @@ import org.locationtech.jts.geom.LineString import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import java.time.ZonedDateTime import javax.measure.quantity.Dimensionless import javax.measure.quantity.Speed -import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND -import static edu.ie3.util.quantities.PowerSystemUnits.PU class LineInputFactoryTest extends Specification implements FactoryTestHelper { def "A LineInputFactory should contain exactly the expected class for parsing"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/NodeInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/NodeInputFactoryTest.groovy index f9f28cafe..8fba840d1 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/NodeInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/NodeInputFactoryTest.groovy @@ -15,8 +15,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.ComparableQuantity -import javax.measure.quantity.ElectricPotential import java.time.ZonedDateTime +import javax.measure.quantity.ElectricPotential class NodeInputFactoryTest extends Specification implements FactoryTestHelper { def "A NodeInputFactory should contain exactly the expected class for parsing"() { diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/OperatorInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/OperatorInputFactoryTest.groovy index 9a85edab5..b4b07b8d2 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/OperatorInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/OperatorInputFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.input import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.utils.Try import spock.lang.Specification @@ -33,7 +33,7 @@ class OperatorInputFactoryTest extends Specification { def inputClass = OperatorInput when: - Try input = inputFactory.get(new SimpleEntityData(parameter, inputClass)) + Try input = inputFactory.get(new EntityData(parameter, inputClass)) then: input.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/SwitchInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/SwitchInputFactoryTest.groovy index 9c862e663..48d087a6a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/SwitchInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/SwitchInputFactoryTest.groovy @@ -58,4 +58,38 @@ class SwitchInputFactoryTest extends Specification implements FactoryTestHelper assert closed } } + + def "A SwitchInputFactory should parse a valid SwitchInput with parallelDevices parameter correctly"() { + given: "a system participant input type factory and model data" + def inputFactory = new SwitchInputFactory() + Map parameter = [ + "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", + "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", + "operatesuntil": "", + "id" : "TestID", + "closed" : "true", + "paralleldevices": "2" + ] + def inputClass = SwitchInput + def operatorInput = Mock(OperatorInput) + def nodeInputA = Mock(NodeInput) + def nodeInputB = Mock(NodeInput) + + expect: + Try input = inputFactory.get(new ConnectorInputEntityData(parameter, inputClass, operatorInput, nodeInputA, nodeInputB)) + input.success + input.data.get().getClass() == inputClass + input.data.get().with { + assert uuid == UUID.fromString(parameter["uuid"]) + assert operationTime.startDate.present + assert operationTime.startDate.get() == ZonedDateTime.parse(parameter["operatesfrom"]) + assert !operationTime.endDate.present + assert operator == operatorInput + assert id == parameter["id"] + assert nodeA == nodeInputA + assert nodeB == nodeInputB + assert closed + assert parallelDevices == 1 + } + } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactoryTest.groovy index 1c12b1e27..99bd62bd3 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer2WInputFactoryTest.groovy @@ -6,14 +6,13 @@ package edu.ie3.datamodel.io.factory.input import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.connector.Transformer2WInput import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput import edu.ie3.datamodel.utils.Try +import edu.ie3.test.common.GridTestData import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification -import edu.ie3.test.common.GridTestData import java.time.ZonedDateTime @@ -85,10 +84,12 @@ class Transformer2WInputFactoryTest extends Specification implements FactoryTest def typeInput = Mock(Transformer2WTypeInput) when: - inputFactory.get(new TypedConnectorInputEntityData(parameter, inputClass, operatorInput, nodeInputA, nodeInputB, typeInput)) + Try input = inputFactory.get(new TypedConnectorInputEntityData(parameter, inputClass, operatorInput, nodeInputA, nodeInputB, typeInput)) then: - def e = thrown(IllegalArgumentException) - e.message == "nodeA must be on the higher voltage side of the transformer" + input.failure + def e = input.exception.get() + e.cause.class == IllegalArgumentException + e.cause.message == "nodeA must be on the higher voltage side of the transformer" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactoryTest.groovy index f518207c2..6ea95414d 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/Transformer3WInputFactoryTest.groovy @@ -9,6 +9,7 @@ import edu.ie3.datamodel.exceptions.FactoryException import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.connector.Transformer2WInput import edu.ie3.datamodel.models.input.connector.Transformer3WInput import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput import edu.ie3.datamodel.utils.Try @@ -79,11 +80,12 @@ class Transformer3WInputFactoryTest extends Specification implements FactoryTes def typeInput = Mock(Transformer3WTypeInput) when: - inputFactory.get(new Transformer3WInputEntityData(parameter, inputClass, nodeInputA, nodeInputB, nodeInputC, typeInput)) + Try input = inputFactory.get(new Transformer3WInputEntityData(parameter, inputClass, nodeInputA, nodeInputB, nodeInputC, typeInput)) then: - def e = thrown(IllegalArgumentException) - e.message == "Voltage level of node a must be greater than voltage level of node b and voltage level of node b must be greater than voltage level of node c" + input.failure + def e = input.exception.get() + e.cause.class == IllegalArgumentException + e.cause.message == "Voltage level of node a must be greater than voltage level of node b and voltage level of node b must be greater than voltage level of node c" } } - diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/BmInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/BmInputFactoryTest.groovy index 04d9e40b7..bd9e10266 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/BmInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/BmInputFactoryTest.groovy @@ -5,8 +5,11 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.BmInput @@ -17,10 +20,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class BmInputFactoryTest extends Specification implements FactoryTestHelper { def "A BmInputFactory should contain exactly the expected class for parsing"() { @@ -48,11 +49,12 @@ class BmInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = BmInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(BmTypeInput) when: Try input = inputFactory.get( - new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, typeInput)) + new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit, typeInput)) then: input.success @@ -72,6 +74,7 @@ class BmInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput assert !marketReaction assert costControlled diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactoryTest.groovy index 373da8d5b..aedb04fce 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/ChpInputFactoryTest.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.ChpInput @@ -18,10 +21,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class ChpInputFactoryTest extends Specification implements FactoryTestHelper { def "A ChpInputFactory should contain exactly the expected class for parsing"() { @@ -47,13 +48,14 @@ class ChpInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = ChpInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(ChpTypeInput) def thermalBusInput = Mock(ThermalBusInput) def thermalStorageInput = Mock(ThermalStorageInput) when: Try input = inputFactory.get( - new ChpInputEntityData(parameter, operatorInput, nodeInput, typeInput, thermalBusInput, thermalStorageInput)) + new ChpInputEntityData(parameter, operatorInput, nodeInput, emUnit, typeInput, thermalBusInput, thermalStorageInput)) then: input.success @@ -73,9 +75,9 @@ class ChpInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput assert marketReaction } } } - diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy index ba8ae0d84..673185c12 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EmInputFactoryTest.groovy @@ -6,19 +6,12 @@ package edu.ie3.datamodel.io.factory.input.participant import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData -import edu.ie3.datamodel.models.ControlStrategy -import edu.ie3.datamodel.models.EmControlStrategy -import edu.ie3.datamodel.models.input.NodeInput +import edu.ie3.datamodel.io.factory.input.EmAssetInputEntityData +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.system.EmInput -import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import edu.ie3.datamodel.utils.Try -import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Specification -import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime class EmInputFactoryTest extends Specification { @@ -32,7 +25,7 @@ class EmInputFactoryTest extends Specification { inputFactory.supportedClasses == expectedClasses } - def "A EmInputFactory should parse a valid EmInput correctly"() { + def "A EmInputFactory should parse a valid EmInput with parent EM correctly"() { given: def inputFactory = new EmInputFactory() Map parameter = [ @@ -40,17 +33,15 @@ class EmInputFactoryTest extends Specification { "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", "operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", - "connectedassets" : "4e840ea0-fb72-422e-942f-4111312e9914 a17aa6f0-e663-4186-ac34-a7b68573938b", - "controlstrategy" : "self_optimization" + "controlstrategy" : "no_control" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def parentEmUnit = Mock(EmInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new EmAssetInputEntityData(parameter, inputClass, operatorInput, parentEmUnit)) then: input.success @@ -63,21 +54,12 @@ class EmInputFactoryTest extends Specification { assert operationTime.endDate.get() == ZonedDateTime.parse(parameter["operatesuntil"]) assert operator == operatorInput assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } - assert connectedAssets == [ - UUID.fromString("4e840ea0-fb72-422e-942f-4111312e9914"), - UUID.fromString("a17aa6f0-e663-4186-ac34-a7b68573938b") - ] as UUID[] - assert controlStrategy == EmControlStrategy.SELF_OPTIMIZATION + assert controlStrategy == parameter["controlstrategy"] + assert parentEm == Optional.of(parentEmUnit) } } - def "A EmInputFactory should parse a valid EmInput with zero connected assets correctly"() { + def "A EmInputFactory should parse a valid EmInput without parent EM correctly"() { given: def inputFactory = new EmInputFactory() Map parameter = [ @@ -85,17 +67,14 @@ class EmInputFactoryTest extends Specification { "operatesfrom" : "2019-01-01T00:00:00+01:00[Europe/Berlin]", "operatesuntil" : "2019-12-31T23:59:00+01:00[Europe/Berlin]", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", - "connectedassets" : "", - "controlstrategy" : "self_optimization" + "controlstrategy" : "no_control" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new EmAssetInputEntityData(parameter, inputClass, operatorInput, null)) then: input.success @@ -108,54 +87,28 @@ class EmInputFactoryTest extends Specification { assert operationTime.endDate.get() == ZonedDateTime.parse(parameter["operatesuntil"]) assert operator == operatorInput assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } - assert connectedAssets == [] as UUID[] - assert controlStrategy == EmControlStrategy.SELF_OPTIMIZATION + assert controlStrategy == parameter["controlstrategy"] + assert parentEm == Optional.empty() } } - def "A EmInputFactory should use a default control strategy if value cannot be parsed"() { + def "A EmInputFactory should fail when passing an invalid UUID"() { given: def inputFactory = new EmInputFactory() Map parameter = [ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", + "uuid" : "- broken -", "id" : "TestID", - "qcharacteristics": "cosPhiFixed:{(0.0,1.0)}", - "connectedassets" : "4e840ea0-fb72-422e-942f-4111312e9914", - "controlstrategy" : " -- invalid --" + "controlstrategy" : "no_control" ] def inputClass = EmInput - def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new EmAssetInputEntityData(parameter, inputClass, operatorInput, null)) then: - input.success - input.data.get().getClass() == inputClass - input.data.get().with { - assert uuid == UUID.fromString(parameter["uuid"]) - assert operationTime.startDate.empty - assert operationTime.endDate.empty - assert operator == operatorInput - assert id == parameter["id"] - assert node == nodeInput - assert qCharacteristics.with { - assert points == Collections.unmodifiableSortedSet([ - new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) - ] as TreeSet) - } - assert connectedAssets == [ - UUID.fromString("4e840ea0-fb72-422e-942f-4111312e9914") - ] as UUID[] - assert controlStrategy == ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY - } + input.failure + input.exception.get().cause.message == "Exception while trying to parse UUID of field \"uuid\" with value \"- broken -\"" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvInputFactoryTest.groovy index 2d8b5c0d0..b9c492de7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvInputFactoryTest.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.EvInput @@ -16,10 +19,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class EvInputFactoryTest extends Specification implements FactoryTestHelper { def "A EvInputFactory should contain exactly the expected class for parsing"() { @@ -44,11 +45,12 @@ class EvInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = EvInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(EvTypeInput) when: Try input = inputFactory.get( - new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, typeInput)) + new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit, typeInput)) then: input.success @@ -68,6 +70,7 @@ class EvInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy index 4f3412e23..c7faf7697 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/EvcsInputFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.input.participant import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.EvcsInput @@ -19,8 +19,8 @@ import edu.ie3.util.quantities.PowerSystemUnits import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime +import javax.measure.quantity.Dimensionless /** * Testing EvcsInputFactory * @@ -55,10 +55,11 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = EvcsInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new SystemParticipantEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit)) then: input.success @@ -78,6 +79,7 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PowerSystemUnits.PU), Quantities.getQuantity(1d, PowerSystemUnits.PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == ChargingPointTypeUtils.HouseholdSocket assert chargingPoints == Integer.parseInt(parameter["chargingpoints"]) assert cosPhiRated == Double.parseDouble(parameter["cosphirated"]) @@ -104,10 +106,11 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = EvcsInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new SystemParticipantEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit)) then: input.failure @@ -132,13 +135,14 @@ class EvcsInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = EvcsInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new SystemParticipantEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit)) then: input.failure - input.exception.get().cause.message == "Exception while trying to parse field \"locationtype\" with supposed int value \"-- invalid --\"" + input.exception.get().cause.message == "Exception while trying to parse field \"locationType\" with supposed int value \"-- invalid --\"" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactoryTest.groovy index fa7184b4b..c7c8bbfa3 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/FixedFeedInInputFactoryTest.groovy @@ -5,9 +5,11 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.FixedFeedInInput @@ -17,10 +19,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class FixedFeedInInputFactoryTest extends Specification implements FactoryTestHelper { def "A FixedFeedInInputFactory should contain exactly the expected class for parsing"() { @@ -47,9 +47,10 @@ class FixedFeedInInputFactoryTest extends Specification implements FactoryTestHe def inputClass = FixedFeedInInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) when: - Try input = inputFactory.get(new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + Try input = inputFactory.get(new SystemParticipantEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit)) then: input.success @@ -68,37 +69,31 @@ class FixedFeedInInputFactoryTest extends Specification implements FactoryTestHe new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert sRated == getQuant(parameter["srated"], StandardUnits.S_RATED) assert cosPhiRated == Double.parseDouble(parameter["cosphirated"]) } } - def "A FixedFeedInInputFactory should throw an exception on invalid or incomplete data (parameter missing)"() { - given: "a system participant input type factory and model data" + def "A FixedFeedInInputFactory should throw an exception on invalid or incomplete data fields"() { + given: def inputFactory = new FixedFeedInInputFactory() - Map parameter = [ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "TestID", - "srated" : "3", - "cosphirated": "4" - ] - def inputClass = FixedFeedInInput - def nodeInput = Mock(NodeInput) + def actualFields = FixedFeedInInputFactory.newSet("uuid", "id", "s_rated", "cosphi_rated") when: - Try input = inputFactory.get(new NodeAssetInputEntityData(parameter, inputClass, nodeInput)) + Try input = inputFactory.validate(actualFields, FixedFeedInInput) then: input.failure - input.exception.get().cause.message == "The provided fields [cosphirated, id, srated, uuid] with data \n" + - "{cosphirated -> 4,\n" + - "id -> TestID,\n" + - "srated -> 3,\n" + - "uuid -> 91ec3bcf-1777-4d38-af67-0bf7c9fa73c7} are invalid for instance of FixedFeedInInput. \n" + + input.exception.get().message == "The provided fields [cosphi_rated, id, s_rated, uuid] are invalid for instance of 'FixedFeedInInput'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'FixedFeedInInput' are possible (NOT case-sensitive!):\n" + - "0: [cosphirated, id, qcharacteristics, srated, uuid]\n" + - "1: [cosphirated, id, operatesfrom, qcharacteristics, srated, uuid]\n" + - "2: [cosphirated, id, operatesuntil, qcharacteristics, srated, uuid]\n" + - "3: [cosphirated, id, operatesfrom, operatesuntil, qcharacteristics, srated, uuid]\n" + "0: [cosPhiRated, id, qCharacteristics, sRated, uuid] or [cos_phi_rated, id, q_characteristics, s_rated, uuid]\n" + + "1: [cosPhiRated, id, operatesFrom, qCharacteristics, sRated, uuid] or [cos_phi_rated, id, operates_from, q_characteristics, s_rated, uuid]\n" + + "2: [cosPhiRated, id, operatesUntil, qCharacteristics, sRated, uuid] or [cos_phi_rated, id, operates_until, q_characteristics, s_rated, uuid]\n" + + "3: [cosPhiRated, id, operatesFrom, operatesUntil, qCharacteristics, sRated, uuid] or [cos_phi_rated, id, operates_from, operates_until, q_characteristics, s_rated, uuid]\n" + + "4: [cosPhiRated, em, id, qCharacteristics, sRated, uuid] or [cos_phi_rated, em, id, q_characteristics, s_rated, uuid]\n" + + "5: [cosPhiRated, em, id, operatesFrom, qCharacteristics, sRated, uuid] or [cos_phi_rated, em, id, operates_from, q_characteristics, s_rated, uuid]\n" + + "6: [cosPhiRated, em, id, operatesUntil, qCharacteristics, sRated, uuid] or [cos_phi_rated, em, id, operates_until, q_characteristics, s_rated, uuid]\n" + + "7: [cosPhiRated, em, id, operatesFrom, operatesUntil, qCharacteristics, sRated, uuid] or [cos_phi_rated, em, id, operates_from, operates_until, q_characteristics, s_rated, uuid]\n" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/HpInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/HpInputFactoryTest.groovy index 47316ab03..550a088fc 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/HpInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/HpInputFactoryTest.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.HpInput @@ -17,10 +20,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class HpInputFactoryTest extends Specification implements FactoryTestHelper { def "A HpInputFactory should contain exactly the expected class for parsing"() { @@ -45,12 +46,13 @@ class HpInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = HpInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(HpTypeInput) def thermalBusInput = Mock(ThermalBusInput) when: Try input = inputFactory.get( - new HpInputEntityData(parameter, operatorInput, nodeInput, typeInput, thermalBusInput)) + new HpInputEntityData(parameter, operatorInput, nodeInput, emUnit, typeInput, thermalBusInput)) then: input.success @@ -70,6 +72,7 @@ class HpInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput assert thermalBus == thermalBusInput } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactoryTest.groovy index cede6ac6b..c0bc33bfa 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/LoadInputFactoryTest.groovy @@ -5,10 +5,12 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.LoadInput @@ -22,8 +24,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class LoadInputFactoryTest extends Specification implements FactoryTestHelper { def "A LoadInputFactory should contain exactly the expected class for parsing"() { given: @@ -38,6 +38,7 @@ class LoadInputFactoryTest extends Specification implements FactoryTestHelper { given: "a system participant input type factory and model data" def inputClass = LoadInput def nodeInput = Mock(NodeInput) + def emUnit = Mock(EmInput) when: def inputFactory = new LoadInputFactory() @@ -52,7 +53,7 @@ class LoadInputFactoryTest extends Specification implements FactoryTestHelper { "cosphirated" : "5" ] Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, nodeInput)) + new SystemParticipantEntityData(parameter, inputClass, nodeInput, emUnit)) then: input.success @@ -69,6 +70,7 @@ class LoadInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert loadProfile == profile assert dsm assert eConsAnnual == getQuant(parameter["econsannual"], StandardUnits.ENERGY_IN) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/PvInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/PvInputFactoryTest.groovy index 4fffbba20..8ea8a4cf8 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/PvInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/PvInputFactoryTest.groovy @@ -5,9 +5,11 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.PvInput @@ -17,10 +19,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class PvInputFactoryTest extends Specification implements FactoryTestHelper { def "A PvInputFactory should contain exactly the expected class for parsing"() { @@ -54,10 +54,11 @@ class PvInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = PvInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) when: Try input = inputFactory.get( - new NodeAssetInputEntityData(parameter, inputClass, operatorInput, nodeInput)) + new SystemParticipantEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit)) then: input.success @@ -77,6 +78,7 @@ class PvInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert albedo == Double.parseDouble(parameter["albedo"]) assert azimuth == getQuant(parameter["azimuth"], StandardUnits.AZIMUTH) assert etaConv == getQuant(parameter["etaconv"], StandardUnits.EFFICIENCY) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactoryTest.groovy index da40b333d..d20685662 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/StorageInputFactoryTest.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.StorageInput @@ -16,10 +19,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class StorageInputFactoryTest extends Specification implements FactoryTestHelper { def "A StorageInputFactory should contain exactly the expected class for parsing"() { @@ -44,11 +45,12 @@ class StorageInputFactoryTest extends Specification implements FactoryTestHelper def inputClass = StorageInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(StorageTypeInput) when: Try input = inputFactory.get( - new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, typeInput)) + new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit, typeInput)) then: input.success @@ -68,6 +70,7 @@ class StorageInputFactoryTest extends Specification implements FactoryTestHelper new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/WecInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/WecInputFactoryTest.groovy index cd432e1f5..d258837ec 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/WecInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/input/participant/WecInputFactoryTest.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.datamodel.io.factory.input.participant +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.system.WecInput @@ -16,10 +19,8 @@ import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Dimensionless import java.time.ZonedDateTime - -import static edu.ie3.util.quantities.PowerSystemUnits.PU +import javax.measure.quantity.Dimensionless class WecInputFactoryTest extends Specification implements FactoryTestHelper { def "A WecInputFactoryTest should contain exactly the expected class for parsing"() { @@ -45,11 +46,12 @@ class WecInputFactoryTest extends Specification implements FactoryTestHelper { def inputClass = WecInput def nodeInput = Mock(NodeInput) def operatorInput = Mock(OperatorInput) + def emUnit = Mock(EmInput) def typeInput = Mock(WecTypeInput) when: Try input = inputFactory.get( - new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, typeInput)) + new SystemParticipantTypedEntityData(parameter, inputClass, operatorInput, nodeInput, emUnit, typeInput)) then: input.success @@ -68,6 +70,7 @@ class WecInputFactoryTest extends Specification implements FactoryTestHelper { new CharacteristicPoint(Quantities.getQuantity(0d, PU), Quantities.getQuantity(1d, PU)) ] as TreeSet) } + assert em == Optional.of(emUnit) assert type == typeInput assert marketReaction } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ConnectorResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ConnectorResultFactoryTest.groovy index d22c8abac..9711dd7f7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ConnectorResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ConnectorResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.connector.ConnectorResult import edu.ie3.datamodel.models.result.connector.LineResult @@ -53,7 +53,7 @@ class ConnectorResultFactoryTest extends Specification implements FactoryTestHel } when: - Try result = resultFactory.get(new SimpleEntityData(parameter, modelClass)) + Try result = resultFactory.get(new EntityData(parameter, modelClass)) then: result.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactoryTest.groovy index c46eabaea..11fcd675f 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/FlexOptionsResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.system.FlexOptionsResult import edu.ie3.datamodel.utils.Try @@ -36,7 +36,7 @@ class FlexOptionsResultFactoryTest extends Specification implements FactoryTestH ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, FlexOptionsResult)) + Try result = resultFactory.get(new EntityData(parameter, FlexOptionsResult)) then: result.success @@ -53,25 +53,16 @@ class FlexOptionsResultFactoryTest extends Specification implements FactoryTestH def "A FlexOptionsResultFactory should throw an exception on invalid or incomplete data"() { given: "a system participant factory and model data" def resultFactory = new FlexOptionsResultFactory() - Map parameter = [ - "time" : "2020-01-30 17:26:44", - "inputModel": "91ec3bcf-1897-4d38-af67-0bf7c9fa73c7", - "pref" : "2", - "pmin" : "-1", - ] + def actualFields = FlexOptionsResultFactory.newSet("time", "input_model", "p_ref", "p_min") when: - Try input = resultFactory.get(new SimpleEntityData(parameter, FlexOptionsResult)) + Try input = resultFactory.validate(actualFields, FlexOptionsResult) then: input.failure - input.exception.get().cause.message == "The provided fields [inputModel, pmin, pref, time] with data \n" + - "{inputModel -> 91ec3bcf-1897-4d38-af67-0bf7c9fa73c7,\n" + - "pmin -> -1,\n" + - "pref -> 2,\n" + - "time -> 2020-01-30 17:26:44} are invalid for instance of FlexOptionsResult. \n" + + input.exception.get().message == "The provided fields [input_model, p_min, p_ref, time] are invalid for instance of 'FlexOptionsResult'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'FlexOptionsResult' are possible (NOT case-sensitive!):\n" + - "0: [inputModel, pmax, pmin, pref, time]\n" + - "1: [inputModel, pmax, pmin, pref, time, uuid]\n" + "0: [inputModel, pMax, pMin, pRef, time] or [input_model, p_max, p_min, p_ref, time]\n" + + "1: [inputModel, pMax, pMin, pRef, time, uuid] or [input_model, p_max, p_min, p_ref, time, uuid]\n" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/NodeResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/NodeResultFactoryTest.groovy index 9dbc4e294..0072bec89 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/NodeResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/NodeResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.utils.Try @@ -35,7 +35,7 @@ class NodeResultFactoryTest extends Specification implements FactoryTestHelper { ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, NodeResult)) + Try result = resultFactory.get(new EntityData(parameter, NodeResult)) then: result.success @@ -51,23 +51,16 @@ class NodeResultFactoryTest extends Specification implements FactoryTestHelper { def "A NodeResultFactory should throw an exception on invalid or incomplete data"() { given: "a system participant factory and model data" def resultFactory = new NodeResultFactory() - Map parameter = [ - "time" : "2020-01-30 17:26:44", - "inputModel": "91ec3bcf-1897-4d38-af67-0bf7c9fa73c7", - "vmag" : "2" - ] + def actualFields = NodeResultFactory.newSet("time", "input_model", "v_mag") when: - Try input = resultFactory.get(new SimpleEntityData(parameter, NodeResult)) + Try input = resultFactory.validate(actualFields, NodeResult) then: input.failure - input.exception.get().cause.message == "The provided fields [inputModel, time, vmag] with data \n" + - "{inputModel -> 91ec3bcf-1897-4d38-af67-0bf7c9fa73c7,\n" + - "time -> 2020-01-30 17:26:44,\n" + - "vmag -> 2} are invalid for instance of NodeResult. \n" + + input.exception.get().message == "The provided fields [input_model, time, v_mag] are invalid for instance of 'NodeResult'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'NodeResult' are possible (NOT case-sensitive!):\n" + - "0: [inputModel, time, vang, vmag]\n" + - "1: [inputModel, time, uuid, vang, vmag]\n" + "0: [inputModel, time, vAng, vMag] or [input_model, time, v_ang, v_mag]\n" + + "1: [inputModel, time, uuid, vAng, vMag] or [input_model, time, uuid, v_ang, v_mag]\n" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/SwitchResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/SwitchResultFactoryTest.groovy index ff05a4ff8..618d3291a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/SwitchResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/SwitchResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.result.connector.SwitchResult import edu.ie3.datamodel.utils.Try import edu.ie3.test.helper.FactoryTestHelper @@ -35,7 +35,7 @@ class SwitchResultFactoryTest extends Specification implements FactoryTestHelper ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, SwitchResult)) + Try result = resultFactory.get(new EntityData(parameter, SwitchResult)) then: result.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactoryTest.groovy index 664749ca6..3bc5f2600 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/SystemParticipantResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.system.* import edu.ie3.datamodel.utils.Try @@ -56,7 +56,7 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor } when: - Try result = resultFactory.get(new SimpleEntityData(parameter, modelClass)) + Try result = resultFactory.get(new EntityData(parameter, modelClass)) then: result.success @@ -110,7 +110,7 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor "q" : "2" ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, StorageResult)) + Try result = resultFactory.get(new EntityData(parameter, StorageResult)) then: result.success @@ -127,23 +127,17 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor def "A SystemParticipantResultFactory should throw an exception on invalid or incomplete data"() { given: "a system participant factory and model data" def resultFactory = new SystemParticipantResultFactory() - Map parameter = [ - "time" : "2020-01-30 17:26:44", - "inputModel": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "q" : "2" - ] + def actualFields = SystemParticipantResultFactory.newSet("time", "input_model", "q") + when: - Try result = resultFactory.get(new SimpleEntityData(parameter, WecResult)) + Try result = resultFactory.validate(actualFields, WecResult) then: result.failure - result.exception.get().cause.message == "The provided fields [inputModel, q, time] with data \n" + - "{inputModel -> 91ec3bcf-1777-4d38-af67-0bf7c9fa73c7,\n" + - "q -> 2,\n" + - "time -> 2020-01-30 17:26:44} are invalid for instance of WecResult. \n" + + result.exception.get().message == "The provided fields [input_model, q, time] are invalid for instance of 'WecResult'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'WecResult' are possible (NOT case-sensitive!):\n" + - "0: [inputModel, p, q, time]\n" + - "1: [inputModel, p, q, time, uuid]\n" + "0: [inputModel, p, q, time] or [input_model, p, q, time]\n" + + "1: [inputModel, p, q, time, uuid] or [input_model, p, q, time, uuid]\n" } def "A SystemParticipantResultFactory should be performant"() { @@ -159,7 +153,7 @@ class SystemParticipantResultFactoryTest extends Specification implements Factor expect: "that the factory should not need more than 3 seconds for processing 10.000 entities" Long startTime = System.currentTimeMillis() 10000.times { - resultFactory.get(new SimpleEntityData(parameter, StorageResult)) + resultFactory.get(new EntityData(parameter, StorageResult)) } BigDecimal elapsedTime = (System .currentTimeMillis() - startTime) / 1000.0 diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy index 3e9456fe2..12b3c1364 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/result/ThermalResultFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.result import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.result.thermal.CylindricalStorageResult import edu.ie3.datamodel.models.result.thermal.ThermalHouseResult @@ -41,7 +41,7 @@ class ThermalResultFactoryTest extends Specification implements FactoryTestHelpe "fillLevel" : "20" ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, CylindricalStorageResult)) + Try result = resultFactory.get(new EntityData(parameter, CylindricalStorageResult)) then: result.success @@ -65,7 +65,7 @@ class ThermalResultFactoryTest extends Specification implements FactoryTestHelpe "indoorTemperature": "21" ] when: - Try result = resultFactory.get(new SimpleEntityData(parameter, ThermalHouseResult)) + Try result = resultFactory.get(new EntityData(parameter, ThermalHouseResult)) then: result.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactoryTest.groovy index 117999ce4..8b871b983 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoIdCoordinateFactoryTest.groovy @@ -25,27 +25,14 @@ class CosmoIdCoordinateFactoryTest extends Specification { def expectedFields = [ "tid", "id", - "latrot", - "longrot", - "latgeo", - "longgeo" + "latRot", + "longRot", + "latGeo", + "longGeo" ] as Set - Map parameter = [ - "tid": "1", - "id": "106580", - "latgeo": "39.602772", - "longgeo": "1.279336", - "latrot": "-10", - "longrot": "-6.8125" - ] - - - def validSimpleFactoryData = new SimpleFactoryData(parameter, Pair) - - when: - def actual = factory.getFields(validSimpleFactoryData) + def actual = factory.getFields(Pair) then: actual.size() == 1 @@ -54,22 +41,16 @@ class CosmoIdCoordinateFactoryTest extends Specification { def "A COSMO id to coordinate factory refuses to build from invalid data"() { given: - Map parameter = [ - "tid": "1", - "id": "106580", - "latrot": "-10", - "longrot": "-6.8125" - ] - - def invalidSimpleFactoryData = new SimpleFactoryData(parameter, Pair) + def actualFields = CosmoIdCoordinateFactory.newSet("tid", "id", "latrot", "longrot") when: - def actual = factory.get(invalidSimpleFactoryData) + def actual = factory.validate(actualFields, Pair) then: actual.failure - actual.exception.get().cause.message.startsWith("The provided fields [id, latrot, longrot, tid] with data \n{id -> 106580,\nlatrot" + - " -> -10,\nlongrot -> -6.8125,\ntid -> 1} are invalid for instance of Pair.") + actual.exception.get().message == "The provided fields [id, latrot, longrot, tid] are invalid for instance of 'Pair'. \n" + + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'Pair' are possible (NOT case-sensitive!):\n" + + "0: [id, latGeo, latRot, longGeo, longRot, tid] or [id, lat_geo, lat_rot, long_geo, long_rot, tid]\n" } def "A COSMO id to coordinate factory builds model from valid data"() { @@ -77,10 +58,10 @@ class CosmoIdCoordinateFactoryTest extends Specification { Map parameter = [ "tid": "1", "id": "106580", - "latgeo": "39.602772", - "longgeo": "1.279336", - "latrot": "-10", - "longrot": "-6.8125" + "latGeo": "39.602772", + "longGeo": "1.279336", + "latRot": "-10", + "longRot": "-6.8125" ] def validSimpleFactoryData = new SimpleFactoryData(parameter, Pair) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy index f83ec6a29..ac44095d8 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/CosmoTimeBasedWeatherValueFactoryTest.groovy @@ -24,11 +24,11 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", "time" : TimeUtil.withDefaults.toString(time), - "diffuseirradiance": "282.671997070312", - "directirradiance" : "286.872985839844", + "diffuseIrradiance": "282.671997070312", + "directIrradiance" : "286.872985839844", "temperature" : "", - "winddirection" : "0", - "windvelocity" : "1.66103506088257" + "windDirection" : "0", + "windVelocity" : "1.66103506088257" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) @@ -57,11 +57,11 @@ class CosmoTimeBasedWeatherValueFactoryTest extends Specification { Map parameter = [ "time" : TimeUtil.withDefaults.toString(time), "uuid" : "980f7714-8def-479f-baae-4deed6c8d6d1", - "diffuseirradiance": "282.671997070312", - "directirradiance" : "286.872985839844", + "diffuseIrradiance": "282.671997070312", + "directIrradiance" : "286.872985839844", "temperature" : "278.019012451172", - "winddirection" : "0", - "windvelocity" : "1.66103506088257" + "windDirection" : "0", + "windVelocity" : "1.66103506088257" ] def data = new TimeBasedWeatherValueData(parameter, coordinate) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactoryTest.groovy index b40b44387..922c82869 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/IconIdCoordinateFactoryTest.groovy @@ -26,18 +26,11 @@ class IconIdCoordinateFactoryTest extends Specification { "id", "latitude", "longitude", - "coordinatetype" + "coordinateType" ] as Set - Map parameter = [ - "id":"477295", - "latitude":"52.312", - "longitude":"12.812", - "coordinatetype":"ICON"] - - def validSimpleFactoryData = new SimpleFactoryData(parameter, Pair) when: - def actual = factory.getFields(validSimpleFactoryData) + def actual = factory.getFields(Pair) then: actual.size() == 1 @@ -46,20 +39,16 @@ class IconIdCoordinateFactoryTest extends Specification { def "A COSMO id to coordinate factory refuses to build from invalid data"() { given: - Map parameter = [ - "id":"477295", - "latitude":"52.312", - "coordinatetype":"ICON"] - - def invalidSimpleFactoryData = new SimpleFactoryData(parameter, Pair) + def actualFields = IconIdCoordinateFactory.newSet("id", "latitude", "coordinatetype") when: - def actual = factory.get(invalidSimpleFactoryData) + def actual = factory.validate(actualFields, Pair) then: actual.failure - actual.exception.get().cause.message.startsWith("The provided fields [coordinatetype, id, latitude] with data \n{coordinatetype -> " + - "ICON,\nid -> 477295,\nlatitude -> 52.312} are invalid for instance of Pair. ") + actual.exception.get().message == "The provided fields [coordinatetype, id, latitude] are invalid for instance of 'Pair'. \n" + + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'Pair' are possible (NOT case-sensitive!):\n" + + "0: [coordinateType, id, latitude, longitude] or [coordinate_type, id, latitude, longitude]\n" } def "A COSMO id to coordinate factory builds model from valid data"() { @@ -68,7 +57,7 @@ class IconIdCoordinateFactoryTest extends Specification { "id":"477295", "latitude":"52.312", "longitude":"12.812", - "coordinatetype":"ICON"] + "coordinateType":"ICON"] def validSimpleFactoryData = new SimpleFactoryData(parameter, Pair) Pair expectedPair = Pair.of(477295, GeoUtils.buildPoint(52.312, 12.812)) diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy index a91436c4e..5b72b7e3a 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/timeseries/TimeBasedSimpleValueFactoryTest.groovy @@ -34,7 +34,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { data.targetClass >> valueClass expect: - factory.getFields(data) == expectedFields + factory.getFields(data.targetClass) == expectedFields where: valueClass || expectedFields @@ -93,7 +93,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { data.targetClass >> NodeInput when: - factory.getFields(data) + factory.getFields(data.targetClass) then: def e = thrown(FactoryException) @@ -128,7 +128,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { "time": defaultTimeUtil.toString(time), "p": "500.0", "q": "165.0", - "heatdemand": "8.0" + "heatDemand": "8.0" ], HeatAndSValue) def expected = new TimeBasedValue( UUID.fromString("78ca078a-e6e9-4972-a58d-b2cadbc2df2c"), @@ -148,7 +148,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { "uuid": "78ca078a-e6e9-4972-a58d-b2cadbc2df2c", "time": defaultTimeUtil.toString(time), "p": "500.0", - "heatdemand": "8.0" + "heatDemand": "8.0" ], HeatAndPValue) def expected = new TimeBasedValue( UUID.fromString("78ca078a-e6e9-4972-a58d-b2cadbc2df2c"), @@ -167,7 +167,7 @@ class TimeBasedSimpleValueFactoryTest extends Specification { def data = new SimpleTimeBasedValueData([ "uuid": "78ca078a-e6e9-4972-a58d-b2cadbc2df2c", "time": defaultTimeUtil.toString(time), - "heatdemand": "8.0" + "heatDemand": "8.0" ], HeatDemandValue) def expected = new TimeBasedValue( UUID.fromString("78ca078a-e6e9-4972-a58d-b2cadbc2df2c"), diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactoryTest.groovy index 0248bf204..321576903 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/LineTypeInputFactoryTest.groovy @@ -6,11 +6,11 @@ package edu.ie3.datamodel.io.factory.typeinput import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.utils.Try -import edu.ie3.test.helper.FactoryTestHelper -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.connector.type.LineTypeInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification class LineTypeInputFactoryTest extends Specification implements FactoryTestHelper { @@ -40,7 +40,7 @@ class LineTypeInputFactoryTest extends Specification implements FactoryTestHelpe def typeInputClass = LineTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactoryTest.groovy index b5f40c2ac..69a10c5e8 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/SystemParticipantTypeInputFactoryTest.groovy @@ -5,8 +5,11 @@ */ package edu.ie3.datamodel.io.factory.typeinput +import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import edu.ie3.datamodel.models.input.system.type.* @@ -18,9 +21,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless import javax.measure.quantity.Speed -import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class SystemParticipantTypeInputFactoryTest extends Specification implements FactoryTestHelper { def "A SystemParticipantTypeInputFactory should contain all expected classes for parsing"() { @@ -56,7 +56,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = EvTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -91,7 +91,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = HpTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -125,7 +125,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = BmTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -163,7 +163,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = WecTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -210,7 +210,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = ChpTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -253,7 +253,7 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def typeInputClass = StorageTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success @@ -280,40 +280,15 @@ class SystemParticipantTypeInputFactoryTest extends Specification implements Fac def "A SystemParticipantTypeInputFactory should throw an exception on invalid or incomplete data"() { given: "a system participant factory and model data" def typeInputFactory = new SystemParticipantTypeInputFactory() - Map parameter = [ - "uuid": "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id": "blablub", - "capex": "3", - "opex": "4", - "srated": "5", - "cosPhiRated": "6", - "estorage": "6", - "pmin": "7", - "pmax": "8", - "eta": "9", - "dod": "10", - "lifetime": "11" - ] + def actualFields = SystemParticipantTypeInputFactory.newSet("uuid", "id", "capex", "opex", "srated", "cosPhiRated", "estorage", "pmin", "pmax", "eta", "dod", "lifetime",) when: - Try input = typeInputFactory.get(new SimpleEntityData(parameter, StorageTypeInput)) + def input = typeInputFactory.validate(actualFields, StorageTypeInput) then: input.failure - input.exception.get().cause.message == "The provided fields [capex, cosPhiRated, dod, estorage, eta, id, lifetime, opex, pmax, pmin, srated, uuid] with data \n" + - "{capex -> 3,\n" + - "cosPhiRated -> 6,\n" + - "dod -> 10,\n" + - "estorage -> 6,\n" + - "eta -> 9,\n" + - "id -> blablub,\n" + - "lifetime -> 11,\n" + - "opex -> 4,\n" + - "pmax -> 8,\n" + - "pmin -> 7,\n" + - "srated -> 5,\n" + - "uuid -> 91ec3bcf-1777-4d38-af67-0bf7c9fa73c7} are invalid for instance of StorageTypeInput. \n" + + input.exception.get().message == "The provided fields [capex, cosPhiRated, dod, estorage, eta, id, lifetime, opex, pmax, pmin, srated, uuid] are invalid for instance of 'StorageTypeInput'. \n" + "The following fields (without complex objects e.g. nodes, operators, ...) to be passed to a constructor of 'StorageTypeInput' are possible (NOT case-sensitive!):\n" + - "0: [activepowergradient, capex, cosphirated, dod, estorage, eta, id, lifecycle, lifetime, opex, pmax, srated, uuid]\n" + "0: [activePowerGradient, capex, cosPhiRated, dod, eStorage, eta, id, lifeCycle, lifeTime, opex, pMax, sRated, uuid] or [active_power_gradient, capex, cos_phi_rated, dod, e_storage, eta, id, life_cycle, life_time, opex, p_max, s_rated, uuid]\n" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactoryTest.groovy index 848de5662..b6f094353 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer2WTypeInputFactoryTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.factory.typeinput import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput import edu.ie3.datamodel.utils.Try @@ -47,7 +47,7 @@ class Transformer2WTypeInputFactoryTest extends Specification implements Factory def typeInputClass = Transformer2WTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactoryTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactoryTest.groovy index d01862624..e040a2132 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactoryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/factory/typeinput/Transformer3WTypeInputFactoryTest.groovy @@ -6,11 +6,11 @@ package edu.ie3.datamodel.io.factory.typeinput import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.utils.Try -import edu.ie3.test.helper.FactoryTestHelper -import edu.ie3.datamodel.io.factory.SimpleEntityData +import edu.ie3.datamodel.io.factory.EntityData import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.helper.FactoryTestHelper import spock.lang.Specification class Transformer3WTypeInputFactoryTest extends Specification implements FactoryTestHelper { @@ -53,7 +53,7 @@ class Transformer3WTypeInputFactoryTest extends Specification implements Factory def typeInputClass = Transformer3WTypeInput when: - Try typeInput = typeInputFactory.get(new SimpleEntityData(parameter, typeInputClass)) + Try typeInput = typeInputFactory.get(new EntityData(parameter, typeInputClass)) then: typeInput.success diff --git a/src/test/groovy/edu/ie3/datamodel/io/naming/EntityPersistenceNamingStrategyTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/naming/EntityPersistenceNamingStrategyTest.groovy index f6319e151..f34873c24 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/naming/EntityPersistenceNamingStrategyTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/naming/EntityPersistenceNamingStrategyTest.groovy @@ -6,7 +6,7 @@ package edu.ie3.datamodel.io.naming import edu.ie3.datamodel.io.source.TimeSeriesMappingSource -import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.MeasurementUnitInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.RandomLoadParameters @@ -21,7 +21,6 @@ import edu.ie3.datamodel.models.input.graphics.LineGraphicInput import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput import edu.ie3.datamodel.models.input.system.BmInput import edu.ie3.datamodel.models.input.system.ChpInput -import edu.ie3.datamodel.models.input.system.EmInput import edu.ie3.datamodel.models.input.system.EvInput import edu.ie3.datamodel.models.input.system.EvcsInput import edu.ie3.datamodel.models.input.system.FixedFeedInInput @@ -38,6 +37,7 @@ import edu.ie3.datamodel.models.input.system.type.StorageTypeInput import edu.ie3.datamodel.models.input.system.type.WecTypeInput import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput +import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.datamodel.models.result.connector.SwitchResult diff --git a/src/test/groovy/edu/ie3/datamodel/io/naming/FileNamingStrategyTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/naming/FileNamingStrategyTest.groovy index e36fe9c9d..0a6565377 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/naming/FileNamingStrategyTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/naming/FileNamingStrategyTest.groovy @@ -9,7 +9,6 @@ import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme import edu.ie3.datamodel.io.naming.timeseries.IndividualTimeSeriesMetaInformation import edu.ie3.datamodel.io.naming.timeseries.LoadProfileTimeSeriesMetaInformation import edu.ie3.datamodel.io.source.TimeSeriesMappingSource -import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.UniqueEntity import edu.ie3.datamodel.models.input.MeasurementUnitInput import edu.ie3.datamodel.models.input.NodeInput @@ -41,6 +40,7 @@ import edu.ie3.datamodel.models.input.system.type.StorageTypeInput import edu.ie3.datamodel.models.input.system.type.WecTypeInput import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput +import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.result.NodeResult import edu.ie3.datamodel.models.result.connector.LineResult import edu.ie3.datamodel.models.result.connector.SwitchResult diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy index 5fffb0fa1..296be7a8c 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/ProcessorProviderTest.groovy @@ -11,6 +11,7 @@ import edu.ie3.datamodel.io.processor.timeseries.TimeSeriesProcessor import edu.ie3.datamodel.io.processor.timeseries.TimeSeriesProcessorKey import edu.ie3.datamodel.io.source.TimeSeriesMappingSource import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.MeasurementUnitInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy index 65dc1e1a6..0f25a83ba 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/input/InputEntityProcessorTest.groovy @@ -5,8 +5,11 @@ */ package edu.ie3.datamodel.io.processor.input +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.UniqueEntity import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.RandomLoadParameters @@ -30,8 +33,6 @@ import tech.units.indriya.quantity.Quantities import java.time.ZonedDateTime -import static edu.ie3.util.quantities.PowerSystemUnits.PU - /** * Testing the function of processors * @@ -143,9 +144,10 @@ class InputEntityProcessorTest extends Specification { def processingResult = processor.handleEntity(validInput) then: "make sure that the result is as expected " - processingResult.forEach { k, v -> + processingResult.forEach { + k, v -> if (k != "nodeInternal") // the internal 3w node is always randomly generated, hence we can skip to test on this - assert (v == expectedResult.get(k)) + assert (v == expectedResult.get(k)) } where: @@ -159,7 +161,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.fixedFeedInInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.fixedFeedInInput.operator.getUuid().toString(), "qCharacteristics": SystemParticipantTestData.cosPhiFixedSerialized, - "sRated" : SystemParticipantTestData.fixedFeedInInput.sRated.to(StandardUnits.S_RATED).getValue().doubleValue().toString() + "sRated" : SystemParticipantTestData.fixedFeedInInput.sRated.to(StandardUnits.S_RATED).getValue().doubleValue().toString(), + "em" : SystemParticipantTestData.fixedFeedInInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] PvInput | SystemParticipantTestData.pvInput || [ "uuid" : SystemParticipantTestData.pvInput.uuid.toString(), @@ -177,7 +180,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.pvInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.pvInput.operator.getUuid().toString(), "qCharacteristics": SystemParticipantTestData.cosPhiFixedSerialized, - "sRated" : SystemParticipantTestData.pvInput.sRated.to(StandardUnits.S_RATED).getValue().doubleValue().toString() + "sRated" : SystemParticipantTestData.pvInput.sRated.to(StandardUnits.S_RATED).getValue().doubleValue().toString(), + "em" : SystemParticipantTestData.pvInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] WecInput | SystemParticipantTestData.wecInput || [ "uuid" : SystemParticipantTestData.wecInput.uuid.toString(), @@ -188,7 +192,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.wecInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.wecInput.operator.uuid.toString(), "qCharacteristics": SystemParticipantTestData.cosPhiPSerialized, - "type" : SystemParticipantTestData.wecInput.type.uuid.toString() + "type" : SystemParticipantTestData.wecInput.type.uuid.toString(), + "em" : SystemParticipantTestData.wecInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] ChpInput | SystemParticipantTestData.chpInput || [ "uuid" : SystemParticipantTestData.chpInput.uuid.toString(), @@ -202,6 +207,7 @@ class InputEntityProcessorTest extends Specification { "thermalBus" : SystemParticipantTestData.chpInput.thermalBus.uuid.toString(), "thermalStorage" : SystemParticipantTestData.chpInput.thermalStorage.uuid.toString(), "type" : SystemParticipantTestData.chpInput.type.uuid.toString(), + "em" : SystemParticipantTestData.chpInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] BmInput | SystemParticipantTestData.bmInput || [ "uuid" : SystemParticipantTestData.bmInput.uuid.toString(), @@ -214,7 +220,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.bmInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.bmInput.operator.uuid.toString(), "qCharacteristics": SystemParticipantTestData.qVSerialized, - "type" : SystemParticipantTestData.bmInput.type.uuid.toString() + "type" : SystemParticipantTestData.bmInput.type.uuid.toString(), + "em" : SystemParticipantTestData.bmInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] EvInput | SystemParticipantTestData.evInput || [ "uuid" : SystemParticipantTestData.evInput.uuid.toString(), @@ -224,7 +231,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.evInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.evInput.operator.getUuid().toString(), "qCharacteristics": SystemParticipantTestData.cosPhiFixedSerialized, - "type" : SystemParticipantTestData.evInput.type.getUuid().toString() + "type" : SystemParticipantTestData.evInput.type.getUuid().toString(), + "em" : SystemParticipantTestData.evInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] LoadInput | SystemParticipantTestData.loadInput || [ @@ -239,7 +247,8 @@ class InputEntityProcessorTest extends Specification { "operator" : SystemParticipantTestData.loadInput.operator.uuid.toString(), "qCharacteristics" : SystemParticipantTestData.cosPhiFixedSerialized, "sRated" : SystemParticipantTestData.loadInput.sRated.getValue().doubleValue().toString(), - "loadProfile" : SystemParticipantTestData.loadInput.loadProfile.key + "loadProfile" : SystemParticipantTestData.loadInput.loadProfile.key, + "em" : SystemParticipantTestData.loadInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] StorageInput | SystemParticipantTestData.storageInput || [ "uuid" : SystemParticipantTestData.storageInput.uuid.toString(), @@ -249,7 +258,8 @@ class InputEntityProcessorTest extends Specification { "operatesFrom" : SystemParticipantTestData.storageInput.operationTime.startDate.orElse(ZonedDateTime.now()).toString(), "operator" : SystemParticipantTestData.storageInput.operator.uuid.toString(), "qCharacteristics": SystemParticipantTestData.cosPhiFixedSerialized, - "type" : SystemParticipantTestData.storageInput.type.uuid.toString() + "type" : SystemParticipantTestData.storageInput.type.uuid.toString(), + "em" : SystemParticipantTestData.storageInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] HpInput | SystemParticipantTestData.hpInput || [ "uuid" : SystemParticipantTestData.hpInput.uuid.toString(), @@ -260,7 +270,8 @@ class InputEntityProcessorTest extends Specification { "operator" : SystemParticipantTestData.hpInput.operator.uuid.toString(), "qCharacteristics": SystemParticipantTestData.cosPhiFixedSerialized, "thermalBus" : SystemParticipantTestData.hpInput.thermalBus.uuid.toString(), - "type" : SystemParticipantTestData.hpInput.type.uuid.toString() + "type" : SystemParticipantTestData.hpInput.type.uuid.toString(), + "em" : SystemParticipantTestData.hpInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] EvcsInput | SystemParticipantTestData.evcsInput || [ "uuid" : SystemParticipantTestData.evcsInput.uuid.toString(), @@ -274,7 +285,8 @@ class InputEntityProcessorTest extends Specification { "cosPhiRated" : SystemParticipantTestData.evcsInput.cosPhiRated.toString(), "chargingPoints" : SystemParticipantTestData.evcsInput.chargingPoints.toString(), "locationType" : SystemParticipantTestData.evcsInput.locationType.name(), - "v2gSupport" : SystemParticipantTestData.evcsInput.v2gSupport.toString() + "v2gSupport" : SystemParticipantTestData.evcsInput.v2gSupport.toString(), + "em" : SystemParticipantTestData.evcsInput.em.map((UniqueEntity::getUuid).andThen(UUID::toString)).orElse("") ] } @@ -354,18 +366,18 @@ class InputEntityProcessorTest extends Specification { given: InputEntityProcessor processor = new InputEntityProcessor(RandomLoadParameters) RandomLoadParameters parameters = new RandomLoadParameters( - UUID.fromString("a5b0f432-27b5-4b3e-b87a-61867b9edd79"), - 4, - 1.2, - 2.3, - 3.4, - 4.5, - 5.6, - 6.7, - 7.8, - 8.9, - 9.10 - ) + UUID.fromString("a5b0f432-27b5-4b3e-b87a-61867b9edd79"), + 4, + 1.2, + 2.3, + 3.4, + 4.5, + 5.6, + 6.7, + 7.8, + 8.9, + 9.10 + ) Map expected = [ "uuid" : "a5b0f432-27b5-4b3e-b87a-61867b9edd79", "quarterHour": "4", @@ -617,14 +629,14 @@ class InputEntityProcessorTest extends Specification { given: InputEntityProcessor processor = new InputEntityProcessor(NodeInput) def nodeWithOutOperator = new NodeInput( - UUID.fromString("6e0980e0-10f2-4e18-862b-eb2b7c90509b"), "node_d", OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited() - , - Quantities.getQuantity(1d, PU), - false, - null, - GermanVoltageLevelUtils.MV_20KV, - 4) + UUID.fromString("6e0980e0-10f2-4e18-862b-eb2b7c90509b"), "node_d", OperatorInput.NO_OPERATOR_ASSIGNED, + OperationTime.notLimited() + , + Quantities.getQuantity(1d, PU), + false, + null, + GermanVoltageLevelUtils.MV_20KV, + 4) Map expected = [ "geoPosition" : "", diff --git a/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy index 94f55d0ad..47eddf263 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/processor/result/ResultEntityProcessorTest.groovy @@ -21,9 +21,9 @@ import spock.lang.Specification import tech.units.indriya.quantity.Quantities import tech.units.indriya.unit.Units +import java.time.ZonedDateTime import javax.measure.Quantity import javax.measure.quantity.* -import java.time.ZonedDateTime class ResultEntityProcessorTest extends Specification { @@ -301,4 +301,3 @@ class ResultEntityProcessorTest extends Specification { } } } - diff --git a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy index 84f0e6ca5..6762fde68 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/CsvFileSinkTest.groovy @@ -5,16 +5,10 @@ */ package edu.ie3.datamodel.io.sink -import edu.ie3.datamodel.models.result.system.EmResult -import edu.ie3.datamodel.models.result.system.FlexOptionsResult - -import java.nio.file.Path - +import static edu.ie3.util.quantities.PowerSystemUnits.DEGREE_GEOM import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE import static tech.units.indriya.unit.Units.PERCENT -import static edu.ie3.util.quantities.PowerSystemUnits.DEGREE_GEOM -import edu.ie3.datamodel.models.input.system.EmInput -import edu.ie3.datamodel.models.input.system.LoadInput + import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.processor.ProcessorProvider import edu.ie3.datamodel.io.processor.input.InputEntityProcessor @@ -23,6 +17,7 @@ import edu.ie3.datamodel.io.processor.timeseries.TimeSeriesProcessor import edu.ie3.datamodel.io.processor.timeseries.TimeSeriesProcessorKey import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.connector.LineInput @@ -32,13 +27,16 @@ import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput import edu.ie3.datamodel.models.input.graphics.LineGraphicInput import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput import edu.ie3.datamodel.models.input.system.EvcsInput +import edu.ie3.datamodel.models.input.system.LoadInput import edu.ie3.datamodel.models.input.system.PvInput import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed import edu.ie3.datamodel.models.input.thermal.CylindricalStorageInput import edu.ie3.datamodel.models.input.thermal.ThermalBusInput import edu.ie3.datamodel.models.input.thermal.ThermalHouseInput +import edu.ie3.datamodel.models.result.system.EmResult import edu.ie3.datamodel.models.result.system.EvResult import edu.ie3.datamodel.models.result.system.EvcsResult +import edu.ie3.datamodel.models.result.system.FlexOptionsResult import edu.ie3.datamodel.models.result.system.PvResult import edu.ie3.datamodel.models.result.system.WecResult import edu.ie3.datamodel.models.timeseries.TimeSeries @@ -48,8 +46,8 @@ import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.EnergyPriceValue import edu.ie3.datamodel.models.value.Value import edu.ie3.test.common.GridTestData -import edu.ie3.test.common.SystemParticipantTestData import edu.ie3.test.common.SampleJointGrid +import edu.ie3.test.common.SystemParticipantTestData import edu.ie3.test.common.ThermalUnitInputTestData import edu.ie3.test.common.TimeSeriesTestData import edu.ie3.util.TimeUtil @@ -58,6 +56,7 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import java.nio.file.Path import javax.measure.Quantity import javax.measure.quantity.Power @@ -252,6 +251,7 @@ class CsvFileSinkTest extends Specification implements TimeSeriesTestData { OperationTime.notLimited(), Mock(NodeInput), new CosPhiFixed("cosPhiFixed:{(0.0,0.95)}"), + Mock(EmInput), 0.2, Quantities.getQuantity(-8.926613807678223, DEGREE_GEOM), Quantities.getQuantity(95d, PERCENT), diff --git a/src/test/groovy/edu/ie3/datamodel/io/sink/InfluxDbSinkIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/sink/InfluxDbSinkIT.groovy index 4b5c57905..eb22b04cd 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/sink/InfluxDbSinkIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/sink/InfluxDbSinkIT.groovy @@ -6,9 +6,9 @@ package edu.ie3.datamodel.io.sink -import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.connectors.InfluxDbConnector import edu.ie3.datamodel.io.naming.EntityPersistenceNamingStrategy +import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.result.ResultEntity diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/EnergyManagementSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/EnergyManagementSourceTest.groovy new file mode 100644 index 000000000..288c6be0a --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/source/EnergyManagementSourceTest.groovy @@ -0,0 +1,284 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.source + +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.exceptions.FactoryException +import edu.ie3.datamodel.exceptions.SourceException +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData +import edu.ie3.datamodel.models.input.EmInput +import edu.ie3.datamodel.utils.Try +import spock.lang.Specification + +import java.util.stream.Stream + +class EnergyManagementSourceTest extends Specification { + + def "An EnergyManagementSource should construct hierarchical EmInputs with two branches as expected"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-0", + "id": "root", + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "child 1", + "parentem" : "0-0-0-0-0", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-11", + "id": "child 1-1", + "parentem" : "0-0-0-0-1", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "child 2", + "parentem" : "0-0-0-0-0", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-21", + "id": "child 2-1", + "parentem" : "0-0-0-0-2", + "controlstrategy" : ""], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + expect: + def emUnits = EnergyManagementSource.createEmInputs(assetEntityDataStream) + + def expectedRootEm = new EmInput( + UUID.fromString("0-0-0-0-0"), + "root", + "", + null + ) + def expectedEm1 = new EmInput( + UUID.fromString("0-0-0-0-1"), + "child 1", + "", + expectedRootEm + ) + def expectedEm11 = new EmInput( + UUID.fromString("0-0-0-0-11"), + "child 1-1", + "", + expectedEm1 + ) + def expectedEm2 = new EmInput( + UUID.fromString("0-0-0-0-2"), + "child 2", + "", + expectedRootEm + ) + def expectedEm21 = new EmInput( + UUID.fromString("0-0-0-0-21"), + "child 2-1", + "", + expectedEm2 + ) + + emUnits == map([expectedRootEm, expectedEm1, expectedEm11, expectedEm2, expectedEm21]) + } + + def "An EnergyManagementSource should construct flat EmInputs without hierarchy as expected"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "em 2", + "parentem" : "", + "controlstrategy" : "strat_b"], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-3", + "id": "em 3", + "parentem" : "", + "controlstrategy" : "other"], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + expect: + def emUnits = EnergyManagementSource.createEmInputs(assetEntityDataStream) + + def expectedEm1 = new EmInput( + UUID.fromString("0-0-0-0-1"), + "em 1", + "", + null + ) + def expectedEm2 = new EmInput( + UUID.fromString("0-0-0-0-2"), + "em 2", + "strat_b", + null + ) + def expectedEm3 = new EmInput( + UUID.fromString("0-0-0-0-3"), + "em 3", + "other", + null + ) + + emUnits == map([expectedEm1, expectedEm2, expectedEm3]) + } + + def "An EnergyManagementSource should fail if any entity data already failed before"() { + given: + def assetEntityDataStream = Stream.of( + new Try.Success(new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "", + "controlstrategy" : ""], + EmInput + )), + new Try.Success(new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "em 2", + "parentem" : "", + "controlstrategy" : ""], + EmInput + )), + new Try.Failure(new SourceException("test failure abc")) + ) + + when: + EnergyManagementSource.createEmInputs(assetEntityDataStream) + + then: + def exc = thrown(SourceException) + exc.cause.message.contains("test failure abc") + } + + def "An EnergyManagementSource should fail if a parent EM UUID is malformed"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "em 2", + "parentem" : "not-a-uuid", + "controlstrategy" : ""], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + when: + EnergyManagementSource.createEmInputs(assetEntityDataStream) + + then: + def exc = thrown(SourceException) + exc.cause.message.contains("Exception while trying to parse UUID of field \"parentem\" with value \"not-a-uuid\"") + } + + def "An EnergyManagementSource should fail if the factory fails for one EM"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", // id is missing + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + when: + EnergyManagementSource.createEmInputs(assetEntityDataStream) + + then: + def exc = thrown(SourceException) + exc.cause.message.contains("An error occurred when creating instance of EmInput") + exc.cause.cause.class == FactoryException + } + + def "An EnergyManagementSource should fail if a parent em is not provided"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "", + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "em 2", + "parentem" : "1-2-3-4-5", // does not exist + "controlstrategy" : ""], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + when: + EnergyManagementSource.createEmInputs(assetEntityDataStream) + + then: + def exc = thrown(SourceException) + exc.message.contains("were assigned a parent EM that does not exist.") + } + + def "An EnergyManagementSource should fail if no parent ems are provided"() { + given: + def assetEntityDataStream = Stream.of( + new AssetInputEntityData( + ["uuid": "0-0-0-0-1", + "id": "em 1", + "parentem" : "1-2-3-4-5", // does not exist + "controlstrategy" : ""], + EmInput + ), + new AssetInputEntityData( + ["uuid": "0-0-0-0-2", + "id": "em 2", + "parentem" : "1-2-3-4-5", // does not exist + "controlstrategy" : ""], + EmInput + ), + ).map(data -> Try.of(() -> data, SourceException)) + + when: + EnergyManagementSource.createEmInputs(assetEntityDataStream) + + then: + def exc = thrown(SourceException) + exc.message.contains("were assigned a parent EM that does not exist.") + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/EntitySourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/EntitySourceTest.groovy index 4b51be15b..f5cbc5bc0 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/EntitySourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/EntitySourceTest.groovy @@ -5,102 +5,228 @@ */ package edu.ie3.datamodel.io.source -import edu.ie3.datamodel.io.factory.input.ThermalBusInputFactory -import edu.ie3.datamodel.io.naming.FileNamingStrategy +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.exceptions.SourceException +import edu.ie3.datamodel.exceptions.ValidationException +import edu.ie3.datamodel.io.factory.EntityData +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData +import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData +import edu.ie3.datamodel.io.factory.input.participant.ChpInputEntityData +import edu.ie3.datamodel.io.factory.input.participant.SystemParticipantTypedEntityData import edu.ie3.datamodel.io.source.csv.CsvDataSource -import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.AssetInput +import edu.ie3.datamodel.models.input.EmInput +import edu.ie3.datamodel.models.input.NodeInput +import edu.ie3.datamodel.models.input.system.ChpInput +import edu.ie3.datamodel.models.input.system.type.ChpTypeInput import edu.ie3.datamodel.models.input.thermal.ThermalBusInput +import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.common.GridTestData import edu.ie3.test.common.SystemParticipantTestData as sptd -import edu.ie3.test.common.GridTestData as gtd - import spock.lang.Shared import spock.lang.Specification -import java.nio.file.Path - class EntitySourceTest extends Specification { private final class DummyEntitySource extends EntitySource { DummyEntitySource(CsvDataSource dataSource) { - this.dataSource = dataSource + super(dataSource) + } + + @Override + void validate() throws ValidationException { } } @Shared - String csvSep = "," - @Shared - Path testBaseFolderPath = Path.of("testBaseFolderPath") // does not have to exist for this test - @Shared - FileNamingStrategy fileNamingStrategy = new FileNamingStrategy() + DummyEntitySource dummyEntitySource = new DummyEntitySource(Mock(CsvDataSource)) + + def "An EntitySource should enrich entity data with a linked entity, if it was provided"() { + given: + Map parameter = [ + "linked_entity" : GridTestData.nodeA.uuid.toString(), + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) - CsvDataSource csvDataSource = new CsvDataSource(csvSep, testBaseFolderPath, fileNamingStrategy) + when: + def result = dummyEntitySource.enrichEntityData(entityData, "linked_entity", entityMap, NodeAssetInputEntityData::new) - DummyEntitySource dummyEntitySource = new DummyEntitySource(csvDataSource) + then: + result == new Try.Success(new NodeAssetInputEntityData(entityData, GridTestData.nodeA)) + } - def "A csv data source is able to find the correct first entity by uuid"() { + def "An EntitySource trying to enrich entity data should fail, if no matching linked entity was provided"() { given: - def uuid = UUID.randomUUID() - def queriedOperator = new OperatorInput(uuid, "b") - def entities = Arrays.asList( - new OperatorInput(UUID.randomUUID(), "a"), - queriedOperator, - new OperatorInput(UUID.randomUUID(), "c") - ) + Map parameter = [ + "linked_entity" : GridTestData.nodeB.uuid.toString(), + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) when: - def actual = dummyEntitySource.findFirstEntityByUuid(uuid, entities) + def result = dummyEntitySource.enrichEntityData(entityData, "linked_entity", entityMap, NodeAssetInputEntityData::new) then: - actual.present - actual.get() == queriedOperator + result.isFailure() + result.getException().get().message.startsWith("Linked linked_entity with UUID 47d29df0-ba2d-4d23-8e75-c82229c5c758 was not found for entity AssetInputEntityData") } - def "A CsvDataSource should always return an operator. Either the found one (if any) or OperatorInput.NO_OPERATOR_ASSIGNED"() { + def "An EntitySource should enrich entity data with two linked entities, if they are provided"() { + given: + Map parameter = [ + "t_bus" : sptd.thermalBus.uuid.toString(), + "t_storage" : sptd.thermalStorage.uuid.toString() + ] + def entityData = new SystemParticipantTypedEntityData(parameter, ChpInput, sptd.participantNode, null, sptd.chpTypeInput) - expect: - dummyEntitySource.getFirstOrDefaultOperator(operators, Optional.of(UUID.fromString(operatorUuid)), entityClassName, requestEntityUuid) == expectedOperator + Map busMap = map([sptd.thermalBus]) + Map storageMap = map([sptd.thermalStorage]) - where: - operatorUuid | operators | entityClassName | requestEntityUuid || expectedOperator - "8f9682df-0744-4b58-a122-f0dc730f6510" | [sptd.hpInput.operator] | "TestEntityClass" | "8f9682df-0744-4b58-a122-f0dc730f6511" || sptd.hpInput.operator - "8f9682df-0744-4b58-a122-f0dc730f6520" | [sptd.hpInput.operator] | "TestEntityClass" | "8f9682df-0744-4b58-a122-f0dc730f6511" || OperatorInput.NO_OPERATOR_ASSIGNED - "8f9682df-0744-4b58-a122-f0dc730f6510" | [] | "TestEntityClass" | "8f9682df-0744-4b58-a122-f0dc730f6511" || OperatorInput.NO_OPERATOR_ASSIGNED + when: + def result = dummyEntitySource.enrichEntityData(entityData, "t_bus", busMap, "t_storage", storageMap, ChpInputEntityData::new) + + then: + result == new Try.Success(new ChpInputEntityData(entityData, sptd.thermalBus, sptd.thermalStorage)) } - def "A CsvDataSource should be able to handle the extraction process of an asset type correctly"() { + def "An EntitySource trying to enrich entity data should fail, if one of two linked entities is not provided"() { + given: + Map parameter = [ + "t_bus" : sptd.thermalBus.uuid.toString(), + "t_storage" : "8851813b-3a7d-4fee-874b-4df9d724e4b4" + ] + def entityData = new SystemParticipantTypedEntityData(parameter, ChpInput, sptd.participantNode, null, sptd.chpTypeInput) + + Map busMap = map([sptd.thermalBus]) + Map storageMap = map([sptd.thermalStorage]) + when: - def assetTypeOpt = dummyEntitySource.getAssetType(types, fieldsToAttributes, "TestClassName") + def result = dummyEntitySource.enrichEntityData(entityData, "t_bus", busMap, "t_storage", storageMap, ChpInputEntityData::new) then: - assetTypeOpt.data.present == resultIsPresent - assetTypeOpt.data.ifPresent({ assetType -> - assert (assetType == resultData) - }) - - where: - types | fieldsToAttributes || resultIsPresent || resultData - [] | ["type": "202069a7-bcf8-422c-837c-273575220c8a"] || false || null - [] | ["bla": "foo"] || false || null - [gtd.transformerTypeBtoD] | ["type": "202069a7-bcf8-422c-837c-273575220c8a"] || true || gtd.transformerTypeBtoD - [sptd.chpTypeInput] | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] || true || sptd.chpTypeInput + result.isFailure() + result.getException().get().message.startsWith("Linked t_storage with UUID 8851813b-3a7d-4fee-874b-4df9d724e4b4 was not found for entity SystemParticipantTypedEntityData") } - def "A CsvDataSource should not throw an exception but assume NO_OPERATOR_ASSIGNED if the operator field is missing in the headline"() { + def "An EntitySource should find a linked entity, if it was provided"() { + given: + Map parameter = [ + "linked_entity" : sptd.emInput.uuid.toString(), + ] + def entityData = new EntityData(parameter, AssetInput) + + Map entityMap = map([sptd.emInput]) + + when: + def result = dummyEntitySource.getLinkedEntity(entityData, "linked_entity", entityMap) + + then: + result == new Try.Success(sptd.emInput) + } + def "An EntitySource trying to find a linked entity should fail, if no matching linked entity was provided"() { given: - def thermalBusInputFieldsToAttributesMap = [ - "uuid" : "0d95d7f2-49fb-4d49-8636-383a5220384e", - "id" : "test_thermalBusInput", - "operatesuntil": "2020-03-25T15:11:31Z[UTC]", - "operatesfrom" : "2020-03-24T15:11:31Z[UTC]" + Map parameter = [ + "linked_entity" : sptd.parentEm.uuid.toString(), ] + def entityData = new EntityData(parameter, AssetInput) + + Map entityMap = map([sptd.emInput]) + + when: + def result = dummyEntitySource.getLinkedEntity(entityData, "linked_entity", entityMap) + + then: + result.isFailure() + result.getException().get().message == "Linked linked_entity with UUID 897bfc17-8e54-43d0-8d98-740786fd94dd was not found for entity EntityData{fieldsToAttributes={linked_entity=897bfc17-8e54-43d0-8d98-740786fd94dd}, targetClass=class edu.ie3.datamodel.models.input.AssetInput}" + } + + def "An EntitySource trying to find a linked entity should fail, if corresponding UUID is malformed"() { + given: + Map parameter = [ + "linked_entity" : "not-a-uuid", + ] + def entityData = new EntityData(parameter, AssetInput) + + Map entityMap = map([sptd.emInput]) + + when: + def result = dummyEntitySource.getLinkedEntity(entityData, "linked_entity", entityMap) + + then: + result.isFailure() + result.getException().get().message == "Extracting UUID field linked_entity from entity data EntityData{fieldsToAttributes={linked_entity=not-a-uuid}, targetClass=class edu.ie3.datamodel.models.input.AssetInput} failed." + } + + def "An EntitySource should optionally enrich entity data with a linked entity, if it was provided"() { + given: + Map parameter = [ + "linked_entity" : GridTestData.nodeA.uuid.toString(), + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) + + when: + def result = dummyEntitySource.optionallyEnrichEntityData(entityData, "linked_entity", entityMap, GridTestData.nodeB, NodeAssetInputEntityData::new) + + then: + result == new Try.Success(new NodeAssetInputEntityData(entityData, GridTestData.nodeA)) + } + + def "An EntitySource should (optionally) enrich entity data with the default entity, if no linked entity is specified"() { + given: + Map parameter = [ + "linked_entity" : "", + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) + + when: + def result = dummyEntitySource.optionallyEnrichEntityData(entityData, "linked_entity", entityMap, GridTestData.nodeB, NodeAssetInputEntityData::new) + + then: + result == new Try.Success(new NodeAssetInputEntityData(entityData, GridTestData.nodeB)) + } + + def "An EntitySource trying to optionally find a linked entity should fail, if no matching linked entity was provided"() { + given: + Map parameter = [ + "linked_entity" : "4ca90220-74c2-4369-9afa-a18bf068840e", + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) + + when: + def result = dummyEntitySource.optionallyEnrichEntityData(entityData, "linked_entity", entityMap, GridTestData.nodeB, NodeAssetInputEntityData::new) + + then: + result.isFailure() + result.getException().get().message.startsWith("Linked linked_entity with UUID 4ca90220-74c2-4369-9afa-a18bf068840e was not found for entity AssetInputEntityData{fieldsToValues={linked_entity=4ca90220-74c2-4369-9afa-a18bf068840e}, targetClass=class edu.ie3.datamodel.models.input.AssetInput") + } + + + def "An EntitySource trying to optionally find a linked entity should fail, if corresponding UUID is malformed"() { + given: + Map parameter = [ + "linked_entity" : "not-a-uuid", + ] + def entityData = new AssetInputEntityData(parameter, AssetInput) + + Map entityMap = map([GridTestData.nodeA]) when: - def thermalBusInputEntity = new ThermalBusInputFactory().get(dummyEntitySource.assetInputEntityDataStream(ThermalBusInput, thermalBusInputFieldsToAttributesMap, Collections.emptyList())) + def result = dummyEntitySource.optionallyEnrichEntityData(entityData, "linked_entity", entityMap, GridTestData.nodeB, NodeAssetInputEntityData::new) then: - noExceptionThrown() // no NPE should be thrown - thermalBusInputEntity.success - thermalBusInputEntity.data.get().operator.id == OperatorInput.NO_OPERATOR_ASSIGNED.id // operator id should be set accordingly + result.isFailure() + result.getException().get().message == "Exception while trying to parse UUID of field \"linked_entity\" with value \"not-a-uuid\"" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy index 0e2e4a8da..bdbe1fea6 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/IdCoordinateSourceMock.groovy @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.io.source +import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.util.geo.CoordinateDistance import org.locationtech.jts.geom.Point import tech.units.indriya.ComparableQuantity @@ -13,6 +14,11 @@ import javax.measure.quantity.Length class IdCoordinateSourceMock implements IdCoordinateSource { + @Override + Optional> getSourceFields() throws SourceException { + return Optional.empty() + } + @Override Optional getCoordinate(int id) { return Optional.empty() diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/SystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/SystemParticipantSourceTest.groovy new file mode 100644 index 000000000..57e7a5566 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/source/SystemParticipantSourceTest.groovy @@ -0,0 +1,121 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.source + +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData +import edu.ie3.datamodel.io.factory.input.participant.ChpInputEntityData +import edu.ie3.datamodel.io.factory.input.participant.HpInputEntityData +import edu.ie3.datamodel.io.factory.input.participant.SystemParticipantEntityData +import edu.ie3.datamodel.io.factory.input.participant.SystemParticipantTypedEntityData +import edu.ie3.datamodel.models.input.system.ChpInput +import edu.ie3.datamodel.models.input.system.HpInput +import edu.ie3.datamodel.models.input.thermal.ThermalBusInput +import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification + +import java.util.stream.Stream + +class SystemParticipantSourceTest extends Specification { + + def "A SystemParticipantSource should build system participant entity from valid and invalid input data as expected"() { + given: + def nodeAssetInputEntityData = Stream.of(new Try.Success<>(new NodeAssetInputEntityData(fieldsToAttributes, ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node))) + + when: + def sysPartEntityDataStream = SystemParticipantSource.systemParticipantEntityStream(nodeAssetInputEntityData, map(emUnits)) + + then: + def element = sysPartEntityDataStream.findFirst().get() + element.success == resultIsPresent + element.data.ifPresent({ + typedEntityData -> + assert (typedEntityData == resultData) + }) + + where: + emUnits | fieldsToAttributes || resultIsPresent || resultData + [] | ["em": "977157f4-25e5-4c72-bf34-440edc778792"] || false || null + [SystemParticipantTestData.emInput] | ["bla": "foo"] || true || new SystemParticipantEntityData(["bla": "foo"], ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, null) + [SystemParticipantTestData.emInput] | [:] || true || new SystemParticipantEntityData([:], ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, null) + [SystemParticipantTestData.emInput] | ["em": "977157f4-25e5-4c72-bf34-440edc778793"] || false || null + [SystemParticipantTestData.emInput] | ["em": "977157f4-25e5-4c72-bf34-440edc778792"] || true || new SystemParticipantEntityData([:], ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, SystemParticipantTestData.emInput) + } + + def "A SystemParticipantSource should build typed entity from valid and invalid input data as expected"() { + given: + def systemParticipantEntityData = Stream.of(new Try.Success<>(new SystemParticipantEntityData(fieldsToAttributes, ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, null))) + + when: + def typedEntityDataStream = SystemParticipantSource.typedSystemParticipantEntityStream(systemParticipantEntityData, map(types)) + + then: + def element = typedEntityDataStream.findFirst().get() + element.success == resultIsPresent + element.data.ifPresent({ + typedEntityData -> + assert (typedEntityData == resultData) + }) + + where: + types | fieldsToAttributes || resultIsPresent || resultData + [] | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] || false || null + [SystemParticipantTestData.chpTypeInput] | ["bla": "foo"] || false || null + [SystemParticipantTestData.chpTypeInput] | [:] || false || null + [SystemParticipantTestData.chpTypeInput] | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb9"] || false || null + [SystemParticipantTestData.chpTypeInput] | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] || true || new SystemParticipantTypedEntityData<>([:], ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, null, SystemParticipantTestData.chpTypeInput) + } + + def "A SystemParticipantSource should build hp input entity from valid and invalid input data as expected"() { + given: + def sysPartTypedEntityData = Stream.of(new Try.Success<>(new SystemParticipantTypedEntityData<>(fieldsToAttributes, HpInput, SystemParticipantTestData.hpInput.operator, SystemParticipantTestData.hpInput.node, SystemParticipantTestData.emInput, SystemParticipantTestData.hpTypeInput))) + + when: + def hpInputEntityDataOpt = SystemParticipantSource.hpEntityStream(sysPartTypedEntityData, map(thermalBuses)) + + then: + def element = hpInputEntityDataOpt.findFirst().get() + element.success == resultIsPresent + element.data.ifPresent({ + hpInputEntityData -> + assert (hpInputEntityData == resultData) + }) + + where: + thermalBuses | fieldsToAttributes || resultIsPresent || resultData + [] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || false || null + [SystemParticipantTestData.hpInput.thermalBus] | ["bla": "foo"] || false || null + [SystemParticipantTestData.hpInput.thermalBus] | [:] || false || null + [SystemParticipantTestData.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384f"] || false || null + [SystemParticipantTestData.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || true || new HpInputEntityData([:], SystemParticipantTestData.hpInput.operator, SystemParticipantTestData.hpInput.node, SystemParticipantTestData.emInput, SystemParticipantTestData.hpTypeInput, SystemParticipantTestData.hpInput.thermalBus) + } + + def "A SystemParticipantSource should build chp input entity from valid and invalid input data as expected"(List thermalStorages, List thermalBuses, Map fieldsToAttributes, boolean resultIsPresent, ChpInputEntityData resultData) { + given: + def sysPartTypedEntityData = Stream.of(new Try.Success<>(new SystemParticipantTypedEntityData<>(fieldsToAttributes, ChpInput, SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, SystemParticipantTestData.emInput, SystemParticipantTestData.chpTypeInput))) + + when: + def hpInputEntityDataOpt = SystemParticipantSource.chpEntityStream(sysPartTypedEntityData, map(thermalStorages), map(thermalBuses)) + + then: + def element = hpInputEntityDataOpt.findFirst().get() + element.success == resultIsPresent + element.data.ifPresent({ + hpInputEntityData -> + assert (hpInputEntityData == resultData) + }) + + where: + thermalStorages | thermalBuses | fieldsToAttributes || resultIsPresent | resultData + [] | [] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || false | null + [SystemParticipantTestData.chpInput.thermalStorage] | [SystemParticipantTestData.chpInput.thermalBus] | ["bla": "foo"] || false | null + [SystemParticipantTestData.chpInput.thermalStorage] | [SystemParticipantTestData.chpInput.thermalBus] | [:] || false | null + [SystemParticipantTestData.chpInput.thermalStorage] | [SystemParticipantTestData.chpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || true | new ChpInputEntityData([:], SystemParticipantTestData.chpInput.operator, SystemParticipantTestData.chpInput.node, SystemParticipantTestData.emInput, SystemParticipantTestData.chpTypeInput, SystemParticipantTestData.chpInput.thermalBus, SystemParticipantTestData.chpInput.thermalStorage) + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/ThermalSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/ThermalSourceTest.groovy new file mode 100644 index 000000000..224773490 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/source/ThermalSourceTest.groovy @@ -0,0 +1,62 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.source + +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.io.factory.input.AssetInputEntityData +import edu.ie3.datamodel.io.factory.input.ThermalUnitInputEntityData +import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.thermal.ThermalBusInput +import edu.ie3.datamodel.models.input.thermal.ThermalUnitInput +import edu.ie3.datamodel.utils.Try +import spock.lang.Specification + +import java.util.stream.Collectors +import java.util.stream.Stream + +class ThermalSourceTest extends Specification { + + def "A ThermalSource should build thermal unit input entity from valid and invalid input data as expected"() { + given: + def operator = new OperatorInput(UUID.fromString("8f9682df-0744-4b58-a122-f0dc730f6510"), "testOperator") + def validFieldsToAttributes = [ + "uuid" : "717af017-cc69-406f-b452-e022d7fb516a", + "id" : "test_thermal_unit", + "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", + "operatesFrom" : "2020-03-24 15:11:31", + "operatesUntil" : "2020-03-25 15:11:31", + "thermalBus" : "0d95d7f2-49fb-4d49-8636-383a5220384e" + ] + def assetInputEntityData = Stream.of(new Try.Success(new AssetInputEntityData(validFieldsToAttributes, ThermalUnitInput, operator))) + + when: + def resultingDataOpt = ThermalSource.thermalUnitInputEntityDataStream(assetInputEntityData, map(thermalBuses)).collect(Collectors.toList()) + + then: + resultingDataOpt.size() == 1 + resultingDataOpt.first().data.present == resultIsPresent + resultingDataOpt.first().data.ifPresent({ resultingData -> + assert (resultingData == expectedThermalUnitInputEntityData) + }) + + where: + thermalBuses || resultIsPresent | expectedThermalUnitInputEntityData + [] || false | null // thermal buses are not present -> method should return an empty optional -> do not check for thermal unit entity data + [ + new ThermalBusInput(UUID.fromString("0d95d7f2-49fb-4d49-8636-383a5220384e"), "test_thermal_bus") + ] || true | + new ThermalUnitInputEntityData([ + "uuid" : "717af017-cc69-406f-b452-e022d7fb516a", + "id" : "test_thermal_unit", + "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", + "operatesFrom" : "2020-03-24 15:11:31", + "operatesUntil": "2020-03-25 15:11:31"], + ThermalUnitInput, + new OperatorInput(UUID.fromString("8f9682df-0744-4b58-a122-f0dc730f6510"), "testOperator"), + new ThermalBusInput(UUID.fromString("0d95d7f2-49fb-4d49-8636-383a5220384e"), "test_thermal_bus")) + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceTest.groovy index e6c58dd97..732836e94 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceTest.groovy @@ -8,8 +8,8 @@ package edu.ie3.datamodel.io.source.csv import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.models.UniqueEntity import edu.ie3.datamodel.models.input.NodeInput +import edu.ie3.datamodel.models.input.system.LoadInput import edu.ie3.test.common.SystemParticipantTestData as sptd - import spock.lang.Shared import spock.lang.Specification @@ -19,7 +19,7 @@ import java.util.concurrent.atomic.LongAdder import java.util.function.Function import java.util.stream.Collectors -class CsvDataSourceTest extends Specification { +class CsvDataSourceTest extends Specification implements CsvTestDataMeta { @Shared Function, String> uuidExtractor = { fieldToValues -> fieldToValues.get("uuid") } @@ -67,11 +67,41 @@ class CsvDataSourceTest extends Specification { def "A DataSource should contain a valid connector after initialization"() { expect: dummyCsvSource.connector != null - dummyCsvSource.connector.baseDirectoryName == testBaseFolderPath + dummyCsvSource.connector.baseDirectory == testBaseFolderPath dummyCsvSource.connector.fileNamingStrategy == fileNamingStrategy dummyCsvSource.connector.entityWriters.isEmpty() } + def "A CsvDataSource should return column names from a valid CSV file as expected"() { + given: + DummyCsvSource source = new DummyCsvSource(csvSep, participantsFolderPath, fileNamingStrategy) + + expect: + source.getSourceFields(LoadInput).get() == [ + "operates_from", + "node", + "s_rated", + "cos_phi_rated", + "load_profile", + "id", + "operates_until", + "uuid", + "q_characteristics", + "e_cons_annual", + "operator", + "dsm", + "em" + ] as Set + } + + def "A CsvDataSource should return an empty result when retrieving column names for a non-existing CSV file"() { + given: + def path = Path.of("this/path/does-not-exist") + + expect: + dummyCsvSource.getSourceFields(path).isEmpty() + } + def "A CsvDataSource should build a valid fields to attributes map with valid data as expected"() { given: def validHeadline = [ @@ -397,7 +427,7 @@ class CsvDataSourceTest extends Specification { when: def allRows = [nodeInputRow]* noOfEntities - def distinctRows = dummyCsvSource.distinctRowsWithLog(allRows, uuidExtractor, NodeInput.simpleName, "UUID") + def distinctRows = dummyCsvSource.distinctRowsWithLog(allRows, uuidExtractor, NodeInput.simpleName, "UUID").getOrThrow() then: distinctRows.size() == distinctSize @@ -419,7 +449,7 @@ class CsvDataSourceTest extends Specification { "v_rated" : "380"] } - def "A CsvDataSource should return an empty set of csv row mappings if the provided collection of mappings contains duplicated UUIDs with different data"() { + def "A CsvDataSource should return a failure if the provided collection of mappings contains duplicated UUIDs with different data"() { given: def nodeInputRow1 = [ @@ -454,6 +484,7 @@ class CsvDataSourceTest extends Specification { def distinctRows = dummyCsvSource.distinctRowsWithLog(allRows, uuidExtractor, NodeInput.simpleName, "UUID") then: - distinctRows.size() == 0 + distinctRows.failure + distinctRows.exception.get().message == "'NodeInput' entities with duplicated UUID key, but different field values found! Please review the corresponding input file! Affected primary keys: 4ca90220-74c2-4369-9afa-a18bf068840d" } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy new file mode 100644 index 000000000..7f5cb7124 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvEnergyManagementSourceTest.groovy @@ -0,0 +1,35 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.io.source.csv + +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.exceptions.SourceException +import edu.ie3.datamodel.io.source.EnergyManagementSource +import edu.ie3.datamodel.io.source.TypeSource +import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.utils.Try +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification + +class CsvEnergyManagementSourceTest extends Specification implements CsvTestDataMeta { + + def "An EnergyManagementSource with csv input should return data from valid em input file as expected"() { + given: + def csvEnergyManagementSource = new EnergyManagementSource( + Mock(TypeSource), + new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + + Map operatorMap = map([SystemParticipantTestData.emInput.operator]) + + expect: + def emUnits = Try.of(() -> csvEnergyManagementSource.getEmUnits(operatorMap), SourceException) + + emUnits.success + emUnits.data.get().size() == 2 + emUnits.data.get() == map([SystemParticipantTestData.emInput, SystemParticipantTestData.parentEm]) + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvGraphicSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvGraphicSourceTest.groovy index 38f15b346..05677834b 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvGraphicSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvGraphicSourceTest.groovy @@ -5,14 +5,16 @@ */ package edu.ie3.datamodel.io.source.csv +import static edu.ie3.test.helper.EntityMap.map + +import edu.ie3.datamodel.exceptions.FailureException import edu.ie3.datamodel.exceptions.SourceException -import edu.ie3.datamodel.io.factory.input.graphics.LineGraphicInputEntityData -import edu.ie3.datamodel.io.factory.input.graphics.NodeGraphicInputEntityData import edu.ie3.datamodel.io.source.GraphicSource import edu.ie3.datamodel.io.source.RawGridSource import edu.ie3.datamodel.io.source.TypeSource import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput +import edu.ie3.datamodel.models.input.connector.LineInput import edu.ie3.datamodel.models.input.graphics.NodeGraphicInput import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.GridTestData as gtd @@ -22,15 +24,14 @@ import spock.lang.Specification class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta { - def "A CsvGraphicSource should provide an instance of GraphicElements based on valid input data correctly"() { given: def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy)) def rawGridSource = new RawGridSource(typeSource, new CsvDataSource(csvSep, gridDefaultFolderPath, fileNamingStrategy)) - def csvGraphicSource = new GraphicSource(typeSource, rawGridSource, new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) + def graphicSource = new GraphicSource(typeSource, rawGridSource, new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) when: - def graphicElements = csvGraphicSource.graphicElements + def graphicElements = graphicSource.graphicElements then: graphicElements.allEntitiesAsList().size() == 3 @@ -44,20 +45,20 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta { def rawGridSource = new RawGridSource(typeSource, new CsvDataSource(csvSep, gridDefaultFolderPath, fileNamingStrategy)) { @Override - Set getNodes() { - return Collections.emptySet() + Map getNodes() { + return Collections.emptyMap() } @Override - Set getNodes(Set operators) { - return Collections.emptySet() + Map getNodes(Map operators) { + return Collections.emptyMap() } } - def csvGraphicSource = new GraphicSource(typeSource, rawGridSource, new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) + def graphicSource = new GraphicSource(typeSource, rawGridSource, new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) when: - def graphicElements = Try.of(() -> csvGraphicSource.graphicElements, SourceException) + def graphicElements = Try.of(() -> graphicSource.graphicElements, SourceException) then: graphicElements.failure @@ -65,13 +66,13 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta { Exception ex = graphicElements.exception.get() ex.class == SourceException - ex.message.startsWith("edu.ie3.datamodel.exceptions.FailureException: 2 exception(s) occurred within \"LineInput\" data, one is: edu.ie3.datamodel.exceptions.FactoryException: edu.ie3.datamodel.exceptions.SourceException: Failure due to: Skipping LineInput with uuid") + ex.message.startsWith("edu.ie3.datamodel.exceptions.FailureException: 2 exception(s) occurred within \"LineInput\" data, one is: edu.ie3.datamodel.exceptions.FactoryException: edu.ie3.datamodel.exceptions.SourceException: Linked nodeA with UUID 4ca90220-74c2-4369-9afa-a18bf068840d was not found for entity") } def "A CsvGraphicSource should read and handle a valid node graphics file as expected"() { given: - def csvGraphicSource = new GraphicSource( + def graphicSource = new GraphicSource( Mock(TypeSource), Mock(RawGridSource), new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) @@ -90,8 +91,13 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta { gtd.nodeGraphicC.point ) + Map nodeMap = [ + (gtd.nodeC.getUuid()) : gtd.nodeC, + (gtd.nodeD.getUuid()) : gtd.nodeD + ] + when: - def nodeGraphics = csvGraphicSource.getNodeGraphicInput([gtd.nodeC, gtd.nodeD] as Set) + def nodeGraphics = graphicSource.getNodeGraphicInput(nodeMap) then: nodeGraphics.size() == 2 @@ -101,91 +107,68 @@ class CsvGraphicSourceTest extends Specification implements CsvTestDataMeta { ] as Set } - def "A CsvGraphicSource should read and handle a valid line graphics file as expected"() { + def "A GraphicSource should read and handle a valid line graphics file as expected"() { given: - def csvGraphicSource = new GraphicSource( + def graphicSource = new GraphicSource( Mock(TypeSource), Mock(RawGridSource), new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) + Map lineMap = [ + (gtd.lineCtoD.getUuid()) : gtd.lineCtoD + ] + when: - def lineGraphics = csvGraphicSource.getLineGraphicInput([gtd.lineCtoD] as Set) + def lineGraphics = graphicSource.getLineGraphicInput(lineMap) then: lineGraphics.size() == 1 lineGraphics.first() == gtd.lineGraphicCtoD } - def "A CsvGraphicSource should build node graphic entity data from valid and invalid input data correctly"() { + def "A GraphicSource when building node graphic data should fail when required node data is not provided"() { given: - def csvGraphicSource = new GraphicSource( + def graphicSource = new GraphicSource( Mock(TypeSource), Mock(RawGridSource), new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) - def fieldsToAttributesMap = [ - "uuid" : "09aec636-791b-45aa-b981-b14edf171c4c", - "graphic_layer": "main", - "node" : "bd837a25-58f3-44ac-aa90-c6b6e3cd91b2", - "path" : "", - "point" : "{\"type\":\"Point\",\"coordinates\":[0.0,10],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}" - ] + Map nodeMap = map(nodeCollection) - expect: - def res = csvGraphicSource.buildNodeGraphicEntityData(fieldsToAttributesMap, nodeCollection as Set) - res.success == isPresent - - if (isPresent) { - def value = res.data.get() + when: + graphicSource.getNodeGraphicInput(nodeMap) - assert value == new NodeGraphicInputEntityData([ - "uuid" : "09aec636-791b-45aa-b981-b14edf171c4c", - "graphic_layer": "main", - "path" : "", - "point" : "{\"type\":\"Point\",\"coordinates\":[0.0,10],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}" - ], gtd.nodeC) - assert value.node == gtd.nodeC - } + then: + def e = thrown(SourceException) + e.cause.class == FailureException + e.cause.message.startsWith(expectedFailures + " exception(s) occurred") where: - nodeCollection || isPresent - []|| false // no nodes provide - [gtd.nodeA, gtd.nodeB]|| false // node cannot be found - [gtd.nodeC]|| true // node found + nodeCollection || expectedFailures + [] || 2 // no nodes provided + [gtd.nodeA, gtd.nodeB] || 2 // wrongs nodes provided + [gtd.nodeC] || 1 // one node provided + [gtd.nodeD] || 1 // one node provided } - def "A CsvGraphicSource should build line graphic entity data from valid and invalid input data correctly"() { + def "A GraphicSource when building line graphic data should fail when required line data is not provided"() { given: - def csvGraphicSource = new GraphicSource( + def graphicSource = new GraphicSource( Mock(TypeSource), Mock(RawGridSource), new CsvDataSource(csvSep, graphicsFolderPath, fileNamingStrategy)) - def fieldsToAttributesMap = [ - "uuid" : "ece86139-3238-4a35-9361-457ecb4258b0", - "graphic_layer": "main", - "line" : "92ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "path" : "{\"type\":\"LineString\",\"coordinates\":[[0.0,0.0],[0.0,10]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}" - ] - - expect: - def res = csvGraphicSource.buildLineGraphicEntityData(fieldsToAttributesMap, nodeCollection as Set) - res.success == isPresent + Map lineMap = map(lineCollection) - if (isPresent) { - def value = res.data.get() - - assert value == new LineGraphicInputEntityData(["uuid" : "ece86139-3238-4a35-9361-457ecb4258b0", - "graphic_layer": "main", - "path" : "{\"type\":\"LineString\",\"coordinates\":[[0.0,0.0],[0.0,10]],\"crs\":{\"type\":\"name\",\"properties\":{\"name\":\"EPSG:4326\"}}}" - ] - , gtd.lineAtoB) - assert value.line == gtd.lineAtoB - } + when: + graphicSource.getLineGraphicInput(lineMap) + then: + def e = thrown(SourceException) + e.cause.class == FailureException + e.cause.message.startsWith(expectedFailures + " exception(s) occurred") where: - nodeCollection || isPresent - []|| false // no nodes provide - [gtd.lineCtoD]|| false // line cannot be found - [gtd.lineAtoB]|| true // line found + lineCollection || expectedFailures + [] || 1 // no lines provided + [gtd.lineAtoB] || 1 // line cannot be found } } \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy index 0a295421c..b878d2b28 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceCosmoIT.groovy @@ -36,7 +36,24 @@ class CsvIdCoordinateSourceCosmoIT extends Specification implements CsvTestDataM def actualStream = source.buildStreamWithFieldsToAttributesMap() then: - actualStream.collect(Collectors.toList()).containsAll(expectedStream.collect(Collectors.toList())) + actualStream.success + actualStream.data.get().collect(Collectors.toList()).containsAll(expectedStream.collect(Collectors.toList())) + } + + def "The CsvCoordinateSource is able to return the source fields from a coordinate file"() { + when: + def sourceFields = source.sourceFields + + then: + sourceFields.present + sourceFields.get() == [ + "id", + "lat_geo", + "lat_rot", + "long_geo", + "long_rot", + "tid" + ] as Set } def "The CsvIdCoordinateSource is able to look up a specific point or an empty Optional otherwise" () { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy index 484d3a4ba..869c9d882 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvIdCoordinateSourceIconIT.groovy @@ -37,7 +37,8 @@ class CsvIdCoordinateSourceIconIT extends Specification implements CsvTestDataMe def actualStream = source.buildStreamWithFieldsToAttributesMap() then: - actualStream.collect(Collectors.toList()).containsAll(expectedStream.collect(Collectors.toList())) + actualStream.success + actualStream.data.get().collect(Collectors.toList()).containsAll(expectedStream.collect(Collectors.toList())) } def "The CsvIdCoordinateSource is able to look up a specific point or an empty Optional otherwise" () { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy index 5049b4bb7..876b73160 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvRawGridSourceTest.groovy @@ -5,6 +5,8 @@ */ package edu.ie3.datamodel.io.source.csv +import static edu.ie3.test.helper.EntityMap.map + import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.io.factory.input.AssetInputEntityData import edu.ie3.datamodel.io.factory.input.ConnectorInputEntityData @@ -56,20 +58,22 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { "closed" : "true" ] - def validAssetEntityInputData = new AssetInputEntityData(fieldsToAttributes, SwitchInput) + def validAssetEntityInputData = Stream.of(Try.Success.of(new AssetInputEntityData(fieldsToAttributes, SwitchInput))) - def nodes = [rgtd.nodeA, rgtd.nodeB] + def nodes = map([rgtd.nodeA, rgtd.nodeB]) when: "the source tries to convert it" - def connectorDataOption = source.buildUntypedConnectorInputEntityData(validAssetEntityInputData, nodes) + def connectorDataOption = source.untypedConnectorEntityDataStream(validAssetEntityInputData, nodes) then: "everything is fine" - connectorDataOption.success - connectorDataOption.data.get().with { - assert fieldsToValues == expectedFieldsToAttributes - assert targetClass == SwitchInput - assert nodeA == rgtd.nodeA - assert nodeB == rgtd.nodeB + connectorDataOption.forEach { actualTry -> + assert actualTry.isSuccess() + actualTry.data.get().with { + assert fieldsToValues == expectedFieldsToAttributes + assert targetClass == SwitchInput + assert nodeA == rgtd.nodeA + assert nodeB == rgtd.nodeB + } } } @@ -86,22 +90,22 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { "closed" : "true" ] - def validAssetEntityInputData = new AssetInputEntityData(fieldsToAttributes, SwitchInput) + def validAssetEntityInputData = Stream.of(Try.Success.of(new AssetInputEntityData(fieldsToAttributes, SwitchInput))) - def nodes = [rgtd.nodeA, rgtd.nodeB] + def nodes = map([rgtd.nodeA, rgtd.nodeB]) when: "the source tries to convert it" - def connectorDataOption = source.buildUntypedConnectorInputEntityData(validAssetEntityInputData, nodes) + def connectorDataOption = source.untypedConnectorEntityDataStream(validAssetEntityInputData, nodes) - then: "it returns en empty Optional" - connectorDataOption.failure + then: "it returns a Failure" + connectorDataOption.allMatch(Try::isFailure) } def "The CsvRawGridSource is able to convert a stream of valid AssetInputEntityData to ConnectorInputEntityData"() { given: "valid input data" def validStream = Stream.of( - new AssetInputEntityData([ + Try.Success.of(new AssetInputEntityData([ "uuid" : "5dc88077-aeb6-4711-9142-db57287640b1", "id" : "test_switch_AtoB", "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", @@ -110,8 +114,8 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { "nodeA" : "4ca90220-74c2-4369-9afa-a18bf068840d", "nodeB" : "47d29df0-ba2d-4d23-8e75-c82229c5c758", "closed" : "true" - ], SwitchInput), - new AssetInputEntityData([ + ], SwitchInput)), + Try.Success.of(new AssetInputEntityData([ "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", "id" : "test_lineCtoD", "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", @@ -126,7 +130,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { "olmCharacteristic" : "olm:{(0.0,1.0)}" ], LineInput) - ) + )) def expectedSet = [ new ConnectorInputEntityData([ @@ -159,145 +163,27 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { ) ] as Set - def nodes = [ + def nodes = map([ rgtd.nodeA, rgtd.nodeB, rgtd.nodeC, rgtd.nodeD - ] + ]) when: "the source tries to convert it" - def actualSet = source.buildUntypedConnectorInputEntityData(validStream, nodes).collect(Collectors.toSet()) + def actualSet = source.untypedConnectorEntityDataStream(validStream, nodes).collect(Collectors.toSet()) then: "everything is fine" actualSet.size() == expectedSet.size() - actualSet.every { - it.success - } - - actualSet.stream().map { it.data.get() }.toList().containsAll(expectedSet) - } - - def "The CsvRawGridSource is able to add a type to untyped ConnectorInputEntityData correctly"() { - given: "valid input data" - def validConnectorEntityData = new ConnectorInputEntityData([ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "test_lineCtoD", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "2", - "type" : "3bed3eb3-9790-4874-89b5-a5434d408088", - "length" : "0.003", - "geoPosition" : "{ \"type\": \"LineString\", \"coordinates\": [[7.411111, 51.492528], [7.414116, 51.484136]]}", - "olmCharacteristic" : "olm:{(0.0,1.0)}" - ], - LineInput, - rgtd.nodeC, - rgtd.nodeD - ) - - def expectedTypedEntityData = new TypedConnectorInputEntityData([ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "test_lineCtoD", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "2", - "length" : "0.003", - "geoPosition" : "{ \"type\": \"LineString\", \"coordinates\": [[7.411111, 51.492528], [7.414116, 51.484136]]}", - "olmCharacteristic" : "olm:{(0.0,1.0)}" - ], - LineInput, - rgtd.nodeC, - rgtd.nodeD, - rgtd.lineTypeInputCtoD - ) - - when: "the source tries to convert it" - def actual = source.addTypeToEntityData(validConnectorEntityData, rgtd.lineTypeInputCtoD) - - then: "everything is fine" - actual == expectedTypedEntityData - } - - def "The CsvRawGridSource is able to find and add a type to untyped ConnectorInputEntityData correctly"() { - given: "valid input data" - def validConnectorEntityData = new ConnectorInputEntityData([ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "test_lineCtoD", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "2", - "type" : "3bed3eb3-9790-4874-89b5-a5434d408088", - "length" : "0.003", - "geoPosition" : "{ \"type\": \"LineString\", \"coordinates\": [[7.411111, 51.492528], [7.414116, 51.484136]]}", - "olmCharacteristic" : "olm:{(0.0,1.0)}" - ], - LineInput, - rgtd.nodeC, - rgtd.nodeD - ) - - def expectedTypedEntityData = new TypedConnectorInputEntityData([ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "test_lineCtoD", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "2", - "length" : "0.003", - "geoPosition" : "{ \"type\": \"LineString\", \"coordinates\": [[7.411111, 51.492528], [7.414116, 51.484136]]}", - "olmCharacteristic" : "olm:{(0.0,1.0)}" - ], - LineInput, - rgtd.nodeC, - rgtd.nodeD, - rgtd.lineTypeInputCtoD - ) - - def availableTypes = [rgtd.lineTypeInputCtoD] - - when: "the source tries to convert it" - def actual = source.findAndAddType(validConnectorEntityData, availableTypes) - - then: "everything is fine" - actual.success - actual.data.get() == expectedTypedEntityData - } - - def "The CsvRawGridSource is able to identify ConnectorInputEntityData data with non matching type requirements correctly"() { - given: "valid input data" - def validConnectorEntityData = new ConnectorInputEntityData([ - "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", - "id" : "test_lineCtoD", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "2", - "type" : "fd5b128d-ed35-4355-94b6-7518c55425fe", - "length" : "0.003", - "geoPosition" : "{ \"type\": \"LineString\", \"coordinates\": [[7.411111, 51.492528], [7.414116, 51.484136]]}", - "olmCharacteristic" : "olm:{(0.0,1.0)}" - ], - LineInput, - rgtd.nodeC, - rgtd.nodeD - ) - - def availableTypes = [rgtd.lineTypeInputCtoD] + def result = Try.scanCollection(actualSet, List) - when: "the source tries to convert it" - def actual = source.findAndAddType(validConnectorEntityData, availableTypes) - - then: "everything is fine" - actual.failure + result.success + result.data.get().toList().containsAll(expectedSet) } def "The CsvRawGridSource is able to convert a stream of valid ConnectorInputEntityData to TypedConnectorInputEntityData"() { given: "valid input data" - def validStream = Stream.of(new Try.Success<>( + def validStream = Stream.of(Try.Success.of( new ConnectorInputEntityData([ "uuid" : "91ec3bcf-1777-4d38-af67-0bf7c9fa73c7", "id" : "test_lineCtoD", @@ -314,7 +200,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { rgtd.nodeC, rgtd.nodeD )), - new Try.Success<>(new ConnectorInputEntityData([ + Try.Success.of(new ConnectorInputEntityData([ "uuid" : "92ec3bcf-1777-4d38-af67-0bf7c9fa73c7", "id" : "test_line_AtoB", "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", @@ -364,98 +250,17 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { ) ] - def availableTypes = [rgtd.lineTypeInputCtoD] + def availableTypes = map([rgtd.lineTypeInputCtoD]) when: "the source tries to convert it" - def actualSet = source.buildTypedConnectorEntityData(validStream, availableTypes).collect(Collectors.toSet()) + def actualSet = source.typedConnectorEntityDataStream(validStream, availableTypes).collect(Collectors.toSet()) then: "everything is fine" actualSet.size() == expectedSet.size() - actualSet.every { - it.success - } - actualSet.stream().map { - it.data.get() - }.toList().containsAll(expectedSet) - } - - def "The CsvRawGridSource is able to add the third node for a three winding transformer correctly"() { - given: "valid input data" - def typedEntityData = new TypedConnectorInputEntityData([ - "uuid" : "cc327469-7d56-472b-a0df-edbb64f90e8f", - "id" : "3w_test", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "nodeC" : "bd837a25-58f3-44ac-aa90-c6b6e3cd91b2", - "parallelDevices" : "1", - "tapPos" : "0", - "autoTap" : "true" - ], - Transformer3WInput, - rgtd.nodeA, - rgtd.nodeB, - rgtd.transformerTypeAtoBtoC) - - def expected = new Transformer3WInputEntityData([ - "uuid" : "cc327469-7d56-472b-a0df-edbb64f90e8f", - "id" : "3w_test", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "parallelDevices" : "1", - "tapPos" : "0", - "autoTap" : "true" - ], - Transformer3WInput, - rgtd.nodeA, - rgtd.nodeB, - rgtd.nodeC, - rgtd.transformerTypeAtoBtoC) - - def availableNodes = [ - rgtd.nodeA, - rgtd.nodeB, - rgtd.nodeC - ] + def result = Try.scanCollection(actualSet, List) - when: "the sources tries to add the node" - def actual = source.addThirdNode(typedEntityData, availableNodes) - - then: "everything is fine" - actual.success - actual.data.get() == expected - } - - def "The CsvRawGridSource is NOT able to add the third node for a three winding transformer, if it is not available"() { - given: "valid input data" - def typedEntityData = new TypedConnectorInputEntityData([ - "uuid" : "cc327469-7d56-472b-a0df-edbb64f90e8f", - "id" : "3w_test", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-24 15:11:31", - "nodeC" : "bd8927b4-0ca9-4dd3-b645-468e6e433160", - "parallelDevices" : "1", - "tapPos" : "0", - "autoTap" : "true" - ], - Transformer3WInput, - rgtd.nodeA, - rgtd.nodeB, - rgtd.transformerTypeAtoBtoC) - - def availableNodes = [ - rgtd.nodeA, - rgtd.nodeB, - rgtd.nodeC - ] - - when: "the sources tries to add the node" - def actual = source.addThirdNode(typedEntityData, availableNodes) - - then: "everything is fine" - actual.failure + result.success + result.data.get().toList().containsAll(expectedSet) } def "The CsvRawGridSource is able to add the third node for a three winding transformer to a stream of candidates"() { @@ -491,11 +296,11 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { rgtd.nodeB, rgtd.transformerTypeAtoBtoC), SourceException)) - def availableNodes = [ + def availableNodes = map([ rgtd.nodeA, rgtd.nodeB, rgtd.nodeC - ] + ]) def expected = new Transformer3WInputEntityData([ "uuid" : "cc327469-7d56-472b-a0df-edbb64f90e8f", @@ -514,7 +319,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { rgtd.transformerTypeAtoBtoC) when: "the sources tries to add nodes" - def actualSet = source.buildTransformer3WEntityData(inputStream, availableNodes).collect(Collectors.toSet()) + def actualSet = source.transformer3WEntityDataStream(inputStream, availableNodes).collect(Collectors.toSet()) def successes = actualSet.stream().filter { it.success }.toList() @@ -544,8 +349,11 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "all nodes are there" actualSet.size() == expectedSet.size() - actualSet.each {actual -> - def expected = expectedSet.find {it.uuid == actual.uuid} + actualSet.each { entry -> + def actual = entry.value + def expected = expectedSet.find { + it.uuid == actual.uuid + } assert expected != null actual.with { @@ -622,7 +430,8 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "all lines are there" actualSet.size() == expectedSet.size() - actualSet.each {actual -> + actualSet.each { entry -> + def actual = entry.value def expected = expectedSet.find {it.uuid == actual.uuid} assert expected != null @@ -739,7 +548,7 @@ class CsvRawGridSourceTest extends Specification implements CsvTestDataMeta { then: "all elements are there" actual != null actual.with { - /* It's okay, to only test the uuids, because content is tested with the other test mehtods */ + /* It's okay, to only test the uuids, because content is tested with the other test methods */ assert nodes.size() == expected.nodes.size() assert nodes.each {entry -> expected.nodes.contains({it.uuid == entry.uuid})} assert lines.size() == expected.lines.size() diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvResultEntitySourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvResultEntitySourceTest.groovy index 65692269d..3ccbd5105 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvResultEntitySourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvResultEntitySourceTest.groovy @@ -6,9 +6,8 @@ package edu.ie3.datamodel.io.source.csv import edu.ie3.datamodel.io.source.ResultEntitySource -import spock.lang.Specification - import edu.ie3.test.common.ResultEntityTestData as retd +import spock.lang.Specification class CsvResultEntitySourceTest extends Specification implements CsvTestDataMeta { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy index 43b2764a2..91486c5eb 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvSystemParticipantSourceTest.groovy @@ -5,52 +5,37 @@ */ package edu.ie3.datamodel.io.source.csv +import static edu.ie3.test.helper.EntityMap.map + import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.exceptions.SystemParticipantsException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData -import edu.ie3.datamodel.io.factory.input.participant.ChpInputEntityData -import edu.ie3.datamodel.io.factory.input.participant.HpInputEntityData -import edu.ie3.datamodel.io.factory.input.participant.SystemParticipantTypedEntityData -import edu.ie3.datamodel.io.source.RawGridSource -import edu.ie3.datamodel.io.source.SystemParticipantSource -import edu.ie3.datamodel.io.source.ThermalSource -import edu.ie3.datamodel.io.source.TypeSource -import edu.ie3.datamodel.models.input.NodeInput +import edu.ie3.datamodel.io.source.* import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.system.BmInput -import edu.ie3.datamodel.models.input.system.ChpInput -import edu.ie3.datamodel.models.input.system.EvInput -import edu.ie3.datamodel.models.input.system.EvcsInput -import edu.ie3.datamodel.models.input.system.FixedFeedInInput -import edu.ie3.datamodel.models.input.system.HpInput -import edu.ie3.datamodel.models.input.system.LoadInput -import edu.ie3.datamodel.models.input.system.PvInput -import edu.ie3.datamodel.models.input.system.StorageInput -import edu.ie3.datamodel.models.input.system.WecInput -import edu.ie3.datamodel.models.input.thermal.ThermalBusInput -import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput +import edu.ie3.datamodel.models.input.system.* import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData as sptd import spock.lang.Specification class CsvSystemParticipantSourceTest extends Specification implements CsvTestDataMeta { - def "A CsvSystemParticipantSource should provide an instance of SystemParticipants based on valid input data correctly"() { + def "A SystemParticipantSource with csv input should provide an instance of SystemParticipants based on valid input data correctly"() { given: def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy)) def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) def rawGridSource = new RawGridSource(typeSource, new CsvDataSource(csvSep, gridDefaultFolderPath, fileNamingStrategy)) + def energyManagementSource = new EnergyManagementSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) def csvSystemParticipantSource = new SystemParticipantSource( typeSource, thermalSource, rawGridSource, + energyManagementSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) when: def systemParticipants = csvSystemParticipantSource.systemParticipants then: - systemParticipants.allEntitiesAsList().size() == 11 + systemParticipants.allEntitiesAsList().size() == 10 systemParticipants.pvPlants.first().uuid == sptd.pvInput.uuid systemParticipants.bmPlants.first().uuid == sptd.bmInput.uuid systemParticipants.chpPlants.first().uuid == sptd.chpInput.uuid @@ -60,11 +45,10 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat systemParticipants.loads.first().uuid == sptd.loadInput.uuid systemParticipants.wecPlants.first().uuid == sptd.wecInput.uuid systemParticipants.storages.first().uuid == sptd.storageInput.uuid - systemParticipants.evCS.first().uuid == sptd.evcsInput.uuid - systemParticipants.emSystems.first().uuid == sptd.emInput.uuid + systemParticipants.evcs.first().uuid == sptd.evcsInput.uuid } - def "A CsvSystemParticipantSource should process invalid input data as expected when requested to provide an instance of SystemParticipants"() { + def "A SystemParticipantSource with csv input should process invalid input data as expected when requested to provide an instance of SystemParticipants"() { given: def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, fileNamingStrategy)) def thermalSource = new ThermalSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) @@ -74,13 +58,15 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat ]) { // partly fake the return method of the csv raw grid source to always return empty node sets // -> elements to build NodeGraphicInputs are missing - getNodes() >> new HashSet() - getNodes(_) >> new HashSet() + getNodes() >> [:] + getNodes(_) >> [:] } as RawGridSource + def energyManagementSource = new EnergyManagementSource(typeSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) def csvSystemParticipantSource = new SystemParticipantSource( typeSource, thermalSource, rawGridSource, + energyManagementSource, new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) when: @@ -92,419 +78,306 @@ class CsvSystemParticipantSourceTest extends Specification implements CsvTestDat Exception ex = systemParticipants.exception.get() ex.class == SystemParticipantsException - ex.message.startsWith("11 error(s) occurred while initializing system participants. " + + ex.message.startsWith("10 error(s) occurred while initializing system participants. " + "edu.ie3.datamodel.exceptions.FailureException: 1 exception(s) occurred within \"FixedFeedInInput\" data, one is: " + "edu.ie3.datamodel.exceptions.FactoryException: edu.ie3.datamodel.exceptions.SourceException: " + - "Failure due to: Skipping FixedFeedInInput with uuid ") + "Linked node with UUID 4ca90220-74c2-4369-9afa-a18bf068840d was not found for entity AssetInputEntityData") } - def "A CsvSystemParticipantSource should build typed entity from valid and invalid input data as expected"() { + def "A SystemParticipantSource with csv input should return data from valid input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def operatorMap = map([sptd.operator]) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) + def thermalBusMap = map([sptd.thermalBus]) + def thermalStorageMap = map([sptd.thermalStorage]) - def nodeAssetInputEntityData = new NodeAssetInputEntityData(fieldsToAttributes, clazz, operator, node) - - when: - def typedEntityDataOpt = csvSystemParticipantSource.buildTypedEntityData(nodeAssetInputEntityData, types) - - then: - typedEntityDataOpt.success == resultIsPresent - typedEntityDataOpt.data.ifPresent({ typedEntityData -> - assert (typedEntityData == resultData) - }) - - where: - types | node | operator | fieldsToAttributes | clazz || resultIsPresent || resultData - []| sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] | ChpInput || false || null - [sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["bla": "foo"] | ChpInput || false || null - [sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | [:] | ChpInput || false || null - [sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb9"] | ChpInput || false || null - [sptd.chpTypeInput] | sptd.chpInput.node | sptd.chpInput.operator | ["type": "5ebd8f7e-dedb-4017-bb86-6373c4b68eb8"] | ChpInput || true || new SystemParticipantTypedEntityData<>([:], clazz, operator, node, sptd.chpTypeInput) - } - - def "A CsvSystemParticipantSource should build hp input entity from valid and invalid input data as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) - - def sysPartTypedEntityData = new SystemParticipantTypedEntityData<>(fieldsToAttributes, HpInput, sptd.hpInput.operator, sptd.hpInput.node, sptd.hpTypeInput) - - when: - def hpInputEntityDataOpt = csvSystemParticipantSource.buildHpEntityData(sysPartTypedEntityData, thermalBuses) - - then: - hpInputEntityDataOpt.success == resultIsPresent - hpInputEntityDataOpt.data.ifPresent({ hpInputEntityData -> - assert (hpInputEntityData == resultData) - }) - - where: - thermalBuses | fieldsToAttributes || resultIsPresent || resultData - [] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || false || null - [sptd.hpInput.thermalBus] | ["bla": "foo"] || false || null - [sptd.hpInput.thermalBus] | [:] || false || null - [sptd.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384f"] || false || null - [sptd.hpInput.thermalBus] | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e"] || true || new HpInputEntityData([:], sptd.hpInput.operator, sptd.hpInput.node, sptd.hpTypeInput, sptd.hpInput.thermalBus) - } + expect: + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(operatorMap, nodeMap, emUnitsMap, map([sptd.hpTypeInput]), thermalBusMap), SourceException) + heatPumps.success + heatPumps.data.get() == [sptd.hpInput] as Set - def "A CsvSystemParticipantSource should build chp input entity from valid and invalid input data as expected"(List thermalStorages, List thermalBuses, Map fieldsToAttributes, boolean resultIsPresent, ChpInputEntityData resultData) { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(operatorMap, nodeMap, emUnitsMap, map([sptd.chpTypeInput]), thermalBusMap, thermalStorageMap), SourceException) + chpUnits.success + chpUnits.data.get() == [sptd.chpInput] as Set - def sysPartTypedEntityData = new SystemParticipantTypedEntityData<>(fieldsToAttributes, ChpInput, sptd.chpInput.operator, sptd.chpInput.node, sptd.chpTypeInput) + def evs = Try.of(() -> csvSystemParticipantSource.getEvs(operatorMap, nodeMap, emUnitsMap, map([sptd.evTypeInput])), SourceException) + evs.success + evs.data.get() == [sptd.evInput] as Set - when: - def hpInputEntityDataOpt = csvSystemParticipantSource.buildChpEntityData(sysPartTypedEntityData, thermalStorages, thermalBuses) + def wecs = Try.of(() -> csvSystemParticipantSource.getWecPlants(operatorMap, nodeMap, emUnitsMap, map([sptd.wecType])), SourceException) + wecs.success + wecs.data.get() == [sptd.wecInput] as Set - then: - hpInputEntityDataOpt.success == resultIsPresent - hpInputEntityDataOpt.data.ifPresent({ hpInputEntityData -> - assert (hpInputEntityData == resultData) - }) + def storages = Try.of(() -> csvSystemParticipantSource.getStorages(operatorMap, nodeMap, emUnitsMap, map([sptd.storageTypeInput])), SourceException) + storages.success + storages.data.get() == [sptd.storageInput] as Set - where: - thermalStorages | thermalBuses | fieldsToAttributes || resultIsPresent | resultData - [] as List | [] as List | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || false | null - [ - sptd.chpInput.thermalStorage - ] as List | [sptd.chpInput.thermalBus] as List | ["bla": "foo"] || false | null - [ - sptd.chpInput.thermalStorage - ] as List | [sptd.chpInput.thermalBus] as List | [:] || false | null - [ - sptd.chpInput.thermalStorage - ] as List | [sptd.chpInput.thermalBus] as List | ["thermalBus": "0d95d7f2-49fb-4d49-8636-383a5220384e", "thermalStorage": "8851813b-3a7d-4fee-874b-4df9d724e4b3"] || true | new ChpInputEntityData([:], sptd.chpInput.operator, sptd.chpInput.node, sptd.chpTypeInput, sptd.chpInput.thermalBus, sptd.chpInput.thermalStorage) - } + def bms = Try.of(() -> csvSystemParticipantSource.getBmPlants(operatorMap, nodeMap, emUnitsMap, map([sptd.bmTypeInput])), SourceException) + bms.success + bms.data.get() == [sptd.bmInput] as Set - def "A CsvSystemParticipantSource should return data from a valid heat pump input file as expected"() { - given: - def csvSystemParticipantSource = new SystemParticipantSource( - Mock(TypeSource), - Mock(ThermalSource), - Mock(RawGridSource), - new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def evcs = Try.of(() -> csvSystemParticipantSource.getEvcs(operatorMap, nodeMap, emUnitsMap), SourceException) + evcs.success + evcs.data.get() == [sptd.evcsInput] as Set - expect: - def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(nodes as Set, operators as Set, types as Set, thermalBuses as Set), SourceException) + def loads = Try.of(() -> csvSystemParticipantSource.getLoads(operatorMap, nodeMap, emUnitsMap), SourceException) + loads.success + loads.data.get() == [sptd.loadInput] as Set - if (heatPumps.success) { - heatPumps.data.get().size() == resultingSize - heatPumps.data.get() == resultingSet as Set - } else { - heatPumps.exception.get().class == SourceException - } + def pvs = Try.of(() -> csvSystemParticipantSource.getPvPlants(operatorMap, nodeMap, emUnitsMap), SourceException) + pvs.success + pvs.data.get() == [sptd.pvInput] as Set - where: - nodes | operators | types | thermalBuses || resultingSize || resultingSet - [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 || [sptd.hpInput] - [sptd.hpInput.node] | [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 || [ - new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.hpInput.type) - ] - [] | [] | [] | [] || 0 || [] - [sptd.hpInput.node] | [] | [] | [] || 0 || [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [] | [] || 0 || [] - [sptd.hpInput.node] | [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 || [] + def fixedFeedIns = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(operatorMap, nodeMap, emUnitsMap), SourceException) + fixedFeedIns.success + fixedFeedIns.data.get() == [sptd.fixedFeedInInput] as Set } - def "A CsvSystemParticipantSource should return data from a valid chp input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from an invalid heat pump input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(nodes as Set, operators as Set, types as Set, thermalBuses as Set, thermalStorages as Set), SourceException) + def heatPumps = Try.of(() -> csvSystemParticipantSource.getHeatPumps(map(operators), nodeMap, emUnitsMap, map(types), map(thermalBuses)), SourceException) - if (chpUnits.success) { - chpUnits.data.get().size() == resultingSize - chpUnits.data.get() == resultingSet as Set - } else { - chpUnits.exception.get().class == SourceException - } + heatPumps.failure + heatPumps.exception.get().class == SourceException where: - nodes | operators | types | thermalBuses | thermalStorages || resultingSize || resultingSet - [sptd.chpInput.node]| [sptd.chpInput.operator]| [sptd.chpInput.type]| [sptd.chpInput.thermalBus]| [ - sptd.chpInput.thermalStorage - ] as List || 1 || [sptd.chpInput] - [sptd.chpInput.node]| []| [sptd.chpInput.type]| [sptd.chpInput.thermalBus]| [ - sptd.chpInput.thermalStorage - ] as List || 1 || [ - new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction) - ] - [] | [] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [sptd.chpInput.operator] | [] | [] | [] as List || 0 || [] - [sptd.chpInput.node] | [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || 0 || [] + operators | types | thermalBuses || resultingSize | resultingSet + [] | [sptd.hpInput.type] | [sptd.hpInput.thermalBus] || 1 | [new HpInput(sptd.hpInput.uuid, sptd.hpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.hpInput.operationTime, sptd.hpInput.node, sptd.hpInput.thermalBus, sptd.hpInput.qCharacteristics, sptd.emInput, sptd.hpInput.type)] + [] | [] | [] || 0 | [] + [] | [] | [] || 0 | [] + [sptd.hpInput.operator] | [] | [] || 0 | [] + [sptd.hpInput.operator] | [sptd.hpInput.type] | [] || 0 | [] } - def "A CsvSystemParticipantSource should return data from valid ev input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from a invalid chp input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(nodes as Set, operators as Set, types as Set), SourceException) + def chpUnits = Try.of(() -> csvSystemParticipantSource.getChpPlants(map(operators), nodeMap, emUnitsMap, map(types), map(thermalBuses), map(thermalStorages)), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + chpUnits.failure + chpUnits.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.evInput.node] | [sptd.evInput.operator] | [sptd.evInput.type] || 1 || [sptd.evInput] - [sptd.evInput.node] | [] | [sptd.evInput.type] || 1 || [ - new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.evInput.type) - ] - [sptd.evInput.node] | [sptd.evInput.operator] | [] || 0 || [] - [sptd.evInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] + operators | types | thermalBuses | thermalStorages || resultingSet + [] | [sptd.chpInput.type] | [sptd.chpInput.thermalBus] | [sptd.chpInput.thermalStorage] || [new ChpInput(sptd.chpInput.uuid, sptd.chpInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.chpInput.operationTime, sptd.chpInput.node, sptd.chpInput.thermalBus, sptd.chpInput.qCharacteristics, sptd.emInput, sptd.chpInput.type, sptd.chpInput.thermalStorage, sptd.chpInput.marketReaction)] + [] | [] | [] | [] as List || [] + [] | [] | [] | [] as List || [] + [sptd.chpInput.operator] | [] | [] | [] as List || [] + [sptd.chpInput.operator] | [sptd.chpInput.type] | [] | [] as List || [] } - def "A CsvSystemParticipantSource should return data from valid wec input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid ev input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvs(map(operators), nodeMap, emUnitsMap, map(types)), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.wecInput.node] | [sptd.wecInput.operator] | [sptd.wecInput.type] || 1 || [sptd.wecInput] - [sptd.wecInput.node] | [] | [sptd.wecInput.type] || 1 || [ - new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.wecInput.type, sptd.wecInput.marketReaction) - ] - [sptd.wecInput.node] | [sptd.wecInput.operator] | [] || 0 || [] - [sptd.wecInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] + operators | types || resultingSet + [] | [sptd.evInput.type] || [new EvInput(sptd.evInput.uuid, sptd.evInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evInput.operationTime, sptd.evInput.node, sptd.evInput.qCharacteristics, sptd.emInput, sptd.evInput.type)] + [sptd.evInput.operator] | [] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid storage input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid wec input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getWecPlants(map(operators), nodeMap, emUnitsMap, map(types)), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.storageInput.node] | [sptd.storageInput.operator] | [sptd.storageInput.type] || 1 || [sptd.storageInput] - [sptd.storageInput.node] | [] | [sptd.storageInput.type] || 1 || [ - new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.storageInput.type) - ] - [sptd.storageInput.node] | [sptd.storageInput.operator] | [] || 0 || [] - [sptd.storageInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] + operators | types || resultingSet + [] | [sptd.wecInput.type] || [new WecInput(sptd.wecInput.uuid, sptd.wecInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.wecInput.operationTime, sptd.wecInput.node, sptd.wecInput.qCharacteristics, sptd.emInput, sptd.wecInput.type, sptd.wecInput.marketReaction)] + [sptd.wecInput.operator] | [] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid bm input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid storage input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(nodes as Set, operators as Set, types as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getStorages(map(operators), nodeMap, emUnitsMap, map(types)), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators | types || resultingSize || resultingSet - [sptd.bmInput.node] | [sptd.bmInput.operator] | [sptd.bmInput.type] || 1 || [sptd.bmInput] - [sptd.bmInput.node] | [] | [sptd.bmInput.type] || 1 || [ - new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff) - ] - [sptd.bmInput.node] | [sptd.bmInput.operator] | [] || 0 || [] - [sptd.bmInput.node] | [] | [] || 0 || [] - [] | [] | [] || 0 || [] + operators | types || resultingSet + [] | [sptd.storageInput.type] || [new StorageInput(sptd.storageInput.uuid, sptd.storageInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.storageInput.operationTime, sptd.storageInput.node, sptd.storageInput.qCharacteristics, sptd.emInput, sptd.storageInput.type)] + [sptd.storageInput.operator] | [] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid ev charging station input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid bm input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def nodeMap = map([sptd.participantNode]) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEvCS(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getBmPlants(map(operators), nodeMap, emUnitsMap, map(types)), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.evcsInput.node] | [sptd.evcsInput.operator] || 1 || [sptd.evcsInput] - [sptd.evcsInput.node] | [] || 1 || [ - new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport) - ] - []| [sptd.evcsInput.operator]|| 0 || [] - []| []|| 0 || [] + operators | types || resultingSet + [] | [sptd.bmInput.type] || [new BmInput(sptd.bmInput.uuid, sptd.bmInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.bmInput.operationTime, sptd.bmInput.node, sptd.bmInput.qCharacteristics, sptd.emInput, sptd.bmInput.type, sptd.bmInput.marketReaction, sptd.bmInput.costControlled, sptd.bmInput.feedInTariff)] + [sptd.bmInput.operator] | [] || [] + [] | [] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid load input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid ev charging station input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getEvcs(map(operators), map(nodes), emUnitsMap), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.loadInput.node] | [sptd.loadInput.operator] || 1 || [sptd.loadInput] - [sptd.loadInput.node] | [] || 1 || [ - new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated) - ] - [] | [sptd.loadInput.operator] || 0 || [] - [] | [] || 0 || [] + nodes | operators || resultingSet + [sptd.evcsInput.node] | [] || [new EvcsInput(sptd.evcsInput.uuid, sptd.evcsInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.evcsInput.operationTime, sptd.evcsInput.node, sptd.evcsInput.qCharacteristics, sptd.emInput, sptd.evcsInput.type, sptd.evcsInput.chargingPoints, sptd.evcsInput.cosPhiRated, sptd.evcsInput.locationType, sptd.evcsInput.v2gSupport)] + [] | [sptd.evcsInput.operator] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid pv input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid load input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getLoads(map(operators), map(nodes), emUnitsMap), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.pvInput.node] | [sptd.pvInput.operator] || 1 || [sptd.pvInput] - [sptd.pvInput.node] | [] || 1 || [ - new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated) - ] - [] | [sptd.pvInput.operator] || 0 || [] - [] | [] || 0 || [] + nodes | operators || resultingSet + [sptd.loadInput.node] | [] || [new LoadInput(sptd.loadInput.uuid, sptd.loadInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.loadInput.operationTime, sptd.loadInput.node, sptd.loadInput.qCharacteristics, sptd.emInput, sptd.loadInput.loadProfile, sptd.loadInput.dsm, sptd.loadInput.eConsAnnual, sptd.loadInput.sRated, sptd.loadInput.cosPhiRated)] + [] | [sptd.loadInput.operator] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid fixedFeedIn input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid pv input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getPvPlants(map(operators), map(nodes), emUnitsMap), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.fixedFeedInInput.node] | [ - sptd.fixedFeedInInput.operator - ] as List || 1 || [sptd.fixedFeedInInput] - [sptd.fixedFeedInInput.node] | [] as List || 1 || [ - new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated) - ] - [] | [ - sptd.fixedFeedInInput.operator - ] as List || 0 || [] - [] | [] as List || 0 || [] + nodes | operators || resultingSet + [sptd.pvInput.node] | [] || [new PvInput(sptd.pvInput.uuid, sptd.pvInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.pvInput.operationTime, sptd.pvInput.node, sptd.pvInput.qCharacteristics, sptd.emInput, sptd.pvInput.albedo, sptd.pvInput.azimuth, sptd.pvInput.etaConv, sptd.pvInput.elevationAngle, sptd.pvInput.kG, sptd.pvInput.kT, sptd.pvInput.marketReaction, sptd.pvInput.sRated, sptd.pvInput.cosPhiRated)] + [] | [sptd.pvInput.operator] || [] + [] | [] || [] } - def "A CsvSystemParticipantSource should return data from valid em input file as expected"() { + def "A SystemParticipantSource with csv input should throw an exception from invalid fixedFeedIn input file as expected"() { given: def csvSystemParticipantSource = new SystemParticipantSource( Mock(TypeSource), Mock(ThermalSource), Mock(RawGridSource), + Mock(EnergyManagementSource), new CsvDataSource(csvSep, participantsFolderPath, fileNamingStrategy)) + def emUnitsMap = map([sptd.emInput]) expect: - def sysParts = Try.of(() -> csvSystemParticipantSource.getEmSystems(nodes as Set, operators as Set), SourceException) + def sysParts = Try.of(() -> csvSystemParticipantSource.getFixedFeedIns(map(operators), map(nodes), emUnitsMap), SourceException) - if (sysParts.success) { - sysParts.data.get().size() == resultingSize - sysParts.data.get() == resultingSet as Set - } else { - sysParts.exception.get().class == SourceException - } + sysParts.failure + sysParts.exception.get().class == SourceException where: - nodes | operators || resultingSize || resultingSet - [sptd.emInput.node] | [sptd.emInput.operator] || 1 || [sptd.emInput] - [] | [sptd.pvInput.operator] || 0 || [] - [] | [] || 0 || [] + nodes | operators || resultingSet + [sptd.fixedFeedInInput.node] | [] as List || [new FixedFeedInInput(sptd.fixedFeedInInput.uuid, sptd.fixedFeedInInput.id, OperatorInput.NO_OPERATOR_ASSIGNED, sptd.fixedFeedInInput.operationTime, sptd.fixedFeedInInput.node, sptd.fixedFeedInInput.qCharacteristics, sptd.emInput, sptd.fixedFeedInInput.sRated, sptd.fixedFeedInInput.cosPhiRated)] + [] | [sptd.fixedFeedInInput.operator] as List || [] + [] | [] as List || [] } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy index bead486fc..7351cf1a2 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvThermalSourceTest.groovy @@ -6,19 +6,12 @@ package edu.ie3.datamodel.io.source.csv import edu.ie3.datamodel.io.naming.FileNamingStrategy -import edu.ie3.datamodel.io.factory.input.AssetInputEntityData -import edu.ie3.datamodel.io.factory.input.ThermalUnitInputEntityData import edu.ie3.datamodel.io.source.ThermalSource import edu.ie3.datamodel.io.source.TypeSource -import edu.ie3.datamodel.models.input.OperatorInput -import edu.ie3.datamodel.models.input.thermal.ThermalBusInput -import edu.ie3.datamodel.models.input.thermal.ThermalUnitInput import edu.ie3.test.common.SystemParticipantTestData as sptd import edu.ie3.test.common.ThermalUnitInputTestData import spock.lang.Specification -import java.util.stream.Collectors - class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { def "A CsvThermalSource should return ThermalBuses from valid and invalid input data as expected"() { @@ -33,10 +26,11 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { then: resultingThermalBusesWoOperator.size() == 1 - resultingThermalBusesWoOperator.first().uuid == sptd.thermalBus.uuid - resultingThermalBusesWoOperator.first().id == sptd.thermalBus.id - resultingThermalBusesWoOperator.first().operator == sptd.thermalBus.operator - resultingThermalBusesWoOperator.first().operationTime == sptd.thermalBus.operationTime + def thermalBusWoOp = resultingThermalBusesWoOperator.values().first() + thermalBusWoOp.uuid == sptd.thermalBus.uuid + thermalBusWoOp.id == sptd.thermalBus.id + thermalBusWoOp.operator == sptd.thermalBus.operator + thermalBusWoOp.operationTime == sptd.thermalBus.operationTime //test method when operators are provided as constructor parameters when: @@ -44,10 +38,11 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { then: resultingThermalBuses.size() == 1 - resultingThermalBuses.first().uuid == sptd.thermalBus.uuid - resultingThermalBuses.first().id == sptd.thermalBus.id - resultingThermalBuses.first().operator == sptd.thermalBus.operator - resultingThermalBuses.first().operationTime == sptd.thermalBus.operationTime + def thermalBus = resultingThermalBuses.values().first() + thermalBus.uuid == sptd.thermalBus.uuid + thermalBus.id == sptd.thermalBus.id + thermalBus.operator == sptd.thermalBus.operator + thermalBus.operationTime == sptd.thermalBus.operationTime } def "A CsvThermalSource should return a CylindricalStorageInput from valid and invalid input data as expected"() { @@ -59,78 +54,41 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { //test method when operators and thermal buses are not provided as constructor parameters when: - def resultingCylindricalStorageWoOperator = csvThermalSource.getCylindricStorages() + def resultingCylindricalStorageWoOperator = csvThermalSource.getCylindricalStorages() then: resultingCylindricalStorageWoOperator.size() == 1 - resultingCylindricalStorageWoOperator.first().uuid == sptd.thermalStorage.uuid - resultingCylindricalStorageWoOperator.first().id == sptd.thermalStorage.id - resultingCylindricalStorageWoOperator.first().operator == sptd.thermalStorage.operator - resultingCylindricalStorageWoOperator.first().operationTime == sptd.thermalStorage.operationTime - resultingCylindricalStorageWoOperator.first().thermalBus == sptd.thermalStorage.thermalBus - resultingCylindricalStorageWoOperator.first().storageVolumeLvl == sptd.storageVolumeLvl - resultingCylindricalStorageWoOperator.first().storageVolumeLvlMin == sptd.storageVolumeLvlMin - resultingCylindricalStorageWoOperator.first().inletTemp == sptd.inletTemp - resultingCylindricalStorageWoOperator.first().returnTemp == sptd.returnTemp - resultingCylindricalStorageWoOperator.first().c == sptd.c + with(resultingCylindricalStorageWoOperator.first()) { + uuid == sptd.thermalStorage.uuid + id == sptd.thermalStorage.id + operator == sptd.thermalStorage.operator + operationTime == sptd.thermalStorage.operationTime + thermalBus == sptd.thermalStorage.thermalBus + storageVolumeLvl == sptd.storageVolumeLvl + storageVolumeLvlMin == sptd.storageVolumeLvlMin + inletTemp == sptd.inletTemp + returnTemp == sptd.returnTemp + c == sptd.c + } //test method when operators and thermal buses are provided as constructor parameters when: - def resultingCylindricalStorage = csvThermalSource.getCylindricStorages(operators, thermalBuses) + def resultingCylindricalStorage = csvThermalSource.getCylindricalStorages(operators, thermalBuses) then: resultingCylindricalStorage.size() == 1 - resultingCylindricalStorage.first().uuid == sptd.thermalStorage.uuid - resultingCylindricalStorage.first().id == sptd.thermalStorage.id - resultingCylindricalStorage.first().operator == sptd.thermalStorage.operator - resultingCylindricalStorage.first().operationTime == sptd.thermalStorage.operationTime - resultingCylindricalStorage.first().thermalBus == sptd.thermalStorage.thermalBus - resultingCylindricalStorage.first().storageVolumeLvl == sptd.storageVolumeLvl - resultingCylindricalStorage.first().storageVolumeLvlMin == sptd.storageVolumeLvlMin - resultingCylindricalStorage.first().inletTemp == sptd.inletTemp - resultingCylindricalStorage.first().returnTemp == sptd.returnTemp - resultingCylindricalStorage.first().c == sptd.c - } - - def "A CsvThermalSource should build thermal unit input entity from valid and invalid input data as expected"() { - given: - def csvTypeSource = new TypeSource(new CsvDataSource(",", typeFolderPath, new FileNamingStrategy())) - def csvThermalSource = new ThermalSource(csvTypeSource, new CsvDataSource(csvSep, thermalFolderPath, fileNamingStrategy)) - def operator = new OperatorInput(UUID.fromString("8f9682df-0744-4b58-a122-f0dc730f6510"), "testOperator") - def validFieldsToAttributes = [ - "uuid" : "717af017-cc69-406f-b452-e022d7fb516a", - "id" : "test_thermal_unit", - "operator" : "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom" : "2020-03-24 15:11:31", - "operatesUntil" : "2020-03-25 15:11:31", - "thermalBus" : "0d95d7f2-49fb-4d49-8636-383a5220384e" - ] - def assetInputEntityData = new AssetInputEntityData(validFieldsToAttributes, ThermalUnitInput, operator) - - when: - def resultingDataOpt = csvThermalSource.buildThermalUnitInputEntityData(assetInputEntityData, thermalBuses).collect(Collectors.toList()) - - then: - resultingDataOpt.size() == 1 - resultingDataOpt.first().data.present == resultIsPresent - resultingDataOpt.first().data.ifPresent({ resultingData -> - assert (resultingData == expectedThermalUnitInputEntityData) - }) - - where: - thermalBuses || resultIsPresent || expectedThermalUnitInputEntityData - []|| false || null // thermal buses are not present -> method should return an empty optional -> do not check for thermal unit entity data - [ - new ThermalBusInput(UUID.fromString("0d95d7f2-49fb-4d49-8636-383a5220384e"), "test_thermal_bus") - ]|| true || - new ThermalUnitInputEntityData(["uuid": "717af017-cc69-406f-b452-e022d7fb516a", - "id": "test_thermal_unit", - "operator": "8f9682df-0744-4b58-a122-f0dc730f6510", - "operatesFrom": "2020-03-24 15:11:31", - "operatesUntil": "2020-03-25 15:11:31"], - ThermalUnitInput, - new OperatorInput(UUID.fromString("8f9682df-0744-4b58-a122-f0dc730f6510"), "testOperator"), - new ThermalBusInput(UUID.fromString("0d95d7f2-49fb-4d49-8636-383a5220384e"), "test_thermal_bus")) + with(resultingCylindricalStorage.first()) { + uuid == sptd.thermalStorage.uuid + id == sptd.thermalStorage.id + operator == sptd.thermalStorage.operator + operationTime == sptd.thermalStorage.operationTime + thermalBus == sptd.thermalStorage.thermalBus + storageVolumeLvl == sptd.storageVolumeLvl + storageVolumeLvlMin == sptd.storageVolumeLvlMin + inletTemp == sptd.inletTemp + returnTemp == sptd.returnTemp + c == sptd.c + } } def "A CsvThermalSource should return a ThermalHouseInput from valid and invalid input data as expected"() { @@ -146,17 +104,19 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { then: resultingThermalHouseWoOperator.size() == 1 - resultingThermalHouseWoOperator.first().uuid == ThermalUnitInputTestData.thermalHouseInput.uuid - resultingThermalHouseWoOperator.first().id == ThermalUnitInputTestData.thermalHouseInput.id - resultingThermalHouseWoOperator.first().operator == ThermalUnitInputTestData.thermalHouseInput.operator - resultingThermalHouseWoOperator.first().operationTime.isLimited() - resultingThermalHouseWoOperator.first().operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime - resultingThermalHouseWoOperator.first().thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus - resultingThermalHouseWoOperator.first().ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses - resultingThermalHouseWoOperator.first().ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa - resultingThermalHouseWoOperator.first().targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature - resultingThermalHouseWoOperator.first().upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit - resultingThermalHouseWoOperator.first().lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + with(resultingThermalHouseWoOperator.values().first()) { + uuid == ThermalUnitInputTestData.thermalHouseInput.uuid + id == ThermalUnitInputTestData.thermalHouseInput.id + operator == ThermalUnitInputTestData.thermalHouseInput.operator + operationTime.isLimited() + operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime + thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus + ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses + ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa + targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature + upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit + lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + } //test method when operators and thermal buses are provided as constructor parameters when: @@ -164,16 +124,18 @@ class CsvThermalSourceTest extends Specification implements CsvTestDataMeta { then: resultingThermalHouse.size() == 1 - resultingThermalHouse.first().uuid == ThermalUnitInputTestData.thermalHouseInput.uuid - resultingThermalHouse.first().id == ThermalUnitInputTestData.thermalHouseInput.id - resultingThermalHouse.first().operator == ThermalUnitInputTestData.thermalHouseInput.operator - resultingThermalHouse.first().operationTime.isLimited() - resultingThermalHouse.first().operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime - resultingThermalHouseWoOperator.first().thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus - resultingThermalHouse.first().ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses - resultingThermalHouse.first().ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa - resultingThermalHouse.first().targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature - resultingThermalHouse.first().upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit - resultingThermalHouse.first().lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + with(resultingThermalHouse.values().first()) { + uuid == ThermalUnitInputTestData.thermalHouseInput.uuid + id == ThermalUnitInputTestData.thermalHouseInput.id + operator == ThermalUnitInputTestData.thermalHouseInput.operator + operationTime.isLimited() + operationTime == ThermalUnitInputTestData.thermalHouseInput.operationTime + thermalBus == ThermalUnitInputTestData.thermalHouseInput.thermalBus + ethLosses == ThermalUnitInputTestData.thermalHouseInput.ethLosses + ethCapa == ThermalUnitInputTestData.thermalHouseInput.ethCapa + targetTemperature == ThermalUnitInputTestData.thermalHouseInput.targetTemperature + upperTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.upperTemperatureLimit + lowerTemperatureLimit == ThermalUnitInputTestData.thermalHouseInput.lowerTemperatureLimit + } } } \ No newline at end of file diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceIT.groovy index de1857954..78ca34d74 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceIT.groovy @@ -5,18 +5,18 @@ */ package edu.ie3.datamodel.io.source.csv -import java.nio.file.Path - import static edu.ie3.test.common.TimeSeriesSourceTestData.* import edu.ie3.datamodel.exceptions.SourceException -import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.factory.timeseries.TimeBasedSimpleValueFactory +import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.models.value.HeatAndPValue import edu.ie3.util.interval.ClosedInterval import spock.lang.Shared import spock.lang.Specification +import java.nio.file.Path + class CsvTimeSeriesSourceIT extends Specification implements CsvTestDataMeta { @Shared @@ -39,7 +39,7 @@ class CsvTimeSeriesSourceIT extends Specification implements CsvTestDataMeta { then: def ex = thrown(SourceException) - ex.message == "Unable to find a file with path '" + filePath + "'." + ex.message == "Unable to find file '" + filePath + "'." ex.cause.class == FileNotFoundException } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceTest.groovy index 5eaaa914e..b5f680079 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTimeSeriesSourceTest.groovy @@ -5,22 +5,20 @@ */ package edu.ie3.datamodel.io.source.csv -import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation -import edu.ie3.datamodel.io.naming.FileNamingStrategy -import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme - -import java.nio.file.Path - import static edu.ie3.datamodel.models.StandardUnits.ENERGY_PRICE import edu.ie3.datamodel.exceptions.SourceException +import edu.ie3.datamodel.io.csv.CsvIndividualTimeSeriesMetaInformation import edu.ie3.datamodel.io.factory.timeseries.TimeBasedSimpleValueFactory +import edu.ie3.datamodel.io.naming.FileNamingStrategy +import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue import edu.ie3.datamodel.models.value.* import edu.ie3.util.TimeUtil import spock.lang.Specification import tech.units.indriya.quantity.Quantities +import java.nio.file.Path import java.time.ZoneId class CsvTimeSeriesSourceTest extends Specification implements CsvTestDataMeta { diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTypeSourceTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTypeSourceTest.groovy index 2aa6331f5..44e2716ce 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTypeSourceTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvTypeSourceTest.groovy @@ -8,10 +8,9 @@ package edu.ie3.datamodel.io.source.csv import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.TypeSource import edu.ie3.datamodel.models.input.OperatorInput -import spock.lang.Specification import edu.ie3.test.common.GridTestData as gtd import edu.ie3.test.common.SystemParticipantTestData as sptd - +import spock.lang.Specification class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { @@ -21,23 +20,22 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { expect: def transformer2WTypes = typeSource.transformer2WTypes - def transformerToBeFound = transformer2WTypes.find {trafoType -> - trafoType.uuid ==gtd.transformerTypeBtoD.uuid + with(transformer2WTypes.get(gtd.transformerTypeBtoD.uuid)) { + id == gtd.transformerTypeBtoD.id + rSc == gtd.transformerTypeBtoD.rSc + xSc == gtd.transformerTypeBtoD.xSc + sRated == gtd.transformerTypeBtoD.sRated + vRatedA == gtd.transformerTypeBtoD.vRatedA + vRatedB == gtd.transformerTypeBtoD.vRatedB + gM == gtd.transformerTypeBtoD.gM + bM == gtd.transformerTypeBtoD.bM + dV == gtd.transformerTypeBtoD.dV + dPhi == gtd.transformerTypeBtoD.dPhi + tapSide == gtd.transformerTypeBtoD.tapSide + tapNeutr == gtd.transformerTypeBtoD.tapNeutr + tapMin == gtd.transformerTypeBtoD.tapMin + tapMax == gtd.transformerTypeBtoD.tapMax } - transformerToBeFound.id == gtd.transformerTypeBtoD.id - transformerToBeFound.rSc == gtd.transformerTypeBtoD.rSc - transformerToBeFound.xSc == gtd.transformerTypeBtoD.xSc - transformerToBeFound.sRated == gtd.transformerTypeBtoD.sRated - transformerToBeFound.vRatedA == gtd.transformerTypeBtoD.vRatedA - transformerToBeFound.vRatedB == gtd.transformerTypeBtoD.vRatedB - transformerToBeFound.gM == gtd.transformerTypeBtoD.gM - transformerToBeFound.bM == gtd.transformerTypeBtoD.bM - transformerToBeFound.dV == gtd.transformerTypeBtoD.dV - transformerToBeFound.dPhi == gtd.transformerTypeBtoD.dPhi - transformerToBeFound.tapSide == gtd.transformerTypeBtoD.tapSide - transformerToBeFound.tapNeutr == gtd.transformerTypeBtoD.tapNeutr - transformerToBeFound.tapMin == gtd.transformerTypeBtoD.tapMin - transformerToBeFound.tapMax == gtd.transformerTypeBtoD.tapMax } def "A CsvTypeSource should read and handle valid operator file as expected"() { @@ -50,10 +48,8 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { expect: def operators = typeSource.operators - operators.first().uuid == firstOperator.uuid - operators.first().id == firstOperator.id - operators[1].uuid == secondOperator.uuid - operators[1].id == secondOperator.id + operators.get(firstOperator.uuid) == firstOperator + operators.get(secondOperator.uuid) == secondOperator } def "A CsvTypeSource should read and handle valid line type file as expected"() { @@ -61,15 +57,15 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def lineTypes = typeSource.lineTypes - lineTypes.first().uuid == gtd.lineTypeInputCtoD.uuid - lineTypes.first().id == gtd.lineTypeInputCtoD.id - lineTypes.first().b == gtd.lineTypeInputCtoD.b - lineTypes.first().g == gtd.lineTypeInputCtoD.g - lineTypes.first().r == gtd.lineTypeInputCtoD.r - lineTypes.first().x == gtd.lineTypeInputCtoD.x - lineTypes.first().iMax == gtd.lineTypeInputCtoD.iMax - lineTypes.first().vRated == gtd.lineTypeInputCtoD.vRated + with(typeSource.lineTypes.get(gtd.lineTypeInputCtoD.uuid)) { + id == gtd.lineTypeInputCtoD.id + b == gtd.lineTypeInputCtoD.b + g == gtd.lineTypeInputCtoD.g + r == gtd.lineTypeInputCtoD.r + x == gtd.lineTypeInputCtoD.x + iMax == gtd.lineTypeInputCtoD.iMax + vRated == gtd.lineTypeInputCtoD.vRated + } } def "A CsvTypeSource should read and handle valid 3W Transformer type file as expected"() { @@ -77,28 +73,28 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def transformer3WTypes = typeSource.transformer3WTypes - transformer3WTypes.first().uuid == gtd.transformerTypeAtoBtoC.uuid - transformer3WTypes.first().id == gtd.transformerTypeAtoBtoC.id - transformer3WTypes.first().sRatedA == gtd.transformerTypeAtoBtoC.sRatedA - transformer3WTypes.first().sRatedB == gtd.transformerTypeAtoBtoC.sRatedB - transformer3WTypes.first().sRatedC == gtd.transformerTypeAtoBtoC.sRatedC - transformer3WTypes.first().vRatedA == gtd.transformerTypeAtoBtoC.vRatedA - transformer3WTypes.first().vRatedB == gtd.transformerTypeAtoBtoC.vRatedB - transformer3WTypes.first().vRatedC == gtd.transformerTypeAtoBtoC.vRatedC - transformer3WTypes.first().rScA == gtd.transformerTypeAtoBtoC.rScA - transformer3WTypes.first().rScB == gtd.transformerTypeAtoBtoC.rScB - transformer3WTypes.first().rScC == gtd.transformerTypeAtoBtoC.rScC - transformer3WTypes.first().xScA == gtd.transformerTypeAtoBtoC.xScA - transformer3WTypes.first().xScB == gtd.transformerTypeAtoBtoC.xScB - transformer3WTypes.first().xScC == gtd.transformerTypeAtoBtoC.xScC - transformer3WTypes.first().gM == gtd.transformerTypeAtoBtoC.gM - transformer3WTypes.first().bM == gtd.transformerTypeAtoBtoC.bM - transformer3WTypes.first().dV == gtd.transformerTypeAtoBtoC.dV - transformer3WTypes.first().dPhi == gtd.transformerTypeAtoBtoC.dPhi - transformer3WTypes.first().tapNeutr == gtd.transformerTypeAtoBtoC.tapNeutr - transformer3WTypes.first().tapMin == gtd.transformerTypeAtoBtoC.tapMin - transformer3WTypes.first().tapMax == gtd.transformerTypeAtoBtoC.tapMax + with(typeSource.transformer3WTypes.get(gtd.transformerTypeAtoBtoC.uuid)) { + id == gtd.transformerTypeAtoBtoC.id + sRatedA == gtd.transformerTypeAtoBtoC.sRatedA + sRatedB == gtd.transformerTypeAtoBtoC.sRatedB + sRatedC == gtd.transformerTypeAtoBtoC.sRatedC + vRatedA == gtd.transformerTypeAtoBtoC.vRatedA + vRatedB == gtd.transformerTypeAtoBtoC.vRatedB + vRatedC == gtd.transformerTypeAtoBtoC.vRatedC + rScA == gtd.transformerTypeAtoBtoC.rScA + rScB == gtd.transformerTypeAtoBtoC.rScB + rScC == gtd.transformerTypeAtoBtoC.rScC + xScA == gtd.transformerTypeAtoBtoC.xScA + xScB == gtd.transformerTypeAtoBtoC.xScB + xScC == gtd.transformerTypeAtoBtoC.xScC + gM == gtd.transformerTypeAtoBtoC.gM + bM == gtd.transformerTypeAtoBtoC.bM + dV == gtd.transformerTypeAtoBtoC.dV + dPhi == gtd.transformerTypeAtoBtoC.dPhi + tapNeutr == gtd.transformerTypeAtoBtoC.tapNeutr + tapMin == gtd.transformerTypeAtoBtoC.tapMin + tapMax == gtd.transformerTypeAtoBtoC.tapMax + } } def "A CsvTypeSource should read and handle valid bm type file as expected"() { @@ -106,14 +102,14 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def bmTypes = typeSource.bmTypes - bmTypes.first().uuid == sptd.bmTypeInput.uuid - bmTypes.first().id == sptd.bmTypeInput.id - bmTypes.first().capex == sptd.bmTypeInput.capex - bmTypes.first().opex == sptd.bmTypeInput.opex - bmTypes.first().cosPhiRated == sptd.bmTypeInput.cosPhiRated - bmTypes.first().activePowerGradient == sptd.bmTypeInput.activePowerGradient - bmTypes.first().etaConv == sptd.bmTypeInput.etaConv + with(typeSource.bmTypes.get(sptd.bmTypeInput.uuid)) { + id == sptd.bmTypeInput.id + capex == sptd.bmTypeInput.capex + opex == sptd.bmTypeInput.opex + cosPhiRated == sptd.bmTypeInput.cosPhiRated + activePowerGradient == sptd.bmTypeInput.activePowerGradient + etaConv == sptd.bmTypeInput.etaConv + } } def "A CsvTypeSource should read and handle valid chp type file as expected"() { @@ -121,16 +117,16 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def chpTypes = typeSource.chpTypes - chpTypes.first().uuid == sptd.chpTypeInput.uuid - chpTypes.first().id == sptd.chpTypeInput.id - chpTypes.first().capex == sptd.chpTypeInput.capex - chpTypes.first().opex == sptd.chpTypeInput.opex - chpTypes.first().etaEl == sptd.chpTypeInput.etaEl - chpTypes.first().etaThermal == sptd.chpTypeInput.etaThermal - chpTypes.first().sRated == sptd.chpTypeInput.sRated - chpTypes.first().pThermal == sptd.chpTypeInput.pThermal - chpTypes.first().pOwn == sptd.chpTypeInput.pOwn + with(typeSource.chpTypes.get(sptd.chpTypeInput.uuid)) { + id == sptd.chpTypeInput.id + capex == sptd.chpTypeInput.capex + opex == sptd.chpTypeInput.opex + etaEl == sptd.chpTypeInput.etaEl + etaThermal == sptd.chpTypeInput.etaThermal + sRated == sptd.chpTypeInput.sRated + pThermal == sptd.chpTypeInput.pThermal + pOwn == sptd.chpTypeInput.pOwn + } } def "A CsvTypeSource should read and handle valid hp type file as expected"() { @@ -138,14 +134,14 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def hpTypes = typeSource.hpTypes - hpTypes.first().uuid == sptd.hpTypeInput.uuid - hpTypes.first().id == sptd.hpTypeInput.id - hpTypes.first().capex == sptd.hpTypeInput.capex - hpTypes.first().opex == sptd.hpTypeInput.opex - hpTypes.first().sRated == sptd.hpTypeInput.sRated - hpTypes.first().cosPhiRated == sptd.hpTypeInput.cosPhiRated - hpTypes.first().pThermal == sptd.hpTypeInput.pThermal + with(typeSource.hpTypes.get(sptd.hpTypeInput.uuid)) { + id == sptd.hpTypeInput.id + capex == sptd.hpTypeInput.capex + opex == sptd.hpTypeInput.opex + sRated == sptd.hpTypeInput.sRated + cosPhiRated == sptd.hpTypeInput.cosPhiRated + pThermal == sptd.hpTypeInput.pThermal + } } def "A CsvTypeSource should read and handle valid storage type file as expected"() { @@ -153,20 +149,20 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def storageTypes = typeSource.storageTypes - storageTypes.first().uuid == sptd.storageTypeInput.uuid - storageTypes.first().id == sptd.storageTypeInput.id - storageTypes.first().capex == sptd.storageTypeInput.capex - storageTypes.first().opex == sptd.storageTypeInput.opex - storageTypes.first().eStorage == sptd.storageTypeInput.eStorage - storageTypes.first().sRated == sptd.storageTypeInput.sRated - storageTypes.first().cosPhiRated == sptd.storageTypeInput.cosPhiRated - storageTypes.first().pMax == sptd.storageTypeInput.pMax - storageTypes.first().activePowerGradient == sptd.storageTypeInput.activePowerGradient - storageTypes.first().eta == sptd.storageTypeInput.eta - storageTypes.first().dod == sptd.storageTypeInput.dod - storageTypes.first().lifeTime == sptd.storageTypeInput.lifeTime - storageTypes.first().lifeCycle == sptd.storageTypeInput.lifeCycle + with(typeSource.storageTypes.get(sptd.storageTypeInput.uuid)) { + id == sptd.storageTypeInput.id + capex == sptd.storageTypeInput.capex + opex == sptd.storageTypeInput.opex + eStorage == sptd.storageTypeInput.eStorage + sRated == sptd.storageTypeInput.sRated + cosPhiRated == sptd.storageTypeInput.cosPhiRated + pMax == sptd.storageTypeInput.pMax + activePowerGradient == sptd.storageTypeInput.activePowerGradient + eta == sptd.storageTypeInput.eta + dod == sptd.storageTypeInput.dod + lifeTime == sptd.storageTypeInput.lifeTime + lifeCycle == sptd.storageTypeInput.lifeCycle + } } def "A CsvTypeSource should read and handle valid wec type file as expected"() { @@ -174,20 +170,21 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def wecTypes = typeSource.wecTypes - wecTypes.first().uuid == sptd.wecType.uuid - wecTypes.first().id == sptd.wecType.id - wecTypes.first().capex == sptd.wecType.capex - wecTypes.first().opex == sptd.wecType.opex - wecTypes.first().cosPhiRated == sptd.wecType.cosPhiRated - wecTypes.first().etaConv == sptd.wecType.etaConv - wecTypes.first().sRated == sptd.wecType.sRated - wecTypes.first().rotorArea == sptd.wecType.rotorArea - wecTypes.first().hubHeight == sptd.wecType.hubHeight - wecTypes.first().cpCharacteristic == sptd.wecType.cpCharacteristic - //check for the individual points - if (wecTypes.first().cpCharacteristic.points.iterator().hasNext()) - wecTypes.first().cpCharacteristic.points.iterator().next() == sptd.wecType.cpCharacteristic.points.iterator().next() + with(typeSource.wecTypes.get(sptd.wecType.uuid)) { + id == sptd.wecType.id + capex == sptd.wecType.capex + opex == sptd.wecType.opex + cosPhiRated == sptd.wecType.cosPhiRated + etaConv == sptd.wecType.etaConv + sRated == sptd.wecType.sRated + rotorArea == sptd.wecType.rotorArea + hubHeight == sptd.wecType.hubHeight + cpCharacteristic == sptd.wecType.cpCharacteristic + //check for the individual points + if (cpCharacteristic.points.iterator().hasNext()) { + assert cpCharacteristic.points.iterator().next() == sptd.wecType.cpCharacteristic.points.iterator().next() + } + } } def "A CsvTypeSource should read and handle valid ev type file as expected"() { @@ -195,14 +192,14 @@ class CsvTypeSourceTest extends Specification implements CsvTestDataMeta { def typeSource = new TypeSource(new CsvDataSource(csvSep, typeFolderPath, new FileNamingStrategy())) expect: - def evTypes = typeSource.evTypes - evTypes.first().uuid == sptd.evTypeInput.uuid - evTypes.first().id == sptd.evTypeInput.id - evTypes.first().capex == sptd.evTypeInput.capex - evTypes.first().opex == sptd.evTypeInput.opex - evTypes.first().eStorage == sptd.evTypeInput.eStorage - evTypes.first().eCons == sptd.evTypeInput.eCons - evTypes.first().sRated == sptd.evTypeInput.sRated - evTypes.first().cosPhiRated == sptd.evTypeInput.cosPhiRated + with(typeSource.evTypes.get(sptd.evTypeInput.uuid)) { + id == sptd.evTypeInput.id + capex == sptd.evTypeInput.capex + opex == sptd.evTypeInput.opex + eStorage == sptd.evTypeInput.eStorage + eCons == sptd.evTypeInput.eCons + sRated == sptd.evTypeInput.sRated + cosPhiRated == sptd.evTypeInput.cosPhiRated + } } } diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy index 25fc33d40..e4873c75e 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceCosmoTest.groovy @@ -120,12 +120,12 @@ class CsvWeatherSourceCosmoTest extends Specification implements CsvTestDataMeta def fieldToValues = [ "uuid" : "71a79f59-eebf-40c1-8358-ba7414077d57", "time" : "2020-10-16T12:40:42Z", - "coordinateid" : "5", - "directirradiance" : "1.234", - "diffuseirradiance": "5.678", + "coordinateId" : "5", + "directIrradiance" : "1.234", + "diffuseIrradiance": "5.678", "temperature" : "9.1011", - "windvelocity" : "12.1314", - "winddirection" : "15.1617" + "windVelocity" : "12.1314", + "windDirection" : "15.1617" ] def expectedValue = new TimeBasedValue( UUID.fromString("71a79f59-eebf-40c1-8358-ba7414077d57"), diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy index 092cb3eff..d83c8d991 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvWeatherSourceIconTest.groovy @@ -5,8 +5,8 @@ */ package edu.ie3.datamodel.io.source.csv -import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.factory.timeseries.IconTimeBasedWeatherValueFactory +import edu.ie3.datamodel.io.naming.FileNamingStrategy import edu.ie3.datamodel.io.source.IdCoordinateSource import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries import edu.ie3.datamodel.models.timeseries.individual.TimeBasedValue diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy index 58f59e065..1814a3f20 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceCosmoIT.groovy @@ -125,7 +125,7 @@ class InfluxDbWeatherSourceCosmoIT extends Specification implements TestContaine equalsIgnoreUUID(coordinateToTimeSeries.get(CosmoWeatherTestData.COORDINATE_193188).entries, timeseries_193188.entries) } - def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to it's ID"() { + def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { given: def validCoordinate = CosmoWeatherTestData.COORDINATE_193186 def invalidCoordinate = GeoUtils.buildPoint(7d, 48d) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy index ef1799a52..640074db7 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/influxdb/InfluxDbWeatherSourceIconIT.groovy @@ -118,7 +118,7 @@ class InfluxDbWeatherSourceIconIT extends Specification implements WeatherSource equalsIgnoreUUID(coordinateToTimeSeries.get(IconWeatherTestData.COORDINATE_67776).entries, timeseries67776.entries) } - def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to it's ID"() { + def "An InfluxDbWeatherSource will return an equivalent to 'empty' when being unable to map a coordinate to its ID"() { given: def validCoordinate = IconWeatherTestData.COORDINATE_67775 def invalidCoordinate = GeoUtils.buildPoint(7d, 48d) diff --git a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSourceIT.groovy b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSourceIT.groovy index 4ad4d730f..8a895bc12 100644 --- a/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSourceIT.groovy +++ b/src/test/groovy/edu/ie3/datamodel/io/source/sql/SqlTimeSeriesSourceIT.groovy @@ -5,8 +5,6 @@ */ package edu.ie3.datamodel.io.source.sql -import edu.ie3.test.helper.TestContainerHelper - import static edu.ie3.test.common.TimeSeriesSourceTestData.* import edu.ie3.datamodel.exceptions.SourceException @@ -15,6 +13,7 @@ import edu.ie3.datamodel.io.naming.DatabaseNamingStrategy import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme import edu.ie3.datamodel.io.naming.timeseries.IndividualTimeSeriesMetaInformation import edu.ie3.datamodel.models.value.* +import edu.ie3.test.helper.TestContainerHelper import edu.ie3.util.interval.ClosedInterval import org.testcontainers.containers.Container import org.testcontainers.containers.PostgreSQLContainer diff --git a/src/test/groovy/edu/ie3/datamodel/models/CommonVoltageLevelTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/CommonVoltageLevelTest.groovy index 85c6f5c38..041f12627 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/CommonVoltageLevelTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/CommonVoltageLevelTest.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.datamodel.models +import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLT +import static tech.units.indriya.unit.Units.VOLT + import edu.ie3.datamodel.exceptions.VoltageLevelException import edu.ie3.datamodel.models.voltagelevels.CommonVoltageLevel import edu.ie3.util.interval.RightOpenInterval @@ -12,9 +15,6 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLT -import static tech.units.indriya.unit.Units.VOLT - class CommonVoltageLevelTest extends Specification { @Shared CommonVoltageLevel dut = new CommonVoltageLevel( diff --git a/src/test/groovy/edu/ie3/datamodel/models/EmControlStrategyTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/EmControlStrategyTest.groovy deleted file mode 100644 index ea13b2f35..000000000 --- a/src/test/groovy/edu/ie3/datamodel/models/EmControlStrategyTest.groovy +++ /dev/null @@ -1,45 +0,0 @@ -/* - * © 2022. TU Dortmund University, - * Institute of Energy Systems, Energy Efficiency and Energy Economics, - * Research group Distribution grid planning and operation - */ -package edu.ie3.datamodel.models - -import edu.ie3.datamodel.exceptions.FactoryException -import edu.ie3.datamodel.io.factory.input.NodeAssetInputEntityData -import edu.ie3.datamodel.io.factory.input.participant.FixedFeedInInputFactory -import edu.ie3.datamodel.models.input.NodeInput -import edu.ie3.datamodel.models.input.system.FixedFeedInInput -import spock.lang.Specification - -import java.util.stream.Collectors - -class EmControlStrategyTest extends Specification { - - def "An em control strategy should be gotten by their key"() { - given: - EmControlStrategy actual = EmControlStrategy.get(key) - - expect: - actual == expected - - where: - key || expected - EmControlStrategy.SELF_OPTIMIZATION.getKey() || EmControlStrategy.SELF_OPTIMIZATION - } - - def "An em control strategy should throw an exception when calling get on unkown key"() { - given: - String unknownKey = "nobody_knows_me" - - when: - EmControlStrategy _ = EmControlStrategy.get(unknownKey) - - then: - IllegalArgumentException ex = thrown() - ex.message == "No predefined energy management control strategy '" + - unknownKey + - "' found. Please provide one of the following keys: " + - Arrays.stream(EmControlStrategy.values()).map(EmControlStrategy::getKey).collect(Collectors.joining(", ")) - } -} diff --git a/src/test/groovy/edu/ie3/datamodel/models/GermanVoltageLevelUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/GermanVoltageLevelUtilsTest.groovy index 496385ffe..f32111e3b 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/GermanVoltageLevelUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/GermanVoltageLevelUtilsTest.groovy @@ -5,13 +5,13 @@ */ package edu.ie3.datamodel.models +import static edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils.* +import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLT + import edu.ie3.datamodel.models.voltagelevels.CommonVoltageLevel import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils.* -import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLT - class GermanVoltageLevelUtilsTest extends Specification { def "The common german voltage level enum should be able to correctly parse different valid inputs"() { diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy index 0baa37cc0..5b8147f20 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/JointGridContainerTest.groovy @@ -5,12 +5,12 @@ */ package edu.ie3.datamodel.models.input.container +import static edu.ie3.test.common.SystemParticipantTestData.emptySystemParticipants + import edu.ie3.test.common.GridTestData import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification -import static edu.ie3.test.common.SystemParticipantTestData.emptySystemParticipants - class JointGridContainerTest extends Specification { private static final GRID_NAME = "single_grid" diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy index d24239bbd..e75cf6526 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/container/SystemParticipantsTest.groovy @@ -22,8 +22,7 @@ class SystemParticipantsTest extends Specification { Collections.singleton(SystemParticipantTestData.loadInput), Collections.singleton(SystemParticipantTestData.pvInput), Collections.singleton(SystemParticipantTestData.storageInput), - Collections.singleton(SystemParticipantTestData.wecInput), - Collections.singleton(SystemParticipantTestData.emInput) + Collections.singleton(SystemParticipantTestData.wecInput) ) when: @@ -45,13 +44,12 @@ class SystemParticipantsTest extends Specification { Collections.singleton(SystemParticipantTestData.loadInput), Collections.singleton(SystemParticipantTestData.pvInput), Collections.singleton(SystemParticipantTestData.storageInput), - Collections.singleton(SystemParticipantTestData.wecInput), - Collections.singleton(SystemParticipantTestData.emInput) + Collections.singleton(SystemParticipantTestData.wecInput) ) def modifiedBmInput = SystemParticipantTestData.bmInput.copy().id("modified").build() def modifiedChpInput = SystemParticipantTestData.chpInput.copy().id("modified").build() - def modifiedEvCSInput = SystemParticipantTestData.evcsInput.copy().id("modified").build() + def modifiedEvcsInput = SystemParticipantTestData.evcsInput.copy().id("modified").build() def modifiedEvInput = SystemParticipantTestData.evInput.copy().id("modified").build() def modifiedFixedFeedInInput = SystemParticipantTestData.fixedFeedInInput.copy().id("modified").build() def modifiedHpInput = SystemParticipantTestData.hpInput.copy().id("modified").build() @@ -59,13 +57,12 @@ class SystemParticipantsTest extends Specification { def modifiedPvInput = SystemParticipantTestData.pvInput.copy().id("modified").build() def modifiedStorageInput = SystemParticipantTestData.storageInput.copy().id("modified").build() def modifiedWecInput = SystemParticipantTestData.wecInput.copy().id("modified").build() - def modifiedEmInput = SystemParticipantTestData.emInput.copy().id("modified").build() when: def modifiedSystemParticipants = systemParticipants.copy() .bmPlants(Set.of(modifiedBmInput)) .chpPlants(Set.of(modifiedChpInput)) - .evCS(Set.of(modifiedEvCSInput)) + .evcs(Set.of(modifiedEvcsInput)) .evs(Set.of(modifiedEvInput)) .fixedFeedIn(Set.of(modifiedFixedFeedInInput)) .heatPumps(Set.of(modifiedHpInput)) @@ -73,13 +70,12 @@ class SystemParticipantsTest extends Specification { .pvPlants(Set.of(modifiedPvInput)) .storages(Set.of(modifiedStorageInput)) .wecPlants(Set.of(modifiedWecInput)) - .emSystems(Set.of(modifiedEmInput)) .build() then: modifiedSystemParticipants.bmPlants.first() == modifiedBmInput modifiedSystemParticipants.chpPlants.first() == modifiedChpInput - modifiedSystemParticipants.evCS.first() == modifiedEvCSInput + modifiedSystemParticipants.evcs.first() == modifiedEvcsInput modifiedSystemParticipants.evs.first() == modifiedEvInput modifiedSystemParticipants.fixedFeedIns.first() == modifiedFixedFeedInInput modifiedSystemParticipants.heatPumps.first() == modifiedHpInput @@ -87,6 +83,5 @@ class SystemParticipantsTest extends Specification { modifiedSystemParticipants.pvPlants.first() == modifiedPvInput modifiedSystemParticipants.storages.first() == modifiedStorageInput modifiedSystemParticipants.wecPlants.first() == modifiedWecInput - modifiedSystemParticipants.emSystems.first() == modifiedEmInput } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/BmInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/BmInputTest.groovy index a5775d34d..d2bdf6069 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/BmInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/BmInputTest.groovy @@ -5,12 +5,12 @@ */ package edu.ie3.datamodel.models.input.system +import static edu.ie3.util.quantities.PowerSystemUnits.EURO_PER_MEGAWATTHOUR + import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.util.quantities.PowerSystemUnits.EURO_PER_MEGAWATTHOUR - class BmInputTest extends Specification { def "A BmInput copy method should work as expected"() { @@ -33,6 +33,29 @@ class BmInputTest extends Specification { assert qCharacteristics == bmInput.qCharacteristics assert feedInTariff == Quantities.getQuantity(15, EURO_PER_MEGAWATTHOUR) assert type == SystemParticipantTestData.bmTypeInput + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a BmInput via builder should work as expected"() { + given: + def bmInput = SystemParticipantTestData.bmInput + + when: + def alteredUnit = bmInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == bmInput.uuid + assert operationTime == bmInput.operationTime + assert operator == bmInput.operator + assert id == bmInput.id + assert marketReaction == bmInput.marketReaction + assert costControlled == bmInput.costControlled + assert qCharacteristics == bmInput.qCharacteristics + assert feedInTariff == bmInput.feedInTariff + assert type.sRated == bmInput.type.sRated * 2d + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/ChpInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/ChpInputTest.groovy index bc6f7f93e..91d94c44b 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/ChpInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/ChpInputTest.groovy @@ -8,7 +8,6 @@ package edu.ie3.datamodel.models.input.system import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification - class ChpInputTest extends Specification { def "A ChpInput copy method should work as expected"() { @@ -19,7 +18,6 @@ class ChpInputTest extends Specification { def alteredUnit = chpInput.copy().thermalBus(SystemParticipantTestData.thermalBus) .type(SystemParticipantTestData.chpTypeInput).thermalStorage(SystemParticipantTestData.thermalStorage).marketReaction(true).build() - then: alteredUnit.with { assert uuid == chpInput.uuid @@ -31,6 +29,31 @@ class ChpInputTest extends Specification { assert thermalStorage == SystemParticipantTestData.thermalStorage assert marketReaction assert type == SystemParticipantTestData.chpTypeInput + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a ChpInput via builder should work as expected"() { + given: + def chpInput = SystemParticipantTestData.chpInput + + when: + def alteredUnit = chpInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == chpInput.uuid + assert operationTime == chpInput.operationTime + assert operator == chpInput.operator + assert id == chpInput.id + assert qCharacteristics == chpInput.qCharacteristics + assert thermalBus == chpInput.thermalBus + assert thermalStorage == chpInput.thermalStorage + assert marketReaction == chpInput.marketReaction + assert type.sRated == chpInput.type.sRated * 2d + assert type.pThermal == chpInput.type.pThermal * 2d + assert type.pOwn == chpInput.type.pOwn * 2d + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy index 20e6bbe31..3c1c6f706 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/EmInputTest.groovy @@ -5,12 +5,10 @@ */ package edu.ie3.datamodel.models.input.system -import static edu.ie3.datamodel.models.ControlStrategy.DefaultControlStrategies.NO_CONTROL_STRATEGY -import edu.ie3.datamodel.models.ControlStrategy +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification - class EmInputTest extends Specification { def "The EmInput constructors work as expected"() { @@ -18,19 +16,15 @@ class EmInputTest extends Specification { def emInput = new EmInput( UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), "test_emInput", - SystemParticipantTestData.participantNode, - SystemParticipantTestData.cosPhiFixed, - SystemParticipantTestData.connectedAssets, - SystemParticipantTestData.emControlStrategy + SystemParticipantTestData.emControlStrategy, + SystemParticipantTestData.parentEm ) then: emInput.with { assert uuid == UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792") assert id == "test_emInput" - assert qCharacteristics == SystemParticipantTestData.cosPhiFixed - assert connectedAssets == SystemParticipantTestData.connectedAssets - assert controlStrategy.key == SystemParticipantTestData.emControlStrategy + assert controlStrategy == SystemParticipantTestData.emControlStrategy } } @@ -64,28 +58,26 @@ class EmInputTest extends Specification { SystemParticipantTestData.emInput.operator.uuid + ", operationTime=" + SystemParticipantTestData.emInput.operationTime + - ", node=" + - SystemParticipantTestData.emInput.node.uuid + - ", qCharacteristics='" + - SystemParticipantTestData.emInput.qCharacteristics + - ", connectedAssets=" + - Arrays.toString(SystemParticipantTestData.emInput.connectedAssets) + ", controlStrategy=" + SystemParticipantTestData.emInput.controlStrategy + + ", parentEm=" + + SystemParticipantTestData.parentEm.uuid + '}' } def "A EmInput copy method should work as expected"() { given: def emInput = SystemParticipantTestData.emInput - def newConnectedAssets = [ - UUID.randomUUID(), - UUID.randomUUID() - ] as UUID[] - + def newStrat = "new_strat" + def givenParentEm = new EmInput( + UUID.fromString("cfc0639b-65bc-47e5-a8e5-82703de3c650"), + "testParent", + "controlStrat", + null + ) when: - def alteredUnit = emInput.copy().connectedAssets(newConnectedAssets).controlStrategy(ControlStrategy.parse("")).build() + def alteredUnit = emInput.copy().controlStrategy(newStrat).parentEm(givenParentEm).build() then: alteredUnit.with { @@ -93,9 +85,8 @@ class EmInputTest extends Specification { assert operationTime == emInput.operationTime assert operator == emInput.operator assert id == emInput.id - assert qCharacteristics == emInput.qCharacteristics - assert connectedAssets == newConnectedAssets - assert controlStrategy == NO_CONTROL_STRATEGY + assert controlStrategy == newStrat + assert parentEm == Optional.of(givenParentEm) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvInputTest.groovy index f31375f45..9f0b96642 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvInputTest.groovy @@ -26,6 +26,28 @@ class EvInputTest extends Specification { assert id == ev.id assert qCharacteristics == ev.qCharacteristics assert type == SystemParticipantTestData.evTypeInput + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling an EvInput via builder should work as expected"() { + given: + def ev = SystemParticipantTestData.evInput + + when: + def alteredUnit = ev.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == ev.uuid + assert operationTime == ev.operationTime + assert operator == ev.operator + assert id == ev.id + assert qCharacteristics == ev.qCharacteristics + assert type.sRated == ev.type.sRated * 2d + assert type.eStorage == ev.type.eStorage * 2d + assert type.eCons == ev.type.eCons * 2d + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy index d27e95008..ec3e4fc24 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/EvcsInputTest.groovy @@ -12,7 +12,7 @@ import spock.lang.Specification class EvcsInputTest extends Specification { - def "A EvCsInput copy method should work as expected"() { + def "An EvcsInput copy method should work as expected"() { given: def evcsInput = SystemParticipantTestData.evcsInput @@ -36,6 +36,30 @@ class EvcsInputTest extends Specification { assert chargingPoints == 1 assert locationType == EvcsLocationType.CHARGING_HUB_HIGHWAY assert v2gSupport + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling an EvcsInput via builder should work as expected"() { + given: + def evcsInput = SystemParticipantTestData.evcsInput + + when: + def alteredUnit = evcsInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == evcsInput.uuid + assert operationTime == evcsInput.operationTime + assert operator == evcsInput.operator + assert id == evcsInput.id + assert qCharacteristics == evcsInput.qCharacteristics + assert type.sRated == evcsInput.type.sRated * 2d + assert cosPhiRated == evcsInput.cosPhiRated + assert chargingPoints == evcsInput.chargingPoints + assert locationType == evcsInput.locationType + assert v2gSupport == evcsInput.v2gSupport + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/FixedFeedInInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/FixedFeedInInputTest.groovy index 500da895b..483877ac3 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/FixedFeedInInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/FixedFeedInInputTest.groovy @@ -29,6 +29,27 @@ class FixedFeedInInputTest extends Specification { assert qCharacteristics == ffIn.qCharacteristics assert sRated == Quantities.getQuantity(10d, PowerSystemUnits.VOLTAMPERE) assert cosPhiRated == 0.8d + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a FixedFeedInInput via builder should work as expected"() { + given: + def ffIn = SystemParticipantTestData.fixedFeedInInput + + when: + def alteredUnit = ffIn.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == ffIn.uuid + assert operationTime == ffIn.operationTime + assert operator == ffIn.operator + assert id == ffIn.id + assert qCharacteristics == ffIn.qCharacteristics + assert sRated == ffIn.sRated * 2d + assert cosPhiRated == ffIn.cosPhiRated + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/HpInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/HpInputTest.groovy index 9e40de6d6..1d3c30ec0 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/HpInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/HpInputTest.groovy @@ -28,6 +28,28 @@ class HpInputTest extends Specification { assert qCharacteristics == hpInput.qCharacteristics assert thermalBus == SystemParticipantTestData.thermalBus assert type == SystemParticipantTestData.hpTypeInput + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a HpInput via builder should work as expected"() { + given: + def hpInput = SystemParticipantTestData.hpInput + + when: + def alteredUnit = hpInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == hpInput.uuid + assert operationTime == hpInput.operationTime + assert operator == hpInput.operator + assert id == hpInput.id + assert qCharacteristics == hpInput.qCharacteristics + assert thermalBus == hpInput.thermalBus + assert type.sRated == hpInput.type.sRated * 2d + assert type.pThermal == hpInput.type.pThermal * 2d + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/LoadInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/LoadInputTest.groovy index b6dfbfcbb..5f5c4e9ea 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/LoadInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/LoadInputTest.groovy @@ -5,16 +5,16 @@ */ package edu.ie3.datamodel.models.input.system -import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile +import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR + import edu.ie3.datamodel.models.input.system.characteristic.CosPhiFixed +import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.test.common.GridTestData import edu.ie3.test.common.SystemParticipantTestData import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATTHOUR - class LoadInputTest extends Specification { @@ -41,6 +41,31 @@ class LoadInputTest extends Specification { assert eConsAnnual == Quantities.getQuantity(6000, KILOWATTHOUR) assert sRated == Quantities.getQuantity(0d, KILOVOLTAMPERE) assert cosPhiRated == 0.8d + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a LoadInput via builder should work as expected"() { + given: + def loadInput = SystemParticipantTestData.loadInput + + when: + def alteredUnit = loadInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == loadInput.uuid + assert operationTime == loadInput.operationTime + assert operator == loadInput.operator + assert id == loadInput.id + assert loadProfile == loadInput.loadProfile + assert dsm == loadInput.dsm + assert node == loadInput.node + assert qCharacteristics == loadInput.qCharacteristics + assert eConsAnnual == loadInput.eConsAnnual * 2d + assert sRated == loadInput.sRated * 2d + assert cosPhiRated == loadInput.cosPhiRated + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/PvInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/PvInputTest.groovy index 4d00c8d37..61e8beca2 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/PvInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/PvInputTest.groovy @@ -5,14 +5,14 @@ */ package edu.ie3.datamodel.models.input.system -import edu.ie3.test.common.SystemParticipantTestData -import spock.lang.Specification -import tech.units.indriya.quantity.Quantities - import static edu.ie3.util.quantities.PowerSystemUnits.DEGREE_GEOM import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE import static tech.units.indriya.unit.Units.PERCENT +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + class PvInputTest extends Specification { @@ -24,6 +24,7 @@ class PvInputTest extends Specification { def alteredUnit = pvInput.copy().albedo(10).azimuth(Quantities.getQuantity(10, DEGREE_GEOM)).elevationAngle(Quantities.getQuantity(50, DEGREE_GEOM)) .etaConv(Quantities.getQuantity(50d, PERCENT)).kG(10).kT(5).marketReaction(true).sRated(Quantities.getQuantity(0d, KILOVOLTAMPERE)) .cosPhiRated(0.7d).build() + then: alteredUnit.with { assert uuid == pvInput.uuid @@ -40,6 +41,34 @@ class PvInputTest extends Specification { assert elevationAngle == Quantities.getQuantity(50, DEGREE_GEOM) assert kG == 10 assert kT == 5 + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a PvInput via builder should work as expected"() { + given: + def pvInput = SystemParticipantTestData.pvInput + + when: + def alteredUnit = pvInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == pvInput.uuid + assert operationTime == pvInput.operationTime + assert operator == pvInput.operator + assert id == pvInput.id + assert qCharacteristics == pvInput.qCharacteristics + assert sRated == pvInput.sRated * 2d + assert cosPhiRated == pvInput.cosPhiRated + assert marketReaction == pvInput.marketReaction + assert albedo == pvInput.albedo + assert azimuth == pvInput.azimuth + assert etaConv == pvInput.etaConv + assert elevationAngle == pvInput.elevationAngle + assert kG == pvInput.kG + assert kT == pvInput.kT + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/StorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/StorageInputTest.groovy index 0bea4865f..9d5731150 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/StorageInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/StorageInputTest.groovy @@ -26,6 +26,28 @@ class StorageInputTest extends Specification { assert id == storageInput.id assert qCharacteristics == storageInput.qCharacteristics assert type == SystemParticipantTestData.storageTypeInput + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a StorageInput via builder should work as expected"() { + given: + def storageInput = SystemParticipantTestData.storageInput + + when: + def alteredUnit = storageInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == storageInput.uuid + assert operationTime == storageInput.operationTime + assert operator == storageInput.operator + assert id == storageInput.id + assert qCharacteristics == storageInput.qCharacteristics + assert type.sRated == storageInput.type.sRated * 2d + assert type.eStorage == storageInput.type.eStorage * 2d + assert type.pMax == storageInput.type.pMax * 2d + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/WecInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/WecInputTest.groovy index 9d8b823af..6044974e8 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/WecInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/WecInputTest.groovy @@ -27,6 +27,29 @@ class WecInputTest extends Specification { assert qCharacteristics == wec.qCharacteristics assert type == SystemParticipantTestData.wecType assert marketReaction + assert em == Optional.of(SystemParticipantTestData.emInput) + } + } + + def "Scaling a WecInput via builder should work as expected"() { + given: + def wec = SystemParticipantTestData.wecInput + + when: + def alteredUnit = wec.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == wec.uuid + assert operationTime == wec.operationTime + assert operator == wec.operator + assert id == wec.id + assert qCharacteristics == wec.qCharacteristics + assert type.sRated == wec.type.sRated * 2d + assert type.rotorArea == wec.type.rotorArea * 2d + assert type.hubHeight == wec.type.hubHeight + assert marketReaction == wec.marketReaction + assert em == Optional.of(SystemParticipantTestData.emInput) } } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/BmTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/BmTypeInputTest.groovy new file mode 100644 index 000000000..ebf8077ff --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/BmTypeInputTest.groovy @@ -0,0 +1,59 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.ACTIVE_POWER_IN +import static edu.ie3.datamodel.models.StandardUnits.CAPEX +import static edu.ie3.datamodel.models.StandardUnits.ENERGY_PRICE + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class BmTypeInputTest extends Specification { + + def "A BmTypeInput copy method should work as expected"() { + given: + def bmTypeInput = SystemParticipantTestData.bmTypeInput + + when: + def alteredUnit = bmTypeInput.copy() + .setsRated(Quantities.getQuantity(50d, ACTIVE_POWER_IN)) + .setCapex(Quantities.getQuantity(110d, CAPEX)) + .setOpex(Quantities.getQuantity(20d, ENERGY_PRICE)) + .build() + + then: + alteredUnit.with { + assert uuid == bmTypeInput.uuid + assert id == bmTypeInput.id + assert capex == Quantities.getQuantity(110d, CAPEX) + assert opex == Quantities.getQuantity(20d, ENERGY_PRICE) + assert sRated == Quantities.getQuantity(50d, ACTIVE_POWER_IN) + assert cosPhiRated == bmTypeInput.cosPhiRated + assert etaConv == bmTypeInput.etaConv + } + } + + def "Scaling a BmTypeInput via builder should work as expected"() { + given: + def bmTypeInput = SystemParticipantTestData.bmTypeInput + + when: + def alteredUnit = bmTypeInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == bmTypeInput.uuid + assert id == bmTypeInput.id + assert capex == bmTypeInput.capex * 2d + assert opex == bmTypeInput.opex + assert sRated == bmTypeInput.sRated * 2d + assert cosPhiRated == bmTypeInput.cosPhiRated + assert etaConv == bmTypeInput.etaConv + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/ChpTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/ChpTypeInputTest.groovy new file mode 100644 index 000000000..caf079216 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/ChpTypeInputTest.groovy @@ -0,0 +1,64 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.ACTIVE_POWER_IN +import static edu.ie3.datamodel.models.StandardUnits.EFFICIENCY + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class ChpTypeInputTest extends Specification { + + def "A ChpTypeInput copy method should work as expected"() { + given: + def chpTypeInput = SystemParticipantTestData.chpTypeInput + + when: + def alteredUnit = chpTypeInput.copy() + .setsRated(Quantities.getQuantity(50d, ACTIVE_POWER_IN)) + .setEtaEl(Quantities.getQuantity(20, EFFICIENCY)) + .setpThermal(Quantities.getQuantity(15, ACTIVE_POWER_IN)) + .build() + + then: + alteredUnit.with { + assert uuid == chpTypeInput.uuid + assert id == chpTypeInput.id + assert capex == chpTypeInput.capex + assert opex == chpTypeInput.opex + assert etaEl == Quantities.getQuantity(20, EFFICIENCY) + assert etaThermal == chpTypeInput.etaThermal + assert sRated == Quantities.getQuantity(50d, ACTIVE_POWER_IN) + assert cosPhiRated == chpTypeInput.cosPhiRated + assert pThermal == Quantities.getQuantity(15, ACTIVE_POWER_IN) + assert pOwn == chpTypeInput.pOwn + } + } + + def "Scaling a ChpTypeInput via builder should work as expected"() { + given: + def chpTypeInput = SystemParticipantTestData.chpTypeInput + + when: + def alteredUnit = chpTypeInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == chpTypeInput.uuid + assert id == chpTypeInput.id + assert capex == chpTypeInput.capex * 2d + assert opex == chpTypeInput.opex + assert etaEl == chpTypeInput.etaEl + assert etaThermal == chpTypeInput.etaThermal + assert sRated == chpTypeInput.sRated * 2d + assert cosPhiRated == chpTypeInput.cosPhiRated + assert pThermal == chpTypeInput.pThermal * 2d + assert pOwn == chpTypeInput.pOwn * 2d + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/EvTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/EvTypeInputTest.groovy new file mode 100644 index 000000000..0437213dc --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/EvTypeInputTest.groovy @@ -0,0 +1,57 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.ENERGY_IN + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class EvTypeInputTest extends Specification { + + def "A EvTypeInput copy method should work as expected"() { + given: + def evTypeInput = SystemParticipantTestData.evTypeInput + + when: + def alteredUnit = evTypeInput.copy() + .seteStorage(Quantities.getQuantity(150, ENERGY_IN)) + .build() + + then: + alteredUnit.with { + assert uuid == evTypeInput.uuid + assert id == evTypeInput.id + assert capex == evTypeInput.capex + assert opex == evTypeInput.opex + assert eStorage == Quantities.getQuantity(150, ENERGY_IN) + assert eCons == evTypeInput.eCons + assert sRated == evTypeInput.sRated + assert cosPhiRated == evTypeInput.cosPhiRated + } + } + + def "Scaling a EvTypeInput via builder should work as expected"() { + given: + def evTypeInput = SystemParticipantTestData.evTypeInput + + when: + def alteredUnit = evTypeInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == evTypeInput.uuid + assert id == evTypeInput.id + assert capex == evTypeInput.capex * 2d + assert opex == evTypeInput.opex + assert eStorage == evTypeInput.eStorage * 2d + assert eCons == evTypeInput.eCons * 2d + assert sRated == evTypeInput.sRated * 2d + assert cosPhiRated == evTypeInput.cosPhiRated + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/HpTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/HpTypeInputTest.groovy new file mode 100644 index 000000000..1cd6ebf65 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/HpTypeInputTest.groovy @@ -0,0 +1,56 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.ACTIVE_POWER_IN + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class HpTypeInputTest extends Specification { + + def "A HpTypeInput copy method should work as expected"() { + given: + def hpTypeInput = SystemParticipantTestData.hpTypeInput + + when: + def alteredUnit = hpTypeInput.copy() + .setpThermal(Quantities.getQuantity(10, ACTIVE_POWER_IN)) + .setCosPhiRated(0.97d) + .build() + + then: + alteredUnit.with { + assert uuid == hpTypeInput.uuid + assert id == hpTypeInput.id + assert capex == hpTypeInput.capex + assert opex == hpTypeInput.opex + assert sRated == hpTypeInput.sRated + assert cosPhiRated == 0.97d + assert pThermal == Quantities.getQuantity(10, ACTIVE_POWER_IN) + } + } + + def "Scaling a HpTypeInput via builder should work as expected"() { + given: + def hpTypeInput = SystemParticipantTestData.hpTypeInput + + when: + def alteredUnit = hpTypeInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == hpTypeInput.uuid + assert id == hpTypeInput.id + assert capex == hpTypeInput.capex * 2d + assert opex == hpTypeInput.opex + assert sRated == hpTypeInput.sRated * 2d + assert cosPhiRated == hpTypeInput.cosPhiRated + assert pThermal == hpTypeInput.pThermal * 2d + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/StorageTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/StorageTypeInputTest.groovy new file mode 100644 index 000000000..81fa3eec5 --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/StorageTypeInputTest.groovy @@ -0,0 +1,71 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.ACTIVE_POWER_IN +import static edu.ie3.datamodel.models.StandardUnits.ENERGY_IN +import static edu.ie3.datamodel.models.StandardUnits.LIFE_TIME + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class StorageTypeInputTest extends Specification { + + def "A StorageTypeInput copy method should work as expected"() { + given: + def storageTypeInput = SystemParticipantTestData.storageTypeInput + + when: + def alteredUnit = storageTypeInput.copy() + .seteStorage(Quantities.getQuantity(90, ENERGY_IN)) + .setpMax(Quantities.getQuantity(15, ACTIVE_POWER_IN)) + .setLifeTime(Quantities.getQuantity(999999, LIFE_TIME)) + .build() + + then: + alteredUnit.with { + assert uuid == storageTypeInput.uuid + assert id == storageTypeInput.id + assert capex == storageTypeInput.capex + assert opex == storageTypeInput.opex + assert eStorage == Quantities.getQuantity(90, ENERGY_IN) + assert sRated == storageTypeInput.sRated + assert cosPhiRated == storageTypeInput.cosPhiRated + assert pMax == Quantities.getQuantity(15, ACTIVE_POWER_IN) + assert activePowerGradient == storageTypeInput.activePowerGradient + assert eta == storageTypeInput.eta + assert dod == storageTypeInput.dod + assert lifeTime == Quantities.getQuantity(999999, LIFE_TIME) + assert lifeCycle == storageTypeInput.lifeCycle + } + } + + def "Scaling a StorageTypeInput via builder should work as expected"() { + given: + def storageTypeInput = SystemParticipantTestData.storageTypeInput + + when: + def alteredUnit = storageTypeInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == storageTypeInput.uuid + assert id == storageTypeInput.id + assert capex == storageTypeInput.capex * 2d + assert opex == storageTypeInput.opex + assert eStorage == storageTypeInput.eStorage * 2d + assert sRated == storageTypeInput.sRated * 2d + assert cosPhiRated == storageTypeInput.cosPhiRated + assert pMax == storageTypeInput.pMax * 2d + assert activePowerGradient == storageTypeInput.activePowerGradient + assert eta == storageTypeInput.eta + assert dod == storageTypeInput.dod + assert lifeTime == storageTypeInput.lifeTime + assert lifeCycle == storageTypeInput.lifeCycle + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/WecTypeInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/WecTypeInputTest.groovy new file mode 100644 index 000000000..5cadc262f --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/WecTypeInputTest.groovy @@ -0,0 +1,63 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type + +import static edu.ie3.datamodel.models.StandardUnits.HUB_HEIGHT +import static edu.ie3.datamodel.models.StandardUnits.ROTOR_AREA + +import edu.ie3.test.common.SystemParticipantTestData +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class WecTypeInputTest extends Specification { + + def "A WecTypeInput copy method should work as expected"() { + given: + def wecType = SystemParticipantTestData.wecType + + when: + def alteredUnit = wecType.copy() + .setRotorArea(Quantities.getQuantity(25, ROTOR_AREA)) + .setHubHeight(Quantities.getQuantity(180, HUB_HEIGHT)) + .build() + + then: + alteredUnit.with { + assert uuid == wecType.uuid + assert id == wecType.id + assert capex == wecType.capex + assert opex == wecType.opex + assert sRated == wecType.sRated + assert cosPhiRated == wecType.cosPhiRated + assert cpCharacteristic == wecType.cpCharacteristic + assert etaConv == wecType.etaConv + assert rotorArea == Quantities.getQuantity(25, ROTOR_AREA) + assert hubHeight == Quantities.getQuantity(180, HUB_HEIGHT) + } + } + + def "Scaling a WecTypeInput via builder should work as expected"() { + given: + def wecType = SystemParticipantTestData.wecType + + when: + def alteredUnit = wecType.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == wecType.uuid + assert id == wecType.id + assert capex == wecType.capex * 2d + assert opex == wecType.opex + assert sRated == wecType.sRated * 2d + assert cosPhiRated == wecType.cosPhiRated + assert cpCharacteristic == wecType.cpCharacteristic + assert etaConv == wecType.etaConv + assert rotorArea == wecType.rotorArea * 2d + assert hubHeight == wecType.hubHeight + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeTest.groovy new file mode 100644 index 000000000..32f3969fe --- /dev/null +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeTest.groovy @@ -0,0 +1,49 @@ +/* + * © 2024. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.datamodel.models.input.system.type.chargingpoint + +import edu.ie3.datamodel.models.ElectricCurrentType +import edu.ie3.datamodel.models.StandardUnits +import spock.lang.Specification +import tech.units.indriya.quantity.Quantities + +class ChargingPointTypeTest extends Specification { + + def "A ChargingPointType copy method should work as expected"() { + given: + def cpt = ChargingPointTypeUtils.HouseholdSocket + + when: + def alteredUnit = cpt.copy() + .setElectricCurrentType(ElectricCurrentType.DC) + .setsRated(Quantities.getQuantity(2.4, StandardUnits.S_RATED)) + .build() + + then: + alteredUnit.with { + assert id == cpt.id + assert sRated == Quantities.getQuantity(2.4, StandardUnits.S_RATED) + assert electricCurrentType == ElectricCurrentType.DC + assert synonymousIds == cpt.synonymousIds + } + } + + def "Scaling a ChargingPointType via builder should work as expected"() { + given: + def cpt = ChargingPointTypeUtils.HouseholdSocket + + when: + def alteredUnit = cpt.copy().scale(2d).build() + + then: + alteredUnit.with { + assert id == cpt.id + assert sRated == cpt.sRated * 2d + assert electricCurrentType == cpt.electricCurrentType + assert synonymousIds == cpt.synonymousIds + } + } +} diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeUtilsTest.groovy index 16339003e..285a969aa 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/system/type/chargingpoint/ChargingPointTypeUtilsTest.groovy @@ -5,14 +5,14 @@ */ package edu.ie3.datamodel.models.input.system.type.chargingpoint +import static edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils.* +import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE + import edu.ie3.datamodel.exceptions.ChargingPointTypeException import edu.ie3.datamodel.models.ElectricCurrentType import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointTypeUtils.* -import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE - /** * //ToDo: Class Description * diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy index 21e707d69..815876368 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/CylindricalStorageInputTest.groovy @@ -36,4 +36,26 @@ class CylindricalStorageInputTest extends Specification { assert c == ThermalUnitInputTestData.c } } + + def "Scaling a CylindricalStorageInput via builder should work as expected"() { + given: + def cylindricalStorageInput = ThermalUnitInputTestData.cylindricStorageInput + + when: + def alteredUnit = cylindricalStorageInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == cylindricalStorageInput.uuid + assert id == cylindricalStorageInput.id + assert operator == cylindricalStorageInput.operator + assert operationTime == cylindricalStorageInput.operationTime + assert thermalBus == cylindricalStorageInput.thermalBus + assert storageVolumeLvl == cylindricalStorageInput.storageVolumeLvl * 2d + assert storageVolumeLvlMin == cylindricalStorageInput.storageVolumeLvlMin * 2d + assert inletTemp == cylindricalStorageInput.inletTemp + assert returnTemp == cylindricalStorageInput.returnTemp + assert c == cylindricalStorageInput.c + } + } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy index 2f5125e92..d2f9c5afd 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/input/thermal/ThermalHouseInputTest.groovy @@ -74,4 +74,26 @@ class ThermalHouseInputTest extends Specification { thermalHouseInput.upperTemperatureLimit == Quantities.getQuantity(25, StandardUnits.TEMPERATURE) thermalHouseInput.lowerTemperatureLimit == Quantities.getQuantity(15, StandardUnits.TEMPERATURE) } + + def "Scaling a ThermalHouseInput via builder should work as expected"() { + given: + def thermalHouseInput = ThermalUnitInputTestData.thermalHouseInput + + when: + def alteredUnit = thermalHouseInput.copy().scale(2d).build() + + then: + alteredUnit.with { + assert uuid == thermalHouseInput.uuid + assert id == thermalHouseInput.id + assert operator == thermalHouseInput.operator + assert operationTime == thermalHouseInput.operationTime + assert thermalBus == thermalHouseInput.thermalBus + assert ethLosses == thermalHouseInput.ethLosses * 2d + assert ethCapa == thermalHouseInput.ethCapa * 2d + assert targetTemperature == thermalHouseInput.targetTemperature + assert upperTemperatureLimit == thermalHouseInput.upperTemperatureLimit + assert lowerTemperatureLimit == thermalHouseInput.lowerTemperatureLimit + } + } } diff --git a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/CharacteristicPointTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/CharacteristicPointTest.groovy index d69f8d95d..40499c5e7 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/CharacteristicPointTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/CharacteristicPointTest.groovy @@ -5,6 +5,10 @@ */ package edu.ie3.datamodel.models.system.characteristic +import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT +import static edu.ie3.util.quantities.PowerSystemUnits.PU +import static tech.units.indriya.unit.Units.PERCENT + import edu.ie3.datamodel.exceptions.ParsingException import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import spock.lang.Specification @@ -13,10 +17,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless import javax.measure.quantity.Power -import static edu.ie3.util.quantities.PowerSystemUnits.KILOWATT -import static edu.ie3.util.quantities.PowerSystemUnits.PU -import static tech.units.indriya.unit.Units.PERCENT - class CharacteristicPointTest extends Specification { def "A set of CharacteristicCoordinates are sorted correctly"() { given: "A set of points" diff --git a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/OlmCharacteristicTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/OlmCharacteristicTest.groovy index bd98d97e2..dd355b830 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/OlmCharacteristicTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/OlmCharacteristicTest.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.datamodel.models.system.characteristic +import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.ParsingException import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import edu.ie3.datamodel.models.input.system.characteristic.OlmCharacteristicInput @@ -15,9 +18,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless import javax.measure.quantity.Speed -import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class OlmCharacteristicTest extends Specification { @Shared OlmCharacteristicInput validInput diff --git a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/ReactivePowerCharacteristicTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/ReactivePowerCharacteristicTest.groovy index 8ef88bb93..f39a5aa61 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/ReactivePowerCharacteristicTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/ReactivePowerCharacteristicTest.groovy @@ -5,6 +5,8 @@ */ package edu.ie3.datamodel.models.system.characteristic +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.ParsingException import edu.ie3.datamodel.models.input.system.characteristic.* import spock.lang.Shared @@ -13,8 +15,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class ReactivePowerCharacteristicTest extends Specification { @Shared CosPhiFixed validCosPhiFixed diff --git a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/WecCharacteristicTest.groovy b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/WecCharacteristicTest.groovy index 62546f077..149bddc94 100644 --- a/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/WecCharacteristicTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/models/system/characteristic/WecCharacteristicTest.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.datamodel.models.system.characteristic +import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.ParsingException import edu.ie3.datamodel.models.input.system.characteristic.CharacteristicPoint import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput @@ -15,9 +18,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.Dimensionless import javax.measure.quantity.Speed -import static edu.ie3.util.quantities.PowerSystemUnits.METRE_PER_SECOND -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class WecCharacteristicTest extends Specification { @Shared WecCharacteristicInput validInput diff --git a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy index 9d1c8f96c..c07ff0d54 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/ContainerUtilsTest.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.datamodel.utils +import static edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils.* +import static edu.ie3.util.quantities.PowerSystemUnits.PU + import edu.ie3.datamodel.exceptions.InvalidGridException import edu.ie3.datamodel.graph.DistanceWeightedGraph import edu.ie3.datamodel.graph.ImpedanceWeightedGraph @@ -24,9 +27,6 @@ import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities -import static edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils.* -import static edu.ie3.util.quantities.PowerSystemUnits.PU - class ContainerUtilsTest extends Specification { @Shared diff --git a/src/test/groovy/edu/ie3/datamodel/utils/GridAndGeoUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/GridAndGeoUtilsTest.groovy index 4e06605a8..8b9f0cf41 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/GridAndGeoUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/GridAndGeoUtilsTest.groovy @@ -5,13 +5,12 @@ */ package edu.ie3.datamodel.utils -import edu.ie3.util.geo.GeoUtils -import edu.ie3.util.quantities.QuantityUtil -import spock.lang.Shared - import static edu.ie3.util.quantities.PowerSystemUnits.* import edu.ie3.test.common.GridTestData +import edu.ie3.util.geo.GeoUtils +import edu.ie3.util.quantities.QuantityUtil +import spock.lang.Shared import spock.lang.Specification import tech.units.indriya.quantity.Quantities diff --git a/src/test/groovy/edu/ie3/datamodel/utils/TryTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/TryTest.groovy index 4a0ff0762..1419f04f3 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/TryTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/TryTest.groovy @@ -10,6 +10,8 @@ import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.exceptions.TryException import spock.lang.Specification +import java.util.stream.Stream + class TryTest extends Specification { def "A method can be applied to a try object"() { @@ -55,12 +57,10 @@ class TryTest extends Specification { }, FailureException) then: - Exception ex = thrown() - ex.class == TryException + TryException ex = thrown(TryException) ex.message == "Wrongly caught exception: " - Throwable cause = ex.cause - cause.class == SourceException - cause.message == "source exception" + ex.cause.class == SourceException + ex.cause.message == "source exception" } def "A failure is returned when using Failure#ofVoid() with an exception"() { @@ -102,12 +102,10 @@ class TryTest extends Specification { }, FailureException) then: - Exception ex = thrown() - ex.class == TryException + TryException ex = thrown(TryException) ex.message == "Wrongly caught exception: " - Throwable cause = ex.cause - cause.class == SourceException - cause.message == "source exception" + ex.cause.class == SourceException + ex.cause.message == "source exception" } def "A Try object can be creates by a boolean and an exception"() { @@ -160,11 +158,33 @@ class TryTest extends Specification { Try.ofVoid(FailureException, one, two) then: - Exception ex = thrown() - ex.class == TryException - Throwable cause = ex.cause - cause.class == SourceException - cause.message == "source exception" + TryException ex = thrown(TryException) + ex.cause.class == SourceException + ex.cause.message == "source exception" + } + + def "A Success is created from a non-empty Optional"() { + given: + def opt = Optional.of("Test") + + when: + def actualTry = Try.from(opt, () -> new FailureException("failure")) + + then: + actualTry.success + actualTry.data.get() == "Test" + } + + def "A Failure is created from an empty Optional"() { + given: + def opt = Optional.empty() + + when: + def actualTry = Try.from(opt, () -> new FailureException("failure")) + + then: + actualTry.failure + actualTry.exception.get().getMessage() == "failure" } def "A void method can be applied to a try object"() { @@ -241,16 +261,28 @@ class TryTest extends Specification { scan.data.get().size() == 3 } - def "The getOrThrow method should work as expected"() { + def "The getOrThrow method should work as expected on a success"() { + given: + def value = "some value" + Try success = new Try.Success<>(value) + + when: + def result = success.getOrThrow() + + then: + noExceptionThrown() + result == value + } + + def "The getOrThrow method should work as expected on a failure"() { given: Try failure = new Try.Failure<>(new SourceException("source exception")) when: - failure.orThrow + failure.getOrThrow() then: - Exception ex = thrown() - ex.class == SourceException + SourceException ex = thrown(SourceException) ex.message == "source exception" } @@ -311,6 +343,135 @@ class TryTest extends Specification { flatMapF.exception.get() == failure.get() } + def "The convert method should work correctly for successes"() { + given: + Try, SourceException> success = new Try.Success(Stream.of(1, 2, 3)) + + when: + List> converted = success.convert(d -> d.map(r -> Try.Success.of(r)).toList(), e -> [Try.Failure.of(e)] ) + + then: + converted.size() == 3 + converted.get(0).data.get() == 1 + converted.get(1).data.get() == 2 + converted.get(2).data.get() == 3 + } + + def "The convert method should work correctly for failures"() { + given: + SourceException exception = new SourceException("exception") + Try, SourceException> failure = new Try.Failure<>(exception) + + when: + List> converted = failure.convert(d -> d.map(r -> Try.Success.of(r)).toList(), e -> [Try.Failure.of(e)] ) + + then: + converted.size() == 1 + converted.get(0).exception.get() == exception + } + + def "The getOrElse method should work as expected on a success"() { + given: + def value = "some value" + Try success = new Try.Success<>(value) + + when: + def result = success.getOrElse(() -> "other") + + then: + result == value + } + + def "The getOrElse method should work as expected on a failure"() { + given: + Try failure = new Try.Failure<>(new SourceException("source exception")) + def defaultString = "other" + + when: + def result = failure.getOrElse(() -> defaultString) + + then: + result == defaultString + } + + def "The orElse method should work as expected on a success"() { + given: + def otherSuccess = new Try.Success<>("other success") + def otherFailure = new Try.Failure<>(new SourceException("other failure")) + Try success = new Try.Success<>("some value") + + when: + def result1 = success.orElse(() -> otherSuccess) + def result2 = success.orElse(() -> otherFailure) + + then: + result1 == success + result2 == success + } + + def "The orElse method should work as expected on a failure"() { + given: + def otherSuccess = new Try.Success<>("other success") + def otherFailure = new Try.Failure<>(new SourceException("other failure")) + Try failure = new Try.Failure<>(new SourceException("source exception")) + + when: + def result1 = failure.orElse(() -> otherSuccess) + def result2 = failure.orElse(() -> otherFailure) + + then: + result1 == otherSuccess + result2 == otherFailure + } + + def "The toOptional method should work as expected on a success"() { + given: + def value = "some value" + Try success = new Try.Success<>(value) + + when: + def result = success.toOptional() + + then: + result == Optional.of(value) + } + + def "The toOptional method should work as expected on a failure"() { + given: + Try failure = new Try.Failure<>(new SourceException("some failure")) + + when: + def result = failure.toOptional() + + then: + result == Optional.empty() + } + + def "The equals and hashCode method should work as expected on a success"() { + given: + def value = "some value" + Try success1 = new Try.Success<>(value) + Try success2 = new Try.Success<>(value) + Try success3 = new Try.Success<>("other value") + + expect: + success1 == success2 + success1.hashCode() == success2.hashCode() + success1 != success3 + success1.hashCode() != success3.hashCode() + } + + def "The equals and hashCode method should work as expected on a failure"() { + given: + // exceptions usually do not implement #equals, this is difficult to test + Try failure1 = new Try.Failure<>(new SourceException("some failure")) + Try failure2 = new Try.Failure<>(new SourceException("other failure")) + + expect: + failure1 != failure2 + failure1.hashCode() != failure2.hashCode() + } + def "All exceptions of a collection of try objects should be returned"() { given: List> tries = List.of( diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantInput.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantInput.groovy index 9aee7acf6..e8f27b4df 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantInput.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantInput.groovy @@ -13,7 +13,7 @@ import java.time.ZonedDateTime class InvalidSystemParticipantInput extends SystemParticipantInput { InvalidSystemParticipantInput(NodeInput node) { - super(UUID.randomUUID(), "invalid_system_participant", node, CosPhiFixed.CONSTANT_CHARACTERISTIC) + super(UUID.randomUUID(), "invalid_system_participant", node, CosPhiFixed.CONSTANT_CHARACTERISTIC, null) } @Override diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantTypeInput.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantTypeInput.groovy index 6c48c319c..32158181e 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantTypeInput.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/InvalidSystemParticipantTypeInput.groovy @@ -5,6 +5,7 @@ */ package edu.ie3.datamodel.utils.validation +import edu.ie3.datamodel.exceptions.NotImplementedException import edu.ie3.datamodel.models.StandardUnits import edu.ie3.datamodel.models.input.system.type.SystemParticipantTypeInput import tech.units.indriya.quantity.Quantities @@ -21,4 +22,9 @@ class InvalidSystemParticipantTypeInput extends SystemParticipantTypeInput { InvalidSystemParticipantTypeInput() { super(UUID.randomUUID(), "invalid_system_participant_type", Quantities.getQuantity(0d, StandardUnits.CAPEX), Quantities.getQuantity(0d, StandardUnits.ENERGY_PRICE), Quantities.getQuantity(0d, StandardUnits.S_RATED), 1.0d) } + + @Override + SystemParticipantTypeInputCopyBuilder copy() { + throw new NotImplementedException("Not implemented") + } } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtilsTest.groovy index 6f9cc47aa..864d621a6 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/SystemParticipantValidationUtilsTest.groovy @@ -5,11 +5,16 @@ */ package edu.ie3.datamodel.utils.validation +import static edu.ie3.datamodel.models.ElectricCurrentType.AC +import static edu.ie3.datamodel.models.StandardUnits.* +import static edu.ie3.util.quantities.PowerSystemUnits.KILOVOLTAMPERE +import static tech.units.indriya.unit.Units.PERCENT + import edu.ie3.datamodel.exceptions.InvalidEntityException -import edu.ie3.datamodel.exceptions.NotImplementedException import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput import edu.ie3.datamodel.models.input.system.type.* +import edu.ie3.datamodel.models.input.system.type.chargingpoint.ChargingPointType import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.SystemParticipantTestData import edu.ie3.util.quantities.interfaces.Currency @@ -21,9 +26,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.* -import static edu.ie3.datamodel.models.StandardUnits.* -import static tech.units.indriya.unit.Units.PERCENT - class SystemParticipantValidationUtilsTest extends Specification { def "Instantiating a ConnectorValidationUtil leads to an exception"() { @@ -48,7 +50,7 @@ class SystemParticipantValidationUtilsTest extends Specification { def "SystemParticipantValidationUtils.check() recognizes all potential errors for a system participant"() { when: - List> exceptions = SystemParticipantValidationUtils.check(invalidSystemParticipant).stream().filter { it -> it.failure }.toList() + List> exceptions = SystemParticipantValidationUtils.check(invalidSystemParticipant).findAll { it -> it.failure } then: exceptions.size() == expectedSize @@ -255,7 +257,7 @@ class SystemParticipantValidationUtilsTest extends Specification { def "SystemParticipantValidationUtils.checkFixedFeedIn() recognizes all potential errors for an a Fixed Feed-In"() { when: - List> exceptions = SystemParticipantValidationUtils.check(invalidFixedFeedIn).stream().filter { it -> it.failure }.toList() + List> exceptions = SystemParticipantValidationUtils.check(invalidFixedFeedIn).findAll { it -> it.failure } then: exceptions.size() == expectedSize @@ -325,7 +327,7 @@ class SystemParticipantValidationUtilsTest extends Specification { def "SystemParticipantValidationUtils.checkLoad() recognizes all potential errors for a load"() { when: - List> exceptions = SystemParticipantValidationUtils.check(invalidLoad).stream().filter { it -> it.failure }.toList() + List> exceptions = SystemParticipantValidationUtils.check(invalidLoad).findAll { it -> it.failure } then: exceptions.size() == expectedSize @@ -355,7 +357,7 @@ class SystemParticipantValidationUtilsTest extends Specification { def "SystemParticipantValidationUtils.checkPV() recognizes all potential errors for a PV"() { when: - List> exceptions = SystemParticipantValidationUtils.check(invalidPV).stream().filter { it -> it.failure }.toList() + List> exceptions = SystemParticipantValidationUtils.check(invalidPV).findAll { it -> it.failure } then: exceptions.size() == expectedSize @@ -460,39 +462,36 @@ class SystemParticipantValidationUtilsTest extends Specification { new WecTypeInput(uuid, id, capex, opex, sRated, cosPhiRated, wecCharacteristic, etaConv, Quantities.getQuantity(-10, ROTOR_AREA), Quantities.getQuantity(-200, HUB_HEIGHT)) || new InvalidEntityException("The following quantities have to be zero or positive: -10 m², -200 m", invalidWecType) } - def "Checking an unsupported asset leads to an exception"() { - given: - def node = Mock(NodeInput) - node.getUuid() >> UUID.randomUUID() - def invalidParticipant = new InvalidSystemParticipantInput(node) - + def "SystemParticipantValidationUtils.checkEvcs() recognizes all potential errors for a evcs"() { when: - List> exceptions = SystemParticipantValidationUtils.check(invalidParticipant).stream().filter { it -> it.failure }.toList() + def exceptions = SystemParticipantValidationUtils.check(invalidEvcs).findAll { it.failure } then: - def e = exceptions.get(0).exception.get().cause - e.message == "Cannot validate object of class 'InvalidSystemParticipantInput', as no routine is implemented." + exceptions.size() == 1 + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedException.class + ex.message == expectedException.message + + where: + invalidEvcs || expectedException + SystemParticipantTestData.evcsInput.copy().chargingPoints(-1).build() || new InvalidEntityException("Invalid number of charging points: '-1'. At least one charging point is needed.", invalidEvcs) + SystemParticipantTestData.evcsInput.copy().chargingPoints(0).build() || new InvalidEntityException("Invalid number of charging points: '0'. At least one charging point is needed.", invalidEvcs) + SystemParticipantTestData.evcsInput.copy().cosPhiRated(2).build() || new InvalidEntityException("Rated power factor of EvcsInput must be between 0 and 1", invalidEvcs) } - def "Checking an unsupported asset type leads to an exception"() { + def "SystemParticipantValidationUtils.checkEvcs() recognizes all potential errors for a evcs type"() { given: - def invalidParticipantInput = new InvalidSystemParticipantTypeInput() - - when: - SystemParticipantValidationUtils.check(invalidParticipantInput) + def invalidType = new ChargingPointType("invalid type", Quantities.getQuantity(-1d, KILOVOLTAMPERE), AC) + def invalidEvcs = SystemParticipantTestData.evcsInput.copy().type(invalidType).build() + def expectedExceptions = new InvalidEntityException("The following quantities have to be zero or positive: -1 kVA", invalidEvcs) - then: - Throwable topEx = thrown() - Throwable e = topEx.cause - e.message.contains "Cannot validate object of class 'InvalidSystemParticipantTypeInput', as no routine is implemented." - } - - def "Checking electric vehicle charging stations leads to an exception"() { when: - SystemParticipantValidationUtils.checkEvcs() + def exceptions = SystemParticipantValidationUtils.check(invalidEvcs).findAll { it.failure } then: - def e = thrown(NotImplementedException) - e.message == "Validation of 'EvcsInput' is currently not supported." + exceptions.size() == 1 + Exception ex = exceptions.get(0).exception.get() + ex.class == expectedExceptions.class + ex.message == expectedExceptions.message } } diff --git a/src/test/groovy/edu/ie3/datamodel/utils/validation/ValidationUtilsTest.groovy b/src/test/groovy/edu/ie3/datamodel/utils/validation/ValidationUtilsTest.groovy index 26c43982d..4dd02967b 100644 --- a/src/test/groovy/edu/ie3/datamodel/utils/validation/ValidationUtilsTest.groovy +++ b/src/test/groovy/edu/ie3/datamodel/utils/validation/ValidationUtilsTest.groovy @@ -11,21 +11,19 @@ import static edu.ie3.datamodel.utils.validation.DummyAssetInput.valid import static edu.ie3.util.quantities.PowerSystemUnits.OHM_PER_KILOMETRE import static edu.ie3.util.quantities.PowerSystemUnits.PU -import edu.ie3.datamodel.exceptions.FailedValidationException +import edu.ie3.datamodel.exceptions.DuplicateEntitiesException import edu.ie3.datamodel.exceptions.InvalidEntityException -import edu.ie3.datamodel.exceptions.UnsafeEntityException import edu.ie3.datamodel.exceptions.ValidationException import edu.ie3.datamodel.models.OperationTime +import edu.ie3.datamodel.models.UniqueEntity import edu.ie3.datamodel.models.input.AssetInput import edu.ie3.datamodel.models.input.NodeInput -import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.connector.type.LineTypeInput import edu.ie3.datamodel.models.voltagelevels.GermanVoltageLevelUtils import edu.ie3.datamodel.utils.Try import edu.ie3.test.common.GridTestData import edu.ie3.util.TimeUtil import edu.ie3.util.quantities.interfaces.SpecificConductance -import org.locationtech.jts.geom.Coordinate import spock.lang.Specification import tech.units.indriya.quantity.Quantities @@ -44,36 +42,15 @@ class ValidationUtilsTest extends Specification { noExceptionThrown() } - def "The validation utils should determine if a collection with UniqueEntity's is distinct by their uuid"() { - - expect: - ValidationUtils.distinctUuids(collection) == distinct - - where: - collection || distinct - [ - GridTestData.nodeF, - new NodeInput( - UUID.fromString("9e37ce48-9650-44ec-b888-c2fd182aff01"), "node_g", OperatorInput.NO_OPERATOR_ASSIGNED, - OperationTime.notLimited() - , - Quantities.getQuantity(1d, PU), - false, - null, - GermanVoltageLevelUtils.LV, - 6) - ] as Set || false - [ - GridTestData.nodeD, - GridTestData.nodeE - ] as Set || true - [] as Set || true - } - def "The validation utils should check for duplicates as expected"() { - expect: - ValidationUtils.checkForDuplicateUuids(collection) == checkResult + def tries = ValidationUtils.checkForDuplicates(collection, UniqueEntity::getUuid) + + if (!tries.isEmpty()) { + tries.get(0).exception.map { + it.message + } == checkResult + } where: collection || checkResult @@ -96,9 +73,9 @@ class ValidationUtilsTest extends Specification { null, GermanVoltageLevelUtils.LV, 6) - ] as Set || Optional.of("9e37ce48-9650-44ec-b888-c2fd182aff01: 2\n" + - " - NodeInput{uuid=9e37ce48-9650-44ec-b888-c2fd182aff01, id='node_f', operator=f15105c4-a2de-4ab8-a621-4bc98e372d92, operationTime=OperationTime{startDate=null, endDate=null, isLimited=false}, vTarget=1 p.u., slack=false, geoPosition=null, voltLvl=CommonVoltageLevel{id='Niederspannung', nominalVoltage=0.4 kV, synonymousIds=[Niederspannung, lv, ns], voltageRange=Interval [0.0 kV, 10 kV)}, subnet=6}\n" + - " - NodeInput{uuid=9e37ce48-9650-44ec-b888-c2fd182aff01, id='node_g', operator=f15105c4-a2de-4ab8-a621-4bc98e372d92, operationTime=OperationTime{startDate=null, endDate=null, isLimited=false}, vTarget=1 p.u., slack=false, geoPosition=null, voltLvl=CommonVoltageLevel{id='Niederspannung', nominalVoltage=0.4 kV, synonymousIds=[Niederspannung, lv, ns], voltageRange=Interval [0.0 kV, 10 kV)}, subnet=6}") + ] as Set || Optional.of("The following entities have duplicate 'UUID': " + + "{NodeInput{uuid=9e37ce48-9650-44ec-b888-c2fd182aff01, id='node_f', operator=f15105c4-a2de-4ab8-a621-4bc98e372d92, operationTime=OperationTime{startDate=null, endDate=null, isLimited=false}, vTarget=1 p.u., slack=false, geoPosition=null, voltLvl=CommonVoltageLevel{id='Niederspannung', nominalVoltage=0.4 kV, synonymousIds=[Niederspannung, lv, ns], voltageRange=Interval [0.0 kV, 10 kV)}, subnet=6}, " + + "NodeInput{uuid=9e37ce48-9650-44ec-b888-c2fd182aff01, id='node_g', operator=f15105c4-a2de-4ab8-a621-4bc98e372d92, operationTime=OperationTime{startDate=null, endDate=null, isLimited=false}, vTarget=1 p.u., slack=false, geoPosition=null, voltLvl=CommonVoltageLevel{id='Niederspannung', nominalVoltage=0.4 kV, synonymousIds=[Niederspannung, lv, ns], voltageRange=Interval [0.0 kV, 10 kV)}, subnet=6}}") [ GridTestData.nodeD, GridTestData.nodeE @@ -106,19 +83,6 @@ class ValidationUtilsTest extends Specification { [] as Set || Optional.empty() } - def "If an object can't be identified, a ValidationException is thrown as expected"() { - when: - ValidationUtils.check(invalidObject) - - then: - Exception ex = thrown() - ex.message.contains(expectedException.message) - - where: - invalidObject || expectedException - new Coordinate(10, 10) || new FailedValidationException("Cannot validate object of class '" + invalidObject.class.simpleName + "', as no routine is implemented.") - } - def "The validation check method recognizes all potential errors for an asset"() { when: ValidationUtils.check(invalidAsset) @@ -133,32 +97,32 @@ class ValidationUtilsTest extends Specification { GridTestData.nodeA.copy().id(null).build() || new InvalidEntityException("No ID assigned", invalidAsset) GridTestData.nodeA.copy().operationTime(null).build() || new InvalidEntityException("Operation time of the asset is not defined", invalidAsset) GridTestData.nodeA.copy().operationTime(OperationTime.builder(). - withStart(TimeUtil.withDefaults.toZonedDateTime("2020-03-26 15:11:31")). - withEnd(TimeUtil.withDefaults.toZonedDateTime("2020-03-25 15:11:31")).build()).build() || new InvalidEntityException("Operation start time of the asset has to be before end time", invalidAsset) + withStart(TimeUtil.withDefaults.toZonedDateTime("2020-03-26 15:11:31")). + withEnd(TimeUtil.withDefaults.toZonedDateTime("2020-03-25 15:11:31")).build()).build() || new InvalidEntityException("Operation start time of the asset has to be before end time", invalidAsset) } def "The check for negative entities should work as expected"() { given: def asset = new LineTypeInput( - UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), - "lineType_AtoB", - Quantities.getQuantity(0d, SUSCEPTANCE_PER_LENGTH), - Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), - Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), - Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), - Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), - Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) - ) + UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), + "lineType_AtoB", + Quantities.getQuantity(0d, SUSCEPTANCE_PER_LENGTH), + Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), + Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), + Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), + Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), + Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) + ) def invalidAsset = new LineTypeInput( - UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), - "lineType_AtoB", - Quantities.getQuantity(-1d, SUSCEPTANCE_PER_LENGTH), // invalid value - Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), - Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), - Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), - Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), - Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) - ) + UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), + "lineType_AtoB", + Quantities.getQuantity(-1d, SUSCEPTANCE_PER_LENGTH), // invalid value + Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), + Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), + Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), + Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), + Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) + ) when: ValidationUtils.detectNegativeQuantities([asset.getB()] as Quantity[], asset) @@ -177,25 +141,25 @@ class ValidationUtilsTest extends Specification { def "The check for zero or negative entities should work as expected"() { given: def asset = new LineTypeInput( - UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), - "lineType_AtoB", - Quantities.getQuantity(1d, SUSCEPTANCE_PER_LENGTH), - Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), - Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), - Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), - Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), - Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) - ) + UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), + "lineType_AtoB", + Quantities.getQuantity(1d, SUSCEPTANCE_PER_LENGTH), + Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), + Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), + Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), + Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), + Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) + ) def invalidAsset = new LineTypeInput( - UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), - "lineType_AtoB", - Quantities.getQuantity(0d, SUSCEPTANCE_PER_LENGTH), // invalid value - Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), - Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), - Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), - Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), - Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) - ) + UUID.fromString("3bed3eb3-9790-4874-89b5-a5434d408088"), + "lineType_AtoB", + Quantities.getQuantity(0d, SUSCEPTANCE_PER_LENGTH), // invalid value + Quantities.getQuantity(0d, CONDUCTANCE_PER_LENGTH), + Quantities.getQuantity(0.437d, OHM_PER_KILOMETRE), + Quantities.getQuantity(0.356d, OHM_PER_KILOMETRE), + Quantities.getQuantity(300d, ELECTRIC_CURRENT_MAGNITUDE), + Quantities.getQuantity(20d, RATED_VOLTAGE_MAGNITUDE) + ) when: ValidationUtils.detectZeroOrNegativeQuantities([asset.getB()] as Quantity[], asset) @@ -211,32 +175,6 @@ class ValidationUtilsTest extends Specification { ex.message == "Entity is invalid because of: \nThe following quantities have to be positive: 0.0 µS/km [LineTypeInput{uuid=3bed3eb3-9790-4874-89b5-a5434d408088, id=lineType_AtoB, b=0.0 µS/km, g=0.0 µS/km, r=0.437 Ω/km, x=0.356 Ω/km, iMax=300 A, vRated=20 kV}]" } - def "Checking an unsupported asset leads to an exception"() { - given: - def invalidAsset = invalid() - - when: - List> exceptions = ValidationUtils.checkAsset(invalidAsset).stream().filter { it -> it.failure }.toList() - - then: - exceptions.size() == 1 - def e = exceptions.get(0).exception.get() - e.message.contains("Cannot validate object of class 'DummyAssetInput', as no routine is implemented.") - } - - def "Checking an unsupported asset type leads to an exception"() { - given: - def invalidAssetType = new InvalidAssetTypeInput() - - when: - List> exceptions = ValidationUtils.checkAssetType(invalidAssetType).stream().filter { it -> it.failure }.toList() - - then: - exceptions.size() == 1 - def e = exceptions.get(0).exception.get() - e.message.contains("Cannot validate object of class 'InvalidAssetTypeInput', as no routine is implemented.") - } - def "Checking an asset type input without an id leads to an exception"() { given: def invalidAssetType = new InvalidAssetTypeInput(UUID.randomUUID(), null) @@ -245,7 +183,7 @@ class ValidationUtilsTest extends Specification { List> exceptions = ValidationUtils.checkAssetType(invalidAssetType).stream().filter { it -> it.failure }.toList() then: - exceptions.size() == 2 + exceptions.size() == 1 def e = exceptions.get(0).exception.get() e.message.startsWith("Entity is invalid because of: \nNo ID assigned [AssetTypeInput") } @@ -259,10 +197,12 @@ class ValidationUtilsTest extends Specification { ] when: - List> exceptions = ValidationUtils.checkIds(validAssetIds) + List> exceptions = ValidationUtils.checkForDuplicates(validAssetIds, AssetInput::getId) then: - exceptions.every { ex -> ex.success } + exceptions.every { + ex -> ex.success + } } def "Duplicate asset input ids leads to an exception"() { @@ -273,11 +213,11 @@ class ValidationUtilsTest extends Specification { ] when: - List> exceptions = ValidationUtils.checkIds(invalidAssetIds) + List> exceptions = ValidationUtils.checkForDuplicates(invalidAssetIds, AssetInput::getId) then: exceptions.size() == 1 exceptions.get(0).failure - exceptions.get(0).exception.get().message.contains("Entity may be unsafe because of: There is already an entity with the id invalid_asset") + exceptions.get(0).exception.get().message.startsWith("The following entities have duplicate 'String': {AssetInput{uuid=") } } diff --git a/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy b/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy index e97f57972..1c56b3838 100644 --- a/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy +++ b/src/test/groovy/edu/ie3/test/common/ComplexTopology.groovy @@ -6,6 +6,7 @@ package edu.ie3.test.common import static edu.ie3.test.common.SystemParticipantTestData.emptySystemParticipants + import edu.ie3.datamodel.graph.SubGridGate import edu.ie3.datamodel.graph.SubGridTopologyGraph import edu.ie3.datamodel.models.input.connector.ConnectorPort @@ -13,7 +14,6 @@ import edu.ie3.datamodel.models.input.container.GraphicElements import edu.ie3.datamodel.models.input.container.JointGridContainer import edu.ie3.datamodel.models.input.container.RawGridElements import edu.ie3.datamodel.models.input.container.SubGridContainer -import edu.ie3.datamodel.models.input.container.SystemParticipants import org.jgrapht.graph.DirectedMultigraph class ComplexTopology extends GridTestData { @@ -64,18 +64,7 @@ class ComplexTopology extends GridTestData { [transformerAtoBtoC] as Set, [] as Set, [] as Set), - new SystemParticipants( - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set), + emptySystemParticipants, new GraphicElements( [] as Set, [] as Set) diff --git a/src/test/groovy/edu/ie3/test/common/GridTestData.groovy b/src/test/groovy/edu/ie3/test/common/GridTestData.groovy index 6c41c051a..ebe746e9c 100644 --- a/src/test/groovy/edu/ie3/test/common/GridTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/GridTestData.groovy @@ -5,6 +5,9 @@ */ package edu.ie3.test.common +import static edu.ie3.datamodel.models.StandardUnits.* +import static edu.ie3.util.quantities.PowerSystemUnits.* + import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.MeasurementUnitInput import edu.ie3.datamodel.models.input.NodeInput @@ -26,9 +29,6 @@ import org.locationtech.jts.geom.Point import org.locationtech.jts.io.geojson.GeoJsonReader import tech.units.indriya.quantity.Quantities -import static edu.ie3.datamodel.models.StandardUnits.* -import static edu.ie3.util.quantities.PowerSystemUnits.* - /** * This class contains a collection of different model instances that can be used for testing purposes. * Please note that these entities do NOT necessarily form a valid grid. For valid topologies please refer diff --git a/src/test/groovy/edu/ie3/test/common/ResultEntityTestData.groovy b/src/test/groovy/edu/ie3/test/common/ResultEntityTestData.groovy index f9fd980bc..cc1f86bfb 100644 --- a/src/test/groovy/edu/ie3/test/common/ResultEntityTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/ResultEntityTestData.groovy @@ -10,8 +10,8 @@ import edu.ie3.util.quantities.PowerSystemUnits import tech.units.indriya.ComparableQuantity import tech.units.indriya.quantity.Quantities -import javax.measure.quantity.Power import java.time.ZonedDateTime +import javax.measure.quantity.Power class ResultEntityTestData { diff --git a/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy b/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy index 57a19b06f..7ae270243 100644 --- a/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy +++ b/src/test/groovy/edu/ie3/test/common/SampleJointGrid.groovy @@ -5,6 +5,8 @@ */ package edu.ie3.test.common +import static edu.ie3.util.quantities.PowerSystemUnits.* + import edu.ie3.datamodel.exceptions.ParsingException import edu.ie3.datamodel.models.OperationTime import edu.ie3.datamodel.models.input.NodeInput @@ -30,8 +32,6 @@ import tech.units.indriya.quantity.Quantities import java.util.stream.Collectors -import static edu.ie3.util.quantities.PowerSystemUnits.* - /** * //ToDo: Class Description * @@ -70,6 +70,7 @@ class SampleJointGrid extends SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, albedo, azimuth, etaConv, @@ -89,6 +90,7 @@ class SampleJointGrid extends SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, standardLoadProfile, false, eConsAnnual, @@ -103,6 +105,7 @@ class SampleJointGrid extends SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, standardLoadProfile, false, eConsAnnual, @@ -118,6 +121,7 @@ class SampleJointGrid extends SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, storageTypeInput) return new SystemParticipants( @@ -127,19 +131,18 @@ class SampleJointGrid extends SystemParticipantTestData { Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), - new HashSet<>(Arrays.asList(loadInput, loadInput1)), + Set.of(loadInput, loadInput1), Collections.singleton(pvInput), Collections.singleton(storageInput), - Collections.emptySet(), Collections.emptySet()) } private static RawGridElements jointSampleRawGridElements() throws ParseException { return new RawGridElements( - new HashSet<>(Arrays.asList(nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, nodeG)), - new HashSet<>(Arrays.asList(lineAB, lineAC, lineBC, lineDE, lineDF, lineEF)), - new HashSet<>(Arrays.asList(transformerDtoA, transformerGtoD)), + Set.of(nodeA, nodeB, nodeC, nodeD, nodeE, nodeF, nodeG), + Set.of(lineAB, lineAC, lineBC, lineDE, lineDF, lineEF), + Set.of(transformerDtoA, transformerGtoD), Collections.emptySet(), Collections.emptySet(), Collections.emptySet()) diff --git a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy index bfafb5d6b..dbcc06e33 100644 --- a/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/SystemParticipantTestData.groovy @@ -5,7 +5,10 @@ */ package edu.ie3.test.common +import static edu.ie3.datamodel.models.StandardUnits.* + import edu.ie3.datamodel.models.OperationTime +import edu.ie3.datamodel.models.input.EmInput import edu.ie3.datamodel.models.input.NodeInput import edu.ie3.datamodel.models.input.OperatorInput import edu.ie3.datamodel.models.input.container.SystemParticipants @@ -29,8 +32,6 @@ import tech.units.indriya.quantity.Quantities import javax.measure.quantity.* -import static edu.ie3.datamodel.models.StandardUnits.* - class SystemParticipantTestData { // general participant data @@ -55,6 +56,25 @@ class SystemParticipantTestData { private static final ComparableQuantity opex = Quantities.getQuantity(50d, ENERGY_PRICE) static final ComparableQuantity etaConv = Quantities.getQuantity(98d, EFFICIENCY) + // EmInput + public static final String emControlStrategy = "self_optimization" + public static final EmInput parentEm = new EmInput( + UUID.fromString("897bfc17-8e54-43d0-8d98-740786fd94dd"), + "test_parentEmInput", + SystemParticipantTestData.operator, + SystemParticipantTestData.operationTime, + emControlStrategy, + null + ) + + public static final EmInput emInput = new EmInput( + UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), + "test_emInput", + SystemParticipantTestData.operator, + SystemParticipantTestData.operationTime, + emControlStrategy, + parentEm + ) // FixedFeedInput public static final FixedFeedInInput fixedFeedInInput = new FixedFeedInInput( @@ -64,6 +84,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, sRated, cosPhiRated ) @@ -81,6 +102,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, albedo, azimuth, etaConv, @@ -117,6 +139,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiP, + emInput, wecType, false ) @@ -154,6 +177,8 @@ class SystemParticipantTestData { public static final ThermalStorageInput thermalStorage = new CylindricalStorageInput( UUID.fromString("8851813b-3a7d-4fee-874b-4df9d724e4b3"), "test_cylindricThermalStorage", + GridTestData.profBroccoli, + OperationTime.notLimited(), thermalBus, storageVolumeLvl, storageVolumeLvlMin, @@ -170,6 +195,7 @@ class SystemParticipantTestData { participantNode, thermalBus, cosPhiFixed, + emInput, chpTypeInput, thermalStorage, false @@ -196,6 +222,7 @@ class SystemParticipantTestData { operationTime, participantNode, qV, + emInput, bmTypeInput, false, false, @@ -221,6 +248,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, evTypeInput ) @@ -234,6 +262,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, standardLoadProfile, false, eConsAnnual, @@ -267,10 +296,10 @@ class SystemParticipantTestData { UUID.fromString("06b58276-8350-40fb-86c0-2414aa4a0452"), "test_storageInput", operator, - operationTime - , + operationTime, participantNode, cosPhiFixed, + emInput, storageTypeInput ) @@ -293,6 +322,7 @@ class SystemParticipantTestData { participantNode, thermalBus, cosPhiFixed, + emInput, hpTypeInput ) @@ -305,6 +335,7 @@ class SystemParticipantTestData { operationTime, participantNode, cosPhiFixed, + emInput, ChargingPointTypeUtils.HouseholdSocket, 4, cosPhiRated, @@ -312,47 +343,16 @@ class SystemParticipantTestData { v2gSupport ) - // Energy Management - public static final UUID[] connectedAssets = new UUID[]{ - loadInput.getUuid(), pvInput.getUuid() - } - public static final String emControlStrategy = "self_optimization" - public static final emInput = new EmInput( - UUID.fromString("977157f4-25e5-4c72-bf34-440edc778792"), - "test_emInput", - operator, - operationTime, - participantNode, - cosPhiFixed, - connectedAssets, - emControlStrategy - ) - - public static allParticipants = [ - fixedFeedInInput, - pvInput, - loadInput, - bmInput, - storageInput, - wecInput, - evInput, - chpInput, - hpInput, - emInput - ] - - static SystemParticipants getEmptySystemParticipants() { - return new SystemParticipants( - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set, - [] as Set) - } + public static SystemParticipants emptySystemParticipants = + new SystemParticipants( + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set, + [] as Set) } diff --git a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy index 2e9dd837f..0246c1c4c 100644 --- a/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy @@ -5,10 +5,15 @@ */ package edu.ie3.test.common +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.unit.Units.CELSIUS +import static tech.units.indriya.unit.Units.METRE_PER_SECOND + import edu.ie3.datamodel.io.naming.timeseries.ColumnScheme import edu.ie3.datamodel.io.naming.timeseries.IndividualTimeSeriesMetaInformation import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.StandardUnits +import edu.ie3.datamodel.models.profile.BdewStandardLoadProfile import edu.ie3.datamodel.models.timeseries.IntValue import edu.ie3.datamodel.models.timeseries.TimeSeries import edu.ie3.datamodel.models.timeseries.individual.IndividualTimeSeries @@ -26,10 +31,6 @@ import java.time.DayOfWeek import java.time.ZoneId import java.time.ZonedDateTime -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.unit.Units.CELSIUS -import static tech.units.indriya.unit.Units.METRE_PER_SECOND - trait TimeSeriesTestData { GeometryFactory geometryFactory = new GeometryFactory(new PrecisionModel(), 4326) Point defaultLocation = geometryFactory.createPoint(new Coordinate(7.412152, 51.492758)) diff --git a/src/test/groovy/edu/ie3/test/common/TypeTestData.groovy b/src/test/groovy/edu/ie3/test/common/TypeTestData.groovy index 8dd69378d..8555fc0cc 100644 --- a/src/test/groovy/edu/ie3/test/common/TypeTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/TypeTestData.groovy @@ -5,13 +5,13 @@ */ package edu.ie3.test.common +import static edu.ie3.util.quantities.PowerSystemUnits.* +import static tech.units.indriya.unit.Units.* + import edu.ie3.datamodel.models.input.system.characteristic.WecCharacteristicInput import edu.ie3.datamodel.models.input.system.type.* import tech.units.indriya.quantity.Quantities -import static edu.ie3.util.quantities.PowerSystemUnits.* -import static tech.units.indriya.unit.Units.* - class TypeTestData extends GridTestData { public static final BmTypeInput bmType = new BmTypeInput( UUID.fromString("c3bd30f5-1a62-4a37-86e3-074040d965a4"), diff --git a/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy b/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy index 950705e57..343af527a 100644 --- a/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy +++ b/src/test/groovy/edu/ie3/test/common/WeatherTestData.groovy @@ -5,6 +5,7 @@ */ package edu.ie3.test.common +import edu.ie3.datamodel.exceptions.SourceException import edu.ie3.datamodel.io.source.IdCoordinateSource import edu.ie3.datamodel.io.source.csv.CsvTestDataMeta import edu.ie3.util.geo.CoordinateDistance @@ -12,14 +13,19 @@ import edu.ie3.util.geo.GeoUtils import org.locationtech.jts.geom.Point import tech.units.indriya.ComparableQuantity -import javax.measure.quantity.Length import java.util.stream.Collectors import java.util.stream.Stream +import javax.measure.quantity.Length abstract class WeatherTestData { static final class DummyIdCoordinateSource implements CsvTestDataMeta, IdCoordinateSource { + @Override + Optional> getSourceFields() throws SourceException { + return Optional.empty() + } + Optional getCoordinate(int id) { switch (id) { case 193186: return Optional.of(GeoUtils.buildPoint(7d, 49d)) diff --git a/src/test/groovy/edu/ie3/test/helper/EntityMap.groovy b/src/test/groovy/edu/ie3/test/helper/EntityMap.groovy new file mode 100644 index 000000000..3e24b2508 --- /dev/null +++ b/src/test/groovy/edu/ie3/test/helper/EntityMap.groovy @@ -0,0 +1,17 @@ +/* + * © 2023. TU Dortmund University, + * Institute of Energy Systems, Energy Efficiency and Energy Economics, + * Research group Distribution grid planning and operation + */ +package edu.ie3.test.helper + +import edu.ie3.datamodel.models.UniqueEntity + +import java.util.function.Function +import java.util.stream.Collectors + +class EntityMap { + static Map map(Collection entities) { + entities.stream().collect(Collectors.toMap(UniqueEntity::getUuid, Function.identity())) + } +} diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv index b9ddc711d..cf9538fba 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_joint_grid/evcs_input.csv @@ -1,3 +1,3 @@ -"uuid","cos_phi_rated","id","node","operates_from","operates_until","operator","q_characteristics","chargingpoints","type","location_type","v2gSupport" +"uuid","cos_phi_rated","id","node","operates_from","operates_until","operator","q_characteristics","charging_points","type","location_type","v2gSupport" 06a14909-366e-4e94-a593-1016e1455b30,0.9,test_evcs_1,5f1c776c-6935-40f7-ba9e-60646e08992b,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME,false 104acdaa-5dc5-4197-aed2-2fddb3c4f237,0.9,test_evcs_2,ed4697fd-016c-40c2-a66b-e793878dadea,,,,cosPhiFixed:{(0.00,1.0)},4,ChargingStationType1,HOME,false \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/bm_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/bm_input.csv index ce7d8b2b6..ab92413aa 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/bm_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/bm_input.csv @@ -1,2 +1,2 @@ -uuid,cost_controlled,feed_in_tariff,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,type -d06e5bb7-a3c7-4749-bdd1-4581ff2f6f4d,false,10.0,test_bmInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"qV:{(0.90,-0.30),(0.95,0.00),(1.05,0.00),(1.10,0.30)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,cost_controlled,feed_in_tariff,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,type,em +d06e5bb7-a3c7-4749-bdd1-4581ff2f6f4d,false,10.0,test_bmInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"qV:{(0.90,-0.30),(0.95,0.00),(1.05,0.00),(1.10,0.30)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/chp_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/chp_input.csv index 71a873f1a..587209298 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/chp_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/chp_input.csv @@ -1,2 +1,2 @@ -uuid,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,thermal_bus,thermal_storage,type -9981b4d7-5a8e-4909-9602-e2e7ef4fca5c,test_chpInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",0d95d7f2-49fb-4d49-8636-383a5220384e,8851813b-3a7d-4fee-874b-4df9d724e4b3,5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,thermal_bus,thermal_storage,type,em +9981b4d7-5a8e-4909-9602-e2e7ef4fca5c,test_chpInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",0d95d7f2-49fb-4d49-8636-383a5220384e,8851813b-3a7d-4fee-874b-4df9d724e4b3,5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv index 7d9de239a..325d29445 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ -uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,7d6f1763-0c1d-4266-a76f-59163ad3808b,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e +uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus,em +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv index ad93c0222..e1bd3d5fa 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/em_input.csv @@ -1,2 +1,3 @@ -uuid,connected_assets,control_strategy,id,node,operates_from,operates_until,operator,q_characteristics -977157f4-25e5-4c72-bf34-440edc778792,eaf77f7e-9001-479f-94ca-7fb657766f5f d56f15b7-8293-4b98-b5bd-58f6273ce229,self_optimization,test_emInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,cosPhiFixed:{(0.00,0.95)} +uuid,control_strategy,id,operates_from,operates_until,operator,parent_em +977157f4-25e5-4c72-bf34-440edc778792,self_optimization,test_emInput,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,897bfc17-8e54-43d0-8d98-740786fd94dd +897bfc17-8e54-43d0-8d98-740786fd94dd,self_optimization,test_parentEmInput,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510, \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/ev_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/ev_input.csv index 586c162ca..ca1a1609f 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/ev_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/ev_input.csv @@ -1,2 +1,2 @@ -uuid,id,node,operates_from,operates_until,operator,q_characteristics,type -a17be20f-c7a7-471d-8ffe-015487c9d022,test_evInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,id,node,operates_from,operates_until,operator,q_characteristics,type,em +a17be20f-c7a7-471d-8ffe-015487c9d022,test_evInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv index 0f8c9375e..f5260fd87 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/evcs_input.csv @@ -1,2 +1,2 @@ -uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_type,v2g_support -798028b5-caff-4da7-bcd9-1750fdd8742c,test_csInput,8f9682df-0744-4b58-a122-f0dc730f6510,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],4ca90220-74c2-4369-9afa-a18bf068840d,cosPhiFixed:{(0.0,0.95)},0.95,hhs,4,HOME,false \ No newline at end of file +uuid,id,operator,operates_from,operates_until,node,q_characteristics,cos_phi_rated,type,charging_points,location_type,v2g_support,em +798028b5-caff-4da7-bcd9-1750fdd8742c,test_csInput,8f9682df-0744-4b58-a122-f0dc730f6510,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],4ca90220-74c2-4369-9afa-a18bf068840d,cosPhiFixed:{(0.0,0.95)},0.95,hhs,4,HOME,false,977157f4-25e5-4c72-bf34-440edc778792 \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/fixed_feed_in_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/fixed_feed_in_input.csv index 0cf4a3ec4..f34ea1235 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/fixed_feed_in_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/fixed_feed_in_input.csv @@ -1,2 +1,2 @@ -uuid,cosphi_rated,id,node,operates_from,operates_until,operator,q_characteristics,s_rated -717af017-cc69-406f-b452-e022d7fb516a,0.95,test_fixedFeedInInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0 +uuid,cos_phi_rated,id,node,operates_from,operates_until,operator,q_characteristics,s_rated,em +717af017-cc69-406f-b452-e022d7fb516a,0.95,test_fixedFeedInInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/hp_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/hp_input.csv index d99bf92b8..ab904335b 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/hp_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/hp_input.csv @@ -1,2 +1,2 @@ -uuid,id,node,operates_from,operates_until,operator,q_characteristics,thermal_bus,type -798028b5-caff-4da7-bcd9-1750fdd8742b,test_hpInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",0d95d7f2-49fb-4d49-8636-383a5220384e,5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,id,node,operates_from,operates_until,operator,q_characteristics,thermal_bus,type,em +798028b5-caff-4da7-bcd9-1750fdd8742b,test_hpInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",0d95d7f2-49fb-4d49-8636-383a5220384e,5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/load_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/load_input.csv index d961a158b..644ae6375 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/load_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/load_input.csv @@ -1,2 +1,2 @@ -uuid,cosphi_rated,dsm,e_cons_annual,id,node,operates_from,operates_until,operator,q_characteristics,s_rated,load_profile -eaf77f7e-9001-479f-94ca-7fb657766f5f,0.95,false,4000.0,test_loadInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0,h0 +uuid,cos_phi_rated,dsm,e_cons_annual,id,node,operates_from,operates_until,operator,q_characteristics,s_rated,load_profile,em +eaf77f7e-9001-479f-94ca-7fb657766f5f,0.95,false,4000.0,test_loadInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0,h0,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/pv_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/pv_input.csv index 70b1881a7..c93d6e94d 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/pv_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/pv_input.csv @@ -1,2 +1,2 @@ -uuid,albedo,azimuth,cosphi_rated,eta_conv,elevation_angle,id,k_g,k_t,market_reaction,node,operates_from,operates_until,operator,q_characteristics,s_rated -d56f15b7-8293-4b98-b5bd-58f6273ce229,0.20000000298023224,-8.926613807678223,0.95,98.0,41.01871871948242,test_pvInput,0.8999999761581421,1.0,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0 +uuid,albedo,azimuth,cos_phi_rated,eta_conv,elevation_angle,id,k_g,k_t,market_reaction,node,operates_from,operates_until,operator,q_characteristics,s_rated,em +d56f15b7-8293-4b98-b5bd-58f6273ce229,0.20000000298023224,-8.926613807678223,0.95,98.0,41.01871871948242,test_pvInput,0.8999999761581421,1.0,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",25.0,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/storage_input.csv index 124265a29..44021c3cb 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/storage_input.csv @@ -1,2 +1,2 @@ -uuid,id,node,operates_from,operates_until,operator,q_characteristics,type -06b58276-8350-40fb-86c0-2414aa4a0452,test_storageInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,id,node,operates_from,operates_until,operator,q_characteristics,type,em +06b58276-8350-40fb-86c0-2414aa4a0452,test_storageInput,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiFixed:{(0.00,0.95)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/time_series_mapping.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/time_series_mapping.csv index e03b276ad..565fcf11c 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/time_series_mapping.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/time_series_mapping.csv @@ -1,4 +1,4 @@ -"uuid";"participant";"time_series" -"58167015-d760-4f90-8109-f2ebd94cda91";"b86e95b0-e579-4a80-a534-37c7a470a409";"67600124-2475-4a62-a410-0dd6eabb9441" -"9a9ebfda-dc26-4a40-b9ca-25cd42f6cc3f";"c7ebcc6c-55fc-479b-aa6b-6fa82ccac6b8";"05a25fe7-11e5-4732-92b0-490cec171c78" -"9c1c53ea-e575-41a2-a373-a8b2d3ed2c39";"90a96daa-012b-4fea-82dc-24ba7a7ab81c";"05a25fe7-11e5-4732-92b0-490cec171c78" \ No newline at end of file +"uuid","participant","time_series" +"58167015-d760-4f90-8109-f2ebd94cda91","b86e95b0-e579-4a80-a534-37c7a470a409","67600124-2475-4a62-a410-0dd6eabb9441" +"9a9ebfda-dc26-4a40-b9ca-25cd42f6cc3f","c7ebcc6c-55fc-479b-aa6b-6fa82ccac6b8","05a25fe7-11e5-4732-92b0-490cec171c78" +"9c1c53ea-e575-41a2-a373-a8b2d3ed2c39","90a96daa-012b-4fea-82dc-24ba7a7ab81c","05a25fe7-11e5-4732-92b0-490cec171c78" \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/wec_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/wec_input.csv index 28b063b88..2be6f5f3a 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/wec_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_participants/wec_input.csv @@ -1,2 +1,2 @@ -uuid,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,type -ee7e2e37-a5ad-4def-a832-26a317567ca1,test_wecInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiP:{(0.00,1.00),(0.90,1.00),(1.20,-0.30)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8 +uuid,id,market_reaction,node,operates_from,operates_until,operator,q_characteristics,type,em +ee7e2e37-a5ad-4def-a832-26a317567ca1,test_wecInput,false,4ca90220-74c2-4369-9afa-a18bf068840d,2020-03-24T15:11:31Z[UTC],2020-03-25T15:11:31Z[UTC],8f9682df-0744-4b58-a122-f0dc730f6510,"cosPhiP:{(0.00,1.00),(0.90,1.00),(1.20,-0.30)}",5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,977157f4-25e5-4c72-bf34-440edc778792 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_results/thermal_house_res.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_results/thermal_house_res.csv index 19d5398ac..9b92587d4 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_results/thermal_house_res.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_results/thermal_house_res.csv @@ -1 +1 @@ -uuid,inputModel,qDot,indoorTemperature \ No newline at end of file +uuid,inputModel,qDot,indoorTemperature,time \ No newline at end of file diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv index 7d9de239a..4a11cda89 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_thermal/cylindrical_storage_input.csv @@ -1,2 +1,2 @@ uuid,c,id,inlet_temp,operates_from,operates_until,operator,return_temp,storage_volume_lvl,storage_volume_lvl_min,thermal_bus -8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,7d6f1763-0c1d-4266-a76f-59163ad3808b,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e +8851813b-3a7d-4fee-874b-4df9d724e4b3,1.0,test_cylindricThermalStorage,110.0,,,f15105c4-a2de-4ab8-a621-4bc98e372d92,80.0,1.039154027,0.3,0d95d7f2-49fb-4d49-8636-383a5220384e diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/bm_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/bm_type_input.csv index 742bbfb0e..e00adbd76 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/bm_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/bm_type_input.csv @@ -1,2 +1,2 @@ -uuid,active_power_gradient,capex,cosphi_rated,eta_conv,id,opex,s_rated +uuid,active_power_gradient,capex,cos_phi_rated,eta_conv,id,opex,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,25.0,100.0,0.95,98.0,test_bmTypeInput,50.0,25.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/chp_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/chp_type_input.csv index 4e19b862a..416890a66 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/chp_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/chp_type_input.csv @@ -1,2 +1,2 @@ -uuid,capex,cosphi_rated,eta_el,eta_thermal,id,opex,p_own,p_thermal,s_rated +uuid,capex,cos_phi_rated,eta_el,eta_thermal,id,opex,p_own,p_thermal,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,100.0,0.95,19.0,76.0,test_chpType,50.0,0.0,9.0,25.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/ev_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/ev_type_input.csv index ab07e35fa..b27fe828c 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/ev_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/ev_type_input.csv @@ -1,2 +1,2 @@ -uuid,capex,cosphi_rated,e_cons,e_storage,id,opex,s_rated +uuid,capex,cos_phi_rated,e_cons,e_storage,id,opex,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,100.0,0.95,5.0,100.0,test_evTypeInput,50.0,25.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/hp_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/hp_type_input.csv index 6f943036a..d41d6d38c 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/hp_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/hp_type_input.csv @@ -1,2 +1,2 @@ -uuid,capex,cosphi_rated,id,opex,p_thermal,s_rated +uuid,capex,cos_phi_rated,id,opex,p_thermal,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,100.0,0.95,test_hpTypeInput,50.0,9.0,25.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/storage_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/storage_type_input.csv index 1c437b952..4497b6159 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/storage_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/storage_type_input.csv @@ -1,2 +1,2 @@ -uuid,active_power_gradient,capex,cosphi_rated,dod,e_storage,eta,id,life_cycle,life_time,opex,p_max,s_rated +uuid,active_power_gradient,capex,cos_phi_rated,dod,e_storage,eta,id,life_cycle,life_time,opex,p_max,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,100.0,100.0,0.95,10.0,100.0,95.0,test_storageTypeInput,100,175316.4,50.0,15.0,25.0 diff --git a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/wec_type_input.csv b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/wec_type_input.csv index 43184d4e0..0fdac436e 100644 --- a/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/wec_type_input.csv +++ b/src/test/resources/edu/ie3/datamodel/io/source/csv/_types/wec_type_input.csv @@ -1,2 +1,2 @@ -uuid,capex,cosphi_rated,cp_characteristic,eta_conv,hub_height,id,opex,rotor_area,s_rated +uuid,capex,cos_phi_rated,cp_characteristic,eta_conv,hub_height,id,opex,rotor_area,s_rated 5ebd8f7e-dedb-4017-bb86-6373c4b68eb8,100.0,0.95,"cP:{(10.00,0.05),(15.00,0.10),(20.00,0.20)}",98.0,200.0,test_wecType,50.0,20.0,25.0