Skip to content
Snippets Groups Projects
Commit 843c9960 authored by gmantele's avatar gmantele
Browse files

Merge branch 'master' into objectPosition

parent d648f48b
No related branches found
No related tags found
No related merge requests found
Showing
with 1532 additions and 227 deletions
......@@ -33,14 +33,18 @@ Each library has its own package (`adql` for ADQL, `uws` for UWS and `tap` for T
### Dependencies
Below are summed up the dependencies of each library:
* ADQL: `adql`, `cds.utils`
* UWS: `uws`, `org.json`
* TAP: `adql`, `uws`, `cds.*`, `org.json`
* ADQL: `adql`, `cds.utils`, `org.postgresql` *(for adql.translator.PgSphereTranslator only)*
* UWS: `uws`, `org.json`, HTTP Multipart lib. (`com.oreilly.servlet`)
* TAP: `adql`, `uws`, `cds.*`, `org.json`, `org.postgresql` *(for adql.translator.PgSphereTranslator only)*, HTTP Multipart lib. (`com.oreilly.servlet`), STIL (`nom.tap`, `org.apache.tools.bzip2`, `uk.ac.starlink`)
In the `lib` directory, you will find 2 JAR files:
* `cos-1.5beta.jar` to deal with HTTP multipart requests
* `stil3.0-5.jar` for [STIL](http://www.star.bris.ac.uk/~mbt/stil/) (VOTable and other formats support)
### ANT scripts
At the root of the repository, there are 3 ANT scripts. Each is dedicated to one library. They are able to generate JAR for sources, binaries and Javadoc.
3 properties must be set before using one of these scripts:
* `CATALINA`: a path toward a JAR or a binary directory containing org.apache.catalina.connector.ClientAbortException.class
* `POSTGRES`: a path toward a JAR or a binary directory containing all org.postgresql.* - [https://jdbc.postgresql.org/download.html](JDBC Postgres driver) - **(ONLY for ADQL and TAP if you want to keep adql.translator.PgSphereTranslator)**
* `SERVLET-API`: a path toward a JAR or a binary directory containing all javax.servlet.*
* (`JUNIT-API` *not required before the version 2.0 of the tap library*: a path toward one or several JARs or binary directories containing all classes to use JUnit.)
* (`JUNIT-API` *not required before the version 2.0 of the tap library OR if you are not interested by the `test` directory (JUnit tests)*: a path toward one or several JARs or binary directories containing all classes to use JUnit.)
......@@ -2,7 +2,7 @@
<!DOCTYPE project>
<project name="adql" basedir="." default="buildLib">
<property name="version" value="1.2" />
<property name="version" value="1.3" />
<property name="srcDir" value="src" />
<property name="compileDir" value="antBuild" />
......@@ -11,7 +11,7 @@
<property name="adqlPath" value="adql/**" />
<property name="utilsPath" value="cds/utils/**" />
<property name="licensePath" value="COPYING.LESSER.txt" />
<property name="licensePath" value="COPYING.LESSER" />
<property name="includesList" value="${adqlPath},${utilsPath},${licensePath}" />
<property name="jarDest" value="." />
......@@ -22,6 +22,33 @@
<property name="adqlParserLink" value="adqlParser.jar" />
<property name="testsDir" value="test" />
<property name="junitReportsDir" value="reports/adql" />
<fail message="The property POSTGRES must be set! It provides the path toward a directory or a JAR which contains all classes inside org.postgresql.">
<condition><not><isset property="POSTGRES"/></not></condition>
</fail>
<fail message="The property SERVLET-API must be set! It provides the path toward a directory or a JAR which contains all classes inside javax.servlet.">
<condition><not><isset property="SERVLET-API"/></not></condition>
</fail>
<fail message="The property JUNIT-API must be set! It provides the path toward a directory or a JAR which contains all classes needed to use JUnit.">
<condition><not><isset property="JUNIT-API"/></not></condition>
</fail>
<!-- CLASSPATHS -->
<path id="adql.classpath">
<pathelement location="${POSTGRES}" />
</path>
<path id="junit.class.path">
<path refid="adql.classpath" />
<pathelement path="${JUNIT-API}" />
<pathelement location="bin" />
</path>
<!-- START -->
<echo>ADQL LIBRARY VERSION = ${version}</echo>
<!-- BUILD ALL TASK -->
......@@ -30,7 +57,24 @@
<antcall target="cleanJavadocBuild" />
</target>
<target name="cleanAll" depends="clean,cleanJavadoc" description="Delete all files generated by this ANT file for the set version." />
<target name="cleanAll" depends="clean,cleanJUnitReports,cleanJavadoc" description="Delete all files generated by this ANT file for the set version." />
<!-- JUNIT VALIDATION -->
<target name="cleanJUnitReports" description="Clean the JUnit reports directory of the ADQL library ONLY.">
<delete dir="${junitReportsDir}" failonerror="false" />
</target>
<target name="junitValidation" depends="cleanJUnitReports" description="Executes all JUnit tests before building the library and stop ANT at any error.">
<mkdir dir="${junitReportsDir}"/>
<junit errorproperty="adqlTestsFailure" failureproperty="adqlTestsFailure">
<classpath refid="junit.class.path" />
<formatter type="brief" usefile="yes" />
<batchtest todir="${junitReportsDir}">
<fileset dir="${testsDir}" includes="adql/**/Test*.java" />
</batchtest>
</junit>
<fail if="${adqlTestsFailure}" message="Failed JUnit validation for ADQL Lib.!" />
</target>
<!-- LIB & SOURCES -->
<target name="clean" description="Delete the JARs for the library (classes), the runnable ADQL parser and for its sources for the set version.">
......@@ -41,9 +85,11 @@
<delete dir="${compileDir}" failonerror="false" />
</target>
<target name="compileLib" depends="clean" description="Build all the classes of the ADQL library. This target is particularly usefull because it lets highlighting missing dependencies.">
<target name="compileLib" depends="clean,junitValidation" description="Build all the classes of the ADQL library. This target is particularly usefull because it lets highlighting missing dependencies.">
<mkdir dir="${compileDir}" />
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false" />
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false" encoding="utf8" bootclasspath="${adql.bootclasspath}">
<classpath refid="adql.classpath" />
</javac>
</target>
<target name="buildLib" depends="compileLib" description="After 'clean', build the library JAR (only classes) and the runnable ADQL parser.">
......@@ -63,7 +109,9 @@
</target>
<target name="buildLibAndSrc" depends="buildLib" description="After 'clean' and 'buildLib', build the sources JAR (only .java).">
<jar compress="false" baseDir="${srcDir}" destfile="${srcJarFile}" includes="${includesList}" />
<jar compress="false" destfile="${srcJarFile}">
<zipfileset dir="${srcDir}" includes="${includesList},${licensePath}" prefix="${srcDir}" />
</jar>
</target>
<!-- JAVADOC -->
......@@ -76,7 +124,7 @@
</target>
<target name="compileJavadoc" depends="cleanJavadoc" description="After 'cleanJavadoc', compile the whole Javadoc.">
<javadoc access="protected" author="true" classpath="." destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<javadoc encoding="utf-8" charset="utf-8" docencoding="utf-8" access="protected" author="true" classpath="." destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<packageset dir="${srcDir}" includes="${includesList}" />
</javadoc>
</target>
......@@ -85,4 +133,4 @@
<jar destfile="${javadocJarFile}" basedir="${javadocDir}" />
</target>
</project>
\ No newline at end of file
</project>
......@@ -2,39 +2,68 @@
<!DOCTYPE project>
<project name="tap" basedir="." default="buildLib">
<property name="version" value="1.1b" />
<property name="version" value="2.0beta" />
<property name="srcDir" value="src" />
<property name="libDir" value="lib" />
<property name="compileDir" value="antBuild" />
<property name="classesDir" value="${compileDir}"/>
<property name="javadocDir" value="javadoc/tap" />
<property name="uploadUtilsJar" value="lib/uploadUtils.jar" />
<property name="cosJarName" value="cos-1.5beta.jar" />
<property name="cosJar" value="${libDir}/${cosJarName}" />
<property name="stilJarName" value="stil_3.0-11.jar" />
<property name="stilJar" value="${libDir}/${stilJarName}" />
<property name="tapPath" value="tap/**,adql/**,uws/**,cds/**" />
<property name="jsonPath" value="org/json/**" />
<property name="uploadUtilsPath" value="com/oreilly/servlet/**,org/kxml2/**,org/xmlpull/**" />
<property name="licensePath" value="COPYING.LESSER.txt" />
<property name="includesList" value="${tapPath},${jsonPath},${uploadUtilsPath},${licensePath}" />
<property name="extLibsPath" value="com/oreilly/servlet/**,nom/tam/**,org/apache/tools/bzip2/**,uk/ac/starlink/**" />
<property name="licensePath" value="COPYING.LESSER" />
<property name="includesList" value="${tapPath},${jsonPath},${extLibsPath}" />
<property name="jarDest" value="." />
<property name="libJarFile" value="${jarDest}/tap_${version}.jar" />
<property name="srcJarFile" value="${jarDest}/tap_src_${version}.jar" />
<property name="javadocJarFile" value="${jarDest}/tap_javadoc_${version}.jar" />
<fail message="Missing property: CATALINA ! It provides the path toward a directory or a JAR which contains the following class: org.apache.catalina.connector.ClientAbortException.">
<condition><not><isset property="CATALINA"/></not></condition>
<property name="testsDir" value="test" />
<property name="adqlJunitReportsDir" value="reports/adql" />
<property name="uwsJunitReportsDir" value="reports/uws" />
<property name="tapJunitReportsDir" value="reports/tap" />
<fail message="The property POSTGRES must be set! It provides the path toward a directory or a JAR which contains all classes inside org.postgresql.">
<condition><not><isset property="POSTGRES"/></not></condition>
</fail>
<fail message="The property SERVLET-API must be set! It provides the path toward a directory or a JAR which contains all classes inside javax.servlet.">
<condition><not><isset property="SERVLET-API"/></not></condition>
</fail>
<fail message="The property JUNIT-API must be set! It provides the path toward a directory or a JAR which contains all classes needed to use JUnit.">
<condition><not><isset property="JUNIT-API"/></not></condition>
</fail>
<fail message="The property JNDI-API must be set! It provides the path toward a directory or a JAR which contains all classes needed to use Simple-JNDI.">
<condition><not><isset property="JNDI-API"/></not></condition>
</fail>
<!-- CLASSPATHS -->
<path id="tap.classpath">
<pathelement location="${uploadUtilsJar}" />
<pathelement location="${CATALINA}" />
<pathelement location="${cosJar}" />
<pathelement location="${jsonJar}" />
<pathelement location="${stilJar}" />
<pathelement location="${POSTGRES}" />
<pathelement location="${SERVLET-API}" />
</path>
<path id="junit.class.path">
<path refid="tap.classpath" />
<pathelement path="${JNDI-API}" />
<pathelement path="${JUNIT-API}" />
<pathelement location="bin" />
</path>
<echo>TAP LIBRARY VERSION = ${version}</echo>
<!-- BUILD ALL TASK -->
......@@ -43,7 +72,34 @@
<antcall target="cleanJavadocBuild" />
</target>
<target name="cleanAll" depends="clean,cleanJavadoc" description="Delete all files generated by this ANT file for the set version." />
<target name="cleanAll" depends="clean,cleanJavadoc,cleanJUnitReports" description="Delete all files generated by this ANT file for the set version." />
<!-- JUNIT VALIDATION -->
<target name="cleanJUnitReports" description="Clean the JUnit reports directory of the ADQL, UWS and TAP library ONLY.">
<delete dir="${adqlJunitReportsDir}" failonerror="false" />
<delete dir="${uwsJunitReportsDir}" failonerror="false" />
<delete dir="${tapJunitReportsDir}" failonerror="false" />
</target>
<target name="junitValidation" depends="cleanJUnitReports" description="Executes all JUnit tests before building the library and stop ANT at any error.">
<mkdir dir="${adqlJunitReportsDir}"/>
<mkdir dir="${uwsJunitReportsDir}"/>
<mkdir dir="${tapJunitReportsDir}"/>
<junit errorproperty="testsFailure" failureproperty="testsFailure">
<classpath refid="junit.class.path" />
<formatter type="brief" usefile="yes" />
<batchtest todir="${adqlJunitReportsDir}">
<fileset dir="${testsDir}" includes="adql/**/Test*.java" />
</batchtest>
<batchtest todir="${uwsJunitReportsDir}">
<fileset dir="${testsDir}" includes="uws/**/Test*.java" />
</batchtest>
<batchtest todir="${tapJunitReportsDir}">
<fileset dir="${testsDir}" includes="tap/**/Test*.java" />
</batchtest>
</junit>
<fail if="${testsFailure}" message="Failed JUnit validation for ADQL, UWS or TAP Lib.!" />
</target>
<!-- LIB & SOURCES -->
<target name="clean" description="Delete the JARs for the library (classes) and for its sources for the set version.">
......@@ -52,9 +108,9 @@
<delete dir="${compileDir}" failonerror="false" />
</target>
<target name="compileLib" depends="clean" description="Build all the classes of the TAP library. This target is particularly usefull because it lets highlighting missing dependencies.">
<target name="compileLib" depends="clean,junitValidation" description="Build all the classes of the TAP library. This target is particularly usefull because it lets highlighting missing dependencies.">
<mkdir dir="${compileDir}" />
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false">
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false" encoding="utf8">
<classpath refid="tap.classpath" />
</javac>
</target>
......@@ -62,14 +118,26 @@
<target name="buildLib" depends="compileLib" description="After 'clean', build the library JAR (only classes).">
<echo>Generate the library:</echo>
<jar basedir="${classesDir}" destfile="${libJarFile}" includes="${includesList}">
<zipfileset src="${uploadUtilsJar}" excludes="META-INF/*" />
<zipfileset src="${cosJar}" excludes="META-INF/*" />
<zipfileset src="${stilJar}" excludes="META-INF/*" />
<zipfileset dir="src" includes="${licensePath}" />
</jar>
<jar basedir="${classesDir}" destfile="${libJarFile}2" includes="${includesList}">
<zipfileset src="${cosJar}" excludes="META-INF/*" />
<zipfileset dir="src" includes="${licensePath}" />
</jar>
<delete dir="${compileDir}" failonerror="true" />
</target>
<target name="buildLibAndSrc" depends="buildLib" description="After 'clean' and 'buildLib', build the sources JAR (only .java).">
<jar compress="false" baseDir="${srcDir}" destfile="${srcJarFile}" includes="${includesList}">
<fileset file="${uploadUtilsJar}" />
<jar compress="false" destfile="${srcJarFile}">
<zipfileset dir="${srcDir}" includes="${includesList},${licensePath}" prefix="${srcDir}" />
<zipfileset dir="${libDir}" includes="${cosJarName}" fullPath="${cosJar}" />
<zipfileset dir="${libDir}" includes="${stilJarName}" fullPath="${stilJar}" />
</jar>
<jar compress="false" destfile="${srcJarFile}2">
<zipfileset dir="${srcDir}" includes="${includesList},${licensePath}" prefix="${srcDir}" />
<zipfileset dir="${libDir}" includes="${cosJarName}" fullPath="${cosJar}" />
</jar>
</target>
......@@ -83,7 +151,7 @@
</target>
<target name="compileJavadoc" depends="cleanJavadoc" description="After 'cleanJavadoc', compile the whole Javadoc.">
<javadoc access="protected" author="true" destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<javadoc encoding="utf-8" charset="utf-8" docencoding="utf-8" access="protected" author="true" destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<packageset dir="${srcDir}" includes="${includesList}" />
<classpath refid="tap.classpath" />
</javadoc>
......@@ -93,4 +161,4 @@
<jar destfile="${javadocJarFile}" basedir="${javadocDir}" />
</target>
</project>
\ No newline at end of file
</project>
......@@ -2,35 +2,47 @@
<!DOCTYPE project>
<project name="uws" basedir="." default="buildLib">
<property name="version" value="4.1b" />
<property name="version" value="4.1" />
<property name="srcDir" value="src" />
<property name="libDir" value="lib" />
<property name="compileDir" value="antBuild" />
<property name="classesDir" value="${compileDir}"/>
<property name="javadocDir" value="javadoc/uws" />
<property name="cosJarName" value="cos-1.5beta.jar" />
<property name="cosJar" value="${libDir}/${cosJarName}" />
<property name="uwsPath" value="uws/**" />
<property name="jsonPath" value="org/json/**" />
<property name="licensePath" value="COPYING.LESSER.txt" />
<property name="includesList" value="${uwsPath},${jsonPath},${licensePath}" />
<property name="licensePath" value="COPYING.LESSER" />
<property name="extLibsPath" value="com/oreilly/servlet/**" />
<property name="includesList" value="${uwsPath},${jsonPath},${extLibsPath}" />
<property name="jarDest" value="." />
<property name="libJarFile" value="${jarDest}/uws_${version}.jar" />
<property name="srcJarFile" value="${jarDest}/uws_src_${version}.jar" />
<property name="javadocJarFile" value="${jarDest}/uws_javadoc_${version}.jar" />
<fail message="Missing property: CATALINA ! It provides the path toward a directory or a JAR which contains the following class: org.apache.catalina.connector.ClientAbortException.">
<condition><not><isset property="CATALINA"/></not></condition>
</fail>
<property name="testsDir" value="test" />
<property name="junitReportsDir" value="reports/uws" />
<fail message="The property SERVLET-API must be set! It provides the path toward a directory or a JAR which contains all classes inside javax.servlet.">
<condition><not><isset property="SERVLET-API"/></not></condition>
</fail>
<!-- CLASSPATHS -->
<path id="uws.classpath">
<pathelement location="${CATALINA}" />
<pathelement location="${cosJar}" />
<pathelement location="${SERVLET-API}" />
</path>
<path id="junit.class.path">
<path refid="uws.classpath" />
<pathelement path="${JUNIT-API}" />
<pathelement location="bin" />
</path>
<echo>UWS LIBRARY VERSION = ${version}</echo>
<!-- BUILD ALL TASK -->
......@@ -39,7 +51,24 @@
<antcall target="cleanJavadocBuild" />
</target>
<target name="cleanAll" depends="clean,cleanJavadoc" description="Delete all files generated by this ANT file for the set version." />
<target name="cleanAll" depends="clean,cleanJavadoc,cleanJUnitReports" description="Delete all files generated by this ANT file for the set version." />
<!-- JUNIT VALIDATION -->
<target name="cleanJUnitReports" description="Clean the JUnit reports directory of the UWS library ONLY.">
<delete dir="${junitReportsDir}" failonerror="false" />
</target>
<target name="junitValidation" depends="cleanJUnitReports" description="Executes all JUnit tests before building the library and stop ANT at any error.">
<mkdir dir="${junitReportsDir}"/>
<junit errorproperty="uwsTestsFailure" failureproperty="uwsTestsFailure">
<classpath refid="junit.class.path" />
<formatter type="brief" usefile="yes" />
<batchtest todir="${junitReportsDir}">
<fileset dir="${testsDir}" includes="uws/**/Test*.java" />
</batchtest>
</junit>
<fail if="${uwsTestsFailure}" message="Failed JUnit validation for UWS Lib.!" />
</target>
<!-- LIB & SOURCES -->
<target name="clean" description="Delete the JARs for the library (classes) and for its sources for the set version.">
......@@ -48,21 +77,27 @@
<delete dir="${compileDir}" failonerror="false" />
</target>
<target name="compileLib" depends="clean" description="Build all the classes of the UWS library. This target is particularly usefull because it lets highlighting missing dependencies.">
<target name="compileLib" depends="clean,junitValidation" description="Build all the classes of the UWS library. This target is particularly usefull because it lets highlighting missing dependencies.">
<mkdir dir="${compileDir}" />
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false">
<javac destdir="${compileDir}" srcdir="${srcDir}" includes="${includesList}" includeantruntime="false" encoding="utf8">
<classpath refid="uws.classpath" />
</javac>
</target>
<target name="buildLib" depends="compileLib" description="After 'clean', build the library JAR (only classes).">
<echo>Generate the library:</echo>
<jar basedir="${classesDir}" destfile="${libJarFile}" includes="${includesList}" />
<jar basedir="${classesDir}" destfile="${libJarFile}" includes="${includesList}">
<zipfileset src="${cosJar}" excludes="META-INF/*" />
<zipfileset dir="src" includes="${licensePath}" />
</jar>
<delete dir="${compileDir}" failonerror="true" />
</target>
<target name="buildLibAndSrc" depends="buildLib" description="After 'clean' and 'buildLib', build the sources JAR (only .java).">
<jar compress="false" baseDir="${srcDir}" destfile="${srcJarFile}" includes="${includesList}" />
<jar compress="false" destfile="${srcJarFile}">
<zipfileset dir="${srcDir}" includes="${includesList},${licensePath}" prefix="${srcDir}" />
<zipfileset dir="${libDir}" includes="${cosJarName}" fullPath="${cosJar}" />
</jar>
</target>
<!-- JAVADOC -->
......@@ -75,7 +110,7 @@
</target>
<target name="compileJavadoc" depends="cleanJavadoc" description="After 'cleanJavadoc', compile the whole Javadoc.">
<javadoc access="protected" author="true" destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<javadoc encoding="utf-8" charset="utf-8" docencoding="utf-8" access="protected" author="true" destdir="${javadocDir}" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" source="1.7" splitindex="true" use="true" version="true">
<packageset dir="${srcDir}" includes="${includesList}" />
<classpath refid="uws.classpath" />
</javadoc>
......@@ -85,4 +120,4 @@
<jar destfile="${javadocJarFile}" basedir="${javadocDir}" />
</target>
</project>
\ No newline at end of file
</project>
File added
File moved
File added
File deleted
File deleted
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project name="TAPUploaderTest" basedir="." default="jarBuild">
<target name="init">
<property name="srcRep" value="src" />
<property name="buildRep" value="build"/>
<property name="jarFile" value="uploadUtils.jar" />
<property name="jarDest" value=".." />
</target>
<target name="jarBuild" depends="init" >
<echo>Création du jar (${jarDest}/${jarFile})...</echo>
<jar destfile="${jarDest}/${jarFile}">
<zipfileset src="binarySavot.jar" excludes="META-INF/*" />
<zipfileset src="cds.savot.common.jar" excludes="META-INF/*" />
<zipfileset src="cds.savot.model.jar" excludes="META-INF/*" />
<zipfileset src="cds.savot.pull.jar" excludes="META-INF/*" />
<zipfileset src="cds.savot.writer.jar" excludes="META-INF/*" />
<zipfileset src="kxml2-min.jar" excludes="META-INF/*" />
<zipfileset src="cos.jar" excludes="META-INF/*" />
</jar>
</target>
</project>
\ No newline at end of file
File deleted
File deleted
File deleted
File deleted
File deleted
This diff is collapsed.
......@@ -16,7 +16,8 @@ package adql.db;
* 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 2011 - UDS/Centre de Données astronomiques de Strasbourg (CDS)
* Copyright 2011,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/
/**
......@@ -27,8 +28,8 @@ package adql.db;
* and corresponds to a real column in the "database" with its DB name ({@link #getDBName()}).
* </p>
*
* @author Gr&eacute;gory Mantelet (CDS)
* @version 08/2011
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.3 (10/2014)
*/
public interface DBColumn {
......@@ -46,6 +47,19 @@ public interface DBColumn {
*/
public String getDBName();
/**
* <p>Get the type of this column (as closed as possible from the "database" type).</p>
*
* <p><i>Note:
* The returned type should be as closed as possible from a type listed by the IVOA in the TAP protocol description into the section UPLOAD.
* </i></p>
*
* @return Its type.
*
* @since 1.3
*/
public DBType getDatatype();
/**
* Gets the table which contains this {@link DBColumn}.
*
......
......@@ -16,12 +16,13 @@ package adql.db;
* 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 2014 - Astronomishes Rechen Institute (ARI)
* Copyright 2014-2015 - Astronomisches Rechen Institut (ARI)
*/
import java.util.ArrayList;
import java.util.Iterator;
import adql.db.exception.UnresolvedJoinException;
import adql.query.ADQLQuery;
/**
......@@ -33,7 +34,7 @@ import adql.query.ADQLQuery;
* in case of several JOINs.
*
* @author Gr&eacute;gory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de
* @version 1.2 (11/2013)
* @version 1.3 (05/2015)
* @since 1.2
*/
public class DBCommonColumn implements DBColumn {
......@@ -54,8 +55,13 @@ public class DBCommonColumn implements DBColumn {
*
* @param leftCol Column of the left join table. May be a {@link DBCommonColumn}.
* @param rightCol Column of the right join table. May be a {@link DBCommonColumn}.
*
* @throws UnresolvedJoinException If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.
*/
public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol){
public DBCommonColumn(final DBColumn leftCol, final DBColumn rightCol) throws UnresolvedJoinException{
// Test whether type of both columns are compatible:
if (leftCol.getDatatype() != null && rightCol.getDatatype() != null && !leftCol.getDatatype().isCompatible(rightCol.getDatatype()))
throw new UnresolvedJoinException("JOIN impossible: incompatible column types when trying to join the columns " + leftCol.getADQLName() + " (" + leftCol.getDatatype() + ") and " + rightCol.getADQLName() + " (" + rightCol.getDatatype() + ")!");
// LEFT COLUMN:
if (leftCol instanceof DBCommonColumn){
......@@ -83,7 +89,6 @@ public class DBCommonColumn implements DBColumn {
// add the table to cover:
addCoveredTable(rightCol.getTable());
}
}
/**
......@@ -112,6 +117,11 @@ public class DBCommonColumn implements DBColumn {
return generalColumnDesc.getDBName();
}
@Override
public final DBType getDatatype(){
return generalColumnDesc.getDatatype();
}
@Override
public final DBTable getTable(){
return null;
......
......@@ -16,7 +16,8 @@ package adql.db;
* 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 - UDS/Centre de Données astronomiques de Strasbourg (CDS)
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/
/**
......@@ -27,8 +28,8 @@ package adql.db;
* and corresponds to a real table in the "database" with its DB name ({@link #getDBName()}).
* </p>
*
* @author Gr&eacute;gory Mantelet (CDS)
* @version 07/2011
* @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.3 (09/2014)
*/
public interface DBTable extends Iterable<DBColumn> {
......@@ -86,10 +87,25 @@ public interface DBTable extends Iterable<DBColumn> {
public DBColumn getColumn(String colName, boolean adqlName);
/**
* Makes a copy of this instance of {@link DBTable}, with the possibility to change the DB and ADQL names.
* <p>Makes a copy of this instance of {@link DBTable}, with the possibility to change the DB and ADQL names.</p>
*
* <p><b>IMPORTANT:</b>
* <b>The given DB and ADQL name may be NULL.</b> If NULL, the copy will contain exactly the same full name (DB and/or ADQL).<br/>
* <b>And they may be qualified</b> (that's to say: prefixed by the schema name or by the catalog and schema name). It means that it is possible to
* change the catalog, schema and table name in the copy.<br/>
* For instance:
* </p>
* <ul>
* <li><i>.copy(null, "foo") =></i> a copy with the same full DB name, but with no ADQL catalog and schema name and with an ADQL table name equals to "foo"</li>
* <li><i>.copy("schema.table", ) =></i> a copy with the same full ADQL name, but with no DB catalog name, with a DB schema name equals to "schema" and with a DB table name equals to "table"</li>
* </ul>
*
* @param dbName Its new DB name.
* It may be qualified.
* It may also be NULL ; if so, the full DB name won't be different in the copy.
* @param adqlName Its new ADQL name.
* It may be qualified.
* It may also be NULL ; if so, the full DB name won't be different in the copy.
*
* @return A modified copy of this {@link DBTable}.
*/
......
package adql.db;
/*
* This file is part of ADQLLibrary.
*
* ADQLLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ADQLLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TAPLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2014 - Astronomisches Rechen Institut (ARI)
*/
/**
*
* <p>
* Describe a full column type as it is described in the IVOA document of TAP.
* Thus, this object contains 2 attributes: <code>type</code> (or datatype) and <code>length</code> (or size).
* </p>
*
* <p>The length/size may be not defined ; in this case, its value is set to {@link #NO_LENGTH} or is negative or null.</p>
*
* <p>All datatypes declared in the IVOA recommendation document of TAP are listed in an enumeration type: {@link DBDatatype}.
* It is used to set the attribute type/datatype of this class.</p>
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 1.3 (10/2014)
* @since 1.3
*/
public class DBType {
/**
* List of all datatypes declared in the IVOA recommendation of TAP (in the section UPLOAD).
*
* @author Gr&eacute;gory Mantelet (ARI)
* @version 1.3 (10/2014)
* @since 1.3
*/
public static enum DBDatatype{
SMALLINT, INTEGER, BIGINT, REAL, DOUBLE, BINARY, VARBINARY, CHAR, VARCHAR, BLOB, CLOB, TIMESTAMP, POINT, REGION;
}
/** Special value in case no length/size is specified. */
public static final int NO_LENGTH = -1;
/** Datatype of a column. */
public final DBDatatype type;
/** The length parameter (only few datatypes need this parameter: char, varchar, binary and varbinary). */
public final int length;
/**
* Build a TAP column type by specifying a datatype.
*
* @param datatype Column datatype.
*/
public DBType(final DBDatatype datatype){
this(datatype, NO_LENGTH);
}
/**
* Build a TAP column type by specifying a datatype and a length (needed only for datatypes like char, varchar, binary and varbinary).
*
* @param datatype Column datatype.
* @param length Length of the column value (needed only for datatypes like char, varchar, binary and varbinary).
*/
public DBType(final DBDatatype datatype, final int length){
if (datatype == null)
throw new NullPointerException("Missing TAP column datatype !");
this.type = datatype;
this.length = length;
}
public boolean isNumeric(){
switch(type){
case SMALLINT:
case INTEGER:
case BIGINT:
case REAL:
case DOUBLE:
/* Note: binaries are also included here because they can also be considered as Numeric,
* but not for JOINs. */
case BINARY:
case VARBINARY:
case BLOB:
return true;
default:
return false;
}
}
public boolean isBinary(){
switch(type){
case BINARY:
case VARBINARY:
case BLOB:
return true;
default:
return false;
}
}
public boolean isString(){
switch(type){
case CHAR:
case VARCHAR:
case CLOB:
case TIMESTAMP:
return true;
default:
return false;
}
}
public boolean isGeometry(){
return (type == DBDatatype.POINT || type == DBDatatype.REGION);
}
public boolean isCompatible(final DBType t){
if (t == null)
return false;
else if (isBinary() == t.isBinary())
return (type == DBDatatype.BLOB && t.type == DBDatatype.BLOB) || (type != DBDatatype.BLOB && t.type != DBDatatype.BLOB);
else if (isNumeric() == t.isNumeric())
return true;
else if (isGeometry() == t.isGeometry())
return (type == t.type);
else if (isString())
return (type == DBDatatype.CLOB && t.type == DBDatatype.CLOB) || (type != DBDatatype.CLOB && t.type != DBDatatype.CLOB);
else
return (type == t.type);
}
@Override
public String toString(){
if (length > 0)
return type + "(" + length + ")";
else
return type.toString();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment