Bugzilla – Attachment 23201 Details for
Bug 11315
Add support for subfield deletion when doing authority merges.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Add the overwriteSubfieldsOnMerge preference.
0001-Add-the-overwriteSubfieldsOnMerge-preference.patch (text/plain), 7.80 KB, created by
Frédérick Capovilla
on 2013-11-27 17:43:20 UTC
(
hide
)
Description:
Add the overwriteSubfieldsOnMerge preference.
Filename:
MIME Type:
Creator:
Frédérick Capovilla
Created:
2013-11-27 17:43:20 UTC
Size:
7.80 KB
patch
obsolete
>From 21ace48fd66f9c7462a5bac3ab7808d06671e876 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Fr=C3=A9d=C3=A9rick?= <frederick.capovilla@libeo.com> >Date: Wed, 27 Nov 2013 12:30:55 -0500 >Subject: [PATCH] Add the overwriteSubfieldsOnMerge preference. > >If activated, all of the biblio's subfields will be overwritten when its >associated authority is modified, so field deletions will be reflected >in the biblio records. >--- > C4/AuthoritiesMarc.pm | 26 +++++++++++-------- > installer/data/mysql/sysprefs.sql | 1 + > installer/data/mysql/updatedatabase.pl | 7 +++++ > .../en/modules/admin/preferences/authorities.pref | 7 +++++ > misc/migration_tools/merge_authority.pl | 6 +++- > 5 files changed, 34 insertions(+), 13 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 7443f36..766e11c 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -732,7 +732,8 @@ sub ModAuthority { > # In that case set system preference "dontmerge" to 1. Otherwise biblios will > # be updated. > unless(C4::Context->preference('dontmerge') eq '1'){ >- &merge($authid,$oldrecord,$authid,$record); >+ my $overwrite = C4::Context->preference('overwriteSubfieldsOnMerge'); >+ &merge($authid,$oldrecord,$authid,$record,$overwrite); > } else { > # save a record in need_merge_authorities table > my $sqlinsert="INSERT INTO need_merge_authorities (authid, done) ". >@@ -1407,7 +1408,7 @@ sub AddAuthorityTrees{ > > =head2 merge > >- $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto) >+ $ref= &merge(mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite) > > Could add some feature : Migrating from a typecode to an other for instance. > Then we should add some new parameter : bibliotargettag, authtargettag >@@ -1415,7 +1416,7 @@ Then we should add some new parameter : bibliotargettag, authtargettag > =cut > > sub merge { >- my ($mergefrom,$MARCfrom,$mergeto,$MARCto) = @_; >+ my ($mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite) = @_; > my ($counteditedbiblio,$countunmodifiedbiblio,$counterrors)=(0,0,0); > my $dbh=C4::Context->dbh; > my $authtypecodefrom = GetAuthTypeCode($mergefrom); >@@ -1491,17 +1492,20 @@ sub merge { > my $tag=$field->tag(); > if ($auth_number==$mergefrom) { > my $field_to=MARC::Field->new(($tag_to?$tag_to:$tag),$field->indicator(1),$field->indicator(2),"9"=>$mergeto); >- my $exclude='9'; >+ my $exclude='9'; > foreach my $subfield (grep {$_->[0] ne '9'} @record_to) { > $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >- $exclude.= $subfield->[0]; >+ $exclude.= $subfield->[0]; > } >- $exclude='['.$exclude.']'; >-# add subfields in $field not included in @record_to >- my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); >- foreach my $subfield (@restore) { >- $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >- } >+ $exclude='['.$exclude.']'; >+ unless($overwrite) { >+ # add subfields in $field not included in @record_to >+ my @restore= grep {$_->[0]!~/$exclude/} $field->subfields(); >+ foreach my $subfield (@restore) { >+ $field_to->add_subfields($subfield->[0] =>$subfield->[1]); >+ } >+ } >+ > $marcrecord->delete_field($field); > $marcrecord->insert_grouped_field($field_to); > $update=1; >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 6438483..b519747 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -289,6 +289,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('OverDriveLibraryID','','Library ID for OverDrive integration','','Integer'), > ('OverdueNoticeBcc','','','Email address to bcc outgoing overdue notices sent by email','free'), > ('OverduesBlockCirc','noblock','noblock|confirmation|block','When checking out an item should overdues block checkout, generate a confirmation dialogue, or allow checkout','Choice'), >+('overwriteSubfieldsOnMerge','0',NULL,'Overwrite the biblio\'s subfields when merging an authority record with a biblio record.','YesNo'), > ('patronimages','0',NULL,'Enable patron images for the Staff Client','YesNo'), > ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), > ('PatronSelfRegistrationAdditionalInstructions','','','A free text field to display additional instructions to newly self registered patrons.','free'), >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index a9e08e3..c68a815 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7771,6 +7771,13 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+$DBversion = "XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('overwriteSubfieldsOnMerge','0',NULL,'Overwrite the biblio\\'s subfields when merging an authority record with a biblio record.','YesNo')"); >+ print "Add the overwriteSubfieldsOnMerge preference.\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >index 2369e2f..5377746 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref >@@ -44,6 +44,13 @@ Authorities: > no: "Don't use" > - authority record numbers instead of text strings for searches from subject tracings. > - >+ - pref: overwriteSubfieldsOnMerge >+ default: no >+ choices: >+ yes: Overwrite >+ no: "Don't overwrite" >+ - "the biblio's subfields when merging an authority record with a biblio record." >+ - > - Use the following text for the contents of UNIMARC authority field 100 position (fixed length data elements). Do NOT include the date (position 00-05). > - pref: UNIMARCAuthorityField100 > defautl: "afrey50 ba0" >diff --git a/misc/migration_tools/merge_authority.pl b/misc/migration_tools/merge_authority.pl >index 8e09594..b6354fa 100755 >--- a/misc/migration_tools/merge_authority.pl >+++ b/misc/migration_tools/merge_authority.pl >@@ -58,6 +58,8 @@ my $authto = GetAuthority($mergeto); > my $authtypecodefrom = GetAuthTypeCode($mergefrom); > my $authtypecodeto = GetAuthTypeCode($mergeto); > >+my $overwrite = C4::Context->preference('overwriteSubfieldsOnMerge'); >+ > unless ($noconfirm || $batch) { > print "************\n"; > print "You will merge authority : $mergefrom ($authtypecodefrom)\n".$authfrom->as_formatted; >@@ -83,13 +85,13 @@ if ($batch) { > print "managing $authid\n" if $verbose; > my $MARCauth = GetAuthority($authid) ; > next unless ($MARCauth); >- merge($authid,$MARCauth,$authid,$MARCauth) if ($MARCauth); >+ merge($authid,$MARCauth,$authid,$MARCauth,$overwrite) if ($MARCauth); > } > $dbh->do("update need_merge_authorities set done=1 where done=2"); #DONE > } else { > my $MARCfrom = GetAuthority($mergefrom); > my $MARCto = GetAuthority($mergeto); >- &merge($mergefrom,$MARCfrom,$mergeto,$MARCto); >+ &merge($mergefrom,$MARCfrom,$mergeto,$MARCto,$overwrite); > #Could add mergefrom authority to mergeto rejected forms before deletion > DelAuthority($mergefrom) if ($mergefrom != $mergeto); > } >-- >1.7.2.5 >
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 11315
:
23201
|
25377
|
25404
|
30940
|
30941
|
58234
|
58235