Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQLFeatureStore: Fix filtering on gml:identifier in BLOB mode #682

Closed
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 @@ -1207,7 +1207,7 @@ private FeatureInputStream queryByOperatorFilterBlob( Query query, QName ftName,
sql.append( "." );
sql.append( blobMapping.getTypeColumn() );
sql.append( "=?" );
if ( wb != null ) {
if ( wb != null && wb.getWhere() != null ) {
sql.append( " AND " );
sql.append( wb.getWhere().getSQL() );
}
Expand All @@ -1233,7 +1233,7 @@ private FeatureInputStream queryByOperatorFilterBlob( Query query, QName ftName,
int i = 1;
// if ( blobMapping != null ) {
stmt.setShort( i++, getSchema().getFtId( ftName ) );
if ( wb != null ) {
if ( wb != null && wb.getWhere() != null ) {
for ( SQLArgument o : wb.getWhere().getArguments() ) {
o.setArgument( stmt, i++ );
}
Expand Down Expand Up @@ -1477,6 +1477,12 @@ private AbstractWhereBuilder getWhereBuilderBlob( OperatorFilter filter, Connect
@Override
public PropertyNameMapping getMapping( ValueReference propName, TableAliasManager aliasManager )
throws FilterEvaluationException, UnmappableException {
return null;
}

@Override
public PropertyNameMapping getSpatialMapping( ValueReference propName, TableAliasManager aliasManager )
throws FilterEvaluationException, UnmappableException {
GeometryStorageParams geometryParams = new GeometryStorageParams( blobMapping.getCRS(), undefinedSrid,
CoordinateDimension.DIM_2 );
GeometryMapping bboxMapping = new GeometryMapping( null, false,
Expand All @@ -1485,12 +1491,6 @@ public PropertyNameMapping getMapping( ValueReference propName, TableAliasManage
return new PropertyNameMapping( getGeometryConverter( bboxMapping ), null, blobMapping.getBBoxColumn(),
aliasManager.getRootTableAlias() );
}

@Override
public PropertyNameMapping getSpatialMapping( ValueReference propName, TableAliasManager aliasManager )
throws FilterEvaluationException, UnmappableException {
return getMapping( propName, aliasManager );
}
};
return dialect.getWhereBuilder( mapper, filter, null, allowInMemoryFiltering );
}
Expand Down
71 changes: 71 additions & 0 deletions deegree-tests/deegree-featurestore-sql-tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>deegree-featurestore-sql-tests</artifactId>
<packaging>jar</packaging>
<name>deegree-featurestore-sql-tests</name>
<description>Basic tests that start up deegree example workspaces</description>

<parent>
<groupId>org.deegree</groupId>
<artifactId>deegree-tests</artifactId>
<version>3.4-RC2-SNAPSHOT</version>
</parent>

<repositories>
<repository>
<id>deegree-repo</id>
<url>http://repo.deegree.org/content/groups/public</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
<includes>
<include>**/*IT.java</include>
</includes>
<argLine>-Xmx1024m -Xss128m -XX:-UseGCOverheadLimit -Xincgc -Djava.awt.headless=true</argLine>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.deegree</groupId>
<artifactId>deegree-featurestore-sql</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>xmlunit</groupId>
<artifactId>xmlunit</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
<display-name>deegree 3 OGC services console + generic client</display-name>

<filter>
<filter-name>Upload Filter</filter-name>
<filter-class>org.deegree.client.core.filter.InputFileFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Upload Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
<servlet-name>services</servlet-name>
<servlet-class>org.deegree.services.controller.OGCFrontController</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>resources</servlet-name>
<servlet-class>org.deegree.services.resources.ResourcesServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet>
<servlet-name>config</servlet-name>
<servlet-class>org.deegree.services.config.servlet.ConfigServlet</servlet-class>
<load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>/services</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>services</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>resources</servlet-name>
<url-pattern>/resources/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>config</servlet-name>
<url-pattern>/config/*</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>

<security-constraint>
<web-resource-collection>
<web-resource-name>Configuration</web-resource-name>
<url-pattern>/config/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>deegree</role-name>
</auth-constraint>
</security-constraint>

<login-config>
<auth-method>BASIC</auth-method>
<realm-name>deegree web configuration API</realm-name>
</login-config>

<security-role>
<description>deegree administrator role</description>
<role-name>deegree</role-name>
</security-role>


<!-- http basic auth enable -->
<!-- Define a security constraint on this application -->
<!-- User and role must be added to tomcat-users.xml -->
<!-- <security-constraint> <web-resource-collection> <web-resource-name>Entire Application</web-resource-name> <url-pattern>/*</url-pattern>
</web-resource-collection> <auth-constraint> <role-name>demoadmin</role-name> </auth-constraint> </security-constraint> <login-config>
<auth-method>BASIC</auth-method> <realm-name>Tomcat Manager Application</realm-name> </login-config> <security-role> <description>The
role that is required to log in to the Manager Application</description> <role-name>demoadmin</role-name> </security-role> -->
<!-- end -->

<!-- error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error.xhtml</location>
</error-page-->

</web-app>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
deegree
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.deegree.feature.persistence.sql;

import static org.deegree.commons.utils.JDBCUtils.close;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
* Methods tor creating and dropping PostGIS test databases.
*
* @author <a href="mailto:schneider@occamlabs.de">Markus Schneider</a>
*
* @since 3.4
*/
public class PostGISSetupHelper {

final static String TEST_DB = "deegree-test";

final static String ADMIN_USER = "postgres";

final static String ADMIN_PASS = "postgres";

final static String ADMIN_DB = "postgres";

final static String HOST = "localhost";

final static String PORT = "5432";

/**
* Creates a new PostgreSQL test database with PostGIS extension.
*/
static void createTestDatabase()
throws SQLException {
dropTestDatabase();
createPostgresDb( ADMIN_USER, ADMIN_PASS, HOST, PORT, ADMIN_DB, TEST_DB );
addPostgisExtension( ADMIN_USER, ADMIN_PASS, HOST, PORT, TEST_DB );
}

/**
* Drops the PostgreSQL test database.
*/
static void dropTestDatabase()
throws SQLException {
final Connection adminConn = getConnection( ADMIN_USER, ADMIN_PASS, HOST, PORT, ADMIN_DB );
Statement stmt = null;
try {
stmt = adminConn.createStatement();
stmt.execute( "DROP DATABASE IF EXISTS \"" + TEST_DB + "\"" );
} finally {
close( null, stmt, adminConn, null );
}
}

private static void createPostgresDb( final String user, final String pass, final String host, final String port,
final String adminDb, final String newDb )
throws SQLException {
final Connection adminConn = getConnection( user, pass, host, port, adminDb );
Statement stmt = null;
try {
stmt = adminConn.createStatement();
stmt.execute( "CREATE DATABASE \"" + newDb + "\"" );
} finally {
close( null, stmt, adminConn, null );
}
}

private static void addPostgisExtension( final String user, final String pass, final String host,
final String port, final String db )
throws SQLException {
final Connection adminConn = getConnection( user, pass, host, port, db );
Statement stmt = null;
try {
stmt = adminConn.createStatement();
stmt.execute( "CREATE EXTENSION postgis" );
} finally {
close( null, stmt, adminConn, null );
}
}

private static Connection getConnection( final String user, final String pass, final String host,
final String port, final String dbName )
throws SQLException {
final String url = "jdbc:postgresql://" + host + ":" + port + "/" + dbName;
return DriverManager.getConnection( url, user, pass );
}

}
Loading