From dadec915da4a54d4e34da90ca003d476e74c4de0 Mon Sep 17 00:00:00 2001 From: amillar Date: Wed, 12 Jun 2002 22:11:14 +0000 Subject: [PATCH] Streamline z3950 search results --- acqui.simple/marcimport.pl | 211 ++++++++++++++++++++----------------- updater/updatedatabase | 2 - 2 files changed, 114 insertions(+), 99 deletions(-) diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index 6d83267cdc..c402308c46 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -195,7 +195,7 @@ sub ProcessFile { my $qlccn=$input->param('lccn'); my $qcontrolnumber=$input->param('controlnumber'); - # See if a particular result record was specified + # See if a particular result item was specified if ($qisbn || $qissn || $qlccn || $qcontrolnumber) { print "New File
\n"; #open (F, "$file"); @@ -344,51 +344,51 @@ RECORD:

New Record

Full MARC Record available at bottom
- - - - - - - - - - - - - - - - - - - - - - - - - -
Title$titleinput
Subtitle$subtitleinput
Author$authorinput
Additional Authors$additionalauthorsinput
Illustrator$illustratorinput
Copyright$copyrightinput
Series Title$seriestitleinput
Volume$volumeinput
Number$numberinput
Volume Date$volumedateinput
Volume Description$volumeddescinput
Subject$subjectinput
Notes$noteinput
Item Type
ISBN$isbninput
ISSN$issninput
LCCN$lccninput
Dewey$deweyinput
Subclass$subclassinput
Publication Year$pubyearinput
Publisher$publisherinput
Place$placeinput
Pages$pagesinput
Size$sizeinput
- - - $fileinput - $marcinput - $origisbn - $origissn - $origlccn - $origcontrolnumber + + + + + + + + + + + + + + + + + + + + + + + + + +
Title$titleinput
Subtitle$subtitleinput
Author$authorinput
Additional Authors$additionalauthorsinput
Illustrator$illustratorinput
Copyright$copyrightinput
Series Title$seriestitleinput
Volume$volumeinput
Number$numberinput
Volume Date$volumedateinput
Volume Description$volumeddescinput
Subject$subjectinput
Notes$noteinput
Item Type
ISBN$isbninput
ISSN$issninput
LCCN$lccninput
Dewey$deweyinput
Subclass$subclassinput
Publication Year$pubyearinput
Publisher$publisherinput
Place$placeinput
Pages$pagesinput
Size$sizeinput
+ + + $fileinput + $marcinput + $origisbn + $origissn + $origlccn + $origcontrolnumber
$marctext EOF } # foreach record } else { - # No result file specified, list results - ListSearchResults($dbh,$input); + # No result item specified, list results + ListFileRecords($dbh,$input); } # if } # sub ProcessFile -sub ListSearchResults { +sub ListFileRecords { use strict; # Input parameters @@ -398,17 +398,21 @@ sub ListSearchResults { )=@_; my ( + $sth, $sti, $field, + $data, # records in MARC file format + $name, + $srvid, + %servernames, + $serverdb, ); - my $data; - my $name; my $z3950=0; my $recordsource; my $record; my ($numrecords,$resultsid,$data,$startdate,$enddate); - # File can be results of z3950 search or uploaded MARC data + # File can be z3950 search query or uploaded MARC data # if z3950 results if ($file=~/Z-(\d+)/) { @@ -416,7 +420,7 @@ sub ListSearchResults { $recordsource=''; } else { # This is a Marc upload - my $sth=$dbh->prepare("select marc,name from uploadedmarc where id=$file"); + $sth=$dbh->prepare("select marc,name from uploadedmarc where id=$file"); $sth->execute; ($data, $name) = $sth->fetchrow; $recordsource="from $name"; @@ -437,44 +441,36 @@ EOF if ($file=~/Z-(\d+)/) { # This is a z3950 search - my $id=$1; # search results id number - my $sth=$dbh->prepare("select servers from z3950queue where id=$id"); - $sth->execute; - my ($servers) = $sth->fetchrow; + my $id=$1; # search query id number my $serverstring; my $starttimer=time(); - # loop through all servers in search request - foreach $serverstring (split(/\s+/, $servers)) { - my ($name, $server, $database, $auth) = split(/\//, $serverstring, 4); - if ($name eq 'MAN') { - print "$server/$database
\n"; - } else { - my $sti=$dbh->prepare("select name from - z3950servers where id=$name"); - $sti->execute; - my ($longname)=$sti->fetchrow; - print "\n"; - if ($longname) { - print "$longname \n"; - } else { - print "$server/$database \n"; - } - } - my $q_server=$dbh->quote($serverstring); - my $startrecord=$input->param("ST-$name"); + $sth=$dbh->prepare(" + select z3950results.numrecords,z3950results.id,z3950results.results, + z3950results.startdate,z3950results.enddate,server + from z3950queue left outer join z3950results + on z3950queue.id=z3950results.queryid + where z3950queue.id=? + order by server + "); + $sth->execute($id); + if ( $sth->rows ) { + # loop through all servers in search results + while ( ($numrecords,$resultsid,$data, + $startdate,$enddate,$serverstring) = $sth->fetchrow ) { + my ($srvid, $server, $database, $auth) = split(/\//, $serverstring, 4); + #print "server=$serverstring\n"; + if ( $server ) { + print " " . + &z3950servername($dbh,$srvid,"$server/$database") . "\n"; + } # if $server + my $startrecord=$input->param("ST-$srvid"); ($startrecord) || ($startrecord='0'); - my $sti=$dbh->prepare(" - select numrecords,id,results,startdate,enddate - from z3950results - where queryid=$id and server=$q_server"); - $sti->execute; - ($numrecords,$resultsid,$data,$startdate,$enddate) = $sti->fetchrow; my $serverplaceholder=''; foreach ($input->param) { (next) unless (/ST-(.+)/); my $serverid=$1; - (next) if ($serverid eq $name); + (next) if ($serverid eq $srvid); my $place=$input->param("ST-$serverid"); $serverplaceholder.="\&ST-$serverid=$place"; } @@ -482,25 +478,25 @@ EOF my $previous=''; my $next=''; if ($startrecord>0) { - $previous="Previous"; + $previous="Previous"; } my $highest; $highest=$startrecord+10; ($highest>$numrecords) && ($highest=$numrecords); if ($numrecords>$startrecord+10) { - $next="Next"; + $next="Next"; } print "[Viewing ".($startrecord+1)." to ".$highest." of $numrecords records] $previous | $next
\n"; + my $stj=$dbh->prepare("update z3950results + set highestseen=? where id=?"); + $stj->execute($startrecord+10,$resultsid); } else { print "
\n"; } print "\n"; - } + } # foreach server my $elapsed=time()-$starttimer; print "
It took $elapsed seconds to process this page.\n"; + } else { + print "No results found for query $id/n"; + } # if rows } else { # This is an uploaded Marc record @@ -545,7 +537,32 @@ EOF } # foreach record } # if z3950 or marc upload print "\n"; -} # sub ListSearchResults +} # sub ListFileRecords + +#-------------- +sub z3950servername { + # inputs + my ( + $dbh, + $srvid, # server id number + $default, + )=@_; + # return + my $longname; + #---- + + my $sti=$dbh->prepare("select name + from z3950servers + where id=?"); + $sti->execute($srvid); + if ( ! $sti->err ) { + ($longname)=$sti->fetchrow; + } + if (! $longname) { + $longname="$default"; + } + return $longname; +} # sub z3950servername sub PrintResultRecordLink { use strict; @@ -636,7 +653,7 @@ sub extractmarcfields { if ( $fieldname=$tagmap{ $field->{'tag'} }->{$subfield}->{name} ) { # Yes, so keep the value if ( ref($field->{'subfields'}->{$subfield} ) eq 'ARRAY' ) { - # if it was an array, just keep first element. + # if it was an array, just keep first element. $bib->{$fieldname}=$field->{'subfields'}->{$subfield}[0]; } else { $bib->{$fieldname}=$field->{'subfields'}->{$subfield}; @@ -769,7 +786,7 @@ sub z3950menu { $elapsed, $elapsedtime, $resultstatus, $statuscolor, - $id, $term, $type, $done, $numrecords, $length, + $id, $term, $type, $done, $startdate, $enddate, $servers, $record,$bib,$title, ); @@ -782,12 +799,12 @@ sub z3950menu { # Check queued queries $sth=$dbh->prepare("select id,term,type,done, - numrecords,length(results),startdate,enddate,servers + startdate,enddate,servers from z3950queue order by id desc limit 20 "); $sth->execute; - while ( ($id, $term, $type, $done, $numrecords, $length, + while ( ($id, $term, $type, $done, $startdate, $enddate, $servers) = $sth->fetchrow) { $type=uc($type); $term=~s/"( id int auto_increment primary key, -- 2.20.1