[open-ils-commits] r18542 - trunk/Open-ILS/src/perlmods/OpenILS/Application (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Nov 1 10:50:56 EDT 2010


Author: miker
Date: 2010-11-01 10:50:53 -0400 (Mon, 01 Nov 2010)
New Revision: 18542

Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Log:
add copy counts to the holdings xml format -- one more step toward freeing ourselves from MVRs

Modified: trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2010-10-29 01:25:41 UTC (rev 18541)
+++ trunk/Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm	2010-11-01 14:50:53 UTC (rev 18542)
@@ -1709,6 +1709,7 @@
     my $offset = $$paging[1] || 0;
 
 	my $_storage = OpenSRF::AppSession->create( 'open-ils.cstore' );
+	my $_search = OpenSRF::AppSession->create( 'open-ils.search' );
 
 	my $o_search = { shortname => uc($ou) };
 	if (!$ou || $ou eq '-') {
@@ -1720,6 +1721,16 @@
         $o_search
     )->gather(1);
 
+    my $top_org = defined($depth) ? 
+        $_storage->request(
+            'open-ils.cstore.json_query',
+            { from => [ 'actor.org_unit_ancestor_at_depth', $one_org->id, $depth ] }
+        )->gather(1)->{id} :
+        $one_org->id;
+
+    my $count_req = $_search->request('open-ils.search.biblio.record.copy_count.atomic' => $top_org => $bib);
+    my $staff_count_req = $_search->request('open-ils.search.biblio.record.copy_count.staff.atomic' => $top_org => $bib);
+
     my $orgs = $_storage->request(
         'open-ils.cstore.json_query.atomic',
         { from => [ 'actor.org_unit_descendants', defined($depth) ? ( $one_org->id, $depth ) :  ( $one_org->id ) ] }
@@ -1780,7 +1791,26 @@
 	$year += 1900;
 	$month += 1;
 
-	$client->respond("<holdings xmlns='http://open-ils.org/spec/holdings/v1'><volumes>\n");
+	$client->respond("<holdings xmlns='http://open-ils.org/spec/holdings/v1'><counts>\n")
+
+	my $copy_counts = $count_req->gather(1);
+	my $staff_copy_counts = $staff_count_req->gather(1);
+
+	for my $c (@$copy_counts) {
+		$$c{transcendant} ||= 0;
+		my $out = "<count type='public'";
+		$out .= " $_='$$c{$_}'" for (qw/count available unshadow transcendant org_unit depth/);
+		$client->respond("$out/>\n")
+	}
+
+	for my $c (@$staff_copy_counts) {
+		$$c{transcendant} ||= 0;
+		my $out = "<count type='staff'";
+		$out .= " $_='$$c{$_}'" for (qw/count available unshadow transcendant org_unit depth/);
+		$client->respond("$out/>\n")
+	}
+
+    $client->respond("</counts><volumes>\n");
     
 	for my $cn (@$cns) {
 		next unless (@{$cn->copies} > 0 or (ref($cn->uri_maps) and @{$cn->uri_maps}));



More information about the open-ils-commits mailing list