From 3306decd7a97338aad19ffa153b83b1e8708726d Mon Sep 17 00:00:00 2001 From: gmantele <gmantele@ari.uni-heidelberg.de> Date: Wed, 22 Feb 2017 11:53:54 +0100 Subject: [PATCH] [ADQL] Follow-up to the previous commit on CENTROID: the automatic datatype detection was missing for CENTROID functions. -- Additionally, some JUnit test files of the `adql` package has been moved to the correct location. --- src/adql/query/ADQLQuery.java | 13 +++++++------ .../{ => query}/TestADQLObjectPosition.java | 2 +- test/adql/{ => query}/TestADQLQuery.java | 18 ++++++++---------- test/adql/{ => query}/TestIdentifierField.java | 2 +- test/adql/{ => query/constraint}/TestIN.java | 2 +- 5 files changed, 18 insertions(+), 19 deletions(-) rename test/adql/{ => query}/TestADQLObjectPosition.java (99%) rename test/adql/{ => query}/TestADQLQuery.java (95%) rename test/adql/{ => query}/TestIdentifierField.java (96%) rename test/adql/{ => query/constraint}/TestIN.java (99%) diff --git a/src/adql/query/ADQLQuery.java b/src/adql/query/ADQLQuery.java index 805b680..dd0a9b9 100644 --- a/src/adql/query/ADQLQuery.java +++ b/src/adql/query/ADQLQuery.java @@ -16,7 +16,7 @@ package adql.query; * You should have received a copy of the GNU Lesser General Public License * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2012-2016 - UDS/Centre de DonnĂ©es astronomiques de Strasbourg (CDS), + * Copyright 2012-2017 - UDS/Centre de DonnĂ©es astronomiques de Strasbourg (CDS), * Astronomisches Rechen Institut (ARI) */ @@ -35,6 +35,7 @@ import adql.query.operand.ADQLColumn; import adql.query.operand.ADQLOperand; import adql.query.operand.function.DefaultUDF; import adql.query.operand.function.geometry.BoxFunction; +import adql.query.operand.function.geometry.CentroidFunction; import adql.query.operand.function.geometry.CircleFunction; import adql.query.operand.function.geometry.PointFunction; import adql.query.operand.function.geometry.PolygonFunction; @@ -46,7 +47,7 @@ import adql.search.ISearchHandler; * <p>The resulting object of the {@link ADQLParser} is an object of this class.</p> * * @author Grégory Mantelet (CDS;ARI) - * @version 1.4 (03/2016) + * @version 1.4 (02/2017) */ public class ADQLQuery implements ADQLObject { @@ -321,7 +322,7 @@ public class ADQLQuery implements ADQLObject { }else{ // Create the DBColumn: DBColumn col = null; - // ...whose the name will be set with the SELECT item's alias: + // ...whose the name will be set with the SELECT item's alias: if (item.hasAlias()){ if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null){ col = ((ADQLColumn)operand).getDBLink(); @@ -333,11 +334,11 @@ public class ADQLQuery implements ADQLObject { else{ if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null) col = ((ADQLColumn)operand).getDBLink(); - if (col == null) + else col = new DefaultDBColumn(item.getName(), null); } - /* For columns created by default (from functions and operations generally), + /* For columns created by default (from functions and operations generally), * set the adequate type if known: */ // CASE: Well-defined UDF if (operand instanceof DefaultUDF && ((DefaultUDF)operand).getDefinition() != null){ @@ -345,7 +346,7 @@ public class ADQLQuery implements ADQLObject { ((DefaultDBColumn)col).setDatatype(type); } // CASE: Point type: - else if (operand instanceof PointFunction) + else if (operand instanceof PointFunction || operand instanceof CentroidFunction) ((DefaultDBColumn)col).setDatatype(new DBType(DBDatatype.POINT)); // CASE: Region type: else if (operand instanceof RegionFunction || operand instanceof CircleFunction || operand instanceof BoxFunction || operand instanceof PolygonFunction) diff --git a/test/adql/TestADQLObjectPosition.java b/test/adql/query/TestADQLObjectPosition.java similarity index 99% rename from test/adql/TestADQLObjectPosition.java rename to test/adql/query/TestADQLObjectPosition.java index 7c1b8d4..7a41bb2 100644 --- a/test/adql/TestADQLObjectPosition.java +++ b/test/adql/query/TestADQLObjectPosition.java @@ -1,4 +1,4 @@ -package adql; +package adql.query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; diff --git a/test/adql/TestADQLQuery.java b/test/adql/query/TestADQLQuery.java similarity index 95% rename from test/adql/TestADQLQuery.java rename to test/adql/query/TestADQLQuery.java index 1ea715b..272622e 100644 --- a/test/adql/TestADQLQuery.java +++ b/test/adql/query/TestADQLQuery.java @@ -1,4 +1,4 @@ -package adql; +package adql.query; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; @@ -14,13 +14,6 @@ import org.junit.Test; import adql.db.DBType; import adql.db.DBType.DBDatatype; import adql.db.FunctionDef; -import adql.query.ADQLObject; -import adql.query.ADQLOrder; -import adql.query.ADQLQuery; -import adql.query.ClauseADQL; -import adql.query.ClauseConstraints; -import adql.query.ClauseSelect; -import adql.query.SelectItem; import adql.query.constraint.Comparison; import adql.query.constraint.ComparisonOperator; import adql.query.constraint.ConstraintsGroup; @@ -39,7 +32,10 @@ import adql.query.operand.function.MathFunctionType; import adql.query.operand.function.SQLFunction; import adql.query.operand.function.SQLFunctionType; import adql.query.operand.function.geometry.BoxFunction; +import adql.query.operand.function.geometry.CentroidFunction; import adql.query.operand.function.geometry.CircleFunction; +import adql.query.operand.function.geometry.GeometryFunction; +import adql.query.operand.function.geometry.GeometryFunction.GeometryValue; import adql.query.operand.function.geometry.PointFunction; import adql.query.operand.function.geometry.PolygonFunction; import adql.query.operand.function.geometry.RegionFunction; @@ -195,8 +191,10 @@ public class TestADQLQuery { try{ select.clear(); select.add(new PointFunction(new StringConstant(""), new ADQLColumn("ra"), new ADQLColumn("dec"))); - assertEquals(1, query.getResultingColumns().length); - assertEquals(DBDatatype.POINT, query.getResultingColumns()[0].getDatatype().type); + select.add(new CentroidFunction(new GeometryValue<GeometryFunction>(new ADQLColumn("aRegion")))); + assertEquals(2, query.getResultingColumns().length); + for(int i = 0; i < 2; i++) + assertEquals(DBDatatype.POINT, query.getResultingColumns()[i].getDatatype().type); }catch(Exception ex){ ex.printStackTrace(); fail("The POINT function is well defined. This error should have occurred."); diff --git a/test/adql/TestIdentifierField.java b/test/adql/query/TestIdentifierField.java similarity index 96% rename from test/adql/TestIdentifierField.java rename to test/adql/query/TestIdentifierField.java index c4c5fc2..2885d10 100644 --- a/test/adql/TestIdentifierField.java +++ b/test/adql/query/TestIdentifierField.java @@ -1,4 +1,4 @@ -package adql; +package adql.query; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; diff --git a/test/adql/TestIN.java b/test/adql/query/constraint/TestIN.java similarity index 99% rename from test/adql/TestIN.java rename to test/adql/query/constraint/TestIN.java index d3ad2f2..ab385db 100644 --- a/test/adql/TestIN.java +++ b/test/adql/query/constraint/TestIN.java @@ -1,4 +1,4 @@ -package adql; +package adql.query.constraint; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -- GitLab