Bugzilla – Attachment 84982 Details for
Bug 19164
Allow MARC modification templates to be used in staged MARC imports
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19164: Add MARC modification template support to misc/stage-file.pl.
Bug-19164-Add-MARC-modification-template-support-t.patch (text/plain), 5.45 KB, created by
Jon Knight
on 2019-02-11 16:05:48 UTC
(
hide
)
Description:
Bug 19164: Add MARC modification template support to misc/stage-file.pl.
Filename:
MIME Type:
Creator:
Jon Knight
Created:
2019-02-11 16:05:48 UTC
Size:
5.45 KB
patch
obsolete
>From 710c561cc0795cfe1e994bef7f05da19d7d63bbf Mon Sep 17 00:00:00 2001 >From: Jon Knight <J.P.Knight@lboro.ac.uk> >Date: Mon, 11 Feb 2019 15:50:30 +0000 >Subject: [PATCH] Bug 19164: Add MARC modification template support to > misc/stage-file.pl. >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >https://bugs.koha-community.org/show_bug.cgi?id=19164 > >Bug 19164 - Allow MARC modification templates to be used in staged MARC imports > >Patch checks for duplicate MARC modificiation templates and if only one is >found that matches the name given on the command line, submits the batch >staging of the input files using that template. > >Test plan: > >1) In the staff web client got to "Home ⺠Tools ⺠MARC modification templates" and create a MARC Modification Template called "Test Bug 19164". Set the action to be "Copy field 999$l to 998$l using RegEx s/NASH/FLASH/ if 999$l matches NASH" > >2) Download the test MARC record from this bug into a file called marc1.mrc into your koha dev user's home directory. > >3) Run misc/stage_file.pl with the command line: > > misc/stage_file.pl --file ~/marc1.mrc --add-items --marcmodtemplate "Test Bug 19164" --item-action replace --comment "testing MARC mod templates on batch staging" > >4) In the staff client, go to Home ⺠Tools ⺠Manage staged MARC records and check that the file is visible and in status "Staged" > >5) Click on the filename to bring up details of the staged batch, and then click on "Basic Christianity. Stott, John R. W. (0802811892)". Note that there is a 998$l field with the value "FLASH" that has been created using the MARC Modification Template. >--- > misc/stage_file.pl | 45 +++++++++++++++++++++++++++++++++++++++++---- > 1 file changed, 41 insertions(+), 4 deletions(-) > >diff --git a/misc/stage_file.pl b/misc/stage_file.pl >index 1f11b6a..48074f7 100755 >--- a/misc/stage_file.pl >+++ b/misc/stage_file.pl >@@ -19,8 +19,7 @@ > # with this program; if not, write to the Free Software Foundation, Inc., > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > >-use strict; >-use warnings; >+use Modern::Perl; > BEGIN { > # find Koha's Perl modules > # test carefully before changing this >@@ -31,6 +30,7 @@ BEGIN { > use C4::Context; > use C4::ImportBatch; > use C4::Matcher; >+use C4::MarcModificationTemplates; > use Getopt::Long; > > $| = 1; >@@ -48,6 +48,8 @@ my $no_replace; > my $format = 'ISO2709'; > my $no_create; > my $item_action = 'always_add'; >+my $marc_mod_template = ''; >+my $marc_mod_template_id = undef; > > my $result = GetOptions( > 'encoding:s' => \$encoding, >@@ -60,9 +62,30 @@ my $result = GetOptions( > 'no-create' => \$no_create, > 'comment:s' => \$batch_comment, > 'authorities' => \$authorities, >+ 'marcmodtemplate:s' => \$marc_mod_template, > 'h|help' => \$want_help > ); > >+if($marc_mod_template ne '') { >+ my @templates = GetModificationTemplates(); >+ foreach my $this_template (@templates) { >+ if($this_template->{'name'} eq $marc_mod_template) { >+ if(!defined $marc_mod_template_id) { >+ $marc_mod_template_id = $this_template->{'template_id'}; >+ } else { >+ print "WARNING: MARC modification template name " . >+ "'$marc_mod_template' matches multiple templates. " . >+ "Please fix this issue before proceeding.\n"; >+ exit 1; >+ } >+ } >+ } >+ >+ if(!defined $marc_mod_template_id ) { >+ die "Can't locate MARC modification template '$marc_mod_template'\n"; >+ } >+} >+ > $record_type = 'auth' if ($authorities); > > if (not $result or $input_file eq "" or $want_help) { >@@ -92,6 +115,7 @@ process_batch({ > no_replace => $no_replace, > no_create => $no_create, > item_action => $item_action, >+ marc_mod_template_id => $marc_mod_template_id, > }); > $dbh->commit(); > >@@ -116,8 +140,13 @@ sub process_batch { > print "... staging MARC records -- please wait\n"; > #FIXME: We should really allow the use of marc modification frameworks and to_marc plugins here if possible > my ($batch_id, $num_valid_records, $num_items, @import_errors) = >- BatchStageMarcRecords($record_type, $params->{encoding}, $marc_records, $params->{input_file}, undef, $params->{batch_comment}, '', $params->{add_items}, 0, >- 100, \&print_progress_and_commit); >+ BatchStageMarcRecords( >+ $record_type, $params->{encoding}, >+ $marc_records, $params->{input_file}, >+ $params->{'marc_mod_template_id'}, >+ $params->{batch_comment}, '', >+ $params->{add_items}, 0, >+ 100, \&print_progress_and_commit); > print "... finished staging MARC records\n"; > > my $num_with_matches = 0; >@@ -218,6 +247,14 @@ Parameters: > the record batch; if the comment > has spaces in it, surround the > comment with quotation marks. >+ --marcmodtemplate <TEMPLATE> >+ This parameter allows you to specify the >+ name of an existing MARC modification >+ template to apply as the MARC records are >+ imported (these templates are created in >+ the "MARC modification templates" tool in >+ Koha). If not specified, no MARC modification >+ templates are used (default). > --help or -h show this message. > _USAGE_ > } >-- >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 19164
:
66351
|
68239
|
68240
|
68249
|
68341
|
68425
|
70033
|
84167
|
84982
|
84987
|
84988