Bug 41685: Sort seefrom/seealso in BuildSummary
Test plan (MARC21):
[1] Create an authority record, say a term. Include two 450s, the first
one starting with Z and second with A. Include five 550s, where two
are narrower ($w==h), two broader ($w==g) and one without $w. Make
sure that the terms will sort differently than the field order (go
back in alphabet when filling subsequent $a's or so).
[2] Perform an authority search that includes the new authority.
[3] Verify that the terms in the Summary column for this authority
are sorted first on hierarchy, second alphabetically. The one
without hierarchy should be in the middle.
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
7d60cc280a
commit
27fb770e77
|
|
@ -1120,7 +1120,8 @@ sub BuildSummary {
|
|||
};
|
||||
}
|
||||
}
|
||||
foreach my $field ( $record->field('4..') ) { #See From
|
||||
my @fields = _marc21_sort_hierarchy_alpha( $record->field('4..') );
|
||||
foreach my $field (@fields) { #See From
|
||||
my $type = 'seefrom';
|
||||
$type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
|
||||
if ( $type eq 'notapplicable' ) {
|
||||
|
|
@ -1143,7 +1144,8 @@ sub BuildSummary {
|
|||
};
|
||||
}
|
||||
}
|
||||
foreach my $field ( $record->field('5..') ) { #See Also
|
||||
@fields = _marc21_sort_hierarchy_alpha( $record->field('5..') );
|
||||
foreach my $field (@fields) { #See Also
|
||||
my $type = 'seealso';
|
||||
$type = ( $marc21controlrefs{ substr $field->subfield('w'), 0, 1 } || '' ) if ( $field->subfield('w') );
|
||||
if ( $type eq 'notapplicable' ) {
|
||||
|
|
@ -1275,6 +1277,18 @@ sub BuildSummary {
|
|||
return \%summary;
|
||||
}
|
||||
|
||||
sub _marc21_sort_hierarchy_alpha {
|
||||
my @fields = @_;
|
||||
return sort {
|
||||
# Sort broader (g) - no hierarchy (tric:gh) - narrower (h)
|
||||
my $a_hier = $a->subfield('w') // q{}; $a_hier = 'gh' if $a_hier !~ /^[gh]$/;
|
||||
my $b_hier = $b->subfield('w') // q{}; $b_hier = 'gh' if $b_hier !~ /^[gh]$/;
|
||||
|
||||
# When hierarchy does not resolve, sort on $a
|
||||
$a_hier cmp $b_hier || $a->subfield('a') cmp $b->subfield('a');
|
||||
} @fields;
|
||||
}
|
||||
|
||||
=head2 GetAuthorizedHeading
|
||||
|
||||
$heading = &GetAuthorizedHeading({ record => $record, authid => $authid })
|
||||
|
|
|
|||
Loading…
Reference in New Issue