HHH-10211 - Checkstyle fixes

This commit is contained in:
Karel Maesen 2016-11-01 16:58:25 +01:00
parent 70d55987f8
commit 55ed5faa3b
18 changed files with 103 additions and 74 deletions

View File

@ -16,6 +16,7 @@ import org.hibernate.spatial.SpatialDialect;
import org.hibernate.spatial.SpatialFunction; import org.hibernate.spatial.SpatialFunction;
/** /**
*
* Created by Karel Maesen, Geovise BVBA on 01/11/16. * Created by Karel Maesen, Geovise BVBA on 01/11/16.
*/ */
public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect { public class PostgisPG9Dialect extends PostgreSQL9Dialect implements SpatialDialect {

View File

@ -1,3 +1,9 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.spatial.dialect.oracle; package org.hibernate.spatial.dialect.oracle;
import java.sql.Connection; import java.sql.Connection;
@ -12,6 +18,7 @@ public class TestConnectionFinder implements ConnectionFinder {
final private ConnectionFinder internal = new DefaultConnectionFinder(); final private ConnectionFinder internal = new DefaultConnectionFinder();
/** /**
* Find an instance of Connection that can be cast to an {@code OracleConnection} instance. * Find an instance of Connection that can be cast to an {@code OracleConnection} instance.
* *

View File

@ -1,3 +1,9 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.spatial.dialect.postgis; package org.hibernate.spatial.dialect.postgis;
import java.sql.SQLException; import java.sql.SQLException;

View File

@ -13,8 +13,6 @@ import java.util.Map;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.junit.Test;
import org.hibernate.Criteria; import org.hibernate.Criteria;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -25,6 +23,9 @@ import org.hibernate.spatial.criterion.SpatialRestrictions;
import org.hibernate.spatial.integration.jts.GeomEntity; import org.hibernate.spatial.integration.jts.GeomEntity;
import org.hibernate.spatial.testing.SpatialDialectMatcher; import org.hibernate.spatial.testing.SpatialDialectMatcher;
import org.hibernate.spatial.testing.SpatialFunctionalTestCase; import org.hibernate.spatial.testing.SpatialFunctionalTestCase;
import org.junit.Test;
import org.hibernate.testing.Skip; import org.hibernate.testing.Skip;
import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertEquals;

View File

@ -92,5 +92,3 @@ public class GeomEntity {
} }
} }

View File

@ -15,16 +15,16 @@ import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.hibernate.spatial.HSMessageLogger;
import org.jboss.logging.Logger;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Point;
import com.vividsolutions.jts.geom.Polygon; import com.vividsolutions.jts.geom.Polygon;
import com.vividsolutions.jts.io.ParseException; import com.vividsolutions.jts.io.ParseException;
import com.vividsolutions.jts.io.WKTReader; import com.vividsolutions.jts.io.WKTReader;
import org.jboss.logging.Logger;
import org.hibernate.spatial.HSMessageLogger;
/** /**
* An <code>AbstractExpectationsFactory</code> provides the expected * An <code>AbstractExpectationsFactory</code> provides the expected
* values to be used in the integration tests of the spatial functions * values to be used in the integration tests of the spatial functions
@ -825,17 +825,23 @@ public abstract class AbstractExpectationsFactory {
if ( results != null ) { if ( results != null ) {
try { try {
results.close(); results.close();
}catch(SQLException e) {} }
catch (SQLException e) {
}
} }
if ( preparedStatement != null ) { if ( preparedStatement != null ) {
try { try {
preparedStatement.close(); preparedStatement.close();
}catch(SQLException e) {} }
catch (SQLException e) {
}
} }
if ( cn != null ) { if ( cn != null ) {
try { try {
cn.close(); cn.close();
}catch(SQLException e){} }
catch (SQLException e) {
}
} }
} }
} }

View File

@ -16,8 +16,9 @@ import com.vividsolutions.jts.geom.GeometryCollection;
* <p/> * <p/>
* The notion of geometric equality can differ slightly between * The notion of geometric equality can differ slightly between
* spatial databases. * spatial databases.
*
* @deprecated Should be replaced by Geolatte-geom GeometryEquality
*/ */
//TODO -- replace by Geolatte-geom
@Deprecated @Deprecated
public class GeometryEquality { public class GeometryEquality {
@ -32,7 +33,9 @@ public class GeometryEquality {
if ( geom1.isEmpty() ) { if ( geom1.isEmpty() ) {
return geom2.isEmpty(); return geom2.isEmpty();
} }
if (!ignoreSRID && !equalSRID(geom1, geom2)) return false; if ( !ignoreSRID && !equalSRID( geom1, geom2 ) ) {
return false;
}
if ( geom1 instanceof GeometryCollection ) { if ( geom1 instanceof GeometryCollection ) {
if ( !(geom2 instanceof GeometryCollection) ) { if ( !(geom2 instanceof GeometryCollection) ) {
@ -59,6 +62,7 @@ public class GeometryEquality {
* *
* @param geom1 * @param geom1
* @param geom2 * @param geom2
*
* @return * @return
*/ */
private boolean equalSRID(Geometry geom1, Geometry geom2) { private boolean equalSRID(Geometry geom1, Geometry geom2) {
@ -118,4 +122,3 @@ public class GeometryEquality {
return c1.x == c2.x && c1.y == c2.y; return c1.x == c2.x && c1.y == c2.y;
} }
} }

View File

@ -212,7 +212,8 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
if ( expected instanceof byte[] ) { if ( expected instanceof byte[] ) {
assertArrayEquals( "Failure on testsuite-suite for case " + id, (byte[]) expected, (byte[]) received ); assertArrayEquals( "Failure on testsuite-suite for case " + id, (byte[]) expected, (byte[]) received );
} else if ( expected instanceof Geometry ) { }
else if ( expected instanceof Geometry ) {
if ( JTS.equals( geometryType ) ) { if ( JTS.equals( geometryType ) ) {
if ( !(received instanceof Geometry) ) { if ( !(received instanceof Geometry) ) {
fail( fail(
@ -224,7 +225,8 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
"Failure on testsuite-suite for case " + id, "Failure on testsuite-suite for case " + id,
geometryEquality.test( (Geometry) expected, (Geometry) received ) geometryEquality.test( (Geometry) expected, (Geometry) received )
); );
} else { }
else {
if ( !(received instanceof org.geolatte.geom.Geometry) ) { if ( !(received instanceof org.geolatte.geom.Geometry) ) {
fail( fail(
"Expected a Geolatte Geometry, but received an object of type " + received.getClass() "Expected a Geolatte Geometry, but received an object of type " + received.getClass()
@ -233,7 +235,10 @@ public abstract class SpatialFunctionalTestCase extends BaseCoreFunctionalTestCa
} }
assertTrue( assertTrue(
"Failure on testsuite-suite for case " + id, "Failure on testsuite-suite for case " + id,
geometryEquality.test( (Geometry) expected, (Geometry) org.geolatte.geom.jts.JTS.to((org.geolatte.geom.Geometry)received) ) geometryEquality.test(
(Geometry) expected,
(Geometry) org.geolatte.geom.jts.JTS.to( (org.geolatte.geom.Geometry) received )
)
); );
} }

View File

@ -26,4 +26,3 @@ public class TestDataElement {
} }
} }

View File

@ -9,8 +9,8 @@ package org.hibernate.spatial.testing;
import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.AvailableSettings;
import org.hibernate.engine.config.spi.ConfigurationService; import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;

View File

@ -79,4 +79,3 @@ public class TestSupportFactories {
} }
} }

View File

@ -28,7 +28,8 @@ public class WktUtility {
String[] tokens = wkt.split( ";" ); String[] tokens = wkt.split( ";" );
if ( tokens.length > 1 ) { if ( tokens.length > 1 ) {
return tokens[1]; return tokens[1];
} else { }
else {
return wkt; return wkt;
} }

View File

@ -277,14 +277,16 @@ public class GeoDBExpectationsFactory extends AbstractExpectationsFactory {
*/ */
@Override @Override
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, protected NativeSQLStatement createNativeRelateStatement(
Geometry geom,
String matrix) { String matrix) {
String sql = "select t.id, ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "' ) from GEOMTEST t where ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "') = 'true' and ST_SRID(t.geom) = 4326"; String sql = "select t.id, ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "' ) from GEOMTEST t where ST_Relate(t.geom, ST_GeomFromText(?, 4326), '" + matrix + "') = 'true' and ST_SRID(t.geom) = 4326";
return createNativeSQLStatementAllWKTParams( sql, geom.toText() ); return createNativeSQLStatementAllWKTParams( sql, geom.toText() );
} }
@Override @Override
protected NativeSQLStatement createNativeDwithinStatement(Point geom, protected NativeSQLStatement createNativeDwithinStatement(
Point geom,
double distance) { double distance) {
String sql = "select t.id, ST_DWithin(t.geom, ST_GeomFromText(?, 4326), " String sql = "select t.id, ST_DWithin(t.geom, ST_GeomFromText(?, 4326), "
+ distance + distance

View File

@ -20,8 +20,9 @@ import org.hibernate.spatial.testing.GeometryEquality;
* Geometry objects, which cannot be cast to {@link org.hibernate.spatial.jts.mgeom.MGeometry} objects. * Geometry objects, which cannot be cast to {@link org.hibernate.spatial.jts.mgeom.MGeometry} objects.
* *
* @author Jan Boonen, Geodan IT b.v. * @author Jan Boonen, Geodan IT b.v.
* @deprecated This should no longer be necesseary
*/ */
@Deprecated //NO LONGER REQUIRED @Deprecated
public class GeoDBGeometryEquality extends GeometryEquality { public class GeoDBGeometryEquality extends GeometryEquality {
@Override @Override

View File

@ -10,23 +10,24 @@
*/ */
package org.hibernate.spatial.testing.dialects.h2geodb; package org.hibernate.spatial.testing.dialects.h2geodb;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.NativeSQLStatement;
import com.vividsolutions.jts.geom.Geometry; import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.geom.Point; import com.vividsolutions.jts.geom.Point;
import org.geolatte.geom.ByteBuffer; import org.geolatte.geom.ByteBuffer;
import org.geolatte.geom.codec.Wkb; import org.geolatte.geom.codec.Wkb;
import org.geolatte.geom.jts.JTS; import org.geolatte.geom.jts.JTS;
import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.NativeSQLStatement;
/** /**
* A Factory class that generates expected {@link org.hibernate.spatial.testing.NativeSQLStatement}s for GeoDB * A Factory class that generates expected {@link org.hibernate.spatial.testing.NativeSQLStatement}s for GeoDB
* version < 0.4. These versions don't support storage of the SRID value with * version < 0.4. These versions don't support storage of the SRID value with
* the geometry. * the geometry.
* *
* @author Jan Boonen, Geodan IT b.v. * @author Jan Boonen, Geodan IT b.v.
* @deprecated No longer used
*/ */
@Deprecated //Class no longer used. Remove. @Deprecated
public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory { public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory {
public GeoDBNoSRIDExpectationsFactory(GeoDBDataSourceUtils dataSourceUtils) { public GeoDBNoSRIDExpectationsFactory(GeoDBDataSourceUtils dataSourceUtils) {
@ -192,7 +193,8 @@ public class GeoDBNoSRIDExpectationsFactory extends AbstractExpectationsFactory
} }
@Override @Override
protected NativeSQLStatement createNativeRelateStatement(Geometry geom, protected NativeSQLStatement createNativeRelateStatement(
Geometry geom,
String matrix) { String matrix) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"Method ST_Relate() is not implemented in the current version of GeoDB." "Method ST_Relate() is not implemented in the current version of GeoDB."

View File

@ -10,8 +10,6 @@ package org.hibernate.spatial.testing.dialects.h2geodb;
import java.io.IOException; import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.spatial.testing.AbstractExpectationsFactory; import org.hibernate.spatial.testing.AbstractExpectationsFactory;
import org.hibernate.spatial.testing.DataSourceUtils; import org.hibernate.spatial.testing.DataSourceUtils;
@ -19,6 +17,7 @@ import org.hibernate.spatial.testing.GeometryEquality;
import org.hibernate.spatial.testing.SQLExpressionTemplate; import org.hibernate.spatial.testing.SQLExpressionTemplate;
import org.hibernate.spatial.testing.TestData; import org.hibernate.spatial.testing.TestData;
import org.hibernate.spatial.testing.TestSupport; import org.hibernate.spatial.testing.TestSupport;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
/** /**
@ -51,7 +50,8 @@ public class GeoDBTestSupport extends TestSupport {
public AbstractExpectationsFactory createExpectationsFactory(DataSourceUtils dataSourceUtils) { public AbstractExpectationsFactory createExpectationsFactory(DataSourceUtils dataSourceUtils) {
if ( dataSourceUtils instanceof GeoDBDataSourceUtils ) { if ( dataSourceUtils instanceof GeoDBDataSourceUtils ) {
return new GeoDBExpectationsFactory( (GeoDBDataSourceUtils) dataSourceUtils ); return new GeoDBExpectationsFactory( (GeoDBDataSourceUtils) dataSourceUtils );
} else { }
else {
throw new IllegalArgumentException( "Requires a GeoDBDataSourceUtils instance" ); throw new IllegalArgumentException( "Requires a GeoDBDataSourceUtils instance" );
} }
} }
@ -60,6 +60,4 @@ public class GeoDBTestSupport extends TestSupport {
return new GeoDBExpressionTemplate(); return new GeoDBExpressionTemplate();
} }
} }