Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
195 commits
Select commit Hold shift + click to select a range
237d17b
merge in feature branch jh/#96-operator-input-factory
johanneshiry Apr 5, 2020
1486499
initial implementation of CsvRawGridSource
johanneshiry Apr 5, 2020
f246984
Merge branch 'jh/#78-nested-model-extractor' into jh/#101-csv-raw-gri…
johanneshiry Apr 5, 2020
c11609d
extending CsvDataSource to account for snake from input files and tra…
johanneshiry Apr 5, 2020
4df9b29
added missing field for ConnectorInput in InputDatamodelConcept.puml
johanneshiry Apr 5, 2020
4b42c3b
- changed field noOfParallelDevices -> parallelDevices to harmonize I…
johanneshiry Apr 5, 2020
73cf856
- CsvRawGridSource processing for lines, nodes and transformer2ws
johanneshiry Apr 5, 2020
3360934
fix a bug in EntityProcessor that leads to processing internal node o…
johanneshiry Apr 5, 2020
68d64b6
3 winding transformers processing from csv files
johanneshiry Apr 5, 2020
7051389
fix a bug in EntityProcess that processed parallelDevices in SwitchIn…
johanneshiry Apr 5, 2020
0029643
finished CsvRawGridSource for all grid entities + fmt
johanneshiry Apr 5, 2020
061d9a4
Merge branch 'master' into jh/#101-csv-raw-grid-source
johanneshiry Apr 6, 2020
91ce990
added shutdown() in DataSink
johanneshiry Apr 6, 2020
8779db4
added evs to SystemParticipants class
johanneshiry Apr 6, 2020
a008dfd
added method to DataSink to persist a JointGrid directly
johanneshiry Apr 6, 2020
714191c
cleanup in CsvRawGridSource
johanneshiry Apr 6, 2020
41a896d
added method in ContainerUtils to determine if a collection of Unique…
johanneshiry Apr 6, 2020
8f611ab
moved unique entity testing method into ValidationUtils + added valid…
johanneshiry Apr 6, 2020
c3869f6
improved exception message for easier debugging for duplicate uuids i…
johanneshiry Apr 6, 2020
c854da9
fix GridTestData + dependant tests to enforce new unique uuid policy
johanneshiry Apr 6, 2020
22cb039
added unique uuids to SystemParticipantTestData for all entities
johanneshiry Apr 6, 2020
1787836
- fix default Lat/Long in NodeInput
johanneshiry Apr 6, 2020
ea51c4c
performance improved CsvRawGridSource getNodes()
johanneshiry Apr 6, 2020
3bc2757
added regex to perform valid splitting with geoJson strings as values…
johanneshiry Apr 6, 2020
aa5af28
removed travis.yml
johanneshiry Apr 6, 2020
f47a47d
improvements in CsvRawGridSource
johanneshiry Apr 6, 2020
bf66dc4
fmt
johanneshiry Apr 6, 2020
d1250f3
Merge remote-tracking branch 'remotes/origin/master' into jh/#101-csv…
johanneshiry Apr 6, 2020
8fae82f
fix a bug with wrong field name in SystemParticipantTypeInputFactory …
johanneshiry Apr 6, 2020
24da53a
replaced method based fieldToAttributesMapping in CsvRawGridSource by…
johanneshiry Apr 7, 2020
a228d7b
deleted old method due to redudancy in CsvDataSource + adapted CsvTyp…
johanneshiry Apr 7, 2020
6b9732b
removed unnecessary collect operations in CsvRawGridSource + replaced…
johanneshiry Apr 7, 2020
578a259
improved error logging in EntityFactory
johanneshiry Apr 7, 2020
e60514a
added interface for thermal sources
johanneshiry Apr 7, 2020
27e4ea4
extended SystemParticipantSource
johanneshiry Apr 7, 2020
8910ab4
fix cosphirated bugs in PvInputFactory and LoadInputFactory + improve…
johanneshiry Apr 7, 2020
1627f67
initial implementation of CsvSystemParticipantSource
johanneshiry Apr 7, 2020
06128ec
moved CsvFileConnector from child classes to abstract super class Csv…
johanneshiry Apr 7, 2020
7e72c72
- ThermalBus + ThermalStorage support for Extractor
johanneshiry Apr 7, 2020
2077288
ThermalSource interface + CsvThermalSource implementation
johanneshiry Apr 7, 2020
26fffa6
removed code duplicates in CsvRawGridSource + simplified buildAssetIn…
johanneshiry Apr 7, 2020
793d399
simplified AssetInputEntityData and replaced Optional<OperatorInput> …
johanneshiry Apr 7, 2020
2ece933
added thermal source to documentation + let ThermalSource extend Data…
johanneshiry Apr 7, 2020
db96b48
performance improvements + code cleanup in CsvSystemParticipantSource
johanneshiry Apr 8, 2020
8ea2337
removed MeasurementUnitInputEntityData + replaced it with UntypedSing…
johanneshiry Apr 8, 2020
d13228e
replaced LineInputEntityData + Transformer2WInputEntityData with Type…
johanneshiry Apr 8, 2020
4665e35
adapted Transformer3WInputEntityData inheritance to apply to the new …
johanneshiry Apr 8, 2020
00cce81
cleanup + improvements in CsvRawGridSource + CsvSystemParticipantSource
johanneshiry Apr 8, 2020
ddf16b2
Merge branch 'master' into jh/#101-csv-raw-grid-source
johanneshiry Apr 8, 2020
66cb046
fix the tests based on the new changes and improvements
johanneshiry Apr 8, 2020
ff39302
simplified version of tracking of invalid elements in CsvRawGridSource
johanneshiry Apr 8, 2020
47354bf
- more code cleanup + removing of duplicates in CsvRawGridSource + Cs…
johanneshiry Apr 8, 2020
f500aac
method renaming for more clarity what it does
johanneshiry Apr 8, 2020
c23b96f
deleted FactoryProvider.java
johanneshiry Apr 8, 2020
4f4de55
Merge branch 'jh/#107-graphic-input-factories-and-sources' into jh/#1…
johanneshiry Apr 8, 2020
31c517a
fix a bug in Extractor when entities contain multiple nested entities
johanneshiry Apr 8, 2020
b4ebf20
- added GraphicSource interface
johanneshiry Apr 8, 2020
7b82e16
removed unused rawGridSource from CsvThermalSource
johanneshiry Apr 9, 2020
9ee0fb5
merge ck/#94 into feature branch
johanneshiry Apr 9, 2020
6673553
started documentation and renamed UntypedSingleNodeEntityData to more…
johanneshiry Apr 9, 2020
566a3f7
cleanup + documentation in several classes
johanneshiry Apr 10, 2020
e21f726
let SinkException be a normal exception instead of a RuntimeException
johanneshiry Apr 10, 2020
62bdc4d
valid logging in CsvFileConnector
johanneshiry Apr 10, 2020
c332e1e
addressed several todos
johanneshiry Apr 10, 2020
1dc1e06
improvements in CsvFileConnector to avoid overriding files (now appen…
johanneshiry Apr 10, 2020
94acc10
- make Extractor ignore OperatorInput.NO_OPERATOR_ASSIGNED
johanneshiry Apr 10, 2020
c040ad7
added support for new characteristics in CsvDataSource
johanneshiry Apr 10, 2020
835ceed
added first CsvIOTest example
johanneshiry Apr 10, 2020
69a1c6a
- replaced TimeTools in GridTestData with new TimeUtil
johanneshiry Apr 12, 2020
23a2ca4
replaced camelCaseToSnakeCase() in CsvFileConnector with StringUtils …
johanneshiry Apr 12, 2020
164627d
- added test für CsvDataSource
johanneshiry Apr 13, 2020
da3768b
- initial CsvTypeSourceTest
johanneshiry Apr 13, 2020
d64e10a
- fixed a bug in Extractor + introduced Extractable interface to avoi…
johanneshiry Apr 13, 2020
27e9288
Revert "- fixed a bug in Extractor + introduced Extractable interface…
johanneshiry Apr 13, 2020
1ce64ac
- fixed a bug in Extractor + added corresponding test
johanneshiry Apr 13, 2020
a54b3b4
- fixed another bug in CsvDataSource
johanneshiry Apr 13, 2020
cd4c2ff
- equals + hashCode methods in LineGraphicInputEntityData + NodeGraph…
johanneshiry Apr 13, 2020
f0846a7
- fmt
johanneshiry Apr 13, 2020
0ad4342
minor refactoring in CsvDataSource + fmt
johanneshiry Apr 13, 2020
87c01b1
fix tests + fmt
johanneshiry Apr 13, 2020
e306d24
removed CsvRawGridSource vom CsvThermalSource
johanneshiry Apr 14, 2020
822d43c
added missing test data files
johanneshiry Apr 14, 2020
2408679
added missing test data files
johanneshiry Apr 14, 2020
676a541
added dummies for CsvThermalSourceTest
johanneshiry Apr 14, 2020
3082f1d
added empty files for CsvRawGridSourceTest + CsvSystemParticipantSour…
johanneshiry Apr 14, 2020
5a5cf01
simplifications + removed code duplicates in CsvRawGridSource & CsvSy…
johanneshiry Apr 14, 2020
381152d
added test for aggregated type extraction in CsvDataSource
johanneshiry Apr 14, 2020
b5a6eed
- equals() and hashCode() in SystemParticipantTypedEntityData
johanneshiry Apr 14, 2020
54bd6bc
simplifications + removed code duplicates in CsvRawGridSource & CsvSy…
johanneshiry Apr 14, 2020
4fdd94a
Merge branch 'master' into jh/#101-csv-raw-grid-source
johanneshiry Apr 14, 2020
a6062e5
Breaking down methods
ckittl Apr 14, 2020
c6ac5e6
Opting out non working tests
ckittl Apr 14, 2020
0d5ae10
Testing the conversion of a single AssetInputEntityData to ConnectorI…
ckittl Apr 14, 2020
512e34d
Testing the conversion of a Stream of AssetInputEntityData to a Strea…
ckittl Apr 14, 2020
187eb31
Testing the conversion of ConnectorInputEntityData to TypedConnectorI…
ckittl Apr 14, 2020
6bac364
init branch
sensarmad Apr 15, 2020
9827492
Transformer 2w test
sensarmad Apr 15, 2020
7f6e2a4
Transformer 3w test
sensarmad Apr 15, 2020
621f0d4
operator test
sensarmad Apr 15, 2020
faaeb44
line type test
sensarmad Apr 15, 2020
51708a2
improved stability for csv file parsing
johanneshiry Apr 15, 2020
df318fe
Testing the conversion of TypedConnectorInputEntityData to Transforme…
ckittl Apr 15, 2020
c4626d7
prevent quoting all fields in all lines in BufferedCsvWriter
johanneshiry Apr 15, 2020
b497050
Only quote the head line of a csv file
ckittl Apr 15, 2020
df9116c
fix processing of NO_OPERATOR_ASSIGNED + added corresponding test
johanneshiry Apr 15, 2020
8444340
Correct handling of default no operator
ckittl Apr 15, 2020
5b90ce4
system participant tests (wec fails due to cpCharacteristic)
sensarmad Apr 15, 2020
486b18d
expand transformer 2w test
sensarmad Apr 15, 2020
756293f
expand operator test
sensarmad Apr 15, 2020
bda3376
expand line type test
sensarmad Apr 15, 2020
3a1f06f
Adapting the equals and hash code methods for characteristics
ckittl Apr 15, 2020
38712f6
expand transformer 3w type test
sensarmad Apr 15, 2020
048757d
Adapting the equals and hash code methods for characteristics
ckittl Apr 15, 2020
ea90c6e
Adapting toString methods
ckittl Apr 15, 2020
2884114
Only remove trailing or leading spaces of fields and not intermediate…
ckittl Apr 15, 2020
6579a3d
added uuids and ids to grid element types
sensarmad Apr 15, 2020
5f6f277
expand bm types test
sensarmad Apr 15, 2020
44f221d
expand chp types test
sensarmad Apr 15, 2020
869b8b9
Testing the reception of nodes
ckittl Apr 15, 2020
5a60feb
expand hp types test
sensarmad Apr 15, 2020
f29ac27
expand storage types test
sensarmad Apr 15, 2020
29e2130
expand ev types test
sensarmad Apr 15, 2020
60775b4
expand wec types test
sensarmad Apr 15, 2020
3bd1a56
Adapting the equals and hash code methods for characteristics
ckittl Apr 15, 2020
b0f109c
inclusion of cpCharacteristics in wec type
sensarmad Apr 15, 2020
3a83536
clean up and formatting
sensarmad Apr 15, 2020
a2dc319
cosphi to cosphiRated in wec
sensarmad Apr 15, 2020
df33475
Testing the reception of lines
ckittl Apr 15, 2020
8ea0f4a
remove size (number of rows) check
sensarmad Apr 15, 2020
71569b7
Testing the reception of measurement units
ckittl Apr 15, 2020
32dca3a
Testing the reception of switches
ckittl Apr 15, 2020
03b3c38
ignore CsvThermalSourceTest for now
sensarmad Apr 15, 2020
5ece189
codacy issues in CsvGraphicSourceTest
johanneshiry Apr 15, 2020
297a92c
Testing the reception of two winding transformers
ckittl Apr 15, 2020
8883da7
Testing the reception of three winding transformers
ckittl Apr 15, 2020
4b27deb
Testing the reception of RawGridElements
ckittl Apr 15, 2020
d850699
removed allowed double quotes for csv rows again
johanneshiry Apr 15, 2020
ea56620
ValidationUtils adaptions for improved uuid duplicates check
johanneshiry Apr 15, 2020
89bf935
added tests for CsvSystemParticipantSource
johanneshiry Apr 15, 2020
43426ec
init branch
sensarmad Apr 15, 2020
eba890e
Make spotlessApply runnable
ckittl Apr 15, 2020
64e6c99
Let CsvThermalSourceTest be successful. :-D
ckittl Apr 15, 2020
eca4d13
Merge remote-tracking branch 'remotes/origin/jh/#101-csv-raw-grid-sou…
ckittl Apr 15, 2020
d1ff0b0
Merge branch 'jh/#101-csv-raw-grid-source' of https://github.com/ie3-…
sensarmad Apr 15, 2020
ba4b8a5
Merge branch 'jh/#101-csv-raw-grid-source' of https://github.com/ie3-…
sensarmad Apr 15, 2020
f42e5e3
finally found a way to deal with different csvRow content incl. quote…
johanneshiry Apr 15, 2020
4c978d9
fmt
johanneshiry Apr 15, 2020
7f8165f
fix sonarqube logging bugs
johanneshiry Apr 15, 2020
01bd8db
simplified geojson regex
johanneshiry Apr 15, 2020
d38eb25
addressing several sonarqube issues
johanneshiry Apr 15, 2020
5e2c464
simplifying regex for sonarqube
johanneshiry Apr 15, 2020
c030a50
Merge branch 'ds/#101-csv-type-source-test' into jh/#101-csv-raw-grid…
johanneshiry Apr 15, 2020
d72e674
Merge branch 'ck/#101-csv-raw-grid-source' into jh/#101-csv-raw-grid-…
johanneshiry Apr 15, 2020
c221c69
Merge branch 'ck/#101-csv-raw-grid-source' into jh/#101-csv-raw-grid-…
johanneshiry Apr 15, 2020
c514c02
added missing test for ValidationUtils
johanneshiry Apr 15, 2020
ce54bed
new test in ExtractorTest
johanneshiry Apr 15, 2020
2dd81f8
override equals() and hashCode() in NodeAssetInputEntityData
johanneshiry Apr 15, 2020
4ad2603
fmt
johanneshiry Apr 15, 2020
5ffb34a
addressing codacy issues
johanneshiry Apr 15, 2020
65afb30
Merge branch 'jh/#101-csv-raw-grid-source' of https://github.com/ie3-…
sensarmad Apr 15, 2020
711b153
Thermal buses test
sensarmad Apr 16, 2020
55b7e46
added description for DataSource interface
johanneshiry Apr 16, 2020
54d4a22
Thermal storages test
sensarmad Apr 16, 2020
41effec
finished javadocs for GraphicSource + CsvGraphicSource
johanneshiry Apr 16, 2020
58fcd89
added javadocs to CsvDataSource + fmt DataSource
johanneshiry Apr 16, 2020
e492079
Thermal unit input test
sensarmad Apr 16, 2020
4274a7c
Update src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnecto…
johanneshiry Apr 16, 2020
c9d94d4
Thermal unit input test passes
sensarmad Apr 16, 2020
4241b87
Merge branch 'jh/#101-csv-raw-grid-source' of https://github.com/ie3-…
sensarmad Apr 16, 2020
3d32251
- added javadocs for RawGridSource and CsvRawGridSource
johanneshiry Apr 16, 2020
e985fc5
switch all collections to sets to prevent passing collections where w…
johanneshiry Apr 16, 2020
98f74b0
- added javadoc for SystemParticipantSource and CsvSystemParticipantS…
johanneshiry Apr 16, 2020
0b6d0fc
all tests pass
sensarmad Apr 16, 2020
7e42761
added javadocs to ThermalSource and CsvThermalSource
johanneshiry Apr 16, 2020
cc4b25d
added javadocs to TypeSource and CsvTypeSource
johanneshiry Apr 16, 2020
8fd0ea5
Merge remote-tracking branch 'origin/jh/#101-csv-raw-grid-source' int…
johanneshiry Apr 16, 2020
d2a29d9
fix tests + fmt
johanneshiry Apr 16, 2020
4f2bda1
Update src/main/java/edu/ie3/datamodel/io/factory/input/TypedConnecto…
johanneshiry Apr 16, 2020
5ffa3c4
addressing reviewers comments
johanneshiry Apr 16, 2020
e21bf64
Update src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceT…
johanneshiry Apr 16, 2020
e73de37
Update src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceT…
johanneshiry Apr 16, 2020
b68ef80
Update src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceT…
johanneshiry Apr 16, 2020
cd1b189
Update src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvDataSourceT…
johanneshiry Apr 16, 2020
bcb63d1
Update src/test/groovy/edu/ie3/datamodel/io/source/csv/CsvGraphicSour…
johanneshiry Apr 16, 2020
c52c7be
addressing reviewers comments
johanneshiry Apr 16, 2020
7b51305
fmt
johanneshiry Apr 16, 2020
577ca0d
Merge branch 'jh/#101-csv-raw-grid-source' of github.com:ie3-institut…
johanneshiry Apr 16, 2020
bdd8dd6
fixing tests
johanneshiry Apr 16, 2020
4c4a5ad
Use the correct Constructors for ThermalHouseInputFactory and Cylindr…
ckittl Apr 16, 2020
bb4e88c
Fixing what I have broken before
ckittl Apr 16, 2020
8789dd2
minor formatting CsvSystemParticipantSource
johanneshiry Apr 16, 2020
2179882
Merge remote-tracking branch 'remotes/origin/jh/#101-csv-raw-grid-sou…
ckittl Apr 16, 2020
776ea8d
added missing javadoc + fmt
johanneshiry Apr 16, 2020
23b7d46
Merge remote-tracking branch 'remotes/origin/jh/#101-csv-raw-grid-sou…
ckittl Apr 16, 2020
7fd1682
Merge branch 'ds/#101-csv-thermal-source-test' into jh/#101-csv-raw-g…
johanneshiry Apr 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

20 changes: 11 additions & 9 deletions docs/uml/main/DataSourceClassDiagramm.puml
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,31 @@ JDBCGridDataSource --> JDBCDataConnector

class CSVGridDataSource {
}
CSVGridDataSource --|> GridDataSource
CSVGridDataSource --> CSVDataConnector
CSVGridDataSource ..|> GridDataSource
CSVGridDataSource ..|> CSVDataConnector

interface AssetDataSource {
{abstract}Future<AssetData> fetchAssetData()
{abstract}Future<List<EVModel>> fetchEvs()
{abstract}Future<List<WECModel>> fetchWecs()
{abstract}Future<List<...>> fetch...()
{abstract}Set<EVModel> fetchEvs()
{abstract}Set<WECModel> fetchWecPlants()
{abstract}Set<...> fetch...()
}
AssetDataSource --|> DataSource
AssetDataSource ..|> DataSource

interface ThermalSource
ThermalSource ..|> DataSource

interface TypeDataSource {
{abstract}Future<TypeData> fetchTypeData()
{abstract}Future<List<EVTypeModel>> fetchEvTypes()
{abstract}Future<List<...>> fetch...()
}
TypeDataSource --|> DataSource
TypeDataSource ..|> DataSource

interface GraphicDataSource {
{abstract}Future<GraphicData> fetchGraphicData()
{abstract}Future<List<...>> fetch...()
}
GraphicDataSource --|> DataSource
GraphicDataSource ..|> DataSource

interface WeatherDataSource {
{abstract}Future<WeatherData> fetchWeatherData()
Expand Down
5 changes: 5 additions & 0 deletions docs/uml/main/InputDataDeployment.puml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ weather
interface grid_source
interface assets_source
interface types_source
interface thermal_source
interface graphics_source
interface weather_source
interface time_series_source
Expand All @@ -64,6 +65,9 @@ assets_source --> assets
types_source --> psql
types_source --> types

thermal_source --> psql
thermal_source --> types

graphics_source --> psql
graphics_source --> graphics

Expand All @@ -81,6 +85,7 @@ inputAccumulator --> types_source
inputAccumulator --> graphics_source
inputAccumulator --> weather_source
inputAccumulator --> time_series_source
inputAccumulator --> thermal_source

projName_model.conf --> config_source

Expand Down
1 change: 1 addition & 0 deletions docs/uml/main/InputDatamodelConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ OperatorInput --|> InputEntity
abstract Class ConnectorInput {
+ nodeA: NodeInput
+ nodeB: NodeInput
+ parallelDevices: Integer
}
ConnectorInput --|> AssetInput
ConnectorInput ..|> HasNodes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @version 0.1
* @since 19.03.20
*/
public class SinkException extends RuntimeException {
public class SinkException extends Exception {
public SinkException(final String message, final Throwable cause) {
super(message, cause);
}
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/edu/ie3/datamodel/exceptions/SourceException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.exceptions;

/**
* Exception that should be used whenever an error occurs in a instance of a {@link
* edu.ie3.datamodel.io.source.DataSource}
*
* @version 0.1
* @since 19.03.20
*/
public class SourceException extends Exception {
public SourceException(final String message, final Throwable cause) {
super(message, cause);
}

public SourceException(final Throwable cause) {
super(cause);
}

public SourceException(final String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
import edu.ie3.datamodel.models.timeseries.TimeSeries;
import edu.ie3.datamodel.models.timeseries.TimeSeriesEntry;
import edu.ie3.datamodel.models.value.Value;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Stream;
import org.apache.logging.log4j.LogManager;
Expand All @@ -36,6 +38,8 @@ public class CsvFileConnector implements DataConnector {
private final FileNamingStrategy fileNamingStrategy;
private final String baseFolderName;

private static final String FILE_ENDING = ".csv";

public CsvFileConnector(String baseFolderName, FileNamingStrategy fileNamingStrategy) {
this.baseFolderName = baseFolderName;
this.fileNamingStrategy = fileNamingStrategy;
Expand Down Expand Up @@ -84,21 +88,68 @@ BufferedCsvWriter getOrInitWriter(T timeSeries, String[] headerElements, String
/**
* Initializes a writer with the given base folder and file definition
*
* @param baseFolderName Base folder, where the file hierarchy should start
* @param baseFolder Base folder, where the file hierarchy should start
* @param fileDefinition Definition of the files shape
* @return an initialized buffered writer
* @throws ConnectorException If the base folder is a file
* @throws IOException If the writer cannot be initialized correctly
*/
private BufferedCsvWriter initWriter(String baseFolderName, CsvFileDefinition fileDefinition)
private BufferedCsvWriter initWriter(String baseFolder, CsvFileDefinition fileDefinition)
throws ConnectorException, IOException {
File basePathDir = new File(baseFolderName);
File basePathDir = new File(baseFolder);
if (basePathDir.isFile())
throw new ConnectorException(
"Base path dir '" + baseFolderName + "' already exists and is a file!");
"Base path dir '" + baseFolder + "' already exists and is a file!");
if (!basePathDir.exists()) basePathDir.mkdirs();

return new BufferedCsvWriter(baseFolderName, fileDefinition);
String fullPathToFile = baseFolder + File.separator + fileDefinition.getFilePath();

File pathFile = new File(fullPathToFile);
if (!pathFile.exists()) {
return new BufferedCsvWriter(baseFolder, fileDefinition, false, true);
}
log.warn(
"File '{}.csv' already exist. Will append new content WITHOUT new header! Full path: {}",
fileDefinition.getFileName(),
pathFile.getAbsolutePath());
return new BufferedCsvWriter(baseFolder, fileDefinition, false, false);
}

/**
* 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
*
* @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
*/
public BufferedReader initReader(Class<? extends UniqueEntity> clz) throws FileNotFoundException {

BufferedReader newReader;

String fileName = null;
try {
fileName =
fileNamingStrategy
.getFileName(clz)
.orElseThrow(
() ->
new ConnectorException(
"Cannot find a naming strategy for class '"
+ clz.getSimpleName()
+ "'."));
} catch (ConnectorException e) {
log.error(
"Cannot get reader for entity '{}' as no file naming strategy for this file exists. Exception:{}",
clz::getSimpleName,
() -> e);
}
File filePath = new File(baseFolderName + File.separator + fileName + FILE_ENDING);
newReader =
new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8), 16384);

return newReader;
}

/**
Expand Down
19 changes: 9 additions & 10 deletions src/main/java/edu/ie3/datamodel/io/csv/BufferedCsvWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ public class BufferedCsvWriter extends BufferedWriter {
* @param quoted True, if the entries may be quoted
* @throws IOException If the FileOutputStream cannot be established.
*/
public BufferedCsvWriter(String baseFolder, CsvFileDefinition fileDefinition, boolean quoted)
public BufferedCsvWriter(
String baseFolder, CsvFileDefinition fileDefinition, boolean quoted, boolean writeHeader)
throws IOException {
super(
new OutputStreamWriter(
new FileOutputStream(baseFolder + File.separator + fileDefinition.getFilePath(), false),
StandardCharsets.UTF_8));
this.fileDefinition = fileDefinition;
this.quoted = quoted;
writeFileHeader();
if (writeHeader) writeFileHeader(fileDefinition.headLineElements);
}

/**
Expand All @@ -49,16 +50,17 @@ public BufferedCsvWriter(String baseFolder, CsvFileDefinition fileDefinition, bo
* @param fileDefinition The foreseen shape of the file
* @throws IOException If the FileOutputStream cannot be established.
*/
public BufferedCsvWriter(String baseFolder, CsvFileDefinition fileDefinition) throws IOException {
this(baseFolder, fileDefinition, true);
public BufferedCsvWriter(String baseFolder, CsvFileDefinition fileDefinition, boolean writeHeader)
throws IOException {
this(baseFolder, fileDefinition, false, writeHeader);
}

/**
* Actually persisting the provided entity field data
*
* @param entityFieldData a mapping of an entity instance fields to their values
*/
public void write(Map<String, String> entityFieldData) throws IOException {
public void write(Map<String, String> entityFieldData) throws IOException, SinkException {
/* Check against eligible head line elements */
String[] eligibleHeadLineElements = fileDefinition.getHeadLineElements();
if (entityFieldData.size() != eligibleHeadLineElements.length
Expand All @@ -77,11 +79,8 @@ public void write(Map<String, String> entityFieldData) throws IOException {
*
* @throws IOException If something is messed up
*/
private void writeFileHeader() throws IOException {
writeOneLine(
quoted
? StringUtils.quote(StringUtils.camelCaseToSnakeCase(fileDefinition.headLineElements))
: StringUtils.camelCaseToSnakeCase(fileDefinition.headLineElements));
private void writeFileHeader(String[] headLineElements) throws IOException {
writeOneLine(StringUtils.quote(StringUtils.camelCaseToSnakeCase(headLineElements)));
}

/**
Expand Down
52 changes: 41 additions & 11 deletions src/main/java/edu/ie3/datamodel/io/extractor/Extractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

import edu.ie3.datamodel.exceptions.ExtractorException;
import edu.ie3.datamodel.models.Operable;
import edu.ie3.datamodel.models.input.AssetTypeInput;
import edu.ie3.datamodel.models.input.InputEntity;
import edu.ie3.datamodel.models.input.OperatorInput;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -27,23 +30,24 @@ private Extractor() {
throw new IllegalStateException("Utility classes cannot be instantiated");
}

public static List<InputEntity> extractElements(NestedEntity nestedEntity)
public static Set<InputEntity> extractElements(NestedEntity nestedEntity)
throws ExtractorException {
List<InputEntity> resultingList = new ArrayList<>();
CopyOnWriteArrayList<InputEntity> resultingList = new CopyOnWriteArrayList<>();
if (nestedEntity instanceof HasNodes) {
resultingList.addAll(((HasNodes) nestedEntity).allNodes());
}
if (nestedEntity instanceof Operable) {
extractOperator((Operable) nestedEntity).ifPresent(resultingList::add);
}
if (nestedEntity instanceof HasType) {
resultingList.add(((HasType) nestedEntity).getType());
resultingList.add(extractType((HasType) nestedEntity));
}
if (nestedEntity instanceof Operable) {
resultingList.add(((Operable) nestedEntity).getOperator());
if (nestedEntity instanceof HasThermalBus) {
resultingList.add(((HasThermalBus) nestedEntity).getThermalBus());
}

if (nestedEntity instanceof HasBus) {
resultingList.add(((HasBus) nestedEntity).getBus());
if (nestedEntity instanceof HasThermalStorage) {
resultingList.add(((HasThermalStorage) nestedEntity).getThermalStorage());
}

if (nestedEntity instanceof HasLine) {
resultingList.add(((HasLine) nestedEntity).getLine());
}
Expand All @@ -54,7 +58,7 @@ public static List<InputEntity> extractElements(NestedEntity nestedEntity)
nestedEntity.getClass().getSimpleName());
}

if (resultingList.isEmpty()) {
if (resultingList.isEmpty() && !(nestedEntity instanceof Operable)) {
throw new ExtractorException(
"Unable to extract entity of class '"
+ nestedEntity.getClass().getSimpleName()
Expand All @@ -64,6 +68,32 @@ public static List<InputEntity> extractElements(NestedEntity nestedEntity)
+ "sub-interfaces correctly?");
}

return Collections.unmodifiableList(resultingList);
resultingList.stream()
.parallel()
.forEach(
element -> {
if (element instanceof NestedEntity) {
try {
resultingList.addAll(extractElements((NestedEntity) element));
} catch (ExtractorException e) {
log.error(
"An error occurred during extraction of nested entity '{}':{}",
() -> element.getClass().getSimpleName(),
() -> e);
}
}
});

return Collections.unmodifiableSet(new HashSet<>(resultingList));
}

public static AssetTypeInput extractType(HasType entityWithType) {
return entityWithType.getType();
}

public static Optional<OperatorInput> extractOperator(Operable entityWithOperator) {
return entityWithOperator.getOperator().getId().equalsIgnoreCase("NO_OPERATOR_ASSIGNED")
? Optional.empty()
: Optional.of(entityWithOperator.getOperator());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @version 0.1
* @since 31.03.20
*/
public interface HasBus extends NestedEntity {
public interface HasThermalBus extends NestedEntity {

ThermalBusInput getBus();
ThermalBusInput getThermalBus();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* © 2020. TU Dortmund University,
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
* Research group Distribution grid planning and operation
*/
package edu.ie3.datamodel.io.extractor;

import edu.ie3.datamodel.models.input.thermal.ThermalStorageInput;

/**
* Interface that should be implemented by all elements holding a {@link ThermalStorageInput}
* elements and should be processable by the {@link Extractor}.
*
* @version 0.1
* @since 31.03.20
*/
public interface HasThermalStorage {

ThermalStorageInput getThermalStorage();
}
Loading