Skip to content

Commit 07eed44

Browse files
committed
simplify persist joint grid
1 parent 8e7ee6d commit 07eed44

File tree

1 file changed

+1
-77
lines changed

1 file changed

+1
-77
lines changed

src/main/java/edu/ie3/datamodel/io/sink/SqlSink.java

Lines changed: 1 addition & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
import edu.ie3.datamodel.models.Entity;
2121
import edu.ie3.datamodel.models.input.*;
2222
import edu.ie3.datamodel.models.input.connector.*;
23-
import edu.ie3.datamodel.models.input.container.GraphicElements;
2423
import edu.ie3.datamodel.models.input.container.JointGridContainer;
25-
import edu.ie3.datamodel.models.input.container.RawGridElements;
26-
import edu.ie3.datamodel.models.input.container.SystemParticipants;
2724
import edu.ie3.datamodel.models.input.graphics.GraphicInput;
2825
import edu.ie3.datamodel.models.input.system.*;
2926
import edu.ie3.datamodel.models.input.thermal.ThermalBusInput;
@@ -280,80 +277,7 @@ private void executeQueryToPersist(String query) {
280277
/** Persists a whole {@link JointGridContainer}. */
281278
public void persistJointGrid(JointGridContainer jointGridContainer, UUID gridUUID) {
282279
DbGridMetadata identifier = new DbGridMetadata(jointGridContainer.getGridName(), gridUUID);
283-
284-
// get raw grid entities with types or operators
285-
RawGridElements rawGridElements = jointGridContainer.getRawGrid();
286-
Set<NodeInput> nodes = rawGridElements.getNodes();
287-
Set<LineInput> lines = rawGridElements.getLines();
288-
Set<Transformer2WInput> transformer2Ws = rawGridElements.getTransformer2Ws();
289-
Set<Transformer3WInput> transformer3Ws = rawGridElements.getTransformer3Ws();
290-
Set<SwitchInput> switches = rawGridElements.getSwitches();
291-
Set<MeasurementUnitInput> measurementUnits = rawGridElements.getMeasurementUnits();
292-
293-
// get system participants with types or operators
294-
SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants();
295-
Set<BmInput> bmPlants = systemParticipants.getBmPlants();
296-
Set<ChpInput> chpPlants = systemParticipants.getChpPlants();
297-
Set<EvcsInput> evCS = systemParticipants.getEvcs();
298-
Set<EvInput> evs = systemParticipants.getEvs();
299-
Set<FixedFeedInInput> fixedFeedIns = systemParticipants.getFixedFeedIns();
300-
Set<HpInput> heatPumps = systemParticipants.getHeatPumps();
301-
Set<LoadInput> loads = systemParticipants.getLoads();
302-
Set<PvInput> pvPlants = systemParticipants.getPvPlants();
303-
Set<StorageInput> storages = systemParticipants.getStorages();
304-
Set<WecInput> wecPlants = systemParticipants.getWecPlants();
305-
306-
// get graphic elements (just for better readability, we could also just get them directly
307-
// below)
308-
GraphicElements graphicElements = jointGridContainer.getGraphics();
309-
310-
// extract types
311-
Set<AssetTypeInput> types =
312-
Stream.of(
313-
lines,
314-
transformer2Ws,
315-
transformer3Ws,
316-
bmPlants,
317-
chpPlants,
318-
evs,
319-
heatPumps,
320-
storages,
321-
wecPlants)
322-
.flatMap(Collection::stream)
323-
.map(Extractor::extractType)
324-
.collect(Collectors.toSet());
325-
326-
// extract operators
327-
Set<OperatorInput> operators =
328-
Stream.of(
329-
nodes,
330-
lines,
331-
transformer2Ws,
332-
transformer3Ws,
333-
switches,
334-
measurementUnits,
335-
bmPlants,
336-
chpPlants,
337-
evCS,
338-
evs,
339-
fixedFeedIns,
340-
heatPumps,
341-
loads,
342-
pvPlants,
343-
storages,
344-
wecPlants)
345-
.flatMap(Collection::stream)
346-
.map(Extractor::extractOperator)
347-
.flatMap(Optional::stream)
348-
.collect(Collectors.toSet());
349-
350-
List<Entity> toAdd = new LinkedList<>();
351-
toAdd.addAll(rawGridElements.allEntitiesAsList());
352-
toAdd.addAll(systemParticipants.allEntitiesAsList());
353-
toAdd.addAll(graphicElements.allEntitiesAsList());
354-
toAdd.addAll(types);
355-
toAdd.addAll(operators);
356-
280+
List<Entity> toAdd = new LinkedList<>(jointGridContainer.allEntitiesAsList());
357281
persistAll(toAdd, identifier);
358282
}
359283

0 commit comments

Comments
 (0)