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