---
#
#  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 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>.

#
# *************************************************************
#      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 matcher_id, 'isbn', 1000 FROM marc_matchers WHERE code = 'ISBN';"
  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'isbn';"
  - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
     SELECT matchpoint_id, 1, '020', 'a' FROM matchpoints WHERE search_index = 'isbn';"
  - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
     SELECT matchpoint_component_id, 1, 'ISBN' FROM matchpoint_components WHERE tag = '020';"

  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT matcher_id, 'issn', 1000 FROM marc_matchers WHERE code = 'ISSN';"
  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'issn';"
  - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
     SELECT matchpoint_id, 1, '022', 'a' FROM matchpoints WHERE search_index = 'issn';"
  - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
     SELECT matchpoint_component_id, 1, 'ISSN' FROM matchpoint_components WHERE tag = '022';"

  - "INSERT INTO matchpoints (matcher_id, search_index, score) SELECT matcher_id, 'local-number', 1000 FROM marc_matchers WHERE code = 'KohaBiblio';"
  - "INSERT INTO matcher_matchpoints SELECT matcher_id, matchpoint_id FROM matchpoints WHERE search_index = 'local-number';"
  - "INSERT INTO matchpoint_components (matchpoint_id, sequence, tag, subfields)
     SELECT matchpoint_id, 1, '999', 'c' FROM matchpoints WHERE search_index = 'local-number';"
  - "INSERT INTO matchpoint_component_norms (matchpoint_component_id, sequence, norm_routine)
     SELECT matchpoint_component_id, 1, 'Biblionumber' FROM matchpoint_components WHERE tag = '999';"
