Skip to content

Commit e29f560

Browse files
Merge pull request #1026 from ie3-institute/jb/#1025-persist-emunits
Enable persisting emUnits
2 parents 2bf8851 + 95ff1c1 commit e29f560

39 files changed

+177
-98
lines changed

src/main/java/edu/ie3/datamodel/io/extractor/Extractor.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ public static Set<UniqueInputEntity> extractElements(NestedEntity nestedEntity)
5151
if (nestedEntity instanceof HasLine nestedHasLine) {
5252
resultingList.add(nestedHasLine.getLine());
5353
}
54+
if (nestedEntity instanceof HasEm nestedHasEms) {
55+
nestedHasEms.getControllingEm().ifPresent(resultingList::add);
56+
}
5457

5558
if (resultingList.contains(null)) {
5659
log.warn(
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* © 2024. TU Dortmund University,
3+
* Institute of Energy Systems, Energy Efficiency and Energy Economics,
4+
* Research group Distribution grid planning and operation
5+
*/
6+
package edu.ie3.datamodel.io.extractor;
7+
8+
import edu.ie3.datamodel.models.input.EmInput;
9+
import java.util.Optional;
10+
11+
/**
12+
* Interface that should be implemented by all elements that can be controlled by {@link
13+
* edu.ie3.datamodel.models.input.EmInput} elements and should be processable by the {@link
14+
* Extractor}.
15+
*/
16+
public interface HasEm extends NestedEntity {
17+
Optional<EmInput> getControllingEm();
18+
}

src/main/java/edu/ie3/datamodel/models/input/EmInput.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66
package edu.ie3.datamodel.models.input;
77

8+
import edu.ie3.datamodel.io.extractor.HasEm;
89
import edu.ie3.datamodel.models.OperationTime;
910
import edu.ie3.datamodel.models.UniqueEntity;
1011
import java.util.Objects;
1112
import java.util.Optional;
1213
import java.util.UUID;
1314

14-
public class EmInput extends AssetInput {
15+
public class EmInput extends AssetInput implements HasEm {
1516

1617
/** Reference to the control strategy to be used for this model */
1718
private final String controlStrategy;
@@ -20,7 +21,7 @@ public class EmInput extends AssetInput {
2021
* Optional UUID of the parent {@link EmInput} that is controlling this em unit. If null, this em
2122
* unit is not em-controlled.
2223
*/
23-
private final EmInput parentEm;
24+
private final EmInput controllingEm;
2425

2526
/**
2627
* Constructor for an operated energy management system
@@ -30,18 +31,18 @@ public class EmInput extends AssetInput {
3031
* @param operator of the asset
3132
* @param operationTime time for which the entity is operated
3233
* @param emControlStrategy the control strategy
33-
* @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable.
34+
* @param controllingEm The {@link EmInput} controlling this em unit. Null, if not applicable.
3435
*/
3536
public EmInput(
3637
UUID uuid,
3738
String id,
3839
OperatorInput operator,
3940
OperationTime operationTime,
4041
String emControlStrategy,
41-
EmInput parentEm) {
42+
EmInput controllingEm) {
4243
super(uuid, id, operator, operationTime);
4344
this.controlStrategy = emControlStrategy;
44-
this.parentEm = parentEm;
45+
this.controllingEm = controllingEm;
4546
}
4647

4748
/**
@@ -50,22 +51,18 @@ public EmInput(
5051
* @param uuid of the input entity
5152
* @param id of the asset
5253
* @param emControlStrategy the control strategy
53-
* @param parentEm The {@link EmInput} controlling this em unit. Null, if not applicable.
54+
* @param controllingEm The {@link EmInput} controlling this em unit. Null, if not applicable.
5455
*/
55-
public EmInput(UUID uuid, String id, String emControlStrategy, EmInput parentEm) {
56+
public EmInput(UUID uuid, String id, String emControlStrategy, EmInput controllingEm) {
5657
super(uuid, id);
5758
this.controlStrategy = emControlStrategy;
58-
this.parentEm = parentEm;
59+
this.controllingEm = controllingEm;
5960
}
6061

6162
public String getControlStrategy() {
6263
return controlStrategy;
6364
}
6465

65-
public Optional<EmInput> getParentEm() {
66-
return Optional.ofNullable(parentEm);
67-
}
68-
6966
@Override
7067
public EmInputCopyBuilder copy() {
7168
return new EmInputCopyBuilder(this);
@@ -77,12 +74,12 @@ public boolean equals(Object o) {
7774
if (!(o instanceof EmInput emInput)) return false;
7875
if (!super.equals(o)) return false;
7976
return Objects.equals(controlStrategy, emInput.controlStrategy)
80-
&& Objects.equals(parentEm, emInput.parentEm);
77+
&& Objects.equals(controllingEm, emInput.controllingEm);
8178
}
8279

8380
@Override
8481
public int hashCode() {
85-
return Objects.hash(super.hashCode(), controlStrategy, parentEm);
82+
return Objects.hash(super.hashCode(), controlStrategy, controllingEm);
8683
}
8784

8885
@Override
@@ -92,15 +89,20 @@ public String toString() {
9289
+ getUuid()
9390
+ ", id='"
9491
+ getId()
95-
+ ", operator="
92+
+ "', operator="
9693
+ getOperator().getUuid()
9794
+ ", operationTime="
9895
+ getOperationTime()
9996
+ ", controlStrategy="
10097
+ getControlStrategy()
101-
+ ", parentEm="
102-
+ getParentEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
103-
+ '}';
98+
+ ", controllingEm="
99+
+ getControllingEm().map(UniqueEntity::getUuid).map(UUID::toString).orElse("")
100+
+ "}";
101+
}
102+
103+
@Override
104+
public Optional<EmInput> getControllingEm() {
105+
return Optional.ofNullable(controllingEm);
104106
}
105107

106108
public static class EmInputCopyBuilder extends AssetInputCopyBuilder<EmInputCopyBuilder> {
@@ -112,7 +114,7 @@ public static class EmInputCopyBuilder extends AssetInputCopyBuilder<EmInputCopy
112114
protected EmInputCopyBuilder(EmInput entity) {
113115
super(entity);
114116
this.controlStrategy = entity.getControlStrategy();
115-
this.parentEm = entity.parentEm;
117+
this.parentEm = entity.controllingEm;
116118
}
117119

118120
public EmInputCopyBuilder controlStrategy(String controlStrategy) {

src/main/java/edu/ie3/datamodel/models/input/system/BmInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public String toString() {
150150
+ ", qCharacteristics='"
151151
+ getqCharacteristics()
152152
+ "', em="
153-
+ getEm()
153+
+ getControllingEm()
154154
+ ", type="
155155
+ type.getUuid()
156156
+ ", marketReaction="

src/main/java/edu/ie3/datamodel/models/input/system/ChpInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public String toString() {
151151
+ ", qCharacteristics='"
152152
+ getqCharacteristics()
153153
+ "', em="
154-
+ getEm()
154+
+ getControllingEm()
155155
+ ", thermalBus="
156156
+ thermalBus.getUuid()
157157
+ ", type="

src/main/java/edu/ie3/datamodel/models/input/system/EvInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public String toString() {
104104
+ ", qCharacteristics='"
105105
+ getqCharacteristics()
106106
+ "', em="
107-
+ getEm()
107+
+ getControllingEm()
108108
+ ", type="
109109
+ type.getUuid()
110110
+ '}';

src/main/java/edu/ie3/datamodel/models/input/system/EvcsInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public String toString() {
219219
+ ", qCharacteristics='"
220220
+ getqCharacteristics()
221221
+ "', em="
222-
+ getEm()
222+
+ getControllingEm()
223223
+ ", type="
224224
+ type
225225
+ ", chargingPoints="

src/main/java/edu/ie3/datamodel/models/input/system/FixedFeedInInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public String toString() {
116116
+ ", qCharacteristics='"
117117
+ getqCharacteristics()
118118
+ "', em="
119-
+ getEm()
119+
+ getControllingEm()
120120
+ ", sRated="
121121
+ sRated
122122
+ ", cosphiRated="

src/main/java/edu/ie3/datamodel/models/input/system/HpInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public String toString() {
119119
+ ", qCharacteristics='"
120120
+ getqCharacteristics()
121121
+ "', em="
122-
+ getEm()
122+
+ getControllingEm()
123123
+ ", type="
124124
+ type.getUuid()
125125
+ ", thermalBus="

src/main/java/edu/ie3/datamodel/models/input/system/LoadInput.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public String toString() {
255255
+ ", qCharacteristics='"
256256
+ getqCharacteristics()
257257
+ "', em="
258-
+ getEm()
258+
+ getControllingEm()
259259
+ ", dsm="
260260
+ dsm
261261
+ ", eConsAnnual="

0 commit comments

Comments
 (0)