From fcb8ca730037dea2ccb1387a0b015474814ba24a Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 23 Feb 2006 04:56:54 +0000 Subject: [PATCH] adding MARC cn extraction git-svn-id: svn://svn.open-ils.org/ILS/trunk@3180 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Cat.pm | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm index 98d0f88119..7e110f5f4f 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Cat.pm @@ -417,6 +417,36 @@ sub biblio_record_record_metadata { } +__PACKAGE__->register_method( + method => "biblio_record_marc_cn", + api_name => "open-ils.cat.biblio.record.marc_cn.retrieve", + argc => 1, #(bib id ) +); + +sub biblio_record_marc_cn { + my( $self, $client, $id ) = @_; + + my $session = OpenSRF::AppSession->create("open-ils.storage"); + my $marc = $session + ->request("open-ils.storage.direct.biblio.record_entry.retrieve", $id ) + ->gather(1) + ->marc; + + my $doc = XML::LibXML->new->parse_string($marc); + $doc->documentElement->setNamespace( "http://www.loc.gov/MARC21/slim", "marc", 1 ); + + my @res; + for my $tag ( qw/050 055 060 070 080 082 086 088 090 092 096 098 099/ ) { + my @node = $doc->findnodes("//marc:datafield[\@tag='$tag']"); + for my $x (@node) { + my $cn = $x->findvalue("marc:subfield[\@code='a' or \@code='b']"); + push @res, {$tag => $cn} if ($cn); + } + } + + return \@res +} + # gets the username sub _get_userid_by_id { -- 2.43.2