Skip to content

Commit

Permalink
gaiavo: add controls and visualisation of TAP tables and related meta…
Browse files Browse the repository at this point in the history
…data
  • Loading branch information
pwdraper committed Aug 8, 2014
1 parent a4b3988 commit f2f103f
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 44 deletions.
1 change: 0 additions & 1 deletion applications/gaia/gaiavo/library/GaiaVOCatRegistry.tcl
Expand Up @@ -191,7 +191,6 @@ itcl::class gaiavo::GaiaVOCatRegistry {
} else {
# Need headers and selected row.
set headings [$itk_component(results) get_headings]
puts "$itk_option(-activate_cmd) \$headings \$args"
eval $itk_option(-activate_cmd) \$headings "$args"
}
}
Expand Down
79 changes: 74 additions & 5 deletions applications/gaia/gaiavo/library/GaiaVOTAPQuery.tcl
Expand Up @@ -89,15 +89,42 @@ itcl::class gaiavo::GaiaVOTAPQuery {
} else {
set name $itk_option(-accessURL)
}
itk_component add service {
LabelValue $w_.service \

itk_component add actionframe {
frame $w_.actionframe
}
pack $itk_component(actionframe) -side top -fill x -ipadx 1m -ipady 1m

itk_component add servicename {
LabelValue $itk_component(actionframe).servicename \
-text "Service:" \
-labelwidth $lwidth \
-valuewidth $vwidth \
-value $name
-value $itk_option(-shortname)
}
pack $itk_component(servicename) -side top -fill x -expand 1
add_short_help $itk_component(servicename) "The TAP service name"

itk_component add serviceurl {
LabelValue $itk_component(actionframe).serviceurl \
-text " " \
-labelwidth $lwidth \
-valuewidth $vwidth \
-value $itk_option(-accessURL)
}
pack $itk_component(serviceurl) -side top -fill x -expand 1
add_short_help $itk_component(serviceurl) "The TAP service endpoint"

# Additional query for discovering information about the tables
# on offer.
itk_component add queryservice {
button $itk_component(actionframe).queryservice \
-text "Tables..." \
-command [code $this query_tables_]
}
pack $itk_component(service) -side top -fill x -ipadx 1m -ipady 1m
add_short_help $itk_component(service) "The TAP service"
pack $itk_component(queryservice) -side right -fill none -expand 0 -ipadx 1m
add_short_help $itk_component(queryservice) \
{Query the service for information about the tables available}

# Get the ADQL query.
itk_component add adqlframe {
Expand Down Expand Up @@ -221,6 +248,42 @@ itcl::class gaiavo::GaiaVOTAPQuery {
}
}

# Query the TAP service about the tables that it provides and display some
# of the metadata. Only done once, as should be fixed for an accessURL.
protected method query_tables_ {} {
if { $tables_doc_ == {} } {
set query "$itk_option(-accessURL)/tables"
if { $querytaptask_ == {} } {
set querytaptask_ [gaia::GaiaForeignExec \#auto \
-application $::gaia_dir/querytapthings \
-preprocess [code $this query_tables_output_] \
-notify [code $this query_tables_done_]]
}

blt::busy hold $w_
set tables_doc_ {}
$querytaptask_ runwith $itk_option(-accessURL) "tables"
} else {
# Just make sure the results window can be viewed.
utilRaiseWindow $w_.tableset
}
}

# Handle output from query_tables task.
protected method query_tables_output_ {msg} {
append tables_doc_ $msg
}

# Query table completed, so pass on result to viewer.
protected method query_tables_done_ {} {
blt::busy release $w_
if { $tables_doc_ != {} } {
utilReUseWidget gaiavo::GaiaVOTableSet $w_.tableset -xml $tables_doc_
::update idletasks
$w_.tableset update
}
}

# Configuration options: (public variables)
# ----------------------

Expand Down Expand Up @@ -259,6 +322,12 @@ itcl::class gaiavo::GaiaVOTAPQuery {
# Set true when a query is being interrupted.
protected variable interrupted_ 0

# Task to query the TAP service about it's tables.
protected variable querytaptask_ {}

# Output from querytaptask_, an XML document.
protected variable tables_doc_ {}

# Common variables: (shared by all instances)
# -----------------

Expand Down
99 changes: 61 additions & 38 deletions applications/gaia/gaiavo/library/GaiaVOTableSet.tcl
Expand Up @@ -126,19 +126,26 @@ itcl::class gaiavo::GaiaVOTableSet {
-selectmode $selectmode_ \
-exportselection $exportselection_ \
-headings {name description} \
-height 5
-height 5 \
-width 80
}
add_short_help $itk_component(tables) {Tables available}

# Set table binding edit the entries.
bind $itk_component(tables).listbox <1> [code $this view_selected_]
bind $itk_component(tables).listbox <<ListboxSelect>> \
[code $this view_selected_]

# Add the table for displaying the current table.
itk_component add table {
TableList $w_.table \
-title "Current table" \
-hscroll 1 \
-selectmode $selectmode_ \
-exportselection $exportselection_ \
-headings {column description datatype} \
-height 15
-headings {column description datatype units ucd utype} \
-height 15 \
-width 80
}
add_short_help $itk_component(table) \
{Columns and descriptions in the current table}
Expand All @@ -157,9 +164,6 @@ itcl::class gaiavo::GaiaVOTableSet {
pack $itk_component(close) -side left -expand 1 -pady 2m
add_short_help $itk_component(close) {Close window}

# Set table binding edit the entries.
bind $itk_component(tables).listbox <1> [code $this view_selected_]

# Pack all widgets into place.
pack $itk_component(tables) -side top -fill both -expand 1
pack $itk_component(table) -side top -fill both -expand 1
Expand Down Expand Up @@ -303,38 +307,39 @@ itcl::class gaiavo::GaiaVOTableSet {

# Now find all the <table>s.
set root [$doc documentElement]
if { ! [string equal -nocase "tableset" [$root nodeName]] } {
error_dialog "root of document not a tableset: [$root nodeName]"
return
}

# Don't do this, some responses are not correct, but still usable.
#if { ! [string match -nocase "*tableset" [$root nodeName]] } {
# error_dialog "root of document not a tableset: [$root nodeName]"
# return
#}
set tables [$root selectNodes "//table"]

# Gather names and descriptions.
set info {}
array unset tablelist_
foreach table $tables {
set nameNode [$table selectNode "name"]
if { $nameNode != {} } {
set name [$nameNode text]

# We require a name.
if { $name != {} } {
set descNode [$table selectNode "description"]
set desc "None provided"
if { $descNode != {} } {
set desc [$descNode text]
}
lappend info [list $name $desc]

# Keep indexed list of table nodes so we can pick out content as
# needed.
set tablelist_($name) $table
}
set name [get_node_text_ $table "name"]

# We require a name.
if { $name != {} } {
set desc [get_node_text_ $table "description"]
set desc [clean_ $desc]
lappend info [list $name $desc]

# Keep indexed list of table nodes so we can pick out content as
# needed.
set tablelist_($name) $table
}
}

set_contents 1 $info
new_info 1

# Select first row.
$itk_component(tables) select_row 1
::update idletasks
view_selected_
}

# View the properties of the selected table.
Expand All @@ -356,21 +361,39 @@ itcl::class gaiavo::GaiaVOTableSet {
set info {}
set columns [$table selectNode "column"]
foreach column $columns {
set nameNode [$column selectNode "name"]
set name [$nameNode text]

set descNode [$column selectNode "description"]
set desc [$descNode text]

set dataNode [$column selectNode "dataType"]
set datatype [$dataNode text]

lappend info [list $name $desc $datatype]
catch {
set name [get_node_text_ $column "name"]
set desc [get_node_text_ $column "description"]
set desc [clean_ $desc]
set datatype [get_node_text_ $column "dataType"]
set units [get_node_text_ $column "unit"]
set ucd [get_node_text_ $column "ucd"]
set utype [get_node_text_ $column "utype"]

lappend info [list $name $desc $datatype $units $ucd $utype]
}
}
set_contents 0 $info
new_info 0
}

# Get all text from a named child.
protected method get_node_text_ {parent name} {
set node [$parent selectNode $name]
if { $node != {} } {
return [$node text]
}
return {}
}


# Clean a string, removing funny characters and trimming.
protected method clean_ {str} {
regsub -all {[^\w\d\s\.]} $str {} str
return [string trim $str]
}


# Configuration options
# =====================

Expand All @@ -388,7 +411,7 @@ itcl::class gaiavo::GaiaVOTableSet {
protected variable tablelist_

# Table configuration.
protected variable selectmode_ single
protected variable selectmode_ browse
protected variable exportselection_ 0

# Common variables: (shared by all instances)
Expand Down

0 comments on commit f2f103f

Please sign in to comment.