⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cardholderbean.java

📁 我在加拿大学习的一个比较复杂的在线银行程序.
💻 JAVA
字号:
package com.ebusiness.ebank.ejb.entitybean;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2005</p> * <p>Company: eBusiness Inc., All right reserved</p> * @author unascribed * @version 1.0 */import java.util.Collection;import java.util.Iterator;import java.sql.Timestamp;import javax.ejb.EntityBean;import javax.ejb.CreateException;import javax.ejb.EJBException;import javax.ejb.FinderException;import javax.ejb.EntityContext;import com.ebusiness.ebank.exception.BusinessException;import com.ebusiness.ebank.exception.SystemException;import com.ebusiness.ebank.exception.ErrorMessages;import com.ebusiness.ebank.bean.CardholderValue;import com.ebusiness.ebank.bean.AddressValue;import com.ebusiness.ebank.bean.ClientCardValue;import com.ebusiness.ebank.servicedelegate.ServiceLocator;import com.ebusiness.ebank.servicedelegate.ServiceLocatorException;import com.ebusiness.ebank.util.Constants;abstract public class CardholderBean implements EntityBean{    private EntityContext ctx;    private static final String INSERT = "INSERT";    private static final String UPDATE = "UPDATE";    private static final String DELETE = "DELETE";    //Bean attribute accessor    abstract public Long getObjectID();    abstract public void setObjectID(Long oid);    abstract public String getSin();    abstract public void setSin(String sin);    abstract public String getFirstName();    abstract public void setFirstName(String firstName);    abstract public String getLastName();    abstract public void setLastName(String lastName);    abstract public String getMotherMaidenName();    abstract public void setMotherMaidenName(String maidenName);    abstract public String getGender();    abstract public void setGender(String gender);    abstract public Timestamp getDateOfBirth();    abstract public void setDateOfBirth(Timestamp dob);    abstract public String getMaritalStatus();    abstract public void setMaritalStatus(String maritalStatus);    abstract public String getEmploymentStatus();    abstract public void setEmploymentStatus(String employmentStatus);    abstract public String getSalary();    abstract public void setSalary(String salary);    abstract public Timestamp getEnrollmentDate();    abstract public void setEnrollmentDate(Timestamp enrollmentDate);    abstract public String getHomePhone();    abstract public void setHomePhone(String homePhone);    abstract public String getCellPhone();    abstract public void setCellPhone(String cellPhone);    abstract public String getBusinessPhone();    abstract public void setBusinessPhone(String businessPhone);    abstract public String getEmails();    abstract public void setEmails(String emails);    abstract public String getStatus();    abstract public void setStatus(String status);    abstract public Timestamp getEffectiveDate();    abstract public void setEffectiveDate(Timestamp effectiveDate);    abstract public Timestamp getExpiryDate();    abstract public void setExpiryDate(Timestamp expiryDate);    public abstract Collection getAddresses();    public abstract void setAddresses(Collection addresses);    abstract public String getCreateUserID();    abstract public void setCreateUserID(String createUserID);    abstract public Timestamp getCreateDate();    abstract public void setCreateDate(Timestamp createDate);    abstract public String getUpdateUserID();    abstract public void setUpdateUserID(String updateUserID);    abstract public Timestamp getUpdateDate();    abstract public void setUpdateDate(Timestamp expiryDate);    abstract public String getAction();    abstract public void setAction(String action);    // Business methods    /**     * Parse the entity bean value to CardholderValue object     *     * @return CardholderValue     */    public CardholderValue getValueObject()    {        CardholderValue value = new CardholderValue(this.getObjectID().longValue());        value.setSIN(this.getSin());        value.setFirstName(this.getFirstName());        value.setLastName(this.getLastName());        value.setMotherMaidenName(this.getMotherMaidenName());        value.setGender(this.getGender());        value.setDateOfBirth(this.getDateOfBirth());        value.setMaritalStatus(this.getMaritalStatus());        value.setEmploymentStatus(this.getEmploymentStatus());        value.setSalary(this.getSalary());        value.setEnrollmentDate(this.getEnrollmentDate());        value.setHomePhone(this.getHomePhone());        value.setCellPhone(this.getCellPhone());        value.setBusinessPhone(this.getBusinessPhone());        value.setEmails(this.getEmails());        value.setStatus(this.getStatus());        //get addresses values and add them to CardholderValue        Collection addresses = this.getAddresses();        for (Iterator iterator = addresses.iterator(); iterator.hasNext();) {            AddressLocal addressLocal = (AddressLocal) iterator.next();            value.addAddress(addressLocal.getValueObject());            //value.addAddress(addressLocal.getLiteValueObject());        }        //common values        value.setEffectiveDate(this.getEffectiveDate());        value.setExpiryDate(this.getExpiryDate());        value.setCreateUserID(this.getCreateUserID());        value.setCreateDate(this.getCreateDate());        value.setUpdateUserID(this.getUpdateUserID());        value.setUpdateDate(this.getUpdateDate());        value.setAction(this.getAction());        return value;    }    public void updateStatus(String status)    {        this.setStatus(status);        this.setUpdateUserID(ctx.getCallerPrincipal().getName());    }    //Add a new address to Cardholder    private void addAddress(AddressLocal address){            getAddresses().add(address);    }    /**     * Update addDelFlag field and replace the process date and time with current date and time.     *     * @param value :    CardholderValue     * @return      :    updated CardholderValue     */    public CardholderValue update(CardholderValue value)    {        this.setSin(value.getSIN());        this.setFirstName(value.getFirstName());        this.setLastName(value.getLastName());        this.setMotherMaidenName(value.getMotherMaidenName());        this.setGender(value.getGender());        this.setDateOfBirth(value.getDateOfBirth());        this.setMaritalStatus(value.getMaritalStatus());        this.setEmploymentStatus(value.getEmploymentStatus());        this.setSalary(value.getSalary());        this.setEnrollmentDate(value.getEnrollmentDate());        this.setHomePhone(value.getHomePhone());        this.setCellPhone(value.getCellPhone());        this.setBusinessPhone(value.getBusinessPhone());        this.setEmails(value.getEmails());        this.setStatus(value.getStatus());        this.setUpdateUserID(this.ctx.getCallerPrincipal().getName());        return this.getValueObject();    }    // Framework and lifecycle methods    /**     * This method will insert a record to the Cardholder table.     * The method should be called within Cardholder Entity Bean since the Cardholder     * must have a valid cardholder     */    public Long ejbCreate(CardholderValue value)         throws CreateException    {        this.setSin(value.getSIN());        this.setFirstName(value.getFirstName());        this.setLastName(value.getLastName());        this.setMotherMaidenName(value.getMotherMaidenName());        this.setGender(value.getGender());        this.setDateOfBirth(value.getDateOfBirth());        this.setMaritalStatus(value.getMaritalStatus());        this.setEmploymentStatus(value.getEmploymentStatus());        this.setSalary(value.getSalary());        this.setEnrollmentDate(value.getEnrollmentDate());        this.setHomePhone(value.getHomePhone());        this.setCellPhone(value.getCellPhone());        this.setBusinessPhone(value.getBusinessPhone());        this.setEmails(value.getEmails());        this.setStatus(value.getStatus());        String userID = this.ctx.getCallerPrincipal().getName();        this.setEffectiveDate(value.getEffectiveDate());        this.setExpiryDate(value.getExpiryDate());        this.setCreateUserID(userID);        this.setUpdateUserID(userID);        return null; //for container managed persistence    }    //Cardholder ObjectID is not ready yet in ejbCreate() method. So the addresses must    //be saved in ejbPostCreate() method    public void ejbPostCreate(CardholderValue value) throws CreateException, BusinessException    {        AddressLocalHome addressHome;        Collection addresses = value.getAddresses();        Iterator it = addresses.iterator();        AddressLocal addressLocal;        AddressValue address;        try        {           addressHome = (AddressLocalHome)ServiceLocator.getInstance().getLocalHome(Constants.ADDRESS_LOCALHOME);        }        catch(ServiceLocatorException ne)        {           throw new CreateException(ErrorMessages.FAIL_TO_LOOKUP_LOCALHOME + " - " + Constants.ADDRESS_LOCALHOME);        }        while((it != null) && (it.hasNext()))        {             address = (AddressValue) it.next();             address.setCardholderOID(this.getObjectID().longValue()); //set cardholderOID for this address             addressLocal = (AddressLocal)addressHome.create(address);             this.addAddress(addressLocal);        }    }    public void ejbActivate() {}    public void ejbLoad() {}    public void ejbPassivate() {}    public void ejbRemove() //this method will delete the record from database    {        this.setUpdateUserID(this.ctx.getCallerPrincipal().getName());        this.setAction(this.DELETE);    }    public void ejbStore() {}    public void setEntityContext(EntityContext ctx)    {        this.ctx = ctx;    }    public void unsetEntityContext()    {        this.ctx = null;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -