/*
 * Copyright (c) 2009 The Olympos Development Team.
 * 
 * http://sourceforge.net/projects/olympos/
 * 
 * All rights reserved. This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html. If redistributing this code, this
 * entire header must remain intact.
 */
Ext.namespace("cwe.modelgrid");

/**
 * @class Loads the data for a model grid.
 * 
 * @extends Ext.data.Store
 * @constructor
 * @see cwe.modelgridgrid.ModelGrid
 * @param {Object}
 *            config The configuration object.
 * @config modelDescription The Model Description to load object of.
 */
cwe.modelgrid.SearchStore = function(config) {
	this.modelDescription = config.modelDescription;

	var exampleRecord = new chi.model.ModelRecord(this.modelDescription);

	var fields = exampleRecord.fields;
	fields.add("cwe-relevance", {
	    name : "cwe-relevance",
	    mapping : "cwe-relevance"
	});
	fields.add("cwe-relative-relevance", {
	    name : "cwe-relative-relevance",
	    mapping : "cwe-relative-relevance"
	});

	cwe.modelgrid.SearchStore.superclass.constructor.call(this, Ext.apply( {
	    proxy : new cwe.modelgrid.SearchProxy( {
	        modelDescription : this.modelDescription,
	        query : config.query
	    }),
	    fields : fields,
	    remoteSort : true
	}, config));
};

Ext.extend(cwe.modelgrid.SearchStore, Ext.data.Store);

cwe.modelgrid.SearchStore.prototype.getModelDescription = function() {
	return this.modelDescription;
};
