From 3ee14f0056c771833d5a2b9805d2f9e228b82670 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 10 Nov 2005 17:55:47 +0000 Subject: [PATCH] adding open-ils.search support from subject crossreferencing git-svn-id: svn://svn.open-ils.org/ILS/trunk@1996 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Search.pm | 1 + .../OpenILS/Application/Search/Authority.pm | 42 +++++++++++++++++++ .../Storage/Publisher/authority.pm | 40 +++++++++++------- 3 files changed, 67 insertions(+), 16 deletions(-) create mode 100644 Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm index 7d187f514b..6284c2eb49 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm @@ -11,6 +11,7 @@ use OpenSRF::Utils::Cache; #use OpenILS::Application::Search::StaffClient; use OpenILS::Application::Search::Biblio; +use OpenILS::Application::Search::Authority; use OpenILS::Application::Search::Actor; use OpenILS::Application::Search::Z3950; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm new file mode 100644 index 0000000000..94a6899c8c --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm @@ -0,0 +1,42 @@ +package OpenILS::Application::Search::Authority; +use base qw/OpenSRF::Application/; +use strict; use warnings; + +use OpenILS::EX; + +use OpenILS::Utils::Fieldmapper; +use OpenILS::Application::AppUtils; + +use JSON; + +use Time::HiRes qw(time); +use OpenSRF::EX qw(:try); +use Digest::MD5 qw(md5_hex); + +sub crossref_subject { + my $self = shift; + my $client = shift; + my $subject = shift; + + my $session = OpenSRF::AppSession->create("open-ils.storage"); + $session->connect; + + my $freq = $session->request('open-ils.storage.authority.subject.see_from.controlled.atomic',$subject); + my $areq = $session->request('open-ils.storage.authority.subject.see_also_from.controlled.atomic',$subject); + + my $from = $freq->gather(1); + my $also = $areq->gather(1); + + $session->disconnect; + + return { from => $from, also => $also }; +} +__PACKAGE__->register_method( + method => "crossref_subject", + api_name => "open-ils.search.authority.subject.crossref", + argc => 1, + note => "Searches authority data for existing subject controlled terms and crossrefs", +); + + +1; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/authority.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/authority.pm index 08351c61fb..863805470c 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/authority.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/authority.pm @@ -96,46 +96,54 @@ sub find_see_from_controlled { my $client = shift; my $term = shift; + (my $class = $self->api_name) =~ s/^.+authority.([^\.]+)\.see.+$/$1/o; + my @marc = $self->method_lookup('open-ils.storage.authority.search.marc') ->run( term => $term, tag => '4%', subfield => 'a' ); for my $m ( @marc ) { my $doc = $parser->parse_string($m); my @nodes = $doc->documentElement->findnodes('//*[substring(@tag,1,1)="1"]/*'); my $list = [ map { $_->textContent } @nodes ]; - $client->respond( $list ) if (_empty_check($$list[0], 'metabib::subject_field_entry')); + $client->respond( $list ) if (_empty_check($$list[0], "metabib::${class}_field_entry")); } return undef; } -__PACKAGE__->register_method( - api_name => "open-ils.storage.authority.see_from.controlled", - method => 'find_see_from_controlled', - api_level => 1, - stream => 1, - cachable => 1, -); +for my $class ( qw/title author subject keyword series/ ) { + __PACKAGE__->register_method( + api_name => "open-ils.storage.authority.$class.see_from.controlled", + method => 'find_see_from_controlled', + api_level => 1, + stream => 1, + cachable => 1, + ); +} sub find_see_also_from_controlled { my $self = shift; my $client = shift; my $term = shift; + (my $class = $self->api_name) =~ s/^.+authority.([^\.]+)\.see.+$/$1/o; + my @marc = $self->method_lookup('open-ils.storage.authority.search.marc') ->run( term => $term, tag => '5%', subfield => 'a' ); for my $m ( @marc ) { my $doc = $parser->parse_string($m); my @nodes = $doc->documentElement->findnodes('//*[substring(@tag,1,1)="1"]/*'); my $list = [ map { $_->textContent } @nodes ]; - $client->respond( $list ) if (_empty_check($$list[0], 'metabib::subject_field_entry')); + $client->respond( $list ) if (_empty_check($$list[0], "metabib::${class}_field_entry")); } return undef; } -__PACKAGE__->register_method( - api_name => "open-ils.storage.authority.see_also_from.controlled", - method => 'find_see_also_from_controlled', - api_level => 1, - stream => 1, - cachable => 1, -); +for my $class ( qw/title author subject keyword series/ ) { + __PACKAGE__->register_method( + api_name => "open-ils.storage.authority.$class.see_also_from.controlled", + method => 'find_see_also_from_controlled', + api_level => 1, + stream => 1, + cachable => 1, + ); +} 1; -- 2.43.2