/*
 * Isomorphic SmartGWT web presentation layer
 * Copyright 2000 and beyond Isomorphic Software, Inc.
 *
 * OWNERSHIP NOTICE
 * Isomorphic Software owns and reserves all rights not expressly granted in this source code,
 * including all intellectual property rights to the structure, sequence, and format of this code
 * and to all designs, interfaces, algorithms, schema, protocols, and inventions expressed herein.
 *
 *  If you have any questions, please email <sourcecode@isomorphic.com>.
 *
 *  This entire comment must accompany any portion of Isomorphic Software source code that is
 *  copied or moved from this file.
 */

//----------------------------------------------------------------------
// Example of a custom DataSource implementation.  This class demonstrates 
// how to write an adapter to plug support for an ORM system (Hibernate, in
// this case).  Note that this is just an example to demonstrate the principles
// involved - SmartClient Server already has considerably more sophisticated
// Hibernate support than this, built-in
//
// NOTE: In the interests of clarity and brevity, this example intentionally 
// omits exception handling
//
//----------------------------------------------------------------------

package de.smartgwttest.server;

import com.isomorphic.criteria.AdvancedCriteria;
import com.isomorphic.criteria.Evaluator;
import com.isomorphic.datasource.BasicDataSource;
import com.isomorphic.datasource.DSRequest;
import com.isomorphic.datasource.DSResponse;

public class ORMDataSource extends BasicDataSource {

	// Override all four CRUD operations - create, retrieve, update and delete
	// (add, fetch, update and remove in SmartClient terminology).

	// Note that the parameters sent by the client arrive here already converted
	// to Java Maps
	// by the SmartClient Server - with SmartClient Pro, Power and Enterprise
	// Editions, there's
	// no need to worry about conversion to and from XML or JSON even in a
	// custom DS
	// implementation

	public DSResponse executeAdd(DSRequest req) throws Exception {
		return new DSResponse();
	}

	public DSResponse executeFetch(DSRequest req) throws Exception {
		AdvancedCriteria criteria = Evaluator.parseAdvancedCriteria(req.getCriteria());
		return new DSResponse();
	}

	public DSResponse executeRemove(DSRequest req) throws Exception {
		return new DSResponse();
	}

	public DSResponse executeUpdate(DSRequest req) throws Exception {
		return new DSResponse();
	}

}
