-
Notifications
You must be signed in to change notification settings - Fork 5
/
TypeSource.java
176 lines (161 loc) · 8.14 KB
/
TypeSource.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* © 2021. 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.io.factory.EntityFactory;
import edu.ie3.datamodel.io.factory.SimpleEntityData;
import edu.ie3.datamodel.io.factory.input.OperatorInputFactory;
import edu.ie3.datamodel.io.factory.typeinput.LineTypeInputFactory;
import edu.ie3.datamodel.io.factory.typeinput.SystemParticipantTypeInputFactory;
import edu.ie3.datamodel.io.factory.typeinput.Transformer2WTypeInputFactory;
import edu.ie3.datamodel.io.factory.typeinput.Transformer3WTypeInputFactory;
import edu.ie3.datamodel.io.source.TypeSourceFactories;
import edu.ie3.datamodel.models.input.InputEntity;
import edu.ie3.datamodel.models.input.OperatorInput;
import edu.ie3.datamodel.models.input.connector.type.LineTypeInput;
import edu.ie3.datamodel.models.input.connector.type.Transformer2WTypeInput;
import edu.ie3.datamodel.models.input.connector.type.Transformer3WTypeInput;
import edu.ie3.datamodel.models.input.system.type.*;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
* Interface that provides the capability to build entities of type {@link
* SystemParticipantTypeInput} and {@link OperatorInput} from different data sources e.g. .csv files
* or databases
*
* @version 0.1
* @since 08.04.20
*/
public interface TypeSource extends DataSource {
/**
* Returns a set of {@link Transformer2WTypeInput} instances. 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 Transformer2WTypeInput} which has to be checked manually, as {@link
* Transformer2WTypeInput#equals(Object)} is NOT restricted on the uuid of {@link
* Transformer2WTypeInput}.
*
* @return a set of object and uuid unique {@link Transformer2WTypeInput} entities
*/
default Set<Transformer2WTypeInput> getTransformer2WTypes() {
return buildEntities(Transformer2WTypeInput.class, TypeSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a set of {@link OperatorInput} instances. 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 OperatorInput} which has to be checked manually, as {@link OperatorInput#equals(Object)}
* is NOT restricted on the uuid of {@link OperatorInput}.
*
* @return a set of object and uuid unique {@link OperatorInput} entities
*/
default Set<OperatorInput> getOperators() {
return buildEntities(OperatorInput.class, TypeSourceFactories.getOperatorInputFactory());
}
/**
* Returns a set of {@link LineTypeInput} instances. 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 LineTypeInput} which has to be checked manually, as {@link LineTypeInput#equals(Object)}
* is NOT restricted on the uuid of {@link LineTypeInput}.
*
* @return a set of object and uuid unique {@link LineTypeInput} entities
*/
default Set<LineTypeInput> getLineTypes() {
return buildEntities(LineTypeInput.class, TypeSourceFactories.getLineTypeInputFactory());
}
/**
* Returns a set of {@link Transformer3WTypeInput} instances. 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 Transformer3WTypeInput} which has to be checked manually, as {@link
* Transformer3WTypeInput#equals(Object)} is NOT restricted on the uuid of {@link
* Transformer3WTypeInput}.
*
* @return a set of object and uuid unique {@link Transformer3WTypeInput} entities
*/
default Set<Transformer3WTypeInput> getTransformer3WTypes() {
return buildEntities(Transformer3WTypeInput.class, TypeSourceFactories.getTransformer3WTypeInputFactory());
}
/**
* Returns a set of {@link BmTypeInput} instances. 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 BmTypeInput} which has to be checked manually, as {@link BmTypeInput#equals(Object)} is
* NOT restricted on the uuid of {@link BmTypeInput}.
*
* @return a set of object and uuid unique {@link BmTypeInput} entities
*/
default Set<BmTypeInput> getBmTypes() {
return buildEntities(BmTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
/**
* Returns a set of {@link ChpTypeInput} instances. 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 ChpTypeInput} which has to be checked manually, as {@link ChpTypeInput#equals(Object)}
* is NOT restricted on the uuid of {@link ChpTypeInput}.
*
* @return a set of object and uuid unique {@link ChpTypeInput} entities
*/
default Set<ChpTypeInput> getChpTypes() {
return buildEntities(ChpTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
/**
* Returns a set of {@link HpTypeInput} instances. 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 HpTypeInput} which has to be checked manually, as {@link HpTypeInput#equals(Object)} is
* NOT restricted on the uuid of {@link HpTypeInput}.
*
* @return a set of object and uuid unique {@link HpTypeInput} entities
*/
default Set<HpTypeInput> getHpTypes() {
return buildEntities(HpTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
/**
* Returns a set of {@link StorageTypeInput} instances. 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 StorageTypeInput} which has to be checked manually, as {@link
* StorageTypeInput#equals(Object)} is NOT restricted on the uuid of {@link StorageTypeInput}.
*
* @return a set of object and uuid unique {@link StorageTypeInput} entities
*/
default Set<StorageTypeInput> getStorageTypes() {
return buildEntities(StorageTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
/**
* Returns a set of {@link WecTypeInput} instances. 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 WecTypeInput} which has to be checked manually, as {@link WecTypeInput#equals(Object)}
* is NOT restricted on the uuid of {@link WecTypeInput}.
*
* @return a set of object and uuid unique {@link WecTypeInput} entities
*/
default Set<WecTypeInput> getWecTypes() {
return buildEntities(WecTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
/**
* Returns a set of {@link EvTypeInput} instances. 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 EvTypeInput} which has to be checked manually, as {@link EvTypeInput#equals(Object)} is
* NOT restricted on the uuid of {@link EvTypeInput}.
*
* @return a set of object and uuid unique {@link EvTypeInput} entities
*/
default Set<EvTypeInput> getEvTypes() {
return buildEntities(EvTypeInput.class, TypeSourceFactories.getSystemParticipantTypeInputFactory());
}
<T extends InputEntity> Stream<Map<String, String>> getSourceData(Class<T> entityClass);
default <T extends InputEntity> Set<T> buildEntities(
Class<T> entityClass,
EntityFactory<? extends InputEntity, SimpleEntityData> factory
) {
return getSourceData(entityClass)
.map(
fieldsToAttributes -> {
SimpleEntityData data = new SimpleEntityData(fieldsToAttributes, entityClass);
return (Optional<T>) factory.get(data);
})
.flatMap(Optional::stream)
.collect(Collectors.toSet());
}
}