Changeset 9518 for branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
- Timestamp:
- 05/07/08 11:10:41 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
r9397 r9518 16 16 use OpenILS::Application::AppUtils; 17 17 use OpenSRF::Utils::Logger qw/$logger/; 18 use OpenILS::Utils:: Editor q/:funcs/;18 use OpenILS::Utils::CStoreEditor q/:funcs/; 19 19 20 20 my $output = "USMARC"; 21 my $U = 'OpenILS::Application::AppUtils'; 21 22 22 23 my $sclient; … … 85 86 return $e->event unless $e->checkauth; 86 87 return $e->event unless $e->allowed('REMOTE_Z3950_QUERY'); 87 return $sclient->config_value('z3950', 'services'); 88 89 my $sources = $e->search_config_z3950_source( 90 [ { name => { '!=' => undef } }, 91 { flesh => 1, flesh_fields => { czs => ['attrs'] } }] 92 ); 93 94 my %hash = (); 95 for my $s ( @$sources ) { 96 $hash{ $s->name } = { 97 name => $s->name, 98 label => $s->label, 99 host => $s->host, 100 port => $s->port, 101 db => $s->db, 102 auth => $s->auth, 103 }; 104 105 for my $a ( @{ $s->attrs } ) { 106 $hash{ $a->source }{attrs}{ $a->name } = { 107 name => $a->name, 108 label => $a->label, 109 code => $a->code, 110 format => $a->format, 111 source => $a->source, 112 }; 113 } 114 } 115 116 return \%hash; 88 117 } 89 118 … … 121 150 my @connections; 122 151 my @results; 152 my @services; 123 153 for (my $i = 0; $i < @{$$args{service}}; $i++) { 124 154 my %tmp_args = %$args; … … 129 159 $logger->debug("z3950: service: $tmp_args{service}, async: $tmp_args{async}"); 130 160 131 $tmp_args{query} = compile_query('and', $tmp_args{service}, $tmp_args{search}); 132 133 my $res = do_service_search( $self, $conn, $auth, \%tmp_args ); 134 135 push @results, $res->{result}; 136 push @connections, $res->{connection}; 161 if ($tmp_args{service} eq 'native-evergreen-catalog') { 162 my $method = $self->method_lookup('open-ils.search.biblio.zstyle'); 163 $conn->respond( 164 $self->method_lookup('open-ils.search.biblio.zstyle')->run($auth, \%tmp_args) 165 ); 166 167 } else { 168 169 $tmp_args{query} = compile_query('and', $tmp_args{service}, $tmp_args{search}); 170 171 my $res = do_service_search( $self, $conn, $auth, \%tmp_args ); 172 173 if ($U->event_code($res)) { 174 $conn->respond($res) if $U->event_code($res); 175 176 } else { 177 push @services, $tmp_args{service}; 178 push @results, $res->{result}; 179 push @connections, $res->{connection}; 180 } 181 } 137 182 138 183 $logger->debug("z3950: Result object: $results[$i], Connection object: $connections[$i]"); … … 141 186 $logger->debug("z3950: Connections created"); 142 187 188 return undef unless (@connections); 143 189 my @records; 190 144 191 while ((my $index = OpenILS::Utils::ZClient::event( \@connections )) != 0) { 145 192 my $ev = $connections[$index - 1]->last_event(); … … 171 218 $$args{port} = $$info{port}; 172 219 $$args{db} = $$info{db}; 220 $logger->debug("z3950: do_search..."); 173 221 174 222 return do_search( $self, $conn, $auth, $args ); … … 203 251 return $editor->event unless $editor->checkauth; 204 252 return $editor->event unless $editor->allowed('REMOTE_Z3950_QUERY'); 253 254 $logger->info("z3950: connecting to server $host:$port:$db as $username"); 205 255 206 256 my $connection = OpenILS::Utils::ZClient->new(
