Display multiple copies and URIs per record in search results
authorDan Scott <dan@coffeecode.net>
Tue, 28 Jun 2011 17:24:37 +0000 (13:24 -0400)
committerDan Scott <dan@coffeecode.net>
Tue, 28 Jun 2011 18:27:09 +0000 (14:27 -0400)
By building up a list of hashes in args.holding instead of a single
result, we can display multiple copies in search results.

Similarly, adding args.uri to misc_util.tt2 gives us the list of located
URIs to display in search results. Note that the XPath for holdings_xml
in in-db unapi will change slightly.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Signed-off-by: Dan Scott <dan@coffeecode.net>

Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Record.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Search.pm
Open-ILS/web/templates/default/opac/parts/misc_util.tt2
Open-ILS/web/templates/default/opac/parts/result/table.tt2

index 02fd651..eba1b74 100644 (file)
@@ -28,7 +28,7 @@ sub load_record {
         'open-ils.cstore.json_query.atomic', 
         $self->mk_copy_query($rec_id, $org, $depth, $copy_limit, $copy_offset));
 
-    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra}'});
+    my (undef, @rec_data) = $self->get_records_and_facets([$rec_id], undef, {flesh => '{holdings_xml,mra,acp}'});
     $ctx->{bre_id} = $rec_data[0]->{id};
     $ctx->{marc_xml} = $rec_data[0]->{marc_xml};
 
index 787228c..82b8865 100644 (file)
@@ -179,7 +179,7 @@ sub load_rresults {
     my ($facets, @data) = $self->get_records_and_facets(
         $rec_ids, $results->{facet_key}, 
         {
-            flesh => '{holdings_xml,mra}',
+            flesh => '{holdings_xml,mra,acp}',
             site => $site,
             depth => $depth
         }
index 0e7cd2c..04add44 100644 (file)
         args.isbn_clean = args.isbn.replace('\ .*', '');
 
         args.holdings = [];
-        FOR holding IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
-            args.holdings.push(
-                holding.getAttribute('label')
-            );
+        args.uris = [];
+
+        # URI info is in volumes/volume/uris/volume, instead of uri element
+        i = 0;
+        FOR volume IN xml.findnodes('//*[local-name()="volumes"]/*[local-name()="volume"]');
+            i = i + 1;
+
+            # Check volume visibility - could push this into XPath
+            vol.label = volume.getAttribute('label');
+            NEXT IF volume.getAttribute('opac_visible') == 'false';
+            NEXT IF volume.getAttribute('deleted') == 'true';
+
+            IF vol.label == '##URI##';
+                FOR uri IN xml.findnodes('//*[local-name()="uris"]/*[local-name()="volume"]', volume);
+                    res.href = uri.getAttribute('href');
+                    res.link = uri.getAttribute('label');
+                    res.note = uri.getAttribute('use_restriction');
+                    args.uris.push(res);
+                END;
+                NEXT;
+            ELSE;
+                copies = xml.findnodes('//*[local-name()="copies"]/*[local-name()="copy"]', volume);
+                FOR copy IN copies;
+                    # Check copy visibility
+                    cp.deleted = copy.getAttribute('deleted');    
+                    cp.visible = copy.getAttribute('opac_visible');
+                    NEXT IF (cp.deleted == 'true' OR cp.visible == 'false');
+
+                    # Iterate through all of the children to determine visibility
+                    FOR node IN cp.childNodes;
+                        NEXT IF cp.visible == 'false';
+                        vis = node.getAttribute('opac_visible');
+                        del = node.getAttribute('deleted');
+                        IF vis == 'false' or del == 'true';
+                            cp.visible = 'false';
+                        END;
+                    END;
+
+                    NEXT IF cp.visible == 'false';
+                    
+                    loc = xml.findnodes('//*[local-name()="location"]', copy);
+                    circlib = xml.findnodes('//*[local-name()="circlib"]', copy);
+                    status = xml.findnodes('//*[local-name()="status"]', copy);
+
+                    holding = {
+                        label => vol.label,
+                        location => loc.0.textContent,
+                        library => circlib.0.textContent,
+                        status => status.0.textContent
+                    };
+                    args.holdings.push(holding);
+                END;
+            END;
         END;
 
         # Extract the copy count summary
index 6fc3b2e..efb50f7 100644 (file)
                                                     </div>
                                                     <table cellpadding="0" cellspacing="0" border="0"
                                                         class="results_info_table">
-                                                        <tr name='bib_cn_list' class='result_table_title_cell'>
-                                                            <td valign='top'>
-                                                                <strong>[% l('Call number:') %]</strong>
-                                                            </td>
-                                                            <td>[% args.holdings.0 %]</td>
-                                                        </tr>
                                                         <tr name="results_pub_tr" class="[% attrs.publisher ? '' : 'hide_me' %]">
                                                             <td valign="top">
                                                                 <strong>[% l('Publisher:') %]</strong>
                                                                 [% args.phys_desc %]
                                                             </td>
                                                         </tr>
+
+                                                        [% FOR copy IN args.holdings %]
+                                                        <tr name='bib_cn_list' class='result_table_title_cell'>
+                                                            <td valign='top'>
+                                                                <strong>[% l('Call number:') %]</strong>
+                                                            </td>
+                                                            <td>[% copy.label _ ' ' _ copy.location _ ' ' _ copy.library _ ' ' _ copy.status %]</td>
+                                                        </tr>
+                                                        [% END %]
+
+                                                        [% FOR uri IN args.uris%]
+                                                        <tr name='bib_uri_list' class='result_table_title_cell'>
+                                                            <td valign='top'>
+                                                                <strong>[% l('Electronic resource') %]</strong>
+                                                            </td>
+                                                            <td><a href="[% uri.href %]">[% uri.link %]</a>[% ' - ' _ uri.note IF uri.note %]</td>
+                                                        </tr>
+                                                        [% END %]
+
+
                                                     </table>
                                                     <div>
                                                         [% l('[_1] of [quant,_2,copy,copies] available',