-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement SQL sinks #903
base: dev
Are you sure you want to change the base?
Implement SQL sinks #903
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That looks already very good. Very nice work @jo-bao 🚀
I guess this was blocked by the PSU not being released, but can now be unblocked by #1006 |
…ources # Conflicts: # src/test/groovy/edu/ie3/test/common/TimeSeriesTestData.groovy
# Conflicts: # src/main/java/edu/ie3/datamodel/io/naming/DatabaseNamingStrategy.java
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good. Some minor things.
Also make sure to take another look at the Sonarqube complaints
RawGridElements rawGridElements = jointGridContainer.getRawGrid(); | ||
Set<NodeInput> nodes = rawGridElements.getNodes(); | ||
Set<LineInput> lines = rawGridElements.getLines(); | ||
Set<Transformer2WInput> transformer2Ws = rawGridElements.getTransformer2Ws(); | ||
Set<Transformer3WInput> transformer3Ws = rawGridElements.getTransformer3Ws(); | ||
Set<SwitchInput> switches = rawGridElements.getSwitches(); | ||
Set<MeasurementUnitInput> measurementUnits = rawGridElements.getMeasurementUnits(); | ||
|
||
// get system participants with types or operators | ||
SystemParticipants systemParticipants = jointGridContainer.getSystemParticipants(); | ||
Set<BmInput> bmPlants = systemParticipants.getBmPlants(); | ||
Set<ChpInput> chpPlants = systemParticipants.getChpPlants(); | ||
Set<EvcsInput> evCS = systemParticipants.getEvcs(); | ||
Set<EvInput> evs = systemParticipants.getEvs(); | ||
Set<FixedFeedInInput> fixedFeedIns = systemParticipants.getFixedFeedIns(); | ||
Set<HpInput> heatPumps = systemParticipants.getHeatPumps(); | ||
Set<LoadInput> loads = systemParticipants.getLoads(); | ||
Set<PvInput> pvPlants = systemParticipants.getPvPlants(); | ||
Set<StorageInput> storages = systemParticipants.getStorages(); | ||
Set<WecInput> wecPlants = systemParticipants.getWecPlants(); | ||
|
||
// get graphic elements (just for better readability, we could also just get them directly | ||
// below) | ||
GraphicElements graphicElements = jointGridContainer.getGraphics(); | ||
|
||
// extract types | ||
Set<AssetTypeInput> types = | ||
Stream.of( | ||
lines, | ||
transformer2Ws, | ||
transformer3Ws, | ||
bmPlants, | ||
chpPlants, | ||
evs, | ||
heatPumps, | ||
storages, | ||
wecPlants) | ||
.flatMap(Collection::stream) | ||
.map(Extractor::extractType) | ||
.collect(Collectors.toSet()); | ||
|
||
// extract operators | ||
Set<OperatorInput> operators = | ||
Stream.of( | ||
nodes, | ||
lines, | ||
transformer2Ws, | ||
transformer3Ws, | ||
switches, | ||
measurementUnits, | ||
bmPlants, | ||
chpPlants, | ||
evCS, | ||
evs, | ||
fixedFeedIns, | ||
heatPumps, | ||
loads, | ||
pvPlants, | ||
storages, | ||
wecPlants) | ||
.flatMap(Collection::stream) | ||
.map(Extractor::extractOperator) | ||
.flatMap(Optional::stream) | ||
.collect(Collectors.toSet()); | ||
|
||
List<Entity> toAdd = new LinkedList<>(); | ||
toAdd.addAll(rawGridElements.allEntitiesAsList()); | ||
toAdd.addAll(systemParticipants.allEntitiesAsList()); | ||
toAdd.addAll(graphicElements.allEntitiesAsList()); | ||
toAdd.addAll(types); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you get all the elements with the e.g. systemParticipants.allEntitiesAsList() method ? The types and operators should be extracted automatically when persisting the participants, don't they?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it will be that easy, because not every system participant has a type. But maybe we can move this to another issue, because csv related it's the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does because you handle nested entities inside persistAll
/** Persists a whole {@link JointGridContainer}. */
public void persistJointGrid(JointGridContainer jointGridContainer, UUID gridUUID) {
DbGridMetadata identifier = new DbGridMetadata(jointGridContainer.getGridName(), gridUUID);
List<Entity> toAdd = new LinkedList<>();
toAdd.addAll(jointGridContainer.allEntitiesAsList());
persistAll(toAdd, identifier);
}
is sufficient
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please leave threads with open points / discussions unresolved, that makes it easier to refer back to 🙂
src/test/resources/edu/ie3/datamodel/io/sink/_sql/sql_test_data.sql
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good. Some minor things.
Also make sure to take another look at the Sonarqube complaints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just this one open point 🙂
Resolves #762