From 116c6ea2536fd0bed6d75c45935ec61b64048140 Mon Sep 17 00:00:00 2001 From: Hylke van der Schaaf Date: Thu, 10 Oct 2024 08:44:11 +0200 Subject: [PATCH] Cleaned up names and unused parameters/fields --- .../persistence/pgjooq/ExpressionHandler.java | 8 ++------ ...ler.java => MariadbExpressionHandler.java} | 19 ++++++++----------- .../pgjooq/MariadbPersistenceManager.java | 10 +++++----- .../pgjooq/PgExpressionHandler.java | 7 +------ .../pgjooq/PostgresPersistenceManager.java | 8 ++++---- .../persistence/pgjooq/QueryBuilder.java | 7 ++----- 6 files changed, 22 insertions(+), 37 deletions(-) rename FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/{MariaDBExpressionHandler.java => MariadbExpressionHandler.java} (81%) diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/ExpressionHandler.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/ExpressionHandler.java index dc77aaa00..cc415a758 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/ExpressionHandler.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/ExpressionHandler.java @@ -71,15 +71,11 @@ import org.slf4j.LoggerFactory; /** - * Superclass for the specific implementations to form the database-dialect specific SQL-Queries. - * - * @author Tobias Hellmund (IOSB) + * Superclass for the specific implementations to form the database-dialect + * specific SQL-Queries. */ public abstract class ExpressionHandler implements ExpressionVisitor { - /** - * The logger for this class. - */ private static final Logger LOGGER = LoggerFactory.getLogger(ExpressionHandler.class); private final QueryBuilder queryBuilder; diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariaDBExpressionHandler.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbExpressionHandler.java similarity index 81% rename from FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariaDBExpressionHandler.java rename to FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbExpressionHandler.java index 44553657d..9e069003d 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariaDBExpressionHandler.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbExpressionHandler.java @@ -29,40 +29,37 @@ import org.geolatte.geom.Geometry; import org.geolatte.geom.codec.Wkt; import org.jooq.impl.DSL; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * @author Hylke van der Schaaf + * Handles translation of OData expressions to MariaDB expressions. */ -public class MariaDBExpressionHandler extends ExpressionHandler { +public class MariadbExpressionHandler extends ExpressionHandler { - private static final String ST_GeomFromText = "ST_GeomFromText(?)"; + private static final String ST_GEOMFROMTEXT = "ST_GeomFromText(?)"; - private static final Logger LOGGER = LoggerFactory.getLogger(MariaDBExpressionHandler.class); - - public MariaDBExpressionHandler(CoreSettings settings, QueryBuilder queryBuilder) { + public MariadbExpressionHandler(CoreSettings settings, QueryBuilder queryBuilder) { super(settings, queryBuilder); } @Override public FieldWrapper visit(LineStringConstant node) { Geometry geom = fromGeoJsonConstant(node); - return new SimpleFieldWrapper(DSL.field(ST_GeomFromText, PostGisGeometryBinding.dataType(), geom.asText())); + return new SimpleFieldWrapper(DSL.field(ST_GEOMFROMTEXT, PostGisGeometryBinding.dataType(), geom.asText())); } @Override public FieldWrapper visit(PointConstant node) { Geometry geom = fromGeoJsonConstant(node); - return new SimpleFieldWrapper(DSL.field(ST_GeomFromText, PostGisGeometryBinding.dataType(), geom.asText())); + return new SimpleFieldWrapper(DSL.field(ST_GEOMFROMTEXT, PostGisGeometryBinding.dataType(), geom.asText())); } @Override public FieldWrapper visit(PolygonConstant node) { Geometry geom = fromGeoJsonConstant(node); - return new SimpleFieldWrapper(DSL.field(ST_GeomFromText, PostGisGeometryBinding.dataType(), geom.asText())); + return new SimpleFieldWrapper(DSL.field(ST_GEOMFROMTEXT, PostGisGeometryBinding.dataType(), geom.asText())); } + @Override public Geometry fromGeoJsonConstant(GeoJsonConstant node) { if (node.getValue().getCrs() == null) { return Wkt.fromWkt(node.getSource()); diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java index b1865f158..c9f8aae0f 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/MariadbPersistenceManager.java @@ -256,7 +256,7 @@ public boolean validatePath(ResourcePath path) { if (idCount < 2) { return true; } - QueryBuilder psb = new QueryBuilder(this, settings, getTableCollection()); + QueryBuilder psb = new QueryBuilder(this); ResultQuery> query = psb .forPath(tempPath) .buildCount(); @@ -285,7 +285,7 @@ public Entity get(EntityType entityType, PkValue pk, Query query) { */ private Entity get(EntityType entityType, PkValue pk, boolean forUpdate, Query query) { init(); - QueryBuilder queryBuilder = new QueryBuilder(this, settings, getTableCollection()); + QueryBuilder queryBuilder = new QueryBuilder(this); ResultQuery sqlQuery = queryBuilder.forTypeAndId(entityType, pk) .usingQuery(query) .forUpdate(forUpdate) @@ -313,7 +313,7 @@ public Object get(ResourcePath path, Query query) { } } - QueryBuilder queryBuilder = new QueryBuilder(this, settings, getTableCollection()) + QueryBuilder queryBuilder = new QueryBuilder(this) .forPath(path) .usingQuery(query); @@ -444,7 +444,7 @@ public void doDelete(ResourcePath path, Query query) { init(); query.clearSelect(); query.addSelect(path.getMainElementType().getEntityProperty("id")); - QueryBuilder psb = new QueryBuilder(this, settings, getTableCollection()) + QueryBuilder psb = new QueryBuilder(this) .forPath(path) .usingQuery(query); @@ -862,7 +862,7 @@ public void generateLiquibaseVariables(Map target, String entity @Override public ExpressionHandler createExpressionHandler(QueryBuilder queryBuilder) { - return new MariaDBExpressionHandler(settings, queryBuilder); + return new MariadbExpressionHandler(settings, queryBuilder); } @Override diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PgExpressionHandler.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PgExpressionHandler.java index 9c4045f3b..b1450b38f 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PgExpressionHandler.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PgExpressionHandler.java @@ -29,19 +29,14 @@ import org.geolatte.geom.Geometry; import org.geolatte.geom.codec.Wkt; import org.jooq.impl.DSL; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** - * - * @author Hylke van der Schaaf + * Handles translation of OData expressions to PostgreSQL expressions. */ public class PgExpressionHandler extends ExpressionHandler { private static final String ST_GEOM_FROM_EWKT = "ST_GeomFromEWKT(?)"; - private static final Logger LOGGER = LoggerFactory.getLogger(PgExpressionHandler.class); - public PgExpressionHandler(CoreSettings settings, QueryBuilder queryBuilder) { super(settings, queryBuilder); } diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java index 71eaff407..3c9f5e663 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/PostgresPersistenceManager.java @@ -256,7 +256,7 @@ public boolean validatePath(ResourcePath path) { if (idCount < 2) { return true; } - QueryBuilder psb = new QueryBuilder(this, settings, getTableCollection()); + QueryBuilder psb = new QueryBuilder(this); ResultQuery> query = psb .forPath(tempPath) .buildCount(); @@ -285,7 +285,7 @@ public Entity get(EntityType entityType, PkValue pk, Query query) { */ private Entity get(EntityType entityType, PkValue pk, boolean forUpdate, Query query) { init(); - QueryBuilder queryBuilder = new QueryBuilder(this, settings, getTableCollection()); + QueryBuilder queryBuilder = new QueryBuilder(this); ResultQuery sqlQuery = queryBuilder.forTypeAndId(entityType, pk) .usingQuery(query) .forUpdate(forUpdate) @@ -313,7 +313,7 @@ public Object get(ResourcePath path, Query query) { } } - QueryBuilder queryBuilder = new QueryBuilder(this, settings, getTableCollection()) + QueryBuilder queryBuilder = new QueryBuilder(this) .forPath(path) .usingQuery(query); @@ -439,7 +439,7 @@ public void doDelete(ResourcePath path, Query query) { init(); query.clearSelect(); query.addSelect(path.getMainElementType().getEntityProperty("id")); - QueryBuilder psb = new QueryBuilder(this, settings, getTableCollection()) + QueryBuilder psb = new QueryBuilder(this) .forPath(path) .usingQuery(query); diff --git a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/QueryBuilder.java b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/QueryBuilder.java index 4a0825123..bbb5d66fa 100644 --- a/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/QueryBuilder.java +++ b/FROST-Server.SQLjooq/src/main/java/de/fraunhofer/iosb/ilt/frostserver/persistence/pgjooq/QueryBuilder.java @@ -40,7 +40,6 @@ import de.fraunhofer.iosb.ilt.frostserver.query.OrderBy; import de.fraunhofer.iosb.ilt.frostserver.query.Query; import de.fraunhofer.iosb.ilt.frostserver.query.expression.Expression; -import de.fraunhofer.iosb.ilt.frostserver.settings.CoreSettings; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -90,7 +89,6 @@ public class QueryBuilder implements ResourcePathVisitor { public static final String DEFAULT_PREFIX = QueryBuilder.ALIAS_PREFIX + "0"; private final JooqPersistenceManager pm; - private final CoreSettings coreSettings; private final TableCollection tableCollection; private Query staQuery; @@ -109,10 +107,9 @@ public class QueryBuilder implements ResourcePathVisitor { private QueryState queryState; - public QueryBuilder(JooqPersistenceManager pm, CoreSettings coreSettings, TableCollection tableCollection) { + public QueryBuilder(JooqPersistenceManager pm) { this.pm = pm; - this.coreSettings = coreSettings; - this.tableCollection = tableCollection; + this.tableCollection = pm.getTableCollection(); } public JooqPersistenceManager getPersistenceManager() {