Koha/t/db_dependent/api/v1
Zeno Tajoli 50a2e9316a Bug 33036: REST API: Merge biblio records implements merging of records
+ attached items, subscriptions etc via the API as an alternative to the web interface: cgi-bin/koha/cataloguing/merge.pl

This is a slightly improved version of Zenos patch: I (domm) have converted the code in Koha::Biblio to a more DBICy style and packed it into a transaction (as requested in Comment 23)

Even the QA script is happy now!

To test:
    1) you need an API user with the permissions "editcatalogue"
    2) two records: one to be merged into (with biblio_id, eg 262) and another one from
       which to merge (with biblio_id_to_merge, eg 9) which will be deleted!
       both records may/should have items, subscription, subscriptionhistory, serial, suggestions
       orders and holds
    3) check both records via the web
    4) Apply patch
    5) Write a JSON file with inside the field 'biblio_id_to_merge' and the biblionumber from wihich to merge.
       As example:
       {
         "biblio_id_to_merge" : 9
       }
     6) Execute an API call with correct headers and location. For example:
        curl -s -u koha:koha --header "Content-Type: application/json" --header "Accept: application/marc-in-json"
                  --request POST "http://127.0.0.1:8080/api/v1/biblios/262/merge" -d @file.json
        You must to setup the headers and to use a json file with parameters
     7) The record with the id 9 is deleted now, the record with 262 has all items, etc attached,
        the return is: return code 200 and the changed record 262 in marc-in-json format
     8) It is possible to override biblio data with an external bib record. You need to put external bib record
        into the json file in marc-in-json format. To write use the json file uploaded as example
        You need to fill the fields 'rules' and 'datarecord'. The field 'rules' must contains 'override_ext'
        To do the call:
         curl -s -u koha:koha --header "Content-Type: application/json" --header "Accept: application/marc-in-json"
                  --request POST "http://127.0.0.1:8080/api/v1/biblios/XXX/merge" -d @file_with_recod.json
      9) The record in 'biblio_id_to_merge' is deleted now, in biblio XXX now there are the bibliographic data
         of field 'datarecord' of json file, the return is: return code 200 and the changed record XXX in marc-in-json format
      10) Go into intranet and do a search. Select two or (better) more record.
      11) Merge them; merge must be a success.
      12) Test with prove -v t/db_dependent/Koha/Biblio.t
      13) Test with prove -v t/db_dependent/api/v1/biblios.t

To test with curl the step 8 you can customize the json file attached in bugzilla.
The marc-in-json record inside follows the MAR21 standard

Sponsored-by: Technische Hochschule Wildau
Co-authored-by: Zeno Tajoli <ztajoli@gmail.com>
Co-authored-by: Thomas Klausner <domm@plix.at>
Co-authored-by: Mark Hofstetter <<mark@hofstetter.at>>
Signed-off-by: Jan Kissig <jkissig@th-wildau.de>

Bug 33036: Update of test number.

