|
Lines 1-6
Link Here
|
| 1 |
package C4::AuthoritiesMarc; |
1 |
package C4::AuthoritiesMarc; |
| 2 |
|
2 |
|
| 3 |
# Copyright 2000-2002 Katipo Communications |
3 |
# Copyright 2000-2002 Katipo Communications |
|
|
4 |
# Copyright 2018 The National Library of Finland, University of Helsinki |
| 4 |
# |
5 |
# |
| 5 |
# This file is part of Koha. |
6 |
# This file is part of Koha. |
| 6 |
# |
7 |
# |
|
Lines 337-346
sub GuessAuthTypeCode {
Link Here
|
| 337 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
338 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
| 338 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
339 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
| 339 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
340 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
|
|
341 |
'147'=>{authtypecode=>'NAME_EVENT'}, |
| 340 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
342 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
| 341 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
343 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
| 342 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
344 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
| 343 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
345 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
|
|
346 |
'162'=>{authtypecode=>'MED_PERFRM'}, |
| 344 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
347 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
| 345 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
348 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
| 346 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
349 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
|
Lines 916-921
sub BuildSummary {
Link Here
|
| 916 |
# construct MARC21 summary |
919 |
# construct MARC21 summary |
| 917 |
# FIXME - looping over 1XX is questionable |
920 |
# FIXME - looping over 1XX is questionable |
| 918 |
# since MARC21 authority should have only one 1XX |
921 |
# since MARC21 authority should have only one 1XX |
|
|
922 |
use C4::Heading::MARC21; |
| 923 |
my $handler = C4::Heading::MARC21->new(); |
| 919 |
my $subfields_to_report; |
924 |
my $subfields_to_report; |
| 920 |
foreach my $field ($record->field('1..')) { |
925 |
foreach my $field ($record->field('1..')) { |
| 921 |
my $tag = $field->tag(); |
926 |
my $tag = $field->tag(); |
|
Lines 923-953
sub BuildSummary {
Link Here
|
| 923 |
# FIXME - 152 is not a good tag to use |
928 |
# FIXME - 152 is not a good tag to use |
| 924 |
# in MARC21 -- purely local tags really ought to be |
929 |
# in MARC21 -- purely local tags really ought to be |
| 925 |
# 9XX |
930 |
# 9XX |
| 926 |
if ($tag eq '100') { |
931 |
|
| 927 |
$subfields_to_report = 'abcdefghjklmnopqrstvxyz'; |
932 |
$subfields_to_report = $handler->get_auth_heading_subfields_to_report($tag); |
| 928 |
} elsif ($tag eq '110') { |
933 |
|
| 929 |
$subfields_to_report = 'abcdefghklmnoprstvxyz'; |
|
|
| 930 |
} elsif ($tag eq '111') { |
| 931 |
$subfields_to_report = 'acdefghklnpqstvxyz'; |
| 932 |
} elsif ($tag eq '130') { |
| 933 |
$subfields_to_report = 'adfghklmnoprstvxyz'; |
| 934 |
} elsif ($tag eq '148') { |
| 935 |
$subfields_to_report = 'abvxyz'; |
| 936 |
} elsif ($tag eq '150') { |
| 937 |
$subfields_to_report = 'abvxyz'; |
| 938 |
} elsif ($tag eq '151') { |
| 939 |
$subfields_to_report = 'avxyz'; |
| 940 |
} elsif ($tag eq '155') { |
| 941 |
$subfields_to_report = 'abvxyz'; |
| 942 |
} elsif ($tag eq '180') { |
| 943 |
$subfields_to_report = 'vxyz'; |
| 944 |
} elsif ($tag eq '181') { |
| 945 |
$subfields_to_report = 'vxyz'; |
| 946 |
} elsif ($tag eq '182') { |
| 947 |
$subfields_to_report = 'vxyz'; |
| 948 |
} elsif ($tag eq '185') { |
| 949 |
$subfields_to_report = 'vxyz'; |
| 950 |
} |
| 951 |
if ($subfields_to_report) { |
934 |
if ($subfields_to_report) { |
| 952 |
push @authorized, { |
935 |
push @authorized, { |
| 953 |
heading => $field->as_string($subfields_to_report), |
936 |
heading => $field->as_string($subfields_to_report), |
|
Lines 1071-1114
sub GetAuthorizedHeading {
Link Here
|
| 1071 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
1054 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
| 1072 |
} |
1055 |
} |
| 1073 |
} else { |
1056 |
} else { |
|
|
1057 |
use C4::Heading::MARC21; |
| 1058 |
my $handler = C4::Heading::MARC21->new(); |
| 1059 |
|
| 1074 |
foreach my $field ($record->field('1..')) { |
1060 |
foreach my $field ($record->field('1..')) { |
| 1075 |
my $tag = $field->tag(); |
1061 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
| 1076 |
next if "152" eq $tag; |
1062 |
return $field->as_string($subfields) if ($subfields); |
| 1077 |
# FIXME - 152 is not a good tag to use |
|
|
| 1078 |
# in MARC21 -- purely local tags really ought to be |
| 1079 |
# 9XX |
| 1080 |
if ($tag eq '100') { |
| 1081 |
return $field->as_string('abcdefghjklmnopqrstvxyz68'); |
| 1082 |
} elsif ($tag eq '110') { |
| 1083 |
return $field->as_string('abcdefghklmnoprstvxyz68'); |
| 1084 |
} elsif ($tag eq '111') { |
| 1085 |
return $field->as_string('acdefghklnpqstvxyz68'); |
| 1086 |
} elsif ($tag eq '130') { |
| 1087 |
return $field->as_string('adfghklmnoprstvxyz68'); |
| 1088 |
} elsif ($tag eq '148') { |
| 1089 |
return $field->as_string('abvxyz68'); |
| 1090 |
} elsif ($tag eq '150') { |
| 1091 |
return $field->as_string('abvxyz68'); |
| 1092 |
} elsif ($tag eq '151') { |
| 1093 |
return $field->as_string('avxyz68'); |
| 1094 |
} elsif ($tag eq '155') { |
| 1095 |
return $field->as_string('abvxyz68'); |
| 1096 |
} elsif ($tag eq '180') { |
| 1097 |
return $field->as_string('vxyz68'); |
| 1098 |
} elsif ($tag eq '181') { |
| 1099 |
return $field->as_string('vxyz68'); |
| 1100 |
} elsif ($tag eq '182') { |
| 1101 |
return $field->as_string('vxyz68'); |
| 1102 |
} elsif ($tag eq '185') { |
| 1103 |
return $field->as_string('vxyz68'); |
| 1104 |
} else { |
| 1105 |
return $field->as_string(); |
| 1106 |
} |
| 1107 |
} |
1063 |
} |
| 1108 |
} |
1064 |
} |
| 1109 |
return; |
1065 |
return; |
| 1110 |
} |
1066 |
} |
| 1111 |
|
1067 |
|
|
|
1068 |
=head2 CompareFieldWithAuthority |
| 1069 |
|
| 1070 |
$match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) |
| 1071 |
|
| 1072 |
Takes a MARC::Field from a bibliographic record and an authid, and returns true if they match. |
| 1073 |
|
| 1074 |
=cut |
| 1075 |
|
| 1076 |
sub CompareFieldWithAuthority { |
| 1077 |
my $args = shift; |
| 1078 |
|
| 1079 |
my $record = GetAuthority($args->{authid}); |
| 1080 |
return unless (ref $record eq 'MARC::Record'); |
| 1081 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 1082 |
# UNIMARC has same subfields for bibs and authorities |
| 1083 |
foreach my $field ($record->field('2..')) { |
| 1084 |
return compare_fields($field, $args->{field}, 'abcdefghijlmnopqrstuvwxyz'); |
| 1085 |
} |
| 1086 |
} else { |
| 1087 |
use C4::Heading::MARC21; |
| 1088 |
my $handler = C4::Heading::MARC21->new(); |
| 1089 |
|
| 1090 |
foreach my $field ($record->field('1..')) { |
| 1091 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
| 1092 |
return compare_fields($field, $args->{field}, $subfields) if ($subfields); |
| 1093 |
} |
| 1094 |
} |
| 1095 |
return 0; |
| 1096 |
} |
| 1097 |
|
| 1112 |
=head2 BuildAuthHierarchies |
1098 |
=head2 BuildAuthHierarchies |
| 1113 |
|
1099 |
|
| 1114 |
$text= &BuildAuthHierarchies( $authid, $force) |
1100 |
$text= &BuildAuthHierarchies( $authid, $force) |
|
Lines 1570-1575
sub get_auth_type_location {
Link Here
|
| 1570 |
} |
1556 |
} |
| 1571 |
} |
1557 |
} |
| 1572 |
|
1558 |
|
|
|
1559 |
=head2 compare_fields |
| 1560 |
|
| 1561 |
my match = compare_fields($field1, $field2, 'abcde'); |
| 1562 |
|
| 1563 |
Compares the listed subfields of both fields and return true if they all match |
| 1564 |
|
| 1565 |
=cut |
| 1566 |
|
| 1567 |
sub compare_fields { |
| 1568 |
my ($field1, $field2, $subfields) = @_; |
| 1569 |
|
| 1570 |
foreach my $subfield (split(//, $subfields)) { |
| 1571 |
my $subfield1 = $field1->subfield($subfield) // ''; |
| 1572 |
my $subfield2 = $field2->subfield($subfield) // ''; |
| 1573 |
return 0 unless $subfield1 eq $subfield2; |
| 1574 |
} |
| 1575 |
return 1; |
| 1576 |
} |
| 1577 |
|
| 1578 |
|
| 1573 |
END { } # module clean-up code here (global destructor) |
1579 |
END { } # module clean-up code here (global destructor) |
| 1574 |
|
1580 |
|
| 1575 |
1; |
1581 |
1; |
|
Lines 1580-1585
__END__
Link Here
|
| 1580 |
Koha Development Team <http://koha-community.org/> |
1586 |
Koha Development Team <http://koha-community.org/> |
| 1581 |
|
1587 |
|
| 1582 |
Paul POULAIN paul.poulain@free.fr |
1588 |
Paul POULAIN paul.poulain@free.fr |
|
|
1589 |
Ere Maijala ere.maijala@helsinki.fi |
| 1583 |
|
1590 |
|
| 1584 |
=cut |
1591 |
=cut |
| 1585 |
|
1592 |
|