@@ -, +, @@ records cd misc/migration_tools sudo koha-shell ./build_oai_sets.pl -i --- C4/OAI/Sets.pm | 7 +++++++ cataloguing/additem.pl | 8 ++++++++ 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, 34 insertions(+), 2 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 --- a/C4/OAI/Sets.pm +++ a/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) { --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -757,6 +757,7 @@ if ($op eq "additem") { } $nextop="additem"; } elsif ($op eq "delinkitem"){ + my $analyticfield = '773'; if ($marcflavour eq 'MARC21' || $marcflavour eq 'NORMARC'){ $analyticfield = '773'; @@ -772,6 +773,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 --- a/installer/data/mysql/atomicupdate/bug_25460-add_oai-PMH:AutoUpdateSetsEmbedItemData_syspref.perl +++ a/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"; +} --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -358,7 +358,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'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ a/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" --