Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
import de.ii.xtraplatform.features.sql.domain.ImmutablePoolSettings;
import de.ii.xtraplatform.features.sql.domain.ImmutableQueryGeneratorSettings;
import de.ii.xtraplatform.features.sql.domain.ImmutableSqlPathDefaults;
import de.ii.xtraplatform.features.sql.domain.SqlClientBasicFactory;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand All @@ -53,6 +52,7 @@

@Singleton
@AutoBind
@SuppressWarnings("PMD.TooManyMethods")
public class FeatureProviderOracleFactory
extends AbstractEntityFactory<FeatureProviderDataV2, FeatureProviderOracle>
implements EntityFactory {
Expand All @@ -74,9 +74,15 @@ public FeatureProviderOracleFactory(
}

// for ldproxy-cfg
public FeatureProviderOracleFactory(SqlClientBasicFactory sqlClientBasicFactory) {
public FeatureProviderOracleFactory() {
super(null);
this.schemaResolvers = null;
this.schemaResolvers =
new Lazy<>() {
@Override
public Set<SchemaFragmentResolver> get() {
return Set.of();
}
};
this.skipHydration = true;
this.connectors = Set.of();
}
Expand Down Expand Up @@ -145,12 +151,12 @@ public Optional<AutoEntityFactory> auto() {

@Override
public EntityData hydrateData(EntityData entityData) {
FeatureProviderSqlData data = (FeatureProviderSqlData) entityData;

if (skipHydration) {
return entityData;
}

FeatureProviderSqlData data = (FeatureProviderSqlData) entityData;

try {
List<TypesResolver> resolvers =
List.of(
Expand Down Expand Up @@ -190,7 +196,8 @@ private FeatureProviderSqlData applyTypesResolver(

while (resolver.needsResolving(types)) {
types = resolver.resolve(types);
if (++rounds >= resolver.maxRounds()) {
rounds++;
if (rounds >= resolver.maxRounds()) {
resolver.maxRoundsWarning().ifPresent(LOGGER::warn);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
import de.ii.xtraplatform.features.sql.domain.SqlDialect;
import java.lang.module.Configuration;
import java.lang.module.ModuleFinder;
import java.nio.file.Path;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.Collator;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -90,13 +87,13 @@ public DataSource createDataSource(String providerId, ConnectionInfoSql connecti
.invoke(ds, String.format(applicationName, providerId));
oracleDataSource.getDeclaredMethod("setDriverType", String.class).invoke(ds, "thin");

if (host.contains(":")) {
if (host.indexOf(':') >= 0) {
oracleDataSource
.getDeclaredMethod("setServerName", String.class)
.invoke(ds, host.substring(0, host.indexOf(":")));
.invoke(ds, host.substring(0, host.indexOf(':')));
oracleDataSource
.getDeclaredMethod("setPortNumber", int.class)
.invoke(ds, Integer.parseInt(host.substring(host.lastIndexOf(":") + 1)));
.invoke(ds, Integer.parseInt(host.substring(host.lastIndexOf(':') + 1)));
} else {
oracleDataSource.getDeclaredMethod("setServerName", String.class).invoke(ds, host);
}
Expand All @@ -111,7 +108,8 @@ public DataSource createDataSource(String providerId, ConnectionInfoSql connecti

private Class<?> loadDriver() {
try {
Path driverPath = driverStore.asLocalPath(Path.of(""), false).get();
java.nio.file.Path driverPath =
driverStore.asLocalPath(java.nio.file.Path.of(""), false).get();
ModuleFinder finder = ModuleFinder.of(driverPath);
ModuleLayer parent = ModuleLayer.boot();
Configuration cf =
Expand Down Expand Up @@ -150,12 +148,13 @@ public List<String> getSystemTables() {
}

@Override
public Map<String, GeoInfo> getGeoInfo(Connection connection, DbInfo dbInfo) throws SQLException {
public Map<String, GeoInfo> getGeoInfo(java.sql.Connection connection, DbInfo dbInfo)
throws java.sql.SQLException {
return Map.of();
}

@Override
public DbInfo getDbInfo(Connection connection) throws SQLException {
public DbInfo getDbInfo(java.sql.Connection connection) throws java.sql.SQLException {
return new DbInfo() {};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import de.ii.xtraplatform.crs.domain.BoundingBox;
import de.ii.xtraplatform.crs.domain.EpsgCrs;
import de.ii.xtraplatform.features.domain.Tuple;
import de.ii.xtraplatform.features.sql.domain.FeatureProviderSqlData.QueryGeneratorSettings;
import de.ii.xtraplatform.features.sql.domain.SchemaSql.PropertyTypeInfo;
import de.ii.xtraplatform.features.sql.domain.SqlDialect;
import java.time.Instant;
Expand All @@ -31,16 +30,27 @@
// - only 2D geometries are supported / have been tested
// - S_CROSSES not supported
// - identifiers must be unquoted, that is, in uppercase in Oracle
@SuppressWarnings("PMD.TooManyMethods")
public class SqlDialectOras implements SqlDialect {

private static final Splitter BBOX_SPLITTER =
Splitter.onPattern("[(), ]").omitEmptyStrings().trimResults();

private QueryGeneratorSettings settings;
private final Map<SpatialFunction, Tuple<String, Optional<String>>> spatialOperators =
new ImmutableMap.Builder<SpatialFunction, Tuple<String, Optional<String>>>()
.put(SpatialFunction.S_EQUALS, Tuple.of("SDO_EQUAL", Optional.empty()))
.put(SpatialFunction.S_DISJOINT, Tuple.of("SDO_RELATE", Optional.of("DISJOINT")))
.put(SpatialFunction.S_TOUCHES, Tuple.of("SDO_TOUCH", Optional.empty()))
.put(SpatialFunction.S_WITHIN, Tuple.of("SDO_INSIDE", Optional.empty()))
.put(SpatialFunction.S_OVERLAPS, Tuple.of("SDO_OVERLAPS", Optional.empty()))
// S_CROSSES is not supported
.put(SpatialFunction.S_INTERSECTS, Tuple.of("SDO_ANYINTERACT", Optional.empty()))
.put(SpatialFunction.S_CONTAINS, Tuple.of("SDO_CONTAINS", Optional.empty()))
.build();

@Override
public String applyToWkt(String column, boolean forcePolygonCCW, boolean linearizeCurves) {
StringBuilder queryBuilder = new StringBuilder("SDO_UTIL.TO_WKTGEOMETRY(");
StringBuilder queryBuilder = new StringBuilder(128).append("SDO_UTIL.TO_WKTGEOMETRY(");
if (linearizeCurves) {
queryBuilder.append("SDO_GEOM.SDO_ARC_DENSIFY(");
}
Expand All @@ -54,7 +64,7 @@ public String applyToWkt(String column, boolean forcePolygonCCW, boolean lineari
if (linearizeCurves) {
queryBuilder.append(",0.001,'arc_tolerance=0.1')");
}
return queryBuilder.append(")").toString();
return queryBuilder.append(')').toString();
}

@Override
Expand All @@ -64,7 +74,7 @@ public String applyToWkt(String wkt, int srid) {

@Override
public String applyToWkb(String column, boolean forcePolygonCCW, boolean linearizeCurves) {
StringBuilder queryBuilder = new StringBuilder("SDO_UTIL.TO_WKBGEOMETRY(");
StringBuilder queryBuilder = new StringBuilder(128).append("SDO_UTIL.TO_WKBGEOMETRY(");
if (linearizeCurves) {
queryBuilder.append("SDO_GEOM.SDO_ARC_DENSIFY(");
}
Expand All @@ -78,7 +88,7 @@ public String applyToWkb(String column, boolean forcePolygonCCW, boolean lineari
if (linearizeCurves) {
queryBuilder.append(",0.001,'arc_tolerance=0.1')");
}
return queryBuilder.append(")").toString();
return queryBuilder.append(')').toString();
}

@Override
Expand Down Expand Up @@ -225,7 +235,7 @@ public Tuple<String, Optional<String>> getSpatialOperator(
throw new IllegalArgumentException(
"3D spatial operators are not supported for Oracle feature providers.");
}
Tuple<String, Optional<String>> op = SPATIAL_OPERATORS.get(spatialFunction);
Tuple<String, Optional<String>> op = spatialOperators.get(spatialFunction);
if (Objects.isNull(op)) {
throw new IllegalArgumentException(
String.format(
Expand All @@ -235,18 +245,6 @@ public Tuple<String, Optional<String>> getSpatialOperator(
return op;
}

private final Map<SpatialFunction, Tuple<String, Optional<String>>> SPATIAL_OPERATORS =
new ImmutableMap.Builder<SpatialFunction, Tuple<String, Optional<String>>>()
.put(SpatialFunction.S_EQUALS, Tuple.of("SDO_EQUAL", Optional.empty()))
.put(SpatialFunction.S_DISJOINT, Tuple.of("SDO_RELATE", Optional.of("DISJOINT")))
.put(SpatialFunction.S_TOUCHES, Tuple.of("SDO_TOUCH", Optional.empty()))
.put(SpatialFunction.S_WITHIN, Tuple.of("SDO_INSIDE", Optional.empty()))
.put(SpatialFunction.S_OVERLAPS, Tuple.of("SDO_OVERLAPS", Optional.empty()))
// S_CROSSES is not supported
.put(SpatialFunction.S_INTERSECTS, Tuple.of("SDO_ANYINTERACT", Optional.empty()))
.put(SpatialFunction.S_CONTAINS, Tuple.of("SDO_CONTAINS", Optional.empty()))
.build();

@Override
public String getSpatialOperatorMatch(SpatialFunction spatialFunction) {
return " = 'TRUE'";
Expand Down
Loading