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

(-)a/C4/ImportBatch.pm (-5 / +19 lines)
Lines 509-524 sub BatchFindDuplicates { Link Here
509
509
510
=head2 BatchCommitRecords
510
=head2 BatchCommitRecords
511
511
512
    my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
512
  Takes a hashref containing params for committing the batch - optional parameters 'progress_interval' and
513
        BatchCommitRecords( $batch_id, $framework, $progress_interval, $progress_callback, $params );
513
  'progress_callback' will define code called every X records.
514
515
  my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
516
        BatchCommitRecords({
517
            batch_id  => $batch_id,
518
            framework => $framework,
519
            overlay_framework => $overlay_framework,
520
            progress_interval => $progress_interval,
521
            progress_callback => $progress_callback,
522
            skip_intermediate_commit => $skip_intermediate_commit
523
        });
514
524
515
    Parameter skip_intermediate_commit does what is says.
525
    Parameter skip_intermediate_commit does what is says.
516
517
=cut
526
=cut
518
527
519
sub BatchCommitRecords {
528
sub BatchCommitRecords {
520
    my ( $batch_id, $framework, $progress_interval, $progress_callback, $params ) = @_;
529
    my $params = shift;
530
    my $batch_id          = $params->{batch_id};
531
    my $framework         = $params->{framework};
532
    my $overlay_framework = $params->{overlay_framework};
521
    my $skip_intermediate_commit = $params->{skip_intermediate_commit};
533
    my $skip_intermediate_commit = $params->{skip_intermediate_commit};
534
    my $progress_interval = $params->{progress_interval} // 0;
535
    my $progress_callback = $params->{progress_callback};
522
    $progress_interval = 0 unless $progress_interval && $progress_interval =~ /^\d+$/;
536
    $progress_interval = 0 unless $progress_interval && $progress_interval =~ /^\d+$/;
523
    $progress_interval = 0 unless ref($progress_callback) eq 'CODE';
537
    $progress_interval = 0 unless ref($progress_callback) eq 'CODE';
524
538
Lines 646-652 sub BatchCommitRecords { Link Here
646
                ModBiblio(
660
                ModBiblio(
647
                    $marc_record,
661
                    $marc_record,
648
                    $recordid,
662
                    $recordid,
649
                    $oldbiblio->frameworkcode,
663
                    $overlay_framework // $oldbiblio->frameworkcode,
650
                    {
664
                    {
651
                        overlay_context   => $context,
665
                        overlay_context   => $context,
652
                        skip_record_index => 1
666
                        skip_record_index => 1
(-)a/Koha/BackgroundJob/MARCImportCommitBatch.pm (-5 / +10 lines)
Lines 59-64 sub process { Link Here
59
59
60
    my $import_batch_id = $args->{import_batch_id};
60
    my $import_batch_id = $args->{import_batch_id};
61
    my $frameworkcode = $args->{frameworkcode};
61
    my $frameworkcode = $args->{frameworkcode};
62
    my $overlay_frameworkcode = $args->{overlay_framework};
62
63
63
    my @messages;
64
    my @messages;
64
    my $job_progress = 0;
65
    my $job_progress = 0;
Lines 70-80 sub process { Link Here
70
        $self->size($size)->store;
71
        $self->size($size)->store;
71
        ( $num_added, $num_updated, $num_items_added,
72
        ( $num_added, $num_updated, $num_items_added,
72
          $num_items_replaced, $num_items_errored, $num_ignored ) =
73
          $num_items_replaced, $num_items_errored, $num_ignored ) =
73
          BatchCommitRecords(
74
          BatchCommitRecords({
74
            $import_batch_id, $frameworkcode, 50,
75
            batch_id => $import_batch_id,
75
            sub { my $job_progress = shift; $self->progress( $job_progress )->store },
76
            framework => $frameworkcode,
76
            { skip_intermediate_commit => 1 },
77
            overlay_framework => $overlay_frameworkcode,
77
        );
78
            progress_interval => 50,
79
            progress_callback =>
80
                sub { my $job_progress = shift; $self->progress( $job_progress )->store },
81
            skip_intermediate_commit => 1,
82
            });
78
        my $count = $num_added + $num_updated;
83
        my $count = $num_added + $num_updated;
79
        if( $count ) {
84
        if( $count ) {
80
            $self->set({ progress => $count, size => $count });
85
            $self->set({ progress => $count, size => $count });
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (+9 lines)
Lines 274-279 Link Here
274
                                                    <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
274
                                                    <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
275
                                                [% END %]
275
                                                [% END %]
276
                                            </select>
276
                                            </select>
277
                                            <br/>
278
                                            When replacing records use this framework:
279
                                            <select name="overlay_framework" id="overlay_frameworks">
280
                                                <option value="_USE_ORIG_">Keep original framework</option>
281
                                                <option value="">Default</option>
282
                                                [% FOREACH framework IN frameworks %]
283
                                                    <option value="[% framework.frameworkcode | html %]">[% framework.frameworktext | html %]</option>
284
                                                [% END %]
285
                                            </select>
277
                                        [% END %]
286
                                        [% END %]
278
                                        <br />
287
                                        <br />
279
                                        <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
288
                                        <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
(-)a/misc/commit_file.pl (-1 / +6 lines)
Lines 83-89 sub process_batch { Link Here
83
83
84
    print "... importing MARC records -- please wait\n";
84
    print "... importing MARC records -- please wait\n";
85
    my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
85
    my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
86
        BatchCommitRecords($import_batch_id, $framework, 100, \&print_progress);
86
        BatchCommitRecords({
87
            batch_id => $import_batch_id,
88
            framework => $framework,
89
            progress_interval => 100,
90
            progress_callback => \&print_progress
91
        });
87
    print "... finished importing MARC records\n";
92
    print "... finished importing MARC records\n";
88
93
89
    print <<_SUMMARY_;
94
    print <<_SUMMARY_;
(-)a/misc/cronjobs/import_webservice_batch.pl (-1 / +4 lines)
Lines 46-49 EOF Link Here
46
my $batch_ids = GetStagedWebserviceBatches() or exit;
46
my $batch_ids = GetStagedWebserviceBatches() or exit;
47
47
48
$framework ||= '';
48
$framework ||= '';
49
BatchCommitRecords($_, $framework) foreach @$batch_ids;
49
BatchCommitRecords({
50
    batch_id  => $_,
51
    framework => $framework
52
}) foreach @$batch_ids;
(-)a/svc/import_bib (-1 / +4 lines)
Lines 92-98 sub import_bib { Link Here
92
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
92
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
93
93
94
    # XXX we are ignoring the result of this;
94
    # XXX we are ignoring the result of this;
95
    BatchCommitRecords($batch_id, $framework) if lc($import_mode) eq 'direct';
95
    BatchCommitRecords({
96
        batch_id  => $batch_id,
97
        framework => $framework
98
    }) if lc($import_mode) eq 'direct';
96
99
97
    my $dbh = C4::Context->dbh();
100
    my $dbh = C4::Context->dbh();
98
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
101
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
(-)a/tools/manage-marc-import.pl (-2 / +3 lines)
Lines 89-99 if ($op eq "") { Link Here
89
    }
89
    }
90
} elsif ($op eq "commit-batch") {
90
} elsif ($op eq "commit-batch") {
91
    my $frameworkcode = $input->param('framework');
91
    my $frameworkcode = $input->param('framework');
92
    my $overlay_framework = $input->param('overlay_framework');
92
    try {
93
    try {
93
        my $job_id = Koha::BackgroundJob::MARCImportCommitBatch->new->enqueue(
94
        my $job_id = Koha::BackgroundJob::MARCImportCommitBatch->new->enqueue(
94
            {
95
            {
95
                import_batch_id => $import_batch_id,
96
                import_batch_id => $import_batch_id,
96
                frameworkcode   => $frameworkcode
97
                frameworkcode   => $frameworkcode,
98
                overlay_framework => $overlay_framework
97
            }
99
            }
98
        );
100
        );
99
        if ($job_id) {
101
        if ($job_id) {
100
- 

Return to bug 15869