Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions docs/uml/main/InputDatamodelConcept.puml
Original file line number Diff line number Diff line change
Expand Up @@ -368,47 +368,47 @@ Class PowerValue {
- p: Quantity<Power> [kW]
- q: Quantity<Power> [kVA]
}
PowerValue --|> Value
Value <|-- PowerValue

Class HeatAndPowerValue {
- heatDemand: Quantity<Power> [kW]
}
HeatAndPowerValue --|> PowerValue
PowerValue <|-- HeatAndPowerValue

Class HeatDemandValue {
- heatDemand: Quantity<Power> [kW]
}
HeatDemandValue --|> Value
Value <|-- HeatDemandValue

Class EnergyPriceValue {
- price: Quantity<SpecificCurrency> [€/MWh]
}
EnergyPriceValue --|> Value
Value <|-- EnergyPriceValue

Class IrradiationValue {
- directIrradiation: Quantity<Irradiation>
- diffuseIrradiation: Quantity<Irradiation>
}
IrradiationValue --|> Value
Value <|-- IrradiationValue

Class TemperatureValue {
- temperature: Quantity<Temperature>
}
TemperatureValue --|> Value
Value <|-- TemperatureValue

Class WindValue {
- direction: Quantity<Angle>
- velocity: Quantity<Speed>
}
WindValue --|> Value
Value <|-- WindValue

Class WeatherValue {
- coordinate: Point
- irradiation: IrradiationValue
- temperature: TemperatureValue
- wind: WindValue
}
WeatherValue --|> Value
Value <|-- WeatherValue
WeatherValue --* IrradiationValue
WeatherValue --* TemperatureValue
WeatherValue --* WindValue
Expand Down Expand Up @@ -440,7 +440,6 @@ Abstract Class TimeSeries<T extends Value> {
+ T getValue(ZonedDateTime)
}
TimeSeries --|> UniqueEntity
TimeSeries "1" --* "n" TimeBasedValue

