You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by kw...@apache.org on 2006/06/14 23:35:21 UTC
svn commit: r414391 - in
/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services:
accountdata/AccountDataServiceDASImpl.java accountdb/AccountDBInit.java
accountlogger/AccountLoggerServiceImpl.java
Author: kwilliams
Date: Wed Jun 14 14:35:21 2006
New Revision: 414391
URL: http://svn.apache.org/viewvc?rev=414391&view=rev
Log:
Brent's BBank changes for T-469
Modified:
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java?rev=414391&r1=414390&r2=414391&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdata/AccountDataServiceDASImpl.java Wed Jun 14 14:35:21 2006
@@ -31,10 +31,9 @@
import java.util.Properties;
import java.util.TimeZone;
-import org.apache.tuscany.das.rdb.ApplyChangesCommand;
import org.apache.tuscany.das.rdb.Command;
-import org.apache.tuscany.das.rdb.CommandGroup;
import org.apache.tuscany.das.rdb.Converter;
+import org.apache.tuscany.das.rdb.DAS;
import org.osoa.sca.annotations.Service;
import bigbank.account.services.account.AccountServiceImpl;
@@ -66,8 +65,9 @@
try {
InputStream mapping = createConfigStream();
- Command select = Command.FACTORY.createCommand(
- "SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID", mapping);
+ DAS das = DAS.FACTORY.createDAS(mapping);
+ Command select = das.createCommand(
+ "SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID");
Connection conn = getConnection();
select.setConnection(conn);
select.setParameterValue("loginID", logonID);
@@ -100,8 +100,8 @@
InputStream mapping = createConfigStream();
- Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID",
- mapping);
+ DAS das = DAS.FACTORY.createDAS(mapping);
+ Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID");
Connection conn = getConnection();
select.setConnection(conn);
select.setParameterValue("loginID", logonID);
@@ -122,7 +122,8 @@
throws RemoteException {
try {
- Command insert = Command.FACTORY.createCommand("insert into customers (firstName,lastName,address,email, loginID, password ) values ('"
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das.createCommand("insert into customers (firstName,lastName,address,email, loginID, password ) values ('"
+ customerProfile.getFirstName() + "', '" + customerProfile.getLastName() + "', '" + customerProfile.getAddress() + "', '"
+ customerProfile.getEmail() + "', '" + customerProfile.getLoginID() + "', '" + customerProfile.getPassword() + "')");
insert.setConnection(getConnection());
@@ -130,14 +131,14 @@
CustomerProfileData ret = getCustomerProfile(customerProfile.getLoginID());
String cid = ret.getId() + "";
if (createSavings) {
- insert = Command.FACTORY.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ AccountServiceImpl.SAVINGS_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_SAVINGS + "', " + 1.0F + ")");
insert.setConnection(getConnection());
insert.execute();
}
if (createCheckings) {
- insert = Command.FACTORY.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ insert = das.createCommand("insert into accounts (id,accountNumber, accountType, balance ) values (" + cid + ", '"
+ AccountServiceImpl.CHECKING_ACCOUNT_PREFIX + cid + "', '" + AccountServiceImpl.ACCOUNT_TYPE_CHECKINGS + "', " + 1.0F + ")");
insert.setConnection(getConnection());
insert.execute();
@@ -155,9 +156,9 @@
public CustomerProfileData createAccountNOTWORKING(CustomerProfileData customerProfile, boolean createSavings, boolean createCheckings)
throws RemoteException {
try {
- CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
- commandGroup.setConnection(getConnection());
- Command read = commandGroup.getCommand("all customers");
+ DAS das = DAS.FACTORY.createDAS(createConfigStream());
+ das.setConnection(getConnection());
+ Command read = das.getCommand("all customers");
// select.setDataObjectModel();
TypeHelper helper = TypeHelper.INSTANCE;
@@ -175,8 +176,7 @@
customer.set("loginID", customerProfile.getLoginID());
customer.set("password", customerProfile.getPassword());
- ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
- apply.execute(root);
+ das.applyChanges(root);
return getCustomerProfile(customerProfile.getLoginID());
} catch (Exception e) {
@@ -193,7 +193,8 @@
final AccountReport accountReport = accountFactory.createAccountReport();
InputStream mapping = createConfigStream();
- Command select = Command.FACTORY.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = :id", mapping);
+ DAS das = DAS.FACTORY.createDAS(mapping);
+ Command select = das.createCommand("SELECT accountNumber, accountType, balance FROM accounts where id = :id");
Connection conn = getConnection();
select.setConnection(conn);
select.setParameterValue("id", customerID);
@@ -204,7 +205,7 @@
// Get Stocks
- select = Command.FACTORY.createCommand(
+ select = das.createCommand(
"SELECT Symbol, quantity, purchasePrice, purchaseDate, purchaseLotNumber FROM stocks where id = :id", createConfigStream());
select.setConnection(conn);
select.setParameterValue("id", customerID);
@@ -234,9 +235,11 @@
public float deposit(String account, float ammount) throws RemoteException {
try {
- Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber",
- createConfigStream());
- Connection conn = getConnection();
+ DAS das = DAS.FACTORY.createDAS(createConfigStream());
+ Connection conn = getConnection();
+ das.setConnection(conn);
+
+ Command select = das.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber");
select.setConnection(conn);
select.setParameterValue("accountNumber", account);
TypeHelper helper = TypeHelper.INSTANCE;
@@ -247,15 +250,14 @@
float newbalance = accountData.getBalance() + ammount;
accountData.setBalance(newbalance);
// update department set companyid = ? where department.name = ?
- CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
- commandGroup.setConnection(conn);
- Command update = commandGroup.getCommand("update balance");
+
+ Command update = das.getCommand("update balance");
update.setParameterValue("BALANCE", new Float(newbalance));
update.setParameterValue("ACCOUNTNUMBER", account);
update.execute();
conn.close();
return newbalance;
- } catch (Exception e) {
+ } catch (Exception e) {
throw new RemoteException(e.getClass().getName(), e);
}
@@ -263,10 +265,10 @@
public StockSummary sellStock(int purchaseLotNumber, int quantity) throws RemoteException {
try {
- CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
- commandGroup.setConnection(getConnection());
+ DAS das = DAS.FACTORY.createDAS(createConfigStream());
+ das.setConnection(getConnection());
- Command read = commandGroup.getCommand("stockbylotSelect");
+ Command read = das.getCommand("stockbylotSelect");
TypeHelper helper = TypeHelper.INSTANCE;
read.setDataObjectModel(helper.getType(DataGraphRoot.class));
read.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);// autoboxing :-)
@@ -277,14 +279,14 @@
int newQuatity = Math.max(stock.getQuantity() - quantity, 0);
if (newQuatity < 1) {
- Command delete = Command.FACTORY.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?");
+ Command delete = das.createCommand("DELETE FROM STOCKS WHERE PURCHASELOTNUMBER = ?");
delete.setParameterValue(1, purchaseLotNumber);
delete.setConnection(getConnection());
delete.execute();
} else {
- Command update = commandGroup.getCommand("stockbylot");
+ Command update = das.getCommand("stockbylot");
update.setParameterValue("QUANTITY", newQuatity);
update.setParameterValue("PURCHASELOTNUMBER", purchaseLotNumber);
@@ -304,8 +306,8 @@
public StockSummary purchaseStock(int id, StockSummary stock) throws RemoteException {
try {
-
- Command insert = Command.FACTORY
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das
.createCommand("insert into stocks (id, symbol, quantity, purchasePrice, purchaseDate) values (?,?,?,?,?)");
insert.setParameterValue(1, new Integer(id));
insert.setParameterValue(2, stock.getSymbol());
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java?rev=414391&r1=414390&r2=414391&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountdb/AccountDBInit.java Wed Jun 14 14:35:21 2006
@@ -35,10 +35,9 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
-import org.apache.tuscany.das.rdb.ApplyChangesCommand;
import org.apache.tuscany.das.rdb.Command;
-import org.apache.tuscany.das.rdb.CommandGroup;
import org.apache.tuscany.das.rdb.Converter;
+import org.apache.tuscany.das.rdb.DAS;
import org.apache.tuscany.das.rdb.config.ConfigFactory;
import org.apache.tuscany.sdo.util.SDOUtil;
@@ -290,9 +289,9 @@
protected void testStrockPurchaseThroughDAS(purchaseStock sp) throws InstantiationException, IllegalAccessException, ClassNotFoundException,
SQLException {
- CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
- commandGroup.setConnection(createConnection());
- Command read = commandGroup.getCommand("all stocks");
+ DAS das = DAS.FACTORY.createDAS(createConfigStream());
+ das.setConnection(createConnection());
+ Command read = das.getCommand("all stocks");
DataObject root = read.executeQuery();
@@ -304,9 +303,7 @@
stockPurchase.set("PURCHASEPRICE", new Float(11.00));
stockPurchase.set("PURCHASEDATE", new Date());
- ApplyChangesCommand apply = commandGroup.getApplyChangesCommand();
-
- apply.execute(root);
+ das.applyChanges(root);
@@ -315,8 +312,8 @@
public CustomerProfileData testgetCustomerByLoginIDThroughDASRead(final String logonID) throws Exception {
InputStream mapping = createConfigStream();
-
- Command select = Command.FACTORY.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID",
+ DAS das = DAS.FACTORY.createDAS(mapping);
+ Command select = das.createCommand("SELECT firstName, lastName, loginID, password, id FROM customers where loginID = :loginID",
mapping);
Connection conn = createConnection();
select.setConnection(conn);
@@ -398,10 +395,10 @@
public void testWithdrawThroughDAS(withdraw wd) throws Exception {
- Command select = Command.FACTORY.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber",
- createConfigStream());
+ DAS das = DAS.FACTORY.createDAS(createConfigStream());
+ Command select = das.createCommand("SELECT accountNumber, balance FROM accounts where accountNumber = :accountNumber");
Connection conn = createConnection();
- select.setConnection(conn);
+ das.setConnection(conn);
select.setParameterValue("accountNumber", wd.getAccountNumber());
TypeHelper helper = TypeHelper.INSTANCE;
@@ -415,9 +412,8 @@
account.setBalance(newbalance);
// update department set companyid = ? where department.name = ?
- CommandGroup commandGroup = CommandGroup.FACTORY.createCommandGroup(createConfigStream());
- commandGroup.setConnection(conn);
- Command update = commandGroup.getCommand("update balance");
+
+ Command update = das.getCommand("update balance");
update.setParameterValue("BALANCE", new Float(newbalance));
update.setParameterValue("ACCOUNTNUMBER", wd.getAccountNumber());
Modified: incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java?rev=414391&r1=414390&r2=414391&view=diff
==============================================================================
--- incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java (original)
+++ incubator/tuscany/java/sampleapps/bigbank/account/src/main/java/bigbank/account/services/accountlogger/AccountLoggerServiceImpl.java Wed Jun 14 14:35:21 2006
@@ -21,11 +21,11 @@
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
-import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
import org.apache.tuscany.das.rdb.Command;
+import org.apache.tuscany.das.rdb.DAS;
import org.osoa.sca.annotations.Service;
import com.bigbank.account.AccountFactory;
@@ -52,8 +52,8 @@
protected static final String protocol = "jdbc:derby:";
public void logDeposit(int id, String account, float amount) throws RemoteException {
-
- Command insert = Command.FACTORY.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
insert.setParameterValue(1, new Integer(id));
insert.setParameterValue(2, account);
insert.setParameterValue(3, ACCT_ACTION_TYPE_DEPOSIT);
@@ -67,8 +67,8 @@
}
public void logWithdrawal(int id, String account, float amount) throws RemoteException {
-
- Command insert = Command.FACTORY.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das.createCommand("insert into acctLog (id, accountNumber, actionType, amount) values (?,?,?,?)");
insert.setParameterValue(1, new Integer(id));
insert.setParameterValue(2, account);
insert.setParameterValue(3, ACCT_ACTION_TYPE_WITHDRAW);
@@ -82,8 +82,8 @@
}
public void logPurchaseStock(int id, StockSummary stock) throws RemoteException {
-
- Command insert = Command.FACTORY.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
insert.setParameterValue(1, new Integer(id));
insert.setParameterValue(2, stock.getSymbol());
insert.setParameterValue(3, new Integer(stock.getQuantity()));
@@ -101,7 +101,8 @@
public void logSellStock(int id, StockSummary stock, int quantity) throws RemoteException {
String symbol = ((stock.getSymbol()!=null)?stock.getSymbol():"null");
- Command insert = Command.FACTORY.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
+ DAS das = DAS.FACTORY.createDAS();
+ Command insert = das.createCommand("insert into stockLog (id, Symbol, quantity, actionType, purchaseLotNumber) values (?,?,?,?,?)");
insert.setParameterValue(1, new Integer(id));
insert.setParameterValue(2, symbol);
insert.setParameterValue(3, new Integer(quantity));
@@ -180,7 +181,8 @@
final AccountLog accountLog = accountFactory.createAccountLog();
InputStream mapping = createConfigStream();
- Command select = Command.FACTORY.createCommand("SELECT logSeqNo, accountNumber, actionType, amount FROM acctLog where id = :id", mapping);
+ DAS das = DAS.FACTORY.createDAS(mapping);
+ Command select = das.createCommand("SELECT logSeqNo, accountNumber, actionType, amount FROM acctLog where id = :id");
Connection conn = getConnection();
select.setConnection(conn);
select.setParameterValue("id", customerID);
@@ -189,8 +191,8 @@
DataGraphRoot root = (DataGraphRoot) select.executeQuery();
accountLog.getAccountLogEntries().addAll(root.getAccountLogEntries());
- select = Command.FACTORY.createCommand(
- "SELECT logSeqNo, Symbol, quantity, actionType, purchaseLotNumber FROM stockLog where id = :id", createConfigStream());
+ select = das.createCommand(
+ "SELECT logSeqNo, Symbol, quantity, actionType, purchaseLotNumber FROM stockLog where id = :id");
select.setConnection(conn);
select.setParameterValue("id", customerID);
select.setDataObjectModel(helper.getType(DataGraphRoot.class));
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org