\n";
print "LSE Annotators List\n";
print "";
foreach my $col (@table_cols) {
print "| $col | " ;
}
print "
\n";
my $config = getQueryConfig();
if($q->param('action') and $q->param('action') eq 'Delete Index') {
print "";
my $s_indexid = $dbh->quote($q->param('indexid'));
print "Deleting index ID $s_indexid (this may take a while)";
my ($location) = $dbh->selectrow_array("select location from collection_indices where indexid = $s_indexid");
$dbh->do("delete from collection_indices where indexid = $s_indexid");
if(-d $location) {
print "Deleting index files from disk..\n";
system('rm','-vrf','$location');
}
print "";
}
if($q->param('action') and $q->param('action') eq 'Create Index') {
my $icmd = $config->{$q->param('indextype')}{indexingcommand};
if(!$icmd) {
print "Error: Invalid Index Type
\n";
exit;
}
print "Creating index in the background\n";
$SIG{CHLD} = 'IGNORE';
defined (my $kid = fork) or die "Cannot fork: $!\n";
if (!$kid) {
system("nice","nohup",$icmd,$q->param('userid'),$q->param('colname'),$q->param('annottype'));
CORE::exit(0);
}
}
#Begin ordinary work for the list
my $cmd = "select c.*, sum(scount) as scount, sum(dcount) as dcount from col_queries cq natural join collections c group by c.name,c.description,c.ready,c.started,c.finished,c.userid order by c.userid,c.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 ;
}
# Get list of index types that can be built
my @indexable_types = ();
foreach my $key (keys(%$config)) {
if(exists $config->{$key}{indexingcommand}) {
push(@indexable_types,$key);
}
}
$sth = $dbh->prepare($cmd) ;
$sth->execute;
while ( my $row = $sth->fetchrow_hashref )
{
print "\n" ;
foreach my $col (@table_cols) {
my $s_userid = $dbh->quote($row->{userid});
my $s_name = $dbh->quote($row->{name});
print "\n";
#display information in table form.
if ( defined $row->{$col} ) {
print "$row->{$col}" ;
} elsif($col eq 'delete') {
print qq();
} elsif($col eq 'newindex') {
print qq(\n";
} elsif($col eq 'oldindex') {
my $indices = $dbh->selectall_arrayref("select annot_type, index_type, location, indexid from collection_indices where name = $s_name and userid = $s_userid");
if(@$indices) {
print "";
print "| Annotation Type | Index Type | Location | \n";
foreach my $index (@$indices) {
print qq(| $index->[0] | $index->[1] | $index->[2] | );
print qq();
}
print " | ";
}
}
print " | \n";
}
print "
\n" ;
} #end while
print "
" ;