Browse Source

Bug 25460: Update OAI sets when adding/editing/deleting item records

Also adds syspref to optionally choose to embed item information in record when adding/editing bibliographic and 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 <instancename>
 ./build_oai_sets.pl -i

5. Check what items are in the OAI set:
sudo koha-mysql <instancename>
select * from oai_sets_biblios;

6. Observe your bib from step 2 is not in the set
7. [ITEM EDIT] Edit the item to have CCODE of FIC repeat step 5 and observe biblio is still not in OAI set
8. [ITEM ADD] Add a new item with CCODE of FIC and repeat step 5 and observe biblio
still not in OAI set
9. [ITEM 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 <instancename>
./updatedatabase.pl
sudo koha-plack --restart <instancename>

11. Enable new syspref OAI-PMH:AutoUpdateSetsEmbedItemData
12. [ITEM ADD] Repeat step 8 and observe biblio is now in the OAI set
13. [ITEM EDIT] Edit both items to have a CCODE of NFIC and repeat step 5 and
observe bib now not in set
14. [ITEM EDIT] Edit one of the items to have CCODE of FIC and repeat step 5
and observe bib now in set
15. [ITEM DELETE] Delete all items off bib and repeat step 5 and observe bib
no longer in set

Sponsored-By: Catalyst IT

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
20.11.x
Alex Buckley 1 year ago
committed by Jonathan Druart
parent
commit
ac1a8adba2
  1. 7
      C4/OAI/Sets.pm
  2. 8
      cataloguing/additem.pl
  3. BIN
      installer/data/mysql/.updatedatabase.pl.swp
  4. 9
      installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl
  5. 3
      installer/data/mysql/mandatory/sysprefs.sql
  6. 9
      koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref

7
C4/OAI/Sets.pm

@ -609,6 +609,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) {

8
cataloguing/additem.pl

@ -769,6 +769,7 @@ if ($op eq "additem") {
}
$nextop="additem";
} elsif ($op eq "delinkitem"){
my $analyticfield = '773';
if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){
$analyticfield = '773';
@ -784,6 +785,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

BIN
installer/data/mysql/.updatedatabase.pl.swp

9
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";
}

3
installer/data/mysql/mandatory/sysprefs.sql

@ -362,7 +362,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'),

9
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.
- <br><strong>NOTE:</strong> This needs OAI-PMH:AutoUpdateSets syspref to be enabled."
-
- Koha's deletedbiblio table
- pref: "OAI-PMH:DeletedRecord"

Loading…
Cancel
Save