[open-ils-commits] r16122 - in trunk/Open-ILS: src/perlmods/OpenILS/Application src/perlmods/OpenILS/WWW web/opac/skin/default/js (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun Apr 4 01:19:07 EDT 2010


Author: miker
Date: 2010-04-04 01:19:03 -0400 (Sun, 04 Apr 2010)
New Revision: 16122

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
   trunk/Open-ILS/web/opac/skin/default/js/result_common.js
Log:
add embedded holdings paging support to biblio-record_entry type unAPI tag URIs -- also works for holdings_xml format directly -- and teach the local call number BibTemplate opac slot how to use this (show first 10 local call numbers, instead of all of them)

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2010-04-04 04:05:16 UTC (rev 16121)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2010-04-04 05:19:03 UTC (rev 16122)
@@ -904,52 +904,43 @@
 	return \%holdings;
 }
 
-__PACKAGE__->register_method(
-	method    => 'new_record_holdings',
-	api_name  => 'open-ils.supercat.record.holdings_xml.retrieve',
-	api_level => 1,
-	argc      => 1,
-	stream    => 1,
-	signature =>
-		{ desc     => <<"		  DESC",
-Returns the XML representation of the requested bibliographic record's holdings
-		  DESC
-		  params   =>
-		  	[
-				{ name => 'bibId',
-				  desc => 'An OpenILS biblio::record_entry id',
-				  type => 'number' },
-			],
-		  'return' =>
-		  	{ desc => 'Stream of bib record holdings hierarchy in XML',
-			  type => 'string' }
-		}
-);
+#__PACKAGE__->register_method(
+#	method    => 'new_record_holdings',
+#	api_name  => 'open-ils.supercat.record.holdings_xml.retrieve',
+#	api_level => 1,
+#	argc      => 1,
+#	stream    => 1,
+#	signature =>
+#		{ desc     => <<"		  DESC",
+#Returns the XML representation of the requested bibliographic record's holdings
+#		  DESC
+#		  params   =>
+#		  	[
+#				{ name => 'bibId',
+#				  desc => 'An OpenILS biblio::record_entry id',
+#				  type => 'number' },
+#			],
+#		  'return' =>
+#		  	{ desc => 'Stream of bib record holdings hierarchy in XML',
+#			  type => 'string' }
+#		}
+#);
+#
 
-
 sub new_record_holdings {
 	my $self = shift;
 	my $client = shift;
 	my $bib = shift;
 	my $ou = shift;
 	my $hide_copies = shift;
+	my $paging = shift;
 
+    $paging = [-1,0] if (!$paging or !ref($paging) or @$paging == 0);
+    my $limit = $$paging[0];
+    my $offset = $$paging[1] || 0;
+
 	my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
 
-	my $tree = $_storage->request(
-		"open-ils.cstore.direct.biblio.record_entry.retrieve",
-		$bib,
-		{ flesh		=> 5,
-		  flesh_fields	=> {
-					bre	=> [qw/call_numbers/],
-		  			acn	=> [qw/copies owning_lib uri_maps/],
-		  			auricnm	=> [qw/uri/],
-					acp	=> [qw/location status circ_lib stat_cat_entries notes/],
-					asce	=> [qw/stat_cat/],
-				}
-		}
-	)->gather(1);
-
 	my $o_search = { shortname => uc($ou) };
 	if (!$ou || $ou eq '-') {
 		$o_search = { parent_ou => undef };
@@ -965,42 +956,54 @@
 
 	my @ou_ids = tree_walker($orgs, 'children', sub {shift->id}) if $orgs;
 
-	$logger->debug("Searching for holdings at orgs [".join(',', at ou_ids)."], based on $ou");
+	$logger->info("Searching for holdings at orgs [".join(',', at ou_ids)."], based on $ou");
 
+	my $cns = $_storage->request(
+		"open-ils.cstore.direct.asset.call_number.search.atomic",
+		{ record  => $bib,
+          deleted => 'f',
+          '-or'   => [
+            { owning_lib => \@ou_ids },
+            { '-exists'  =>
+                { from  => 'acp',
+                  where =>
+                    { call_number => { '=' => {'+acn'=>'id'} },
+                      deleted => 'f',
+                      circ_lib => \@ou_ids
+                  }
+                }
+            }
+          ]
+        },
+		{ flesh		=> 5,
+		  flesh_fields	=> {
+		  			acn	=> [qw/copies owning_lib uri_maps/],
+		  			auricnm	=> [qw/uri/],
+					acp	=> [qw/circ_lib location status stat_cat_entries notes/],
+					asce	=> [qw/stat_cat/],
+				},
+          ( $limit > -1 ? ( limit  => $limit  ) : () ),
+          ( $offset     ? ( offset => $offset ) : () ),
+          order_by  => { acn => { label => {} } }
+		}
+	)->gather(1);
+
 	my ($year,$month,$day) = reverse( (localtime)[3,4,5] );
 	$year += 1900;
 	$month += 1;
 
 	$client->respond("<volumes xmlns='http://open-ils.org/spec/holdings/v1'>\n");
+    
+	for my $cn (@$cns) {
+		next unless (@{$cn->copies} > 0 or (ref($cn->uri_maps) and @{$cn->uri_maps}));
 
-	for my $cn (@{$tree->call_numbers}) {
-		next unless ( $cn->deleted eq 'f' || $cn->deleted == 0 );
-
-		my $found = 0;
-		for my $c (@{$cn->copies}) {
-			next unless grep {$c->circ_lib->id == $_} @ou_ids;
-			next unless ( $c->deleted eq 'f' || $c->deleted == 0 );
-			$found = 1;
-			last;
-		}
-
-		if (!$found && ref($cn->uri_maps) && @{$cn->uri_maps}) {
-			$found = 1 if (grep {$cn->owning_lib->id == $_} @ou_ids);
-		}
-		next unless $found;
-
 		# We don't want O:A:S:unAPI::acn to return the record, we've got that already
-		my $holdings_args = { no_record => 1 };
 		# In the context of BibTemplate, copies aren't necessary because we pull those
 		# in a separate call
-		if ($hide_copies) {
-			$holdings_args->{no_copies} = 1;
-		}
-
         $client->respond(
             OpenILS::Application::SuperCat::unAPI::acn
                 ->new( $cn )
-                ->as_xml( $holdings_args )
+                ->as_xml( {no_record => 1, no_copies => $hide_copies} )
         );
 	}
 
@@ -1027,6 +1030,9 @@
 				{ name => 'hideCopies',
 				  desc => 'Flag that prevents the inclusion of copies in the returned holdings',
 				  type => 'boolean' },
+				{ name => 'paging',
+				  desc => 'Arry of limit and offset for holdings paging',
+				  type => 'array' },
 			],
 		  'return' =>
 		  	{ desc => 'Stream of bib record holdings hierarchy in XML',

Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-04-04 04:05:16 UTC (rev 16121)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-04-04 05:19:03 UTC (rev 16122)
@@ -326,14 +326,15 @@
 	my $format = $cgi->param('format');
 	my $flesh_feed = parse_feed_type($format);
 	(my $base_format = $format) =~ s/(-full|-uris)$//o;
-	my ($id,$type,$command,$lib) = ('','','');
+	my ($id,$type,$command,$lib,$paging) = ('','','');
 
 	if (!$format) {
 		my $body = "Content-type: application/xml; charset=utf-8\n\n";
 	
-		if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+)(?:/(.+))$}o) {
+		if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+?)(?:\[([^\]]+)\])?(?:/(.+))?}o) {
 			$id = $2;
-			$lib = uc($3);
+			$paging = $3;
+			$lib = uc($4);
 			$type = 'record';
 			$type = 'metarecord' if ($1 =~ /^m/o);
 
@@ -418,9 +419,10 @@
 		return Apache2::Const::OK;
 	}
 
-	if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+)(?:/(.+))?}o) {
+	if ($uri =~ m{^tag:[^:]+:([^\/]+)/([^/]+?)(?:\[([^\]]+)\])?(?:/(.+))?}o) {
 		$id = $2;
-		$lib = uc($3);
+		$paging = $3;
+		$lib = uc($4);
 		$type = 'record';
 		$type = 'metarecord' if ($1 =~ /^metabib/o);
 		$type = 'isbn' if ($1 =~ /^isbn/o);
@@ -432,6 +434,12 @@
 		$command = 'browse' if ($type eq 'call_number');
 	}
 
+    if ($paging) {
+        $paging = [split ',', $paging];
+    } else {
+        $paging = [];
+    }
+
 	if (!$lib || $lib eq '-') {
 	 	$lib = $actor->request(
 			'open-ils.actor.org_unit_list.search' => parent_ou => undef
@@ -506,7 +514,8 @@
 			$format => [ $id ],
 			$base,
 			$lib,
-			$flesh_feed
+			$flesh_feed,
+            $paging
 		);
 
 		if (!$feed->count) {
@@ -543,10 +552,12 @@
 		push @params, $lib;
 		if ($format !~ /-full$/o) {
 			push @params, 1;
-		}
+		} else {
+			push @params, 0;
+        }
 	}
 
-	my $req = $supercat->request($method, at params);
+	my $req = $supercat->request($method, at params,$paging);
 	my $data = $req->gather();
 
 	if ($req->failed || !$data) {
@@ -1283,6 +1294,8 @@
 	my $flesh = shift;
 	$flesh = 1 if (!defined($flesh));
 
+	my $paging = shift;
+
 	my $cgi = new CGI;
 	my $base = $cgi->url;
 	my $host = $cgi->virtual_host || $cgi->server_name;
@@ -1323,7 +1336,7 @@
 
 		$xml = '';
 		if ($lib && ($type eq 'marcxml' || $type eq 'atom') &&  $flesh) {
-			my $r = $supercat->request( "open-ils.supercat.$search.holdings_xml.retrieve", $rec, $lib, ($flesh_feed eq "uris") ? 1 : 0 );
+			my $r = $supercat->request( "open-ils.supercat.$search.holdings_xml.retrieve", $rec, $lib, ($flesh_feed eq "uris") ? 1 : 0, $paging );
 			while ( !$r->complete ) {
 				$xml .= join('', map {$_->content} $r->recv);
 			}

Modified: trunk/Open-ILS/web/opac/skin/default/js/result_common.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/result_common.js	2010-04-04 04:05:16 UTC (rev 16121)
+++ trunk/Open-ILS/web/opac/skin/default/js/result_common.js	2010-04-04 05:19:03 UTC (rev 16122)
@@ -493,7 +493,7 @@
 						unHideMe(l_cn_list);
 						new openils.BibTemplate({
 							root : l_cn_list,
-							record : onlyrec,
+							record : '' + onlyrec + '[10]',
 							org_unit : here.shortname()
 						}).render();
 					}, 0
@@ -536,7 +536,7 @@
 					unHideMe(l_cn_list);
 					new openils.BibTemplate({
 						root : l_cn_list,
-						record : onlyrec,
+						record : '' + onlyrec + '[10]',
 						org_unit : here.shortname()
 					}).render();
 				}, 0



More information about the open-ils-commits mailing list