geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jb...@apache.org
Subject svn commit: r899741 - in /geronimo/sandbox/jbohn/daytrader-bp-new/modules: daytrader-api/ daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/ daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/ d...
Date Fri, 15 Jan 2010 18:18:01 GMT
Author: jbohn
Date: Fri Jan 15 18:17:59 2010
New Revision: 899741

URL: http://svn.apache.org/viewvc?rev=899741&view=rev
Log:
update entity beans to only reference implementation classes and not interfaces

Modified:
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/   (props changed)
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/AccountDataBean.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountDataBeanImpl.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountProfileDataBeanImpl.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/HoldingDataBeanImpl.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/OrderDataBeanImpl.java
    geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java

Propchange: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jan 15 18:17:59 2010
@@ -0,0 +1,3 @@
+.classpath
+.project
+.settings

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/AccountDataBean.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/AccountDataBean.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/AccountDataBean.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-api/src/main/java/org/apache/geronimo/samples/daytrader/persistence/api/AccountDataBean.java
Fri Jan 15 18:17:59 2010
@@ -60,12 +60,8 @@
 
     public Collection<OrderDataBean> getOrders();
 
-    public void setOrders(Collection<OrderDataBean> orders);
-    
     public Collection<HoldingDataBean> getHoldings();
 
-    public void setHoldings(Collection<HoldingDataBean> holdings);
-
     public AccountProfileDataBean getProfile();
 
     public void setProfile(AccountProfileDataBean profile);

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountDataBeanImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountDataBeanImpl.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountDataBeanImpl.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountDataBeanImpl.java
Fri Jan 15 18:17:59 2010
@@ -19,6 +19,7 @@
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 
@@ -96,14 +97,14 @@
     private BigDecimal openBalance;         /* open balance */
     
 	 @OneToMany(mappedBy = "account", fetch=FetchType.LAZY)
-    private Collection<OrderDataBean> orders;
+    private Collection<OrderDataBeanImpl> orders;
     
     @OneToMany(mappedBy = "account", fetch=FetchType.LAZY)
-    private Collection<HoldingDataBean> holdings;
+    private Collection<HoldingDataBeanImpl> holdings;
     
     @OneToOne(fetch=FetchType.LAZY)
     @JoinColumn(name="PROFILE_USERID")
-    private AccountProfileDataBean profile;
+    private AccountProfileDataBeanImpl profile;
 
 //    @Version
 //    private Integer optock;
@@ -260,18 +261,26 @@
      */
 
     public Collection<OrderDataBean> getOrders() {
-        return orders;
+        Collection orderDataBeans = new ArrayList();
+        for (OrderDataBeanImpl o : orders ) {
+            orderDataBeans.add( (OrderDataBean) o);
+        }
+        return orderDataBeans;
     }
 
