-
Notifications
You must be signed in to change notification settings - Fork 5
/
EnergyManagementSource.java
64 lines (56 loc) · 2.58 KB
/
EnergyManagementSource.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
58
59
60
61
62
63
64
/*
* © 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.SourceException;
import edu.ie3.datamodel.io.factory.input.participant.EmInputFactory;
import edu.ie3.datamodel.models.input.EmInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import java.util.Map;
import java.util.UUID;
public class EnergyManagementSource extends EntitySource {
private final TypeSource typeSource;
private final EmInputFactory emInputFactory;
public EnergyManagementSource(TypeSource typeSource, DataSource dataSource) {
super(dataSource);
this.typeSource = typeSource;
this.emInputFactory = new EmInputFactory();
}
/**
* Returns a unique set of {@link EmInput} instances.
*
* <p>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<UUID, EmInput> getEmUnits() throws SourceException {
Map<UUID, OperatorInput> 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}.
*
* <p>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.
*
* <p>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 map of uuid to {@link EmInput} entities
*/
public Map<UUID, EmInput> getEmUnits(Map<UUID, OperatorInput> operators) throws SourceException {
return unpackMap(
buildAssetInputEntityData(EmInput.class, operators).map(emInputFactory::get),
EmInput.class);
}
}