Skip to content

Commit 62564e2

Browse files
committed
changes after review
1 parent 16f65e8 commit 62564e2

File tree

6 files changed

+19
-61
lines changed

6 files changed

+19
-61
lines changed

src/main/java/edu/ie3/datamodel/io/DbGridMetadata.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
/** Class for identification of entities and results from grids in SQL databases. */
1414
public record DbGridMetadata(String gridName, UUID uuid) {
1515

16-
public static final String GRID_TABLE = "grids";
17-
public static final String GRID_NAME = "grid_name";
18-
public static final String GRID_UUID = "grid_uuid";
16+
public static final String GRID_TABLE_COLUMN = "grids";
17+
public static final String GRID_NAME_COLUMN = "grid_name";
18+
public static final String GRID_UUID_COLUMN = "grid_uuid";
1919

2020
public String toString() {
21-
return GRID_NAME + "=" + gridName + ", " + GRID_UUID + "=" + uuid.toString();
21+
return GRID_NAME_COLUMN + "=" + gridName + ", " + GRID_UUID_COLUMN + "=" + uuid.toString();
2222
}
2323

2424
/** @return Stream with grid uuid */

src/main/java/edu/ie3/datamodel/io/SqlUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private static String beginQueryCreateTable(String schemaName, String tableName)
2525

2626
/** @return query to create a SQL table for a grid */
2727
public static String queryCreateGridTable(String schemaName) {
28-
return beginQueryCreateTable(schemaName, DbGridMetadata.GRID_TABLE)
28+
return beginQueryCreateTable(schemaName, DbGridMetadata.GRID_TABLE_COLUMN)
2929
+ "\tuuid uuid PRIMARY KEY,\n\tname TEXT NOT NULL\n"
3030
+ endQueryCreateTable;
3131
}

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,13 @@ public <C extends Entity> void persistAll(Collection<C> entities, DbGridMetadata
106106
persistMixedList(
107107
entitiesToAdd.stream().filter(ent -> cls.isAssignableFrom(ent.getClass())).toList(),
108108
identifier);
109-
entitiesToAdd.removeIf(
110-
ent ->
111-
cls.isAssignableFrom(
112-
ent.getClass())); // maybe it's not necessary, but I'm not sure if there are
113-
// entities who aren't in the hierarchic structure
109+
entitiesToAdd.removeIf(ent -> cls.isAssignableFrom(ent.getClass()));
114110
}
115111
persistMixedList(new ArrayList<>(entitiesToAdd), identifier); // persist left entities
116112
}
117113

118114
/**
119-
* Persist an entity. By default this method take care about the extraction process of nested
115+
* Persist an entity. By default this method takes care of the extraction process of nested
120116
* entities (if any)
121117
*
122118
* @param entity the entity that should be persisted
@@ -456,7 +452,7 @@ private static String basicInsertQuery(String schemaName, String tableName) {
456452
/** Provides the insert, column names, grid identifier and the VALUES statement for a query. */
457453
private String basicInsertQueryValuesGrid(
458454
String schemaName, String tableName, String[] headerElements) {
459-
String[] addParams = {DbGridMetadata.GRID_UUID};
455+
String[] addParams = {DbGridMetadata.GRID_UUID_COLUMN};
460456
return basicInsertQuery(schemaName, tableName)
461457
+ " "
462458
+ writeOneLine(StringUtils.camelCaseToSnakeCase(headerElements), addParams)
@@ -469,7 +465,7 @@ private String basicInsertQueryValuesGrid(
469465
*/
470466
private String basicInsertQueryValuesITS(
471467
String schemaName, String tableName, String[] headerElements) {
472-
String[] addParams = {DbGridMetadata.GRID_UUID, TIME_SERIES};
468+
String[] addParams = {DbGridMetadata.GRID_UUID_COLUMN, TIME_SERIES};
473469
return basicInsertQuery(schemaName, tableName)
474470
+ " "
475471
+ writeOneLine(StringUtils.camelCaseToSnakeCase(headerElements), addParams)

src/test/groovy/edu/ie3/datamodel/io/sink/SqlSinkTest.groovy

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -130,28 +130,7 @@ class SqlSinkTest extends Specification implements TestContainerHelper, TimeSeri
130130
timeSeriesProcessorMap.put(timeSeriesProcessorKey, timeSeriesProcessor)
131131

132132
SqlSink sink = new SqlSink(schemaName,
133-
new ProcessorProvider([
134-
new ResultEntityProcessor(PvResult),
135-
new ResultEntityProcessor(WecResult),
136-
new ResultEntityProcessor(EvResult),
137-
new ResultEntityProcessor(EvcsResult),
138-
new ResultEntityProcessor(EmResult),
139-
new ResultEntityProcessor(FlexOptionsResult),
140-
new InputEntityProcessor(Transformer2WInput),
141-
new InputEntityProcessor(NodeInput),
142-
new InputEntityProcessor(EvcsInput),
143-
new InputEntityProcessor(Transformer2WTypeInput),
144-
new InputEntityProcessor(LineGraphicInput),
145-
new InputEntityProcessor(NodeGraphicInput),
146-
new InputEntityProcessor(CylindricalStorageInput),
147-
new InputEntityProcessor(ThermalHouseInput),
148-
new InputEntityProcessor(OperatorInput),
149-
new InputEntityProcessor(LineInput),
150-
new InputEntityProcessor(ThermalBusInput),
151-
new InputEntityProcessor(LineTypeInput),
152-
new InputEntityProcessor(LoadInput),
153-
new InputEntityProcessor(EmInput)
154-
], timeSeriesProcessorMap),
133+
new ProcessorProvider(),
155134
namingStrategy,
156135
connector)
157136
UUID inputModel = UUID.fromString("22bea5fc-2cb2-4c61-beb9-b476e0107f52")

src/test/resources/edu/ie3/datamodel/io/sink/_sql/input_entities.sql

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,17 @@ CREATE TABLE public.node_graphic_input
7979

8080
CREATE TABLE public.cylindrical_storage_input
8181
(
82-
uuid UUID PRIMARY KEY,
82+
uuid uuid PRIMARY KEY,
8383
c DOUBLE PRECISION NOT NULL,
8484
id TEXT NOT NULL,
85-
inlet_temp DOUBLE PRECISION NOT NULL,
86-
operates_from TIMESTAMP WITH TIME ZONE,
87-
operates_until TIMESTAMP WITH TIME ZONE,
88-
operator UUID,
89-
return_temp DOUBLE PRECISION NOT NULL,
90-
storage_volume_lvl DOUBLE PRECISION NOT NULL,
91-
storage_volume_lvl_min DOUBLE PRECISION NOT NULL,
92-
thermal_bus UUID NOT NULL,
93-
grid_uuid UUID NOT NULL REFERENCES grids(uuid)
85+
inlet_temp double precision NOT NULL,
86+
operates_from timestamp with time zone,
87+
operates_until timestamp with time zone,
88+
operator uuid,
89+
return_temp double precision NOT NULL,
90+
storage_volume_lvl double precision NOT NULL,
91+
thermal_bus uuid NOT NULL,
92+
grid_uuid uuid NOT NULL
9493
)
9594
WITHOUT OIDS
9695
TABLESPACE pg_default;

src/test/resources/edu/ie3/datamodel/io/sink/_sql/sql_test_data.sql

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)