|
Lines 952-957
sub get_marc_host {
Link Here
|
| 952 |
} |
952 |
} |
| 953 |
} |
953 |
} |
| 954 |
|
954 |
|
|
|
955 |
=head3 get_marc_volumes |
| 956 |
|
| 957 |
my $volumes = $self->get_marc_volumes(); |
| 958 |
|
| 959 |
Returns an array of MARCXML data, which are analytic parts of |
| 960 |
this object (MARC21 773$w points to this) |
| 961 |
|
| 962 |
=cut |
| 963 |
|
| 964 |
sub get_marc_volumes { |
| 965 |
my ($self, $max_results) = @_; |
| 966 |
|
| 967 |
return [] if (C4::Context->preference('marcflavour') ne 'MARC21'); |
| 968 |
|
| 969 |
my $searchstr = $self->get_volumes_query; |
| 970 |
|
| 971 |
if (defined($searchstr)) { |
| 972 |
my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); |
| 973 |
my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( $searchstr, 0, $max_results ); |
| 974 |
$self->{_marc_volumes} = $results if ( defined($results) && scalar(@$results) ); |
| 975 |
} |
| 976 |
|
| 977 |
return $self->{_marc_volumes} || []; |
| 978 |
} |
| 979 |
|
| 980 |
=head2 get_volumes_query |
| 981 |
|
| 982 |
Returns a query which can be used to search for all component parts of MARC21 biblios |
| 983 |
|
| 984 |
=cut |
| 985 |
|
| 986 |
sub get_volumes_query { |
| 987 |
my ($self) = @_; |
| 988 |
|
| 989 |
my $marc = $self->metadata->record; |
| 990 |
|
| 991 |
my $searchstr; |
| 992 |
if ( C4::Context->preference('UseControlNumber') ) { |
| 993 |
my $pf001 = $marc->field('001') || undef; |
| 994 |
|
| 995 |
if ( defined($pf001) ) { |
| 996 |
$searchstr = "("; |
| 997 |
my $pf003 = $marc->field('003') || undef; |
| 998 |
|
| 999 |
if ( !defined($pf003) ) { |
| 1000 |
# search for 773$w='Host001' |
| 1001 |
$searchstr .= "rcn:" . $pf001->data(); |
| 1002 |
} |
| 1003 |
else { |
| 1004 |
$searchstr .= "("; |
| 1005 |
# search for (773$w='Host001' and 003='Host003') or 773$w='(Host003)Host001' |
| 1006 |
$searchstr .= "(rcn:" . $pf001->data() . " AND cni:" . $pf003->data() . ")"; |
| 1007 |
$searchstr .= " OR rcn:\"" . $pf003->data() . " " . $pf001->data() . "\""; |
| 1008 |
$searchstr .= ")"; |
| 1009 |
} |
| 1010 |
|
| 1011 |
# exclude monograph and serial component part records |
| 1012 |
$searchstr .= " NOT (bib-level:a OR bib-level:b)"; |
| 1013 |
$searchstr .= ")"; |
| 1014 |
} |
| 1015 |
} |
| 1016 |
else { |
| 1017 |
my $cleaned_title = $marc->title; |
| 1018 |
$cleaned_title =~ tr|/||; |
| 1019 |
$searchstr = "ti,phr:($cleaned_title)"; |
| 1020 |
} |
| 1021 |
|
| 1022 |
return $searchstr; |
| 1023 |
} |
| 1024 |
|
| 955 |
=head2 Internal methods |
1025 |
=head2 Internal methods |
| 956 |
|
1026 |
|
| 957 |
=head3 type |
1027 |
=head3 type |