use LSE::Database::Connection ; use LSE::Monitor; use CGI ; use strict ; use warnings ; my $q = new CGI ; print $q->header ; my @table_cols = ( 'annot_id', 'name', 'pid', 'hostname', 'jobid', 'status', "utime", "newcommand", "oldcommand", "stop" ) ; my $table_name = 'annotators' ; print "\n" ; print "
\n"; print "\n"; print ""; foreach my $col (@table_cols) { print "" ; } print "\n"; my $dbh = getConnection() ; #Check to make sure th e current user has the right priveleges my $current_user = $dbh->quote($ENV{REMOTE_USER}) ; my $sth = $dbh->prepare("select * from users where userid = $current_user") ; $sth->execute ; my $current_user_info = $sth->fetchrow_hashref ; #If not an administrator don't allow to view page if ($current_user_info->{gid} ne 'admin') { print "Error: you aren't authorized to view this page" ; exit ; } ## STOP ANNOTATOR if ( $q->param('stop') ) { my $dying_id = $q->param('stop') ; my $s_dying_id = $dbh->quote($dying_id); my $com = "select * from $table_name where annot_id=$s_dying_id " ; #print "$com" ; $sth = $dbh->prepare($com) ; $sth->execute() ; my $deadrow = $sth->fetchrow_hashref() ; print "
\n";
    LSE::Monitor::killAnnotator( $deadrow ) ; 
    print "
\n"; } ## START ANNOTATOR if( $q->param('startannotator') ) { my $start_type = $q->param('startannotator'); my $start_machine = $q->param('machine'); print "
\n";
    LSE::Monitor::startAnnotator($start_type,$start_machine);
    print "
\n"; } ## SET ANNOTATOR STATUS if ($q->param('setcommand') ) { my $annot = $q->param('setcommand'); my $newcommand = $q->param('newcommand'); my $s_newcommand = $dbh->quote($newcommand); if($annot eq '*') { $dbh->do("update annotators set newcommand = $s_newcommand"); } else { my $s_annot = $dbh->quote($annot); $dbh->do("update annotators set newcommand = $s_newcommand WHERE annot_id = $s_annot"); } } #Begin ordinary work for the list my $cmd = "select * from $table_name " ; if (defined $q->param('sort')) { my $sortval = $q->param('sort'); $cmd = "$cmd order by $sortval" ; #if the sort parameter is defined, then check to see #if the reverse parameter is defined if (defined $q->param('reverse') && $q->param('reverse') eq 'true' ) { $cmd = "$cmd desc" ; } #include this print for degubing purposes #print $cmd ; } $sth = $dbh->prepare($cmd) ; $sth->execute; while ( my $row = $sth->fetchrow_hashref ) { #create an empty anonymous hash print "\n" ; foreach my $col (@table_cols) { #populate the hash with columns from the row #display information in table form. if ( defined $row->{$col} ) { print "\t\n"; } elsif($col eq 'newcommand') { print "\n"; } elsif ( $col eq 'stop' ) { print "\t\n" ; } } print "\n" ; } #end while print "
LSE Annotators List
$col
$row->{$col}\n" ; print "\n"; printNewCommandSelect($row->{annot_id}); print "" ; print "
" ; print "{annot_id}\">"; print qq(); print "
"; print "\t
\n" ; } else { print "\t
" ; print "

Set new command for all annotators:\n"; printNewCommandSelect(); printStartNewAnnotator(); print qq(

Reload
Note: If you started a new annotator, you should reload to see its status by clicking here rather than using your Reload button, or you might accidentally start extra annotators

); sub printNewCommandSelect { my $annot_id = shift; $annot_id = '*' unless $annot_id; print "
" ; print qq(); print< EOT print qq(); print "\n"; } sub printStartNewAnnotator { use LSE::Config; my $scfg = getServiceConfig(); print "
" ; print qq(Start annotator of type); print qq(\n"; print qq(on machine ); print qq(); print "
\n"; }