-
Notifications
You must be signed in to change notification settings - Fork 5
/
RawGridSource.java
313 lines (293 loc) · 16.3 KB
/
RawGridSource.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/*
* © 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.input.*;
import edu.ie3.datamodel.models.input.MeasurementUnitInput;
import edu.ie3.datamodel.models.input.NodeInput;
import edu.ie3.datamodel.models.input.OperatorInput;
import edu.ie3.datamodel.models.input.connector.LineInput;
import edu.ie3.datamodel.models.input.connector.SwitchInput;
import edu.ie3.datamodel.models.input.connector.Transformer2WInput;
import edu.ie3.datamodel.models.input.connector.Transformer3WInput;
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.container.RawGridElements;
import edu.ie3.datamodel.models.input.system.type.EvTypeInput;
import java.util.Optional;
import java.util.Set;
/**
* Interface that provides the capability to build entities that are hold by a {@link
* RawGridElements} as well as the {@link RawGridElements} container as well from different data
* sources e.g. .csv files or databases.
*
* @version 0.1
* @since 08.04.20
*/
public class RawGridSource implements DataSource {
//general fields
TypeSource typeSource;
FunctionalDataSource dataSource;
//factories
private final NodeInputFactory nodeInputFactory;
private final LineInputFactory lineInputFactory;
private final Transformer2WInputFactory transformer2WInputFactory;
private final Transformer3WInputFactory transformer3WInputFactory;
private final SwitchInputFactory switchInputFactory;
private final MeasurementUnitInputFactory measurementUnitInputFactory;
public RawGridSource(TypeSource _typeSource, FunctionalDataSource _dataSource) {
this.typeSource = _typeSource;
this.dataSource = _dataSource;
// init factories
this.nodeInputFactory = new NodeInputFactory();
this.lineInputFactory = new LineInputFactory();
this.transformer2WInputFactory = new Transformer2WInputFactory();
this.transformer3WInputFactory = new Transformer3WInputFactory();
this.switchInputFactory = new SwitchInputFactory();
this.measurementUnitInputFactory = new MeasurementUnitInputFactory();
}
/**
* Should return either a consistent instance of {@link RawGridElements} wrapped in {@link
* Optional} or an empty {@link Optional}. The decision to use {@link Optional} instead of
* returning the {@link RawGridElements} instance directly is motivated by the fact, that a {@link
* RawGridElements} is a container instance that depends on several other entities. Without being
* complete, it is useless for further processing.
*
* <p>Hence, whenever at least one entity {@link RawGridElements} depends on cannot be provided,
* {@link Optional#empty()} should be returned and extensive logging should provide enough
* information to debug the error and fix the persistent data that has been failed to processed.
*
* <p>Furthermore, it is expected, that the specific implementation of this method ensures not
* only the completeness of the resulting {@link RawGridElements} instance, but also its validity
* e.g. in the sense that not duplicate UUIDs exist within all entities contained in the returning
* instance.
*
* @return either a valid, complete {@link RawGridElements} optional or {@link Optional#empty()}
*/
public Optional<RawGridElements> getGridData() { return null; }
/**
* Returns a unique set of {@link NodeInput} 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 NodeInput} which has to be checked manually,
* as {@link NodeInput#equals(Object)} is NOT restricted on the uuid of {@link NodeInput}.
*
* @return a set of object and uuid unique {@link NodeInput} entities
*/
public Set<NodeInput> getNodes() {
return getNodes(typeSource.getOperators());
}
/**
* Returns a set of {@link NodeInput} 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
* NodeInput} which has to be checked manually, as {@link NodeInput#equals(Object)} is NOT
* restricted on the uuid of {@link NodeInput}.
*
* <p>In contrast to {@link #getNodes} this interface provides the ability to pass in an already
* existing set of {@link OperatorInput} entities, the {@link NodeInput} 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 it's up to the concrete implementation of an
* empty set or 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 set of object and uuid unique {@link NodeInput} entities
*/
public Set<NodeInput> getNodes(Set<OperatorInput> operators) {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getNodeInputFactory());
}
/**
* Returns a unique set of {@link LineInput} 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 LineInput} which has to be checked manually,
* as {@link LineInput#equals(Object)} is NOT restricted on the uuid of {@link LineInput}.
*
* @return a set of object and uuid unique {@link LineInput} entities
*/
public Set<LineInput> getLines() {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a set of {@link LineInput} 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
* LineInput} which has to be checked manually, as {@link LineInput#equals(Object)} is NOT
* restricted on the uuid of {@link LineInput}.
*
* <p>In contrast to {@link #getNodes} this interface provides the ability to pass in an already
* existing set of {@link NodeInput}, {@link LineTypeInput} and {@link OperatorInput} entities,
* the {@link LineInput} instances depend on. Doing so, already loaded nodes, line types and
* operators can be recycled to improve performance and prevent unnecessary loading operations.
*
* <p>If something fails during the creation process it's up to the concrete implementation of an
* empty set or 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
* @param nodes a set of object and uuid unique {@link NodeInput} entities
* @param lineTypeInputs a set of object and uuid unique {@link LineTypeInput} entities
* @return a set of object and uuid unique {@link LineInput} entities
*/
public Set<LineInput> getLines(
Set<NodeInput> nodes, Set<LineTypeInput> lineTypeInputs, Set<OperatorInput> operators) {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a unique set of {@link Transformer2WInput} 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 Transformer2WInput} which has to be checked
* manually, as {@link Transformer2WInput#equals(Object)} is NOT restricted on the uuid of {@link
* Transformer2WInput}.
*
* @return a set of object and uuid unique {@link Transformer2WInput} entities
*/
public Set<Transformer2WInput> get2WTransformers() {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a set of {@link Transformer2WInput} 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 Transformer2WInput} which has to be checked manually, as {@link
* Transformer2WInput#equals(Object)} is NOT restricted on the uuid of {@link Transformer2WInput}.
*
* <p>In contrast to {@link #getNodes()} this interface provides the ability to pass in an already
* existing set of {@link NodeInput}, {@link Transformer2WTypeInput} and {@link OperatorInput}
* entities, the {@link Transformer2WInput} instances depend on. Doing so, already loaded nodes,
* line types and operators can be recycled to improve performance and prevent unnecessary loading
* operations.
*
* <p>If something fails during the creation process it's up to the concrete implementation of an
* empty set or 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
* @param nodes a set of object and uuid unique {@link NodeInput} entities
* @param transformer2WTypes a set of object and uuid unique {@link Transformer2WTypeInput}
* entities
* @return a set of object and uuid unique {@link Transformer2WInput} entities
*/
public Set<Transformer2WInput> get2WTransformers(
Set<NodeInput> nodes,
Set<Transformer2WTypeInput> transformer2WTypes,
Set<OperatorInput> operators) {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a unique set of {@link Transformer3WInput} 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 Transformer3WInput} which has to be checked
* manually, as {@link Transformer3WInput#equals(Object)} is NOT restricted on the uuid of {@link
* Transformer3WInput}.
*
* @return a set of object and uuid unique {@link Transformer3WInput} entities
*/
public Set<Transformer3WInput> get3WTransformers() {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a set of {@link Transformer3WInput} 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 Transformer3WInput} which has to be checked manually, as {@link
* Transformer3WInput#equals(Object)} is NOT restricted on the uuid of {@link Transformer3WInput}.
*
* <p>In contrast to {@link #getNodes()} this interface provides the ability to pass in an already
* existing set of {@link NodeInput}, {@link Transformer3WTypeInput} and {@link OperatorInput}
* entities, the {@link Transformer3WInput} instances depend on. Doing so, already loaded nodes,
* line types and operators can be recycled to improve performance and prevent unnecessary loading
* operations.
*
* <p>If something fails during the creation process it's up to the concrete implementation of an
* empty set or 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
* @param nodes a set of object and uuid unique {@link NodeInput} entities
* @param transformer3WTypeInputs a set of object and uuid unique {@link Transformer3WTypeInput}
* entities
* @return a set of object and uuid unique {@link Transformer3WInput} entities
*/
public Set<Transformer3WInput> get3WTransformers(
Set<NodeInput> nodes,
Set<Transformer3WTypeInput> transformer3WTypeInputs,
Set<OperatorInput> operators) {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a unique set of {@link SwitchInput} 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 SwitchInput} which has to be checked
* manually, as {@link SwitchInput#equals(Object)} is NOT restricted on the uuid of {@link
* SwitchInput}.
*
* @return a set of object and uuid unique {@link SwitchInput} entities
*/
public Set<SwitchInput> getSwitches() {
return dataSource.buildEntities(Transformer2WTypeInput.class, RawGridSourceFactories.getTransformer2WTypeInputFactory());
}
/**
* Returns a set of {@link SwitchInput} 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 SwitchInput} which has to be checked manually, as {@link SwitchInput#equals(Object)} is
* NOT restricted on the uuid of {@link SwitchInput}.
*
* <p>In contrast to {@link #getNodes()} this interface provides the ability to pass in an already
* existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link SwitchInput}
* instances depend on. Doing so, already loaded nodes, line types and operators can be recycled
* to improve performance and prevent unnecessary loading operations.
*
* <p>If something fails during the creation process it's up to the concrete implementation of an
* empty set or 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
* @param nodes a set of object and uuid unique {@link NodeInput} entities
* @return a set of object and uuid unique {@link SwitchInput} entities
*/
public Set<SwitchInput> getSwitches(Set<NodeInput> nodes, Set<OperatorInput> operators) {
return dataSource.buildEntities(Transformer2WTypeInput.class, transformer2WTypeInputFactory);
}
/**
* Returns a unique set of {@link MeasurementUnitInput} 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 MeasurementUnitInput} which has to be checked
* manually, as {@link MeasurementUnitInput#equals(Object)} is NOT restricted on the uuid of
* {@link MeasurementUnitInput}.
*
* @return a set of object and uuid unique {@link MeasurementUnitInput} entities
*/
public Set<MeasurementUnitInput> getMeasurementUnits() {
return dataSource.buildEntities(Transformer2WTypeInput.class, transformer2WTypeInputFactory);
}
/**
* Returns a set of {@link MeasurementUnitInput} 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 MeasurementUnitInput} which has to be checked manually, as {@link
* MeasurementUnitInput#equals(Object)} is NOT restricted on the uuid of {@link
* MeasurementUnitInput}.
*
* <p>In contrast to {@link #getNodes()} this interface provides the ability to pass in an already
* existing set of {@link NodeInput} and {@link OperatorInput} entities, the {@link
* MeasurementUnitInput} instances depend on. Doing so, already loaded nodes, line types and
* operators can be recycled to improve performance and prevent unnecessary loading operations.
*
* <p>If something fails during the creation process it's up to the concrete implementation of an
* empty set or 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
* @param nodes a set of object and uuid unique {@link NodeInput} entities
* @return a set of object and uuid unique {@link MeasurementUnitInput} entities
*/
public Set<MeasurementUnitInput> getMeasurementUnits(Set<NodeInput> nodes, Set<OperatorInput> operators) {
return dataSource.buildEntities(EvTypeInput.class, RawGridSourceFactories.getSystemParticipantTypeInputFactory());
}
}