2 package OpenILS::Application::Search::Z3950;
3 use strict; use warnings;
4 use base qw/OpenSRF::Application/;
11 use OpenILS::Utils::ModsParser;
13 my $output = "USMARC"; # only support output for now
17 __PACKAGE__->register_method(
18 method => "z39_search_by_string",
19 api_name => "open-ils.search.z3950.raw_string",
21 note => "z3950 search by raw query string",
25 sub z39_search_by_string {
27 my( $self, $client, $server,
28 $port, $db, $search, $user, $pw ) = @_;
30 throw OpenSRF::EX::InvalidArg unless(
31 $server and $port and $db and $search);
36 my $conn = new Net::Z3950::Connection(
41 preferredRecordSyntax => $output,
45 my $rs = $conn->search( $search );
50 $hash->{count} = $rs->size();
51 warn "Z3950 Search recovered " . $hash->{count} . " records\n";
53 for( my $x = 0; $x != $hash->{count}; $x++ ) {
54 my $rec = $rs->record($x+1);
55 my $marc = MARC::Record->new_from_usmarc($rec->rawdata());
57 my $u = OpenILS::Utils::ModsParser->new();
58 $u->start_mods_batch($marc->as_xml());
59 my $mods = $u->finish_mods_batch();
61 push @$records, $mods;
64 $hash->{records} = $records;