Lines 1-6
Link Here
|
1 |
package Koha::Z3950Responder::GenericSession; |
1 |
package Koha::Z3950Responder::GenericSession; |
2 |
|
2 |
|
3 |
# Copyright The National Library of Finland 2018 |
3 |
# Copyright The National Library of Finland 2018-2019 |
4 |
# |
4 |
# |
5 |
# This file is part of Koha. |
5 |
# This file is part of Koha. |
6 |
# |
6 |
# |
Lines 61-67
sub start_search {
Link Here
|
61 |
my $query = $args->{RPN}->{'query'}->to_koha($self->{'attribute_mappings'}->{$database}); |
61 |
my $query = $args->{RPN}->{'query'}->to_koha($self->{'attribute_mappings'}->{$database}); |
62 |
$self->log_debug(" parsed search: $query"); |
62 |
$self->log_debug(" parsed search: $query"); |
63 |
my @operands = $query; |
63 |
my @operands = $query; |
64 |
(undef, $built_query) = $builder->build_query_compat( undef, \@operands, undef, undef, undef, 0); |
64 |
my $sort = $self->_convert_sort_rules($args->{SRW_SORTKEYS} // ''); |
|
|
65 |
|
66 |
(undef, $built_query) = $builder->build_query_compat( undef, \@operands, undef, undef, $sort, 0); |
65 |
|
67 |
|
66 |
my ($error, $marcresults, $hits ) = $searcher->simple_search_compat($built_query, 0, $num_to_prefetch); |
68 |
my ($error, $marcresults, $hits ) = $searcher->simple_search_compat($built_query, 0, $num_to_prefetch); |
67 |
if (defined $error) { |
69 |
if (defined $error) { |
Lines 108-111
sub fetch_record {
Link Here
|
108 |
return $resultset->{cached_results}[$offset - $resultset->{cached_offset}]; |
110 |
return $resultset->{cached_results}[$offset - $resultset->{cached_offset}]; |
109 |
} |
111 |
} |
110 |
|
112 |
|
|
|
113 |
=head2 Internal methods |
114 |
|
115 |
=head3 _convert_sort_rules |
116 |
|
117 |
my $sort = $self->_convert_sort_rules($srw_sortkeys); |
118 |
|
119 |
Convert SRW_SORTKEYS from SimpleServer to Koha's format |
120 |
|
121 |
=cut |
122 |
|
123 |
sub _convert_sort_rules { |
124 |
my ( $self, $srw_sortkeys ) = @_; |
125 |
|
126 |
my @result; |
127 |
my @sortkeys = split(' ', $srw_sortkeys); |
128 |
foreach my $sortkey (@sortkeys) { |
129 |
my @parts = split(',', $sortkey); |
130 |
my $field = $parts[0]; |
131 |
my $direction = $parts[2] // 1 == 1 ? 'asc' : 'desc'; |
132 |
push @result, $field . '_' . $direction; |
133 |
} |
134 |
return \ |
135 |
} |
136 |
|
111 |
1; |
137 |
1; |
112 |
- |
|
|