/*
 * JOnAS: Java(TM) Open Application Server
 * Copyright (C) 1999 Bull S.A.
 * Contact: jonas-team@objectweb.org
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * --------------------------------------------------------------------------
 * $Id$
 * --------------------------------------------------------------------------
 */

package org.objectweb.jonas.jtests.beans.relation.omb;

import java.util.Collection;
import java.rmi.RemoteException;
import javax.ejb.CreateException;
import javax.ejb.EJBObject;
import javax.ejb.FinderException;

/**
 * @author S.Chassande-Barrioz, Helene Joanin, Philippe Durieux
 */
public interface ARemote extends EJBObject {

    String getId() throws RemoteException;

    /**
     * It replaces the referenced elements of the relation by the element of the
     * collection specified.
     * This method has the transactional attribut TX_SUPPORTS.
     * @param c is a collection of the primary key of the bean 'B'. Then the
     * elements are java.lang.String objects.
     * @throw a FinderException if among the collection a primary key does not
     * match to a bean.
     */
    void assignB(Collection c) throws FinderException, RemoteException;

    /**
     * It replaces the referenced elements of the relation by the element of the
     * collection specified.
     * This method has the transactional attribut TX_REQUIRES_NEW.
     * @param c is a collection of the primary key of the bean 'B'. Then the
     * elements are java.lang.String objects.
     * @throw a FinderException if among the collection a primary key does not
     * match to a bean.
     */
    void assignBInNewTx(Collection c) throws FinderException, RemoteException;


    /**
     * It returns the primary key of the referenced elements.
     * This method has the transactional attribut TX_SUPPORTS.
     * @return a collection of the primary key of the bean 'B'. Then the
     * elements are java.lang.String objects.
     */
    Collection retrieveB() throws RemoteException;

    /**
     * It returns the primary key of the referenced elements.
     * @return a collection of the primary key of the bean 'B'. Then the
     * elements are java.lang.String objects.
     * Same as retrieveB, but the implementation differs.
     */
    Collection retrieveBisB() throws RemoteException;

    /**
     * It returns the primary key of the referenced elements.
     * This method has the transactional attribut TX_REQUIRES_NEW.
     * @return a collection of the primary key of the bean 'B'. Then the
     * elements are java.lang.String objects.
     */
    Collection retrieveBInNewTx() throws RemoteException;


    /**
     * It adds in the multivalued relation the bean B defined by the primary
     * keys specified by the parameter.
     * This method has the transactional attribut TX_SUPPORTS.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void addAllInB(Collection pkbs) throws FinderException, RemoteException;

    /**
     * It adds in the multivalued relation the beans B defined by the primary
     * keys specified by the parameter.
     * This method has the transactional attribut TX_REQUIRES_NEW.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void addAllInBInNewTx(Collection pkbs) throws FinderException, RemoteException;


    /**
     * It adds in the multivalued relation the bean B defined by its primary
     * key specified by the parameter.
     * This method has the transactional attribut TX_SUPPORTS.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void addInB(String pkb) throws FinderException, RemoteException;

    /**
     * It adds in the multivalued relation the bean B defined by its primary
     * key specified by the parameter.
     * This method has the transactional attribut TX_REQUIRES_NEW.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void addInBInNewTx(String pkb) throws FinderException, RemoteException;

    /**
     * Creates a new B and add it to the B list of A.
     */
    void addNewB(String pkb) throws CreateException, FinderException, RemoteException;

    /**
     * It removes from the multivalued relation the bean B defined by its primary
     * key specified by the parameter.
     * This method has the transactional attribut TX_SUPPORTS.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void removeFromB(String pkb) throws FinderException, RemoteException;

    /**
     * It removes from the multivalued relation the bean B defined by its primary
     * key specified by the parameter.
     * This method has the transactional attribut TX_REQUIRES_NEW.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    void removeFromBInNewTx(String pkb) throws FinderException, RemoteException;


    /**
     * It clear the multivalued relation
     * This method has the transactional attribut TX_SUPPORTS.
     */
    void clearB() throws RemoteException;

    /**
     * It clear the multivalued relation
     * This method has the transactional attribut TX_REQUIRES_NEW.
     */
    void clearBInNewTx() throws RemoteException;

    /**
     * It returns true the multivalued relation contains all the bean B defined
     * by the primary keys specified by the parameter.
     * This method has the transactional attribut TX_SUPPORTS.
     * @throw a FinderException if a primary key does not match to a bean.
     */
    boolean containAllInB(Collection pkbs) throws FinderException, RemoteException;


    /**
     * It returns true the multivalued relation contains the bean B defined
     * by the primary key specified by the parameter.
     * This method has the transactional attribut TX_SUPPORTS.
     * @throw a FinderException if the primary key does not match to a bean.
     */
    boolean containInB(String pkb) throws FinderException, RemoteException;

    /**
     * This method check it isn't allowed to reset the pk.
     * It returns true if the test is ok.
     * See spec 2.0, chapter 10.3.5, page 134
     */
    boolean testResetPkForbidden(String pka) throws RemoteException;

}
