/*
* Copyright 2008 punkt .netServices
*
* Licensed under the punkt .netServices License, Version 2.3 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.punkt.at/licenses/LICENSE-2.3
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/


/*
* @author turnguard
*/


function LuceneSearchAssetType(Name) {
	this.class_IE = "ConXSearch.core.Search.LuceneSearchAssetType";
	this.name = Name;
	this.startAt = 0;
	this.hitsPerPage = 10000; // MZ 10000 statt 5
	this.totalHits = 0;
   	this.filter = new Array();
	this.searchFields = new Array();
    this.sort = "";
	this.display = "none";

	this.GetClass = function(){ return this.class_IE; }

	this.SetName = function(name){ this.name = name; }
   	this.GetName = function(){ return this.name};

   	this.SetStartAt = function(startAt){ this.startAt = startAt; }    
	this.GetStartAt = function(){ return this.startAt; }    

   	this.SetHitsPerPage = function(hitsPerPage){ this.hitsPerPage = hitsPerPage; }
	this.GetHitsPerPage = function(){ return this.hitsPerPage; }

	this.GetTotalHits = function(){ return this.totalHits; }
	
	this.AddAssetTypeSearchFilter = function(AssetTypeSearchFilter){ this.filter.push(AssetTypeSearchFilter); }
	this.GetAssetTypeSearchFilter = function(){ return this.filter; }
	
	this.SetSearchFields = function(searchFields){ this.searchFields = searchFields; }
	this.AddSearchField = function(searchField){ this.searchFields.push(searchField); }
	this.GetSearchFields = function(){ return this.searchFields(); }
    this.SetPaginatorConfig = function(PaginatorConfig){ 
    	this.paginatorConfig = PaginatorConfig;
    	this.paginatorConfig.SetHitsPerPage(this.hitsPerPage);
	}
   	this.SetSort = function(sort){ this.sort = sort; }
	this.SetDisplay = function(display){ this.display = display; }
	this.GetDisplay = function(){ return this.display; }
}

function LuceneSearchAssetTypeFilter(){
	this.class_IE = "ConXSearch.core.Search.LuceneSearchAssetTypeFilter";
	this.key = "";
	this.value = "";
	this.type = 1;


	this.GetClass = function(){ return this.class_IE; }

	this.SetKey = function(key){ this.key = key; }
	this.GetKey = function(){ return this.key; }

	this.SetValue = function(value){ this.value = value; }
	this.GetValue = function(){ return this.value; }

    this.SetType = function(type) { this.type = type; }
}

function LuceneSearchSetup(){
	this.class_IE = "ConXSearch.core.Search.LuceneSearchSetup";
	this.name = "";
	this.assetTypes = new Array();
    this.info = new Object();
	this.queryString = "";
	this.groupResults="true";
    this.useThesaurus="false";
	this.GetClass = function(){ return this.class_IE; }
    this.lang = "en";

   	this.forwardTemplate = "UnGroupedResult.jsp";
	this.startAt = 0;
	this.hitsPerPage = 10;
	
	/* FOR UNGROUPED RESULTS */
	this.SetForwardTemplate = function(forwardTemplate){ this.forwardTemplate = forwardTemplate; }
   	this.GetForwardTemplate = function(){ return this.forwardTemplate};
   	this.SetStartAt = function(startAt){ this.startAt = startAt; }    
	this.GetStartAt = function(){ return this.startAt; }    
   	this.SetHitsPerPage = function(hitsPerPage){ this.hitsPerPage = hitsPerPage; }
	this.GetHitsPerPage = function(){ return this.hitsPerPage; }
    this.SetPaginatorConfig = function(PaginatorConfig){ 
	  	this.paginatorConfig = PaginatorConfig;
   		this.paginatorConfig.SetHitsPerPage(this.hitsPerPage);
	}


    this.SetLang = function(lang){ this.lang=lang;}
    this.GetLang = function(){ return this.lang;}
	
	this.SetName = function(name){ this.name = name; }
	this.GetName = function(){ return this.name; }
	this.AddAssetType = function(AssetType) {  this.assetTypes.push(AssetType); }
	this.GetAssetTypes = function() { return this.assetTypes; }
	this.SetQueryString = function(queryString){ this.queryString = queryString.replace(/([\"])/g,function(thematch){ return "\""; }).replace(/([\'])/g,function(thematch){ return "\'";});}

	this.GetQueryString = function(){ return this.queryString; }
	this.SetGroupResults = function(groupResults){ this.groupResults=groupResults; }
	this.GetGroupResults = function(){ return this.groupResults; }
    this.SetUseThesaurus = function(useThesaurus){ this.useThesaurus = useThesaurus; }
   	this.AddInfo = function(Key,Value){
       		this.info[Key]=Value;
    }
    this.GetInfo = function(){ return this.info;}

	this.UpdateDisplay = function(AssetType, display){
		for(var i = 0; i < this.assetTypes.length; i++){
			if(this.assetTypes[i].GetName()==AssetType){
				this.assetTypes[i].SetDisplay(display);
				return;
			}
		}
	}
}


