/*
 * 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$
 * --------------------------------------------------------------------------
 */

// PersonneEC.java

package org.objectweb.jonas.jtests.beans.annuaire;

import javax.ejb.EntityBean;

import org.objectweb.util.monolog.api.BasicLevel;

/**
 * This is an entity bean with "container managed persistence version 1.x".
 * This class extends the similar entity bean with "CMP version 2.x",
 * and implements methods specifics to this bean.
 * @author Philippe Durieux, Helene Joanin (jonas team)
 */
public class PersonneEC extends PersonneEC2 implements EntityBean {

    boolean dirty = false;
    boolean isModifiedCalled = false;
    boolean ejbStoreCalled = false;

    // ------------------------------------------------------------------
    // State of the bean. 
    // They must be public for Container Managed Persistance.
    // ------------------------------------------------------------------
    public String nom;
    public String numero;
    public int timerIdent;
    public int timerCount;

    // ------------------------------------------------------------------
    // Accessors and setters implementation
    // ------------------------------------------------------------------

    /**
     * getNumero / Tx Attribute = Required
     */
    public String getNumero() {
        logger.log(BasicLevel.DEBUG, "");
        return numero;
    }

    /**
     * setNumero / Tx Attribute = Required
     */
    public void setNumero(String s) {
        logger.log(BasicLevel.DEBUG, "");
        numero = s;
        dirty = true;
    }

    /**
     * setNumero / Tx Attribute = Supports
     */
    public void setNumeroNTX(String s) {
        logger.log(BasicLevel.DEBUG, "");
        super.setNumeroNTX(s);
        dirty = true;
    }

    /**
     * setNom - Attention: on modifie la PK!!!
     */
    public void setNom(String s) {
        logger.log(BasicLevel.DEBUG, "");
        nom = s;
        dirty = true;
    }

    /**
     * getNom
     */
    public String getNom() {
        logger.log(BasicLevel.DEBUG, "");
        return nom;
    }

    public int getTimerIdent() {
        logger.log(BasicLevel.DEBUG, "");
        return timerIdent;
    }

    public void setTimerIdent(int id) {
        logger.log(BasicLevel.DEBUG, "");
        dirty = true;
        timerIdent = id;
    }

    public int getTimerCount() {
        logger.log(BasicLevel.DEBUG, "");
        return timerCount;
    }

    public void setTimerCount(int cnt) {
        logger.log(BasicLevel.DEBUG, "");
        dirty = true;
        timerCount = cnt;
    }


    // ------------------------------------------------------------------
    // isModified method
    // ------------------------------------------------------------------
    public boolean isModified() {
        isModifiedCalled = true;
        return dirty;
    }

    // ------------------------------------------------------------------
    // EntityBean implementation
    // ------------------------------------------------------------------

    public void ejbLoad() {
        logger.log(BasicLevel.DEBUG, "");
        super.ejbLoad();
        dirty = false;
    }

    public void ejbStore() {
        logger.log(BasicLevel.DEBUG, "");
        ejbStoreCalled = true;
        super.ejbStore();
        dirty = false;
    }
    
    // ------------------------------------------------------------------
    // Personne implementation
    // ------------------------------------------------------------------

    public boolean isDirty() {
        logger.log(BasicLevel.DEBUG, "PersonneEC "+nom+" isDirty ="+dirty+" "+numero);
        return dirty;
    }

    public void reset() {
        logger.log(BasicLevel.DEBUG, "PersonneEC "+nom+" reset "+numero);
        isModifiedCalled = false;
        ejbStoreCalled = false;
    }

    public boolean isModifiedCalled() {
        logger.log(BasicLevel.DEBUG, "PersonneEC "+nom+" isModifiedCalled ="+isModifiedCalled+" "+numero);
        return isModifiedCalled;
    }

    public boolean ejbStoreCalled() {
        logger.log(BasicLevel.DEBUG, "PersonneEC "+nom+" ejbStoreCalled ="+ejbStoreCalled+" "+numero);
        return ejbStoreCalled;
    }
	
}
