Notes to create web filter page multiple choice selectors for martview http://eugenes.org/gmod/biomart/ D. Gilbert, Jan 2006 See biomart0_3.cvs.diff for source differences below from this CVS release :pserver:cvsuser@cvs.sanger.ac.uk:/cvsroot/CVSmaster/biomart-web -r release-0_3 :::::::::::: example meta.xml # Use internalName="..multi.." to trigger martview multi-selection :::::::::: BooleanListFilter BioMart::Configuration::BooleanListFilter # This combines parts of BooleanFilter + ValueFilter for query of several boolean fields (OR) :::::::::: martview # martview has various hacks to get multi-selection to work # 1. sub get_main_panel: set $entry->set_cgi_multiple(1) if filter->name =~ /multi/ # 2. sub get_status_panel,initialise_results : # 2a. keep all @values from CGI->param(): my @values = $CGI->param( $dataSetName.'_'.$entry->name ); # 2b. for BooleanFilter, and multi-values, use BioMart::Configuration::BooleanListFilter instead # 2c. for ValueFilter, add @values back into $value list before AttributeTable # 3. sub validate_params: dont wipe out @values in CGI->param() with edits sub get_main_panel{ # CHECKBOX WITH SELECT AND RADIO BUTTONS if (($$options[0] && $$options[0]->filter && $$options[0]->filter->isa ("BioMart::Configuration::BooleanFilter"))){ ... ## dgg here; want multi-select lists; if ($filter->name() =~ /multi/) { # fixme $entry->set_cgi_multiple(1); $entry->set_cgi_size(5); } ## ... # CHECKBOX WITH SELECT (UNLESS NESTED OPTIONS - TREE ONTOLOGY FILTER) #elsif (($$options[0] elsif ((($$options[0] && !$nested_option_flag) || $filter->name eq $ref || $filter->name eq $subRef || $filter->name eq $secondRef)){ ... ## dgg here; want multi-select lists; if ($filter->name() =~ /multi/) { # fixme $entry->set_cgi_multiple(1); $entry->set_cgi_size(5); } ## sub get_status_panel{ ... # Are there CGI values for this entry? my @values = $CGI->param( $dataSetName.'_'. $entry->name ); my $value = $values[0] || next; $value = unescapeHTML( $value ); #dgg debug where is multiselect list ? my @debugallvals= @values; # $CGI->param( $dataSetName.'_'. $entry->name ); ... if ($$options[0] && $$options[0]->filter && $$options[0]->filter->isa ("BioMart::Configuration::BooleanFilter")){ my $option_name = $CGI->param($dataSetName. '_'.$entry->name.'_filter'); ### dgg; need patch here? YES for multiselect list ## but boolfilter doesnt support multi-list; how to do? ## need to query->addFilter( join( ' OR ', @ entries ) ); ## SEE BELOW; need this code twice ... my @debug_allopts= $CGI->param( $dataSetName.'_'. $entry->name.'_filter' ); warn("DEBUG.in2 _filter=$option_name; allopts= @debug_allopts \n") if DEBUG; if(@debug_allopts > 1) { use BioMart::Configuration::BooleanListFilter; # should be in BioMart::Configurator; my $att_table = BioMart::AttributeTable->new(); my $dnames=""; my $entry1; foreach my $oname (@debug_allopts){ my $option = $ct->getOptionByName($oname); next if (!$option); $dnames .= $option->displayName.", "; my $bentry = $option->filter; if ($value ne 'Only'){ $bentry->setExcluded; } else{ $bentry->setIncluded; } $bentry->displayName($option->displayName); $att_table->addRow( [ $bentry ] ); $entry1= $bentry unless($entry1); } my $blistentry = BioMart::Configuration::BooleanListFilter->new(); #$entry1 $blistentry->initFromBoolFilter($entry1); # this fixes it $blistentry->name($entry->name.'_blist'); ## fixme... $blistentry->displayName($dnames); $blistentry->setTable($att_table); if ($value ne 'Only'){ $blistentry->setExcluded; } else{ $blistentry->setIncluded; } $entry= $blistentry; } else { ###### ... orig code ... } # dgg } elsif ($$options[0] && $$options[0]->filter && $$options[0]->filter->isa ("BioMart::Configuration::ValueFilter")){ my $option_name = $CGI->param($dataSetName. '_'.$entry->name);#.'_filter'); my $option = $ct->getOptionByName($option_name); next if (!$option); $entry = $option->filter; $entry->displayName($option->displayName); my $att_table = BioMart::AttributeTable->new(); $value = $CGI->param( $dataSetName.'_'.$name. '_list' ); ## dgg patch for multilist all values if(@debugallvals>1) { shift @debugallvals; foreach( @debugallvals) { $value .= ','.$_ ; } warn "DEBUG.in6: value=$value\n" if DEBUG; } ... ## dgg patch for multilist all values my $ismultilist= 0; if(@debugallvals>1) { shift @debugallvals; foreach( @debugallvals) { $value .= ','.$_ ; } warn "DEBUG.in7: value=$value\n" if DEBUG; ## this is it $ismultilist= 1; } my $att_table = BioMart::AttributeTable->new(); my @values = split('\,',$value); foreach (@values){ $att_table->addRow([$_]); } if( $ismultilist) { ## dgg $value =~ s/,/, /g; #?? $value = substr($value,0,75)."..." if(length($value)>80); } if (!$ismultilist && $option && !$nested_option_flag ) { $value = $option->displayName;# for status panel below } next if ($entry->isa("BioMart::Configuration::BooleanFilter")); $entry->setTable($att_table); } sub validate_params{# deals with the add_cgi_processing and add_error aspects of MetaData ... ## dgg; is below cgi-set wiping out array vals? YES my @debugvals= $martview::CGI->param( $dataset.'_'. $name ); warn("DEBUG.in4 ",$dataset.'_'. $name," vals=",@debugvals,"\n") if DEBUG; my $val = $martview::CGI->param($dataset.'_'.$name); my $oldval= $val; #dgg ... # substitute any stars back to spaces $val =~ s/\*/ /g; } $martview::CGI->param($dataset.'_'.$name, $val) unless($oldval eq $val); #dgg; dont wipe out array params ! sub initialise_results{ ... # Are there CGI values for this entry? my @values = $CGI->param( $dataSetName.'_'.$entry->name ); my $value = $values[0] || next; my @debugallvals= @values; # dgg ... my $options = $entry->getAllOptions; if ($$options[0] && $$options[0]->filter && $$options[0]->filter->isa ("BioMart::Configuration::BooleanFilter")){ my $option_name = $CGI->param($dataSetName.'_'. $entry->name.'_filter'); ## dgg; fixme again same as above ## dgg; need patch here? YES for multiselect list ## but boolfilter doesnt support multi-list; how to do? ## need to query->addFilter( join( ' OR ', @ entries ) ); my @debug_allopts= $CGI->param( $dataSetName.'_'. $entry->name.'_filter' ); if(@debug_allopts > 1) { ## use BioMart::Configuration::BooleanListFilter; # should be in BioMart::Configurator; my $att_table = BioMart::AttributeTable->new(); my $dnames=""; my $entry1; foreach my $oname (@debug_allopts){ my $option = $ct->getOptionByName($oname); next if (!$option); $dnames .= $option->displayName.", "; my $bentry = $option->filter; if ($value ne 'Only'){ $bentry->setExcluded; } else{ $bentry->setIncluded; } $bentry->displayName($option->displayName); $att_table->addRow( [ $bentry ] ); $entry1= $bentry unless($entry1); } my $blistentry = BioMart::Configuration::BooleanListFilter->new(); #$entry1 $blistentry->initFromBoolFilter($entry1); # this fixes it $blistentry->name($entry->name.'_blist'); ## fixme... $blistentry->displayName($dnames); $blistentry->setTable($att_table); if ($value ne 'Only'){ $blistentry->setExcluded; } else{ $blistentry->setIncluded; } $entry= $blistentry; } else { ###### ... } ###### end dgg } ... my $ismultilist= 0; if(@debugallvals>1) { shift @debugallvals; foreach( @debugallvals) { $value .= ','.$_ ; } warn "DEBUG.in10: value=$value\n" if DEBUG; ## this is it $ismultilist= 1; }