|
+ #open (F, "$file");
+ #my $data=;
+ my $data;
+ my $name;
+ my $z3950=0;
+ if ($file=~/Z-(\d+)/) {
+ print << "EOF";
+
+
+Select a New File
+
+
+| Select a Record to Import |
+
EOF
- my $text='';
- foreach $record (@records) {
- my @subjects=();
- my ($lccn, $isbn, $issn, $dewey, $author, $title, $place, $publisher, $publicationyear, $volume, $number, @subjects, $note, $controlnumber);
- foreach $field (@$record) {
- $text.=$field->{'tag'}."\n";
- foreach (keys %{$field->{'subfields'}}) {
- my $value=$field->{'subfields'}->{$_};
- $text.=" $_: $value\n";
+ my $id=$1;
+ my $sth=$dbh->prepare("select servers from z3950queue where id=$id");
+ $sth->execute;
+ my ($servers) = $sth->fetchrow;
+ my $serverstring;
+ foreach $serverstring (split(/\s+/, $servers)) {
+ my ($name, $server, $database, $auth) = split(/\//, $serverstring, 4);
+ if ($name eq 'LOC') {
+ print "Library of Congress \n";
+ } elsif ($name eq 'NLC') {
+ print "National Library of Canada \n";
+ } else {
+ print "$server/$database \n";
}
- if ($field->{'tag'} eq '001') {
- $controlnumber=$field->{'indicator'};
- }
- if ($field->{'tag'} eq '010') {
- $lccn=$field->{'subfields'}->{'a'};
- $lccn=~s/^\s*//;
- ($lccn) = (split(/\s+/, $lccn))[0];
- }
- if ($field->{'tag'} eq '015') {
- $lccn=$field->{'subfields'}->{'a'};
- $lccn=~s/^\s*//;
- $lccn=~s/^C//;
- ($lccn) = (split(/\s+/, $lccn))[0];
- }
- if ($field->{'tag'} eq '020') {
- $isbn=$field->{'subfields'}->{'a'};
- ($isbn=~/ARRAY/) && ($isbn=$$isbn[0]);
- $isbn=~s/[^\d]*//g;
- }
- if ($field->{'tag'} eq '022') {
- $issn=$field->{'subfields'}->{'a'};
- $issn=~s/^\s*//;
- ($issn) = (split(/\s+/, $issn))[0];
- }
- if ($field->{'tag'} eq '082') {
- $dewey=$field->{'subfields'}->{'a'};
- $dewey=~s/\///g;
- if (@$dewey) {
- $dewey=$$dewey[0];
- }
- #$dewey=~s/\///g;
- }
- if ($field->{'tag'} eq '100') {
- $author=$field->{'subfields'}->{'a'};
- }
- if ($field->{'tag'} eq '245') {
- $title=$field->{'subfields'}->{'a'};
- $title=~s/ \/$//;
- $subtitle=$field->{'subfields'}->{'b'};
- $subtitle=~s/ \/$//;
- }
- if ($field->{'tag'} eq '260') {
- $place=$field->{'subfields'}->{'a'};
- if (@$place) {
- $place=$$place[0];
- }
- $place=~s/\s*:$//g;
- $publisher=$field->{'subfields'}->{'b'};
- if (@$publisher) {
- $publisher=$$publisher[0];
- }
- $publisher=~s/\s*:$//g;
- $publicationyear=$field->{'subfields'}->{'c'};
- if ($publicationyear=~/c(\d\d\d\d)/) {
- $copyrightdate=$1;
- }
- if ($publicationyear=~/[^c](\d\d\d\d)/) {
- $publicationyear=$1;
- } elsif ($copyrightdate) {
- $publicationyear=$copyrightdate;
+ print "\n";
}
- my $q_isbn=$dbh->quote((($isbn) || ('NIL')));
- my $q_issn=$dbh->quote((($issn) || ('NIL')));
- my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
- my $q_controlnumber=$dbh->quote((($controlnumber) || ('NIL')));
- my $sth=$dbh->prepare("select * from marcrecorddone where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or controlnumber=$q_controlnumber");
+ } else {
+ my $sth=$dbh->prepare("select marc,name from uploadedmarc where id=$file");
$sth->execute;
- my $donetext='';
- if ($sth->rows) {
- $donetext="DONE";
- }
- $sth=$dbh->prepare("select * from biblioitems where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
- $sth->execute;
- if ($sth->rows) {
- $donetext="DONE";
- }
- if ($isbn) {
- print "$title by $author $donetext \n";
- } elsif ($lccn) {
- print "$title by $author $donetext \n";
- } elsif ($issn) {
- print "$title by $author $donetext\n";
- } elsif ($controlnumber) {
- print "$title by $author $donetext\n";
- } else {
- print "Error: Contact steve regarding $title by $author \n";
+ ($data, $name) = $sth->fetchrow;
+ print << "EOF";
+
+
+Select a New File
+
+
+Select a Record to Import from $name |
+
+EOF
+
+ my @records=parsemarcdata($data);
+ foreach $record (@records) {
+ my ($lccn, $isbn, $issn, $dewey, $author, $title, $place, $publisher, $publicationyear, $volume, $number, @subjects, $note, $controlnumber);
+ foreach $field (@$record) {
+ if ($field->{'tag'} eq '001') {
+ $controlnumber=$field->{'indicator'};
+ }
+ if ($field->{'tag'} eq '010') {
+ $lccn=$field->{'subfields'}->{'a'};
+ $lccn=~s/^\s*//;
+ ($lccn) = (split(/\s+/, $lccn))[0];
+ }
+ if ($field->{'tag'} eq '015') {
+ $lccn=$field->{'subfields'}->{'a'};
+ $lccn=~s/^\s*//;
+ $lccn=~s/^C//;
+ ($lccn) = (split(/\s+/, $lccn))[0];
+ }
+ if ($field->{'tag'} eq '020') {
+ $isbn=$field->{'subfields'}->{'a'};
+ ($isbn=~/ARRAY/) && ($isbn=$$isbn[0]);
+ $isbn=~s/[^\d]*//g;
+ }
+ if ($field->{'tag'} eq '022') {
+ $issn=$field->{'subfields'}->{'a'};
+ $issn=~s/^\s*//;
+ ($issn) = (split(/\s+/, $issn))[0];
+ }
+ if ($field->{'tag'} eq '100') {
+ $author=$field->{'subfields'}->{'a'};
+ }
+ if ($field->{'tag'} eq '245') {
+ $title=$field->{'subfields'}->{'a'};
+ $title=~s/ \/$//;
+ $subtitle=$field->{'subfields'}->{'b'};
+ $subtitle=~s/ \/$//;
+ }
+ }
+ my $q_isbn=$dbh->quote((($isbn) || ('NIL')));
+ my $q_issn=$dbh->quote((($issn) || ('NIL')));
+ my $q_lccn=$dbh->quote((($lccn) || ('NIL')));
+ my $q_controlnumber=$dbh->quote((($controlnumber) || ('NIL')));
+ my $sth=$dbh->prepare("select * from marcrecorddone where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn or controlnumber=$q_controlnumber");
+ $sth->execute;
+ my $donetext='';
+ if ($sth->rows) {
+ $donetext="DONE";
+ }
+ $sth=$dbh->prepare("select * from biblioitems where isbn=$q_isbn or issn=$q_issn or lccn=$q_lccn");
+ $sth->execute;
+ if ($sth->rows) {
+ $donetext="DONE";
+ }
+ ($author) && ($author="by $author");
+ if ($isbn) {
+ print "$title$subtitle $author $donetext \n";
+ } elsif ($lccn) {
+ print "$title$subtitle $author $donetext \n";
+ } elsif ($issn) {
+ print "$title$subtitle $author $donetext\n";
+ } elsif ($controlnumber) {
+ print "$title by $author $donetext\n";
+ } else {
+ print "Error: Contact steve regarding $title by $author \n";
+ }
}
}
print " | \n";
}
} else {
- opendir(D, "/home/$userid/");
- my @dirlist=readdir D;
- foreach $file (@dirlist) {
- (next) if ($file=~/^\./);
- (next) if ($file=~/^nsmail$/);
- (next) if ($file=~/^public_html$/);
- ($file=~/\.mrc/) || ($filelist.="$file \n");
- (next) unless ($file=~/\.mrc$/);
- $file=~s/ /\%20/g;
- print "$file \n";
+
+SWITCH:
+ {
+ if ($menu eq 'z3950') { z3950(); last SWITCH; }
+ if ($menu eq 'uploadmarc') { uploadmarc(); last SWITCH; }
+ if ($menu eq 'manual') { manual(); last SWITCH; }
+ mainmenu();
}
- print << "EOF";
-
+EOF
+}
+
+sub manual {
+}
+
+
+sub mainmenu {
+ print << "EOF";
+Main Menu
+
+EOF
+}
+
+sub skip {
+
+ #opendir(D, "/home/$userid/");
+ #my @dirlist=readdir D;
+ #foreach $file (@dirlist) {
+# (next) if ($file=~/^\./);
+# (next) if ($file=~/^nsmail$/);
+# (next) if ($file=~/^public_html$/);
+# ($file=~/\.mrc/) || ($filelist.="$file \n");
+# (next) unless ($file=~/\.mrc$/);
+# $file=~s/ /\%20/g;
+# print "$file \n";
+# }
+
+
+ # | |