-
Notifications
You must be signed in to change notification settings - Fork 5
/
CsvJointGridContainerSource.java
57 lines (49 loc) · 2.37 KB
/
CsvJointGridContainerSource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* © 2022. 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 edu.ie3.datamodel.exceptions.SourceException;
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;
public class CsvJointGridContainerSource {
private CsvJointGridContainerSource() {}
public static JointGridContainer read(String gridName, String csvSep, String directoryPath)
throws SourceException {
/* Parameterization */
FileNamingStrategy namingStrategy = new FileNamingStrategy(); // Default naming strategy
/* Instantiating sources */
TypeSource typeSource = new CsvTypeSource(csvSep, directoryPath, namingStrategy);
RawGridSource rawGridSource =
new CsvRawGridSource(csvSep, directoryPath, namingStrategy, typeSource);
ThermalSource thermalSource =
new CsvThermalSource(csvSep, directoryPath, namingStrategy, typeSource);
SystemParticipantSource systemParticipantSource =
new CsvSystemParticipantSource(
csvSep, directoryPath, namingStrategy, typeSource, thermalSource, rawGridSource);
GraphicSource graphicsSource =
new CsvGraphicSource(csvSep, directoryPath, namingStrategy, typeSource, rawGridSource);
/* Loading models */
RawGridElements rawGridElements =
rawGridSource
.getGridData()
.orElseThrow(() -> new SourceException("Error during reading of raw grid data."));
SystemParticipants systemParticipants =
systemParticipantSource
.getSystemParticipants()
.orElseThrow(
() -> new SourceException("Error during reading of system participant data."));
GraphicElements graphicElements =
graphicsSource
.getGraphicElements()
.orElseThrow(() -> new SourceException("Error during reading of graphic elements."));
JointGridContainer fullGrid =
new JointGridContainer(gridName, rawGridElements, systemParticipants, graphicElements);
return fullGrid;
}
}