Source: queryResult.js

/**
 * @class
 * The result from a fetchData call to a searcher
 * */
Septima.Search.QueryResult = Septima.Class (
		/** @lends Septima.Search.QueryResult# */
		{
	
	_searcher: null,
	_results: null,
	_newQueries: null,
	_suggestions: null,
	_allResults: null,
	
	initialize: function (searcher) {
		this._searcher = searcher;
		this._results = [];
		this._newQueries = [];
		this._suggestions = [];
		this._allResults = [];
		this._target = this.getTarget(this._searcher);
	},
	
	addResult: function(title, description, geometry, data){
		var result = {"title": title, "description": description, "geometry": geometry, "data": data, "searcher": this._searcher};
		if (typeof result.target === 'undefined'){
			result.target = this._target;
		}
		this._results.push(result);
		this._allResults.push(result);
		return result;
	},
	
	addResults: function(results){
		for (var i=0;i<results.length;i++){
			var result = results[i];
			if (typeof result.target === 'undefined'){
				result.target = this._target;
			}
			this._results.push(result);
			this._allResults.push(result);
		}
	},
	
	addSuggestion: function(title, suggestion){
		this._suggestions.push({"title": title, "suggestion": suggestion, "searcher": this._searcher});
	},
	
	addSuggestions: function(suggestions){
		for (var i=0;i<suggestions.length;i++){
			this._suggestions.push(suggestions[i]);
		}
	},
	
	addNewQuery: function(title, description, newQueryString, geometry, data){
		var newQuery = {"title": title, "description": description, "newquery": newQueryString, "geometry": geometry, "data": data, "searcher": this._searcher};
		this._newQueries.push(newQuery);
		this._allResults.push(newQuery);
		return newQuery;
	},
	
	addNewQueries: function(newQueries){
		for (var i=0;i<newQueries.length;i++){
			this._newQueries.push(newQueries[i]);
			this._allResults.push(newQueries[i]);
		}
	},
	
	getSearcher: function(){
		return this._searcher;
	},
	
	getTarget: function(searcher){
		var target = "none";
		if (typeof searcher !== 'undefined' && searcher !== null){
			if (searcher.title !== ''){
				target = searcher.title;
			}else{
				target = searcher.getId();
			}
		}
		return target;
	},
	
	getNewQueries: function(){
		return this._newQueries;
	},
	
	getResults: function(){
		return this._results;
	},
	
	getAllResults: function(){
		return this._allResults;
	},
	
	getSuggestions: function(){
		return this._suggestions;
	},
	
	CLASS_NAME: 'Septima.Search.QueryResult'

});