-    public void setOrders(Collection<OrderDataBean> orders) {
+    public void setOrders(Collection<OrderDataBeanImpl> orders) {
         this.orders = orders;
     }
     
     public Collection<HoldingDataBean> getHoldings() {
-        return holdings;
+        Collection holdingDataBeans = new ArrayList();
+        for (HoldingDataBeanImpl h : holdings ) {
+            holdingDataBeans.add( (HoldingDataBean) h);
+        }
+        return holdingDataBeans;
     }
 
-    public void setHoldings(Collection<HoldingDataBean> holdings) {
+    public void setHoldings(Collection<HoldingDataBeanImpl> holdings) {
         this.holdings = holdings;
     }
 
@@ -280,7 +289,7 @@
     }
 
     public void setProfile(AccountProfileDataBean profile) {
-        this.profile = profile;
+        this.profile = (AccountProfileDataBeanImpl) profile;
     }
 
     public void login(String password) {

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountProfileDataBeanImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountProfileDataBeanImpl.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountProfileDataBeanImpl.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/AccountProfileDataBeanImpl.java
Fri Jan 15 18:17:59 2010
@@ -63,7 +63,7 @@
     private String creditCard;          /* creditCard */
     
 	@OneToOne(mappedBy="profile", fetch=FetchType.LAZY)
-    private AccountDataBean account;
+    private AccountDataBeanImpl account;
 
 //    @Version
 //    private Integer optLock;
@@ -173,7 +173,7 @@
     }
 
     public void setAccount(AccountDataBean account) {
-        this.account = account;
+        this.account = (AccountDataBeanImpl) account;
     }
     
     @Override

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/HoldingDataBeanImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/HoldingDataBeanImpl.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/HoldingDataBeanImpl.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/HoldingDataBeanImpl.java
Fri Jan 15 18:17:59 2010
@@ -71,10 +71,11 @@
 
 	@ManyToOne(fetch = FetchType.LAZY)
 	@JoinColumn(name = "ACCOUNT_ACCOUNTID")
-	private AccountDataBean account;
+	private AccountDataBeanImpl account;
+
 	@ManyToOne(fetch = FetchType.EAGER)
 	@JoinColumn(name = "QUOTE_SYMBOL")
-	private QuoteDataBean quote;
+	private QuoteDataBeanImpl quote;
 
 	// @Version
 	// private Integer optLock;
@@ -177,7 +178,7 @@
 	}
 
 	public void setAccount(AccountDataBean account) {
-		this.account = account;
+		this.account = (AccountDataBeanImpl) account;
 	}
 
 	/*
@@ -189,7 +190,7 @@
 	}
 
 	public void setQuote(QuoteDataBean quote) {
-		this.quote = quote;
+		this.quote = (QuoteDataBeanImpl) quote;
 	}
 
 	@Override

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/OrderDataBeanImpl.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/OrderDataBeanImpl.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/OrderDataBeanImpl.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-entities/src/main/java/org/apache/geronimo/samples/daytrader/beans/OrderDataBeanImpl.java
Fri Jan 15 18:17:59 2010
@@ -97,15 +97,15 @@
 
 	@ManyToOne(fetch = FetchType.LAZY)
 	@JoinColumn(name="ACCOUNT_ACCOUNTID")
-    private AccountDataBean account;
+    private AccountDataBeanImpl account;
 
 	@ManyToOne(fetch = FetchType.EAGER)
 	@JoinColumn(name = "QUOTE_SYMBOL")
-    private QuoteDataBean quote;
+    private QuoteDataBeanImpl quote;
 
 	@OneToOne(fetch = FetchType.LAZY)
 	@JoinColumn(name = "HOLDING_HOLDINGID")
-    private HoldingDataBean holding;
+    private HoldingDataBeanImpl holding;
 	
 
 	 @Transient
@@ -260,7 +260,7 @@
 	}
 
 	public void setAccount(AccountDataBean account) {
-		this.account = account;
+		this.account = (AccountDataBeanImpl) account;
 	}
 
 	public QuoteDataBean getQuote() {
@@ -268,7 +268,7 @@
 	}
 
 	public void setQuote(QuoteDataBean quote) {
-		this.quote = quote;
+		this.quote = (QuoteDataBeanImpl) quote;
 	}
 
 	public HoldingDataBean getHolding() {
@@ -276,7 +276,7 @@
 	}
 
 	public void setHolding(HoldingDataBean holding) {
-		this.holding = holding;
+		this.holding = (HoldingDataBeanImpl) holding;
 	}
 
 	public boolean isBuy() {

Modified: geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java?rev=899741&r1=899740&r2=899741&view=diff
==============================================================================
--- geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java
(original)
+++ geronimo/sandbox/jbohn/daytrader-bp-new/modules/daytrader-persist-jpa/src/main/java/org/apache/geronimo/samples/daytrader/persist/jpa/TradeJPADirect.java
Fri Jan 15 18:17:59 2010
@@ -111,8 +111,7 @@
             // ordered by their change in value
             Collection<QuoteDataBean> quotes;
 
-            Query query = entityManager
-                          .createNamedQuery("quoteejb.quotesByChange");
+            Query query = entityManager.createNamedQuery("quoteejb.quotesByChange");
             quotes = query.getResultList();
 
             QuoteDataBean[] quoteArray = (QuoteDataBean[]) quotes.toArray(new QuoteDataBean[quotes.size()]);
@@ -162,14 +161,14 @@
             if (Log.doTrace())
                 Log.trace("TradeJPADirect:buy", userID, symbol, quantity, orderProcessingMode);
 
-            AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
             AccountDataBean account = profile.getAccount();
 
-            QuoteDataBean quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
+            QuoteDataBeanImpl quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
 
-            HoldingDataBean holding = null; // The holding will be created by this buy order
+            HoldingDataBeanImpl holding = null; // The holding will be created by this buy
order
 
-            order = createOrder(account, quote, holding, "buy", quantity);
+            order = createOrder( account, (QuoteDataBean) quote, (HoldingDataBean) holding,
"buy", quantity);
 
             // order = createOrder(account, quote, holding, "buy", quantity);
             // UPDATE - account should be credited during completeOrder
@@ -211,10 +210,10 @@
             if (Log.doTrace())
                 Log.trace("TradeJPADirect:sell", userID, holdingID, orderProcessingMode);
 
-            AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+            AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
 
             AccountDataBean account = profile.getAccount();
-            HoldingDataBean holding = entityManager.find(HoldingDataBeanImpl.class, holdingID);
+            HoldingDataBeanImpl holding = entityManager.find(HoldingDataBeanImpl.class, holdingID);
 
             if (holding == null) {
                 Log.error("TradeJPADirect:sell User " + userID
@@ -278,7 +277,7 @@
     public OrderDataBean completeOrder(Integer orderID, boolean twoPhase)
     throws Exception {
 
-        OrderDataBean order = null;
+        OrderDataBeanImpl order = null;
 
         if (Log.doTrace())
             Log.trace("TradeJPADirect:completeOrder", orderID + " twoPhase=" + twoPhase);
@@ -363,7 +362,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:cancelOrder", orderID + " twoPhase=" + twoPhase);
 
-        OrderDataBean order = entityManager.find(OrderDataBeanImpl.class, orderID);
+        OrderDataBeanImpl order = entityManager.find(OrderDataBeanImpl.class, orderID);
         order.cancel();
     }
 
@@ -377,7 +376,7 @@
     public Collection<OrderDataBean> getOrders(String userID) {
         if (Log.doTrace())
             Log.trace("TradeJPADirect:getOrders", userID);
-        AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
         AccountDataBean account = profile.getAccount();
         return account.getOrders();
     }
@@ -398,7 +397,7 @@
             Iterator itr = results.iterator();
             // Spin through the orders to populate the lazy quote fields
             while (itr.hasNext()) {
-                OrderDataBean thisOrder = (OrderDataBean) itr.next();
+                OrderDataBeanImpl thisOrder = (OrderDataBeanImpl) itr.next();
                 thisOrder.getQuote();
             }
 
@@ -428,7 +427,7 @@
                                                         + "from accountejb a where a.profile_userid
= ?",
                                                         org.apache.geronimo.samples.daytrader.beans.AccountDataBeanImpl.class);
                 findaccountid.setParameter(1, userID);
-                AccountDataBean account = (AccountDataBean) findaccountid.getSingleResult();
+                AccountDataBeanImpl account = (AccountDataBeanImpl) findaccountid.getSingleResult();
                 Integer accountid = account.getAccountID();
                 Query updateStatus = entityManager.createNativeQuery("UPDATE orderejb o SET
o.orderStatus = 'completed' WHERE "
                                                                      + "o.orderStatus = 'closed'
AND o.ACCOUNT_ACCOUNTID  = ?");
@@ -449,7 +448,7 @@
     public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price)
{
 
         try {
-            QuoteDataBean quote = new QuoteDataBeanImpl(symbol, companyName, 0, price, price,
price, price, 0);
+            QuoteDataBeanImpl quote = new QuoteDataBeanImpl(symbol, companyName, 0, price,
price, price, price, 0);
             entityManager.persist(quote);
 
             if (Log.doTrace())
@@ -467,7 +466,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:getQuote", symbol);
 
-        QuoteDataBean qdb = entityManager.find(QuoteDataBeanImpl.class, symbol);
+        QuoteDataBeanImpl qdb = entityManager.find(QuoteDataBeanImpl.class, symbol);
 
         return qdb;
     }
@@ -483,8 +482,9 @@
 
     public QuoteDataBean updateQuotePriceVolume(String symbol,
                                                 BigDecimal changeFactor, double sharesTraded)
{
-        if (!TradeConfig.getUpdateQuotePrices())
+        if (!TradeConfig.getUpdateQuotePrices()) {
             return new QuoteDataBeanImpl();
+        }
 
         if (Log.doTrace())
             Log.trace("TradeJPADirect:updateQuote", symbol, changeFactor);
@@ -492,9 +492,9 @@
         /*
          * Add logic to determine JPA layer, because JBoss5' Hibernate 3.3.1GA
          * DB2Dialect and MySQL5Dialect do not work with annotated query
-         * "quoteejb.quoteForUpdate" defined in QuoteDatabean
+         * "quoteejb.quoteForUpdate" defined in QuoteDataBeanImpl
          */
