gmantele / vollt

Java libraries implementing the IVOA protocol: ADQL, UWS and TAP
http://cdsportal.u-strasbg.fr/taptuto/
29 stars 28 forks source link

[adqlLib-2.0-beta] Migration of old code #149

Closed olebole closed 8 months ago

olebole commented 8 months ago

Hi Grégory,

thanks again for the new ADQL beta version! Do you have any hints how to migrate older code (ADQLQuery ---> ADQLSet)? Specifically, I am now working to get Aladin working with the new lib, and there are two methods which are not in ADQLSet: getFrom() and getWhere():

ADQLSet adqlQuery = syntaxParser.parseQuery(query);
tableNames = new ArrayList<>();
for (ADQLTable adqlTable : adqlQuery.getFrom().getTables()) {
        …
}

DynamicTabForm.java:805-809

What is the "new" way to get the tables and the "where" clause? Can/shall one just force-cast the result of parseQuery()?

gmantele commented 8 months ago

Hi Ole,

Aladin is still using ADQLLib-1.5 or earlier. I guess it should be to the Aladin team to migrate to ADQLLib-2.0-beta ; but honestly, I would not recommend them to do so ; I would rather advise them to wait for the stable release instead of investing time in this migration work. Is not it possible to still have in Debian both versions of ADQLLib, one used by TOPCAT and the other one by Aladin?

Anyway, if one would like to do such migration, and not knowing why the list of tables is needed here (there may be other ways to get it), here would be the change to apply.

ADQLSet is an abstract class which is extended by ADQLQuery. So, the simplest way to make your snippet work would be the following:

ADQLSet adqlQuery = syntaxParser.parseQuery(query);
tableNames = new ArrayList<>();
if (adqlQuery instanceof ADQLQuery){
    for (ADQLTable adqlTable : ((ADQLQuery)adqlQuery).getFrom().getTables()) {
            …
    }
}else{
    //     throw new ...Exception(...);
    // OR
    //     keep the variable `tableNames` empty
}
olebole commented 8 months ago

In principle you are right; however in Debian we use a the same version for all dependent packages. For ADQL, this is Aladin and Topcat. Topcat was the driver to get an updated ADQL (beta) version, and so I need to locally adjust Aladin until there is a proper update by the Aladin developers as CDS. The patch you propose seems to work for me, so I will apply it to the Debian package (to keep Aladin working). Thank you!