package com.fuse.storage;

/*
	FUSE Light Server - multiuser server application
	Copyright (C) 2000 Aapo Kyrola / Sulake Oy  Helsinki, Finland

	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/


import java.util.*;
import java.rmi.*;

/**
  * FUSEDatabase is an highlevel remote interface to a 
  * database which can store FUSEDataObjects.
  * @see com.fuse.storage.FUSEDataObject
  * @author Aapo Kyrola
  */
public interface FUSEDatabase extends Remote {
	
	/**
	  * Constructs a FUSEDataObject of given type, which
	  * is compatible with the database implementation.
	  * The loaded object is typically named <impl package>.<type><impl type>:
	  * for example, if type is "FUSEUser" and we are using SQL implementation,
	  * the class is com.fuse.storage.sql.FUSEUserSQL
	  * @param type object type, such as "FUSEUser" or "logentry"
	  * @throws java.lang.ClassNotFoundException if object not found
	  */
	public FUSEDataObject createNew(String type) throws ClassNotFoundException, RemoteException;
	
	/** 
	  * Stores an object
	  * @param dbObject the object to store
	  * @returns the stored object  (use it after this method)
	  * @throws com.fuse.storage.DatabaseException if insertion failed
	  */
	public FUSEDataObject insert(FUSEDataObject dbObject) throws DatabaseException, RemoteException;
	
	/**
	  * Deletes an object from the database
	  * @param dbObject the data object to delete
	  * @throws com.fuse.storage.DatabaseException if deleting failed
	  */
	public void delete(FUSEDataObject dbObject) throws DatabaseException, RemoteException;
	
	/**
	  * Updates an object in the database
	  * @param dbObject the data object to update
	  * @returns the updated object (use it after this method)
	  */
	public FUSEDataObject update(FUSEDataObject dbObject) throws DatabaseException, RemoteException;
	
	/**
	  * Makes a query of data object from the database. The actual query is 
	  * done by the ObjectQueryBean
	  * @param bean the objectQueryBean which implements the query
	  * @returns Vector the found objects
	  */
	public Vector query(ObjectQueryBean bean) throws DatabaseException, RemoteException;
	
	/**
	  * Makes a query which returns some numeric information.
	  * @param bean the bean which implements the query
	  * @returns an object which knows the resuls
	  */
	public Object querySummary(SummaryQueryBean bean) throws DatabaseException, RemoteException;
}
