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

(-)a/C4/ImportBatch.pm (-13 / +19 lines)
Lines 550-575 sub BatchFindDuplicates { Link Here
550
550
551
=head2 BatchCommitRecords
551
=head2 BatchCommitRecords
552
552
553
  Takes a hashref containing params for committing the batch - optional parameters 'progress_interval' and
554
  'progress_callback' will define code called every X records.
555
553
  my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
556
  my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) =
554
        BatchCommitRecords($batch_id, $framework,
557
        BatchCommitRecords({
555
        $progress_interval, $progress_callback);
558
            batch_id  => $batch_id,
559
            framework => $framework,
560
            overlay_framework => $overlay_framework,
561
            progress_interval => $progress_interval,
562
            progress_callback => $progress_callback
563
        });
556
564
557
=cut
565
=cut
558
566
559
sub BatchCommitRecords {
567
sub BatchCommitRecords {
560
    my $batch_id = shift;
568
    my $params = shift;
561
    my $framework = shift;
569
    my $batch_id          = $params->{batch_id};
570
    my $framework         = $params->{framework};
571
    my $overlay_framework = $params->{overlay_framework};
562
572
563
    # optional callback to monitor status 
573
    # optional callback to monitor status 
564
    # of job
574
    # of job
565
    my $progress_interval = 0;
575
    my $progress_interval = $params->{progress_interval} // 0;
566
    my $progress_callback = undef;
576
    my $progress_callback = $params->{progress_callback};
567
    if ($#_ == 1) {
577
    $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0;
568
        $progress_interval = shift;
578
    $progress_interval = 0 unless 'CODE' eq ref $progress_callback;
569
        $progress_callback = shift;
570
        $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0;
571
        $progress_interval = 0 unless 'CODE' eq ref $progress_callback;
572
    }
573
579
574
    my $record_type;
580
    my $record_type;
575
    my $num_added = 0;
581
    my $num_added = 0;
Lines 666-672 sub BatchCommitRecords { Link Here
666
                }
672
                }
667
                $oldxml = $old_marc->as_xml($marc_type);
673
                $oldxml = $old_marc->as_xml($marc_type);
668
674
669
                ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode);
675
                ModBiblio($marc_record, $recordid, $overlay_framework // $oldbiblio->frameworkcode);
670
                $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?";
676
                $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?";
671
677
672
                if ($item_result eq 'create_new' || $item_result eq 'replace') {
678
                if ($item_result eq 'create_new' || $item_result eq 'replace') {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt (+9 lines)
Lines 211-216 Link Here
211
          <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
211
          <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option>
212
      [% END %]
212
      [% END %]
213
    </select>
213
    </select>
214
    <br/>
215
    When replacing records use this framework:
216
    <select name="overlay_framework" id="overlay_frameworks">
217
      <option value="_USE_ORIG_">Keep original framework</option>
218
      <option value="">Default</option>
219
      [% FOREACH framework IN frameworks %]
220
          <option value="[% framework.value %]">[% framework.label %]</option>
221
      [% END %]
222
    </select>
214
    [% END %]
223
    [% END %]
215
    <br/>
224
    <br/>
216
    <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" />
225
    <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, '', 100, \&print_progress_and_commit);
86
        BatchCommitRecords({
87
            batch_id => $import_batch_id,
88
            framework => '',
89
            progress_interval => 100,
90
            progress_callback => \&print_progress_and_commit
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 / +5 lines)
Lines 54-57 EOF Link Here
54
my $batch_ids = GetStagedWebserviceBatches() or exit;
54
my $batch_ids = GetStagedWebserviceBatches() or exit;
55
55
56
$framework ||= '';
56
$framework ||= '';
57
BatchCommitRecords($_, $framework) foreach @$batch_ids;
57
BatchCommitRecords({
58
    batch_id  => $_,
59
    framework => $framework
60
}) foreach @$batch_ids;
61
(-)a/svc/import_bib (-1 / +4 lines)
Lines 88-94 sub import_bib { Link Here
88
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
88
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
89
89
90
    # XXX we are ignoring the result of this;
90
    # XXX we are ignoring the result of this;
91
    BatchCommitRecords($batch_id, $framework) if lc($import_mode) eq 'direct';
91
    BatchCommitRecords({
92
        batch_id  => $batch_id,
93
        framework => $framework
94
    }) if lc($import_mode) eq 'direct';
92
95
93
    my $dbh = C4::Context->dbh();
96
    my $dbh = C4::Context->dbh();
94
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
97
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
(-)a/tools/manage-marc-import.pl (-5 / +12 lines)
Lines 99-105 if ($op eq "") { Link Here
99
        add_saved_job_results_to_template($template, $completedJobID);
99
        add_saved_job_results_to_template($template, $completedJobID);
100
    } else {
100
    } else {
101
        my $framework = $input->param('framework');
101
        my $framework = $input->param('framework');
102
        commit_batch($template, $import_batch_id, $framework);
102
        my $overlay_framework = $input->param('overlay_framework');
103
        commit_batch($template, $import_batch_id, $framework, $overlay_framework);
103
    }
104
    }
104
    import_records_list($template, $import_batch_id, $offset, $results_per_page);
105
    import_records_list($template, $import_batch_id, $offset, $results_per_page);
105
} elsif ($op eq "revert-batch") {
106
} elsif ($op eq "revert-batch") {
Lines 230-236 sub import_batches_list { Link Here
230
}
231
}
231
232
232
sub commit_batch {
233
sub commit_batch {
233
    my ($template, $import_batch_id, $framework) = @_;
234
    my ($template, $import_batch_id, $framework, $overlay_framework) = @_;
234
235
235
    my $job = undef;
236
    my $job = undef;
236
    my ( $num_added, $num_updated, $num_items_added,
237
    my ( $num_added, $num_updated, $num_items_added,
Lines 243-254 sub commit_batch { Link Here
243
                $job = put_in_background($import_batch_id);
244
                $job = put_in_background($import_batch_id);
244
                $callback = progress_callback( $job, $dbh );
245
                $callback = progress_callback( $job, $dbh );
245
            }
246
            }
247
            my $params = {
248
                batch_id  => $import_batch_id,
249
                framework => $framework,
250
                progress_interval => 50,
251
                progress_callback => $callback
252
            };
253
            $params->{overlay_framework} = $overlay_framework unless $overlay_framework eq '_USE_ORIG_';
254
246
            (
255
            (
247
                $num_added, $num_updated, $num_items_added,
256
                $num_added, $num_updated, $num_items_added,
248
                $num_items_replaced, $num_items_errored, $num_ignored
257
                $num_items_replaced, $num_items_errored, $num_ignored
249
              )
258
              )
250
              = BatchCommitRecords( $import_batch_id, $framework, 50,
259
              = BatchCommitRecords($params);
251
                $callback );
252
        }
260
        }
253
    );
261
    );
254
262
255
- 

Return to bug 15869