=head1 SYNOPSIS
Z3950Search($pars, $template);
- ($count, @results) = &BreedingSearch($title,$isbn,$random);
+ ($count, @results) = &BreedingSearch($title,$isbn);
=head1 DESCRIPTION
=head2 BreedingSearch
-($count, @results) = &BreedingSearch($title,$isbn,$random);
+($count, @results) = &BreedingSearch($title,$isbn);
C<$title> contains the title,
C<$isbn> contains isbn or issn,
-C<$random> contains the random seed from a z3950 search.
C<$count> is the number of items in C<@results>. C<@results> is an
array of references-to-hash; the keys are the items from the C<import_records> and
=cut
sub BreedingSearch {
- my ($search,$isbn,$z3950random) = @_;
+ my ($search,$isbn) = @_;
my $dbh = C4::Context->dbh;
my $count = 0;
my ($query,@bind);
JOIN import_records USING (import_record_id)
JOIN import_batches USING (import_batch_id)
WHERE ";
- if ($z3950random) {
- $query .= "z3950random = ?";
- @bind=($z3950random);
- } else {
- @bind=();
- if (defined($search) && length($search)>0) {
- $search =~ s/(\s+)/\%/g;
- $query .= "title like ? OR author like ?";
- push(@bind,"%$search%", "%$search%");
- }
- if ($#bind!=-1 && defined($isbn) && length($isbn)>0) {
- $query .= " and ";
- }
- if (defined($isbn) && length($isbn)>0) {
- $query .= "isbn like ?";
- push(@bind,"$isbn%");
- }
+ @bind=();
+ if (defined($search) && length($search)>0) {
+ $search =~ s/(\s+)/\%/g;
+ $query .= "title like ? OR author like ?";
+ push(@bind,"%$search%", "%$search%");
}
- $sth = $dbh->prepare($query);
+ if ($#bind!=-1 && defined($isbn) && length($isbn)>0) {
+ $query .= " and ";
+ }
+ if (defined($isbn) && length($isbn)>0) {
+ $query .= "isbn like ?";
+ push(@bind,"$isbn%");
+ }
+ $sth = $dbh->prepare($query);
$sth->execute(@bind);
while (my $data = $sth->fetchrow_hashref) {
$results[$count] = $data;
( $marcrecord, $error ) = _do_xslt_proc($marcrecord, $servhref, $xslh);
my $batch_id = GetZ3950BatchId($servhref->{servername});
- my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0, 0);
- #FIXME passing 0 for z3950random
- #Will eliminate this unused field in a followup report
+ my $breedingid = AddBiblioToBatch($batch_id, $seq, $marcrecord, 'UTF-8', 0);
#Last zero indicates: no update for batch record counts
=head2 ImportBreedingAuth
-ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding,$z3950random);
+ImportBreedingAuth($marcrecords,$overwrite_auth,$filename,$encoding);
ImportBreedingAuth imports MARC records in the reservoir (import_records table).
ImportBreedingAuth is based on the ImportBreeding subroutine.
=cut
sub ImportBreedingAuth {
- my ($marcrecord,$overwrite_auth,$filename,$encoding,$z3950random) = @_;
+ my ($marcrecord,$overwrite_auth,$filename,$encoding) = @_;
my $dbh = C4::Context->dbh;
my $batch_id = GetZ3950BatchId($filename);
if ($breedingid && $overwrite_auth eq '1') {
ModAuthorityInBatch($breedingid, $marcrecord);
} else {
- my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random);
+ my $import_id = AddAuthToBatch($batch_id, $imported, $marcrecord, $encoding);
$breedingid = $import_id;
}
$imported++;
my $dbh = C4::Context->dbh;
my @id= @{$pars->{id}};
- my $random= $pars->{random};
my $page= $pars->{page};
my $show_next = 0;
my $total_pages = 0;
- my $attr = '';
- my $host;
- my $server;
- my $database;
- my $port;
- my $marcdata;
my @encoding;
my @results;
- my $count;
- my $record;
my @serverhost;
my @breeding_loop = ();
-
my @oConnection;
my @oResult;
my @errconn;
foreach my $servid (@id) {
my $sth = $dbh->prepare("select * from z3950servers where id=?");
$sth->execute($servid);
- while ( $server = $sth->fetchrow_hashref ) {
+ while ( my $server = $sth->fetchrow_hashref ) {
$oConnection[$s] = _create_connection( $server );
$oResult[$s] =
$oConnection[$s]->search_pqf( $zquery ):
$oConnection[$s]->search(new ZOOM::Query::CQL(
_translate_query( $server, $squery )));
- $encoding[$s] = ($server->{encoding}?$server->{encoding}:"iso-5426");
+ $encoding[$s] = $server->{encoding} // "iso-5426";
$servers[$s] = $server;
$s++;
} ## while fetch
if ( $k != 0 ) {
$k--;
- my ($error, $errmsg, $addinfo, $diagset)= $oConnection[$k]->error_x();
+ my ($error )= $oConnection[$k]->error_x(); #ignores errmsg, addinfo, diagset
if ($error) {
if ($error =~ m/^(10000|10007)$/ ) {
push(@errconn, {'server' => $serverhost[$k]});
$heading_authtype_code = GuessAuthTypeCode($marcrecord);
$heading = C4::AuthoritiesMarc::GetAuthorizedHeading({ record => $marcrecord });
- my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k], $random);
+ my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreedingAuth( $marcrecord, 2, $serverhost[$k], $encoding[$k]);
my %row_data;
$row_data{server} = $servers[$k]->{'servername'};
$row_data{breedingid} = $breedingid;
=head2 AddBiblioToBatch
my $import_record_id = AddBiblioToBatch($batch_id, $record_sequence,
- $marc_record, $encoding, $z3950random, $update_counts);
+ $marc_record, $encoding, $update_counts);
=cut
my $record_sequence = shift;
my $marc_record = shift;
my $encoding = shift;
- my $z3950random = shift;
my $update_counts = @_ ? shift : 1;
- my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'biblio', $encoding, $z3950random, C4::Context->preference('marcflavour'));
+ my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'biblio', $encoding, C4::Context->preference('marcflavour'));
_add_biblio_fields($import_record_id, $marc_record);
_update_batch_record_counts($batch_id) if $update_counts;
return $import_record_id;
=head2 AddAuthToBatch
my $import_record_id = AddAuthToBatch($batch_id, $record_sequence,
- $marc_record, $encoding, $z3950random, $update_counts, [$marc_type]);
+ $marc_record, $encoding, $update_counts, [$marc_type]);
=cut
my $record_sequence = shift;
my $marc_record = shift;
my $encoding = shift;
- my $z3950random = shift;
my $update_counts = @_ ? shift : 1;
my $marc_type = shift || C4::Context->preference('marcflavour');
$marc_type = 'UNIMARCAUTH' if $marc_type eq 'UNIMARC';
- my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'auth', $encoding, $z3950random, $marc_type);
+ my $import_record_id = _create_import_record($batch_id, $record_sequence, $marc_record, 'auth', $encoding, $marc_type);
_add_auth_fields($import_record_id, $marc_record);
_update_batch_record_counts($batch_id) if $update_counts;
return $import_record_id;
# internal functions
sub _create_import_record {
- my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $z3950random, $marc_type) = @_;
+ my ($batch_id, $record_sequence, $marc_record, $record_type, $encoding, $marc_type) = @_;
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("INSERT INTO import_records (import_batch_id, record_sequence, marc, marcxml, marcxml_old,
- record_type, encoding, z3950random)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
+ record_type, encoding)
+ VALUES (?, ?, ?, ?, ?, ?, ?)");
$sth->execute($batch_id, $record_sequence, $marc_record->as_usmarc(), $marc_record->as_xml($marc_type), '',
- $record_type, $encoding, $z3950random);
+ $record_type, $encoding);
my $import_record_id = $dbh->{'mysql_insertid'};
$sth->finish();
return $import_record_id;