package m05bRestriccionEJB;

import javax.ejb.CreateException;
import javax.ejb.EntityBean;
import javax.ejb.EntityContext;
import javax.ejb.RemoveException;

import m05bBD.m05bRestriccion;


/**
 * This class is the Bean Implementation for the Entity EJB <tt>M05RestriccionEB</tt>.
 *
 * @see     m05.exe.Restriccion
 * @see     m05.exe.M05RestriccionEB
 * @see     m05.exe.M05RestriccionEBPK
 * @see     m05.exe.M05RestriccionEBHome
 * @author <a href="mailto:paco.gomez@terra.com">Paco Gomez</a>.
 *         Professional J2EE Programming with BEA WebLogic Server, 
 *         by Gomez & Zadrozny, Copyright &#169; 2000. 
 */
abstract public class m05RestriccionBean implements EntityBean {
  
  private EntityContext ctx;



  /** 
   * This is the primary key.
   * It is the clave, which is the primary key 
   * in table <tt>m0547t00</tt>.
   */
  /*public String res_dni   = "0";
  public String res_descripcion     = "";*/
  
  /**
   * Returns the Restriccion information of this E-EJB.
   */    
  public m05bRestriccion getRestriccion(){
    m05bRestriccion res = new m05bRestriccion();
    
    res.setRes_dni(getRes_dni());
    res.setRes_descripcion(getRes_descripcion());
    res.setRes_descripcionEu(getRes_descripcionEu());
    
    return res;	
  }    

  /**
   * Sets the Restriccion information of this E-EJB.
   * @exception P2GException 
   *              If the given Restriccion <tt>res_dni</tt> field 
   *              does not match the primary key that is in the E-EJB.
   */   
  public void setRestriccion(m05bRestriccion res)
    throws Exception{
   
    //the primary key is never modified!!
    if (getRes_dni() != res.getRes_dni())
      throw new CreateException ("Cannot modify a different res");
      
    setRes_descripcion(res.getRes_descripcion());
    
  }   	
  
  abstract public String getRes_dni();
  abstract public void setRes_dni(String n);
  
  abstract public String getRes_descripcion();
  abstract public void setRes_descripcion(String n);
  abstract public String getRes_descripcionEu();
  abstract public void setRes_descripcionEu(String n);
  public void ejbActivate() {
  }

  public void ejbPassivate() {
  }

  public void setEntityContext(EntityContext ctx) {
    this.ctx = ctx;
  }

  public void unsetEntityContext() {
    this.ctx = null;
  }

  public void ejbLoad() {
  }
  
  public void ejbStore() {
  }

  public void ejbRemove()
    throws RemoveException
  {
  }

  /**
   * This function initializes the Restriccion 
   * information of this E-EJB.
   * It assigns a new primary key to the Restriccion.
   */ 
  public m05RestriccionPK ejbCreate(m05bRestriccion res) 
    throws CreateException
  {
    try {
      setRes_dni(getRes_dni());
    } catch (Exception e) {
      throw new CreateException (e.getMessage());
    }    
    setRes_descripcion(res.getRes_descripcion());
    setRes_descripcionEu(res.getRes_descripcionEu());
    return null;      	
  }

  public void ejbPostCreate(m05bRestriccion res) 
  {
  }

 
}