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));
44 $hash{$string}++ if (lc($$x[0]) eq lc($term));
46 my $from = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ];
52 last unless ($$x[$i]);
53 if ($string =~ /\W$/o) {
54 $string .= ' '.$$x[$i];
56 $string .= ' -- '.$$x[$i];
59 next if (lc($string) eq lc($term));
61 $hash{$string}++ if (lc($$x[0]) eq lc($term));
63 my $also = [ sort { $hash{$b} <=> $hash{$a} || $a cmp $b } keys %hash ];
69 return { from => $from, also => $also };
71 __PACKAGE__->register_method(
72 method => "crossref_authority",
73 api_name => "open-ils.search.authority.crossref",
75 note => "Searches authority data for existing controlled terms and crossrefs",