| Filename | /usr/share/koha/lib/C4/Search/PazPar2.pm |
| Statements | Executed 16 statements in 1.39ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 33µs | 42µs | C4::Search::PazPar2::BEGIN@20 |
| 1 | 1 | 1 | 31µs | 130µs | C4::Search::PazPar2::BEGIN@26 |
| 1 | 1 | 1 | 30µs | 34µs | C4::Search::PazPar2::BEGIN@23 |
| 1 | 1 | 1 | 22µs | 29µs | C4::Search::PazPar2::BEGIN@24 |
| 1 | 1 | 1 | 21µs | 24µs | C4::Search::PazPar2::BEGIN@25 |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::init |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::new |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::record |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::search |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::show |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::stat |
| 0 | 0 | 0 | 0s | 0s | C4::Search::PazPar2::termlist |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package C4::Search::PazPar2; | ||||
| 2 | |||||
| 3 | # Copyright (C) 2007 LibLime | ||||
| 4 | # | ||||
| 5 | # This file is part of Koha. | ||||
| 6 | # | ||||
| 7 | # Koha is free software; you can redistribute it and/or modify it under the | ||||
| 8 | # terms of the GNU General Public License as published by the Free Software | ||||
| 9 | # Foundation; either version 2 of the License, or (at your option) any later | ||||
| 10 | # version. | ||||
| 11 | # | ||||
| 12 | # Koha is distributed in the hope that it will be useful, but WITHOUT ANY | ||||
| 13 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | ||||
| 14 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. | ||||
| 15 | # | ||||
| 16 | # You should have received a copy of the GNU General Public License along | ||||
| 17 | # with Koha; if not, write to the Free Software Foundation, Inc., | ||||
| 18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||||
| 19 | |||||
| 20 | 3 | 56µs | 2 | 52µs | # spent 42µs (33+10) within C4::Search::PazPar2::BEGIN@20 which was called:
# once (33µs+10µs) by C4::Search::BEGIN@25 at line 20 # spent 42µs making 1 call to C4::Search::PazPar2::BEGIN@20
# spent 10µs making 1 call to strict::import |
| 21 | #use warnings; FIXME - Bug 2505 | ||||
| 22 | |||||
| 23 | 3 | 57µs | 2 | 38µs | # spent 34µs (30+4) within C4::Search::PazPar2::BEGIN@23 which was called:
# once (30µs+4µs) by C4::Search::BEGIN@25 at line 23 # spent 34µs making 1 call to C4::Search::PazPar2::BEGIN@23
# spent 4µs making 1 call to UNIVERSAL::import |
| 24 | 3 | 54µs | 2 | 36µs | # spent 29µs (22+7) within C4::Search::PazPar2::BEGIN@24 which was called:
# once (22µs+7µs) by C4::Search::BEGIN@25 at line 24 # spent 29µs making 1 call to C4::Search::PazPar2::BEGIN@24
# spent 7µs making 1 call to UNIVERSAL::import |
| 25 | 3 | 50µs | 2 | 27µs | # spent 24µs (21+3) within C4::Search::PazPar2::BEGIN@25 which was called:
# once (21µs+3µs) by C4::Search::BEGIN@25 at line 25 # spent 24µs making 1 call to C4::Search::PazPar2::BEGIN@25
# spent 3µs making 1 call to UNIVERSAL::import |
| 26 | 3 | 1.17ms | 2 | 156µs | # spent 130µs (31+99) within C4::Search::PazPar2::BEGIN@26 which was called:
# once (31µs+99µs) by C4::Search::BEGIN@25 at line 26 # spent 130µs making 1 call to C4::Search::PazPar2::BEGIN@26
# spent 26µs making 1 call to XML::Simple::import |
| 27 | |||||
| 28 | =head1 NAME | ||||
| 29 | |||||
| - - | |||||
| 39 | =head1 DESCRIPTION | ||||
| 40 | |||||
| - - | |||||
| 43 | sub new { | ||||
| 44 | my $class = shift; | ||||
| 45 | my $endpoint = shift; | ||||
| 46 | |||||
| 47 | my $self = {}; | ||||
| 48 | $self->{'endpoint'} = $endpoint; | ||||
| 49 | $self->{'session'} = ''; | ||||
| 50 | $self->{'ua'} = LWP::UserAgent->new; | ||||
| 51 | bless $self, $class; | ||||
| 52 | |||||
| 53 | return $self; | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | sub init { | ||||
| 57 | my $self = shift; | ||||
| 58 | |||||
| 59 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 60 | $uri->query_param(command => 'init'); | ||||
| 61 | my $response = $self->{'ua'}->get($uri); | ||||
| 62 | if ($response->is_success) { | ||||
| 63 | my $message = XMLin($response->content); | ||||
| 64 | if ($message->{'status'} eq 'OK') { | ||||
| 65 | $self->{'session'} = $message->{'session'}; | ||||
| 66 | } | ||||
| 67 | } else { | ||||
| 68 | warn $response->status_line; | ||||
| 69 | } | ||||
| 70 | } | ||||
| 71 | |||||
| 72 | sub search { | ||||
| 73 | my $self = shift; | ||||
| 74 | my $query = shift; | ||||
| 75 | |||||
| 76 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 77 | $uri->query_param(command => 'search'); | ||||
| 78 | $uri->query_param(session => $self->{'session'}); | ||||
| 79 | $uri->query_param(query => $query); | ||||
| 80 | my $response = $self->{'ua'}->get($uri); | ||||
| 81 | if ($response->is_success) { | ||||
| 82 | #print $response->content, "\n"; | ||||
| 83 | } else { | ||||
| 84 | warn $response->status_line; | ||||
| 85 | } | ||||
| 86 | |||||
| 87 | } | ||||
| 88 | |||||
| 89 | sub stat { | ||||
| 90 | my $self = shift; | ||||
| 91 | |||||
| 92 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 93 | $uri->query_param(command => 'stat'); | ||||
| 94 | $uri->query_param(session => $self->{'session'}); | ||||
| 95 | my $response = $self->{'ua'}->get($uri); | ||||
| 96 | if ($response->is_success) { | ||||
| 97 | return $response->content; | ||||
| 98 | } else { | ||||
| 99 | warn $response->status_line; | ||||
| 100 | return; | ||||
| 101 | } | ||||
| 102 | } | ||||
| 103 | |||||
| 104 | sub show { | ||||
| 105 | my $self = shift; | ||||
| 106 | my $start = shift; | ||||
| 107 | my $count = shift; | ||||
| 108 | my $sort = shift; | ||||
| 109 | |||||
| 110 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 111 | $uri->query_param(command => 'show'); | ||||
| 112 | $uri->query_param(start => $start); | ||||
| 113 | $uri->query_param(num => $count); | ||||
| 114 | $uri->query_param(block => 1); | ||||
| 115 | $uri->query_param(session => $self->{'session'}); | ||||
| 116 | $uri->query_param(sort => $sort); | ||||
| 117 | my $response = $self->{'ua'}->get($uri); | ||||
| 118 | if ($response->is_success) { | ||||
| 119 | return $response->content; | ||||
| 120 | } else { | ||||
| 121 | warn $response->status_line; | ||||
| 122 | return; | ||||
| 123 | } | ||||
| 124 | |||||
| 125 | } | ||||
| 126 | |||||
| 127 | sub record { | ||||
| 128 | my $self = shift; | ||||
| 129 | my $id = shift; | ||||
| 130 | my $offset = shift; | ||||
| 131 | |||||
| 132 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 133 | $uri->query_param(command => 'record'); | ||||
| 134 | $uri->query_param(id => $id); | ||||
| 135 | $uri->query_param(offset => $offset); | ||||
| 136 | $uri->query_param(binary => 1); | ||||
| 137 | $uri->query_param(session => $self->{'session'}); | ||||
| 138 | my $response = $self->{'ua'}->get($uri); | ||||
| 139 | if ($response->is_success) { | ||||
| 140 | return $response->content; | ||||
| 141 | } else { | ||||
| 142 | warn $response->status_line; | ||||
| 143 | return; | ||||
| 144 | } | ||||
| 145 | } | ||||
| 146 | |||||
| 147 | sub termlist { | ||||
| 148 | my $self = shift; | ||||
| 149 | my $name = shift; | ||||
| 150 | |||||
| 151 | my $uri = URI->new($self->{'endpoint'}); | ||||
| 152 | $uri->query_param(command => 'termlist'); | ||||
| 153 | $uri->query_param(name => $name); | ||||
| 154 | $uri->query_param(session => $self->{'session'}); | ||||
| 155 | my $response = $self->{'ua'}->get($uri); | ||||
| 156 | if ($response->is_success) { | ||||
| 157 | return $response->content; | ||||
| 158 | } else { | ||||
| 159 | warn $response->status_line; | ||||
| 160 | return; | ||||
| 161 | } | ||||
| 162 | |||||
| 163 | } | ||||
| 164 | |||||
| 165 | 1 | 6µs | 1; | ||
| 166 | |||||
| 167 | =head1 AUTHOR | ||||
| 168 | |||||
| - - |