Bug 24593: Rewrite marc21_default_matching_rules to YAML

YAML version of marc21 optional marc21_default_matching_rules.

To test:
1) Do a clean install with optional data,
   dump table marc_matchers, reserve.

2) Apply this patch and it's dependencies

3) Do a clean install, dump again and compare
   No major differences expected

4) Try translation
  a) Go to misc/translator
  b) create files for a new language
     ./translate create xx-YY
  c) Check new file po/xx-YY-instaler-MARC21.po
     Verify strings from this file.
  d) Install new language
     ./translate install xx-YY
  e) Try clean install with new files

NOTE: This patch fails with qa tools!
Reason is that qa tools use YAML.pm module to
check files, but Installer.pm or LangInstaller.pm
are using YAML::Syck, using that module gives
no error, check for example:

perl -e 'use YAML::Syck qw( LoadFile ); $y = LoadFile("marc21_default_matching_rules.yml");'
No error!

perl -e 'use YAML qw( LoadFile ); $y = LoadFile("marc21_default_matching_rules.yml");'
Error!

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Bernardo Gonzalez Kriegel 2020-02-05 10:11:16 -03:00 committed by Martin Renvoize
parent 95884c204c
commit 2c8f894b96
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
3 changed files with 69 additions and 51 deletions

View File

@ -1,46 +0,0 @@
--
-- Default MARC matching rules for Koha
--
-- Copyright (C) 2007 LiblimeA
--
-- This file is part of Koha.
--
-- Koha is free software; you can redistribute it and/or modify it
-- under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- Koha is distributed in the hope that it will be useful, but
-- WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with Koha; if not, see <http://www.gnu.org/licenses>.
INSERT INTO marc_matchers (code, description, record_type, threshold)
VALUES ('ISBN', '020$a', 'biblio', 1000);
INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'isbn', 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, '020', 'a' FROM matchpoints;
INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
SELECT MAX(matchpoint_component_id), 1, 'ISBN' FROM matchpoint_components;
INSERT INTO marc_matchers (code, description, record_type, threshold)
VALUES ('ISSN', '022$a', 'biblio', 1000);
INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'issn', 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, '022', 'a' FROM matchpoints;
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;

View File

@ -1,5 +0,0 @@
Selected matching rules for MARC 21 bibliographic
records, including:
ISBN
ISSN

View File

@ -0,0 +1,69 @@
---
#
# Copyright 2020 Koha Development Team
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# *************************************************************
# Default MARC matching rules for Koha
# *************************************************************
description:
- "Selected matching rules for MARC 21 bibliographic records, including:"
- ""
- "ISBN"
- "ISSN"
tables:
- marc_matchers:
translatable: []
multiline: []
rows:
- code: "ISBN"
description: "020$a"
record_type: biblio
threshold: 1000
- code: "ISSN"
description: "022$a"
record_type: biblio
threshold: 1000
- code: "KohaBiblio"
description: "999$c"
record_type: biblio
threshold: 1000
sql_statements:
- "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'isbn', 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, '020', 'a' FROM matchpoints;"
- "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
SELECT MAX(matchpoint_component_id), 1, 'ISBN' FROM matchpoint_components;"
- "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT MAX(matcher_id), 'issn', 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, '022', 'a' FROM matchpoints;"
- "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
SELECT MAX(matchpoint_component_id), 1, 'ISSN' FROM matchpoint_components;"
- "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;"