Lines 48-54
C4::Breeding : module to add biblios to import_records via
Link Here
|
48 |
=head1 SYNOPSIS |
48 |
=head1 SYNOPSIS |
49 |
|
49 |
|
50 |
Z3950Search($pars, $template); |
50 |
Z3950Search($pars, $template); |
51 |
($count, @results) = &BreedingSearch($title,$isbn,$random); |
51 |
($count, @results) = &BreedingSearch($title,$isbn); |
52 |
|
52 |
|
53 |
=head1 DESCRIPTION |
53 |
=head1 DESCRIPTION |
54 |
|
54 |
|
Lines 57-66
cataloguing reservoir features.
Link Here
|
57 |
|
57 |
|
58 |
=head2 BreedingSearch |
58 |
=head2 BreedingSearch |
59 |
|
59 |
|
60 |
($count, @results) = &BreedingSearch($title,$isbn,$random); |
60 |
($count, @results) = &BreedingSearch($title,$isbn); |
61 |
C<$title> contains the title, |
61 |
C<$title> contains the title, |
62 |
C<$isbn> contains isbn or issn, |
62 |
C<$isbn> contains isbn or issn, |
63 |
C<$random> contains the random seed from a z3950 search. |
|
|
64 |
|
63 |
|
65 |
C<$count> is the number of items in C<@results>. C<@results> is an |
64 |
C<$count> is the number of items in C<@results>. C<@results> is an |
66 |
array of references-to-hash; the keys are the items from the C<import_records> and |
65 |
array of references-to-hash; the keys are the items from the C<import_records> and |
Lines 69-75
C<import_biblios> tables of the Koha database.
Link Here
|
69 |
=cut |
68 |
=cut |
70 |
|
69 |
|
71 |
sub BreedingSearch { |
70 |
sub BreedingSearch { |
72 |
my ($search,$isbn,$z3950random) = @_; |
71 |
my ($search,$isbn) = @_; |
73 |
my $dbh = C4::Context->dbh; |
72 |
my $dbh = C4::Context->dbh; |
74 |
my $count = 0; |
73 |
my $count = 0; |
75 |
my ($query,@bind); |
74 |
my ($query,@bind); |
Lines 84-108
sub BreedingSearch {
Link Here
|
84 |
JOIN import_records USING (import_record_id) |
83 |
JOIN import_records USING (import_record_id) |
85 |
JOIN import_batches USING (import_batch_id) |
84 |
JOIN import_batches USING (import_batch_id) |
86 |
WHERE "; |
85 |
WHERE "; |
87 |
if ($z3950random) { |
86 |
@bind=(); |
88 |
$query .= "z3950random = ?"; |
87 |
if (defined($search) && length($search)>0) { |
89 |
@bind=($z3950random); |
88 |
$search =~ s/(\s+)/\%/g; |
90 |
} else { |
89 |
$query .= "title like ? OR author like ?"; |
91 |
@bind=(); |
90 |
push(@bind,"%$search%", "%$search%"); |
92 |
if (defined($search) && length($search)>0) { |
|
|
93 |
$search =~ s/(\s+)/\%/g; |
94 |
$query .= "title like ? OR author like ?"; |
95 |
push(@bind,"%$search%", "%$search%"); |
96 |
} |
97 |
if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { |
98 |
$query .= " and "; |
99 |
} |
100 |
if (defined($isbn) && length($isbn)>0) { |
101 |
$query .= "isbn like ?"; |
102 |
push(@bind,"$isbn%"); |
103 |
} |
104 |
} |
91 |
} |
105 |
$sth = $dbh->prepare($query); |
92 |
if ($#bind!=-1 && defined($isbn) && length($isbn)>0) { |
|
|
93 |
$query .= " and "; |
94 |
} |
95 |
if (defined($isbn) && length($isbn)>0) { |
96 |
$query .= "isbn like ?"; |
97 |
push(@bind,"$isbn%"); |
98 |
} |
99 |
$sth = $dbh->prepare($query); |
106 |
$sth->execute(@bind); |
100 |
$sth->execute(@bind); |
107 |
while (my $data = $sth->fetchrow_hashref) { |
101 |
while (my $data = $sth->fetchrow_hashref) { |
108 |
$results[$count] = $data; |
102 |
$results[$count] = $data; |
Lines 307-315
sub _handle_one_result {
Link Here
|
307 |
( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh); |
301 |
( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh); |
308 |
|
302 |
|
309 |
my $batch_id = GetZ3950BatchId($servhref->{servername}); |
303 |
my $batch_id = GetZ3950BatchId($servhref->{servername}); |
310 |
my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0, 0); |
304 |
my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0); |
311 |
#FIXME passing 0 for z3950random |
|
|
312 |
#Will eliminate this unused field in a followup report |
313 |
#Last zero indicates: no update for batch record counts |
305 |
#Last zero indicates: no update for batch record counts |
314 |
|
306 |
|
315 |
|
307 |
|
Lines 491-497
sub _translate_query { #SRU query adjusted per server cf. srufields column
Link Here
|
491 |
|
483 |
|
492 |
=head2 ImportBreedingAuth |
484 |
=head2 ImportBreedingAuth |
493 |
|
485 |
|
494 |
ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random); |
486 |
ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding); |
495 |
|
487 |
|
496 |
ImportBreedingAuth imports MARC records in the reservoir (import_records table). |
488 |
ImportBreedingAuth imports MARC records in the reservoir (import_records table). |
497 |
ImportBreedingAuth is based on the ImportBreeding subroutine. |
489 |
ImportBreedingAuth is based on the ImportBreeding subroutine. |
Lines 499-505
ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random
Link Here
|
499 |
=cut |
491 |
=cut |
500 |
|
492 |
|
501 |
sub ImportBreedingAuth { |
493 |
sub ImportBreedingAuth { |
502 |
my ($marcrecord,$overwrite_auth,$filename,$encoding,$z3950random) = @_; |
494 |
my ($marcrecord,$overwrite_auth,$filename,$encoding) = @_; |
503 |
my $dbh = C4::Context->dbh; |
495 |
my $dbh = C4::Context->dbh; |
504 |
|
496 |
|
505 |
my $batch_id = GetZ3950BatchId($filename); |
497 |
my $batch_id = GetZ3950BatchId($filename); |
Lines 550-556
sub ImportBreedingAuth {
Link Here
|
550 |
if ($breedingid && $overwrite_auth eq '1') { |
542 |
if ($breedingid && $overwrite_auth eq '1') { |
551 |
ModAuthorityInBatch($breedingid, $marcrecord); |
543 |
ModAuthorityInBatch($breedingid, $marcrecord); |
552 |
} else { |
544 |
} else { |
553 |
my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random); |
545 |
my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding); |
554 |
$breedingid = $import_id; |
546 |
$breedingid = $import_id; |
555 |
} |
547 |
} |
556 |
$imported++; |
548 |
$imported++; |
Lines 577-601
sub Z3950SearchAuth {
Link Here
|
577 |
|
569 |
|
578 |
my $dbh = C4::Context->dbh; |
570 |
my $dbh = C4::Context->dbh; |
579 |
my @id= @{$pars->{id}}; |
571 |
my @id= @{$pars->{id}}; |
580 |
my $random= $pars->{random}; |
|
|
581 |
my $page= $pars->{page}; |
572 |
my $page= $pars->{page}; |
582 |
|
573 |
|
583 |
|
574 |
|
584 |
my $show_next = 0; |
575 |
my $show_next = 0; |
585 |
my $total_pages = 0; |
576 |
my $total_pages = 0; |
586 |
my $attr = ''; |
|
|
587 |
my $host; |
588 |
my $server; |
589 |
my $database; |
590 |
my $port; |
591 |
my $marcdata; |
592 |
my @encoding; |
577 |
my @encoding; |
593 |
my @results; |
578 |
my @results; |
594 |
my $count; |
|
|
595 |
my $record; |
596 |
my @serverhost; |
579 |
my @serverhost; |
597 |
my @breeding_loop = (); |
580 |
my @breeding_loop = (); |
598 |
|
|
|
599 |
my @oConnection; |
581 |
my @oConnection; |
600 |
my @oResult; |
582 |
my @oResult; |
601 |
my @errconn; |
583 |
my @errconn; |
Lines 611-617
sub Z3950SearchAuth {
Link Here
|
611 |
foreach my $servid (@id) { |
593 |
foreach my $servid (@id) { |
612 |
my $sth = $dbh->prepare("select * from z3950servers where id=?"); |
594 |
my $sth = $dbh->prepare("select * from z3950servers where id=?"); |
613 |
$sth->execute($servid); |
595 |
$sth->execute($servid); |
614 |
while ( $server = $sth->fetchrow_hashref ) { |
596 |
while ( my $server = $sth->fetchrow_hashref ) { |
615 |
$oConnection[$s] = _create_connection( $server ); |
597 |
$oConnection[$s] = _create_connection( $server ); |
616 |
|
598 |
|
617 |
$oResult[$s] = |
599 |
$oResult[$s] = |
Lines 619-625
sub Z3950SearchAuth {
Link Here
|
619 |
$oConnection[$s]->search_pqf( $zquery ): |
601 |
$oConnection[$s]->search_pqf( $zquery ): |
620 |
$oConnection[$s]->search(new ZOOM::Query::CQL( |
602 |
$oConnection[$s]->search(new ZOOM::Query::CQL( |
621 |
_translate_query( $server, $squery ))); |
603 |
_translate_query( $server, $squery ))); |
622 |
$encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426"); |
604 |
$encoding[$s] = $server->{encoding} // "iso-5426"; |
623 |
$servers[$s] = $server; |
605 |
$servers[$s] = $server; |
624 |
$s++; |
606 |
$s++; |
625 |
} ## while fetch |
607 |
} ## while fetch |
Lines 636-642
sub Z3950SearchAuth {
Link Here
|
636 |
|
618 |
|
637 |
if ( $k != 0 ) { |
619 |
if ( $k != 0 ) { |
638 |
$k--; |
620 |
$k--; |
639 |
my ($error, $errmsg, $addinfo, $diagset)= $oConnection[$k]->error_x(); |
621 |
my ($error )= $oConnection[$k]->error_x(); #ignores errmsg, addinfo, diagset |
640 |
if ($error) { |
622 |
if ($error) { |
641 |
if ($error =~ m/^(10000|10007)$/ ) { |
623 |
if ($error =~ m/^(10000|10007)$/ ) { |
642 |
push(@errconn, {'server' => $serverhost[$k]}); |
624 |
push(@errconn, {'server' => $serverhost[$k]}); |
Lines 667-673
sub Z3950SearchAuth {
Link Here
|
667 |
$heading_authtype_code = GuessAuthTypeCode($marcrecord); |
649 |
$heading_authtype_code = GuessAuthTypeCode($marcrecord); |
668 |
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
650 |
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord }); |
669 |
|
651 |
|
670 |
my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k], $random); |
652 |
my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k]); |
671 |
my %row_data; |
653 |
my %row_data; |
672 |
$row_data{server} = $servers[$k]->{'servername'}; |
654 |
$row_data{server} = $servers[$k]->{'servername'}; |
673 |
$row_data{breedingid} = $breedingid; |
655 |
$row_data{breedingid} = $breedingid; |