Class IndividualTimeSeries<T extends Value> {
- timeToTimeBasedValue:HashMap<ZonedDateTime, TimeBasedValue<T>>
Expand All @@ -449,6 +448,7 @@ Class IndividualTimeSeries<T extends Value> {
+ addAll(Map<ZonedDateTime, T>): void
}
IndividualTimeSeries --|> TimeSeries
IndividualTimeSeries "n" --* "1" TimeBasedValue

Class PowerTimeSeries {
}
Expand All @@ -466,6 +466,7 @@ Abstract Class RepetitiveTimeSeries<T extends Value> {
+ calc(ZonedDateTime): T
}
RepetitiveTimeSeries --|> TimeSeries
RepetitiveTimeSeries "n" --* "1" Value

Class LoadProfileInput {
+ profile: LoadProfileType
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* © 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;

public class DeserializationException extends Exception {
public DeserializationException(String message) {
super(message);
}

public DeserializationException(String message, Throwable cause) {
super(message, cause);
}

public DeserializationException(String message, Object deserializationObject) {
super(message + "\nAffected object to be deseralized: " + deserializationObject.toString());
}

public DeserializationException(String message, Object deserializationObject, Throwable cause) {
super(
message + "\nAffected object to be deseralized: " + deserializationObject.toString(),
cause);
}
}
30 changes: 30 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/CsvFileDefinition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* © 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;

import java.util.Arrays;

public class CsvFileDefinition extends FileDefinition {
private static final String EXTENSION = "csv";

public CsvFileDefinition(String fileName, String[] headLineElements) {
super(fileName, EXTENSION, headLineElements);
}

@Override
public String toString() {
return "CsvFileDefinition{"
+ "fileName='"
+ fileName
+ '\''
+ ", fileExtension='"
+ fileExtension
+ '\''
+ ", headLineElements="
+ Arrays.toString(headLineElements)
+ '}';
}
}
9 changes: 9 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/Destination.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* © 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;

/** Interface to denote where some piece of information is supposed to end */
public interface Destination {}
98 changes: 98 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/FileDefinition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* © 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;

import java.io.File;
import java.util.Arrays;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* Class to contain all relevant information to prepare a file for reading or writing objects to /
* from
*/
public class FileDefinition implements Destination {
private static final Pattern fileNamePattern = Pattern.compile("[\\w\\\\/-]+");
private static final Pattern extensionPattern = Pattern.compile("\\.?([\\w\\.]+)$");
private static final Pattern fullPathPattern =
Pattern.compile("(" + fileNamePattern.pattern() + ")\\.+(\\w+)");

protected final String fileName;
protected final String fileExtension;
protected final String[] headLineElements;

public FileDefinition(String fileName, String fileExtension, String[] headLineElements) {
if (fileName.matches(fullPathPattern.pattern())) {
Matcher matcher = extensionPattern.matcher(fileExtension);
matcher.matches();
this.fileName = matcher.group(0).replaceAll("\\\\/", File.separator);
} else if (fileName.matches(fileNamePattern.pattern())) {
this.fileName = fileName.replaceAll("\\\\/", File.separator);
} else {
throw new IllegalArgumentException(
"The file name \"" + fileName + "\" is no valid file name.");
}

if (fileExtension.matches(fullPathPattern.pattern())) {
Matcher matcher = extensionPattern.matcher(fileExtension);
matcher.matches();
this.fileExtension = matcher.group(1).replaceAll("\\.", "");
} else if (fileExtension.matches(extensionPattern.pattern())) {
Matcher matcher = extensionPattern.matcher(fileExtension);
matcher.matches();
this.fileExtension = matcher.group(0).replaceAll("\\.", "");
} else {
throw new IllegalArgumentException(
"The extension \"" + fileExtension + "\" is no valid file extension.");
}

this.headLineElements = headLineElements;
}

public String getFileName() {
return fileName;
}

public String getFileExtension() {
return fileExtension;
}

public String[] getHeadLineElements() {
return headLineElements;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
FileDefinition that = (FileDefinition) o;
return fileName.equals(that.fileName)
&& fileExtension.equals(that.fileExtension)
&& Arrays.equals(headLineElements, that.headLineElements);
}

@Override
public int hashCode() {
int result = Objects.hash(fileName, fileExtension);
result = 31 * result + Arrays.hashCode(headLineElements);
return result;
}

@Override
public String toString() {
return "FileDefinition{"
+ "fileName='"
+ fileName
+ '\''
+ ", fileExtension='"
+ fileExtension
+ '\''
+ ", headLineElements="
+ Arrays.toString(headLineElements)
+ '}';
}
}
25 changes: 25 additions & 0 deletions src/main/java/edu/ie3/datamodel/io/FileNamingStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import edu.ie3.datamodel.models.UniqueEntity;
import edu.ie3.datamodel.models.input.AssetInput;
import edu.ie3.datamodel.models.input.AssetTypeInput;
import edu.ie3.datamodel.models.input.LoadProfileInput;
import edu.ie3.datamodel.models.input.RandomLoadParameters;
import edu.ie3.datamodel.models.input.graphics.GraphicInput;
import edu.ie3.datamodel.models.input.system.characteristic.AssetCharacteristicInput;
import edu.ie3.datamodel.models.result.ResultEntity;
import java.util.Optional;
import java.util.UUID;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

Expand All @@ -31,6 +33,7 @@ public class FileNamingStrategy {
private static final String INPUT_ENTITY_SUFFIX = "_input";
private static final String TYPE_INPUT = "_type_input";
private static final String GRAPHIC_INPUT_SUFFIX = "_graphic";
private static final String TIME_SERIES_SUFFIX = "_timeseries";

private static final String INPUT_CLASS_STRING = "Input";

Expand Down Expand Up @@ -83,6 +86,28 @@ public Optional<String> getFileName(Class<? extends UniqueEntity> cls) {
return Optional.empty();
}

public Optional<String> getIndividualTimeSeriesFileName(UUID uuid) {
return Optional.of(
prefix
.concat("individual")
.concat(TIME_SERIES_SUFFIX)
.concat("_")
.concat(uuid.toString())
.concat(suffix));
}

public Optional<String> getLoadProfileInputFileName(UUID uuid) {
String identifier =
LoadProfileInput.class.getSimpleName().replace(INPUT_CLASS_STRING, "").toLowerCase();
return Optional.of(
prefix
.concat(identifier)
.concat(TIME_SERIES_SUFFIX)
.concat("_")
.concat(uuid.toString())
.concat(suffix));
}

/**
* Get the the file name for all {@link GraphicInput}s
*
Expand Down
Loading