From 0f69d0e602e0263cb927315a16b0e4d9ccbf2b73 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 10 Nov 2005 20:57:20 +0000 Subject: [PATCH] added support for all authority xrefs -- XXX we need MADS to do facets :( git-svn-id: svn://svn.open-ils.org/ILS/trunk@1999 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Search/Authority.pm | 55 +++++++++++++++---- 1 file changed, 45 insertions(+), 10 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm index 94a6899c8c..d0ef219714 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/Authority.pm @@ -13,29 +13,64 @@ use Time::HiRes qw(time); use OpenSRF::EX qw(:try); use Digest::MD5 qw(md5_hex); -sub crossref_subject { +sub crossref_authority { my $self = shift; my $client = shift; - my $subject = shift; + my $class = shift; + my $term = 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 $freq = $session->request("open-ils.storage.authority.$class.see_from.controlled.atomic",$term); + my $areq = $session->request("open-ils.storage.authority.$class.see_also_from.controlled.atomic",$term); - my $from = $freq->gather(1); - my $also = $areq->gather(1); + my $fr = $freq->gather(1); + my $al = $areq->gather(1); + + my %hash = (); + for my $x (@$fr) { + my $string = $$x[0]; + for my $i (1..10) { + last unless ($$x[$i]); + if ($string =~ /\W$/o) { + $string .= ' '.$$x[$i]; + } else { + $string .= ' -- '.$$x[$i]; + } + } + next if (lc($string) eq lc($term)); + $hash{$string}++; + } + my $from = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ]; + + %hash = (); + for my $x (@$al) { + my $string = $$x[0]; + for my $i (1..10) { + last unless ($$x[$i]); + if ($string =~ /\W$/o) { + $string .= ' '.$$x[$i]; + } else { + $string .= ' -- '.$$x[$i]; + } + } + next if (lc($string) eq lc($term)); + $hash{$string}++; + } + my $also = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ]; $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", + method => "crossref_authority", + api_name => "open-ils.search.authority.crossref", + argc => 2, + note => "Searches authority data for existing controlled terms and crossrefs", ); -- 2.43.2