Bugzilla – Attachment 180600 Details for
Bug 39545
Construct more complete 773 content when creating a child record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39545: Better generation of 773 field for a child record (MARC21)
Bug-39545-Better-generation-of-773-field-for-a-chi.patch (text/plain), 5.96 KB, created by
Roman Dolny
on 2025-04-03 17:24:36 UTC
(
hide
)
Description:
Bug 39545: Better generation of 773 field for a child record (MARC21)
Filename:
MIME Type:
Creator:
Roman Dolny
Created:
2025-04-03 17:24:36 UTC
Size:
5.96 KB
patch
obsolete
>From 5dc61a412561c7d64e34cd7e64cffd33ff3fef97 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Thu, 3 Apr 2025 12:44:31 +0000 >Subject: [PATCH] Bug 39545: Better generation of 773 field for a child record > (MARC21) > >When creating a child record (New > New child record from Normal view) >the information put in field 773 is very basic, sometimes not >complete (e.g. only one ISBN, only 245 $a in 773 $t, 773 $w >missing 003 of the host record etc.) and put in random order. > >Test plan: >========== >1. Find any record to be a host record for an analytical record. You > can enrich the record with multiple 020, 490+830 fields, make sure that > there are 001 and 003 fields present. >2. From upper menu chose New > New child record. >3. See the generated field 773 - the subfields are incomplete and in > random order. >4. Apply the patch ; restart_all. >5. Repeat p. 2.-3. See that the generated 773 field contains now much > more information, including 773 $7 and also preset leader. > >Signed-off-by: Roman Dolny <roman.dolny@jezuici.pl> >--- > C4/Biblio.pm | 96 +++++++++++++++++++++++++++------------- > cataloguing/addbiblio.pl | 1 + > 2 files changed, 67 insertions(+), 30 deletions(-) > >diff --git a/C4/Biblio.pm b/C4/Biblio.pm >index 21cb96741a..f5025ee4c1 100644 >--- a/C4/Biblio.pm >+++ b/C4/Biblio.pm >@@ -3016,46 +3016,82 @@ sub prepare_host_field { > my $field; > my $host_field; > if ( $marcflavour eq 'MARC21' ) { >- if ( $field = $host->field('100') || $host->field('110') || $host->field('11') ) { >- my $s = $field->as_string('ab'); >- if ($s) { >- $sfd{a} = $s; >+ my $main_entry; >+ my @f773subfields; >+ if ( $host->field('1..') ) { >+ $main_entry = $host->field('1..')->clone; >+ if ( $main_entry->tag eq '111' ) { >+ $main_entry->delete_subfield( code => qr/[94j]/ ); >+ } else { >+ $main_entry->delete_subfield( code => qr/[94e]/ ); > } > } >- if ( $field = $host->field('245') ) { >- my $s = $field->as_string('a'); >- if ($s) { >- $sfd{t} = $s; >+ my $s7 = "nn" . substr( $host->leader, 6, 2 ); >+ if ($main_entry) { >+ my $c1 = 'n'; >+ if ( $main_entry->tag =~ /^1[01]/ ) { >+ $c1 = $main_entry->indicator('1') >+ if $main_entry->tag =~ /^1[01]/; >+ $c1 = $main_entry->tag eq '100' ? 1 : 2 unless $c1 =~ /\d/; > } >+ my $c0 = >+ ( $main_entry->tag eq '100' ) ? 'p' >+ : ( >+ $main_entry->tag eq '110' ? 'c' >+ : ( $main_entry->tag eq '111' ? 'm' : 'u' ) >+ ); >+ substr( $s7, 0, 2, $c0 . $c1 ); > } >- if ( $field = $host->field('260') ) { >- my $s = $field->as_string('abc'); >- if ($s) { >- $sfd{d} = $s; >- } >+ push @f773subfields, ( '7', $s7 ); >+ >+ if ($main_entry) { >+ my $a = $main_entry->as_string; >+ $a =~ s/\.$// unless $a =~ /\b[a-z]{1,2}\.$/i; >+ push @f773subfields, ( 'a', $a ); > } >- if ( $field = $host->field('240') ) { >- my $s = $field->as_string(); >- if ($s) { >- $sfd{b} = $s; >- } >+ >+ my $f245c = $host->field('245')->clone; >+ $f245c->delete_subfield( code => 'c' ); >+ my $t = $f245c->as_string; >+ $t =~ s/(\s*\/\s*|\.)$//; >+ $t = ucfirst substr( $t, $f245c->indicator('2') ); >+ push @f773subfields, ( 't', $t ); >+ if ( $host->field('250') ) { >+ my $b = $host->field('250')->as_string; >+ $b =~ s/\.$//; >+ push @f773subfields, ( 'b', $b ); > } >- if ( $field = $host->field('022') ) { >- my $s = $field->as_string('a'); >- if ($s) { >- $sfd{x} = $s; >- } >+ if ( $host->field('260') ) { >+ my $d = $host->field('260')->as_string('abc'); >+ $d =~ s/\.$//; >+ push @f773subfields, ( 'd', $d ); > } >- if ( $field = $host->field('020') ) { >- my $s = $field->as_string('a'); >- if ($s) { >- $sfd{z} = $s; >+ for my $f ( $host->field('8[013][01]') ) { >+ my $k = $f->as_string('abcdnjltnp'); >+ if ( $f->subfield('x') ) { >+ $k .= ', ISSN ' . $f->subfield('x'); >+ } >+ if ( $f->subfield('v') ) { >+ $k .= ' ; ' . $f->subfield('v'); > } >+ push @f773subfields, ( 'k', $k ); > } >- if ( $field = $host->field('001') ) { >- $sfd{w} = $field->data(),; >+ for my $f ( $host->field('022') ) { >+ push @f773subfields, ( 'x', $f->subfield('a') ) >+ if $f->subfield('a'); >+ } >+ for my $f ( $host->field('020') ) { >+ push @f773subfields, ( 'z', $f->subfield('a') ) >+ if $f->subfield('a'); >+ } >+ if ( $host->field('001') ) { >+ my $w = $host->field('001')->data; >+ if ( $host->field('003') ) { >+ $w = '(' . $host->field('003')->data . ')' . $w; >+ } >+ push @f773subfields, ( 'w', $w ); > } >- $host_field = MARC::Field->new( 773, '0', ' ', %sfd ); >+ $host_field = MARC::Field->new( 773, '0', ' ', @f773subfields ); > return $host_field; > } elsif ( $marcflavour eq 'UNIMARC' ) { > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index b4c3f677c1..1dccc842b8 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -644,6 +644,7 @@ if ($hostbiblionumber) { > if ($parentbiblio) { > my $marcflavour = C4::Context->preference('marcflavour'); > $record = MARC::Record->new(); >+ $record->leader(' naa a22 i 4500'); > SetMarcUnicodeFlag( $record, $marcflavour ); > my $hostfield = prepare_host_field( $parentbiblio, $marcflavour ); > if ($hostfield) { >-- >2.39.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 39545
:
180571
|
180572
| 180600 |
180601