You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2006/10/30 22:52:56 UTC
svn commit: r469284 [1/3] - in /geronimo/daytrader/trunk: ./ modules/ear/
modules/ejb/ modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/
modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/
modules/ejb/src/main/resources/...
Author: djencks
Date: Mon Oct 30 13:52:55 2006
New Revision: 469284
URL: http://svn.apache.org/viewvc?view=rev&rev=469284
Log:
DAYTRADER-16 add JPA mode. Don't know if direct and ejb mode still work. Requires fix for OPENEJB-300 to fully work
Added:
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeJPA.java (with props)
geronimo/daytrader/trunk/modules/ejb/src/main/resources/META-INF/daytrader.sql (with props)
geronimo/daytrader/trunk/modules/ejb/src/main/resources/META-INF/persistence.xml
- copied, changed from r464280, geronimo/sandbox/javaee5/itests-jee5/jpa/ejb/src/main/resources/META-INF/persistence.xml
geronimo/daytrader/trunk/plans/daytrader-jpa-plan.xml (with props)
Modified:
geronimo/daytrader/trunk/modules/ear/pom.xml
geronimo/daytrader/trunk/modules/ejb/pom.xml
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountProfileDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/HoldingDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBeanWS.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/OrderDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/QuoteDataBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeAction.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeConfig.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeServices.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/TradeWSAction.java
geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/ejb/AccountProfileBean.java
geronimo/daytrader/trunk/modules/ejb/src/main/resources/META-INF/ejb-jar.xml
geronimo/daytrader/trunk/modules/web/src/main/webapp/WEB-INF/web.xml
geronimo/daytrader/trunk/pom.xml
Modified: geronimo/daytrader/trunk/modules/ear/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ear/pom.xml?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ear/pom.xml (original)
+++ geronimo/daytrader/trunk/modules/ear/pom.xml Mon Oct 30 13:52:55 2006
@@ -50,6 +50,7 @@
<plugins>
<plugin>
<artifactId>maven-ear-plugin</artifactId>
+ <version>2.2</version>
<configuration>
<displayName>DayTrader 1.2</displayName>
<description>
Modified: geronimo/daytrader/trunk/modules/ejb/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/pom.xml?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/pom.xml (original)
+++ geronimo/daytrader/trunk/modules/ejb/pom.xml Mon Oct 30 13:52:55 2006
@@ -44,6 +44,10 @@
<artifactId>geronimo-qname_1.1_spec</artifactId>
</dependency>
<dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jpa_3.0_spec</artifactId>
+ </dependency>
+ <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<scope>provided</scope>
@@ -53,6 +57,22 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.openjpa</groupId>
+ <artifactId>openjpa-persistence-jdbc</artifactId>
+ <version>0.9.0-incubating-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.6.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xmlParserAPIs</artifactId>
+ <version>2.2.1</version>
+ </dependency>
</dependencies>
<build>
<resources>
@@ -63,6 +83,37 @@
</resources>
<plugins>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <configuration>
+ <tasks>
+ <path id="enhance.path.ref">
+ <fileset dir="${project.build.outputDirectory}">
+ <include name="**/*.class"/>
+ </fileset>
+ </path>
+ <pathconvert property="enhance.files"
+ refid="enhance.path.ref"
+ pathsep=" "/>
+ <java classname="org.apache.openjpa.enhance.PCEnhancer">
+ <arg line="-p persistence.xml"/>
+ <arg line="${enhance.files}"/>
+ <classpath>
+ <path refid="maven.dependency.classpath"/>
+ <path refid="maven.compile.classpath"/>
+ </classpath>
+ </java>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
<plugin>
<artifactId>maven-ejb-plugin</artifactId>
<configuration>
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountDataBean.java Mon Oct 30 13:52:55 2006
@@ -17,221 +17,315 @@
package org.apache.geronimo.samples.daytrader;
+import java.io.Serializable;
import java.math.BigDecimal;
+import java.sql.Timestamp;
+import java.util.Collection;
import java.util.Date;
-import java.io.Serializable;
-
-import org.apache.geronimo.samples.daytrader.util.*;
-
-public class AccountDataBean implements Serializable
-{
-
- /* Accessor methods for persistent fields */
- private Integer accountID; /* accountID */
- private int loginCount; /* loginCount */
- private int logoutCount; /* logoutCount */
- private Date lastLogin; /* lastLogin Date */
- private Date creationDate; /* creationDate */
- private BigDecimal balance; /* balance */
- private BigDecimal openBalance; /* open balance */
-
- /* Accessor methods for relationship fields are only included for the AccountProfile profileID */
-
- private String profileID;
- public AccountDataBean(){ }
- public AccountDataBean(Integer accountID,
- int loginCount,
- int logoutCount,
- Date lastLogin,
- Date creationDate,
- BigDecimal balance,
- BigDecimal openBalance,
- String profileID)
- {
- setAccountID(accountID);
- setLoginCount(loginCount);
- setLogoutCount(logoutCount);
- setLastLogin(lastLogin);
- setCreationDate(creationDate);
- setBalance(balance);
- setOpenBalance(openBalance);
- setProfileID(profileID);
}
-
- public static AccountDataBean getRandomInstance() {
- return new AccountDataBean(new Integer(TradeConfig.rndInt(100000)), //accountID
- TradeConfig.rndInt(10000), //loginCount
- TradeConfig.rndInt(10000), //logoutCount
- new java.util.Date(), //lastLogin
- new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)), //creationDate
- TradeConfig.rndBigDecimal(1000000.0f), //balance
- TradeConfig.rndBigDecimal(1000000.0f), //openBalance
- TradeConfig.rndUserID() //profileID
- );
- }
-
- public String toString()
- {
- return "\n\tAccount Data for account: " + getAccountID()
- + "\n\t\t loginCount:" + getLoginCount()
- + "\n\t\t logoutCount:" + getLogoutCount()
- + "\n\t\t lastLogin:" + getLastLogin()
- + "\n\t\t creationDate:" + getCreationDate()
- + "\n\t\t balance:" + getBalance()
- + "\n\t\t openBalance:" + getOpenBalance()
- + "\n\t\t profileID:" + getProfileID()
- ;
- }
- public String toHTML()
- {
- return "<BR>Account Data for account: <B>" + getAccountID() + "</B>"
- + "<LI> loginCount:" + getLoginCount() + "</LI>"
- + "<LI> logoutCount:" + getLogoutCount() + "</LI>"
- + "<LI> lastLogin:" + getLastLogin() + "</LI>"
- + "<LI> creationDate:" + getCreationDate() + "</LI>"
- + "<LI> balance:" + getBalance() + "</LI>"
- + "<LI> openBalance:" + getOpenBalance() + "</LI>"
- + "<LI> profileID:" + getProfileID() + "</LI>"
- ;
- }
- public void print()
- {
- Log.log( this.toString() );
- }
-
- /**
- * Gets the accountID
- * @return Returns a Integer
- */
- public Integer getAccountID() {
- return accountID;
- }
- /**
- * Sets the accountID
- * @param accountID The accountID to set
- */
- public void setAccountID(Integer accountID)
- {
- this.accountID = accountID;
- }
-
/**
- * Gets the loginCount
- * @return Returns a int
- */
- public int getLoginCount() {
- return loginCount;
- }
- /**
- * Sets the loginCount
- * @param loginCount The loginCount to set
- */
- public void setLoginCount(int loginCount)
- {
- this.loginCount = loginCount;
- }
-
- /**
- * Gets the logoutCount
- * @return Returns a int
- */
- public int getLogoutCount() {
- return logoutCount;
- }
- /**
- * Sets the logoutCount
- * @param logoutCount The logoutCount to set
- */
- public void setLogoutCount(int logoutCount)
- {
- this.logoutCount = logoutCount;
- }
-
- /**
- * Gets the lastLogin
- * @return Returns a Date
- */
- public Date getLastLogin() {
- return lastLogin;
- }
- /**
- * Sets the lastLogin
- * @param lastLogin The lastLogin to set
- */
- public void setLastLogin(Date lastLogin)
- {
- this.lastLogin = lastLogin;
- }
-
- /**
- * Gets the creationDate
- * @return Returns a Date
- */
- public Date getCreationDate() {
- return creationDate;
- }
- /**
- * Sets the creationDate
- * @param creationDate The creationDate to set
- */
- public void setCreationDate(Date creationDate)
- {
- this.creationDate = creationDate;
- }
-
- /**
- * Gets the balance
- * @return Returns a BigDecimal
- */
- public BigDecimal getBalance() {
- return balance;
- }
- /**
- * Sets the balance
- * @param balance The balance to set
- */
- public void setBalance(BigDecimal balance)
- {
- this.balance = balance;
- }
-
- /**
- * Gets the openBalance
- * @return Returns a BigDecimal
- */
- public BigDecimal getOpenBalance() {
- return openBalance;
- }
- /**
- * Sets the openBalance
- * @param openBalance The openBalance to set
- */
- public void setOpenBalance(BigDecimal openBalance)
- {
- this.openBalance = openBalance;
- }
-
- /**
- * Gets the profileID
- * @return Returns a String
- */
- public String getProfileID() {
- return profileID;
- }
- /**
- * Sets the profileID
- * @param profileID The profileID to set
- */
- public void setProfileID(String profileID) {
- this.profileID = profileID;
- }
-
/**
- * Gets the profileID
- * @return Returns a String
- */
- /* Disabled for D185273
- public String getUserID() {
- return getProfileID();
- }
- */
+import javax.ejb.EJBException;
+import javax.persistence.CascadeType;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToMany;
+import javax.persistence.OneToOne;
+import javax.persistence.Version;
+import javax.persistence.Table;
+import javax.persistence.JoinColumn;
+import javax.persistence.Column;
+
+import org.apache.geronimo.samples.daytrader.util.Log;
+
+@Entity(name = "accountejb")
+@Table(name = "accountejb")
+public class AccountDataBean implements Serializable {
+
+ /* Accessor methods for persistent fields */
+ @Id
+ @GeneratedValue
+ private Integer accountID; /* accountID */
+ private int loginCount; /* loginCount */
+ private int logoutCount; /* logoutCount */
+ private Date lastLogin; /* lastLogin Date */
+ private Date creationDate; /* creationDate */
+ private BigDecimal balance; /* balance */
+ private BigDecimal openBalance; /* open balance */
+ @OneToMany(mappedBy = "account", cascade = CascadeType.ALL)
+ private Collection<OrderDataBean> orders;
+ @OneToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "PROFILE_USERID", referencedColumnName = "userID")
+ @Column(length = 250)
+ private AccountProfileDataBean profile;
+ @Version
+ private Integer optLock;
+
+ /* Accessor methods for relationship fields are only included for the AccountProfile profileID */
+
+ private String profileID;
+
+ public AccountDataBean() {
+ }
+
+ public AccountDataBean(Integer accountID,
+ int loginCount,
+ int logoutCount,
+ Date lastLogin,
+ Date creationDate,
+ BigDecimal balance,
+ BigDecimal openBalance,
+ String profileID) {
+ setAccountID(accountID);
+ setLoginCount(loginCount);
+ setLogoutCount(logoutCount);
+ setLastLogin(lastLogin);
+ setCreationDate(creationDate);
+ setBalance(balance);
+ setOpenBalance(openBalance);
+ setProfileID(profileID);
+ }
+
+ public AccountDataBean(int loginCount,
+ int logoutCount,
+ Date lastLogin,
+ Date creationDate,
+ BigDecimal balance,
+ BigDecimal openBalance,
+ String profileID) {
+ setLoginCount(loginCount);
+ setLogoutCount(logoutCount);
+ setLastLogin(lastLogin);
+ setCreationDate(creationDate);
+ setBalance(balance);
+ setOpenBalance(openBalance);
+ setProfileID(profileID);
+ }
+
+ public static AccountDataBean getRandomInstance() {
+ return new AccountDataBean(new Integer(TradeConfig.rndInt(100000)), //accountID
+ TradeConfig.rndInt(10000), //loginCount
+ TradeConfig.rndInt(10000), //logoutCount
+ new java.util.Date(), //lastLogin
+ new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)), //creationDate
+ TradeConfig.rndBigDecimal(1000000.0f), //balance
+ TradeConfig.rndBigDecimal(1000000.0f), //openBalance
+ TradeConfig.rndUserID() //profileID
+ );
+ }
+
+ public String toString() {
+ return "\n\tAccount Data for account: " + getAccountID()
+ + "\n\t\t loginCount:" + getLoginCount()
+ + "\n\t\t logoutCount:" + getLogoutCount()
+ + "\n\t\t lastLogin:" + getLastLogin()
+ + "\n\t\t creationDate:" + getCreationDate()
+ + "\n\t\t balance:" + getBalance()
+ + "\n\t\t openBalance:" + getOpenBalance()
+ + "\n\t\t profileID:" + getProfileID()
+ ;
+ }
+
+ public String toHTML() {
+ return "<BR>Account Data for account: <B>" + getAccountID() + "</B>"
+ + "<LI> loginCount:" + getLoginCount() + "</LI>"
+ + "<LI> logoutCount:" + getLogoutCount() + "</LI>"
+ + "<LI> lastLogin:" + getLastLogin() + "</LI>"
+ + "<LI> creationDate:" + getCreationDate() + "</LI>"
+ + "<LI> balance:" + getBalance() + "</LI>"
+ + "<LI> openBalance:" + getOpenBalance() + "</LI>"
+ + "<LI> profileID:" + getProfileID() + "</LI>"
+ ;
+ }
+
+ public void print() {
+ Log.log(this.toString());
+ }
+
+ /**
+ * Gets the accountID
+ *
+ * @return Returns a Integer
+ */
+ public Integer getAccountID() {
+ return accountID;
+ }
+
+ /**
+ * Sets the accountID
+ *
+ * @param accountID The accountID to set
+ */
+ public void setAccountID(Integer accountID) {
+ this.accountID = accountID;
+ }
+
+ /**
+ * Gets the loginCount
+ *
+ * @return Returns a int
+ */
+ public int getLoginCount() {
+ return loginCount;
+ }
+
+ /**
+ * Sets the loginCount
+ *
+ * @param loginCount The loginCount to set
+ */
+ public void setLoginCount(int loginCount) {
+ this.loginCount = loginCount;
+ }
+
+ /**
+ * Gets the logoutCount
+ *
+ * @return Returns a int
+ */
+ public int getLogoutCount() {
+ return logoutCount;
+ }
+
+ /**
+ * Sets the logoutCount
+ *
+ * @param logoutCount The logoutCount to set
+ */
+ public void setLogoutCount(int logoutCount) {
+ this.logoutCount = logoutCount;
+ }
+
+ /**
+ * Gets the lastLogin
+ *
+ * @return Returns a Date
+ */
+ public Date getLastLogin() {
+ return lastLogin;
+ }
+
+ /**
+ * Sets the lastLogin
+ *
+ * @param lastLogin The lastLogin to set
+ */
+ public void setLastLogin(Date lastLogin) {
+ this.lastLogin = lastLogin;
+ }
+
+ /**
+ * Gets the creationDate
+ *
+ * @return Returns a Date
+ */
+ public Date getCreationDate() {
+ return creationDate;
+ }
+
+ /**
+ * Sets the creationDate
+ *
+ * @param creationDate The creationDate to set
+ */
+ public void setCreationDate(Date creationDate) {
+ this.creationDate = creationDate;
+ }
+
+ /**
+ * Gets the balance
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getBalance() {
+ return balance;
+ }
+
+ /**
+ * Sets the balance
+ *
+ * @param balance The balance to set
+ */
+ public void setBalance(BigDecimal balance) {
+ this.balance = balance;
+ }
+
+ /**
+ * Gets the openBalance
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getOpenBalance() {
+ return openBalance;
+ }
+
+ /**
+ * Sets the openBalance
+ *
+ * @param openBalance The openBalance to set
+ */
+ public void setOpenBalance(BigDecimal openBalance) {
+ this.openBalance = openBalance;
+ }
+
+ /**
+ * Gets the profileID
+ *
+ * @return Returns a String
+ */
+ public String getProfileID() {
+ return profileID;
+ }
+
+ /**
+ * Sets the profileID
+ *
+ * @param profileID The profileID to set
+ */
+ public void setProfileID(String profileID) {
+ this.profileID = profileID;
+ }
+
+ /**
+ * Gets the profileID
+ *
+ * @return Returns a String
+ */
+ /* Disabled for D185273
+ public String getUserID() {
+ return getProfileID();
+ }
+ */
+ public Collection<OrderDataBean> getOrders() {
+ return orders;
+ }
+
+ public void setOrders(Collection<OrderDataBean> orders) {
+ this.orders = orders;
+ }
+
+ public AccountProfileDataBean getProfile() {
+ return profile;
+ }
+
+ public void setProfile(AccountProfileDataBean profile) {
+ this.profile = profile;
+ }
+
+ public void login(String password) {
+ AccountProfileDataBean profile = getProfile();
+ if ((profile == null) || (profile.getPassword().equals(password) == false)) {
+ String error = "AccountBean:Login failure for account: " + getAccountID() +
+ ((profile == null) ? "null AccountProfile" :
+ "\n\tIncorrect password-->" + profile.getUserID() + ":" + profile.getPassword());
+ throw new EJBException(error);
+ }
+
+ setLastLogin(new Timestamp(System.currentTimeMillis()));
+ setLoginCount(getLoginCount() + 1);
+ }
+
+ public void logout() {
+ setLogoutCount(getLogoutCount() + 1);
+ }
}
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountProfileDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountProfileDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountProfileDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/AccountProfileDataBean.java Mon Oct 30 13:52:55 2006
@@ -17,167 +17,207 @@
package org.apache.geronimo.samples.daytrader;
-import org.apache.geronimo.samples.daytrader.util.*;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.OneToOne;
+import javax.persistence.Version;
+import javax.persistence.Table;
+import javax.persistence.Column;
+import org.apache.geronimo.samples.daytrader.util.Log;
+
+@Entity(name = "accountprofileejb")
+@Table(name = "accountprofileejb")
public class AccountProfileDataBean
- implements java.io.Serializable
-{
+ implements java.io.Serializable {
/* Accessor methods for persistent fields */
- private String userID; /* userID */
- private String password; /* password */
- private String fullName; /* fullName */
- private String address; /* address */
- private String email; /* email */
- private String creditCard; /* creditCard */
+ @Id
+ @GeneratedValue
+ @Column(length=250)
+ private String userID; /* userID */
+ @Column(length=250)
+ private String passwd; /* password */
+ @Column(length=250)
+ private String fullName; /* fullName */
+ @Column(length=250)
+ private String address; /* address */
+ @Column(length=250)
+ private String email; /* email */
+ @Column(length=250)
+ private String creditCard; /* creditCard */
+ @OneToOne
+ private AccountDataBean account;
+ @Version
+ private Integer optLock;
- public AccountProfileDataBean(){ }
- public AccountProfileDataBean(String userID,
- String password,
- String fullName,
- String address,
- String email,
- String creditCard)
- {
- setUserID(userID);
- setPassword(password);
- setFullName(fullName);
- setAddress(address);
- setEmail(email);
- setCreditCard(creditCard);
- }
-
- public static AccountProfileDataBean getRandomInstance() {
- return new AccountProfileDataBean(
- TradeConfig.rndUserID(), // userID
- TradeConfig.rndUserID(), // password
- TradeConfig.rndFullName(), // fullname
- TradeConfig.rndAddress(), // address
- TradeConfig.rndEmail(TradeConfig.rndUserID()), //email
- TradeConfig.rndCreditCard() // creditCard
- );
- }
-
- public String toString()
- {
- return "\n\tAccount Profile Data for userID:" + getUserID()
- + "\n\t\t password:" + getPassword()
- + "\n\t\t fullName:" + getFullName()
- + "\n\t\t address:" + getAddress()
- + "\n\t\t email:" + getEmail()
- + "\n\t\t creditCard:" + getCreditCard()
- ;
- }
- public String toHTML()
- {
- return "<BR>Account Profile Data for userID: <B>" + getUserID() + "</B>"
- + "<LI> password:" + getPassword() + "</LI>"
- + "<LI> fullName:" + getFullName() + "</LI>"
- + "<LI> address:" + getAddress() + "</LI>"
- + "<LI> email:" + getEmail() + "</LI>"
- + "<LI> creditCard:" + getCreditCard() + "</LI>"
- ;
- }
- public void print()
- {
- Log.log( this.toString() );
- }
-
- /**
- * Gets the userID
- * @return Returns a String
- */
- public String getUserID() {
- return userID;
- }
- /**
- * Sets the userID
- * @param userID The userID to set
- */
- public void setUserID(String userID)
- {
- this.userID = userID;
- }
-
- /**
- * Gets the password
- * @return Returns a String
- */
- public String getPassword() {
- return password;
- }
- /**
- * Sets the password
- * @param password The password to set
- */
- public void setPassword(String password)
- {
- this.password = password;
- }
-
- /**
- * Gets the fullName
- * @return Returns a String
- */
- public String getFullName() {
- return fullName;
- }
- /**
- * Sets the fullName
- * @param fullName The fullName to set
- */
- public void setFullName(String fullName)
- {
- this.fullName = fullName;
- }
-
- /**
- * Gets the address
- * @return Returns a String
- */
- public String getAddress() {
- return address;
- }
- /**
- * Sets the address
- * @param address The address to set
- */
- public void setAddress(String address)
- {
- this.address = address;
- }
-
- /**
- * Gets the email
- * @return Returns a String
- */
- public String getEmail() {
- return email;
- }
- /**
- * Sets the email
- * @param email The email to set
- */
- public void setEmail(String email)
- {
- this.email = email;
- }
-
- /**
- * Gets the creditCard
- * @return Returns a String
- */
- public String getCreditCard() {
- return creditCard;
- }
- /**
- * Sets the creditCard
- * @param creditCard The creditCard to set
- */
- public void setCreditCard(String creditCard)
- {
- this.creditCard = creditCard;
- }
+ public AccountProfileDataBean() {
+ }
+ public AccountProfileDataBean(String userID,
+ String password,
+ String fullName,
+ String address,
+ String email,
+ String creditCard) {
+ setUserID(userID);
+ setPassword(password);
+ setFullName(fullName);
+ setAddress(address);
+ setEmail(email);
+ setCreditCard(creditCard);
+ }
+
+ public static AccountProfileDataBean getRandomInstance() {
+ return new AccountProfileDataBean(
+ TradeConfig.rndUserID(), // userID
+ TradeConfig.rndUserID(), // passwd
+ TradeConfig.rndFullName(), // fullname
+ TradeConfig.rndAddress(), // address
+ TradeConfig.rndEmail(TradeConfig.rndUserID()), //email
+ TradeConfig.rndCreditCard() // creditCard
+ );
+ }
+
+ public String toString() {
+ return "\n\tAccount Profile Data for userID:" + getUserID()
+ + "\n\t\t passwd:" + getPassword()
+ + "\n\t\t fullName:" + getFullName()
+ + "\n\t\t address:" + getAddress()
+ + "\n\t\t email:" + getEmail()
+ + "\n\t\t creditCard:" + getCreditCard()
+ ;
+ }
+
+ public String toHTML() {
+ return "<BR>Account Profile Data for userID: <B>" + getUserID() + "</B>"
+ + "<LI> passwd:" + getPassword() + "</LI>"
+ + "<LI> fullName:" + getFullName() + "</LI>"
+ + "<LI> address:" + getAddress() + "</LI>"
+ + "<LI> email:" + getEmail() + "</LI>"
+ + "<LI> creditCard:" + getCreditCard() + "</LI>"
+ ;
+ }
+
+ public void print() {
+ Log.log(this.toString());
+ }
+
+ /**
+ * Gets the userID
+ *
+ * @return Returns a String
+ */
+ public String getUserID() {
+ return userID;
+ }
+
+ /**
+ * Sets the userID
+ *
+ * @param userID The userID to set
+ */
+ public void setUserID(String userID) {
+ this.userID = userID;
+ }
+
+ /**
+ * Gets the passwd
+ *
+ * @return Returns a String
+ */
+ public String getPassword() {
+ return passwd;
+ }
+
+ /**
+ * Sets the passwd
+ *
+ * @param password The passwd to set
+ */
+ public void setPassword(String password) {
+ this.passwd = password;
+ }
+
+ /**
+ * Gets the fullName
+ *
+ * @return Returns a String
+ */
+ public String getFullName() {
+ return fullName;
+ }
+
+ /**
+ * Sets the fullName
+ *
+ * @param fullName The fullName to set
+ */
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+ /**
+ * Gets the address
+ *
+ * @return Returns a String
+ */
+ public String getAddress() {
+ return address;
+ }
+
+ /**
+ * Sets the address
+ *
+ * @param address The address to set
+ */
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ /**
+ * Gets the email
+ *
+ * @return Returns a String
+ */
+ public String getEmail() {
+ return email;
+ }
+
+ /**
+ * Sets the email
+ *
+ * @param email The email to set
+ */
+ public void setEmail(String email) {
+ this.email = email;
+ }
+
+ /**
+ * Gets the creditCard
+ *
+ * @return Returns a String
+ */
+ public String getCreditCard() {
+ return creditCard;
+ }
+
+ /**
+ * Sets the creditCard
+ *
+ * @param creditCard The creditCard to set
+ */
+ public void setCreditCard(String creditCard) {
+ this.creditCard = creditCard;
+ }
+
+ public AccountDataBean getAccount() {
+ return account;
+ }
+
+ public void setAccount(AccountDataBean account) {
+ this.account = account;
+ }
}
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/HoldingDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/HoldingDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/HoldingDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/HoldingDataBean.java Mon Oct 30 13:52:55 2006
@@ -21,152 +21,220 @@
import java.math.BigDecimal;
import java.util.Date;
-import org.apache.geronimo.samples.daytrader.util.*;
-
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Version;
+import javax.persistence.Table;
+import javax.persistence.Column;
+
+import org.apache.geronimo.samples.daytrader.util.Log;
+
+@Entity(name = "holdingejb")
+@Table(name = "holdingejb")
+@NamedQueries({
+@NamedQuery(name = "holdingsByUserID",
+ query = "SELECT h FROM holdingejb h where h.account.profile.userID = :userID")
+ })
public class HoldingDataBean
- implements Serializable {
+ implements Serializable {
/* persistent/relationship fields */
- private Integer holdingID; /* holdingID */
- private double quantity; /* quantity */
- private BigDecimal purchasePrice; /* purchasePrice */
- private Date purchaseDate; /* purchaseDate */
- private String quoteID; /* Holding(*) ---> Quote(1) */
-
- public HoldingDataBean(){ }
- public HoldingDataBean(Integer holdingID,
- double quantity,
- BigDecimal purchasePrice,
- Date purchaseDate,
- String quoteID)
- {
- setHoldingID(holdingID);
- setQuantity(quantity);
- setPurchasePrice(purchasePrice);
- setPurchaseDate(purchaseDate);
- setQuoteID(quoteID);
- }
-
- public static HoldingDataBean getRandomInstance() {
- return new HoldingDataBean(
- new Integer(TradeConfig.rndInt(100000)), //holdingID
- TradeConfig.rndQuantity(), //quantity
- TradeConfig.rndBigDecimal(1000.0f), //purchasePrice
- new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)), //purchaseDate
- TradeConfig.rndSymbol() // symbol
- );
- }
-
- public String toString()
- {
- return "\n\tHolding Data for holding: " + getHoldingID()
- + "\n\t\t quantity:" + getQuantity()
- + "\n\t\t purchasePrice:" + getPurchasePrice()
- + "\n\t\t purchaseDate:" + getPurchaseDate()
- + "\n\t\t quoteID:" + getQuoteID()
- ;
- }
-
- public String toHTML()
- {
- return "<BR>Holding Data for holding: " + getHoldingID() + "</B>"
- + "<LI> quantity:" + getQuantity() + "</LI>"
- + "<LI> purchasePrice:" + getPurchasePrice() + "</LI>"
- + "<LI> purchaseDate:" + getPurchaseDate() + "</LI>"
- + "<LI> quoteID:" + getQuoteID() + "</LI>"
- ;
- }
- public void print()
- {
- Log.log( this.toString() );
- }
- /**
- * Gets the holdingID
- * @return Returns a Integer
- */
- public Integer getHoldingID() {
- return holdingID;
- }
- /**
- * Sets the holdingID
- * @param holdingID The holdingID to set
- */
- public void setHoldingID(Integer holdingID)
- {
- this.holdingID = holdingID;
- }
-
- /**
- * Gets the quantity
- * @return Returns a BigDecimal
- */
- public double getQuantity() {
- return quantity;
- }
- /**
- * Sets the quantity
- * @param quantity The quantity to set
- */
- public void setQuantity(double quantity)
- {
- this.quantity = quantity;
- }
-
- /**
- * Gets the purchasePrice
- * @return Returns a BigDecimal
- */
- public BigDecimal getPurchasePrice() {
- return purchasePrice;
- }
- /**
- * Sets the purchasePrice
- * @param purchasePrice The purchasePrice to set
- */
- public void setPurchasePrice(BigDecimal purchasePrice)
- {
- this.purchasePrice = purchasePrice;
- }
-
- /**
- * Gets the purchaseDate
- * @return Returns a Date
- */
- public Date getPurchaseDate() {
- return purchaseDate;
- }
- /**
- * Sets the purchaseDate
- * @param purchaseDate The purchaseDate to set
- */
- public void setPurchaseDate(Date purchaseDate)
- {
- this.purchaseDate = purchaseDate;
- }
-
- /**
- * Gets the quoteID
- * @return Returns a Integer
- */
- public String getQuoteID() {
- return quoteID;
- }
- /**
- * Sets the quoteID
- * @param quoteID The quoteID to set
- */
- public void setQuoteID(String quoteID)
- {
- this.quoteID = quoteID;
- }
- /**
- * Gets the quoteID
- * @return Returns a Integer
- */
- /* Disabled for D185273
- public String getSymbol() {
- return getQuoteID();
- }
- */
+ @Id
+ @GeneratedValue
+ private Integer holdingID; /* holdingID */
+ private double quantity; /* quantity */
+ private BigDecimal purchasePrice; /* purchasePrice */
+ private Date purchaseDate; /* purchaseDate */
+ @Column(length = 250)
+ private String quoteID; /* Holding(*) ---> Quote(1) */
+ @OneToOne
+ private AccountDataBean account;
+ @OneToOne
+ private QuoteDataBean quote;
+
+ @Version
+ private Integer optLock;
+
+ public HoldingDataBean() {
+ }
+
+ public HoldingDataBean(Integer holdingID,
+ double quantity,
+ BigDecimal purchasePrice,
+ Date purchaseDate,
+ String quoteID) {
+ setHoldingID(holdingID);
+ setQuantity(quantity);
+ setPurchasePrice(purchasePrice);
+ setPurchaseDate(purchaseDate);
+ setQuoteID(quoteID);
+ }
+
+ public HoldingDataBean(double quantity,
+ BigDecimal purchasePrice,
+ Date purchaseDate,
+ AccountDataBean account,
+ QuoteDataBean quote) {
+ setQuantity(quantity);
+ setPurchasePrice(purchasePrice);
+ setPurchaseDate(purchaseDate);
+ setAccount(account);
+ setQuote(quote);
+ }
+
+ public static HoldingDataBean getRandomInstance() {
+ return new HoldingDataBean(
+ new Integer(TradeConfig.rndInt(100000)), //holdingID
+ TradeConfig.rndQuantity(), //quantity
+ TradeConfig.rndBigDecimal(1000.0f), //purchasePrice
+ new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)), //purchaseDate
+ TradeConfig.rndSymbol() // symbol
+ );
+ }
+
+ public String toString() {
+ return "\n\tHolding Data for holding: " + getHoldingID()
+ + "\n\t\t quantity:" + getQuantity()
+ + "\n\t\t purchasePrice:" + getPurchasePrice()
+ + "\n\t\t purchaseDate:" + getPurchaseDate()
+ + "\n\t\t quoteID:" + getQuoteID()
+ ;
+ }
+
+ public String toHTML() {
+ return "<BR>Holding Data for holding: " + getHoldingID() + "</B>"
+ + "<LI> quantity:" + getQuantity() + "</LI>"
+ + "<LI> purchasePrice:" + getPurchasePrice() + "</LI>"
+ + "<LI> purchaseDate:" + getPurchaseDate() + "</LI>"
+ + "<LI> quoteID:" + getQuoteID() + "</LI>"
+ ;
+ }
+
+ public void print() {
+ Log.log(this.toString());
+ }
+
+ /**
+ * Gets the holdingID
+ *
+ * @return Returns a Integer
+ */
+ public Integer getHoldingID() {
+ return holdingID;
+ }
+
+ /**
+ * Sets the holdingID
+ *
+ * @param holdingID The holdingID to set
+ */
+ public void setHoldingID(Integer holdingID) {
+ this.holdingID = holdingID;
+ }
+
+ /**
+ * Gets the quantity
+ *
+ * @return Returns a BigDecimal
+ */
+ public double getQuantity() {
+ return quantity;
+ }
+
+ /**
+ * Sets the quantity
+ *
+ * @param quantity The quantity to set
+ */
+ public void setQuantity(double quantity) {
+ this.quantity = quantity;
+ }
+
+ /**
+ * Gets the purchasePrice
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getPurchasePrice() {
+ return purchasePrice;
+ }
+
+ /**
+ * Sets the purchasePrice
+ *
+ * @param purchasePrice The purchasePrice to set
+ */
+ public void setPurchasePrice(BigDecimal purchasePrice) {
+ this.purchasePrice = purchasePrice;
+ }
+
+ /**
+ * Gets the purchaseDate
+ *
+ * @return Returns a Date
+ */
+ public Date getPurchaseDate() {
+ return purchaseDate;
+ }
+
+ /**
+ * Sets the purchaseDate
+ *
+ * @param purchaseDate The purchaseDate to set
+ */
+ public void setPurchaseDate(Date purchaseDate) {
+ this.purchaseDate = purchaseDate;
+ }
+
+ /**
+ * Gets the quoteID
+ *
+ * @return Returns symbol for associated quote
+ */
+ public String getQuoteID() {
+ if (quote != null) {
+ return quote.getSymbol();
+ }
+ return quoteID;
+ }
+
+ /**
+ * Sets the quoteID
+ *
+ * @param quoteID The quoteID to set
+ */
+ public void setQuoteID(String quoteID) {
+ this.quoteID = quoteID;
+ }
+
+ public AccountDataBean getAccount() {
+ return account;
+ }
+
+ public void setAccount(AccountDataBean account) {
+ this.account = account;
+ }
+
+ /**
+ * Gets the quoteID
+ *
+ * @return Returns a Integer
+ */
+ /* Disabled for D185273
+ public String getSymbol() {
+ return getQuoteID();
+ }
+ */
+ public QuoteDataBean getQuote() {
+ return quote;
+ }
+
+ public void setQuote(QuoteDataBean quote) {
+ this.quote = quote;
+ }
}
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBean.java Mon Oct 30 13:52:55 2006
@@ -17,15 +17,20 @@
package org.apache.geronimo.samples.daytrader;
-import java.util.*;
-import java.math.BigDecimal;
import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
-import org.apache.geronimo.samples.daytrader.util.*;
+import org.apache.geronimo.samples.daytrader.util.FinancialUtils;
+import org.apache.geronimo.samples.daytrader.util.Log;
public class MarketSummaryDataBean implements Serializable
{
-
private BigDecimal TSIA; /* Trade Stock Index Average */
+
+ private BigDecimal TSIA; /* Trade Stock Index Average */
private BigDecimal openTSIA; /* Trade Stock Index Average at the open */
private double volume; /* volume of shares traded */
private Collection topGainers; /* Collection of top gaining stocks */
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBeanWS.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBeanWS.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBeanWS.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/MarketSummaryDataBeanWS.java Mon Oct 30 13:52:55 2006
@@ -17,12 +17,13 @@
package org.apache.geronimo.samples.daytrader;
-import java.util.Collection;
+import java.io.Serializable;
import java.math.BigDecimal;
+import java.util.Collection;
import java.util.Date;
-import java.io.Serializable;
-import org.apache.geronimo.samples.daytrader.util.*;
+import org.apache.geronimo.samples.daytrader.util.FinancialUtils;
+import org.apache.geronimo.samples.daytrader.util.Log;
/**
*
@@ -33,7 +34,8 @@
*/
public class MarketSummaryDataBeanWS implements Serializable
{
-
private BigDecimal TSIA; /* Trade Stock Index Average */
+
+ private BigDecimal TSIA; /* Trade Stock Index Average */
private BigDecimal openTSIA; /* Trade Stock Index Average at the open */
private double volume; /* volume of shares traded */
private QuoteDataBean topGainers[]; /* Collection of top gaining stocks */
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/OrderDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/OrderDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/OrderDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/OrderDataBean.java Mon Oct 30 13:52:55 2006
@@ -18,245 +18,374 @@
package org.apache.geronimo.samples.daytrader;
+import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
-import java.io.Serializable;
-
-import org.apache.geronimo.samples.daytrader.util.*;
-
-
-public class OrderDataBean implements Serializable
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Version;
+import javax.persistence.Table;
+import javax.persistence.Column;
+
+import org.apache.geronimo.samples.daytrader.util.Log;
+
+
+@Entity(name="orderejb")
+@Table(name = "orderejb")
+@NamedQueries({
+ @NamedQuery(name="closedOrders",
+ query="SELECT o FROM orderejb o WHERE " +
+ " o.orderStatus = 'closed' AND " +
+ " o.account.profile.userID = :userID"),
+ @NamedQuery(name="completeClosedOrders",
+ query="UPDATE orderejb o SET o.orderStatus = completed' WHERE " +
+ " o.orderStatus = 'closed' AND " +
+ " o.account.profile.userID = :userID")
+ })
+public class OrderDataBean implements Serializable
{
-
+
+ @Id
+ @GeneratedValue
private Integer orderID; /* orderID */
- private String orderType; /* orderType (buy, sell, etc.) */
- private String orderStatus; /* orderStatus (open, processing, completed, closed, cancelled) */
- private Date openDate; /* openDate (when the order was entered) */
- private Date completionDate; /* completionDate */
- private double quantity; /* quantity */
- private BigDecimal price; /* price */
- private BigDecimal orderFee; /* price */
+ @Column(length=250)
+ private String orderType; /* orderType (buy, sell, etc.) */
+ @Column(length=250)
+ private String orderStatus; /* orderStatus (open, processing, completed, closed, cancelled) */
+ private Date openDate; /* openDate (when the order was entered) */
+ private Date completionDate; /* completionDate */
+ private double quantity; /* quantity */
+ private BigDecimal price; /* price */
+ private BigDecimal orderFee; /* price */
+ @ManyToOne
+ private AccountDataBean account;
+ @OneToOne
+ private QuoteDataBean quote;
+ @OneToOne
+ private HoldingDataBean holding;
+ @Version
+ private Integer optLock;
/* Fields for relationship fields are not kept in the Data Bean */
- private String symbol;
-
- public OrderDataBean() {}
- /**
- * OrderDataBean
- * @construct an OrderDataBean
- */
- public OrderDataBean(Integer orderID,
- String orderType,
- String orderStatus,
- Date openDate,
- Date completionDate,
- double quantity,
- BigDecimal price,
- BigDecimal orderFee,
- String symbol
- )
- {
- setOrderID(orderID);
- setOrderType(orderType);
- setOrderStatus(orderStatus);
- setOpenDate(openDate);
- setCompletionDate(completionDate);
- setQuantity(quantity);
- setPrice(price);
- setOrderFee(orderFee);
- setSymbol(symbol);
- }
-
- public static OrderDataBean getRandomInstance() {
- return new OrderDataBean(
- new Integer(TradeConfig.rndInt(100000)),
- TradeConfig.rndBoolean() ? "buy" : "sell",
- "open",
- new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)),
- new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)),
- TradeConfig.rndQuantity(),
- TradeConfig.rndBigDecimal(1000.0f),
- TradeConfig.rndBigDecimal(1000.0f),
- TradeConfig.rndSymbol()
- );
- }
-
- public String toString()
- {
- return "Order " + getOrderID()
- + "\n\t orderType: " + getOrderType()
- + "\n\t orderStatus: " + getOrderStatus()
- + "\n\t openDate: " + getOpenDate()
- + "\n\t completionDate: " + getCompletionDate()
- + "\n\t quantity: " + getQuantity()
- + "\n\t price: " + getPrice()
- + "\n\t orderFee: " + getOrderFee()
- + "\n\t symbol: " + getSymbol()
- ;
- }
- public String toHTML()
- {
- return "<BR>Order <B>" + getOrderID() + "</B>"
- + "<LI> orderType: " + getOrderType() + "</LI>"
- + "<LI> orderStatus: " + getOrderStatus() + "</LI>"
- + "<LI> openDate: " + getOpenDate() + "</LI>"
- + "<LI> completionDate: " + getCompletionDate() + "</LI>"
- + "<LI> quantity: " + getQuantity() + "</LI>"
- + "<LI> price: " + getPrice() + "</LI>"
- + "<LI> orderFee: " + getOrderFee() + "</LI>"
- + "<LI> symbol: " + getSymbol() + "</LI>"
- ;
- }
-
- public void print()
- {
- Log.log( this.toString() );
- }
-
- /**
- * Gets the orderID
- * @return Returns a Integer
- */
- public Integer getOrderID() {
- return orderID;
- }
- /**
- * Sets the orderID
- * @param orderID The orderID to set
- */
- public void setOrderID(Integer orderID) {
- this.orderID = orderID;
- }
+ private String symbol;
+ public OrderDataBean() {}
+ /**
+ * OrderDataBean
+ */
+ public OrderDataBean(Integer orderID,
+ String orderType,
+ String orderStatus,
+ Date openDate,
+ Date completionDate,
+ double quantity,
+ BigDecimal price,
+ BigDecimal orderFee,
+ String symbol
+ )
+ {
+ setOrderID(orderID);
+ setOrderType(orderType);
+ setOrderStatus(orderStatus);
+ setOpenDate(openDate);
+ setCompletionDate(completionDate);
+ setQuantity(quantity);
+ setPrice(price);
+ setOrderFee(orderFee);
+ setSymbol(symbol);
+ }
+ public OrderDataBean(String orderType,
+ String orderStatus,
+ Date openDate,
+ Date completionDate,
+ double quantity,
+ BigDecimal price,
+ BigDecimal orderFee,
+ AccountDataBean account,
+ QuoteDataBean quote, HoldingDataBean holding)
+ {
+ setOrderType(orderType);
+ setOrderStatus(orderStatus);
+ setOpenDate(openDate);
+ setCompletionDate(completionDate);
+ setQuantity(quantity);
+ setPrice(price);
+ setOrderFee(orderFee);
+ setAccount(account);
+ setQuote(quote);
+ setHolding(holding);
+ }
+
+ public static OrderDataBean getRandomInstance() {
+ return new OrderDataBean(
+ new Integer(TradeConfig.rndInt(100000)),
+ TradeConfig.rndBoolean() ? "buy" : "sell",
+ "open",
+ new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)),
+ new java.util.Date(TradeConfig.rndInt(Integer.MAX_VALUE)),
+ TradeConfig.rndQuantity(),
+ TradeConfig.rndBigDecimal(1000.0f),
+ TradeConfig.rndBigDecimal(1000.0f),
+ TradeConfig.rndSymbol()
+ );
+ }
+
+ public String toString()
+ {
+ return "Order " + getOrderID()
+ + "\n\t orderType: " + getOrderType()
+ + "\n\t orderStatus: " + getOrderStatus()
+ + "\n\t openDate: " + getOpenDate()
+ + "\n\t completionDate: " + getCompletionDate()
+ + "\n\t quantity: " + getQuantity()
+ + "\n\t price: " + getPrice()
+ + "\n\t orderFee: " + getOrderFee()
+ + "\n\t symbol: " + getSymbol()
+ ;
+ }
+ public String toHTML()
+ {
+ return "<BR>Order <B>" + getOrderID() + "</B>"
+ + "<LI> orderType: " + getOrderType() + "</LI>"
+ + "<LI> orderStatus: " + getOrderStatus() + "</LI>"
+ + "<LI> openDate: " + getOpenDate() + "</LI>"
+ + "<LI> completionDate: " + getCompletionDate() + "</LI>"
+ + "<LI> quantity: " + getQuantity() + "</LI>"
+ + "<LI> price: " + getPrice() + "</LI>"
+ + "<LI> orderFee: " + getOrderFee() + "</LI>"
+ + "<LI> symbol: " + getSymbol() + "</LI>"
+ ;
+ }
+
+ public void print()
+ {
+ Log.log( this.toString() );
+ }
+
+ /**
+ * Gets the orderID
+ * @return Returns a Integer
+ */
+ public Integer getOrderID() {
+ return orderID;
+ }
+ /**
+ * Sets the orderID
+ * @param orderID The orderID to set
+ */
+ public void setOrderID(Integer orderID) {
+ this.orderID = orderID;
+ }
+
+
+ /**
+ * Gets the orderType
+ * @return Returns a String
+ */
+ public String getOrderType() {
+ return orderType;
+ }
+ /**
+ * Sets the orderType
+ * @param orderType The orderType to set
+ */
+ public void setOrderType(String orderType) {
+ this.orderType = orderType;
+ }
+
+
+ /**
+ * Gets the orderStatus
+ * @return Returns a String
+ */
+ public String getOrderStatus() {
+ return orderStatus;
+ }
+ /**
+ * Sets the orderStatus
+ * @param orderStatus The orderStatus to set
+ */
+ public void setOrderStatus(String orderStatus) {
+ this.orderStatus = orderStatus;
+ }
+
+
+ /**
+ * Gets the openDate
+ * @return Returns a Date
+ */
+ public Date getOpenDate() {
+ return openDate;
+ }
+ /**
+ * Sets the openDate
+ * @param openDate The openDate to set
+ */
+ public void setOpenDate(Date openDate) {
+ this.openDate = openDate;
+ }
+
+
+ /**
+ * Gets the completionDate
+ * @return Returns a Date
+ */
+ public Date getCompletionDate() {
+ return completionDate;
+ }
+ /**
+ * Sets the completionDate
+ * @param completionDate The completionDate to set
+ */
+ public void setCompletionDate(Date completionDate) {
+ this.completionDate = completionDate;
+ }
+
+
+ /**
+ * Gets the quantity
+ * @return Returns a BigDecimal
+ */
+ public double getQuantity() {
+ return quantity;
+ }
+ /**
+ * Sets the quantity
+ * @param quantity The quantity to set
+ */
+ public void setQuantity(double quantity) {
+ this.quantity = quantity;
+ }
+
+
+ /**
+ * Gets the price
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getPrice() {
+ return price;
+ }
+ /**
+ * Sets the price
+ * @param price The price to set
+ */
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+
+ /**
+ * Gets the orderFee
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getOrderFee() {
+ return orderFee;
+ }
+ /**
+ * Sets the orderFee
+ * @param orderFee The orderFee to set
+ */
+ public void setOrderFee(BigDecimal orderFee) {
+ this.orderFee = orderFee;
+ }
+
+ /**
+ * Gets the symbol
+ * @return Returns a String
+ */
+ public String getSymbol() {
+ if (quote != null) {
+ return quote.getSymbol();
+ }
+ return symbol;
+ }
+ /**
+ * Sets the symbol
+ * @param symbol The symbol to set
+ */
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ public AccountDataBean getAccount() {
+ return account;
+ }
+
+ public void setAccount(AccountDataBean account) {
+ this.account = account;
+ }
+
+ public QuoteDataBean getQuote() {
+ return quote;
+ }
+
+ public void setQuote(QuoteDataBean quote) {
+ this.quote = quote;
+ }
+
+ public HoldingDataBean getHolding() {
+ return holding;
+ }
+
+ public void setHolding(HoldingDataBean holding) {
+ this.holding = holding;
+ }
+
+ public boolean isBuy()
+ {
+ String orderType = getOrderType();
+ if ( orderType.compareToIgnoreCase("buy") == 0 )
+ return true;
+ return false;
+ }
+
+ public boolean isSell()
+ {
+ String orderType = getOrderType();
+ if ( orderType.compareToIgnoreCase("sell") == 0 )
+ return true;
+ return false;
+ }
+
+ public boolean isOpen()
+ {
+ String orderStatus = getOrderStatus();
+ if ( (orderStatus.compareToIgnoreCase("open") == 0) ||
+ (orderStatus.compareToIgnoreCase("processing") == 0) )
+ return true;
+ return false;
+ }
+
+ public boolean isCompleted()
+ {
+ String orderStatus = getOrderStatus();
+ if ( (orderStatus.compareToIgnoreCase("completed") == 0) ||
+ (orderStatus.compareToIgnoreCase("alertcompleted") == 0) ||
+ (orderStatus.compareToIgnoreCase("cancelled") == 0) )
+ return true;
+ return false;
+ }
+
+ public boolean isCancelled()
+ {
+ String orderStatus = getOrderStatus();
+ if (orderStatus.compareToIgnoreCase("cancelled") == 0)
+ return true;
+ return false;
+ }
- /**
- * Gets the orderType
- * @return Returns a String
- */
- public String getOrderType() {
- return orderType;
- }
- /**
- * Sets the orderType
- * @param orderType The orderType to set
- */
- public void setOrderType(String orderType) {
- this.orderType = orderType;
- }
-
-
- /**
- * Gets the orderStatus
- * @return Returns a String
- */
- public String getOrderStatus() {
- return orderStatus;
- }
- /**
- * Sets the orderStatus
- * @param orderStatus The orderStatus to set
- */
- public void setOrderStatus(String orderStatus) {
- this.orderStatus = orderStatus;
- }
-
- /**
- * Gets the openDate
- * @return Returns a Date
- */
- public Date getOpenDate() {
- return openDate;
- }
- /**
- * Sets the openDate
- * @param openDate The openDate to set
- */
- public void setOpenDate(Date openDate) {
- this.openDate = openDate;
- }
-
-
- /**
- * Gets the completionDate
- * @return Returns a Date
- */
- public Date getCompletionDate() {
- return completionDate;
- }
- /**
- * Sets the completionDate
- * @param completionDate The completionDate to set
- */
- public void setCompletionDate(Date completionDate) {
- this.completionDate = completionDate;
- }
-
-
- /**
- * Gets the quantity
- * @return Returns a BigDecimal
- */
- public double getQuantity() {
- return quantity;
- }
- /**
- * Sets the quantity
- * @param quantity The quantity to set
- */
- public void setQuantity(double quantity) {
- this.quantity = quantity;
- }
-
-
- /**
- * Gets the price
- * @return Returns a BigDecimal
- */
- public BigDecimal getPrice() {
- return price;
- }
- /**
- * Sets the price
- * @param price The price to set
- */
- public void setPrice(BigDecimal price) {
- this.price = price;
- }
-
-
- /**
- * Gets the orderFee
- * @return Returns a BigDecimal
- */
- public BigDecimal getOrderFee() {
- return orderFee;
- }
- /**
- * Sets the orderFee
- * @param orderFee The orderFee to set
- */
- public void setOrderFee(BigDecimal orderFee) {
- this.orderFee = orderFee;
- }
-
- /**
- * Gets the symbol
- * @return Returns a String
- */
- public String getSymbol() {
- return symbol;
- }
- /**
- * Sets the symbol
- * @param symbol The symbol to set
- */
- public void setSymbol(String symbol) {
- this.symbol = symbol;
+ public void cancel()
+ {
+ setOrderStatus("cancelled");
}
-
}
Modified: geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/QuoteDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/QuoteDataBean.java?view=diff&rev=469284&r1=469283&r2=469284
==============================================================================
--- geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/QuoteDataBean.java (original)
+++ geronimo/daytrader/trunk/modules/ejb/src/main/java/org/apache/geronimo/samples/daytrader/QuoteDataBean.java Mon Oct 30 13:52:55 2006
@@ -17,224 +17,251 @@
package org.apache.geronimo.samples.daytrader;
-import java.math.BigDecimal;
import java.io.Serializable;
+import java.math.BigDecimal;
-import org.apache.geronimo.samples.daytrader.util.*;
-
-public class QuoteDataBean implements Serializable
-{
-
- /* Accessor methods for persistent fields */
-
- private String symbol; /* symbol */
- private String companyName; /* companyName */
- private double volume; /* volume */
- private BigDecimal price; /* price */
- private BigDecimal open; /* open price */
- private BigDecimal low; /* low price */
- private BigDecimal high; /* high price */
- private double change; /* price change */
-
- /* Accessor methods for relationship fields are not kept in the DataBean */
- public QuoteDataBean(){ }
-
- public QuoteDataBean(String symbol, String companyName, double volume,
- BigDecimal price, BigDecimal open, BigDecimal low,
- BigDecimal high, double change)
- {
- setSymbol(symbol);
- setCompanyName(companyName);
- setVolume(volume);
- setPrice(price);
- setOpen(open);
- setLow(low);
- setHigh(high);
- setChange(change);
- }
-
- public static QuoteDataBean getRandomInstance() {
- return new QuoteDataBean(
- TradeConfig.rndSymbol(), //symbol
- TradeConfig.rndSymbol() + " Incorporated", //Company Name
- TradeConfig.rndFloat(100000), //volume
- TradeConfig.rndBigDecimal(1000.0f), //price
- TradeConfig.rndBigDecimal(1000.0f), //open
- TradeConfig.rndBigDecimal(1000.0f), //low
- TradeConfig.rndBigDecimal(1000.0f), //high
- TradeConfig.rndFloat(100000) //volume
- );
- }
-
- //Create a "zero" value quoteDataBean for the given symbol
- public QuoteDataBean(String symbol)
- {
- setSymbol(symbol);
- }
-
-
- public String toString()
- {
- return "\n\tQuote Data for: " + getSymbol()
- + "\n\t\t companyName: " + getCompanyName()
- + "\n\t\t volume: " + getVolume()
- + "\n\t\t price: " + getPrice()
- + "\n\t\t open: " + getOpen()
- + "\n\t\t low: " + getLow()
- + "\n\t\t high: " + getHigh()
- + "\n\t\t change: " + getChange()
- ;
- }
-
- public String toHTML()
- {
- return "<BR>Quote Data for: " + getSymbol()
- + "<LI> companyName: " + getCompanyName() + "</LI>"
- + "<LI> volume: " + getVolume()+ "</LI>"
- + "<LI> price: " + getPrice()+ "</LI>"
- + "<LI> open: " + getOpen()+ "</LI>"
- + "<LI> low: " + getLow()+ "</LI>"
- + "<LI> high: " + getHigh()+ "</LI>"
- + "<LI> change: " + getChange()+ "</LI>"
- ;
- }
- public void print()
- {
- Log.log( this.toString() );
- }
-
- /**
- * Gets the symbol
- * @return Returns a String
- */
- public String getSymbol()
- {
- return symbol;
- }
- /**
- * Sets the symbol
- * @param symbol The symbol to set
- */
- public void setSymbol(String symbol)
- {
- this.symbol = symbol;
- }
-
- /**
- * Gets the companyName
- * @return Returns a String
- */
- public String getCompanyName()
- {
- return companyName;
- }
- /**
- * Sets the companyName
- * @param companyName The companyName to set
- */
- public void setCompanyName(String companyName)
- {
- this.companyName = companyName;
- }
-
- /**
- * Gets the price
- * @return Returns a BigDecimal
- */
- public BigDecimal getPrice()
- {
- return price;
- }
- /**
- * Sets the price
- * @param price The price to set
- */
- public void setPrice(BigDecimal price)
- {
- this.price = price;
- }
-
- /**
- * Gets the open
- * @return Returns a BigDecimal
- */
- public BigDecimal getOpen()
- {
- return open;
- }
- /**
- * Sets the open
- * @param open The open to set
- */
- public void setOpen(BigDecimal open)
- {
- this.open = open;
- }
-
- /**
- * Gets the low
- * @return Returns a BigDecimal
- */
- public BigDecimal getLow()
- {
- return low;
- }
- /**
- * Sets the low
- * @param low The low to set
- */
- public void setLow(BigDecimal low)
- {
- this.low = low;
- }
-
- /**
- * Gets the high
- * @return Returns a BigDecimal
- */
- public BigDecimal getHigh()
- {
- return high;
- }
- /**
- * Sets the high
- * @param high The high to set
- */
- public void setHigh(BigDecimal high)
- {
- this.high = high;
- }
-
- /**
- * Gets the change
- * @return Returns a double
- */
- public double getChange()
- {
- return change;
- }
- /**
- * Sets the change
- * @param change The change to set
- */
- public void setChange(double change)
- {
- this.change = change;
- }
-
- /**
- * Gets the volume
- * @return Returns a BigDecimal
- */
- public double getVolume() {
- return volume;
- }
- /**
- * Sets the volume
- * @param volume The volume to set
- */
- public void setVolume(double volume) {
- this.volume = volume;
- }
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.NamedQueries;
+import javax.persistence.NamedQuery;
+import javax.persistence.Version;
+import javax.persistence.Table;
+import javax.persistence.Column;
+
+import org.apache.geronimo.samples.daytrader.util.Log;
+
+@Entity(name = "quoteejb")
+@Table(name = "quoteejb")
+@NamedQueries({
+@NamedQuery(name = "allQuotes",
+ query = "SELECT q FROM quoteejb q"),
+@NamedQuery(name = "quotesByChange",
+ query = "SELECT q FROM quoteejb q WHERE q.symbol LIKE 's:1__' ORDER BY q.change1 DESC")
+ })
+public class QuoteDataBean implements Serializable {
+
+ /* Accessor methods for persistent fields */
+
+ @Id
+ @Column(length = 250)
+ private String symbol; /* symbol */
+ @Column(length = 250)
+ private String companyName; /* companyName */
+ private double volume; /* volume */
+ private BigDecimal price; /* price */
+ private BigDecimal open1; /* open1 price */
+ private BigDecimal low; /* low price */
+ private BigDecimal high; /* high price */
+ private double change1; /* price change */
+ @Version
+ private Integer optLock;
+
+ /* Accessor methods for relationship fields are not kept in the DataBean */
+ public QuoteDataBean() {
+ }
+
+ public QuoteDataBean(String symbol, String companyName, double volume,
+ BigDecimal price, BigDecimal open, BigDecimal low,
+ BigDecimal high, double change) {
+ setSymbol(symbol);
+ setCompanyName(companyName);
+ setVolume(volume);
+ setPrice(price);
+ setOpen(open);
+ setLow(low);
+ setHigh(high);
+ setChange(change);
+ }
+
+ public static QuoteDataBean getRandomInstance() {
+ return new QuoteDataBean(
+ TradeConfig.rndSymbol(), //symbol
+ TradeConfig.rndSymbol() + " Incorporated", //Company Name
+ TradeConfig.rndFloat(100000), //volume
+ TradeConfig.rndBigDecimal(1000.0f), //price
+ TradeConfig.rndBigDecimal(1000.0f), //open1
+ TradeConfig.rndBigDecimal(1000.0f), //low
+ TradeConfig.rndBigDecimal(1000.0f), //high
+ TradeConfig.rndFloat(100000) //volume
+ );
+ }
+
+ //Create a "zero" value quoteDataBean for the given symbol
+ public QuoteDataBean(String symbol) {
+ setSymbol(symbol);
+ }
+
+
+ public String toString() {
+ return "\n\tQuote Data for: " + getSymbol()
+ + "\n\t\t companyName: " + getCompanyName()
+ + "\n\t\t volume: " + getVolume()
+ + "\n\t\t price: " + getPrice()
+ + "\n\t\t open1: " + getOpen()
+ + "\n\t\t low: " + getLow()
+ + "\n\t\t high: " + getHigh()
+ + "\n\t\t change1: " + getChange()
+ ;
+ }
+
+ public String toHTML() {
+ return "<BR>Quote Data for: " + getSymbol()
+ + "<LI> companyName: " + getCompanyName() + "</LI>"
+ + "<LI> volume: " + getVolume() + "</LI>"
+ + "<LI> price: " + getPrice() + "</LI>"
+ + "<LI> open1: " + getOpen() + "</LI>"
+ + "<LI> low: " + getLow() + "</LI>"
+ + "<LI> high: " + getHigh() + "</LI>"
+ + "<LI> change1: " + getChange() + "</LI>"
+ ;
+ }
+
+ public void print() {
+ Log.log(this.toString());
+ }
+
+ /**
+ * Gets the symbol
+ *
+ * @return Returns a String
+ */
+ public String getSymbol() {
+ return symbol;
+ }
+
+ /**
+ * Sets the symbol
+ *
+ * @param symbol The symbol to set
+ */
+ public void setSymbol(String symbol) {
+ this.symbol = symbol;
+ }
+
+ /**
+ * Gets the companyName
+ *
+ * @return Returns a String
+ */
+ public String getCompanyName() {
+ return companyName;
+ }
+
+ /**
+ * Sets the companyName
+ *
+ * @param companyName The companyName to set
+ */
+ public void setCompanyName(String companyName) {
+ this.companyName = companyName;
+ }
+
+ /**
+ * Gets the price
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getPrice() {
+ return price;
+ }
+
+ /**
+ * Sets the price
+ *
+ * @param price The price to set
+ */
+ public void setPrice(BigDecimal price) {
+ this.price = price;
+ }
+
+ /**
+ * Gets the open1
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getOpen() {
+ return open1;
+ }
+
+ /**
+ * Sets the open1
+ *
+ * @param open The open1 to set
+ */
+ public void setOpen(BigDecimal open) {
+ this.open1 = open;
+ }
+
+ /**
+ * Gets the low
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getLow() {
+ return low;
+ }
+
+ /**
+ * Sets the low
+ *
+ * @param low The low to set
+ */
+ public void setLow(BigDecimal low) {
+ this.low = low;
+ }
+
+ /**
+ * Gets the high
+ *
+ * @return Returns a BigDecimal
+ */
+ public BigDecimal getHigh() {
+ return high;
+ }
+
+ /**
+ * Sets the high
+ *
+ * @param high The high to set
+ */
+ public void setHigh(BigDecimal high) {
+ this.high = high;
+ }
+
+ /**
+ * Gets the change1
+ *
+ * @return Returns a double
+ */
+ public double getChange() {
+ return change1;
+ }
+
+ /**
+ * Sets the change1
+ *
+ * @param change The change1 to set
+ */
+ public void setChange(double change) {
+ this.change1 = change;
+ }
+
+ /**
+ * Gets the volume
+ *
+ * @return Returns a BigDecimal
+ */
+ public double getVolume() {
+ return volume;
+ }
+
+ /**
+ * Sets the volume
+ *
+ * @param volume The volume to set
+ */
+ public void setVolume(double volume) {
+ this.volume = volume;
+ }
}