|
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 359-368
sub GuessAuthTypeCode {
Link Here
|
| 359 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
360 |
'110'=>{authtypecode=>'CORPO_NAME'}, |
| 360 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
361 |
'111'=>{authtypecode=>'MEETI_NAME'}, |
| 361 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
362 |
'130'=>{authtypecode=>'UNIF_TITLE'}, |
|
|
363 |
'147'=>{authtypecode=>'NAME_EVENT'}, |
| 362 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
364 |
'148'=>{authtypecode=>'CHRON_TERM'}, |
| 363 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
365 |
'150'=>{authtypecode=>'TOPIC_TERM'}, |
| 364 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
366 |
'151'=>{authtypecode=>'GEOGR_NAME'}, |
| 365 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
367 |
'155'=>{authtypecode=>'GENRE/FORM'}, |
|
|
368 |
'162'=>{authtypecode=>'MED_PERFRM'}, |
| 366 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
369 |
'180'=>{authtypecode=>'GEN_SUBDIV'}, |
| 367 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
370 |
'181'=>{authtypecode=>'GEO_SUBDIV'}, |
| 368 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
371 |
'182'=>{authtypecode=>'CHRON_SUBD'}, |
|
Lines 938-943
sub BuildSummary {
Link Here
|
| 938 |
# construct MARC21 summary |
941 |
# construct MARC21 summary |
| 939 |
# FIXME - looping over 1XX is questionable |
942 |
# FIXME - looping over 1XX is questionable |
| 940 |
# since MARC21 authority should have only one 1XX |
943 |
# since MARC21 authority should have only one 1XX |
|
|
944 |
use C4::Heading::MARC21; |
| 945 |
my $handler = C4::Heading::MARC21->new(); |
| 941 |
my $subfields_to_report; |
946 |
my $subfields_to_report; |
| 942 |
foreach my $field ($record->field('1..')) { |
947 |
foreach my $field ($record->field('1..')) { |
| 943 |
my $tag = $field->tag(); |
948 |
my $tag = $field->tag(); |
|
Lines 945-975
sub BuildSummary {
Link Here
|
| 945 |
# FIXME - 152 is not a good tag to use |
950 |
# FIXME - 152 is not a good tag to use |
| 946 |
# in MARC21 -- purely local tags really ought to be |
951 |
# in MARC21 -- purely local tags really ought to be |
| 947 |
# 9XX |
952 |
# 9XX |
| 948 |
if ($tag eq '100') { |
953 |
|
| 949 |
$subfields_to_report = 'abcdefghjklmnopqrstvxyz'; |
954 |
$subfields_to_report = $handler->get_auth_heading_subfields_to_report($tag); |
| 950 |
} elsif ($tag eq '110') { |
955 |
|
| 951 |
$subfields_to_report = 'abcdefghklmnoprstvxyz'; |
|
|
| 952 |
} elsif ($tag eq '111') { |
| 953 |
$subfields_to_report = 'acdefghklnpqstvxyz'; |
| 954 |
} elsif ($tag eq '130') { |
| 955 |
$subfields_to_report = 'adfghklmnoprstvxyz'; |
| 956 |
} elsif ($tag eq '148') { |
| 957 |
$subfields_to_report = 'abvxyz'; |
| 958 |
} elsif ($tag eq '150') { |
| 959 |
$subfields_to_report = 'abvxyz'; |
| 960 |
} elsif ($tag eq '151') { |
| 961 |
$subfields_to_report = 'avxyz'; |
| 962 |
} elsif ($tag eq '155') { |
| 963 |
$subfields_to_report = 'abvxyz'; |
| 964 |
} elsif ($tag eq '180') { |
| 965 |
$subfields_to_report = 'vxyz'; |
| 966 |
} elsif ($tag eq '181') { |
| 967 |
$subfields_to_report = 'vxyz'; |
| 968 |
} elsif ($tag eq '182') { |
| 969 |
$subfields_to_report = 'vxyz'; |
| 970 |
} elsif ($tag eq '185') { |
| 971 |
$subfields_to_report = 'vxyz'; |
| 972 |
} |
| 973 |
if ($subfields_to_report) { |
956 |
if ($subfields_to_report) { |
| 974 |
push @authorized, { |
957 |
push @authorized, { |
| 975 |
heading => $field->as_string($subfields_to_report), |
958 |
heading => $field->as_string($subfields_to_report), |
|
Lines 1093-1136
sub GetAuthorizedHeading {
Link Here
|
| 1093 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
1076 |
return $field->as_string('abcdefghijlmnopqrstuvwxyz'); |
| 1094 |
} |
1077 |
} |
| 1095 |
} else { |
1078 |
} else { |
|
|
1079 |
use C4::Heading::MARC21; |
| 1080 |
my $handler = C4::Heading::MARC21->new(); |
| 1081 |
|
| 1096 |
foreach my $field ($record->field('1..')) { |
1082 |
foreach my $field ($record->field('1..')) { |
| 1097 |
my $tag = $field->tag(); |
1083 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
| 1098 |
next if "152" eq $tag; |
1084 |
return $field->as_string($subfields) if ($subfields); |
| 1099 |
# FIXME - 152 is not a good tag to use |
|
|
| 1100 |
# in MARC21 -- purely local tags really ought to be |
| 1101 |
# 9XX |
| 1102 |
if ($tag eq '100') { |
| 1103 |
return $field->as_string('abcdefghjklmnopqrstvxyz68'); |
| 1104 |
} elsif ($tag eq '110') { |
| 1105 |
return $field->as_string('abcdefghklmnoprstvxyz68'); |
| 1106 |
} elsif ($tag eq '111') { |
| 1107 |
return $field->as_string('acdefghklnpqstvxyz68'); |
| 1108 |
} elsif ($tag eq '130') { |
| 1109 |
return $field->as_string('adfghklmnoprstvxyz68'); |
| 1110 |
} elsif ($tag eq '148') { |
| 1111 |
return $field->as_string('abvxyz68'); |
| 1112 |
} elsif ($tag eq '150') { |
| 1113 |
return $field->as_string('abvxyz68'); |
| 1114 |
} elsif ($tag eq '151') { |
| 1115 |
return $field->as_string('avxyz68'); |
| 1116 |
} elsif ($tag eq '155') { |
| 1117 |
return $field->as_string('abvxyz68'); |
| 1118 |
} elsif ($tag eq '180') { |
| 1119 |
return $field->as_string('vxyz68'); |
| 1120 |
} elsif ($tag eq '181') { |
| 1121 |
return $field->as_string('vxyz68'); |
| 1122 |
} elsif ($tag eq '182') { |
| 1123 |
return $field->as_string('vxyz68'); |
| 1124 |
} elsif ($tag eq '185') { |
| 1125 |
return $field->as_string('vxyz68'); |
| 1126 |
} else { |
| 1127 |
return $field->as_string(); |
| 1128 |
} |
| 1129 |
} |
1085 |
} |
| 1130 |
} |
1086 |
} |
| 1131 |
return; |
1087 |
return; |
| 1132 |
} |
1088 |
} |
| 1133 |
|
1089 |
|
|
|
1090 |
=head2 CompareFieldWithAuthority |
| 1091 |
|
| 1092 |
$match = &CompareFieldWithAuthority({ field => $field, authid => $authid }) |
| 1093 |
|
| 1094 |
Takes a MARC::Field from a bibliographic record and an authid, and returns true if they match. |
| 1095 |
|
| 1096 |
=cut |
| 1097 |
|
| 1098 |
sub CompareFieldWithAuthority { |
| 1099 |
my $args = shift; |
| 1100 |
|
| 1101 |
my $record = GetAuthority($args->{authid}); |
| 1102 |
return unless (ref $record eq 'MARC::Record'); |
| 1103 |
if (C4::Context->preference('marcflavour') eq 'UNIMARC') { |
| 1104 |
# UNIMARC has same subfields for bibs and authorities |
| 1105 |
foreach my $field ($record->field('2..')) { |
| 1106 |
return compare_fields($field, $args->{field}, 'abcdefghijlmnopqrstuvwxyz'); |
| 1107 |
} |
| 1108 |
} else { |
| 1109 |
use C4::Heading::MARC21; |
| 1110 |
my $handler = C4::Heading::MARC21->new(); |
| 1111 |
|
| 1112 |
foreach my $field ($record->field('1..')) { |
| 1113 |
my $subfields = $handler->get_valid_bib_heading_subfields($field->tag()); |
| 1114 |
return compare_fields($field, $args->{field}, $subfields) if ($subfields); |
| 1115 |
} |
| 1116 |
} |
| 1117 |
return 0; |
| 1118 |
} |
| 1119 |
|
| 1134 |
=head2 BuildAuthHierarchies |
1120 |
=head2 BuildAuthHierarchies |
| 1135 |
|
1121 |
|
| 1136 |
$text= &BuildAuthHierarchies( $authid, $force) |
1122 |
$text= &BuildAuthHierarchies( $authid, $force) |
|
Lines 1592-1597
sub get_auth_type_location {
Link Here
|
| 1592 |
} |
1578 |
} |
| 1593 |
} |
1579 |
} |
| 1594 |
|
1580 |
|
|
|
1581 |
=head2 compare_fields |
| 1582 |
|
| 1583 |
my match = compare_fields($field1, $field2, 'abcde'); |
| 1584 |
|
| 1585 |
Compares the listed subfields of both fields and return true if they all match |
| 1586 |
|
| 1587 |
=cut |
| 1588 |
|
| 1589 |
sub compare_fields { |
| 1590 |
my ($field1, $field2, $subfields) = @_; |
| 1591 |
|
| 1592 |
foreach my $subfield (split(//, $subfields)) { |
| 1593 |
my $subfield1 = $field1->subfield($subfield) // ''; |
| 1594 |
my $subfield2 = $field2->subfield($subfield) // ''; |
| 1595 |
return 0 unless $subfield1 eq $subfield2; |
| 1596 |
} |
| 1597 |
return 1; |
| 1598 |
} |
| 1599 |
|
| 1600 |
|
| 1595 |
END { } # module clean-up code here (global destructor) |
1601 |
END { } # module clean-up code here (global destructor) |
| 1596 |
|
1602 |
|
| 1597 |
1; |
1603 |
1; |
|
Lines 1602-1607
__END__
Link Here
|
| 1602 |
Koha Development Team <http://koha-community.org/> |
1608 |
Koha Development Team <http://koha-community.org/> |
| 1603 |
|
1609 |
|
| 1604 |
Paul POULAIN paul.poulain@free.fr |
1610 |
Paul POULAIN paul.poulain@free.fr |
|
|
1611 |
Ere Maijala ere.maijala@helsinki.fi |
| 1605 |
|
1612 |
|
| 1606 |
=cut |
1613 |
=cut |
| 1607 |
|
1614 |
|