Bugzilla – Attachment 77018 Details for
Bug 15869
Change framework on overlay
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15869: Change framework on overlay
Bug-15869-Change-framework-on-overlay.patch (text/plain), 8.12 KB, created by
Nick Clemens (kidclamp)
on 2018-07-16 17:22:23 UTC
(
hide
)
Description:
Bug 15869: Change framework on overlay
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-07-16 17:22:23 UTC
Size:
8.12 KB
patch
obsolete
>From 43e02b4ba1ad02d1a6d1ec26ad2eb1c33a910e6f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 13 Sep 2016 15:23:50 +0000 >Subject: [PATCH] Bug 15869: Change framework on overlay > >This patch allows for selection of framework to use when overlaying >records - by default it is set to keep the initial framework > >To test: > 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 >10 - Import records >11 - Note records now use selected framework and are displayed/edited >correctly >--- > C4/ImportBatch.pm | 32 +++++++++++++--------- > .../prog/en/modules/tools/manage-marc-import.tt | 9 ++++++ > misc/commit_file.pl | 7 ++++- > misc/cronjobs/import_webservice_batch.pl | 6 +++- > svc/import_bib | 5 +++- > tools/manage-marc-import.pl | 16 ++++++++--- > 6 files changed, 55 insertions(+), 20 deletions(-) > >diff --git a/C4/ImportBatch.pm b/C4/ImportBatch.pm >index 3727f41..f44aef4 100644 >--- a/C4/ImportBatch.pm >+++ b/C4/ImportBatch.pm >@@ -550,26 +550,32 @@ sub BatchFindDuplicates { > > =head2 BatchCommitRecords > >+ 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, $framework, >- $progress_interval, $progress_callback); >+ BatchCommitRecords({ >+ batch_id => $batch_id, >+ framework => $framework, >+ overlay_framework => $overlay_framework, >+ progress_interval => $progress_interval, >+ progress_callback => $progress_callback >+ }); > > =cut > > sub BatchCommitRecords { >- my $batch_id = shift; >- my $framework = shift; >+ my $params = shift; >+ my $batch_id = $params->{batch_id}; >+ my $framework = $params->{framework}; >+ my $overlay_framework = $params->{overlay_framework}; > > # optional callback to monitor status > # of job >- my $progress_interval = 0; >- my $progress_callback = undef; >- if ($#_ == 1) { >- $progress_interval = shift; >- $progress_callback = shift; >- $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0; >- $progress_interval = 0 unless 'CODE' eq ref $progress_callback; >- } >+ my $progress_interval = $params->{progress_interval} // 0; >+ my $progress_callback = $params->{progress_callback}; >+ $progress_interval = 0 unless $progress_interval =~ /^\d+$/ and $progress_interval > 0; >+ $progress_interval = 0 unless 'CODE' eq ref $progress_callback; > > my $record_type; > my $num_added = 0; >@@ -666,7 +672,7 @@ sub BatchCommitRecords { > } > $oldxml = $old_marc->as_xml($marc_type); > >- ModBiblio($marc_record, $recordid, $oldbiblio->frameworkcode); >+ ModBiblio($marc_record, $recordid, $overlay_framework // $oldbiblio->frameworkcode); > $query = "UPDATE import_biblios SET matched_biblionumber = ? WHERE import_record_id = ?"; > > if ($item_result eq 'create_new' || $item_result eq 'replace') { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >index cff595a..4260d84 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/manage-marc-import.tt >@@ -211,6 +211,15 @@ > <option value="[% framework.frameworkcode %]">[% framework.frameworktext %]</option> > [% END %] > </select> >+ <br/> >+ When replacing records use this framework: >+ <select name="overlay_framework" id="overlay_frameworks"> >+ <option value="_USE_ORIG_">Keep original framework</option> >+ <option value="">Default</option> >+ [% FOREACH framework IN frameworks %] >+ <option value="[% framework.value %]">[% framework.label %]</option> >+ [% END %] >+ </select> > [% END %] > <br/> > <input type="submit" class="button" name="mainformsubmit" value="Import this batch into the catalog" /> >diff --git a/misc/commit_file.pl b/misc/commit_file.pl >index bd29df3..6354015 100755 >--- a/misc/commit_file.pl >+++ b/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, '', 100, \&print_progress_and_commit); >+ BatchCommitRecords({ >+ batch_id => $import_batch_id, >+ framework => '', >+ progress_interval => 100, >+ progress_callback => \&print_progress_and_commit >+ }); > print "... finished importing MARC records\n"; > > print <<_SUMMARY_; >diff --git a/misc/cronjobs/import_webservice_batch.pl b/misc/cronjobs/import_webservice_batch.pl >index 0e1384f..99303f9 100755 >--- a/misc/cronjobs/import_webservice_batch.pl >+++ b/misc/cronjobs/import_webservice_batch.pl >@@ -54,4 +54,8 @@ EOF > my $batch_ids = GetStagedWebserviceBatches() or exit; > > $framework ||= ''; >-BatchCommitRecords($_, $framework) foreach @$batch_ids; >+BatchCommitRecords({ >+ batch_id => $_, >+ framework => $framework >+}) foreach @$batch_ids; >+ >diff --git a/svc/import_bib b/svc/import_bib >index 8577036..1d4fa56 100755 >--- a/svc/import_bib >+++ b/svc/import_bib >@@ -88,7 +88,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 =?"); >diff --git a/tools/manage-marc-import.pl b/tools/manage-marc-import.pl >index 4fea400..8afa6c8 100755 >--- a/tools/manage-marc-import.pl >+++ b/tools/manage-marc-import.pl >@@ -99,7 +99,8 @@ if ($op eq "") { > add_saved_job_results_to_template($template, $completedJobID); > } else { > my $framework = $input->param('framework'); >- commit_batch($template, $import_batch_id, $framework); >+ my $overlay_framework = $input->param('overlay_framework'); >+ commit_batch($template, $import_batch_id, $framework, $overlay_framework); > } > import_records_list($template, $import_batch_id, $offset, $results_per_page); > } elsif ($op eq "revert-batch") { >@@ -230,7 +231,7 @@ sub import_batches_list { > } > > sub commit_batch { >- my ($template, $import_batch_id, $framework) = @_; >+ my ($template, $import_batch_id, $framework, $overlay_framework) = @_; > > my $job = undef; > my ( $num_added, $num_updated, $num_items_added, >@@ -243,12 +244,19 @@ sub commit_batch { > $job = put_in_background($import_batch_id); > $callback = progress_callback( $job, $dbh ); > } >+ my $params = { >+ batch_id => $import_batch_id, >+ framework => $framework, >+ progress_interval => 50, >+ progress_callback => $callback >+ }; >+ $params->{overlay_framework} = $overlay_framework unless $overlay_framework eq '_USE_ORIG_'; >+ > ( > $num_added, $num_updated, $num_items_added, > $num_items_replaced, $num_items_errored, $num_ignored > ) >- = BatchCommitRecords( $import_batch_id, $framework, 50, >- $callback ); >+ = BatchCommitRecords($params); > } > ); > >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15869
:
55543
|
70800
|
77018
|
140857
|
140858
|
142257
|
142258
|
143033
|
145271
|
145272
|
145273
|
145274
|
145406