Skip to content

Commit

Permalink
Cleaned up names and unused parameters/fields
Browse files Browse the repository at this point in the history
  • Loading branch information
hylkevds committed Oct 10, 2024
1 parent f368e90 commit 116c6ea
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<FieldWrapper> {

/**
* The logger for this class.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(ExpressionHandler.class);

private final QueryBuilder queryBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<? extends GeoJsonObject> node) {
if (node.getValue().getCrs() == null) {
return Wkt.fromWkt(node.getSource());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record1<Integer>> query = psb
.forPath(tempPath)
.buildCount();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -862,7 +862,7 @@ public void generateLiquibaseVariables(Map<String, Object> target, String entity

@Override
public ExpressionHandler createExpressionHandler(QueryBuilder queryBuilder) {
return new MariaDBExpressionHandler(settings, queryBuilder);
return new MariadbExpressionHandler(settings, queryBuilder);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Record1<Integer>> query = psb
.forPath(tempPath)
.buildCount();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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() {
Expand Down

0 comments on commit 116c6ea

Please sign in to comment.