📄 tradedetailsbean.java
字号:
/*
* @author : Pushkala
* @version : 1.0
*
* Development Environment : Oracle9i JDeveloper
*
* Name of the File : TradeDetailsBean.java
*
* Creation / Modification History
* Pushkala 26-Apr-2002 Created
*
*/
package oracle.otnsamples.ibfbs.trademanagement.ejb;
import java.util.Date;
import java.util.Collection;
import java.util.ArrayList;
import java.util.Iterator;
import javax.ejb.EntityContext;
import javax.ejb.FinderException;
import oracle.otnsamples.ibfbs.trademanagement.ejb.TradeDetailsLocal;
/**
* This Class contains the Bean Implementation for TradeDetailsLocal interface.
* UserAccount is an Entity Object. Every User Account can have multiple
* TradeDetails and this 1:N relationship between User Account
* Entity Bean and TradeDetails Bean is managed by the OC4J EJB Container.
* This is a CMP Bean where persistence is managed by the EJB Container.
* This Entity represents the TRADEDETAILS Table in the database.
*
* This new feature called CMR (Container Managed Relationships) is a new
* feature added in EJB 2.0 Specification.
*
* Note that A) This class is defined as abstract as Container actually
* implements most of the logic for managing relationships (CMR). This feature
* is added in EJB 2.0 Specification
* B) This Class also do not declare the instance variables such
* as accountNumber, symbol etc. In earlier approach EJB 1.1, the Entity Bean
* used to declare the instance variables mapping to variables in the Entity
* object. This was removed in EJB 2.0 Specification.
*
* @version 1.0
* @since 1.0
*/
public abstract class TradeDetailsBean implements javax.ejb.EntityBean {
/**
* This method is called by the EJB Container when the client invokes
* create() method on the home interface.
*
* @param tradeId Trade Id
* @param accountNumber User Account Number
* @param action Action
* Valid Values are
* 'B' for 'Buy,
* 'S' for 'Sell',
* 'T' for 'Transfer'
* @param quantity Quantity
* @param tradeDate Trade Date
* @param price Price
* @param symbol Symbol
* @param orderType Order Type
* Valid Values are
* 'M' for 'Market Order',
* 'L' for 'Limit Order',
* 'D' for 'Day Order'
* @param status Status of the order
* Valid Values are
* 'R' for 'Requested' when market is closed,
* 'Q' for 'Queued' when order is in queue,
* 'O' for 'Ordered' when the acknowledgement is received for order,
* 'E' for 'Executed' when the order is executed,
* 'P' for 'PartExecuted' when the order is part executed,
* 'X' for 'Rejected' by Exchange,
* 'C' for 'Cancelled' by User
* @param exchangeId Exchange Id
* @return The primary Key of the created record, in this case null is returned
* @since 1.0
*/
public Integer ejbCreate(Integer tradeId, Integer accountNumber,
String action, Integer quantity, Date tradeDate,
float price, String symbol, String orderType,
String status, Integer exchangeId) {
setTradeId(tradeId);
setAccountNumber(accountNumber);
setAction(action);
setQuantity(quantity);
setTradeDate(tradeDate);
setPrice(price);
setSymbol(symbol);
setOrderType(orderType);
setStatus(status);
setExchangeId(exchangeId);
return null;
}
/**
* This method is called by the EJB Container after invoking of ejbCreate().
* This method has the same signature as ejbCreate() method.
*
* @param tradeId Trade Id
* @param accountNumber User Account Number
* @param action Action
* Valid Values are
* 'B' for 'Buy,
* 'S' for 'Sell',
* 'T' for 'Transfer'
* @param quantity Quantity
* @param tradeDate Trade Date
* @param price Price
* @param symbol Symbol
* @param orderType Order Type
* Valid Values are
* 'M' for 'Market Order',
* 'L' for 'Limit Order',
* 'D' for 'Day Order'
* @param status Status of the order
* Valid Values are
* 'R' for 'Requested' when market is closed,
* 'Q' for 'Queued' when order is in queue,
* 'O' for 'Ordered' when the acknowledgement is received for order,
* 'E' for 'Executed' when the order is executed,
* 'P' for 'PartExecuted' when the order is part executed,
* 'X' for 'Rejected' by Exchange,
* 'C' for 'Cancelled' by User
* @param exchangeId Exchange Id
* @since 1.0
*/
public void ejbPostCreate(Integer tradeId, Integer accountNumber,
String action, Integer quantity, Date tradeDate,
float price, String symbol, String orderType,
String status, Integer exchangeId) {
}
/**
* Declare Abstract Methods for persistent fields. Note that the persistent
* fields are tradeId, accountNumber, action, quantity, tradeDate, Symbol,
* price, orderType, status, exchangeId. These methods are supplied by the
* EJB Container itself Unlike in EJB 1.1 spec, where it was the
* responsibility of the bean itself to manage these fields.
*/
/**
* Method to get the Trade Id of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Trade Id
* @since 1.0
*/
public abstract Integer getTradeId();
/**
* Method to set the Trade Id of the current TradeDetails.
* The method definition is provided by the container.
*
* @param tradeId Trade Id
* @since 1.0
*/
public abstract void setTradeId(Integer tradeId);
/**
* Method to get the User Account Number of the current TradeDetails.
* The method definition is provided by the container.
*
* @return The Account Number
* @since 1.0
*/
public abstract Integer getAccountNumber();
/**
* Method to set the Account Number of the current TradeDetails.
* The method definition is provided by the container.
*
* @param accountNumber User Account Number
* @since 1.0
*/
public abstract void setAccountNumber(Integer accountNumber);
/**
* Method to get the Action of the current TradeDetails.
* The method definition is provided by the container.
*
* @return String indicating the action
* @since 1.0
*/
public abstract String getAction();
/**
* Method to set the action of the current TradeDetails.
* The method definition is provided by the container.
*
* @param action Action
* @since 1.0
*/
public abstract void setAction(String action);
/**
* Method to get the quantity of stocks of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Quantity of stocks
* @since 1.0
*/
public abstract Integer getQuantity();
/**
* Method to set the quantity of stocks of the current TradeDetails.
* The method definition is provided by the container.
*
* @param quantity Quantity
* @since 1.0
*/
public abstract void setQuantity(Integer quantity);
/**
* Method to get the Trade Date of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Trade Date
* @since 1.0
*/
public abstract Date getTradeDate();
/**
* Method to set the Trade Date of the current TradeDetails.
* The method definition is provided by the container.
*
* @param tradeDate Trade Date
* @since 1.0
*/
public abstract void setTradeDate(Date tradeDate);
/**
* Method to get the Stock price of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Stock Price
* @since 1.0
*/
public abstract float getPrice();
/**
* Method to set the stock price of the current TradeDetails.
* The method definition is provided by the container.
*
* @param price Price
* @since 1.0
*/
public abstract void setPrice(float price);
/**
* Method to get the Stock Symbol of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Stock Symbol
* @since 1.0
*/
public abstract String getSymbol();
/**
* Method to set the Stock Symbol of the current TradeDetails.
* The method definition is provided by the container.
*
* @param symbol Stock Symbol
* @since 1.0
*/
public abstract void setSymbol(String symbol);
/**
* Method to get the Order Type of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Order Type
* @since 1.0
*/
public abstract String getOrderType();
/**
* Method to set the Order Type of the current TradeDetails.
* The method definition is provided by the container.
*
* @param orderType Order Type
* @since 1.0
*/
public abstract void setOrderType(String orderType);
/**
* Method to get the status of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Status
* @since 1.0
*/
public abstract String getStatus();
/**
* Method to set the status of the current TradeDetails.
* The method definition is provided by the container.
*
* @param status Status
* @since 1.0
*/
public abstract void setStatus(String status);
/**
* Method to get the Exchange Id of the current TradeDetails.
* The method definition is provided by the container.
*
* @return Exchange Id
* @since 1.0
*/
public abstract Integer getExchangeId();
/**
* Method to set the exchange id of the current TradeDetails.
* The method definition is provided by the container.
*
* @param exchangeId Exchange Id
* @since 1.0
*/
public abstract void setExchangeId(Integer exchangeId);
/**
* Method to select all the TradeDetails.
*
* @return Collection of all TradeDetails
* @exception FinderException Exception if the EJB-QL fails
*/
public abstract Collection ejbSelectTradeDetails() throws FinderException;
/**
* Method to perform post-processing operations on all the
* Tradedetails retrieved by calling the above method. This
* method further processes the retrieved Tradedetails and checks
* for the trades that were done between the input dates and returns
* the collection of Tradedetails.
* Post-processing information within the EJB container itself
* has the following two advantages :
* 1) It improves performance as the application can now leverage
* the advantage of the vast resources available to the server.
* 2) The data-processing code should go into the business logic
* and not the web-tier. This helps in maintaining the code.
* Above are the two design considerations when deciding between ejbFind and
* ejbSelect methods.
*
* @param toDate Start datetime for checking tradedate
* @param sysDate End datetime for checking tradedate
* @return Collection of <input number of> Top (credited) UserAccounts
* @exception FinderException Exception if the EJB-QL fails
*/
public Collection ejbHomeTradeDetails(Date toDate, Date sysDate)
throws FinderException {
// Invoke the ejbSelect method and get all the TradeDetails.
Collection coll = this.ejbSelectTradeDetails();
// Initialize new Collection to store the retrieved values
Collection tdColl = new ArrayList();
TradeDetailsLocal td = null;
// If the collection is not empty
if (coll != null) {
// Initialize the iterator
Iterator iter = coll.iterator();
// Loop through the Iterator
while (iter.hasNext()){
// Get the TradeDetails
td = (TradeDetailsLocal)iter.next();
// To the new collection add all the tradedetails where
// tradedate is between previous timer interval and current date
if ( td.getTradeDate().after(toDate) &&
td.getTradeDate().before(sysDate) ) {
tdColl.add(td);
}
}
}
return tdColl;
}
/**
* Standard CallBack methods
*/
public void setEntityContext(EntityContext ec) {}
public void unsetEntityContext() {}
public void ejbLoad() {}
public void ejbStore() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void ejbRemove() {}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -