From a5fe0a2e83114464c51e1c17e4a0ca9a047455b9 Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 2 Sep 2013 13:25:03 +1000 Subject: [PATCH] Bug 10811 - Add a 999$c record matching rule to the MARC21 defaults This patch adds a default record matching rule for biblionumber using the 999$c and the Local-Number index. This is part of the optional marc21 SQL, as well as in the updatabase.pl script. TEST PLAN --------- 1) Back up your DB, because you probably want it back. 2) Apply the patch 3) Run the QA test tool. 4) Run updatedatabase.pl 5) Export some MARC bibliographic records from Koha 6) Import those same MARC bibliographic records using the "KohaBiblio" record matching rule. 7) The incoming records should match perfectly 8) Check the mysql tables (marc_matchers, matchpoints, matcher_matchpoints, matchpoint_components, matchpoint_component_norms) to make sure the values were inserted as expected. 9) drop the koha database 10) create the koha database 11) Go to the staff client page, and do a "fresh" install making sure to select lots of optional marc 21 matching rules so the .../marc21/optional/marc21_default_matching_rules.sql gets triggered. 12) Check the mysql tables (marc_matchers, matchpoints, matcher_matchpoints, matchpoint_components, matchpoint_component_norms) to make sure the values were inserted as expected. 13) Restore your DB backup. :) I wasn't able to do steps 5-7 properly, because of the lack of 999$c MARC records in my data as far as I know. --- .../optional/marc21_default_matching_rules.sql | 8 ++++++++ installer/data/mysql/updatedatabase.pl | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.sql b/installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.sql index 4d39a5e..1160094 100644 --- a/installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.sql +++ b/installer/data/mysql/en/marcflavour/marc21/optional/marc21_default_matching_rules.sql @@ -36,3 +36,11 @@ INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields) INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine) SELECT MAX(matchpoint_component_id), 1, 'ISSN' FROM matchpoint_components; +INSERT INTO marc_matchers (code, description, record_type, threshold) + VALUES ('KohaBiblio', '999$c', 'biblio', 1000); +INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'Local-Number', 1000 FROM marc_matchers; +INSERT INTO matcher_matchpoints SELECT MAX(matcher_id), MAX(matchpoint_id) FROM matchpoints; +INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields) + SELECT MAX(matchpoint_id), 1, '999', 'c' FROM matchpoints; +INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine) + SELECT MAX(matchpoint_component_id), 1, 'Biblionumber' FROM matchpoint_components; \ No newline at end of file diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 80ab210..17b705d 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -7912,6 +7912,19 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +$DBversion = "3.13.00.XXX"; +if ( CheckVersion($DBversion) ) { + if ( C4::Context->preference("marcflavour") eq 'MARC21' ) { + $dbh->do("INSERT INTO marc_matchers (code, description, record_type, threshold) VALUES ('KohaBiblio', '999\$c', 'biblio', 1000)"); + $dbh->do("INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'Local-Number', 1000 FROM marc_matchers"); + $dbh->do("INSERT INTO matcher_matchpoints SELECT MAX(matcher_id), MAX(matchpoint_id) FROM matchpoints"); + $dbh->do("INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields) SELECT MAX(matchpoint_id), 1, '999', 'c' FROM matchpoints"); + $dbh->do("INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine) SELECT MAX(matchpoint_component_id), 1, 'Biblionumber' FROM matchpoint_components"); + } + print "Upgrade to $DBversion done (Bug 10811: Add a 999\$c record matching rule to the MARC21 defaults)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.9.5