/*
 * 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");

/**
 */
cwe.Persistency = function() {
	cwe.Persistency.superclass.constructor.call(this);

};

Ext.extend(cwe.Persistency, chi.persistency.DionysosJson);

cwe.Persistency.prototype.listTransactions = function(accountOid, recurring, query, limit, offset, sortAttributeName, sortDirection, successHandler, errorHandler) {
	return this.jsonRequest( {
	    action : "listTransactions",
	    accountOid : accountOid,
	    recurring : recurring,
	    query : query,
	    limit : limit,
	    offset : offset,
	    sortFieldName : sortAttributeName,
	    sortDirection : sortDirection
	}, successHandler, errorHandler, this.listTransactionsRecordHandler);
};

cwe.Persistency.prototype.listTransactionsRecordHandler = function(handler, options, data) {
	return {
	    accountOid : options.localParams.accountOid,
	    recurring : options.localParams.recurring,
	    query : options.localParams.query,
	    limit : options.localParams.limit,
	    offset : options.localParams.offset,
	    sortAttributeName : options.localParams.sortFieldName,
	    sortDirection : options.localParams.sortDirection,
	    records : this.createListRecords(data.list),
	    totalCount : data.totalCount,
	    searchData : data.searchData,
	    maxRelevance : data.maxRelevance
	};
};