-        QuoteDataBean quote = null;
+        QuoteDataBeanImpl quote = null;
         if (TradeConfig.jpaLayer == TradeConfig.HIBERNATE) {
             quote = entityManager.find(QuoteDataBeanImpl.class, symbol);
         } else if (TradeConfig.jpaLayer == TradeConfig.OPENJPA) {
@@ -502,7 +502,7 @@
             Query q = entityManager.createNamedQuery("quoteejb.quoteForUpdate");
             q.setParameter(1, symbol);
   
-            quote = (QuoteDataBean) q.getSingleResult();
+            quote = (QuoteDataBeanImpl) q.getSingleResult();
         }
 
         BigDecimal oldPrice = quote.getPrice();
@@ -553,7 +553,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:getAccountData", userID);
 
-        AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
         /*
          * Inflate the lazy data memebers
          */
@@ -570,7 +570,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:getProfileData", userID);
 
-        AccountProfileDataBean apb = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl apb = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
         return apb;
     }
 
@@ -593,7 +593,7 @@
          * entityManager.merge(profileData); //System.out.println(temp);
          */
 
-        AccountProfileDataBean temp = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl temp = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
         temp.setAddress(address);
         temp.setPassword(password);
         temp.setFullName(fullName);
@@ -607,7 +607,7 @@
     public AccountDataBean login(String userID, String password)
     throws Exception {
 
-        AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
 
         if (profile == null) {
             throw new RuntimeException("No such user: " + userID);
@@ -629,7 +629,7 @@
         if (Log.doTrace())
             Log.trace("TradeJPADirect:logout", userID);
 
-        AccountProfileDataBean profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
+        AccountProfileDataBeanImpl profile = entityManager.find(AccountProfileDataBeanImpl.class,
userID);
         AccountDataBean account = profile.getAccount();
 
         account.logout();
@@ -641,8 +641,8 @@
     public AccountDataBean register(String userID, String password, String fullname, 
                                     String address, String email, String creditcard,
                                     BigDecimal openBalance) {
-        AccountDataBean account = null;
-        AccountProfileDataBean profile = null;
+        AccountDataBeanImpl account = null;
+        AccountProfileDataBeanImpl profile = null;
 
         if (Log.doTrace())
             Log.trace("TradeJPADirect:register", userID, password, fullname, address, email,
creditcard, openBalance);
@@ -659,12 +659,13 @@
             profile = new AccountProfileDataBeanImpl(userID, password, fullname,
                                                  address, email, creditcard);
             account = new AccountDataBeanImpl(0, 0, null, new Timestamp(System.currentTimeMillis()),
openBalance, openBalance, userID);
-            profile.setAccount(account);
-            account.setProfile(profile);
+            profile.setAccount((AccountDataBean)account);
+            account.setProfile((AccountProfileDataBean)profile);
             entityManager.persist(profile);
             entityManager.persist(account);
         }
 
+
         return account;
     }
 
@@ -683,7 +684,7 @@
     private OrderDataBean createOrder(AccountDataBean account,
                                       QuoteDataBean quote, HoldingDataBean holding, String
orderType,
                                       double quantity) {
-        OrderDataBean order;
+        OrderDataBeanImpl order;
         if (Log.doTrace())
             Log.trace("TradeJPADirect:createOrder(orderID=" + " account="
                       + ((account == null) ? null : account.getAccountID())
@@ -711,7 +712,7 @@
 
     private HoldingDataBean createHolding(AccountDataBean account,
                                           QuoteDataBean quote, double quantity, BigDecimal
purchasePrice) throws Exception {
-        HoldingDataBean newHolding = new HoldingDataBeanImpl(quantity,
+        HoldingDataBeanImpl newHolding = new HoldingDataBeanImpl(quantity,
                                                          purchasePrice, new Timestamp(System.currentTimeMillis()),
                                                          account, quote);
         entityManager.persist(newHolding);



Mime
View raw message