/*
 *************************************************************************
 * Copyright (c) 2004, 2005 Actuate Corporation.
 * 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
 *
 * Contributors:
 *  Actuate Corporation  - initial API and implementation
 *  
 *************************************************************************
 */

package org.eclipse.birt.data.oda.impl;

import java.util.Properties;
import org.eclipse.birt.data.oda.IConnection;
import org.eclipse.birt.data.oda.IDataSetMetaData;
import org.eclipse.birt.data.oda.IQuery;
import org.eclipse.birt.data.oda.OdaException;

/**
 * Default implementation of IConnection 
 * for a simple ODA runtime driver.
 * @deprecated	As of BIRT 2.0, replaced by
 * 		{@link org.eclipse.datatools.connectivity.oda.impl.SimpleConnection} .
 * 		<br>The BIRT ODA run-time framework has been migrated to the 
 * 		Eclipse Data Tools Platform (DTP) project.
 */
public class SimpleConnection implements IConnection
{
    private boolean m_isOpen = false;
    
	/**
	 * @see org.eclipse.birt.data.oda.IConnection#open(java.util.Properties)
	 */
	public void open( Properties connProperties ) throws OdaException
	{
	    m_isOpen = true;
		// TODO data source dependent
		throw new UnsupportedOperationException( "Please override and implement me." );
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#close()
	 */
	public void close() throws OdaException
	{
	    m_isOpen = false;
		// TODO data source dependent
		throw new UnsupportedOperationException( "Please override and implement me." );
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#isOpen()
	 */
	public boolean isOpen() throws OdaException
	{
		return m_isOpen;
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#getMetaData(java.lang.String)
	 */
	public IDataSetMetaData getMetaData( String dataSetType ) throws OdaException
	{
	    // ignores the dataSetType, 
	    // assuming the simple driver supports only one type
		return new SimpleDataSetMetaData( this );
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#newQuery(java.lang.String)
	 */
	public IQuery newQuery( String dataSetType ) throws OdaException
	{
	    // ignores the dataSetType, 
	    // assuming the simple driver supports only one type
		return new SimpleQuery();
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#getMaxQueries()
	 */
	public int getMaxQueries() throws OdaException
	{
		return 0;	// no limit
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#commit()
	 */
	public void commit() throws OdaException
	{
	    // do nothing; assumes no transaction support
	}

	/**
	 * @see org.eclipse.birt.data.oda.IConnection#rollback()
	 */
	public void rollback() throws OdaException
	{
	    throw new UnsupportedOperationException();
	}
}
