Bugzilla – Attachment 100556 Details for
Bug 21708
Editing a record moves field 999 to first in the marcxml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24544: Add script to insert persistent identifiers
Bug-24544-Add-script-to-insert-persistent-identifi.patch (text/plain), 3.80 KB, created by
Marcel de Rooy
on 2020-03-11 13:38:32 UTC
(
hide
)
Description:
Bug 24544: Add script to insert persistent identifiers
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-03-11 13:38:32 UTC
Size:
3.80 KB
patch
obsolete
>From 54a0aca47a427d338b1ef5a915717728a9e519de Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 3 Mar 2020 13:58:35 +0000 >Subject: [PATCH] Bug 24544: Add script to insert persistent identifiers >Content-Type: text/plain; charset=utf-8 > >--- > misc/cronjobs/insert_persistent_id.pl | 101 ++++++++++++++++++++++++++++++++++ > 1 file changed, 101 insertions(+) > create mode 100755 misc/cronjobs/insert_persistent_id.pl > >diff --git a/misc/cronjobs/insert_persistent_id.pl b/misc/cronjobs/insert_persistent_id.pl >new file mode 100755 >index 0000000000..cb429d01c4 >--- /dev/null >+++ b/misc/cronjobs/insert_persistent_id.pl >@@ -0,0 +1,101 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Copyright (C) 2020 Rijksmuseum >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+=head1 NAME >+ >+insert_persistent_id.pl - cron script to insert persistent identifiers for biblio records and items in MARC records >+ >+=cut >+ >+use Modern::Perl; >+use Data::Dumper; >+use Getopt::Long; >+use Pod::Usage; >+ >+use C4::Context; >+use C4::Log; >+use Koha::Authorities; >+use Koha::Biblios; >+use Koha::Items; >+use Koha::PID::Controller; >+use Koha::Script -cron; >+ >+my $params = {}; >+GetOptions( >+ 'help|?|h' => \$params->{help}, >+ 'manual|m' => \$params->{manual}, >+ 'confirm|c' => \$params->{confirm}, >+ 'verbose|v' => \$params->{verbose}, >+ 'category:s' => \$params->{category}, >+ 'updates:i' => \$params->{updates}, >+ 'records:i' => \$params->{records}, >+ 'hours:i' => \$params->{hours}, >+) or pod2usage(2); >+pod2usage( -verbose => 2 ) if $params->{manual}; >+pod2usage(1) if $params->{help} || !$params->{confirm}; >+ >+cronlogaction(); >+ >+# main loop >+my $loopcontrol = { >+ read => 0, update => 0, time => time() + ($params->{hours}//0)*3600, >+}; >+my $rs = get_record_set($params); >+my $ctrl = Koha::PID::Controller->new; >+my $pid; >+while( my $obj = $rs->next ) { >+ $pid = $ctrl->get({ category => $params->{category}, object => $obj }); >+ my $result; >+ if( !$pid ) { >+ $pid = $ctrl->generate({ category => $params->{category}, kohaIdentifier => $obj->id, object => $obj }); >+ $result = $ctrl->insert({ pid => $pid, category => $params->{category}, kohaIdentifier => $obj->id, object => $obj }); >+ $loopcontrol->{update}++; >+ } >+print Dumper( $pid, $result->{success}, $obj->id ); >+ $loopcontrol->{read}++; >+ last if $params->{updates} && $loopcontrol->{update} > $params->{updates}; >+ last if $params->{records} && $loopcontrol->{read} > $params->{records}; >+ last if $params->{hours} && $loopcontrol->{time} > time(); >+} >+print Dumper( $loopcontrol ); >+ >+ >+sub get_record_set { >+ my $params = shift; >+ my $category = $params->{category}; >+ if( $category eq 'item' ) { >+ return Koha::Items->search; >+ } elsif( $category eq 'biblio' ) { >+ return Koha::Biblios->search; >+ } elsif( $category eq 'PERSO_NAME' || $category eq 'CORPO_NAME' || $category eq 'GEOGR_NAME' || $category eq 'MEETI_NAME' || $category eq 'TOPIC_TERM' ) { >+ return Koha::Authorities->search({ authtypecode => $category }); >+ } >+} >+ >+=head1 SYNOPSIS >+ >+./insert_persistent_id.pl -c >+ >+=head1 DESCRIPTION >+ >+This script adds persistent identifiers to authority, biblio and item records. >+ >+=head1 OPTIONS >+ >+=cut >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21708
:
83365
|
100469
|
100556
|
100557
|
100558
|
101334
|
101335
|
101377
|
101378