1 package OpenILS::Application::Search::Serial;
2 use base qw/OpenILS::Application/;
3 use strict; use warnings;
6 use OpenSRF::Utils::JSON;
7 use OpenILS::Utils::Fieldmapper;
8 use OpenILS::Utils::MFHDParser;
9 use OpenSRF::Utils::SettingsClient;
10 use OpenILS::Utils::CStoreEditor q/:funcs/;
11 use OpenSRF::Utils::Cache;
14 use OpenSRF::Utils::Logger qw/:logger/;
18 use OpenSRF::Utils::JSON;
20 use Time::HiRes qw(time);
21 use OpenSRF::EX qw(:try);
22 use Digest::MD5 qw(md5_hex);
27 use OpenILS::Const qw/:const/;
29 use OpenILS::Application::AppUtils;
30 my $apputils = "OpenILS::Application::AppUtils";
33 my $pfx = "open-ils.search_";
41 Takes an MFHD record ID and returns a hash of holdings statements
46 my ($self, $client, $id) = @_;
48 my $session = OpenSRF::AppSession->create("open-ils.cstore");
49 my $request = $session->request(
50 "open-ils.cstore.direct.serial.record_entry.retrieve", $id )->gather(1);
52 my $u = OpenILS::Utils::MFHDParser->new();
53 my $mfhd_hash = $u->generate_svr( $request->marc );
55 $session->disconnect();
59 __PACKAGE__->register_method(
60 method => "mfhd_to_hash",
61 api_name => "open-ils.search.serial.record.mfhd.retrieve",
63 note => "Given a serial record ID, return MFHD holdings"
68 =item * bib_to_mfhd_hash
72 Given a bib record ID, returns a hash of holdings statements
76 sub bib_to_mfhd_hash {
77 my ($self, $client, $bib) = @_;
81 # XXX perhaps this? --miker
82 # my $e = OpenILS::Utils::CStoreEditor->new();
83 # my $mfhd = $e->search_serial_record_entry({ record => $bib });
84 # return $u->generate_svr( $mfhd->[0]->marc ) if (ref $mfhd);
87 my @mfhd = $U->cstorereq( "open-ils.cstore.json_query.atomic", {
88 select => { sre => 'marc' },
90 where => { record => $bib },
94 if (!@mfhd or scalar(@mfhd) == 0) {
98 my $u = OpenILS::Utils::MFHDParser->new();
99 $mfhd_hash = $u->generate_svr( $mfhd[0][0]->{marc} );
104 __PACKAGE__->register_method(
105 method => "bib_to_mfhd_hash",
106 api_name => "open-ils.search.serial.record.bib_to_mfhd.retrieve",
108 note => "Given a bibliographic record ID, return MFHD holdings"
112 my ($self, $client, $bib) = @_;
116 my $e = OpenILS::Utils::CStoreEditor->new();
117 my $serials = $e->search_serial_record_entry({ record => $bib });
122 my $u = OpenILS::Utils::MFHDParser->new();
123 foreach (@$serials) {
124 push(@$mfhd, $u->generate_svr($_->marc));
130 __PACKAGE__->register_method(
131 method => "bib_to_mfhd",
132 api_name => "open-ils.search.serial.record.bib.retrieve",
134 note => "Given a bibliographic record ID, return MFHD holdings"