Commit 0d917663 authored by Keith Jolley's avatar Keith Jolley
Browse files

Merge branch 'develop' into submitter_accounts

parents c53f0b42 047ce504
......@@ -306,8 +306,8 @@ sub _print_interface {
sub _print_allele_designations {
my ( $self, $data ) = @_;
my $q = $self->{'cgi'};
say "<div class=\"box\" id=\"alleles\" style=\"overflow:auto\">";
say "<fieldset style=\"float:left\"><legend>Loci</legend>";
say q(<div class="box" id="alleles" style="overflow:auto">);
say q(<fieldset style="float:left"><legend>Loci</legend>);
my $isolate_record = BIGSdb::IsolateInfoPage->new(
(
system => $self->{'system'},
......@@ -328,11 +328,11 @@ sub _print_allele_designations {
say $q->start_form;
my $set_id = $self->get_set_id;
my ( $loci, $labels ) = $self->{'datastore'}->get_locus_list( { set_id => $set_id } );
say "<label for=\"locus\">Locus: </label>";
say q(<label for="locus">Locus: </label>);
say $q->popup_menu( -name => 'locus', -id => 'locus', -values => $loci, -labels => $labels );
say $q->submit( -label => 'Add/update', -class => 'submit' );
$q->param( 'page', 'alleleUpdate' );
$q->param( 'isolate_id', $q->param('id') );
$q->param( page => 'alleleUpdate' );
$q->param( isolate_id => $q->param('id') );
say $q->hidden($_) foreach qw(db page isolate_id);
say $q->end_form;
say "</fieldset></div>";
......
......@@ -308,7 +308,7 @@ sub _get_form_fields {
-name => $name,
-id => $name,
-values => [@optlist],
-default => $newdata{ $att->{'name'} },
-default => $options->{'update'} ? $newdata{ $att->{'name'} } : $att->{'default'},
-labels => $labels,
%html5_args
);
......
......@@ -138,9 +138,11 @@ sub get_isolate_loci {
}
}
} else { #Just list MLST loci
my $scheme_id_ref = $self->{'datastore'}->run_simple_query("SELECT id FROM schemes WHERE description = 'MLST'");
if ( ref $scheme_id_ref eq 'ARRAY' ) {
my $scheme_loci = $self->{'datastore'}->get_scheme_loci( $scheme_id_ref->[0] );
my $scheme_ids =
$self->{'datastore'}
->run_query( "SELECT id FROM schemes WHERE description LIKE 'MLST%' ORDER BY display_order", undef, { fetch => 'col_arrayref' } );
foreach my $scheme_id (@$scheme_ids) {
my $scheme_loci = $self->{'datastore'}->get_scheme_loci($scheme_id);
foreach my $locus (@$scheme_loci) {
my $cleaned_name = $self->clean_locus( $locus, { no_common_name => 1, text_output => 1 } );
push @headers, $cleaned_name;
......
......@@ -519,7 +519,7 @@ sub _get_provenance_fields {
&& !$self->{'system'}->{'privacy'} )
)
{
if ( $value > 0 && $userdata->{'email'} ne '' && $userdata->{'email'} ne '-' ) {
if ( $value > 0 && $userdata->{'email'} =~ /@/ ) {
$person .= " (E-mail: <a href=\"mailto:$userdata->{'email'}\">$userdata->{'email'}</a>)";
}
}
......@@ -576,27 +576,26 @@ sub _get_provenance_fields {
my %attributes = map { $_->{'attribute'} => $_->{'value'} } @$attribute_list;
if ( keys %attributes ) {
my $rows = keys %attributes || 1;
foreach ( sort { $order{$a} <=> $order{$b} } keys(%attributes) ) {
my $url_ref =
$self->{'datastore'}
->run_simple_query( "SELECT url FROM isolate_field_extended_attributes WHERE isolate_field=? AND attribute=?",
$field, $_ );
foreach my $attribute ( sort { $order{$a} <=> $order{$b} } keys(%attributes) ) {
my $url = $self->{'datastore'}->run_query(
"SELECT url FROM isolate_field_extended_attributes WHERE isolate_field=? AND attribute=?",
[ $field, $attribute ]
);
my $att_web;
if ( ref $url_ref eq 'ARRAY' ) {
my $url = $url_ref->[0] || '';
$url =~ s/\[\?\]/$attributes{$_}/;
if ($url) {
$url =~ s/\[\?\]/$attributes{$attribute}/;
$url =~ s/\&/\&amp;/g;
my $domain;
if ( ( lc($url) =~ /http:\/\/(.*?)\/+/ ) ) {
$domain = $1;
}
$att_web = "<a href=\"$url\">$attributes{$_}</a>" if $url;
$att_web = qq(<a href="$url">$attributes{$attribute}</a>) if $url;
if ( $domain && $domain ne $q->virtual_host ) {
$att_web .= " <span class=\"link\"><span style=\"font-size:1.2em\">&rarr;</span> $domain</span>";
$att_web .= qq( <span class="link"><span style="font-size:1.2em">&rarr;</span> $domain</span>);
}
}
$buffer .= "<dt class=\"dontend\">$_</dt>\n";
$buffer .= "<dd>" . ( $att_web || $attributes{$_} ) . "</dd>\n";
$buffer .= "<dt class=\"dontend\">$attribute</dt>\n";
$buffer .= "<dd>" . ( $att_web || $attributes{$attribute} ) . "</dd>\n";
}
}
}
......
......@@ -93,9 +93,19 @@ sub initiate {
}
}
$self->set_system_overrides;
$self->{'dataConnector'}->initiate( $self->{'system'}, $self->{'config'} );
$self->db_connect;
$self->setup_datastore if $self->{'db'};
if ($self->{'db'}){
$self->setup_datastore ;
if ( defined $self->{'options'}->{'v'} ) {
my $view_exists =
$self->{'datastore'}
->run_query( "SELECT EXISTS(SELECT * FROM information_schema.tables WHERE table_name=?)", $self->{'options'}->{'v'} );
die "Invalid view selected.\n" if !$view_exists;
$self->{'system'}->{'view'} = $self->{'options'}->{'v'};
}
}
return;
}
......
#DatabaseFields.pm - Database field description plugin for BIGSdb
#Written by Keith Jolley
#Copyright (c) 2010-2013, University of Oxford
#Copyright (c) 2010-2014, University of Oxford
#E-mail: keith.jolley@zoo.ox.ac.uk
#
#This file is part of Bacterial Isolate Genome Sequence Database (BIGSdb).
......@@ -34,7 +34,7 @@ sub get_attributes {
description => 'Display description of fields defined for the current database',
menutext => 'Description of database fields',
module => 'DatabaseFields',
version => '1.0.2',
version => '1.0.3',
section => 'miscellaneous',
order => 10,
dbtype => 'isolates'
......@@ -50,15 +50,15 @@ sub set_pref_requirements {
sub run {
my ($self) = @_;
say "<h1>Description of database fields</h1>";
say "<div class=\"box\" id=\"resultstable\">";
say "<p>Order columns by clicking their headings. <a href=\"$self->{'system'}->{'script_name'}?"
. "db=$self->{'instance'}&amp;page=plugin&amp;name=DatabaseFields\">Reset default order</a>.</p>";
say "<table class=\"tablesorter\" id=\"sortTable\">\n<thead>";
say "<tr><th>field name</th><th>comments</th><th>data type</th><th class=\"{sorter: false}\">allowed values</th>"
. "<th>required</th></tr></thead>\n<tbody>";
say q(<h1>Description of database fields</h1>);
say q(<div class="box" id="resultstable"><div class="scrollable">);
say qq(<p>Order columns by clicking their headings. <a href="$self->{'system'}->{'script_name'}?db=$self->{'instance'}&amp;)
. qq(page=plugin&amp;name=DatabaseFields">Reset default order</a>.</p>);
say qq(<table class="tablesorter" id="sortTable">\n<thead>);
say qq(<tr><th>field name</th><th>comments</th><th>data type</th><th class="{sorter: false}">allowed values</th><th>required</th></tr>)
. qq(</thead>\n<tbody>);
$self->_print_fields;
say "</tbody></table>\n</div>";
say qq(</tbody></table>\n</div></div>);
return;
}
......@@ -78,11 +78,15 @@ sub _print_fields {
. "</td><td>$thisfield->{'comments'}</td><td>$thisfield->{'type'}</td><td>";
if ( $thisfield->{'optlist'} ) {
my $option_list = $self->{'xmlHandler'}->get_field_option_list($field);
say "$_<br />" foreach @$option_list;
} elsif ( defined $thisfield->{'min'} || defined $thisfield->{'max'} ){
foreach my $option (@$option_list) {
$option =~ s/</&lt;/g;
$option =~ s/>/&gt;/g;
say "$option<br />";
}
} elsif ( defined $thisfield->{'min'} || defined $thisfield->{'max'} ) {
print "min: $thisfield->{'min'}" if defined $thisfield->{'min'};
print "; " if defined $thisfield->{'min'} && defined $thisfield->{'max'};
say "max: $thisfield->{'max'}" if defined $thisfield->{'max'};
print "; " if defined $thisfield->{'min'} && defined $thisfield->{'max'};
say "max: $thisfield->{'max'}" if defined $thisfield->{'max'};
} elsif ( $field eq 'sender' || $field eq 'sequenced_by' || ( $thisfield->{'userfield'} // '' ) eq 'yes' ) {
say "<a href=\"$self->{'system'}->{'script_name'}?db=$self->{'instance'}&amp;page=fieldValues&amp;field=f_sender\" "
. "target=\"_blank\">Click for list of sender ids</a>";
......
......@@ -62,7 +62,8 @@ GetOptions(
'o|order' => \$opts{'o'},
'q|quiet' => \$opts{'q'},
'r|random' => \$opts{'r'},
'T|already_tagged' => \$opts{'T'}
'T|already_tagged' => \$opts{'T'},
'v|view=s' => \$opts{'v'}
) or die("Error in command line arguments\n");
if ( $opts{'h'} ) {
......@@ -235,6 +236,9 @@ ${bold}--threads$norm ${under}THREADS$norm
${bold}-T, --already_tagged$norm
Scan even when sequence tagged (no designation).
${bold}-v, --view$norm ${under}VIEW$norm
Isolate database view (overrides value set in config.xml).
${bold}-w, --word_size$norm ${under}SIZE$norm
BLASTN word size.
......
......@@ -63,7 +63,8 @@ GetOptions(
'n|new_only' => \$opts{'n'},
'o|order' => \$opts{'o'},
'r|random' => \$opts{'r'},
'T|already_tagged' => \$opts{'T'}
'T|already_tagged' => \$opts{'T'},
'v|view=s' => \$opts{'v'}
) or die("Error in command line arguments\n");
if ( $opts{'h'} ) {
......@@ -235,6 +236,9 @@ ${bold}--threads$norm ${under}THREADS$norm
${bold}-T, --already_tagged$norm
Scan even when sequence tagged (no designation).
${bold}-v, --view$norm ${under}VIEW$norm
Isolate database view (overrides value set in config.xml).
${bold}-w, --word_size$norm ${under}SIZE$norm
BLASTN word size.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment