P898427 Get holdings_xml.retrieve to flesh URIs properly
authorJames Fournie <jfournie@sitka.bclibraries.ca>
Fri, 9 Dec 2011 01:00:14 +0000 (17:00 -0800)
committerDan Scott <dscott@laurentian.ca>
Thu, 12 Jan 2012 03:54:02 +0000 (22:54 -0500)
Flesh URIs when requested with the -uris or -full feed type.
This was broken when commit f2b822f8 fixed authority browsing.

holdings_xml-full never appeared to retrieve URIs properly, so that has
been added.

This also makes holdings_xml-uris behave in the new manner of URIs as per
git commit ba47ecc61, retrieving URIs for ancestors rather than descendants.

Signed-off-by: James Fournie <jfournie@sitka.bclibraries.ca>
Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/src/perlmods/lib/OpenILS/Application/SuperCat.pm

index 879ba77..d98bb3d 100644 (file)
@@ -2146,20 +2146,58 @@ sub new_record_holdings {
         }
     ]);
 
-    if ($flesh and $flesh eq 'uris') {
-        %subselect = (
-            owning_lib => \@ou_ids,
-            '-exists'  => {
-                from  => { auricnm => 'auri' },
-                where => {
-                    call_number => { '=' => {'+acn'=>'id'} },
-                    '+auri' => { active => 't' }
+    # we are dealing with -full or -uris, so we need to flesh things out
+    if ($flesh) {
+
+        # either way we're going to need uris
+        # get all the uris up the tree (see also ba47ecc6196)
+
+        my $uri_orgs = $_storage->request(
+            'open-ils.cstore.json_query.atomic',
+            { from => [ 'actor.org_unit_ancestors', $one_org->id ] }
+        )->gather(1);
+
+        my @uri_ou_ids = map { $_->{id} } @$uri_orgs;
+
+        # we have a -uris, just get the uris
+        if ($flesh == 2) {
+            %subselect = (
+                owning_lib => \@uri_ou_ids,
+                '-exists'  => {
+                    from  => { auricnm => 'auri' },
+                    where => {
+                        call_number => { '=' => {'+acn'=>'id'} },
+                        '+auri' => { active => 't' }
+                    }
                 }
-            }
-        );
+            );
+        # we have a -full, get all the things
+        } elsif ($flesh == 1) {
+            %subselect = ( '-or' => [
+                { owning_lib => \@ou_ids },
+                { '-exists'  =>
+                    { from  => 'acp',
+                      where => {
+                        call_number => { '=' => {'+acn'=>'id'} },
+                        deleted => 'f',
+                        circ_lib => \@ou_ids
+                      }
+                    }
+                },
+                { '-and' => [
+                    { owning_lib => \@uri_ou_ids },
+                    { '-exists'  => {
+                        from  => { auricnm => 'auri' },
+                        where => {
+                            call_number => { '=' => {'+acn'=>'id'} },
+                            '+auri' => { active => 't' }
+                        }
+                    }}
+                ]}
+            ]);
+        }
     }
 
-
        my $cns = $_storage->request(
                "open-ils.cstore.direct.asset.call_number.search.atomic",
                { record  => $bib,