// DistrictEC2R.java
package org.objectweb.jonas.stests.appli;

import org.objectweb.jonas.common.Log;
import org.objectweb.util.monolog.api.Logger;
import org.objectweb.util.monolog.api.BasicLevel;

/**
 *
 */
public  abstract class DistrictEC2R implements javax.ejb.EntityBean {

    static private Logger logger = null;
    javax.ejb.EntityContext ejbContext;

 
    public java.lang.String ejbCreate(int did, String wid, String name, int order) 
        throws javax.ejb.CreateException{
        logger.log(BasicLevel.DEBUG, "");
        setDistrictId(did);
        setNextOrder(order);
        setDistrictName(name);
        setWarehouseId(wid);
        return null;
    }

    public void ejbPostCreate(int did, String wid, String name, int order) {
        logger.log(BasicLevel.DEBUG, "");
    }

    // ------------------------------------------------------------------
    // Persistent fields
    // 
    // ------------------------------------------------------------------
    public abstract int getDistrictId();
    public abstract void setDistrictId(int id);

    public abstract int getNextOrder();
    public abstract void setNextOrder(int o);

   public abstract String getWarehouseId();
    public abstract void setWarehouseId(String w);

    public abstract String getDistrictName();
    public abstract void setDistrictName(String w);

    // ------------------------------------------------------------------
    // Standard call back methods
    // ------------------------------------------------------------------

 
    public void setEntityContext(javax.ejb.EntityContext ctx) {
        if (logger == null) {
            logger = Log.getLogger("org.objectweb.jonas_tests");
        }
        logger.log(BasicLevel.DEBUG, "");
        ejbContext = ctx;
    }


    public void unsetEntityContext() {
        logger.log(BasicLevel.DEBUG, "");
        ejbContext = null;
    }

    public void ejbRemove() throws javax.ejb.RemoveException {
        logger.log(BasicLevel.DEBUG, "");
    }

 
    public void ejbLoad() {
        logger.log(BasicLevel.DEBUG, "");
    }


    public void ejbStore() {
        logger.log(BasicLevel.DEBUG, "");
    }
        

    public void ejbPassivate() {
        logger.log(BasicLevel.DEBUG, "");
    }


    public void ejbActivate() {
        logger.log(BasicLevel.DEBUG, "");
    }    

    public void setNextOrderId(int order) {
        setNextOrder(order);
    }
    /**
     * Gets the district's next order number
     *
     * @throws RemoteException if an RMI exception occurs
     *
     * @param increment a boolean. If true, the order number is incremented after
     * after it is returned. If false, the order number is not incremented.
     *
     * @return an int which represents the next order number
     */
    public int getNextOrderId(boolean increment) {
        int temp = getNextOrder();
        if (increment) {
            setNextOrder(temp+1);
 
        }
        logger.log(BasicLevel.DEBUG,"DistrictBean getNextOrderId  returns :"+temp);
    return temp;
  }

}



