@@ -, +, @@ 1 - Create some records using one framework 2 - Export the records 3 - Edit the records to add fields not in original framework 4 - Stage records using a rule that will find matches 5 - Import 6 - Note records contain new fields on display, but they are lost on edit 7 - Apply patch 8 - Stage records again 9 - Select a framework that contains the new fields on import --- C4/ImportBatch.pm | 24 +++++++++++++++---- Koha/BackgroundJob/MARCImportCommitBatch.pm | 15 ++++++++---- .../en/modules/tools/manage-marc-import.tt | 9 +++++++ misc/commit_file.pl | 7 +++++- misc/cronjobs/import_webservice_batch.pl | 5 +++- svc/import_bib | 5 +++- tools/manage-marc-import.pl | 4 +++- 7 files changed, 55 insertions(+), 14 deletions(-) --- a/C4/ImportBatch.pm +++ a/C4/ImportBatch.pm @@ -509,16 +509,30 @@ sub BatchFindDuplicates { =head2 BatchCommitRecords - my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = - BatchCommitRecords( $batch_id, $framework, $progress_interval, $progress_callback, $params ); + Takes a hashref containing params for committing the batch - optional parameters 'progress_interval' and + 'progress_callback' will define code called every X records. + + my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = + BatchCommitRecords({ + batch_id => $batch_id, + framework => $framework, + overlay_framework => $overlay_framework, + progress_interval => $progress_interval, + progress_callback => $progress_callback, + skip_intermediate_commit => $skip_intermediate_commit + }); Parameter skip_intermediate_commit does what is says. - =cut sub BatchCommitRecords { - my ( $batch_id, $framework, $progress_interval, $progress_callback, $params ) = @_; + my $params = shift; + my $batch_id = $params->{batch_id}; + my $framework = $params->{framework}; + my $overlay_framework = $params->{overlay_framework}; my $skip_intermediate_commit = $params->{skip_intermediate_commit}; + my $progress_interval = $params->{progress_interval} // 0; + my $progress_callback = $params->{progress_callback}; $progress_interval = 0 unless $progress_interval && $progress_interval =~ /^\d+$/; $progress_interval = 0 unless ref($progress_callback) eq 'CODE'; @@ -646,7 +660,7 @@ sub BatchCommitRecords { ModBiblio( $marc_record, $recordid, - $oldbiblio->frameworkcode, + $overlay_framework // $oldbiblio->frameworkcode, { overlay_context => $context, skip_record_index => 1 --- a/Koha/BackgroundJob/MARCImportCommitBatch.pm +++ a/Koha/BackgroundJob/MARCImportCommitBatch.pm @@ -59,6 +59,7 @@ sub process { my $import_batch_id = $args->{import_batch_id}; my $frameworkcode = $args->{frameworkcode}; + my $overlay_frameworkcode = $args->{overlay_framework}; my @messages; my $job_progress = 0; @@ -70,11 +71,15 @@ sub process { $self->size($size)->store; ( $num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored ) = - BatchCommitRecords( - $import_batch_id, $frameworkcode, 50, - sub { my $job_progress = shift; $self->progress( $job_progress )->store }, - { skip_intermediate_commit => 1 }, - ); + BatchCommitRecords({ + batch_id => $import_batch_id, + framework => $frameworkcode, + overlay_framework => $overlay_frameworkcode, + progress_interval => 50, + progress_callback => + sub { my $job_progress = shift; $self->progress( $job_progress )->store }, + skip_intermediate_commit => 1, + }); my $count = $num_added + $num_updated; if( $count ) { $self->set({ progress => $count, size => $count }); --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt @@ -271,6 +271,15 @@ [% END %] +
+ When replacing records use this framework: + [% END %]
--- a/misc/commit_file.pl +++ a/misc/commit_file.pl @@ -83,7 +83,12 @@ sub process_batch { print "... importing MARC records -- please wait\n"; my ($num_added, $num_updated, $num_items_added, $num_items_replaced, $num_items_errored, $num_ignored) = - BatchCommitRecords($import_batch_id, $framework, 100, \&print_progress); + BatchCommitRecords({ + batch_id => $import_batch_id, + framework => $framework, + progress_interval => 100, + progress_callback => \&print_progress + }); print "... finished importing MARC records\n"; print <<_SUMMARY_; --- a/misc/cronjobs/import_webservice_batch.pl +++ a/misc/cronjobs/import_webservice_batch.pl @@ -46,4 +46,7 @@ EOF my $batch_ids = GetStagedWebserviceBatches() or exit; $framework ||= ''; -BatchCommitRecords($_, $framework) foreach @$batch_ids; +BatchCommitRecords({ + batch_id => $_, + framework => $framework +}) foreach @$batch_ids; --- a/svc/import_bib +++ a/svc/import_bib @@ -92,7 +92,10 @@ sub import_bib { my $number_of_matches = BatchFindDuplicates($batch_id, $matcher); # XXX we are ignoring the result of this; - BatchCommitRecords($batch_id, $framework) if lc($import_mode) eq 'direct'; + BatchCommitRecords({ + batch_id => $batch_id, + framework => $framework + }) if lc($import_mode) eq 'direct'; my $dbh = C4::Context->dbh(); my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?"); --- a/tools/manage-marc-import.pl +++ a/tools/manage-marc-import.pl @@ -89,11 +89,13 @@ if ($op eq "") { } } elsif ($op eq "commit-batch") { my $frameworkcode = $input->param('framework'); + my $overlay_framework = $input->param('overlay_framework'); try { my $job_id = Koha::BackgroundJob::MARCImportCommitBatch->new->enqueue( { import_batch_id => $import_batch_id, - frameworkcode => $frameworkcode + frameworkcode => $frameworkcode, + overlay_framework => $overlay_framework } ); if ($job_id) { --