// EmpBean.java

package hr;

import javax.ejb.*;
import java.rmi.*;
import java.util.*;

public abstract class EmpBean implements EntityBean
{

    private EntityContext ectx;

    // getters and setters for cmp fields
    // ===========================================================

    public abstract Integer getEmpNo();
    public abstract void setEmpNo(Integer empNo);

    public abstract String getEmpName();
    public abstract void setEmpName(String empName);

    public abstract Float getSalary();
    public abstract void setSalary(Float salary);

    // getters and setters for relationship fields
    // ===========================================================

    // 1:1 uni
    public abstract AddressLocal getAddress();
    public abstract void setAddress(AddressLocal addressLocal);

    // 1:m uni
    public abstract Collection getPhones();
    public abstract void setPhones(Collection phones);

    // m:1 bi
    public abstract DeptLocal getDept();
    public abstract void setDept(DeptLocal deptLocal);

    // m:m bi
    public abstract Collection getProjects();
    public abstract void setProjects(Collection projects);

    // 1:m bi and m:1 bi
    public abstract Collection getDirects();
    public abstract void setDirects(Collection directs);
    public abstract EmpLocal getManager();
    public abstract void setManager(EmpLocal empLocal);

    // ===========================================================

    public Integer ejbCreate(Emp emp) throws CreateException
    {
        setEmpNo(emp.getEmpNo());
        setEmpName(emp.getEmpName());
        setSalary(emp.getSalary());
        return null;
    }

    public void ejbPostCreate(Emp emp) throws CreateException
    {
        // when just after bean created
    }

    public void ejbStore()
    {
        // when bean persisted
    }

    public void ejbLoad()
    {
        // when bean loaded
    }

    public void ejbRemove()
    {
        // when bean removed
    }

    public void ejbActivate()
    {
        // when bean activated
    }

    public void ejbPassivate()
    {
        // when bean deactivated
    }

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

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

}
