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

(-)a/C4/Breeding.pm (-3 / +4 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 137-143 sub ImportBreeding { Link Here
137
                    if ($breedingid && $overwrite_biblio eq '1') {
138
                    if ($breedingid && $overwrite_biblio eq '1') {
138
                        ModBiblioInBatch($breedingid, $marcrecord);
139
                        ModBiblioInBatch($breedingid, $marcrecord);
139
                    } else {
140
                    } else {
140
                        my $import_id = AddBiblioToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random);
141
                        my $import_id = AddBiblioToBatch($batch_id, $imported, $marcrecord, $encoding, $z3950random, $update_counts);
141
                        $breedingid = $import_id;
142
                        $breedingid = $import_id;
142
                    }
143
                    }
143
                    $imported++;
144
                    $imported++;
Lines 145-151 sub ImportBreeding { Link Here
145
            }
146
            }
146
        }
147
        }
147
    }
148
    }
148
    return ($notmarcrecord,$alreadyindb,$alreadyinfarm,$imported,$breedingid);
149
    return ( $notmarcrecord, $alreadyindb, $alreadyinfarm, $imported, $breedingid, $batch_id );
149
}
150
}
150
151
151
152
(-)a/C4/ImportBatch.pm (+6 lines)
Lines 73-78 BEGIN { Link Here
73
    SetImportRecordStatus
73
    SetImportRecordStatus
74
    GetImportRecordMatches
74
    GetImportRecordMatches
75
    SetImportRecordMatches
75
    SetImportRecordMatches
76
77
    UpdateBatchRecordCounts
76
	);
78
	);
77
}
79
}
78
80
Lines 1310-1315 sub _update_batch_record_counts { Link Here
1310
    $sth->finish();
1312
    $sth->finish();
1311
}
1313
}
1312
1314
1315
sub UpdateBatchRecordCounts {
1316
    return _update_batch_record_counts( @_ );
1317
}
1318
1313
sub _get_commit_action {
1319
sub _get_commit_action {
1314
    my ($overlay_action, $nomatch_action, $item_action, $overlay_status, $import_record_id) = @_;
1320
    my ($overlay_action, $nomatch_action, $item_action, $overlay_status, $import_record_id) = @_;
1315
    
1321
    
(-)a/acqui/z3950_search.pl (-2 / +30 lines)
Lines 32-37 use C4::Koha; Link Here
32
use C4::Charset;
32
use C4::Charset;
33
use C4::Bookseller qw/ GetBookSellerFromId /;
33
use C4::Bookseller qw/ GetBookSellerFromId /;
34
use ZOOM;
34
use ZOOM;
35
use List::MoreUtils qw(uniq);
35
36
36
my $input        = new CGI;
37
my $input        = new CGI;
37
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 230-235 warn "query ".$query if $DEBUG; Link Here
230
231
231
  warn "# nremaining = $nremaining\n" if $DEBUG;
232
  warn "# nremaining = $nremaining\n" if $DEBUG;
232
233
234
  my @batch_id;
233
  while ( $nremaining-- ) {
235
  while ( $nremaining-- ) {
234
236
235
    my $k;
237
    my $k;
Lines 289-297 warn "query ".$query if $DEBUG; Link Here
289
                        $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn};
291
                        $oldbiblio->{issn} =~ s/\(/ \(/g if $oldbiblio->{issn};
290
                          my (
292
                          my (
291
                            $notmarcrecord, $alreadyindb, $alreadyinfarm,
293
                            $notmarcrecord, $alreadyindb, $alreadyinfarm,
292
                            $imported,      $breedingid
294
                            $imported,      $breedingid,  $batch_id
293
                          )
295
                          )
294
                          = ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950' );
296
                          = ImportBreeding( $marcdata, 2, $serverhost[$k], $encoding[$k], $random, 'z3950', 0 );
297
298
                        # Delay the updating of batch record counts until the very end
299
                        push( @batch_id, $batch_id );
300
295
                        my %row_data;
301
                        my %row_data;
296
                        $row_data{server}       = $servername[$k];
302
                        $row_data{server}       = $servername[$k];
297
                        $row_data{isbn}         = $oldbiblio->{isbn};
303
                        $row_data{isbn}         = $oldbiblio->{isbn};
Lines 320-323 breeding_loop => \@breeding_loop, Link Here
320
numberpending => $nremaining > 0 ? $nremaining : 0,
326
numberpending => $nremaining > 0 ? $nremaining : 0,
321
errconn       => \@errconn
327
errconn       => \@errconn
322
);
328
);
329
330
 # Process the delayed batch record count updates
331
my $pid;
332
if ( $pid = fork ) {
333
    # Parent, continue on as usual
334
         
335
    # prevent parent exiting from
336
    # destroying the kid's database handle 
337
    # FIXME: according to DBI doc, this may not work for Oracle
338
    $dbh->{InactiveDestroy}  = 1;
339
} else {
340
    close STDOUT;
341
    close STDERR;
342
         
343
    @batch_id = uniq(@batch_id);
344
    foreach my $bid (@batch_id) {
345
        C4::ImportBatch::UpdateBatchRecordCounts::UpdateBatchRecordCounts($bid);
346
    }
347
            
348
    exit;
349
}
350
323
output_html_with_http_headers $input, $cookie, $template->output;
351
output_html_with_http_headers $input, $cookie, $template->output;
(-)a/cataloguing/z3950_search.pl (-2 / +29 lines)
Lines 30-35 use C4::Context; Link Here
30
use C4::Breeding;
30
use C4::Breeding;
31
use C4::Koha;
31
use C4::Koha;
32
use C4::Charset;
32
use C4::Charset;
33
use List::MoreUtils qw(uniq);
34
33
use ZOOM;
35
use ZOOM;
34
36
35
my $input         = new CGI;
37
my $input         = new CGI;
Lines 70-75 my @serverloop = (); Link Here
70
my @serverhost;
72
my @serverhost;
71
my @servername;
73
my @servername;
72
my @breeding_loop = ();
74
my @breeding_loop = ();
75
my @batch_id;
73
76
74
my ( $start_run, $end_run );
77
my ( $start_run, $end_run );
75
78
Lines 287-296 else { Link Here
287
                        $oldbiblio->{issn} =~ s/\(/ \(/g  if $oldbiblio->{issn};
290
                        $oldbiblio->{issn} =~ s/\(/ \(/g  if $oldbiblio->{issn};
288
                        my (
291
                        my (
289
                            $notmarcrecord, $alreadyindb, $alreadyinfarm,
292
                            $notmarcrecord, $alreadyindb, $alreadyinfarm,
290
                            $imported,      $breedingid
293
                            $imported,      $breedingid,  $batch_id,
291
                          )
294
                          )
292
                          = ImportBreeding( $marcdata, 2, $serverhost[$k],
295
                          = ImportBreeding( $marcdata, 2, $serverhost[$k],
293
                            $encoding[$k], $random, 'z3950' );
296
                            $encoding[$k], $random, 'z3950' );
297
298
                        # Delay the updating of batch record counts until the very end
299
                        push( @batch_id, $batch_id );
300
294
                        my %row_data;
301
                        my %row_data;
295
                        $row_data{server}     = $servername[$k];
302
                        $row_data{server}     = $servername[$k];
296
                        $row_data{isbn}       = $oldbiblio->{isbn};
303
                        $row_data{isbn}       = $oldbiblio->{isbn};
Lines 329-334 else { Link Here
329
        errconn       => \@errconn
336
        errconn       => \@errconn
330
    );
337
    );
331
338
339
    # Process the delayed batch record count updates
340
    my $pid;
341
    if ( $pid = fork ) {
342
        # Parent, continue on as usual
343
344
        # prevent parent exiting from
345
        # destroying the kid's database handle
346
        # FIXME: according to DBI doc, this may not work for Oracle
347
        $dbh->{InactiveDestroy} = 1;
348
    } else {
349
        close STDOUT;
350
        close STDERR;
351
352
        @batch_id = uniq(@batch_id);
353
        foreach my $bid (@batch_id) {
354
            C4::ImportBatch::UpdateBatchRecordCounts($bid);
355
        }
356
357
        exit;
358
    }
359
332
    if ( $numberpending == 0 ) {
360
    if ( $numberpending == 0 ) {
333
        $end_run = time();
361
        $end_run = time();
334
        $template->param( run_time => $end_run - $start_run );
362
        $template->param( run_time => $end_run - $start_run );
335
- 

Return to bug 10004