1 package OpenILS::Application::Search;
2 use base qw/OpenSRF::Application/;
3 use OpenSRF::EX qw(:try);
4 use strict; use warnings;
5 use OpenILS::Utils::Fieldmapper;
6 use Time::HiRes qw(time);
7 use OpenILS::Application::Cat::Utils;
12 OpenSRF::Application->method_lookup( "blah" );
15 warn "Child Init Failed: " . shift() . "\n";
22 __PACKAGE__->register_method(
23 method => "cat_biblio_search_class",
24 api_name => "open-ils.search.cat.biblio.class",
26 note => "Searches biblio information by search class",
29 sub cat_biblio_search_class {
30 my( $self, $client, $class, $sort, $string ) = @_;
32 # sort = title, author, pubdate
34 warn "Starting search " . time() . "\n";
38 warn "Searching $class, $sort, $string\n";
40 if( $class eq "author" ) {
43 { tag => "100", subfield => "a"} ,
44 { tag => "700", subfield => "a"} ];
46 } elsif( $class eq "title" ) {
49 { tag => "245", subfield => "a"},
50 { tag => "242", subfield => "a"},
51 { tag => "240", subfield => "a"},
52 { tag => "210", subfield => "a"},
55 } elsif( $class eq "subject" ) {
57 $search_hash = [ { tag => "650", subfield => "_" } ];
59 } elsif( $class eq "tcn" ) {
61 $search_hash = [ { tag => "035", subfield => "_" } ];
65 warn "Looking up method: " . time() . "\n";
67 my $method = $self->method_lookup("open-ils.search.biblio.marc");
69 throw OpenSRF::EX::PANIC
70 ("Can't lookup method 'open-ils.search.biblio.marc'");
73 warn "Running: " . time() . "\n";
75 my ($records) = $method->run( $search_hash, $string );
77 warn "Search For Id's complete, fixing: " . time() . "\n";
83 $method = $self->method_lookup("open-ils.storage.biblio.record_marc.batch.retrieve");
84 warn "Found method batch " . time() . "\n";
87 throw OpenSRF::EX::PANIC ("Can't lookup method 'open-ils.storage.biblio.record_marc.batch.retrieve");
90 warn "running batch " . time() . "\n";
91 my @marxml_objs = $method->run( @$records );
92 warn "done running batch " . time() . "\n";
95 for my $marcxml (@marxml_objs) {
96 warn "Starting batch " . time() . "\n";
97 my $u = OpenILS::Application::Cat::Utils->new();
98 $u->start_mods_batch( $marcxml->marc );
99 my $mods = $u->finish_mods_batch();
100 push @results, $mods;
105 warn Dumper \@results;
108 #@records = sort { $a->{$sort} <=> $b->{$sort} } @records;
116 __PACKAGE__->register_method(
117 method => "biblio_search_marc",
118 api_name => "open-ils.search.biblio.marc",
120 note => "Searches biblio information by marc tag",
123 sub biblio_search_marc {
124 my( $self, $client, $search_hash, $string ) = @_;
127 warn "Looking up search method: " . time() . "\n";
128 my $method = $self->method_lookup( "open-ils.storage.metabib.full_rec.search.fts" );
130 throw OpenSRF::EX::PANIC
131 ("Can't lookup method 'open-ils.storage open-ils.storage.metabib.full_rec.search.fts'");
134 warn "Running search method: " . time() . "\n";
135 my ($data) = $method->run( $search_hash, $string );
142 warn "returning id's @ids\n";