Skip to content
Snippets Groups Projects
Commit 763168d2 authored by gmantele's avatar gmantele Committed by GitHub
Browse files

[ADQL,Build] Merge pull request #20 from vforchi/master

New build system (Gradle) and fixes in SQLServer translator (atan2 function, order of TOP and DISTINCT).
parents 704877d2 3952a24a
No related branches found
No related tags found
No related merge requests found
...@@ -85,3 +85,7 @@ All of these ANT scripts have the following main targets: ...@@ -85,3 +85,7 @@ All of these ANT scripts have the following main targets:
* `buildLibAndSrc`: same as `buildLib` + building of a JAR file containing all the sources and the required libraries. * `buildLibAndSrc`: same as `buildLib` + building of a JAR file containing all the sources and the required libraries.
* `buildJavadoc`: generate a JAR containing the Javadoc of the target library's classes. * `buildJavadoc`: generate a JAR containing the Javadoc of the target library's classes.
* `buildAll`: equivalent of `buildLibAndSrc` and `buildJavadoc` together. The result is 3 JARs: one with the compiled classes, one with the corresponding sources and the last one with the Javadoc. * `buildAll`: equivalent of `buildLibAndSrc` and `buildJavadoc` together. The result is 3 JARs: one with the compiled classes, one with the corresponding sources and the last one with the Javadoc.
### Gradle build
The code can be built with Gradle, either as a jar file to be included in other projects
or as a war file to be deployed in Tomcat.
apply plugin: 'java'
apply plugin: 'war'
repositories {
jcenter()
mavenCentral()
mavenLocal()
}
dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
compile 'javax.servlet:javax.servlet-api:3.0.1'
compile 'postgresql:postgresql:9.1-901.jdbc4'
testCompile 'simple-jndi:simple-jndi:0.11.4.1'
testCompile 'junit:junit:4.12'
}
sourceSets.main.java.srcDirs = ["src"]
// the tests fail because they have environemnt specific parameters
// sourceSets.test.java.srcDirs = ["test"]
...@@ -19,18 +19,9 @@ package adql.translator; ...@@ -19,18 +19,9 @@ package adql.translator;
* Copyright 2016 - Astronomisches Rechen Institut (ARI) * Copyright 2016 - Astronomisches Rechen Institut (ARI)
*/ */
import java.util.ArrayList; import adql.db.*;
import java.util.Iterator;
import adql.db.DBChecker;
import adql.db.DBColumn;
import adql.db.DBTable;
import adql.db.DBType;
import adql.db.DBType.DBDatatype; import adql.db.DBType.DBDatatype;
import adql.db.DefaultDBColumn;
import adql.db.DefaultDBTable;
import adql.db.STCS.Region; import adql.db.STCS.Region;
import adql.db.SearchColumnList;
import adql.db.exception.UnresolvedJoinException; import adql.db.exception.UnresolvedJoinException;
import adql.parser.ADQLParser; import adql.parser.ADQLParser;
import adql.parser.ParseException; import adql.parser.ParseException;
...@@ -41,18 +32,10 @@ import adql.query.IdentifierField; ...@@ -41,18 +32,10 @@ import adql.query.IdentifierField;
import adql.query.from.ADQLJoin; import adql.query.from.ADQLJoin;
import adql.query.operand.ADQLColumn; import adql.query.operand.ADQLColumn;
import adql.query.operand.function.MathFunction; import adql.query.operand.function.MathFunction;
import adql.query.operand.function.geometry.AreaFunction; import adql.query.operand.function.geometry.*;
import adql.query.operand.function.geometry.BoxFunction;
import adql.query.operand.function.geometry.CentroidFunction; import java.util.ArrayList;
import adql.query.operand.function.geometry.CircleFunction; import java.util.Iterator;
import adql.query.operand.function.geometry.ContainsFunction;
import adql.query.operand.function.geometry.DistanceFunction;
import adql.query.operand.function.geometry.ExtractCoord;
import adql.query.operand.function.geometry.ExtractCoordSys;
import adql.query.operand.function.geometry.IntersectsFunction;
import adql.query.operand.function.geometry.PointFunction;
import adql.query.operand.function.geometry.PolygonFunction;
import adql.query.operand.function.geometry.RegionFunction;
/** /**
* <p>MS SQL Server translator.</p> * <p>MS SQL Server translator.</p>
...@@ -189,7 +172,7 @@ public class SQLServerTranslator extends JDBCTranslator { ...@@ -189,7 +172,7 @@ public class SQLServerTranslator extends JDBCTranslator {
for(int i = 0; i < clause.size(); i++){ for(int i = 0; i < clause.size(); i++){
if (i == 0){ if (i == 0){
sql = clause.getName() + (clause.hasLimit() ? " TOP " + clause.getLimit() + " " : "") + (clause.distinctColumns() ? " DISTINCT" : ""); sql = clause.getName() + (clause.distinctColumns() ? " DISTINCT" : "") + (clause.hasLimit() ? " TOP " + clause.getLimit() + " " : "");
}else }else
sql += " " + clause.getSeparator(i); sql += " " + clause.getSeparator(i);
...@@ -343,6 +326,8 @@ public class SQLServerTranslator extends JDBCTranslator { ...@@ -343,6 +326,8 @@ public class SQLServerTranslator extends JDBCTranslator {
return "round(" + ((fct.getNbParameters() >= 2) ? (translate(fct.getParameter(0)) + ", " + translate(fct.getParameter(1))) : "") + ",1)"; return "round(" + ((fct.getNbParameters() >= 2) ? (translate(fct.getParameter(0)) + ", " + translate(fct.getParameter(1))) : "") + ",1)";
case MOD: case MOD:
return ((fct.getNbParameters() >= 2) ? (translate(fct.getParameter(0)) + "% " + translate(fct.getParameter(1))) : ""); return ((fct.getNbParameters() >= 2) ? (translate(fct.getParameter(0)) + "% " + translate(fct.getParameter(1))) : "");
case ATAN2:
return "ATN2(" + translate(fct.getParameter(0)) + ", " + translate(fct.getParameter(1)) + ")";
default: default:
return getDefaultADQLFunction(fct); return getDefaultADQLFunction(fct);
} }
......
...@@ -734,7 +734,7 @@ public class ResultSetTableIterator implements TableIterator { ...@@ -734,7 +734,7 @@ public class ResultSetTableIterator implements TableIterator {
else if (colType != null && colValue != null && colType.type == DBDatatype.CHAR && (colType.length == 1 || colType.length <= 0) && colValue instanceof String) else if (colType != null && colValue != null && colType.type == DBDatatype.CHAR && (colType.length == 1 || colType.length <= 0) && colValue instanceof String)
colValue = ((String)colValue).charAt(0); colValue = ((String)colValue).charAt(0);
// if the column value is a geometrical object, it must be serialized in STC-S: // if the column value is a geometrical object, it must be serialized in STC-S:
else if (translator != null && colType != null && colType.isGeometry()){ else if (translator != null && colType != null && colType.isGeometry()) {
try{ try{
Region region = translator.translateGeometryFromDB(colValue); Region region = translator.translateGeometryFromDB(colValue);
if (region != null) if (region != null)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment