Commit abdd9aa9 authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

1323: Implement metasearch for SRU endpoints

Task-Url: https://pm.winseda.de/issues/1323
parent 1361870c
......@@ -52,6 +52,10 @@ Search.prototype.initComponents = function() {
customSearch: this.options.customSearch,
responseHandler: this.responseHandler
});
this.metaQueryHandler = new MetaQueryHandler({
queryHandler: this.queryHandler
});
this.sourceSelection = new SourceSelection();
this.sourceSelection.init();
......@@ -76,6 +80,10 @@ Search.prototype.search = function() {
this.queryHandler.doSearch();
};
Search.prototype.metasearch = function(sourceIds, isShowMore) {
this.metaQueryHandler.metasearch(sourceIds, isShowMore);
};
Search.prototype.expandSearch = function(expression) {
this.queryHandler.expandSearch(expression);
};
......
var MetaQueryHandler = function(options) {
this.options = $.extend({
queryHandler : null,
}, options)
};
MetaQueryHandler.prototype.metasearch = function(sourceIds, isShowMore) {
this.doSearch(sourceIds, isShowMore);
};
MetaQueryHandler.prototype.doSearch = function(sourceIds, isShowMore) {
if (isShowMore===null || isShowMore===undefined) {
isShowMore=false;
}
this.query = this.options.queryHandler.buildQuery(isShowMore);
this.imageQueue = [];
var metaQuery = $.extend(
this.query, {
sourceIds: sourceIds
});
var _this = this;
if (metaQuery!==null) {
// TODO Must be special
//$("#search-loading-indicator").removeClass("fade");
$.ajax({
url: __util.getBaseUrl() + "metaquery/",
type: "POST",
dataType: "json",
data: JSON.stringify(metaQuery),
contentType: "application/json",
success: function(data, jqXHR, textStatus) {
/*$("#search-loading-indicator").addClass("fade");
if (data==null) {
__util.processServerError(jqXHR, textStatus);
}
_this.responseHandler.process(data, isShowMore);*/
},
error : function(jqXHR, textStatus, message) {
//$("#search-loading-indicator").addClass("fade");
__util.processServerError(jqXHR, textStatus);
}
});
}
};
\ No newline at end of file
......@@ -55,8 +55,7 @@ var QueryHandler = function(options) {
QueryHandler.prototype.expandSearch = function(expression) {
if (expression==null || expression==="") {
return;
}
var _this = this;
}
if ($("#expression").length>0) {
if ($("#expression").val().length>0) {
$("#expression").val($("#expression").val() + " " + expression);
......@@ -69,11 +68,9 @@ QueryHandler.prototype.expandSearch = function(expression) {
$(facetElement).find(".search-facet-expression").val(expression);
//_this.doSearch();
});
}
};
QueryHandler.prototype.selectFacetingSchema = function() {
this.schemaId = $("#schemaId").val();
var container = $("#facet-schema-info");
......@@ -129,8 +126,6 @@ QueryHandler.prototype.clearSearchFacets = function() {
$("#search-facets-container").text("");
};
QueryHandler.prototype.insertSearchFacet = function() {
var _this = this;
$.ajax({
......@@ -166,24 +161,24 @@ QueryHandler.prototype.removeSearchFacet = function(control) {
this.reorderFacets();
};
QueryHandler.prototype.doSearch = function(isShowMore) {
//if (isShowMore===null || isShowMore===undefined) {
QueryHandler.prototype.doSearch = function(isShowMore) {
if (isShowMore===null || isShowMore===undefined) {
isShowMore=false;
//}
var _this = this;
}
this.query = this.buildQuery(isShowMore);
this.imageQueue = [];
$(".wordcloud").text("");
this.clouds = [];
var _this = this;
if (this.query!==null) {
$("#search-loading-indicator").removeClass("fade");
$.ajax({
url: __util.getBaseUrl() + "query/",
type: "POST",
dataType: "json",
data: JSON.stringify(_this.query),
data: JSON.stringify(this.query),
contentType: "application/json",
success: function(data, jqXHR, textStatus) {
$("#search-loading-indicator").addClass("fade");
......@@ -198,6 +193,7 @@ QueryHandler.prototype.doSearch = function(isShowMore) {
}
});
}
};
QueryHandler.prototype.doSearchDelayed = function() {
......@@ -213,10 +209,6 @@ QueryHandler.prototype.delaySearch = function(timestamp) {
}
};
QueryHandler.prototype.addFilter = function(queryFilter, html) {
var match = false;
......@@ -255,9 +247,6 @@ QueryHandler.prototype.removeAllFilters = function() {
this.doSearchDelayed();
};
QueryHandler.prototype.buildQuery = function(isShowMore) {
var query = {
entities: [],
......
......@@ -34,10 +34,8 @@ var ResponseHandler = function(options) {
"~eu.dariah.de.minfba.search.view.result.no_title",
"~eu.dariah.de.minfba.search.view.result.resources.relevance_score",
"~eu.dariah.de.minfba.search.view.result.resources.hits_in_document",
"~eu.dariah.de.minfba.search.view.result.show_more"
]);
"~eu.dariah.de.minfba.search.view.result.show_more"
]);
this.imageQueue = [];
};
......@@ -58,6 +56,14 @@ ResponseHandler.prototype.process = function(resultArray, isShowMore) {
//_this.processResponseTerms();
//_this.processResponseSubjects();
//
} else if (data.resultType=="META") {
var sourceIds = [];
for (var j=0; j<data.resultDatasources.length; j++) {
sourceIds.push(data.resultDatasources[j].providerId);
}
search.metasearch(sourceIds, false);
}
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment