Skip to content

Commit

Permalink
PsqlStorageTest tests implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Pawel Mazurek authored and Pawel Mazurek committed Nov 16, 2023
1 parent d95b488 commit 51b4b15
Show file tree
Hide file tree
Showing 4 changed files with 270 additions and 29 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ val gt_referencing = "org.geotools:gt-referencing:19.1"
val gt_epsg_hsql = "org.geotools:gt-epsg-hsql:19.1"
val gt_epsg_extension = "org.geotools:gt-epsg-extension:19.1"

val spatial4j = "com.spatial4j:spatial4j:0.5"

val slf4j_api = "org.slf4j:slf4j-api:2.0.6"
val slf4j_console = "org.slf4j:slf4j-simple:2.0.6";

Expand Down Expand Up @@ -286,6 +288,7 @@ project(":here-naksha-lib-psql") {
implementation(vividsolutions_jts_core)

testImplementation(mockito)
testImplementation(spatial4j)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ public ReadFeatures(@Nullable List<@NotNull String> collections) {
@AvailableSince(NakshaVersion.v2_0_7)
private boolean returnDeleted;

@AvailableSince(NakshaVersion.v2_0_7)
public @NotNull ReadFeatures withReturnDeleted(boolean returnDeleted) {
this.returnDeleted = returnDeleted;
return this;
}

@AvailableSince(NakshaVersion.v2_0_7)
private boolean returnAllVersions;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,7 @@
import com.here.naksha.lib.core.NakshaContext;
import com.here.naksha.lib.core.exceptions.StorageLockException;
import com.here.naksha.lib.core.models.XyzError;
import com.here.naksha.lib.core.models.storage.ErrorResult;
import com.here.naksha.lib.core.models.storage.Notification;
import com.here.naksha.lib.core.models.storage.ReadFeatures;
import com.here.naksha.lib.core.models.storage.ReadRequest;
import com.here.naksha.lib.core.models.storage.Result;
import com.here.naksha.lib.core.models.storage.WriteCollections;
import com.here.naksha.lib.core.models.storage.WriteFeatures;
import com.here.naksha.lib.core.models.storage.WriteOp;
import com.here.naksha.lib.core.models.storage.WriteRequest;
import com.here.naksha.lib.core.models.storage.*;
import com.here.naksha.lib.core.storage.IStorageLock;
import com.here.naksha.lib.core.util.CloseableResource;
import com.here.naksha.lib.core.util.json.Json;
Expand Down Expand Up @@ -186,7 +178,24 @@ Result process(@NotNull Notification<?> notification) {
Result executeRead(@NotNull ReadRequest<?> readRequest) {
if (readRequest instanceof final ReadFeatures readFeatures) {
final List<@NotNull String> collections = readFeatures.getCollections();
final SQL sql = sql();
// TODO read multiple collections
final PreparedStatement stmt = prepare(sql().add(
"SELECT jsondata->'properties'->'@ns:com:here:xyz'->>'action', jsondata->>'id', jsondata->'properties'->'@ns:com:here:xyz'->>'uuid', jsondata->>'type', 'TODO' as r_ptype, jsondata::jsonb, ST_AsEWKB(geo)")
.add(" FROM ")
.addIdent(collections.get(0))
.add(" WHERE jsondata->>'id' = ?;"));
try {
// TODO create dynamic where section
stmt.setString(1, readFeatures.getPropertyOp().value().toString());
return new PsqlSuccess(new PsqlCursor<>(this, stmt, stmt.executeQuery()));
} catch (SQLException e) {
try {
stmt.close();
} catch (Throwable ce) {
log.info("Failed to close statement", ce);
}
throw unchecked(e);
}
}
return new ErrorResult(XyzError.NOT_IMPLEMENTED, "executeRead");
}
Expand Down
Loading

0 comments on commit 51b4b15

Please sign in to comment.