From 3a996962a510c6b796b905971d4b1649f560a1c8 Mon Sep 17 00:00:00 2001 From: Andreas Roussos Date: Mon, 7 Jul 2025 02:45:50 +0300 Subject: [PATCH] Bug 40308: add new System Preferences for OCLC Dewey API This patch adds four new System Preferences that control the integration with the OCLC Dewey Linked Data API, namely: - OCLCAPIWSKeyClientID: Stores the client ID component of your OCLC API WSKey - OCLCAPIWSKeyClientSecret: Stores the client secret component of your OCLC API WSKey - OCLCDeweyLinkedDataAPI: Basically an On/Off "switch" for the lookup service - OCLCDeweyLinkedDataLanguage: Sets the language of the DDC description to be fetched Test plan: 0) Launch either a MARC21 or a UNIMARC KTD container (MARC flavour does not play a role for this particular test plan), then apply this patch. 1) Run `reset_all` to force your KTD instance to load installer/data/mysql/mandatory/sysprefs.sql. 2) Then, visit Administration > System preferences > Web services and inspect the four new sysprefs under 'OCLC Dewey Linked Data API'. Look for typos in the descriptions, etc. 3) Then, run `updatedatabase` to test the atomic update. It should complete without warnings/errors. 4) Finally, visually inspect the output of `git log -p C4/UsageStats.pm` for errors. Notice that the System Preferences pertaining to the WSKey client ID and secret were *not* added for security reasons. --- C4/UsageStats.pm | 2 + .../data/mysql/atomicupdate/bug_40308.pl | 49 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 4 ++ .../admin/preferences/web_services.pref | 33 +++++++++++++ 4 files changed, 88 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_40308.pl diff --git a/C4/UsageStats.pm b/C4/UsageStats.pm index 4022741ac0..535d92b6ee 100644 --- a/C4/UsageStats.pm +++ b/C4/UsageStats.pm @@ -351,6 +351,8 @@ sub _shared_preferences { ILS-DI OAI-PMH version + OCLCDeweyLinkedDataAPI + OCLCDeweyLinkedDataLanguage /; return \@preferences; diff --git a/installer/data/mysql/atomicupdate/bug_40308.pl b/installer/data/mysql/atomicupdate/bug_40308.pl new file mode 100755 index 0000000000..c961700bd2 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_40308.pl @@ -0,0 +1,49 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "40308", + description => + "Adds new system preferences 'OCLCAPIWSKeyClientID', 'OCLCAPIWSKeyClientSecret', 'OCLCDeweyLinkedDataAPI', and 'OCLCDeweyLinkedDataLanguage'", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OCLCAPIWSKeyClientID', '', NULL, 'The client ID component of your OCLC API WSKey', 'Free') + } + ); + say_success( $out, "Added new system preference 'OCLCAPIWSKeyClientID'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OCLCAPIWSKeyClientSecret', '', NULL, 'The client secret component of your OCLC API WSKey', 'Free') + } + ); + say_success( $out, "Added new system preference 'OCLCAPIWSKeyClientSecret'" ); + + say_info( + $out, + "Please refer to https://help.oclc.org/Librarian_Toolbox/OCLC_APIs/Get_started/Request_an_API_WSKey for information on how to obtain an OCLC API WSKey" + ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OCLCDeweyLinkedDataAPI', '0', NULL, 'If enabled, users will be able to query the OCLC Dewey Linked Data API while cataloguing authorities', 'YesNo') + } + ); + say_success( $out, "Added new system preference 'OCLCDeweyLinkedDataAPI'" ); + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('OCLCDeweyLinkedDataLanguage', 'en', 'de|en|fr|it|no|sv', 'Defines the language of the DDC number/range description to be copied in authority subfield 083$c (MARC21) or 676$c (UNIMARC)', 'Choice') + } + ); + say_success( $out, "Added new system preference 'OCLCDeweyLinkedDataLanguage'" ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index f9f419c39d..763fd90622 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -465,6 +465,10 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('OAI-PMH:DeletedRecord','persistent','Koha\'s deletedbiblio table will never be deleted (persistent), might be deleted (transient), or will never have any data in it (no)','transient|persistent|no','Choice'), ('OAI-PMH:HarvestEmailReport','','','After an OAI-PMH harvest, send a report email to the email address','Free'), ('OAI-PMH:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), +('OCLCAPIWSKeyClientID', '', NULL, 'The client ID component of your OCLC API WSKey', 'Free'), +('OCLCAPIWSKeyClientSecret', '', NULL, 'The client secret component of your OCLC API WSKey', 'Free'), +('OCLCDeweyLinkedDataAPI', '0', NULL, 'If enabled, users will be able to query the OCLC Dewey Linked Data API while cataloguing authorities', 'YesNo'), +('OCLCDeweyLinkedDataLanguage', 'en', 'de|en|fr|it|no|sv', 'Defines the language of the DDC number/range description to be copied in authority subfield 083$c (MARC21) or 676$c (UNIMARC)', 'Choice'), ('OnSiteCheckoutAutoCheck','0','','Enable/Do not enable onsite checkout by default if last checkout was an onsite checkout','YesNo'), ('OnSiteCheckouts','0','','Enable/Disable the on-site checkouts feature','YesNo'), ('OnSiteCheckoutsForce','0','','Enable/Disable the on-site for all cases (Even if a user is debarred, etc.)','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index a1900bc746..f574530768 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -141,3 +141,36 @@ Web services: 0: Disable - the IdRef web service from the OPAC detail page. IdRef allows requests for authorities from the Sudoc database. - Please note that this feature is available only for UNIMARC. + + OCLC Dewey Linked Data API: + - + - "OCLC API WSKey Client ID:" + - pref: OCLCAPIWSKeyClientID + - Along with OCLCAPIWSKeyClientSecret, enables OCLCDeweyLinkedDataAPI. + - + - "OCLC API WSKey Client Secret:" + - pref: OCLCAPIWSKeyClientSecret + - Along with OCLCAPIWSKeyClientID, enables OCLCDeweyLinkedDataAPI. + - + - pref: OCLCDeweyLinkedDataAPI + choices: + 1: Enable + 0: Disable + - querying the OCLC Dewey Linked Data API while editing authority records. + -

This feature enables searching for DDC (Dewey Decimal Classification) numbers in the OCLC Dewey Linked Data API. + -
The API is capable of returning unique Linked Data IDs (URIs) and corresponding URLs for a given DDC number (or range), which can then be stored in subfield 082$1/083$1 (MARC21), or 676$R (UNIMARC). + -
The API is also capable of returning Descriptions for a given Linked Data URI, which can then be stored in subfield 083$c (MARC21), or 676$c (UNIMARC). + -

Requires both OCLCAPIWSKeyClientID and OCLCAPIWSKeyClientSecret to be set before set to 'Enable'. + -
Please refer to the official OCLC documentation for information on how to obtain an OCLC API WSKey. + -

NOTE: You must have a valid WebDewey subscription in order to request a WSKey capable of accessing the OCLC Dewey Linked Data API. + - + - Use + - pref: OCLCDeweyLinkedDataLanguage + choices: + en: English + fr: French + de: German + it: Italian + no: Norwegian + sv: Swedish + - as the language of the DDC number/range description to be copied in authority subfield 083$c (MARC21) or 676$c (UNIMARC). -- 2.39.5