From 979a6d7fe9abc82bea57669ae6d2d6a44826f4e9 Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 24 Jul 2006 14:22:17 +0000 Subject: [PATCH] improving ISBN based unapi stuff git-svn-id: svn://svn.open-ils.org/ILS/trunk@5098 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/SuperCat.pm | 42 ++++++++++++++++++++++ Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 39 ++++++++++++++++++-- 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm index 9b0cfba4a2..51085055cf 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm @@ -686,6 +686,48 @@ Returns the Fieldmapper object representation of the requested bibliographic rec ); +sub retrieve_isbn_object { + my $self = shift; + my $client = shift; + my $isbn = shift; + + return undef unless ($isbn); + + my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' ); + my $recs = $_storage->request( + 'open-ils.cstore.direct.metabib.full_rec.search.atomic', + { tag => { like => '02%'}, value => {like => "$isbn\%"}} + )->gather(1); + + return undef unless (@$recs); + + return $_storage->request( + 'open-ils.cstore.direct.biblio.record_entry.search.atomic', + { id => $recs->[0]->record } + )->gather(1); +} +__PACKAGE__->register_method( + method => 'retrieve_isbn_object', + api_name => 'open-ils.supercat.isbn.object.retrieve', + api_level => 1, + argc => 1, + signature => + { desc => <<" DESC", +Returns the Fieldmapper object representation of the requested bibliographic record + DESC + params => + [ + { name => 'isbn', + desc => 'an ISBN', + type => 'string' }, + ], + 'return' => + { desc => 'The bib record', + type => 'object' } + } +); + + sub retrieve_metarecord_mods { my $self = shift; diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index fe9ec79f87..86bb93e644 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -312,12 +312,47 @@ sub unapi { $command = 'browse' if ($type eq 'call_number'); } + if (!$lib) { + $lib = $actor->request( + 'open-ils.actor.org_unit_list.search' => parent_ou => undef + )->gather(1)->[0]->shortname; + } + + my $lib_object = $actor->request( + 'open-ils.actor.org_unit_list.search' => shortname => $lib + )->gather(1)->[0]; + my $lib_id = $lib_object->id; + + my $ou_types = $actor->request( 'open-ils.actor.org_types.retrieve' )->gather(1); + my $lib_depth = (grep { $_->id == $lib_object->ou_type } @$ou_types)[0]->depth; + if ($type eq 'call_number' and $command eq 'browse') { $lib = uc($lib); print "Location: $root/browse/$base_format/call_number/$lib/$id\n\n"; return 302; } + if ($type eq 'isbn') { + my $rec = $supercat->request('open-ils.supercat.isbn.object.retrieve',$id)->gather(1); + if (!@$rec) { + print "Content-type: text/html; charset=utf-8\n\n"; + $apache->custom_response( 404, <<" HTML"); + + + Type [$type] with id [$id] not found! + + +
+
Sorry, we couldn't $command a $type with the id of $id in format $format.
+ + + HTML + return 404; + } + $id = $rec->[0]->id; + $type = 'record'; + } + if ( !grep { (keys(%$_))[0] eq $base_format } @{ $supercat->request("open-ils.supercat.$type.formats")->gather(1) } @@ -341,9 +376,9 @@ sub unapi { } if ($format eq 'opac') { - print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n" + print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id&l=$lib_id&d=$lib_depth\n\n" if ($type eq 'metarecord'); - print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n" + print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id&l=$lib_id&d=$lib_depth\n\n" if ($type eq 'record'); return 302; } elsif (OpenILS::WWW::SuperCat::Feed->exists($base_format)) { -- 2.11.0