[open-ils-commits] r9518 -
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search
svn at svn.open-ils.org
svn at svn.open-ils.org
Wed May 7 11:10:43 EDT 2008
Author: erickson
Date: 2008-05-07 11:10:41 -0400 (Wed, 07 May 2008)
New Revision: 9518
Modified:
branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
Log:
repairing the evergree-native-catalog z source and from-db-config-reading that was lost during handpatching in the trunk merge
Modified: branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm
===================================================================
--- branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm 2008-05-07 02:55:00 UTC (rev 9517)
+++ branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm 2008-05-07 15:10:41 UTC (rev 9518)
@@ -15,9 +15,10 @@
use OpenSRF::Utils::SettingsClient;
use OpenILS::Application::AppUtils;
use OpenSRF::Utils::Logger qw/$logger/;
-use OpenILS::Utils::Editor q/:funcs/;
+use OpenILS::Utils::CStoreEditor q/:funcs/;
my $output = "USMARC";
+my $U = 'OpenILS::Application::AppUtils';
my $sclient;
my %services;
@@ -84,7 +85,35 @@
my $e = new_editor(authtoken=>$auth);
return $e->event unless $e->checkauth;
return $e->event unless $e->allowed('REMOTE_Z3950_QUERY');
- return $sclient->config_value('z3950', 'services');
+
+ my $sources = $e->search_config_z3950_source(
+ [ { name => { '!=' => undef } },
+ { flesh => 1, flesh_fields => { czs => ['attrs'] } }]
+ );
+
+ my %hash = ();
+ for my $s ( @$sources ) {
+ $hash{ $s->name } = {
+ name => $s->name,
+ label => $s->label,
+ host => $s->host,
+ port => $s->port,
+ db => $s->db,
+ auth => $s->auth,
+ };
+
+ for my $a ( @{ $s->attrs } ) {
+ $hash{ $a->source }{attrs}{ $a->name } = {
+ name => $a->name,
+ label => $a->label,
+ code => $a->code,
+ format => $a->format,
+ source => $a->source,
+ };
+ }
+ }
+
+ return \%hash;
}
@@ -120,6 +149,7 @@
my @connections;
my @results;
+ my @services;
for (my $i = 0; $i < @{$$args{service}}; $i++) {
my %tmp_args = %$args;
$tmp_args{service} = $$args{service}[$i];
@@ -128,19 +158,36 @@
$logger->debug("z3950: service: $tmp_args{service}, async: $tmp_args{async}");
- $tmp_args{query} = compile_query('and', $tmp_args{service}, $tmp_args{search});
+ if ($tmp_args{service} eq 'native-evergreen-catalog') {
+ my $method = $self->method_lookup('open-ils.search.biblio.zstyle');
+ $conn->respond(
+ $self->method_lookup('open-ils.search.biblio.zstyle')->run($auth, \%tmp_args)
+ );
- my $res = do_service_search( $self, $conn, $auth, \%tmp_args );
+ } else {
- push @results, $res->{result};
- push @connections, $res->{connection};
+ $tmp_args{query} = compile_query('and', $tmp_args{service}, $tmp_args{search});
+
+ my $res = do_service_search( $self, $conn, $auth, \%tmp_args );
+
+ if ($U->event_code($res)) {
+ $conn->respond($res) if $U->event_code($res);
+ } else {
+ push @services, $tmp_args{service};
+ push @results, $res->{result};
+ push @connections, $res->{connection};
+ }
+ }
+
$logger->debug("z3950: Result object: $results[$i], Connection object: $connections[$i]");
}
$logger->debug("z3950: Connections created");
+ return undef unless (@connections);
my @records;
+
while ((my $index = OpenILS::Utils::ZClient::event( \@connections )) != 0) {
my $ev = $connections[$index - 1]->last_event();
$logger->debug("z3950: Received event $ev");
@@ -170,6 +217,7 @@
$$args{host} = $$info{host};
$$args{port} = $$info{port};
$$args{db} = $$info{db};
+ $logger->debug("z3950: do_search...");
return do_search( $self, $conn, $auth, $args );
}
@@ -203,6 +251,8 @@
return $editor->event unless $editor->checkauth;
return $editor->event unless $editor->allowed('REMOTE_Z3950_QUERY');
+ $logger->info("z3950: connecting to server $host:$port:$db as $username");
+
my $connection = OpenILS::Utils::ZClient->new(
$host, $port,
databaseName => $db,
More information about the open-ils-commits
mailing list