//Agurtzane Ene12: mantenimiento destinos
package m05bDestinoEJB;

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

import m05bBD.m05bDestino;


/**
 * This class is the Bean Implementation for the Entity EJB <tt>M05DestinoEB</tt>.
 *
 * @see     m05.exe.Destino
 * @see     m05.exe.M05DestinoEB
 * @see     m05.exe.M05DestinoEBPK
 * @see     m05.exe.M05DestinoEBHome

 */
abstract public class m05DestinoBean implements EntityBean {
  
  private EntityContext ctx;



  /** 
   * This is the primary key.
   * It is the clave, which is the primary key 
   * in table <tt>m0502t00</tt>.
   */
  
  /**
   * Returns the Destino information of this E-EJB.
   */    
  public m05bDestino getDestino(){
    m05bDestino destino = new m05bDestino();
    
    destino.setDest_codigo(getDest_codigo());
    destino.setDest_descripcion(getDest_descripcion());
    destino.setDest_edescripcion(getDest_edescripcion());
    
    return destino;	
  }    

  /**
   * Sets the Destino information of this E-EJB.
   * @exception P2GException 
   *              If the given Destino <tt>avi_codigo</tt> field 
   *              does not match the primary key that is in the E-EJB.
   */   
  public void setDestino(m05bDestino destino)
    throws Exception{
   
    //the primary key is never modified!!
    if (getDest_codigo() != destino.getDest_codigo())
      throw new CreateException ("Cannot modify a different destino");
      
    setDest_descripcion(destino.getDest_descripcion());
    setDest_edescripcion(destino.getDest_edescripcion());
   
  }   	
  
  abstract public String getDest_codigo();
  abstract public void setDest_codigo(String n);
  
  abstract public String getDest_descripcion();
  abstract public void setDest_descripcion(String n);

  abstract public String getDest_edescripcion();
  abstract public void setDest_edescripcion(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 Destino 
   * information of this E-EJB.
   * It assigns a new primary key to the Destino.
   */ 
  public m05DestinoPK ejbCreate(m05bDestino destino) 
    throws CreateException
  {
    try {
      setDest_codigo(getDest_codigo());
    } catch (Exception e) {
      throw new CreateException (e.getMessage());
    }    
    setDest_descripcion(destino.getDest_descripcion());
    setDest_edescripcion(destino.getDest_descripcion());
    return null;      	
  }

  public void ejbPostCreate(m05bDestino destino) 
  {
  }

 
}
