use XML::LibXML;
use XML::LibXSLT;
+use Data::Dumper;
+$Data::Dumper::Indent = 0;
+use OpenSRF::Utils::Logger qw/:logger/;
my $apputils = "OpenILS::Application::AppUtils";
+=head comment
__PACKAGE__->register_method(
method => "biblio_search_marc",
api_name => "open-ils.search.biblio.marc",
return $data;
}
+=cut
# --------------------------------------------------------------------------------
# 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 };
-}
+=head comment
__PACKAGE__->register_method(
method => "cat_biblio_search_class",
api_name => "open-ils.search.cat.biblio.class",
return undef;
}
+=cut
+
#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;
}
+__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 };
+}
+
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;
var ORIGLOC;
var TOPRANK;
var AUTHTIME;
+var ADVTERM;
/* cookie values */
var SBEXTRAS;
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";
/* ---------------------------------------------------------------------------- */
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;
if(isNaN(ORIGLOC)) ORIGLOC = 0;
if(isNaN(TOPRANK)) TOPRANK = 1;
if(isNaN(AUTHTIME)) AUTHTIME = 1;
+ if(ADVTERM==null) ADVTERM = "";
}
function initCookies() {
function getSearchBarExtras(){return SBEXTRAS;}
function getFontSize(){return FONTSIZE;};
function getSkin(){return SKIN;};
+function getAdvTerm(){return ADVTERM;}
function findBasePath() {
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(/\?\&/,"?");
}
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;
}
+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) {
function mresultUnload() { removeChildren(table); table = null;}
function mresultDoSearch() {
- //idsCookie = new HTTP.Cookies();
if(getOffset() == 0) {
swapCanvas($('loading_alt'));
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,
function mresultHandleCount(r) {
HITCOUNT = parseInt(r.getResultObject());
+ alert('mresultHandleCount()');
runEvt('result', 'hitCountReceived');
}
+*/
/* performs the actual search */
}
}
+
+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();
<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>
<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>
</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>
-<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>
</span>
<span style='padding-right:9px;'>
- <!--
- <span>&common.format;: </span>
- -->
+ <!--#set var='FORM_SEL_ID' value='form_selector'-->
<!--#include virtual="format_selector.xml"-->
</span>
<!-- 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-->
<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; }