this.requestBatch = new RequestBatch();
this.finalized = false;
+ this.builtLinks = false;
}
AbstractRecordResultPage.prototype.resetSearch = function() {
this.ranks = new Array();
this.hitCount = 0; /* hits for the current search */
this.searchOffset = 0; /* the offset for the search display */
+ this.page = 0;
}
AbstractRecordResultPage.prototype.gatherIDs = function(result) {
+ if(result == null) return;
this.hitCount = parseInt(result.count);
+
if(this.hitCount < 1 ) {
this.finalizePage();
return false;
AbstractRecordResultPage.prototype.displayRecord =
function( record, search_id, page_id ) {
+ if(record == null) return;
+
if(page_id == 0)
this.buildNextLinks();
AbstractRecordResultPage.prototype.mkAuthorLink = function(auth) {
var href = createAppElement("a");
add_css_class(href,"record_result_sidebar_link");
+
href.setAttribute("href",
"?target=mr_result&mr_search_type=author&page=0&mr_search_query=" +
- encodeURIComponent(auth));
+ encodeURIComponent(auth) +
+ "&mr_search_depth=" + this.searchDepth +
+ "&mr_search_location=" + this.searchLocation);
+
href.appendChild(createAppTextNode(auth));
return href;
}
add_css_class(href,"record_result_sidebar_link");
href.setAttribute("href",
"?target=mr_result&mr_search_type=subject&page=0&mr_search_query=" +
- encodeURIComponent(sub));
+ encodeURIComponent(sub) +
+ "&mr_search_depth=" + this.searchDepth +
+ "&mr_search_location=" + this.searchLocation);
href.appendChild(createAppTextNode(sub));
return href;
}
AbstractRecordResultPage.prototype.buildNextLinks = function() {
+ if(this.builtLinks)
+ return;
+ this.builtLinks = true;
+
+
var obj = this;
var next;
MRResultPage.prototype.addMenuItems = function(menu, record) {
menu.addItem("View Metarecord Details",
function() { alert(record.doc_id()); });
- xulEvtMRResultDisplayed( menu, record );
+ if(isXUL())
+ xulEvtMRResultDisplayed( menu, record );
}
MRResultPage.prototype.doSearch = function() {
+ debug("XUL IS " + isXUL() );
+
var string = paramObj.__mr_search_query;
var stype = paramObj.__mr_search_type;
var location = paramObj.__mr_search_location;
if(depth == null)
depth = globalSearchDepth;
+
+ if(depth == null)
+ depth = findOrgDepth(globalLocation.ou_type());
+
if(location == null)
location = globalLocation.id();
+ " and offset " + this.searchOffset +
" depth: " + depth + " location: " + location);
+ debug("gathering the search count\n");
- var request = new RemoteRequest(
- "open-ils.search", "open-ils.search.biblio.class",
- this.stype, this.string,
- this.searchLocation,
- this.searchDepth, "50", this.searchOffset );
+ if(this.searchOffset > 0) {
+ this.buildNextLinks();
+ this.doMRSearch();
+
+ } else {
+
+ var creq = new RemoteRequest(
+ "open-ils.search", "open-ils.search.biblio.class.count",
+ this.stype, this.string, this.searchLocation, this.searchDepth );
+
+ /* this request grabs the search count. When the counts come back
+ the metarecord ids are collected */
+ var obj = this;
+ creq.setCompleteCallback(
+ function(req) {
+
+ try {
+ obj.hitCount = req.getResultObject();
+
+ } catch(E) {
+ if(instanceOf(E, ex)) {
+ alert(E.err_msg());
+ return;
+ }
+ else throw E;
+ }
+
+ obj.buildNextLinks();
+ obj.doMRSearch();
+ debug("Kicking off the record id's request");
+ }
+ );
+ creq.send();
+ }
+}
+
+
+MRResultPage.prototype.doMRSearch = function() {
var obj = this;
+ var method = "open-ils.search.biblio.class";
+ if( this.hitCount > 1000 )
+ method = method + ".unordered";
+
+ debug("Search method is " + method);
+
+ var request = new RemoteRequest(
+ "open-ils.search", method,
+ obj.stype, obj.string,
+ obj.searchLocation,
+ obj.searchDepth, "100", obj.searchOffset );
+
request.setCompleteCallback(
function(req) {
var result = req.getResultObject();
+ result.count = obj.hitCount;
obj.gatherIDs(result)
obj.collectRecords();
obj.requestBatch.remove(req);
}
);
-
- this.requestBatch.add(request);
+ obj.requestBatch.add(request);
request.send();
-}
+}
MRResultPage.prototype.collectRecords = function() {