View | Details | Raw Unified | Return to bug 10004
Collapse All | Expand All

(-)a/C4/Breeding.pm (-4 / +31 lines)
Lines 25-30 use C4::Koha; Link Here
25
use C4::Charset;
25
use C4::Charset;
26
use MARC::File::USMARC;
26
use MARC::File::USMARC;
27
use C4::ImportBatch;
27
use C4::ImportBatch;
28
use List::MoreUtils qw(uniq);
28
29
29
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
30
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
30
31
Lines 71-77 C4::Breeding : module to add biblios to import_records via Link Here
71
=cut
72
=cut
72
73
73
sub ImportBreeding {
74
sub ImportBreeding {
74
    my ($marcrecords,$overwrite_biblio,$filename,$encoding,$z3950random,$batch_type) = @_;
75
    my ( $marcrecords, $overwrite_biblio, $filename, $encoding, $z3950random, $batch_type, $update_counts ) = @_;
75
    my @marcarray = split /\x1D/, $marcrecords;
76
    my @marcarray = split /\x1D/, $marcrecords;
76
    
77
    
77
    my $dbh = C4::Context->dbh;
78
    my $dbh = C4::Context->dbh;
Lines 140-146 sub ImportBreeding { Link Here
140
                    if ($breedingid && $overwrite_biblio eq '1') {
141
                    if ($breedingid && $overwrite_biblio eq '1') {
141
                        ModBiblioInBatch($breedingid, $marcrecord);
142
                        ModBiblioInBatch($breedingid, $marcrecord);
142
                    } else {
143
                    } else {
143
                        my $import_id = AddBiblioToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random);
144
                        my $import_id = AddBiblioToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random, $update_counts);
144
                        $breedingid = $import_id;
145
                        $breedingid = $import_id;
145
                    }
146
                    }
146
                    $imported++;
147
                    $imported++;
Lines 148-154 sub ImportBreeding { Link Here
148
            }
149
            }
149
        }
150
        }
150
    }
151
    }
151
    return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid);
152
    return ( $notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid, $batch_id );
152
}
153
}
153
154
154
155
Lines 341-346 sub Z3950Search { Link Here
341
        $oResult[$z] = $oConnection[$z]->search_pqf($query);
342
        $oResult[$z] = $oConnection[$z]->search_pqf($query);
342
    }
343
    }
343
344
345
    my @batch_id;
344
    while ( $nremaining-- ) {
346
    while ( $nremaining-- ) {
345
        my $k;
347
        my $k;
346
        my $event;
348
        my $event;
Lines 382-388 sub Z3950Search { Link Here
382
                            # pad | and ( with spaces to allow line breaks in the HTML
384
                            # pad | and ( with spaces to allow line breaks in the HTML
383
                            $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn};
385
                            $oldbiblio->{issn} =~ s/\|/ \| /g if $oldbiblio->{issn};
384
                            $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn};
386
                            $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn};
385
                            my ($notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid)= ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' );
387
388
                            my ( $notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid, $batch_id ) =
389
                              ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950', 0 );
390
391
                            # Delay the updating of batch record counts until the very end
392
                            push( @batch_id, $batch_id );
393
386
                            my %row_data;
394
                            my %row_data;
387
                            $row_data{server}       = $servername[$k];
395
                            $row_data{server}       = $servername[$k];
388
                            $row_data{isbn}         = $oldbiblio->{isbn};
396
                            $row_data{isbn}         = $oldbiblio->{isbn};
Lines 427-432 sub Z3950Search { Link Here
427
        servers => \@servers,
435
        servers => \@servers,
428
        errconn       => \@errconn
436
        errconn       => \@errconn
429
    );
437
    );
438
439
    # Process the delayed batch record count updates
440
    my $pid;
441
    if ( $pid = fork ) {
442
        # Parent, continue on as usual
443
444
        # prevent parent exiting from
445
        # destroying the kid's database handle 
446
        # FIXME: according to DBI doc, this may not work for Oracle
447
        $dbh->{InactiveDestroy}  = 1;
448
    } else {
449
        close STDOUT;
450
        close STDERR;
451
452
        @batch_id = uniq(@batch_id);
453
        foreach my $bid (@batch_id) {
454
            UpdateBatchRecordCounts($bid);
455
        }
456
    }
430
}
457
}
431
458
432
1;
459
1;
(-)a/C4/ImportBatch.pm (-1 / +6 lines)
Lines 76-81 BEGIN { Link Here
76
    SetImportRecordStatus
76
    SetImportRecordStatus
77
    GetImportRecordMatches
77
    GetImportRecordMatches
78
    SetImportRecordMatches
78
    SetImportRecordMatches
79
80
    UpdateBatchRecordCounts
79
	);
81
	);
80
}
82
}
81
83
Lines 1446-1451 sub _update_batch_record_counts { Link Here
1446
    $sth->finish();
1448
    $sth->finish();
1447
}
1449
}
1448
1450
1451
sub UpdateBatchRecordCounts {
1452
    return _update_batch_record_counts( @_ );
1453
}
1454
1449
sub _get_commit_action {
1455
sub _get_commit_action {
1450
    my ($overlay_action, $nomatch_action, $item_action, $overlay_status, $import_record_id, $record_type) = @_;
1456
    my ($overlay_action, $nomatch_action, $item_action, $overlay_status, $import_record_id, $record_type) = @_;
1451
    
1457
    
1452
- 

Return to bug 10004