File ../biblios.t was update with a new subutest.
So we need this update to have a 'OK' after test running.

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit c60a6d8cd9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2024-03-21 10:43:30 +01:00
..
items Bug 35963: (QA follow-up): tidy up code and fix exec permission 2024-03-11 10:42:34 +01:00
acquisitions_baskets.t Bug 29523: Remove the FIXME 2023-10-27 16:40:45 -03:00
acquisitions_funds.t Bug 29523: Remove the FIXME 2023-10-27 16:40:45 -03:00
acquisitions_orders.t Bug 36066: (follow-up) Move 403 to 409 when status ne cancelled 2024-03-11 15:35:52 +01:00
acquisitions_vendor_issues.t Bug 33105: Tidy files 2023-07-20 10:59:31 -03:00
acquisitions_vendors.t
advanced_editor_macros.t
article_requests.t
auth.t Bug 34999: Add unit test 2024-01-17 10:18:42 +01:00
auth_authenticate_api_request.t Bug 32551: Regression tests 2024-01-15 15:16:19 +01:00
auth_basic.t
authorised_values.t
authorities.t Bug 33996: Add missing authority objects mapping 2023-06-29 11:11:12 -03:00
biblios.t Bug 33036: REST API: Merge biblio records implements merging of records 2024-03-21 10:43:30 +01:00
bookings.t Bug 36100: (QA follow-up) Move 400 to 409 2024-03-11 11:00:23 +01:00
cashups.t
checkouts.t Bug 35469: Add 'manage_bookings' subpermission to /checkouts 2024-03-11 11:22:54 +01:00
cities.t
clubs_holds.t
erm_agreements.t
erm_counter_files.t Bug 34587: (QA follow-up): squash 2023-10-31 16:46:30 -03:00
erm_counter_registries.t Bug 35757: (QA follow-up) Tidy 2024-01-15 15:02:22 +01:00
erm_custom_reports.t Bug 34587: (QA follow-up) Tidy 2023-10-31 16:46:32 -03:00
erm_documents.t
erm_eholdings_packages.t
erm_eholdings_resources.t
erm_eholdings_titles.t Bug 35115: (QA follow-up): 2023-11-29 17:36:10 -03:00
erm_licenses.t
erm_sushi_services.t Bug 35757: (QA follow-up) Tidy 2024-01-15 15:02:22 +01:00
erm_usage_data_providers.t Bug 34587: Fix license issues 2023-11-01 09:26:11 -03:00
erm_usage_titles.t Bug 34587: Fix license issues 2023-11-01 09:26:11 -03:00
erm_users.t Bug 12133: Fix failing tests 2023-11-14 10:32:36 -03:00
holds.t Bug 8367: (QA follow-up) Fix broken tests 2023-11-02 10:22:40 -03:00
idp.t
ill_backends.t Bug 22440: Move backend statuses api endpoint 2023-05-05 09:13:43 -03:00
ill_batches.t Bug 30719: (QA follow-up) Pick better column names and cleanup 2023-10-17 14:45:23 -03:00
ill_batchstatuses.t Bug 30719: (QA follow-up) Rename illbatchstatuses 2023-10-17 14:45:22 -03:00
ill_requests.t Bug 29523: Fix tests 2023-10-28 09:47:38 -03:00
import_batch_profiles.t
import_record_matches.t
item_groups.t
item_types.t Bug 34008: Harmonize attribute names 2023-11-01 17:23:15 -03:00
items.t Bug 35167: Regression tests 2023-10-27 16:44:05 -03:00
jobs.t Bug 33852: Add one more test 2023-06-09 08:29:01 -03:00
libraries.t
oauth.t
pagination.t
password_validation.t Bug 35204: Add unit tests 2024-01-03 15:51:13 +01:00
patrons.t Bug 30230: (QA follow-up) Add unit tests for API definition change 2024-02-01 16:22:55 +01:00
patrons_accounts.t Bug 21043: Handle exceptions and switch to debit response 2023-05-05 12:13:52 -03:00
patrons_extended_attributes.t
patrons_holds.t Bug 33573: Unit tests 2023-07-03 14:51:30 -03:00
patrons_password.t
patrons_password_expiration.t
preservation_Processings.t Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
preservation_Trains.t Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
preservation_WaitingList.t Bug 30708: Tidy perl files 2023-10-18 15:42:04 -03:00
query.t
return_claims.t Bug 32496: Reduce unnecessary unblessings of objects in Circulation.pm 2023-09-22 10:52:39 -03:00
search_filters.t
smtp_servers.t Bug 34243: Fix copy/pasted city references in api tests 2023-07-14 08:59:49 -03:00
stockrotationstage.t
suggestions.t Bug 32942: (QA follow-up) Fix regression test 2023-09-18 15:31:46 -03:00
ticket_updates.t
tickets.t
transfer_limits.t
two_factor_auth.t
unhandled_exceptions.t