From e575f34d68d14fda64cf46c9d349f770769115da Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 29 Jun 2010 18:10:55 +0000 Subject: [PATCH] improve browse support; correct thinkos in new holdings fleshing code; improve generated MODS XML (remove some namespace prefixes) git-svn-id: svn://svn.open-ils.org/ILS/trunk@16829 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/SuperCat.pm | 13 +++---- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 40 +++++++++++++--------- 2 files changed, 30 insertions(+), 23 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm index 7aec0ad679..0e82150f3b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm @@ -1672,6 +1672,7 @@ sub retrieve_metarecord_mods { # ... and a MODS clone to populate, with guts removed. my $mods = $_parser->parse_string($master)->documentElement; + $mods->setNamespace('http://www.loc.gov/mods/', undef); $mods->setNamespace( "http://www.loc.gov/mods/", "mods", 1 ); ($mods) = $mods->findnodes('//mods:mods'); $mods->removeChildNodes; @@ -1679,11 +1680,11 @@ sub retrieve_metarecord_mods { # Add the metarecord ID as a (locally defined) info URI my $recordInfo = $mods ->ownerDocument - ->createElement("mods:recordInfo"); + ->createElement("recordInfo"); my $recordIdentifier = $mods ->ownerDocument - ->createElement("mods:recordIdentifier"); + ->createElement("recordIdentifier"); my ($year,$month,$day) = reverse( (localtime)[3,4,5] ); $year += 1900; @@ -1740,23 +1741,23 @@ sub retrieve_metarecord_mods { my $relatedItem = $mods ->ownerDocument - ->createElement("mods:relatedItem"); + ->createElement("relatedItem"); $relatedItem->setAttribute( type => 'constituent' ); my $identifier = $mods ->ownerDocument - ->createElement("mods:identifier"); + ->createElement("identifier"); $identifier->setAttribute( type => 'uri' ); my $subRecordInfo = $mods ->ownerDocument - ->createElement("mods:recordInfo"); + ->createElement("recordInfo"); my $subRecordIdentifier = $mods ->ownerDocument - ->createElement("mods:recordIdentifier"); + ->createElement("recordIdentifier"); my $subid = $map->source; $subRecordIdentifier->appendTextNode( diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 4df2b68bc2..8d0c174304 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -364,7 +364,7 @@ sub unapi { if (!$format) { my $body = "Content-type: application/xml; charset=utf-8\n\n"; - if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { + if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { $id = $2; $paging = $3; $lib = uc($4); @@ -453,20 +453,21 @@ sub unapi { return Apache2::Const::OK; } - if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { + my $scheme; + if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^\/[]+)(?:\[([0-9,]+)\])?(?:/(.+))?}o) { + $scheme = $1; $id = $2; $paging = $3; ($lib,$depth) = split('/', $4); $type = 'record'; - $type = 'metarecord' if ($1 =~ /^metabib/o); - $type = 'isbn' if ($1 =~ /^isbn/o); - $type = 'call_number' if ($1 =~ /^call_number/o); - $type = 'acp' if ($1 =~ /^asset-copy/o); - $type = 'acn' if ($1 =~ /^asset-call_number/o); - $type = 'auri' if ($1 =~ /^asset-uri/o); - $type = 'authority' if ($1 =~ /^authority/o); + $type = 'metarecord' if ($scheme =~ /^metabib/o); + $type = 'isbn' if ($scheme =~ /^isbn/o); + $type = 'acp' if ($scheme =~ /^asset-copy/o); + $type = 'acn' if ($scheme =~ /^asset-call_number/o); + $type = 'auri' if ($scheme =~ /^asset-uri/o); + $type = 'authority' if ($scheme =~ /^authority/o); $command = 'retrieve'; - $command = 'browse' if ($type eq 'call_number'); + $command = 'browse' if (grep { $scheme eq $_ } qw/call_number title author subjet topic authority.title authority.author authority.subject authority.topic series item-age/); } if ($paging) { @@ -489,8 +490,8 @@ sub unapi { my $ou_types = $actor->request( 'open-ils.actor.org_types.retrieve' )->gather(1); my $lib_depth = $depth || (grep { $_->id == $lib_object->ou_type } @$ou_types)[0]->depth; - if ($type eq 'call_number' and $command eq 'browse') { - print "Location: $root/browse/$base_format/call_number/$lib/$id\n\n"; + if ($command eq 'browse') { + print "Location: $root/browse/$base_format/$scheme/$lib/$id\n\n"; return 302; } @@ -583,7 +584,7 @@ sub unapi { my $method = "open-ils.supercat.$type.$base_format.$command"; my @params = ($id); - push @params, $lib, $flesh_feed, $paging if ($base_format eq 'holdings_xml'); + push @params, $lib, $lib_depth, $flesh_feed, $paging if ($base_format eq 'holdings_xml'); my $req = $supercat->request($method,@params); my $data = $req->gather(); @@ -1340,7 +1341,11 @@ sub create_record_feed { my $base = $cgi->url; my $host = $cgi->virtual_host || $cgi->server_name; - my $year = (gmtime())[5] + 1900; + my ($year,$month,$day) = reverse( (localtime)[3,4,5] ); + $year += 1900; + $month += 1; + + my $tag_prefix = sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d", $month, $day); my $flesh_feed = parse_feed_type($type); @@ -1362,11 +1367,12 @@ sub create_record_feed { #my $rec = $record->id; my $rec = $record; - my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib"; - $item_tag = "tag:$host,$year:isbn/$rec/$lib" if ($search eq 'isbn'); + my $item_tag = "$tag_prefix:biblio-record_entry/$rec/$lib"; + $item_tag = "$tag_prefix:metabib-metarecord/$rec/$lib" if ($search eq 'metarecord'); + $item_tag = "$tag_prefix:isbn/$rec/$lib" if ($search eq 'isbn'); $item_tag .= "/$depth" if (defined($depth)); - $item_tag = "tag:$host,$year:authority-record_entry/$rec" if ($search eq 'authority'); + $item_tag = "$tag_prefix:authority-record_entry/$rec" if ($search eq 'authority'); my $xml = $supercat->request( "open-ils.supercat.$search.$type.retrieve", -- 2.11.0