📄 addressbean.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.sql.Timestamp;import javax.ejb.EntityBean;import javax.ejb.CreateException;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.AddressValue;import com.ebusiness.ebank.util.ValidationHelper;import com.ebusiness.ebank.util.Constants;abstract public class AddressBean implements EntityBean{ private EntityContext ctx; private static final String INSERT = "I"; private static final String UPDATE = "U"; private static final String DELETE = "D"; //Bean attribute accessor abstract public Long getObjectID(); abstract public void setObjectID(Long oid); abstract public String getAddressType(); abstract public void setAddressType(String AddressType); abstract public String getStreetNo(); abstract public void setStreetNo(String streetNo); abstract public String getStreetName(); abstract public void setStreetName(String streetName); abstract public String getSuiteNo(); abstract public void setSuiteNo(String suiteNo); abstract public String getCity(); abstract public void setCity(String city); abstract public String getProvinceState(); abstract public void setProvinceState(String provinceState); abstract public String getCountry(); abstract public void setCountry(String country); abstract public String getPostalZipCode(); abstract public void setPostalZipCode(String postalZipCode); abstract public Long getCardholderOID(); abstract public void setCardholderOID(Long oid); abstract public Timestamp getEffectiveDate(); abstract public void setEffectiveDate(Timestamp effectiveDate); abstract public Timestamp getExpiryDate(); abstract public void setExpiryDate(Timestamp expiryDate); 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 AddressValue object * * @return AddressValue */ public AddressValue getValueObject() { AddressValue value = new AddressValue(this.getObjectID().longValue()); value.setAddressType(this.getAddressType()); value.setStreetNo(this.getStreetNo()); value.setStreetName(this.getStreetName()); value.setSuiteNo(this.getSuiteNo()); value.setCity(this.getCity()); value.setProvinceState(this.getProvinceState()); value.setCountry(this.getCountry()); value.setPostalZipCode(this.getPostalZipCode()); value.setCardholderOID(this.getCardholderOID().longValue()); //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; } /** * Parse the key fileds of entity bean value to AddressValue object * * @return AddressValue */ public AddressValue getLiteValueObject() { AddressValue value = new AddressValue(this.getObjectID().longValue()); value.setAddressType(this.getAddressType()); value.setStreetNo(this.getStreetNo()); value.setStreetName(this.getStreetName()); value.setSuiteNo(this.getSuiteNo()); value.setCity(this.getCity()); value.setProvinceState(this.getProvinceState()); value.setCountry(this.getCountry()); value.setPostalZipCode(this.getPostalZipCode()); value.setCardholderOID(this.getCardholderOID().longValue()); //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; } /** * Update addDelFlag field and replace the process date and time with current date and time. * * @param value : AddressValue * @return : updated AddressValue */ public AddressValue update(AddressValue value) throws BusinessException { this.validate(value); //validate the address before update it this.setAddressType(value.getAddressType()); this.setStreetNo(value.getStreetNo()); this.setStreetName(value.getStreetName()); this.setSuiteNo(value.getSuiteNo()); this.setCity(value.getCity()); this.setProvinceState(value.getProvinceState()); this.setCountry(value.getCountry()); this.setPostalZipCode(value.getPostalZipCode()); this.setUpdateUserID(this.ctx.getCallerPrincipal().getName()); return this.getValueObject(); } //validate the address. the address should be validated before inserting or updating private void validate(AddressValue value) throws BusinessException { if (!ValidationHelper.getInstance().isCountryValid(value.getCountry())) throw new BusinessException(ErrorMessages.COUNTRY_NOT_EXIST); if (!ValidationHelper.getInstance().isStateProvValid(value.getCountry(), value.getProvinceState())) throw new BusinessException(ErrorMessages.STATE_NOT_EXIST); } // Framework and lifecycle methods /** * This method will insert a record to the Address table. * The method should be called within Cardholder Entity Bean since the address * must have a valid cardholder */ public Long ejbCreate(AddressValue value) throws CreateException, BusinessException { this.validate(value); //validate the address before save it this.setAddressType(value.getAddressType()); this.setStreetNo(value.getStreetNo()); this.setStreetName(value.getStreetName()); this.setSuiteNo(value.getSuiteNo()); this.setCity(value.getCity()); this.setProvinceState(value.getProvinceState()); this.setCountry(value.getCountry()); this.setPostalZipCode(value.getPostalZipCode()); //this.setCardholderOID(new Long(value.getCardholderOID())); 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 } public void ejbPostCreate(AddressValue value) throws CreateException {} 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 + -