incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chint...@apache.org
Subject svn commit: r816884 - in /incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader: dal/CustomerDAO.java mssql/MSSQLCustomerDAO.java mysql/MySQLCustomerDAO.java
Date Sat, 19 Sep 2009 10:03:13 GMT
Author: chintana
Date: Sat Sep 19 10:03:13 2009
New Revision: 816884

URL: http://svn.apache.org/viewvc?rev=816884&view=rev
Log:
Implementing the new operation

Modified:
    incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java
    incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mssql/MSSQLCustomerDAO.java
    incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mysql/MySQLCustomerDAO.java

Modified: incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java?rev=816884&r1=816883&r2=816884&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java
(original)
+++ incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java
Sat Sep 19 10:03:13 2009
@@ -28,6 +28,9 @@
 
 public interface CustomerDAO {
 
+    public String getProfileIdFromStsIdentifier(String Id, String Sts)
+            throws DAOException;
+
 	public CustomHoldingBean getHoldingForUpdate(int orderId)
 			throws DAOException;
 

Modified: incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mssql/MSSQLCustomerDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mssql/MSSQLCustomerDAO.java?rev=816884&r1=816883&r2=816884&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mssql/MSSQLCustomerDAO.java
(original)
+++ incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mssql/MSSQLCustomerDAO.java
Sat Sep 19 10:03:13 2009
@@ -55,11 +55,50 @@
     private static final String SQL_INSERT_ACCOUNT = "INSERT INTO dbo.account (CREATIONDATE,
OPENBALANCE, LOGOUTCOUNT, BALANCE, LASTLOGIN, LOGINCOUNT, PROFILE_USERID) VALUES (GetDate(),
?, ?, ?, ?, ?, ?); SELECT ID=@@IDENTITY";
     private static final String SQL_UPDATE_ACCOUNT_PROFILE = "UPDATE dbo.accountprofile WITH
(ROWLOCK) SET ADDRESS=?, PASSWORD=?, EMAIL=?, CREDITCARD=?, FULLNAME=? WHERE USERID=?";
     private static final String SQL_SELECT_HOLDINGS = "SELECT HOLDING.HOLDINGID, HOLDING.QUANTITY,
HOLDING.PURCHASEPRICE, HOLDING.PURCHASEDATE, HOLDING.QUOTE_SYMBOL,HOLDING.ACCOUNT_ACCOUNTID
 from dbo.holding WHERE HOLDING.ACCOUNT_ACCOUNTID = (SELECT ACCOUNTID FROM ACCOUNT WHERE PROFILE_USERID
= ?) ORDER BY HOLDING.HOLDINGID DESC";
+    private static final String SQL_SELECT_CUSTOMERPROFILE_BYSTSID = "Set NOCOUNT ON; SELECT
ACCOUNTPROFILE.UserID FROM dbo.ACCOUNT, dbo.ACCOUNTPROFILE, dbo.STSACCOUNTLOOKUP WITH (NOLOCK)
WHERE ACCOUNT.PROFILE_USERID = ACCOUNTPROFILE.USERID and ACCOUNT.ACCOUNTID = STSACCOUNTLOOKUP.UserID
and STSACCOUNTLOOKUP.StsUniqueIdentifier = ? and STSACCOUNTLOOKUP.IssuingSts = ?";
 
     public MSSQLCustomerDAO(Connection sqlConnection) throws DAOException {
         super(sqlConnection);
     }
 
+    public String getProfileIdFromStsIdentifier(String Id, String Sts) throws DAOException
{
+        if (logger.isDebugEnabled()) {
+            logger.debug("MSSQLCustomerDAO.getProfileIdFromStsIdentifier(String, String)\nUnique
identifier: " + Id + "\nSts: " + Sts);
+        }
+
+        PreparedStatement selectProfileId = null;
+        String pid = null; // profile id
+        try {
+            selectProfileId = sqlConnection.prepareStatement(SQL_SELECT_CUSTOMERPROFILE_BYSTSID);
+            selectProfileId.setString(1, Id);
+            selectProfileId.setString(2, Sts);
+            ResultSet rs = selectProfileId.executeQuery();
+            if (rs.next()) {
+                try {
+                    pid = rs.getString(1);
+                    return pid;
+                } finally {
+                    try {
+                        rs.close();
+                    } catch (SQLException e) {
+                        logger.debug("", e);
+                    }
+                }
+            }
+        } catch (SQLException e) {
+            throw new DAOException("Exception is thrown when selecting the profile id for
unique id: " + Id + "and Sts: " + Sts, e);
+        } finally {
+            if (selectProfileId != null) {
+                try {
+                    selectProfileId.close();
+                } catch (SQLException e) {
+                    logger.debug("", e);
+                }
+            }
+        }
+        return pid;
+    }
+
     public CustomHoldingBean getHoldingForUpdate(int orderId) throws DAOException {
         if (logger.isDebugEnabled()) {
             logger.debug("MSSQLCustomerDAO.getHoldingForUpdate(int)\nOrder ID :" + orderId);

Modified: incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mysql/MySQLCustomerDAO.java
URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mysql/MySQLCustomerDAO.java?rev=816884&r1=816883&r2=816884&view=diff
==============================================================================
--- incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mysql/MySQLCustomerDAO.java
(original)
+++ incubator/stonehenge/trunk/stocktrader/wsas/common/src/org/apache/stonehenge/stocktrader/mysql/MySQLCustomerDAO.java
Sat Sep 19 10:03:13 2009
@@ -54,11 +54,50 @@
     private static final String SQL_INSERT_ACCOUNT = "INSERT INTO account (creationdate,
openbalance, logoutcount, balance, lastlogin, logincount, profile_userid, accountid) VALUES
(now(), ?, ?, ?, ?, ?, ?, null); SELECT LAST_INSERT_ID();";
     private static final String SQL_UPDATE_ACCOUNT_PROFILE = "UPDATE accountprofile SET address
= ?, password = ?, email = ?, creditcard = ?, fullname = ? WHERE userid = ?";
     private static final String SQL_SELECT_HOLDINGS = "SELECT holdingid, quantity, purchaseprice,
purchasedate, quote_symbol, account_accountid FROM holding WHERE account_accountid = (SELECT
accountid FROM account WHERE profile_userid = ?) ORDER BY holdingid DESC";
+    private static final String SQL_SELECT_CUSTOMERPROFILE_BYSTSID = "SELECT userid FROM
account a, accountprofile p, stsaccountlookup s WHERE a.profile_userid = p.userid AND a.accountid
= s.userid AND s.stsuniqueidentifier = ? AND s.issuingsts = ?";
 
     public MySQLCustomerDAO(Connection sqlConnection) throws DAOException {
         super(sqlConnection);
     }
 
+    public String getProfileIdFromStsIdentifier(String Id, String Sts) throws DAOException
{
+        if (logger.isDebugEnabled()) {
+            logger.debug("MSSQLCustomerDAO.getProfileIdFromStsIdentifier(String, String)\nUnique
identifier: " + Id + "\nSts: " + Sts);
+        }
+
+        PreparedStatement selectProfileId = null;
+        String pid = null; // profile id
+        try {
+            selectProfileId = sqlConnection.prepareStatement(SQL_SELECT_CUSTOMERPROFILE_BYSTSID);
+            selectProfileId.setString(1, Id);
+            selectProfileId.setString(2, Sts);
+            ResultSet rs = selectProfileId.executeQuery();
+            if (rs.next()) {
+                try {
+                    pid = rs.getString(1);
+                    return pid;
+                } finally {
+                    try {
+                        rs.close();
+                    } catch (SQLException e) {
+                        logger.debug("", e);
+                    }
+                }
+            }
+        } catch (SQLException e) {
+            throw new DAOException("Exception is thrown when selecting the profile id for
unique id: " + Id + "and Sts: " + Sts, e);
+        } finally {
+            if (selectProfileId != null) {
+                try {
+                    selectProfileId.close();
+                } catch (SQLException e) {
+                    logger.debug("", e);
+                }
+            }
+        }
+        return pid;
+    }
+
     public CustomHoldingBean getHoldingForUpdate(int orderId) throws DAOException {
         if (logger.isDebugEnabled()) {
             logger.debug("MySQLCustomerDAO.getHoldingForUpdate(int)\nOrder ID :" + orderId);



Mime
View raw message