From af6d0dde9b6ac93b11a555c9738e3f4478622b12 Mon Sep 17 00:00:00 2001 From: Alex Buckley Date: Tue, 12 May 2020 02:57:20 +0000 Subject: [PATCH] Bug 25460: Update OAI sets when adding/editing/deleting item records Test plan: 1. Enable OAI-PMH and OAI-PMH:AutoUpdateSets sysprefs 2. Create a biblio record with 1 item with CCODE of NFIC 3. In Administration > OAI Sets configuration create a set and define the mapping: Field: 952, Subfield: 8, Operator: is equal to, Value: FIC 4. Run the build_oai_sets.pl script: cd misc/migration_tools sudo koha-shell ./build_oai_sets.pl -i 5. Check what items are in the OAI set: sudo koha-mysql select * from oai_sets_biblios; 6. Observe your bib from step 2 is not in the set 7. [EDIT] Edit the item to have CCODE of FIC repeat step 5 and observe biblio is still not in OAI set 8. [ADD] Add a new item with CCODE of FIC and repeat step 5 and observe biblio still not in OAI set 9. [DELETE] Delete one of your 2 items and repeat step 5 and observe biblio still not in OAI set 10. Apply patch, update database and restart plack (instruction below on the latter 2 actions): cd installer/data/mysql sudo koha-shell ./updatedatabase.pl sudo koha-plack --restart 11. Enable new syspref OAI-PMH:AutoUpdateSetsEmbedItemData 12. [ADD] Repeat step 8 and observe biblio is now in the OAI set 13. [EDIT] Edit both items to have a CCODE of NFIC and repeat step 5 and observe bib now not in set 14. [EDIT] Edit one of the items to have CCODE of FIC and repeat step 5 and observe bib now in set 15. [DELETE] Delete all items off bib and repeat step 5 and observe bib no longer in set Sponsored-By: Catalyst IT --- C4/OAI/Sets.pm | 8 +++++++- cataloguing/additem.pl | 11 +++++++++-- installer/data/mysql/.updatedatabase.pl.swp | Bin 0 -> 28672 bytes ...add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl | 9 +++++++++ installer/data/mysql/sysprefs.sql | 3 ++- .../prog/en/modules/admin/preferences/web_services.pref | 9 ++++++++- 6 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 installer/data/mysql/.updatedatabase.pl.swp create mode 100644 installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl diff --git a/C4/OAI/Sets.pm b/C4/OAI/Sets.pm index 2d96fb14e6..29e8abfc2f 100644 --- a/C4/OAI/Sets.pm +++ b/C4/OAI/Sets.pm @@ -504,7 +504,6 @@ sub CalcOAISetsBiblio { next if not $mapping; my $rule_operator = $mapping->{'rule_operator'}; my $result = _evalRule($record, $mapping); - # First rule or 'or' rule is always pushed if (!@$rules || $rule_operator eq 'or') { push @$rules, [$result]; @@ -609,6 +608,13 @@ sub UpdateOAISetsBiblio { return unless($biblionumber and $record); + if (C4::Context->preference('OAI-PMH:AutoUpdateSetsEmbedItemData')) { + C4::Biblio::EmbedItemsInMarcBiblio({ + marc_record => $record, + biblionumber => $biblionumber + }); + } + my $sets_biblios; my @sets = CalcOAISetsBiblio($record); foreach (@sets) { diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index b0ce8b58c5..cc3768ff60 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -628,7 +628,6 @@ if ($op eq "additem") { exit; } - #------------------------------------------------------------------------------- } elsif ($op eq "edititem") { #------------------------------------------------------------------------------- @@ -737,7 +736,8 @@ if ($op eq "additem") { if $newitemlost && $newitemlost ge '1' && !$olditemlost; } $nextop="additem"; -} elsif ($op eq "delinkitem"){ + + } elsif ($op eq "delinkitem"){ my $analyticfield = '773'; if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){ $analyticfield = '773'; @@ -753,6 +753,13 @@ if ($op eq "additem") { my $modbibresult = ModBiblio($record, $biblionumber,''); } +# update OAI-PMH sets +if ($op) { + if (C4::Context->preference("OAI-PMH:AutoUpdateSets")) { + C4::OAI::Sets::UpdateOAISetsBiblio($biblionumber, $record); + } +} + # #------------------------------------------------------------------------------- # build screen with existing items. and "new" one diff --git a/installer/data/mysql/.updatedatabase.pl.swp b/installer/data/mysql/.updatedatabase.pl.swp new file mode 100644 index 0000000000000000000000000000000000000000..61306b23aac6b6d8829b2ac12665a61cbf607292 GIT bin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|xuq)a{y+3>l-MTpcLC@AvoKKEzYsX*?^eNgZ1)PV|MO6g^|ynkQ2&L3 zZv$Tq{;J^bgY*2=jg2nbe-E73=S_mY3(oO-S@3tj&qVzTaiPKX-v)QU?-2Yg!Drz@ zf%V@6$FdN*Lhv`hIe(uK{B>{>^)JOhXZx>#kAUAO_#eSHf*;rG9kBkZLjOv^UlIIB z1d{b%2Iu|5*93nFoY&VE1>Xw30sciWk+c05!FhiEk>D?Y!|jm5MvC>H2j~1K3H}^7 z=l2%D{{TJ!{|>@HXZz2BbN`hE|2;V8@8g314xHD|8U%{%KLgJ5<9flL2Iu(yTJWd9 zOYnaVHWF-q63$P-_Z5QUbnq2KAc#N^fgl1w1cC?z5eOm>L?DR3UvUKVzyCM)rGIBn zqW}Fr@9%fe!EGexk(^7?MKYOW50clY>{gPeNFE^BLh=)mdr7pNJ4k|05P={9K?H&b z1Q7@#5JVt|KoEf-0zm|V2m}%Mi$;LnV&c-XMBdB7y#MQ0tk?#<_@by^45NP;d3v?Q z`pV%4iZpvgJgN&Hd#tL#iwf3yub@)%7sxl6sT%!H{aad=MH787dgoM~^4<@n-;DMN z-g`r@MiX^}D&E2EX8nqau&OE1JDx1Z$d12L=X6zQT(M$BqkapCc2>V0K)<#tpSMQ! tD>w2cz4Q#PtDtu?WR1L`-`_AgM6Z0%FJ_tBJZG+=_X(8rOLFMi|4&*H2O9tY literal 0 HcmV?d00001 diff --git a/installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl b/installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl new file mode 100644 index 0000000000..7798c5c6d3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if ( CheckVersion($DBversion) ) { + $dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OAI-PMH:AutoUpdateSetEmbedItemData', '0', '', 'Embed item information when automatically updating OAI sets. Requires OAI-PMH:AutoUpdateSets syspref to be enabled', 'YesNo') }); + + $dbh->do(q{ UPDATE systempreferences SET explanation = 'Automatically update OAI sets when a bibliographic or item record is created or updated' WHERE variable = 'OAI-PMH:AutoUpdateSets' }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 25460 - Update OAI set when adding/editing/deleting item records)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 58bd459e94..3f930c4df8 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -353,7 +353,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('numSearchRSSResults','50',NULL,'Specify the maximum number of results to display on a RSS page of results','Integer'), ('OAI-PMH','0',NULL,'if ON, OAI-PMH server is enabled','YesNo'), ('OAI-PMH:archiveID','KOHA-OAI-TEST',NULL,'OAI-PMH archive identification','Free'), -('OAI-PMH:AutoUpdateSets','0','','Automatically update OAI sets when a bibliographic record is created or updated','YesNo'), +('OAI-PMH:AutoUpdateSets','0','','Automatically update OAI sets when a bibliographic or item record is created or updated','YesNo'), +('OAI-PMH:AutoUpdateSetEmbedItemData', '0', '', 'Embed item information when automatically updating OAI sets. Requires OAI-PMH:AutoUpdateSets syspref to be enabled', 'YesNo'), ('OAI-PMH:ConfFile','',NULL,'If empty, Koha OAI Server operates in normal mode, otherwise it operates in extended mode.','File'), ('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:MaxCount','50',NULL,'OAI-PMH maximum number of records by answer to ListRecords and ListIdentifiers queries','Integer'), 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 00556878c4..cb2cfad38e 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 @@ -64,7 +64,14 @@ Web services: choices: yes: Enable no: Disable - - automatic update of OAI-PMH sets when a bibliographic record is created or updated + - automatic update of OAI-PMH sets when a bibliographic or item record is created or updated + - + - pref: "OAI-PMH:AutoUpdateSetsEmbedItemData" + choices: + yes: Enable + no: Disable + - embedding of item data when automatically updating OAI-PMH sets. + -
NOTE: This needs OAI-PMH:AutoUpdateSets syspref to be enabled." - - Koha's deletedbiblio table - pref: "OAI-PMH:DeletedRecord" -- 2.11.0