Changeset 9518

Show
Ignore:
Timestamp:
05/07/08 11:10:41 (1 week ago)
Author:
erickson
Message:

repairing the evergree-native-catalog z source and from-db-config-reading that was lost during handpatching in the trunk merge

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/acq-experiment/Open-ILS/src/perlmods/OpenILS/Application/Search/Z3950.pm

    r9397 r9518  
    1616use OpenILS::Application::AppUtils; 
    1717use OpenSRF::Utils::Logger qw/$logger/; 
    18 use OpenILS::Utils::Editor q/:funcs/; 
     18use OpenILS::Utils::CStoreEditor q/:funcs/; 
    1919 
    2020my $output      = "USMARC";  
     21my $U = 'OpenILS::Application::AppUtils';  
    2122 
    2223my $sclient; 
     
    8586        return $e->event unless $e->checkauth; 
    8687        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;  
    88117} 
    89118 
     
    121150        my @connections; 
    122151        my @results; 
     152    my @services;  
    123153        for (my $i = 0; $i < @{$$args{service}}; $i++) { 
    124154                my %tmp_args = %$args; 
     
    129159                $logger->debug("z3950: service: $tmp_args{service}, async: $tmp_args{async}"); 
    130160 
    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        } 
    137182 
    138183                $logger->debug("z3950: Result object: $results[$i], Connection object: $connections[$i]"); 
     
    141186        $logger->debug("z3950: Connections created"); 
    142187 
     188    return undef unless (@connections); 
    143189        my @records; 
     190 
    144191        while ((my $index = OpenILS::Utils::ZClient::event( \@connections )) != 0) { 
    145192                my $ev = $connections[$index - 1]->last_event(); 
     
    171218        $$args{port}    = $$info{port}; 
    172219        $$args{db}              = $$info{db}; 
     220    $logger->debug("z3950: do_search..."); 
    173221 
    174222        return do_search( $self, $conn, $auth, $args ); 
     
    203251        return $editor->event unless $editor->checkauth; 
    204252        return $editor->event unless $editor->allowed('REMOTE_Z3950_QUERY'); 
     253 
     254    $logger->info("z3950: connecting to server $host:$port:$db as $username"); 
    205255 
    206256        my $connection = OpenILS::Utils::ZClient->new(