From f36ec98fd268134c39af026303432b23867ea120 Mon Sep 17 00:00:00 2001 From: tonnesen Date: Sat, 3 Nov 2001 07:28:20 +0000 Subject: [PATCH] Z39.50 now stores list of servers to query in a database table. --- acqui.simple/marcimport.pl | 62 ++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index fef6f4c5c3..7aae1e9d67 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -87,14 +87,13 @@ if ($input->param('z3950queue')) { foreach ($input->param) { if (/S-(.*)/) { my $server=$1; - if ($server eq 'LOC') { - push @serverlist, "LOC/z3950.loc.gov:7090/voyager//"; - } - if ($server eq 'NLC') { - push @serverlist, "NLC/amicus.nlc-bnc.ca:210/AMICUS/bccms1/hawk5fad"; - } if ($server eq 'MAN') { push @serverlist, "MAN/".$input->param('manualz3950server')."//"; + } else { + my $sth=$dbh->prepare("select host,port,db,userid,password from z3950servers where id=$server"); + $sth->execute; + my ($host, $port, $db, $userid, $password) = $sth->fetchrow; + push @serverlist, "$server/$host\:$port/$db/$userid/$password"; } } } @@ -277,6 +276,9 @@ EOF $sth->execute; my ($barcode) = $sth->fetchrow; $barcode++; + if ($barcode==1) { + $barcode=int(rand()*1000000); + } print << "EOF";
@@ -315,14 +317,21 @@ if ($input->param('newitem')) { my $biblionumber=$input->param('biblionumber'); my $biblioitemnumber=$input->param('biblioitemnumber'); my $replacementprice=($input->param('replacementprice') || 0); - my $sth=$dbh->prepare("select max(itemnumber) from items"); - $sth->execute; - my ($itemnumber) = $sth->fetchrow; - $itemnumber++; - my @datearr=localtime(time); - my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3]; - $sth=$dbh->prepare("insert into items (itemnumber, biblionumber, biblioitemnumber, barcode, itemnotes, homebranch, holdingbranch, dateaccessioned, replacementprice) values ($itemnumber, $biblionumber, $biblioitemnumber, $q_barcode, $q_notes, $q_homebranch, 'STWE', '$date', $replacementprice)"); + my $sth=$dbh->prepare("select barcode from items where + barcode=$q_barcode"); $sth->execute; + if ($sth->rows) { + print "Barcode '$barcode' has already been assigned.

\n"; + } else { + $sth=$dbh->prepare("select max(itemnumber) from items"); + $sth->execute; + my ($itemnumber) = $sth->fetchrow; + $itemnumber++; + my @datearr=localtime(time); + my $date=(1900+$datearr[5])."-".($datearr[4]+1)."-".$datearr[3]; + $sth=$dbh->prepare("insert into items (itemnumber, biblionumber, biblioitemnumber, barcode, itemnotes, homebranch, holdingbranch, dateaccessioned, replacementprice) values ($itemnumber, $biblionumber, $biblioitemnumber, $q_barcode, $q_notes, $q_homebranch, 'STWE', '$date', $replacementprice)"); + $sth->execute; + } } @@ -688,12 +697,18 @@ EOF my $serverstring; foreach $serverstring (split(/\s+/, $servers)) { my ($name, $server, $database, $auth) = split(/\//, $serverstring, 4); - if ($name eq 'LOC') { + if ($name eq 'MAN') { + print "$server/$database
\n"; + } elsif ($name eq 'LOC') { print "Library of Congress
\n"; } elsif ($name eq 'NLC') { print "National Library of Canada
\n"; } else { - print "$server/$database
\n"; + my $sti=$dbh->prepare("select name from + z3950servers where id=$name"); + $sti->execute; + my ($longname)=$sti->fetchrow; + print "$longname
\n"; } print "

    \n"; my $q_server=$dbh->quote($serverstring); @@ -886,7 +901,7 @@ sub z3950 { $sth->execute; print "Main Menu
    \n"; print "
    \n"; - print "

    Results of Z3950 searches

    \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) { $type=uc($type); @@ -920,19 +935,26 @@ sub z3950 { } print "
    \n"; 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) { + ($checked) ? ($checked='checked') : ($checked=''); + $serverlist.=" $name
    \n"; + } + $serverlist.=" \n"; + print << "EOF";

    - +
    Search for MARC records
    LOC and NLC
    Search for MARC records
    Query Term
    ISBN LCCN Title
    - Library of Congress
    - National Library of Canada
    - + $serverlist
    -- 2.39.5