Bugzilla – Attachment 125519 Details for
Bug 14957
Write protecting MARC fields based on source of import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14957: (QA follow-up) Rename 'merge' => 'overlay'
Bug-14957-QA-follow-up-Rename-merge--overlay.patch (text/plain), 49.82 KB, created by
Martin Renvoize (ashimema)
on 2021-09-30 13:43:57 UTC
(
hide
)
Description:
Bug 14957: (QA follow-up) Rename 'merge' => 'overlay'
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-09-30 13:43:57 UTC
Size:
49.82 KB
patch
obsolete
>From 706e665294c300b3d513f54a35162f84ffafc2e2 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 26 Mar 2021 13:12:11 -0300 >Subject: [PATCH] Bug 14957: (QA follow-up) Rename 'merge' => 'overlay' > >This patch acknowledges the fact that 'merging' has a different meaning >in Koha than the behavior this great patchset introduces. The more >idiomatic way of describing the behavior is to talk about 'overlay rules'. > >This patch also: >- Fixes kohastructure.sql missing table encoding a collation >- Fixes the atomic update completely missing a table >- Moves the syspref entry to 'Importing', probably a rebase issue > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > C4/Biblio.pm | 43 +++++++----- > .../{MarcMergeRule.pm => MarcOverlayRule.pm} | 22 +++--- > Koha/{MarcMergeRule.pm => MarcOverlayRule.pm} | 10 +-- > ...{MarcMergeRules.pm => MarcOverlayRules.pm} | 44 ++++++------ > ...c-merge-rules.pl => marc-overlay-rules.pl} | 23 +++--- > .../bug_14957-marc-merge-rules.perl | 64 ++++++++++------- > installer/data/mysql/kohastructure.sql | 28 ++++---- > installer/data/mysql/mandatory/sysprefs.sql | 2 +- > .../data/mysql/mandatory/userpermissions.sql | 2 +- > .../prog/en/includes/admin-menu.inc | 4 +- > .../prog/en/includes/permissions.inc | 6 +- > .../prog/en/modules/admin/admin-home.tt | 4 +- > ...c-merge-rules.tt => marc-overlay-rules.tt} | 70 +++++++++---------- > .../admin/preferences/cataloguing.pref | 14 ++-- > .../{MarcMergeRules.t => MarcOverlayRules.t} | 62 ++++++++-------- > 15 files changed, 204 insertions(+), 194 deletions(-) > rename Koha/Exceptions/{MarcMergeRule.pm => MarcOverlayRule.pm} (65%) > rename Koha/{MarcMergeRule.pm => MarcOverlayRule.pm} (83%) > rename Koha/{MarcMergeRules.pm => MarcOverlayRules.pm} (88%) > rename admin/{marc-merge-rules.pl => marc-overlay-rules.pl} (83%) > rename koha-tmpl/intranet-tmpl/prog/en/modules/admin/{marc-merge-rules.tt => marc-overlay-rules.tt} (90%) > rename t/db_dependent/Biblio/{MarcMergeRules.t => MarcOverlayRules.t} (88%) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 8080087d66..59fe6721eb 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -61,7 +61,7 @@ BEGIN { > DelBiblio > BiblioAutoLink > LinkBibHeadingsToAuthorities >- ApplyMarcMergeRules >+ ApplyMarcOverlayRules > TransformMarcToKoha > TransformHtmlToMarc > TransformHtmlToXml >@@ -110,12 +110,12 @@ use Koha::Acquisition::Currencies; > use Koha::Biblio::Metadatas; > use Koha::Holds; > use Koha::ItemTypes; >+use Koha::MarcOverlayRules; > use Koha::Plugins; > use Koha::SearchEngine; > use Koha::SearchEngine::Indexer; > use Koha::Libraries; > use Koha::Util::MARC; >-use Koha::MarcMergeRules; > > =head1 NAME > >@@ -334,9 +334,9 @@ The C<$options> argument is a hashref with additional parameters: > > =item C<context> > >-This parameter is forwared to L</ApplyMarcMergeRules> where it is used for >-selecting the current rule set if Marc Merge Rules is enabled. >-See L</ApplyMarcMergeRules> for more details. >+This parameter is forwarded to L</ApplyMarcOverlayRules> where it is used for >+selecting the current rule set if MARCOverlayRules is enabled. >+See L</ApplyMarcOverlayRules> for more details. > > =item C<disable_autolink> > >@@ -385,12 +385,17 @@ sub ModBiblio { > > _strip_item_fields($record, $frameworkcode); > >- # apply merge rules >- if (C4::Context->preference('MARCMergeRules') && $biblionumber && defined $options && exists $options->{'context'}) { >- $record = ApplyMarcMergeRules({ >+ # apply overlay rules >+ if ( C4::Context->preference('MARCOverlayRules') >+ && $biblionumber >+ && defined $options >+ && exists $options->{'context'} ) >+ { >+ $record = ApplyMarcOverlayRules( >+ { > biblionumber => $biblionumber, >- record => $record, >- context => $options->{'context'}, >+ record => $record, >+ context => $options->{'context'}, > } > ); > } >@@ -3256,9 +3261,9 @@ sub RemoveAllNsb { > return $record; > } > >-=head2 ApplyMarcMergeRules >+=head2 ApplyMarcOverlayRules > >- my $record = ApplyMarcMergeRules($params) >+ my $record = ApplyMarcOverlayRules($params) > > Applies marc merge rules to a record. > >@@ -3294,30 +3299,28 @@ fields with this field tag from C<record>. > > =cut > >-sub ApplyMarcMergeRules { >+sub ApplyMarcOverlayRules { > my ($params) = @_; > my $biblionumber = $params->{biblionumber}; > my $incoming_record = $params->{record}; > > if (!$biblionumber) { >- carp 'ApplyMarcMergeRules called on undefined biblionumber'; >+ carp 'ApplyMarcOverlayRules called on undefined biblionumber'; > return; > } > if (!$incoming_record) { >- carp 'ApplyMarcMergeRules called on undefined record'; >+ carp 'ApplyMarcOverlayRules called on undefined record'; > return; > } > my $old_record = GetMarcBiblio({ biblionumber => $biblionumber }); > >- # Skip merge rules if called with no context >+ # Skip overlay rules if called with no context > if ($old_record && defined $params->{context}) { >- return Koha::MarcMergeRules->merge_records($old_record, $incoming_record, $params->{context}); >+ return Koha::MarcOverlayRules->merge_records($old_record, $incoming_record, $params->{context}); > } > return $incoming_record; > } > >-1; >- > =head2 _after_biblio_action_hooks > > Helper method that takes care of calling all plugin hooks >@@ -3341,6 +3344,8 @@ sub _after_biblio_action_hooks { > ); > } > >+1; >+ > __END__ > > =head1 AUTHOR >diff --git a/Koha/Exceptions/MarcMergeRule.pm b/Koha/Exceptions/MarcOverlayRule.pm >similarity index 65% >rename from Koha/Exceptions/MarcMergeRule.pm >rename to Koha/Exceptions/MarcOverlayRule.pm >index a3cd708c45..f3596022e7 100644 >--- a/Koha/Exceptions/MarcMergeRule.pm >+++ b/Koha/Exceptions/MarcOverlayRule.pm >@@ -1,4 +1,4 @@ >-package Koha::Exceptions::MarcMergeRule; >+package Koha::Exceptions::MarcOverlayRule; > > # This file is part of Koha. > # >@@ -19,34 +19,34 @@ use Modern::Perl; > > use Exception::Class ( > >- 'Koha::Exceptions::MarcMergeRule' => { >+ 'Koha::Exceptions::MarcOverlayRule' => { > description => 'Something went wrong!', > }, >- 'Koha::Exceptions::MarcMergeRule::InvalidTagRegExp' => { >- isa => 'Koha::Exceptions::MarcMergeRule', >+ 'Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp' => { >+ isa => 'Koha::Exceptions::MarcOverlayRule', > description => 'Invalid regular expression for tag' > }, >- 'Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions' => { >- isa => 'Koha::Exceptions::MarcMergeRule', >+ 'Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions' => { >+ isa => 'Koha::Exceptions::MarcOverlayRule', > description => 'Invalid control field actions' > } > ); > > =head1 NAME > >-Koha::Exceptions::MarcMergeRule - Base class for MarcMergeRule exceptions >+Koha::Exceptions::MarcOverlayRule - Base class for MarcOverlayRule exceptions > > =head1 Exceptions > >-=head2 Koha::Exceptions::MarcMergeRule >+=head2 Koha::Exceptions::MarcOverlayRule > >-Generic MarcMergeRule exception >+Generic MarcOverlayRule exception > >-=head2 Koha::Exceptions::MarcMergeRule::InvalidTagRegExp >+=head2 Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp > > Exception for rule validation when rule tag is an invalid regular expression > >-=head2 Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions >+=head2 Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions > > Exception for rule validation for control field rules with invalid combination of actions > >diff --git a/Koha/MarcMergeRule.pm b/Koha/MarcOverlayRule.pm >similarity index 83% >rename from Koha/MarcMergeRule.pm >rename to Koha/MarcOverlayRule.pm >index d1bdbbac18..9a753ef544 100644 >--- a/Koha/MarcMergeRule.pm >+++ b/Koha/MarcOverlayRule.pm >@@ -1,4 +1,4 @@ >-package Koha::MarcMergeRule; >+package Koha::MarcOverlayRule; > > # This file is part of Koha. > # >@@ -23,7 +23,7 @@ my $cache = Koha::Caches->get_instance(); > > =head1 NAME > >-Koha::MarcMergeRule - Koha MarcMergeRule Object class >+Koha::MarcOverlayRule - Koha MarcOverlayRule Object class > > =cut > >@@ -35,7 +35,7 @@ Override C<store> to clear marc merge rules cache. > > sub store { > my $self = shift @_; >- $cache->clear_from_cache('marc_merge_rules'); >+ $cache->clear_from_cache('marc_overlay_rules'); > $self->SUPER::store(@_); > } > >@@ -47,12 +47,12 @@ Override C<delete> to clear marc merge rules cache. > > sub delete { > my $self = shift @_; >- $cache->clear_from_cache('marc_merge_rules'); >+ $cache->clear_from_cache('marc_overlay_rules'); > $self->SUPER::delete(@_); > } > > sub _type { >- return 'MarcMergeRule'; >+ return 'MarcOverlayRule'; > } > > 1; >diff --git a/Koha/MarcMergeRules.pm b/Koha/MarcOverlayRules.pm >similarity index 88% >rename from Koha/MarcMergeRules.pm >rename to Koha/MarcOverlayRules.pm >index 555402ff22..11b33d1928 100644 >--- a/Koha/MarcMergeRules.pm >+++ b/Koha/MarcOverlayRules.pm >@@ -1,4 +1,4 @@ >-package Koha::MarcMergeRules; >+package Koha::MarcOverlayRules; > > # This file is part of Koha. > # >@@ -17,10 +17,10 @@ package Koha::MarcMergeRules; > > use Modern::Perl; > use List::Util qw(first); >-use Koha::MarcMergeRule; >+use Koha::MarcOverlayRule; > use Carp; > >-use Koha::Exceptions::MarcMergeRule; >+use Koha::Exceptions::MarcOverlayRule; > use Try::Tiny; > use Scalar::Util qw(looks_like_number); > >@@ -30,11 +30,11 @@ my $cache = Koha::Caches->get_instance(); > > =head1 NAME > >-Koha::MarcMergeRules - Koha MarcMergeRules Object set class >+Koha::MarcOverlayRules - Koha MarcOverlayRules Object set class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods > > =head3 operations > >@@ -48,9 +48,9 @@ sub operations { > > =head3 context_rules > >- my $rules = Koha::MarcMergeRules->context_rules($context); >+ my $rules = Koha::MarcOverlayRules->context_rules($context); > >-Gets all MARC merge rules for the supplied C<$context> (hashref with { module => filter, ... } values). >+Gets all MARC overlay rules for the supplied C<$context> (hashref with { module => filter, ... } values). > > =cut > >@@ -59,7 +59,7 @@ sub context_rules { > > return unless %{$context}; > >- my $rules = $cache->get_from_cache('marc_merge_rules', { unsafe => 1 }); >+ my $rules = $cache->get_from_cache('marc_overlay_rules', { unsafe => 1 }); > > if (!$rules) { > $rules = {}; >@@ -93,7 +93,7 @@ sub context_rules { > push @{$regexps}, [$rule{tag}, $operations]; > } > } >- $cache->set_in_cache('marc_merge_rules', $rules); >+ $cache->set_in_cache('marc_overlay_rules', $rules); > } > > my $context_rules = undef; >@@ -120,9 +120,9 @@ sub context_rules { > > =head3 merge_records > >- my $merged_record = Koha::MarcMergeRules->merge_records($old_record, $incoming_record, $context); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($old_record, $incoming_record, $context); > >-Merge C<$old_record> with C<$incoming_record> applying merge rules for C<$context>. >+Overlay C<$old_record> with C<$incoming_record> applying overlay rules for C<$context>. > Returns merged record C<$merged_record>. C<$old_record>, C<$incoming_record> and > C<$merged_record> are all MARC::Record objects. > >@@ -289,12 +289,12 @@ sub merge_records { > } > > sub _clear_caches { >- $cache->clear_from_cache('marc_merge_rules'); >+ $cache->clear_from_cache('marc_overlay_rules'); > } > > =head2 find_or_create > >-Override C<find_or_create> to clear marc merge rules cache. >+Override C<find_or_create> to clear marc overlay rules cache. > > =cut > >@@ -306,7 +306,7 @@ sub find_or_create { > > =head2 update > >-Override C<update> to clear marc merge rules cache. >+Override C<update> to clear marc overlay rules cache. > > =cut > >@@ -318,7 +318,7 @@ sub update { > > =head2 delete > >-Override C<delete> to clear marc merge rules cache. >+Override C<delete> to clear marc overlay rules cache. > > =cut > >@@ -330,11 +330,11 @@ sub delete { > > =head2 validate > >- Koha::MarcMergeRules->validate($rule_data); >+ Koha::MarcOverlayRules->validate($rule_data); > >-Validates C<$rule_data>. Throws C<Koha::Exceptions::MarcMergeRule::InvalidTagRegExp> >+Validates C<$rule_data>. Throws C<Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp> > if C<$rule_data->{tag}> contains an invalid regular expression. Throws >-C<Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions> if contains invalid >+C<Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions> if contains invalid > combination of actions for control fields. Otherwise returns true. > > =cut >@@ -346,7 +346,7 @@ sub validate { > if ($rule_data->{tag} ne '*') { > eval { qr/$rule_data->{tag}/ }; > if ($@) { >- Koha::Exceptions::MarcMergeRule::InvalidTagRegExp->throw( >+ Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp->throw( > "Invalid tag regular expression" > ); > } >@@ -358,7 +358,7 @@ sub validate { > $rule_data->{append} && > !$rule_data->{remove} > ) { >- Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions->throw( >+ Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions->throw( > "Combination of allow append and skip remove not permitted for control fields" > ); > } >@@ -367,7 +367,7 @@ sub validate { > } > > sub _type { >- return 'MarcMergeRule'; >+ return 'MarcOverlayRule'; > } > > =head3 object_class >@@ -375,7 +375,7 @@ sub _type { > =cut > > sub object_class { >- return 'Koha::MarcMergeRule'; >+ return 'Koha::MarcOverlayRule'; > } > > 1; >diff --git a/admin/marc-merge-rules.pl b/admin/marc-overlay-rules.pl >similarity index 83% >rename from admin/marc-merge-rules.pl >rename to admin/marc-overlay-rules.pl >index 0c9a5433fe..e143f6c448 100755 >--- a/admin/marc-merge-rules.pl >+++ b/admin/marc-overlay-rules.pl >@@ -34,11 +34,10 @@ use C4::ImportBatch; > use C4::Matcher; > use C4::BackgroundJob; > use C4::Labels::Batch; >-use Koha::MarcMergeRules; >-use Koha::MarcMergeRule; >-use Koha::Patron::Categories; # TODO: Required? Try without use >+use Koha::MarcOverlayRules; >+use Koha::Patron::Categories; > >-my $script_name = "/cgi-bin/koha/admin/marc-merge-rules.pl"; >+my $script_name = "/cgi-bin/koha/admin/marc-overlay-rules.pl"; > > my $input = new CGI; > my $op = $input->param('op') || ''; >@@ -67,11 +66,11 @@ my $rule_from_cgi = sub { > > my ($template, $loggedinuser, $cookie) = get_template_and_user( > { >- template_name => "admin/marc-merge-rules.tt", >+ template_name => "admin/marc-overlay-rules.tt", > query => $input, > type => "intranet", > authnotrequired => 0, >- flagsrequired => { parameters => 'manage_marc_merge_rules' }, >+ flagsrequired => { parameters => 'manage_marc_overlay_rules' }, > debug => 1, > } > ); >@@ -83,7 +82,7 @@ our $sessionID = $cookies{'CGISESSID'}->value; > > my $get_rules = sub { > # TODO: order? >- return [map { { $_->get_columns() } } Koha::MarcMergeRules->_resultset->all]; >+ return [map { { $_->get_columns() } } Koha::MarcOverlayRules->_resultset->all]; > }; > my $rules; > >@@ -101,7 +100,7 @@ if ($op eq 'remove' || $op eq 'doremove') { > elsif ($op eq 'doremove') { > my @remove_ids = $input->multi_param('batchremove'); > push @remove_ids, scalar $input->param('id') if $input->param('id'); >- Koha::MarcMergeRules->search({ id => { in => \@remove_ids } })->delete(); >+ Koha::MarcOverlayRules->search({ id => { in => \@remove_ids } })->delete(); > $rules = $get_rules->(); > } > } >@@ -120,19 +119,19 @@ elsif ($op eq 'doedit' || $op eq 'add') { > my $rule_data = $rule_from_cgi->($input); > if (!@{$errors}) { > try { >- Koha::MarcMergeRules->validate($rule_data); >+ Koha::MarcOverlayRules->validate($rule_data); > } > catch { > die $_ unless blessed $_ && $_->can('rethrow'); > >- if ($_->isa('Koha::Exceptions::MarcMergeRule::InvalidTagRegExp')) { >+ if ($_->isa('Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp')) { > push @{$errors}, { > type => 'error', > code => 'invalid_tag_regexp', > tag => $rule_data->{tag}, > }; > } >- elsif ($_->isa('Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions')) { >+ elsif ($_->isa('Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions')) { > push @{$errors}, { > type => 'error', > code => 'invalid_control_field_actions', >@@ -144,7 +143,7 @@ elsif ($op eq 'doedit' || $op eq 'add') { > } > }; > if (!@{$errors}) { >- my $rule = Koha::MarcMergeRules->find_or_create($rule_data); >+ my $rule = Koha::MarcOverlayRules->find_or_create($rule_data); > # Need to call set and store here in case we have an update > $rule->set($rule_data); > $rule->store(); >diff --git a/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.perl b/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.perl >index e6f1c69c6c..e915f5bc87 100644 >--- a/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.perl >+++ b/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.perl >@@ -1,41 +1,51 @@ > $DBversion = 'XXX'; # will be replaced by the RM > if( CheckVersion( $DBversion ) ) { >- my $sql = q{ >- CREATE TABLE IF NOT EXISTS `marc_merge_rules` ( >- `id` int(11) NOT NULL auto_increment, >- `tag` varchar(255) NOT NULL, >- `module` varchar(127) NOT NULL, >- `filter` varchar(255) NOT NULL, >- `add` tinyint NOT NULL, >- `append` tinyint NOT NULL, >- `remove` tinyint NOT NULL, >- `delete` tinyint NOT NULL, >- PRIMARY KEY(`id`) >- ); >- }; >- $dbh->do( $sql ); > >- $sql = q{ >+ unless (TableExists('marc_overlay_rules_modules')) { >+ $dbh->do(q{ >+ CREATE TABLE `marc_overlay_rules_modules` ( >+ `name` varchar(127) NOT NULL, >+ `description` varchar(255), >+ `specificity` int(11) NOT NULL UNIQUE, >+ PRIMARY KEY(`name`) >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+ }); >+ } >+ >+ unless (TableExists('marc_overlay_rules')) { >+ $dbh->do(q{ >+ CREATE TABLE IF NOT EXISTS `marc_overlay_rules` ( >+ `id` int(11) NOT NULL auto_increment, >+ `tag` varchar(255) NOT NULL, -- can be regexp, so need > 3 chars >+ `module` varchar(127) NOT NULL, >+ `filter` varchar(255) NOT NULL, >+ `add` TINYINT(1) NOT NULL DEFAULT 0, >+ `append` TINYINT(1) NOT NULL DEFAULT 0, >+ `remove` TINYINT(1) NOT NULL DEFAULT 0, >+ `delete` TINYINT(1) NOT NULL DEFAULT 0, >+ PRIMARY KEY(`id`), >+ CONSTRAINT `marc_overlay_rules_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_overlay_rules_modules` (`name`) ON DELETE CASCADE ON UPDATE CASCADE >+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; >+ }); >+ } >+ >+ $dbh->do(q{ > INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ( >- 'MARCMergeRules', >+ 'MARCOverlayRules', > '0', > NULL, >- 'Use the MARC merge rules system to decide what actions to take for each field when modifying records.', >+ 'Use the MARC record overlay rules system to decide what actions to take for each field when modifying records.', > 'YesNo' > ); >- }; >- $dbh->do( $sql ); >+ }); > >- $sql = q{ >+ $dbh->do(q{ > INSERT IGNORE INTO permissions (module_bit, code, description) VALUES ( > 3, >- 'manage_marc_merge_rules', >- 'Manage MARC merge rules configuration' >+ 'manage_marc_overlay_rules', >+ 'Manage MARC overlay rules configuration' > ); >- }; >- $dbh->do( $sql ); >+ }); > >- # Always end with this (adjust the bug info) >- SetVersion( $DBversion ); >- print "Upgrade to $DBversion done (Bug 14957 - Write protecting MARC fields based on source of import)\n"; >+ NewVersion( $DBversion, 14957, "Add a way to define overlay rules for incoming MARC records)\n"; > } >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 7f0e03bbc7..a05410dd04 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3384,11 +3384,11 @@ CREATE TABLE `marc_matchers` ( > /*!40101 SET character_set_client = @saved_cs_client */; > > -- >--- Table structure for table `marc_merge_rules_modules` >+-- Table structure for table `marc_overlay_rules_modules` > -- > >-DROP TABLE IF EXISTS `marc_merge_rules_modules`; >-CREATE TABLE `marc_merge_rules_modules` ( >+DROP TABLE IF EXISTS `marc_overlay_rules_modules`; >+CREATE TABLE `marc_overlay_rules_modules` ( > `name` varchar(127) NOT NULL, > `description` varchar(255), > `specificity` int(11) NOT NULL UNIQUE, >@@ -3396,22 +3396,22 @@ CREATE TABLE `marc_merge_rules_modules` ( > ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- >--- Table structure for table `marc_merge_rules` >+-- Table structure for table `marc_overlay_rules` > -- > >-DROP TABLE IF EXISTS `marc_merge_rules`; >-CREATE TABLE IF NOT EXISTS `marc_merge_rules` ( >- `id` int(11) NOT NULL auto_increment, >- `tag` varchar(255) NOT NULL, -- can be regexp, so need > 3 chars >+DROP TABLE IF EXISTS `marc_overlay_rules`; >+CREATE TABLE IF NOT EXISTS `marc_overlay_rules` ( >+ `id` int(11) NOT NULL auto_increment, >+ `tag` varchar(255) NOT NULL, -- can be regexp, so need > 3 chars > `module` varchar(127) NOT NULL, > `filter` varchar(255) NOT NULL, >- `add` tinyint NOT NULL, >- `append` tinyint NOT NULL, >- `remove` tinyint NOT NULL, >- `delete` tinyint NOT NULL, >+ `add` TINYINT(1) NOT NULL DEFAULT 0, >+ `append` TINYINT(1) NOT NULL DEFAULT 0, >+ `remove` TINYINT(1) NOT NULL DEFAULT 0, >+ `delete` TINYINT(1) NOT NULL DEFAULT 0, > PRIMARY KEY(`id`), >- CONSTRAINT `marc_merge_rules_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_merge_rules_modules` (`name`) ON DELETE CASCADE ON UPDATE CASCADE >-); >+ CONSTRAINT `marc_overlay_rules_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_overlay_rules_modules` (`name`) ON DELETE CASCADE ON UPDATE CASCADE >+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; > > -- > -- Table structure for table `marc_modification_template_actions` >diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql >index cb4a4aeff9..00ae0fa863 100644 >--- a/installer/data/mysql/mandatory/sysprefs.sql >+++ b/installer/data/mysql/mandatory/sysprefs.sql >@@ -331,9 +331,9 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('MarcFieldForModifierName','',NULL,'Where to store the name of the record''s last modifier','Free'), > ('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'), > ('MarcItemFieldsToOrder','',NULL,'Set the mapping values for new item records created from a MARC record in a staged file. In a YAML format.','textarea'), >-('MARCMergeRules','0',NULL,'Use the MARC merge rules system to decide what actions to take for each field when modifying records.','YesNo'), > ('MarkLostItemsAsReturned','batchmod,moredetail,cronjob,additem,pendingreserves,onpayment','claim_returned|batchmod|moredetail|cronjob|additem|pendingreserves|onpayment','Mark items as returned when flagged as lost','multiple'), > ('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'), >+('MARCOverlayRules','0',NULL,'Use the MARC record overlay rules system to decide what actions to take for each field when modifying records.','YesNo'), > ('MaxFine',NULL,'','Maximum fine a patron can have for all late returns at one moment. Single item caps are specified in the circulation rules matrix.','Integer'), > ('MaxItemsToDisplayForBatchDel','1000',NULL,'Display up to a given number of items in a single item deletionbatch.','Integer'), > ('MaxItemsToDisplayForBatchMod','1000',NULL,'Display up to a given number of items in a single item modification batch.','Integer'), >diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql >index 581aaf2a5e..f070e501d8 100644 >--- a/installer/data/mysql/mandatory/userpermissions.sql >+++ b/installer/data/mysql/mandatory/userpermissions.sql >@@ -25,7 +25,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > ( 3, 'manage_oai_sets', 'Manage OAI sets'), > ( 3, 'manage_item_search_fields', 'Manage item search fields'), > ( 3, 'manage_search_engine_config', 'Manage search engine configuration'), >- ( 3, 'manage_marc_merge_rules', 'Manage MARC merge rules configuration'), >+ ( 3, 'manage_marc_overlay_rules', 'Manage MARC overlay rules configuration'), > ( 3, 'manage_search_targets', 'Manage Z39.50 and SRU server configuration'), > ( 3, 'manage_didyoumean', 'Manage Did you mean? configuration'), > ( 3, 'manage_column_config', 'Manage column configuration'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 1765de3bfc..4d553f5a90 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -93,8 +93,8 @@ > [% IF ( CAN_user_parameters_manage_search_engine_config ) %] > <li><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration (Elasticsearch)</a></li> > [% END %] >- [% IF ( CAN_user_parameters_manage_marc_merge_rules ) %] >- <li><a href="/cgi-bin/koha/admin/marc-merge-rules.pl">MARC merge rules</a></li> >+ [% IF ( CAN_user_parameters_manage_marc_overlay_rules ) %] >+ <li><a href="/cgi-bin/koha/admin/marc-overlay-rules.pl">MARC overlay rules</a></li> > [% END %] > </ul> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >index 76f39a1af0..cbbe30fbc1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -210,9 +210,9 @@ > Manage search engine configuration > </span> > <span class="permissioncode">([% name | html %])</span> >- [%- CASE 'manage_marc_merge_rules' -%] >- <span class="sub_permission manage_marc_merge_rules_subpermission"> >- Manage MARC merge rules configuration >+ [%- CASE 'manage_marc_overlay_rules' -%] >+ <span class="sub_permission manage_marc_overlay_rules_subpermission"> >+ Manage MARC overlay rules configuration > </span> > <span class="permissioncode">([% name | html %])</span> > [%- CASE 'manage_search_targets' -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index b58bfd42b6..a6961a5ca8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -183,8 +183,8 @@ > <dt><a href="/cgi-bin/koha/admin/searchengine/elasticsearch/mappings.pl">Search engine configuration (Elasticsearch)</a></dt> > <dd>Manage indexes, facets, and their mappings to MARC fields and subfields</dd> > [% END %] >- <dt><a href="/cgi-bin/koha/admin/marc-merge-rules.pl">MARC merge rules</a></dt> >- <dd>Managed MARC field merge rules</dd> >+ <dt><a href="/cgi-bin/koha/admin/marc-overlay-rules.pl">MARC overlay rules</a></dt> >+ <dd>Managed MARC field overlay rules</dd> > </dl> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-merge-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >similarity index 90% >rename from koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-merge-rules.tt >rename to koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >index 950eadd879..b23d1d99e7 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-merge-rules.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt >@@ -1,6 +1,6 @@ > [% USE Koha %] > [% INCLUDE 'doc-head-open.inc' %] >-<title>Koha › Administration › MARC merge rules</title> >+<title>Koha › Administration › MARC overlay rules</title> > [% INCLUDE 'doc-head-close.inc' %] > [% Asset.css("css/datatables.css") %] > [% INCLUDE 'datatables.inc' %] >@@ -16,20 +16,20 @@ function doSubmit(op, id) { > $('<input type="hidden"/>') > .attr('name', 'op') > .attr('value', op) >- .appendTo('#marc-merge-rules-form'); >+ .appendTo('#marc-overlay-rules-form'); > > if(id) { > $('<input type="hidden"/>') > .attr('name', 'id') > .attr('value', id) >- .appendTo('#marc-merge-rules-form'); >+ .appendTo('#marc-overlay-rules-form'); > } > > var valid = true; > if (op == 'add' || op == 'edit') { > var validate = [ >- $('#marc-merge-rules-form input[name="filter"]'), >- $('#marc-merge-rules-form input[name="tag"]') >+ $('#marc-overlay-rules-form input[name="filter"]'), >+ $('#marc-overlay-rules-form input[name="tag"]') > ]; > for(var i = 0; i < validate.length; i++) { > if (validate[i].length) { >@@ -44,7 +44,7 @@ function doSubmit(op, id) { > } > > if (valid) { >- $('#marc-merge-rules-form').submit(); >+ $('#marc-overlay-rules-form').submit(); > } > > return valid; >@@ -87,7 +87,7 @@ $(document).ready(function(){ > }); > } > >- $('#marc-merge-rules').dataTable($.extend(true, {}, dataTablesDefaults, { >+ $('#marc-overlay-rules').dataTable($.extend(true, {}, dataTablesDefaults, { > "aoColumns": [ > {"bSearchable": false, "bSortable": false}, > {"sSortDataType": "dom-input"}, >@@ -104,56 +104,56 @@ $(document).ready(function(){ > "pagingType": "simple" > })); > >- var merge_rules_presets = {}; >- merge_rules_presets[_("Protect")] = { >+ var overlay_rules_presets = {}; >+ overlay_rules_presets[_("Protect")] = { > 'add': 0, > 'append': 0, > 'remove': 0, > 'delete': 0 > }; >- merge_rules_presets[_("Overwrite")] = { >+ overlay_rules_presets[_("Overwrite")] = { > 'add': 1, > 'append': 1, > 'remove': 1, > 'delete': 1 > }; >- merge_rules_presets[_("Add new")] = { >+ overlay_rules_presets[_("Add new")] = { > 'add': 1, > 'append': 0, > 'remove': 0, > 'delete': 0 > }; >- merge_rules_presets[_("Add and append")] = { >+ overlay_rules_presets[_("Add and append")] = { > 'add': 1, > 'append': 1, > 'remove': 0, > 'delete': 0 > }; >- merge_rules_presets[_("Protect from deletion")] = { >+ overlay_rules_presets[_("Protect from deletion")] = { > 'add': 1, > 'append': 1, > 'remove': 1, > 'delete': 0 > }; > >- var merge_rules_label_to_value = {}; >- merge_rules_label_to_value[_("Add")] = 1; >- merge_rules_label_to_value[_("Append")] = 1; >- merge_rules_label_to_value[_("Remove")] = 1; >- merge_rules_label_to_value[_("Delete")] = 1; >- merge_rules_label_to_value[_("Skip")] = 0; >+ var overlay_rules_label_to_value = {}; >+ overlay_rules_label_to_value[_("Add")] = 1; >+ overlay_rules_label_to_value[_("Append")] = 1; >+ overlay_rules_label_to_value[_("Remove")] = 1; >+ overlay_rules_label_to_value[_("Delete")] = 1; >+ overlay_rules_label_to_value[_("Skip")] = 0; > > function hash_config(config) { > return JSON.stringify(config, Object.keys(config).sort()); > } > >- var merge_rules_preset_map = {}; >- $.each(merge_rules_presets, function(preset, config) { >- merge_rules_preset_map[hash_config(config)] = preset; >+ var overlay_rules_preset_map = {}; >+ $.each(overlay_rules_presets, function(preset, config) { >+ overlay_rules_preset_map[hash_config(config)] = preset; > }); > >- function operations_config_merge_rule_preset(config) { >- return merge_rules_preset_map[hash_config(config)] || ''; >+ function operations_config_overlay_rule_preset(config) { >+ return overlay_rules_preset_map[hash_config(config)] || ''; > } > > /* Set preset values according to operation config */ >@@ -162,10 +162,10 @@ $(document).ready(function(){ > var operations_config = {}; > $('.rule-operation-action', $this).each(function() { > var $operation = $(this); >- operations_config[$operation.data('operation')] = merge_rules_label_to_value[$operation.text()]; >+ operations_config[$operation.data('operation')] = overlay_rules_label_to_value[$operation.text()]; > }); > $('.rule-preset', $this).text( >- operations_config_merge_rule_preset(operations_config) || _("Custom") >+ operations_config_overlay_rule_preset(operations_config) || _("Custom") > ); > }); > >@@ -178,7 +178,7 @@ $(document).ready(function(){ > operations_config[$this.attr('name')] = parseInt($this.val()); > }); > $('select[name="preset"]', $parent_row).val( >- operations_config_merge_rule_preset(operations_config) >+ operations_config_overlay_rule_preset(operations_config) > ); > }); > >@@ -188,7 +188,7 @@ $(document).ready(function(){ > var $parent_row = $this.closest('tr'); > var preset = $this.val(); > if (preset) { >- $.each(merge_rules_presets[preset], function(operation, action) { >+ $.each(overlay_rules_presets[preset], function(operation, action) { > $('select[name="' + operation + '"]', $parent_row).val(action); > }); > } >@@ -264,19 +264,19 @@ $(document).ready(function(){ > }); > </script> > </head> >-<body id="admin_marc-merge-rules" class="admin"> >+<body id="admin_marc-overlay-rules" class="admin"> > [% INCLUDE 'header.inc' %] > [% INCLUDE 'cat-search.inc' %] > > <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >- › MARC merge rules >+ › MARC overlay rules > </div> > > <div class="main container-fluid"> > <div class="row"> > <div class="col-sm-10 col-sm-push-2"> > >-<h1>Manage MARC merge rules</h1> >+<h1>Manage MARC overlay rules</h1> > > [% FOR m IN messages %] > <div class="dialog [% m.type | html %]"> >@@ -291,9 +291,9 @@ $(document).ready(function(){ > </div> > [% END %] > >-[% UNLESS Koha.Preference( 'MARCMergeRules' ) %] >+[% UNLESS Koha.Preference( 'MARCOverlayRules' ) %] > <div class="dialog message"> >- The <b>MARCMergeRules</b> preference is not set, don't forget to enable it for rules to take effect. >+ The <b>MARCOverlayRules</b> preference is not set, don't forget to enable it for rules to take effect. > </div> > [% END %] > [% IF removeConfirm %] >@@ -308,8 +308,8 @@ $(document).ready(function(){ > </div> > [% END %] > >-<form action="[% script_name %]" method="POST" id="marc-merge-rules-form"> >-<table id="marc-merge-rules"> >+<form action="[% script_name %]" method="POST" id="marc-overlay-rules-form"> >+<table id="marc-overlay-rules"> > <thead><tr> > <th>Rule</th> > <th>Module</th> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index bea83babae..be76b9b2cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -279,7 +279,12 @@ Cataloging: > 1: "do" > 0: "don't" > - attempt to match aggressively by trying all variations of the ISSNs in the imported record as a phrase in the ISSN fields of already cataloged records. >- >+ - >+ - pref: MARCOverlayRules >+ choices: >+ yes: "Use" >+ no: "Don't use" >+ - MARC overlay rules for incoming records, to decide which action to take for each field. > Exporting: > - > - "Include the following fields when exporting BibTeX:" >@@ -305,10 +310,3 @@ Cataloging: > - "All values of repeating tags and subfields will be printed with the given RIS tag." > - "<br/>" > - "Use of TY ( record type ) as a key will <em>replace</em> the default TY with the field value of your choosing." >- - >- - When importing records >- - pref: MARCMergeRules >- choices: >- yes: "use" >- no: "don't use" >- - MARC merge rules to decide which action to take for each field. >diff --git a/t/db_dependent/Biblio/MarcMergeRules.t b/t/db_dependent/Biblio/MarcOverlayRules.t >similarity index 88% >rename from t/db_dependent/Biblio/MarcMergeRules.t >rename to t/db_dependent/Biblio/MarcOverlayRules.t >index cf178063d8..0a13426a7d 100755 >--- a/t/db_dependent/Biblio/MarcMergeRules.t >+++ b/t/db_dependent/Biblio/MarcOverlayRules.t >@@ -22,19 +22,19 @@ use MARC::Record; > > use C4::Context; > use C4::Biblio; >-use Koha::Database; #?? >+use Koha::Database; > > use Test::More tests => 23; > use Test::MockModule; > >-use Koha::MarcMergeRules; >+use Koha::MarcOverlayRules; > > use t::lib::Mocks; > > my $schema = Koha::Database->schema; > $schema->storage->txn_begin; > >-t::lib::Mocks::mock_preference('MARCMergeRules', '1'); >+t::lib::Mocks::mock_preference('MARCOverlayRules', '1'); > > # Create a record > my $orig_record = MARC::Record->new(); >@@ -54,11 +54,11 @@ $incoming_record->append_fields( > MARC::Field->new('501', '', '', 'a' => 'Two cold bottles of beer in the fridge'), # Added > ); > >-# Test default behavior when MARCMergeRules is enabled, but no rules defined (overwrite) >+# Test default behavior when MARCOverlayRules is enabled, but no rules defined (overwrite) > subtest 'Record fields has been overwritten when no merge rules are defined' => sub { > plan tests => 4; > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > >@@ -79,7 +79,7 @@ subtest 'Record fields has been overwritten when no merge rules are defined' => > ); > }; > >-my $rule = Koha::MarcMergeRules->find_or_create({ >+my $rule = Koha::MarcOverlayRules->find_or_create({ > tag => '*', > module => 'source', > filter => '*', >@@ -92,7 +92,7 @@ my $rule = Koha::MarcMergeRules->find_or_create({ > subtest 'Record fields has been protected when matched merge all rule operations are set to "0"' => sub { > plan tests => 3; > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 3, "Record has the expected number of fields"); >@@ -122,7 +122,7 @@ subtest 'Only new fields has been added when add = 1, append = 0, remove = 0, de > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 5, "Record has the expected number of fields"); >@@ -159,7 +159,7 @@ subtest 'Only appended fields has been added when add = 0, append = 1, remove = > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 4, "Record has the expected number of fields"); >@@ -191,7 +191,7 @@ subtest 'Appended and added fields has been added when add = 1, append = 1, remo > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 6, "Record has the expected number of fields"); >@@ -228,7 +228,7 @@ subtest 'Record fields has been only removed when add = 0, append = 0, remove = > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 2, "Record has the expected number of fields"); >@@ -258,7 +258,7 @@ subtest 'Record fields has been added and removed when add = 1, append = 0, remo > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 4, "Record has the expected number of fields"); >@@ -294,7 +294,7 @@ subtest 'Record fields has been appended and removed when add = 0, append = 1, r > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 3, "Record has the expected number of fields"); >@@ -324,7 +324,7 @@ subtest 'Record fields has been added, appended and removed when add = 0, append > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 5, "Record has the expected number of fields"); >@@ -361,7 +361,7 @@ subtest 'Record fields has been deleted when add = 0, append = 0, remove = 0, de > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 2, "Record has the expected number of fields"); >@@ -386,7 +386,7 @@ subtest 'Record fields has been added and deleted when add = 1, append = 0, remo > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 4, "Record has the expected number of fields"); >@@ -417,7 +417,7 @@ subtest 'Record fields has been appended and deleted when add = 0, append = 1, r > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 3, "Record has the expected number of fields"); >@@ -442,7 +442,7 @@ subtest 'Record fields has been added, appended and deleted when add = 1, append > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 5, "Record has the expected number of fields"); >@@ -473,7 +473,7 @@ subtest 'Record fields has been removed and deleted when add = 0, append = 0, re > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 1, "Record has the expected number of fields"); >@@ -498,7 +498,7 @@ subtest 'Record fields has been added, removed and deleted when add = 1, append > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 3, "Record has the expected number of fields"); >@@ -529,7 +529,7 @@ subtest 'Record fields has been appended, removed and deleted when add = 0, appe > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > cmp_ok(scalar @all_fields, '==', 2, "Record has the expected number of fields"); >@@ -554,7 +554,7 @@ subtest 'Record fields has been overwritten when add = 1, append = 1, remove = 1 > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > >@@ -578,7 +578,7 @@ subtest 'Record fields has been overwritten when add = 1, append = 1, remove = 1 > # Test rule tag specificity > > # Protect field 500 with more specific tag value >-my $skip_all_rule = Koha::MarcMergeRules->find_or_create({ >+my $skip_all_rule = Koha::MarcOverlayRules->find_or_create({ > tag => '500', > module => 'source', > filter => '*', >@@ -591,7 +591,7 @@ my $skip_all_rule = Koha::MarcMergeRules->find_or_create({ > subtest '"500" field has been protected when rule matching on tag "500" is add = 0, append = 0, remove = 0, delete = 0' => sub { > plan tests => 4; > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > >@@ -626,7 +626,7 @@ subtest '"5XX" fields has been protected when rule matching on regexp "5\d{2}" i > ); > $skip_all_rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > >@@ -655,7 +655,7 @@ subtest 'Record fields has been overwritten when non wild card rule with filter > ); > $rule->store(); > >- my $merged_record = Koha::MarcMergeRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); >+ my $merged_record = Koha::MarcOverlayRules->merge_records($orig_record, $incoming_record, { 'source' => 'test' }); > > my @all_fields = $merged_record->fields(); > >@@ -679,7 +679,7 @@ subtest 'Record fields has been overwritten when non wild card rule with filter > subtest 'An exception is thrown when append = 1, remove = 0 is set for control field rule' => sub { > plan tests => 2; > my $exception = try { >- Koha::MarcMergeRules->validate({ >+ Koha::MarcOverlayRules->validate({ > 'tag' => '008', > 'append' => 1, > 'remove' => 0, >@@ -689,14 +689,14 @@ subtest 'An exception is thrown when append = 1, remove = 0 is set for control f > return $_; > }; > ok(defined $exception, "Exception was caught"); >- ok($exception->isa('Koha::Exceptions::MarcMergeRule::InvalidControlFieldActions'), "Exception is of correct class"); >+ ok($exception->isa('Koha::Exceptions::MarcOverlayRule::InvalidControlFieldActions'), "Exception is of correct class"); > }; > > subtest 'An exception is thrown when rule tag is set to invalid regexp' => sub { > plan tests => 2; > > my $exception = try { >- Koha::MarcMergeRules->validate({ >+ Koha::MarcOverlayRules->validate({ > 'tag' => '**' > }); > } >@@ -704,7 +704,7 @@ subtest 'An exception is thrown when rule tag is set to invalid regexp' => sub { > return $_; > }; > ok(defined $exception, "Exception was caught"); >- ok($exception->isa('Koha::Exceptions::MarcMergeRule::InvalidTagRegExp'), "Exception is of correct class"); >+ ok($exception->isa('Koha::Exceptions::MarcOverlayRule::InvalidTagRegExp'), "Exception is of correct class"); > }; > > $skip_all_rule->delete(); >@@ -775,5 +775,3 @@ subtest 'context option in ModBiblio is handled correctly' => sub { > $rule->delete(); > > $schema->storage->txn_rollback; >- >-1; >-- >2.20.1
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 14957
:
44056
|
44057
|
44058
|
51723
|
51724
|
56637
|
56638
|
56643
|
56644
|
56645
|
56646
|
56647
|
56648
|
57114
|
57115
|
57116
|
57117
|
57118
|
57119
|
59811
|
59812
|
59885
|
60711
|
60824
|
60825
|
61065
|
61641
|
61736
|
64792
|
72498
|
74855
|
75118
|
76201
|
76202
|
76203
|
76204
|
76205
|
76206
|
76207
|
76208
|
76209
|
76210
|
78651
|
78652
|
78653
|
79367
|
79368
|
79369
|
79370
|
79890
|
80972
|
80973
|
80974
|
80975
|
81176
|
81177
|
81178
|
81179
|
81621
|
81699
|
81700
|
81705
|
81706
|
81707
|
81708
|
81969
|
81970
|
81971
|
82030
|
82031
|
82775
|
87709
|
87711
|
87771
|
87929
|
88205
|
88206
|
89961
|
90668
|
90669
|
90671
|
90672
|
90722
|
90723
|
90740
|
90741
|
92933
|
92934
|
92935
|
92936
|
92937
|
92938
|
92999
|
93499
|
94909
|
94911
|
99998
|
100052
|
100053
|
100054
|
100055
|
100056
|
100057
|
100058
|
100059
|
100060
|
100061
|
101510
|
109955
|
109956
|
109957
|
109958
|
109959
|
109960
|
109961
|
109962
|
109963
|
116622
|
116623
|
116624
|
116625
|
117844
|
117845
|
117849
|
117850
|
117853
|
117859
|
117964
|
117965
|
117966
|
118918
|
118919
|
118920
|
118921
|
118922
|
118923
|
118924
|
118925
|
118926
|
118927
|
118934
|
118935
|
118936
|
118937
|
118938
|
118939
|
118940
|
118941
|
118942
|
118943
|
118944
|
118945
|
118946
|
118957
|
120533
|
120534
|
120535
|
120536
|
120537
|
120538
|
120539
|
120540
|
120541
|
120542
|
120543
|
120544
|
120545
|
120546
|
120547
|
120548
|
120550
|
120553
|
120554
|
120555
|
120556
|
120557
|
120581
|
120582
|
120583
|
120584
|
120585
|
120586
|
120587
|
120588
|
120589
|
120590
|
120591
|
120592
|
120593
|
120594
|
120595
|
120596
|
120597
|
120598
|
120599
|
120600
|
120601
|
120602
|
120603
|
120604
|
120605
|
120670
|
120671
|
120705
|
125514
|
125515
|
125516
|
125517
|
125518
|
125519
|
125520
|
125521
|
125522
|
125523
|
125524
|
125525
|
125526
|
125527
|
125528
|
125529
|
125530
|
125531
|
125532
|
125533
|
125534
|
125535
|
125536
|
125537
|
125538
|
125539
|
125540
|
125632
|
125633
|
125636
|
126424
|
126425
|
126431
|
126592
|
126666
|
126667
|
126752
|
126753
|
126754
|
126755
|
126756
|
126757
|
126758
|
126759
|
126760
|
126761
|
126762
|
126763
|
126764
|
126765
|
126766
|
126767
|
126768
|
126769
|
126770
|
126771
|
126772
|
126773
|
126774
|
126775
|
126776
|
126777
|
126778
|
126779
|
126780
|
126781
|
126782
|
126783
|
126784
|
126785
|
126786
|
126950
|
126951