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() { ...@@ -52,6 +52,10 @@ Search.prototype.initComponents = function() {
customSearch: this.options.customSearch, customSearch: this.options.customSearch,
responseHandler: this.responseHandler responseHandler: this.responseHandler
}); });
this.metaQueryHandler = new MetaQueryHandler({
queryHandler: this.queryHandler
});
this.sourceSelection = new SourceSelection(); this.sourceSelection = new SourceSelection();
this.sourceSelection.init(); this.sourceSelection.init();
...@@ -76,6 +80,10 @@ Search.prototype.search = function() { ...@@ -76,6 +80,10 @@ Search.prototype.search = function() {
this.queryHandler.doSearch(); this.queryHandler.doSearch();
}; };
Search.prototype.metasearch = function(sourceIds, isShowMore) {
this.metaQueryHandler.metasearch(sourceIds, isShowMore);
};
Search.prototype.expandSearch = function(expression) { Search.prototype.expandSearch = function(expression) {
this.queryHandler.expandSearch(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) { ...@@ -55,8 +55,7 @@ var QueryHandler = function(options) {
QueryHandler.prototype.expandSearch = function(expression) { QueryHandler.prototype.expandSearch = function(expression) {
if (expression==null || expression==="") { if (expression==null || expression==="") {
return; return;
} }
var _this = this;
if ($("#expression").length>0) { if ($("#expression").length>0) {
if ($("#expression").val().length>0) { if ($("#expression").val().length>0) {
$("#expression").val($("#expression").val() + " " + expression); $("#expression").val($("#expression").val() + " " + expression);
...@@ -69,11 +68,9 @@ QueryHandler.prototype.expandSearch = function(expression) { ...@@ -69,11 +68,9 @@ QueryHandler.prototype.expandSearch = function(expression) {
$(facetElement).find(".search-facet-expression").val(expression); $(facetElement).find(".search-facet-expression").val(expression);
//_this.doSearch(); //_this.doSearch();
}); });
} }
}; };
QueryHandler.prototype.selectFacetingSchema = function() { QueryHandler.prototype.selectFacetingSchema = function() {
this.schemaId = $("#schemaId").val(); this.schemaId = $("#schemaId").val();
var container = $("#facet-schema-info"); var container = $("#facet-schema-info");
...@@ -129,8 +126,6 @@ QueryHandler.prototype.clearSearchFacets = function() { ...@@ -129,8 +126,6 @@ QueryHandler.prototype.clearSearchFacets = function() {
$("#search-facets-container").text(""); $("#search-facets-container").text("");
}; };
QueryHandler.prototype.insertSearchFacet = function() { QueryHandler.prototype.insertSearchFacet = function() {
var _this = this; var _this = this;
$.ajax({ $.ajax({
...@@ -166,24 +161,24 @@ QueryHandler.prototype.removeSearchFacet = function(control) { ...@@ -166,24 +161,24 @@ QueryHandler.prototype.removeSearchFacet = function(control) {
this.reorderFacets(); this.reorderFacets();
}; };
QueryHandler.prototype.doSearch = function(isShowMore) { QueryHandler.prototype.doSearch = function(isShowMore) {
//if (isShowMore===null || isShowMore===undefined) { if (isShowMore===null || isShowMore===undefined) {
isShowMore=false; isShowMore=false;
//} }
var _this = this;
this.query = this.buildQuery(isShowMore); this.query = this.buildQuery(isShowMore);
this.imageQueue = []; this.imageQueue = [];
$(".wordcloud").text(""); $(".wordcloud").text("");
this.clouds = []; this.clouds = [];
var _this = this;
if (this.query!==null) { if (this.query!==null) {
$("#search-loading-indicator").removeClass("fade"); $("#search-loading-indicator").removeClass("fade");
$.ajax({ $.ajax({
url: __util.getBaseUrl() + "query/", url: __util.getBaseUrl() + "query/",
type: "POST", type: "POST",
dataType: "json", dataType: "json",
data: JSON.stringify(_this.query), data: JSON.stringify(this.query),
contentType: "application/json", contentType: "application/json",
success: function(data, jqXHR, textStatus) { success: function(data, jqXHR, textStatus) {
$("#search-loading-indicator").addClass("fade"); $("#search-loading-indicator").addClass("fade");
...@@ -198,6 +193,7 @@ QueryHandler.prototype.doSearch = function(isShowMore) { ...@@ -198,6 +193,7 @@ QueryHandler.prototype.doSearch = function(isShowMore) {
} }
}); });
} }
}; };
QueryHandler.prototype.doSearchDelayed = function() { QueryHandler.prototype.doSearchDelayed = function() {
...@@ -213,10 +209,6 @@ QueryHandler.prototype.delaySearch = function(timestamp) { ...@@ -213,10 +209,6 @@ QueryHandler.prototype.delaySearch = function(timestamp) {
} }
}; };
QueryHandler.prototype.addFilter = function(queryFilter, html) { QueryHandler.prototype.addFilter = function(queryFilter, html) {
var match = false; var match = false;
...@@ -255,9 +247,6 @@ QueryHandler.prototype.removeAllFilters = function() { ...@@ -255,9 +247,6 @@ QueryHandler.prototype.removeAllFilters = function() {
this.doSearchDelayed(); this.doSearchDelayed();
}; };
QueryHandler.prototype.buildQuery = function(isShowMore) { QueryHandler.prototype.buildQuery = function(isShowMore) {
var query = { var query = {
entities: [], entities: [],
......
...@@ -34,10 +34,8 @@ var ResponseHandler = function(options) { ...@@ -34,10 +34,8 @@ var ResponseHandler = function(options) {
"~eu.dariah.de.minfba.search.view.result.no_title", "~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.relevance_score",
"~eu.dariah.de.minfba.search.view.result.resources.hits_in_document", "~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 = []; this.imageQueue = [];
}; };
...@@ -58,6 +56,14 @@ ResponseHandler.prototype.process = function(resultArray, isShowMore) { ...@@ -58,6 +56,14 @@ ResponseHandler.prototype.process = function(resultArray, isShowMore) {
//_this.processResponseTerms(); //_this.processResponseTerms();
//_this.processResponseSubjects(); //_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);
} }
} }
}; };
......
Supports Markdown
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