From ac329c4a577b56351100af213934722de8e200e1 Mon Sep 17 00:00:00 2001 From: amillar Date: Sun, 2 Jun 2002 15:16:08 +0000 Subject: [PATCH] Clean up z3950 menu --- acqui.simple/marcimport.pl | 149 +++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 56 deletions(-) diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index 2fdeda4969..4e760dd7f2 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -101,17 +101,16 @@ print startmenu('acquisitions'); # Process input parameters my $file=$input->param('file'); +my $menu = $input->param('menu'); if ($input->param('z3950queue')) { PostToZ3950Queue($dbh,$input); } - if ($input->param('uploadmarc')) { AcceptMarcUpload($dbh,$input) } - if ($input->param('insertnewrecord')) { # Add biblio item, and set up menu for adding item copies ($biblionumber,$biblioitemnumber)=AcceptBiblioitem($dbh,$input); @@ -122,16 +121,14 @@ if ($input->param('insertnewrecord')) { } -#--------------------------------------- -# Add item copy if ($input->param('newitem')) { + # Add item copy &AcceptItemCopy($dbh,$input); } # if newitem - -my $menu = $input->param('menu'); if ($file) { + # A MARC file has been specified; process it for review form my $sth; print "Main Menu
\n"; my $qisbn=$input->param('isbn'); @@ -374,7 +371,7 @@ RECORD: } push @subjects, $subject; } - } + } # foreach field $titleinput=$input->textfield(-name=>'title', -default=>$title, -size=>40); $marcinput=$input->hidden(-name=>'marc', -default=>$marc); $subtitleinput=$input->textfield(-name=>'subtitle', -default=>$subtitle, -size=>40); @@ -470,7 +467,7 @@ RECORD: $marctext EOF - } + } # foreach record } else { #open (F, "$file"); #my $data=; @@ -725,60 +722,89 @@ EOF SWITCH: { - if ($menu eq 'z3950') { z3950(); last SWITCH; } + if ($menu eq 'z3950') { z3950menu($dbh,$input); last SWITCH; } if ($menu eq 'uploadmarc') { uploadmarc(); last SWITCH; } if ($menu eq 'manual') { manual(); last SWITCH; } mainmenu(); } } +print endmenu(); +print endpage(); -sub z3950 { - my $sth=$dbh->prepare("select id,term,type,done,numrecords,length(results),startdate,enddate,servers from z3950queue order by id desc limit 20"); - $sth->execute; +sub z3950menu { + use strict; + my ( + $dbh, + $input, + )=@_; + + my ( + $sth, $sti, + $processing, + $realenddate, + $totalrecords, + $elapsed, + $elapsedtime, + $resultstatus, $statuscolor, + $id, $term, $type, $done, $numrecords, $length, + $startdate, $enddate, $servers + ); + print "Main Menu
\n"; print "\n"; + # End of query listing + + #------------------------------ + # Search input form + print "
\n"; print "

Results of Z39.50 searches

\n"; - print "Refresh
\n
    \n"; - while (my ($id, $term, $type, $done, $numrecords, $length, $startdate, $enddate, $servers) = $sth->fetchrow) { + print "Refresh
    \n" . + "
      \n"; + + # Check queued queries + $sth=$dbh->prepare("select id,term,type,done, + numrecords,length(results),startdate,enddate,servers + from z3950queue + order by id desc + limit 20 "); + $sth->execute; + while ( ($id, $term, $type, $done, $numrecords, $length, + $startdate, $enddate, $servers) = $sth->fetchrow) { $type=uc($type); $term=~s//>/g; - my $sti=$dbh->prepare("select id,server,startdate,enddate,numrecords from z3950results where queryid=$id"); - $sti->execute; + + # See if query produced results + $sti=$dbh->prepare("select id,server,startdate,enddate,numrecords + from z3950results + where queryid=?"); + $sti->execute($id); if ($sti->rows) { - my $processing=0; - my $realenddate=0; - my $totalrecords=0; - while (my ($r_id,$r_server,$r_startdate,$r_enddate,$r_numrecords) = $sti->fetchrow) { + $processing=0; + $realenddate=0; + $totalrecords=0; + while (my ($r_id,$r_server,$r_startdate,$r_enddate,$r_numrecords) + = $sti->fetchrow) { if ($r_enddate==0) { + # It hasn't finished yet $processing=1; } else { + # It finished, see how long it took. if ($r_enddate>$realenddate) { $realenddate=$r_enddate; } } $totalrecords+=$r_numrecords; - } + } # while results + if ($processing) { - my $elapsed=time()-$startdate; - my $elapsedtime=''; - if ($elapsed>60) { - $elapsedtime=sprintf "%d minutes",($elapsed/60); - } else { - $elapsedtime=sprintf "%d seconds",$elapsed; - } - if ($totalrecords) { - $totalrecords="$totalrecords found."; - } else { - $totalrecords=''; - } - print "
    • $type=$term Processing... $totalrecords ($elapsedtime)
      \n"; + $elapsed=time()-$startdate; + $resultstatus="Processing..."; + $statuscolor="red"; } else { - my $elapsed=$realenddate-$startdate; - my $elapsedtime=''; + $elapsed=$realenddate-$startdate; + $resultstatus="Done."; + $statuscolor="black"; + } + if ($elapsed>60) { $elapsedtime=sprintf "%d minutes",($elapsed/60); } else { @@ -789,15 +815,25 @@ sub z3950 { } else { $totalrecords=''; } - print "
    • $type=$term Done. $totalrecords ($elapsedtime)
      \n"; - } + print "
    • ". + "$type=$term" . + "$resultstatus $totalrecords " . + "($elapsedtime)
      \n"; } else { - print "
    • $type=$term Pending
      \n"; - } - } - print "
    \n"; - print "
\n"; - my $sth=$dbh->prepare("select id,name,checked from z3950servers order by rank"); + print "
  • + $type=$term Pending
    \n"; + } # if results done + } # while queries + print "
  • \n"; + + my $sth=$dbh->prepare("select id,name,checked + from z3950servers + order by rank"); $sth->execute; my $serverlist=''; while (my ($id, $name, $checked) = $sth->fetchrow) { @@ -814,21 +850,23 @@ print << "EOF";

    - +
    Search for MARC records
    + - - +  ISBN +  LCCN
    +  Author +  Title +  Keyword + +
    Search for MARC records
    Query Term
     ISBN  LCCN
     Author  Title  Keyword
    - $serverlist -
    - -
    $serverlist
    EOF print "

    \n"; -} +} # sub z3950 sub uploadmarc { print "Main Menu
    \n"; @@ -891,8 +929,6 @@ sub skip { #
    } -print endmenu(); -print endpage(); sub parsemarcdata { my $data=shift; @@ -959,12 +995,13 @@ sub parsemarcdata { $field{'subfields'}=\%subfields; } push (@record, \%field); - } + } # foreach field in record push (@records, \@record); $counter++; } + print "" if $debug; return @records; -} +} # sub parsemarcfileformat #---------------------------- # Accept form results to add query to z3950 queue -- 2.39.5