Skip to content

Commit

Permalink
vo: improve TAP table labelling.
Browse files Browse the repository at this point in the history
Modify the way table names are identified in the ADQL to generate a
label for loaded TAP tables.  In particular, get it to work better
for VizieR tables, which have names with a lot of funny characters in.
  • Loading branch information
mbtaylor committed Jun 10, 2013
1 parent 6200851 commit 2f78eb0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions vo/src/main/uk/ac/starlink/vo/TapTableLoadDialog.java
Expand Up @@ -70,9 +70,10 @@ public class TapTableLoadDialog extends DalTableLoadDialog {
Pattern.CASE_INSENSITIVE );

// Pattern for locating table names in ADQL, used for generating terse
// query summaries; doesn't need to be very good.
// query summaries; doesn't need to be very good. Could be improved
// by using the ADQL parser if required.
private static final Pattern TNAME_REGEX =
Pattern.compile( "(FROM|JOIN)\\s+([a-z][a-z0-9._]*)",
Pattern.compile( "(FROM|JOIN)\\s+(\\S*)",
Pattern.CASE_INSENSITIVE );

/**
Expand Down Expand Up @@ -418,8 +419,16 @@ private String createLoadLabel( String adql ) {
if ( adql != null ) {
Matcher matcher = TNAME_REGEX.matcher( adql );
for ( boolean more = false; matcher.find(); more = true ) {
String tname = matcher.group( 2 );

/* Do some mangling, since at present the label
* can be truncated elsewhere in the application by
* assuming "/" characters represent pathnames for which
* the earlier parts can get discarded. */
tname = tname.replaceAll( "/+", "_" )
.replaceAll( "\"", "" );
sbuf.append( more ? ',' : '_' )
.append( matcher.group( 2 ) );
.append( tname );
}
}
return sbuf.toString();
Expand Down

0 comments on commit 2f78eb0

Please sign in to comment.