added search interface for the advanced search, marc search, and isbn search
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 20:19:41 +0000 (20:19 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 15 Dec 2005 20:19:41 +0000 (20:19 +0000)
more work on opac advanced search interface

git-svn-id: svn://svn.open-ils.org/ILS/trunk@2410 dcc99617-32d9-48b4-a31d-7c20da2025e4

12 files changed:
Open-ILS/src/perlmods/OpenILS/Application/Search/Biblio.pm
Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/common/js/utils.js
Open-ILS/web/opac/skin/default/js/mresult.js
Open-ILS/web/opac/skin/default/xml/advanced/advanced_quick.xml
Open-ILS/web/opac/skin/default/xml/advanced/advanced_refined.xml
Open-ILS/web/opac/skin/default/xml/advanced/advanced_wizard.xml
Open-ILS/web/opac/skin/default/xml/common/format_selector.xml
Open-ILS/web/opac/skin/default/xml/common/searchbar.xml
Open-ILS/web/opac/skin/default/xml/index.xml
Open-ILS/web/opac/skin/default/xml/page_advanced.xml

index 57090d3..539930a 100644 (file)
@@ -19,6 +19,9 @@ use Digest::MD5 qw(md5_hex);
 
 use XML::LibXML;
 use XML::LibXSLT;
+use Data::Dumper;
+$Data::Dumper::Indent = 0;
+use OpenSRF::Utils::Logger qw/:logger/;
 
 my $apputils = "OpenILS::Application::AppUtils";
 
@@ -33,6 +36,7 @@ sub test { return "test"; }
 
 
 
+=head comment
 __PACKAGE__->register_method(
        method  => "biblio_search_marc",
        api_name        => "open-ils.search.biblio.marc",
@@ -63,6 +67,7 @@ sub biblio_search_marc {
        return $data;
 
 }
+=cut
 
 
 
@@ -280,26 +285,7 @@ sub biblio_search_tcn {
 # --------------------------------------------------------------------------------
 # ISBN
 
-__PACKAGE__->register_method(
-       method  => "biblio_search_isbn",
-       api_name        => "open-ils.search.biblio.isbn",
-);
 
-sub biblio_search_isbn { 
-       my( $self, $client, $isbn ) = @_;
-       throw OpenSRF::EX::InvalidArg 
-
-               ("biblio_search_isbn needs an ISBN to search")
-                       unless defined $isbn;
-
-       warn "biblio search for ISBN $isbn\n";
-       my $method = $self->method_lookup("open-ils.search.biblio.marc");
-       my ($records) = $method->run( $cat_search_hash->{isbn}, $isbn );
-
-       return { count => 0 } unless($records and @$records);
-       my $size = @$records;
-       return { count => $size, ids => $records };
-}
 
 
 
@@ -456,6 +442,7 @@ sub barcode_to_mods {
 
 
 
+=head comment
 __PACKAGE__->register_method(
        method  => "cat_biblio_search_class",
        api_name        => "open-ils.search.cat.biblio.class",
@@ -527,6 +514,8 @@ sub cat_biblio_search_class {
        return undef;
 }
 
+=cut
+
 
 
 
@@ -691,8 +680,6 @@ sub biblio_search_class {
        #my @all_ids;
 
        warn "Received " . scalar(@$records) . " id's from class search\n";
-       use Data::Dumper;
-       warn Dumper $records;
 
 #      for my $i (@$records) { if(defined($i)) { push @all_ids, $i; } }
 #      my @ids = @all_ids;
@@ -1058,6 +1045,121 @@ sub copy_count_summary {
 }
 
 
+__PACKAGE__->register_method(
+       method          => "multiclass_search",
+       api_name        => "open-ils.search.biblio.multiclass",
+       notes           => <<"  NOTES");
+               Performs a multiclass search
+               PARAMS( searchBlob, org_unit, format, limit ) 
+               where searchBlob is defined like this:
+                       { 
+                               "title" : { "term" : "water" }, 
+                               "author" : { "term" : "smith" }, 
+                               ... 
+                       }
+       NOTES
+
+__PACKAGE__->register_method(
+       method          => "multiclass_search",
+       api_name        => "open-ils.search.biblio.multiclass.staff",
+       notes           => "see open-ils.search.biblio.multiclass" );
+
+sub multiclass_search {
+       my( $self, $client, $searchBlob, $orgid, $format, $limit ) = @_;
+
+       $logger->debug("Performing multiclass search with org => $orgid, " .
+               "format => $format, limit => $limit, and search blob " . Dumper($searchBlob));
+
+       my $meth = 'open-ils.storage.metabib.post_filter.multiclass.search_fts.metarecord.atomic';
+       if($self->api_name =~ /staff/) { $meth =~ s/metarecord\.atomic/metarecord.staff.atomic/; }
+
+
+       my $records = $apputils->simplereq(
+               'open-ils.storage', $meth, 
+                org_unit => $orgid, searches => $searchBlob, format => $format, limit => $limit );
+
+       my $count = 0;
+       my $recs = [];
+
+       if( ref($records) and $records->[0] and 
+               defined($records->[0]->[3])) { $count = $records->[0]->[3];}
+
+       for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
+
+       # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
+       return { ids => $recs, count => $count };
+
+
+}
+
+__PACKAGE__->register_method(
+       method          => "marc_search",
+       api_name        => "open-ils.search.biblio.marc",
+       notes           => <<"  NOTES");
+               Performs a multiclass search
+               PARAMS( searchBlob, org_unit, format ) 
+               where searchBlob is defined like this:
+               [ 
+                       {
+                               "term":"shakespeare",
+                               "restrict":[{"tag":"245","subfield":"a"}] 
+                       }, 
+                       {
+                               "term":"bloom",
+                               "restrict":[{"tag":"100","subfield":"a"}] 
+                       } 
+
+               ]
+       NOTES
+
+
+sub marc_search {
+       my( $self, $client, $searchBlob, $orgid, $format ) = @_;
+
+       $logger->debug("Performing MARC search with org => $orgid, " .
+               "format => $format and search blob " . Dumper($searchBlob) );
+               
+       my $records =  $apputils->simplereq(
+               'open-ils.storage',
+               'open-ils.storage.metabib.full_rec.multi_search.atomic',
+               searches => $searchBlob, org_unit => $orgid, format => $format );
+
+       my $count = 0;
+       my $recs = [];
+
+       if( ref($records) and $records->[0] and 
+               defined($records->[0]->[3])) { $count = $records->[0]->[3];}
+
+       for my $r (@$records) { push( @$recs, $r ) if ($r and $r->[0]); }
+
+       # records has the form: [ mrid, rank, singleRecord / 0, hitCount ];
+       return { ids => $recs, count => $count };
+
+}
+
+
+
+__PACKAGE__->register_method(
+       method  => "biblio_search_isbn",
+       api_name        => "open-ils.search.biblio.isbn",
+);
+
+sub biblio_search_isbn { 
+       my( $self, $client, $isbn ) = @_;
+
+       $logger->debug("Searching ISBN $isbn");
+
+       my $method = $self->method_lookup("open-ils.search.biblio.marc");
+
+       my ($records) = $method->run(  
+               [ {     term => $isbn,
+                               restrict => $cat_search_hash->{isbn} } ], 1);
+
+       return { count => 0 } unless($records and @$records);
+       my $size = @$records;
+       return { count => $size, ids => $records };
+}
+
 
 
 
index d17fd89..60b6496 100644 (file)
@@ -11,9 +11,10 @@ var PARAM_COUNT              = "c";                  /* hits per page */
 var PARAM_HITCOUNT     = "hc";                 /* hits per page */
 var PARAM_MRID                 = "m";                  /* metarecord id */
 var PARAM_RID                  = "r";                  /* record id */
-var PARAM_ORIGLOC              = "ol"                  /* the original location */
-var PARAM_TOPRANK              = "tr"                  /* this highest ranking rank */
-var PARAM_AUTHTIME     = "at"                  /* inactivity timeout in seconds */
+var PARAM_ORIGLOC              = "ol";                 /* the original location */
+var PARAM_TOPRANK              = "tr";                 /* this highest ranking rank */
+var PARAM_AUTHTIME     = "at";                 /* inactivity timeout in seconds */
+var PARAM_ADVTERM              = "adv";                        /* advanced search term */
 
 /* URL param values (see comments above) */
 var TERM;  
@@ -29,6 +30,7 @@ var FONTSIZE;
 var ORIGLOC;
 var TOPRANK;
 var AUTHTIME;
+var ADVTERM;
 
 /* cookie values */
 var SBEXTRAS; 
@@ -210,6 +212,7 @@ var FETCH_REVIEWS                                   = "open-ils.search:open-ils.search.added_content.review.re
 var FETCH_TOC                                          = "open-ils.search:open-ils.search.added_content.toc.retrieve";
 var FETCH_ACONT_SUMMARY                        = "open-ils.search:open-ils.search.added_content.summary.retrieve";
 var FETCH_USER_BYBARCODE               = "open-ils.actor:open-ils.actor.user.fleshed.retrieve_by_barcode";
+var FETCH_ADV_MRIDS                            = "open-ils.search:open-ils.search.biblio.multiclass:1";
 /* ---------------------------------------------------------------------------- */
 
 
index 99f6693..030fe00 100644 (file)
@@ -80,6 +80,7 @@ function initParams() {
        RID             = parseInt(cgi.param(PARAM_RID));
        TOPRANK  = parseFloat(cgi.param(PARAM_TOPRANK));
        AUTHTIME        = parseInt(cgi.param(PARAM_AUTHTIME));
+       ADVTERM = cgi.param(PARAM_ADVTERM);
 
        /* set up some sane defaults */
        if(isNaN(LOCATION))     LOCATION        = 1;
@@ -92,6 +93,7 @@ function initParams() {
        if(isNaN(ORIGLOC))      ORIGLOC = 0;
        if(isNaN(TOPRANK))      TOPRANK = 1;
        if(isNaN(AUTHTIME))     AUTHTIME        = 1;
+       if(ADVTERM==null)               ADVTERM = "";
 }
 
 function initCookies() {
@@ -119,6 +121,7 @@ function getAuthtime() { return AUTHTIME; }
 function getSearchBarExtras(){return SBEXTRAS;}
 function getFontSize(){return FONTSIZE;};
 function getSkin(){return SKIN;};
+function getAdvTerm(){return ADVTERM;}
 
 
 function findBasePath() {
@@ -176,6 +179,7 @@ function  buildOPACLink(args, slim, ssl) {
        string += _appendParam(RID,             PARAM_RID, args, getRid, string);
        string += _appendParam(TOPRANK, PARAM_TOPRANK, args, getTopRank, string);
        string += _appendParam(AUTHTIME,        PARAM_AUTHTIME, args, getAuthtime, string);
+       string += _appendParam(ADVTERM, PARAM_ADVTERM, args, getAdvTerm, string);
 
        return string.replace(/\&$/,'').replace(/\?\&/,"?");    
 }
@@ -604,6 +608,7 @@ function _timerRun(tname) {
        var _t;
        eval('_t='+tname);
        if(_t.done) return;
+       if(_t.count > 100) return;
        var str = ' . ';
        if( (_t.count % 5) == 0 ) 
                str = _t.count / 5;
index c6d8e2d..79e82a3 100644 (file)
@@ -175,6 +175,12 @@ function setSelector( sel, value ) {
 }
 
 
+function getSelectorVal( sel ) {
+       if(!sel) return undef;
+       return sel.options[sel.selectedIndex].value;
+}
+
+
 /* split on spaces.  capitalize the first /\w/ character in
    each substring */
 function normalize(val) {
index b2acb64..29a4629 100644 (file)
@@ -18,7 +18,6 @@ attachEvt("result", "idsReceived", mresultCollectRecords);
 function mresultUnload() { removeChildren(table); table = null;}
 
 function mresultDoSearch() {
-       //idsCookie = new HTTP.Cookies();
 
        if(getOffset() == 0) {
                swapCanvas($('loading_alt'));
@@ -31,12 +30,17 @@ function mresultDoSearch() {
        while( table.parentNode.rows.length <= (getDisplayCount() + 1) )  /* add an extra row so IE and safari won't complain */
                table.appendChild(G.ui.result.row_template.cloneNode(true));
 
-       if(getOffset() == 0 || getHitCount() == null ) 
-               mresultCollectIds(FETCH_MRIDS_FULL); 
-       else  
-               mresultCollectIds(FETCH_MRIDS);
+       if(getOffset() == 0 || getHitCount() == null ) {
+               if( getAdvTerm() && !getTerm() ) mresultCollectAdvIds(1);
+               else mresultCollectIds(FETCH_MRIDS_FULL); 
+
+       } else  {
+               if( getAdvTerm() && !getTerm()) mresultCollectAdvIds();
+               else mresultCollectIds(FETCH_MRIDS);
+       }
 }
 
+/*
 function mresultGetCount() {
        var form = (getForm() == "all") ? null : getForm();
        var req = new Request(FETCH_MRCOUNT, 
@@ -47,8 +51,10 @@ function mresultGetCount() {
 
 function mresultHandleCount(r) {
        HITCOUNT = parseInt(r.getResultObject());
+       alert('mresultHandleCount()');
        runEvt('result', 'hitCountReceived');
 }
+*/
 
 
 /* performs the actual search */
@@ -77,6 +83,32 @@ function mresultCollectIds(method) {
        }
 }
 
+
+function mresultCollectAdvIds() {
+
+       if( (getOffset() > 0) && (getOffset() < mresultPreCache) ) {
+               var c = JSON2js(idsCookie.read(COOKIE_IDS));
+               if(c) { records = c[0]; ranks = c[1]; }
+       }
+
+       if(     getOffset() != 0 && 
+                       records[getOffset()] != null && 
+                       records[resultFinalPageIndex()] != null) {
+                       runEvt('result', 'hitCountReceived');
+                       mresultCollectRecords(); 
+
+       } else {
+
+               var form = (getForm() == "all") ? null : getForm();
+               var req = new Request(FETCH_ADV_MRIDS, 
+                       JSON2js(getAdvTerm()), getLocation(), form, mresultPreCache );
+               req.callback(mresultHandleMRIds);
+               req.send();
+       }
+}
+
+
+
 function mresultHandleMRIds(r) {
        var res = r.getResultObject();
 
index c4b340a..3ee3471 100644 (file)
@@ -8,11 +8,13 @@
                <tr>
                        <td>
                                <span style='padding-right: 10px;'>&opac.advanced.quick.isbn;:</span>
-                               <input type='text' size='10' maxlength='10'> </input>
+                               <input style='margin: 5px;' type='text' size='10' maxlength='10'> </input>
+                               <input type='submit' id='opac.advanced.quick.isbn.submit' value='&common.submit;'> </input>
                        </td>
                        <td>
                                <span style='padding-right: 10px;'>&opac.advanced.quick.issn;:</span>
-                               <input type='text' size='8' maxlength='8'> </input>
+                               <input style='margin: 5px;' type='text' size='8' maxlength='8'> </input>
+                               <input type='submit' id='opac.advanced.quick.issn.submit' value='&common.submit;'> </input>
                        </td>
                </tr>
        </tbody>
index 486281e..71ddea1 100644 (file)
                <tr>
                        <td><span>&common.format;: </span></td>
                        
-                       <td> <!--#include virtual="../common/format_selector.xml"--> </td>
+                       <td> 
+                               <!--#set var='FORM_SEL_ID' value='advanced.refined.form_selector'-->
+                               <!--#include virtual="../common/format_selector.xml"--> 
+                       </td>
                        <td colspan='1' align='center'>
-                               <input type='submit' 
-                                       id='advanced.refined.submit' value='&common.submit;'> </input>
+                               <input type='submit' onclick='advRefinedRun();' value='&common.submit;'> </input>
                        </td>
                </tr>
        </tbody>
index cf7dac4..bceaf54 100644 (file)
                        </td>
                        <td align='center'>
                                <span>&common.format;: </span>
+                               <!--#set var='FORM_SEL_ID' value='advanced.wizard.form_selector'-->
                                <!--#include virtual="../common/format_selector.xml"-->
                        </td>
                </tr>
                <tr>
                        <td colspan='2' align='center'>
-                               <input type='submit' 
-                                       id='advanced.wizard.submit' value='&common.submit;'> </input>
+                               <input type='submit' onclick='advWizardRun();' value='&common.submit;'> </input>
                        </td>
                </tr>
        </tbody>
index 910fb82..f7f733b 100644 (file)
@@ -1,4 +1,4 @@
-<select id='form_selector' >
+<select id='<!--#echo var="FORM_SEL_ID"-->' >
        <option value='all'>&opac.search.allFormats;</option>
        <option value='at'>&opac.search.books;</option>
        <option value='at-d'>&opac.search.largePrint;</option>
index fffc38c..65f49ef 100644 (file)
@@ -46,9 +46,7 @@
                                        </span>
 
                                        <span style='padding-right:9px;'>
-                                               <!--
-                                               <span>&common.format;: </span>
-                                               -->
+                                               <!--#set var='FORM_SEL_ID' value='form_selector'-->
                                                <!--#include virtual="format_selector.xml"-->
                                        </span>
 
index a2c9a49..373e8ef 100644 (file)
@@ -7,7 +7,7 @@
 <!-- Tells the browser to translate the page as HTML --> 
 <?xml-stylesheet type="text/xsl" href="html_xsl.xml"?> 
 <!--#else-->
-<?xml-stylesheet type="text/xsl" href="html_xsl.xml"?>  <!-- keep this in until we can fix some bugs -->
+<?xml-stylesheet type="text/xsl" href="html_xsl.xml"?> 
 <!--#endif-->
 
 
index d648d8e..f2f4487 100644 (file)
@@ -1,5 +1,7 @@
 <div id='canvas_main' style='margin-top: 20px;'>
 
+       <script language='javascript' src='../js/advanced.js'> </script>
+
        <style type='text/css'>
                .advanced_div { text-align: center; margin: 20px; 
                        margin-top: 30px; margin-bottom: 30px; width: 95%; padding: 5px; }