1 package OpenILS::Application::Search::Authority;
2 use base qw/OpenSRF::Application/;
3 use strict; use warnings;
7 use OpenILS::Utils::Fieldmapper;
8 use OpenILS::Application::AppUtils;
12 use Time::HiRes qw(time);
13 use OpenSRF::EX qw(:try);
14 use Digest::MD5 qw(md5_hex);
16 sub crossref_authority {
22 my $session = OpenSRF::AppSession->create("open-ils.storage");
25 my $freq = $session->request("open-ils.storage.authority.$class.see_from.controlled.atomic",$term);
26 my $areq = $session->request("open-ils.storage.authority.$class.see_also_from.controlled.atomic",$term);
28 my $fr = $freq->gather(1);
29 my $al = $areq->gather(1);
35 last unless ($$x[$i]);
36 if ($string =~ /\W$/o) {
37 $string .= ' '.$$x[$i];
39 $string .= ' -- '.$$x[$i];
42 next if (lc($string) eq lc($term));
45 my $from = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ];
51 last unless ($$x[$i]);
52 if ($string =~ /\W$/o) {
53 $string .= ' '.$$x[$i];
55 $string .= ' -- '.$$x[$i];
58 next if (lc($string) eq lc($term));
61 my $also = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ];
67 return { from => $from, also => $also };
69 __PACKAGE__->register_method(
70 method => "crossref_authority",
71 api_name => "open-ils.search.authority.crossref",
73 note => "Searches authority data for existing controlled terms and crossrefs",