Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomMarketSummaryBean.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomMarketSummaryBean.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomMarketSummaryBean.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomMarketSummaryBean.java Tue Jun 29 06:33:54 2010 @@ -1,93 +1,93 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader; - -import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -public class CustomMarketSummaryBean { - - private static final long serialVersionUID = 6180349684421231291L; - - protected BigDecimal tsia; - protected BigDecimal openTSIA; - protected Double volume; - protected List<CustomQuoteBean> topGainers = new ArrayList<CustomQuoteBean>(); - protected List<CustomQuoteBean> topLosers = new ArrayList<CustomQuoteBean>(); - protected Calendar summaryDate; - - public CustomMarketSummaryBean(BigDecimal tSIA, BigDecimal openTSIA, - double volume, List<CustomQuoteBean> topGainers, - List<CustomQuoteBean> topLosers) { - setTSIA(tSIA); - setOpenTSIA(openTSIA); - setVolume(volume); - setTopGainers(topGainers); - setTopLosers(topLosers); - } - - private void setTopGainers(List<CustomQuoteBean> topGainers) { - this.topGainers.addAll(topGainers); - } - - public List<CustomQuoteBean> getTopGainers() { - return topGainers; - } - - private void setTopLosers(List<CustomQuoteBean> topLosers) { - this.topLosers.addAll(topLosers); - } - - public List<CustomQuoteBean> getTopLosers() { - return topLosers; - } - - public BigDecimal getTSIA() { - return tsia; - } - - public void setTSIA(BigDecimal tsia) { - this.tsia = tsia; - } - - public BigDecimal getOpenTSIA() { - return openTSIA; - } - - public void setOpenTSIA(BigDecimal openTSIA) { - this.openTSIA = openTSIA; - } - - public Double getVolume() { - return volume; - } - - public void setVolume(Double volume) { - this.volume = volume; - } - - public Calendar getSummaryDate() { - return summaryDate; - } - - public void setSummaryDate(Calendar summaryDate) { - this.summaryDate = summaryDate; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.List; + +public class CustomMarketSummaryBean { + + private static final long serialVersionUID = 6180349684421231291L; + + protected BigDecimal tsia; + protected BigDecimal openTSIA; + protected Double volume; + protected List<CustomQuoteBean> topGainers = new ArrayList<CustomQuoteBean>(); + protected List<CustomQuoteBean> topLosers = new ArrayList<CustomQuoteBean>(); + protected Calendar summaryDate; + + public CustomMarketSummaryBean(BigDecimal tSIA, BigDecimal openTSIA, + double volume, List<CustomQuoteBean> topGainers, + List<CustomQuoteBean> topLosers) { + setTSIA(tSIA); + setOpenTSIA(openTSIA); + setVolume(volume); + setTopGainers(topGainers); + setTopLosers(topLosers); + } + + private void setTopGainers(List<CustomQuoteBean> topGainers) { + this.topGainers.addAll(topGainers); + } + + public List<CustomQuoteBean> getTopGainers() { + return topGainers; + } + + private void setTopLosers(List<CustomQuoteBean> topLosers) { + this.topLosers.addAll(topLosers); + } + + public List<CustomQuoteBean> getTopLosers() { + return topLosers; + } + + public BigDecimal getTSIA() { + return tsia; + } + + public void setTSIA(BigDecimal tsia) { + this.tsia = tsia; + } + + public BigDecimal getOpenTSIA() { + return openTSIA; + } + + public void setOpenTSIA(BigDecimal openTSIA) { + this.openTSIA = openTSIA; + } + + public Double getVolume() { + return volume; + } + + public void setVolume(Double volume) { + this.volume = volume; + } + + public Calendar getSummaryDate() { + return summaryDate; + } + + public void setSummaryDate(Calendar summaryDate) { + this.summaryDate = summaryDate; + } +}
Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomMarketSummaryBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomOrderBean.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomOrderBean.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomOrderBean.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomOrderBean.java Tue Jun 29 06:33:54 2010 @@ -1,169 +1,169 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader; - -import java.math.BigDecimal; -import java.util.Calendar; - -/** - * This class is to be used as the data model for order information. - */ -public class CustomOrderBean { - - private static final long serialVersionUID = 5294153874232419015L; - - int accountId; - int holdingId; - - protected Integer orderID; - protected String orderType; - protected String orderStatus; - protected Calendar openDate; - protected Calendar completionDate; - protected Double quantity; - protected BigDecimal price; - protected BigDecimal orderFee; - protected String symbol; - -// public CustomOrderBean(OrderDataBean orderDataBean) { -// setCompletionDate(orderDataBean.getCompletionDate()); -// setOpenDate(orderDataBean.getOpenDate()); -// setOrderFee(orderDataBean.getOrderFee()); -// setOrderID(orderDataBean.getOrderID()); -// setOrderStatus(orderDataBean.getOrderStatus()); -// setOrderType(orderDataBean.getOrderType()); -// setPrice(orderDataBean.getPrice()); -// setQuantity(orderDataBean.getQuantity()); -// setSymbol(orderDataBean.getSymbol()); -// } - - public CustomOrderBean(int orderId, String orderType, String orderStatus, - Calendar openDate, Calendar 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); - } - - /** - * Constructs data instance for order information. - * - * @param accountId - * the account ID of the buyer or seller - * @param holdingId - * the ID of corresponding holding of the order - */ - public CustomOrderBean(int accountId, int holdingId) { - this.accountId = accountId; - this.holdingId = holdingId; - } - - public int getAccountId() { - return accountId; - } - - public void setAccountId(int accountId) { - this.accountId = accountId; - } - - public int getHoldingId() { - return holdingId; - } - - public void setHoldingId(int holdingId) { - this.holdingId = holdingId; - } - - public Integer getOrderID() { - return orderID; - } - - public void setOrderID(Integer orderID) { - this.orderID = orderID; - } - - public String getOrderType() { - return orderType; - } - - public void setOrderType(String orderType) { - this.orderType = orderType; - } - - public String getOrderStatus() { - return orderStatus; - } - - public void setOrderStatus(String orderStatus) { - this.orderStatus = orderStatus; - } - - public Calendar getOpenDate() { - return openDate; - } - - public void setOpenDate(Calendar openDate) { - this.openDate = openDate; - } - - public Calendar getCompletionDate() { - return completionDate; - } - - public void setCompletionDate(Calendar completionDate) { - this.completionDate = completionDate; - } - - public Double getQuantity() { - return quantity; - } - - public void setQuantity(Double quantity) { - this.quantity = quantity; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public BigDecimal getOrderFee() { - return orderFee; - } - - public void setOrderFee(BigDecimal orderFee) { - this.orderFee = orderFee; - } - - public String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader; + +import java.math.BigDecimal; +import java.util.Calendar; + +/** + * This class is to be used as the data model for order information. + */ +public class CustomOrderBean { + + private static final long serialVersionUID = 5294153874232419015L; + + int accountId; + int holdingId; + + protected Integer orderID; + protected String orderType; + protected String orderStatus; + protected Calendar openDate; + protected Calendar completionDate; + protected Double quantity; + protected BigDecimal price; + protected BigDecimal orderFee; + protected String symbol; + +// public CustomOrderBean(OrderDataBean orderDataBean) { +// setCompletionDate(orderDataBean.getCompletionDate()); +// setOpenDate(orderDataBean.getOpenDate()); +// setOrderFee(orderDataBean.getOrderFee()); +// setOrderID(orderDataBean.getOrderID()); +// setOrderStatus(orderDataBean.getOrderStatus()); +// setOrderType(orderDataBean.getOrderType()); +// setPrice(orderDataBean.getPrice()); +// setQuantity(orderDataBean.getQuantity()); +// setSymbol(orderDataBean.getSymbol()); +// } + + public CustomOrderBean(int orderId, String orderType, String orderStatus, + Calendar openDate, Calendar 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); + } + + /** + * Constructs data instance for order information. + * + * @param accountId + * the account ID of the buyer or seller + * @param holdingId + * the ID of corresponding holding of the order + */ + public CustomOrderBean(int accountId, int holdingId) { + this.accountId = accountId; + this.holdingId = holdingId; + } + + public int getAccountId() { + return accountId; + } + + public void setAccountId(int accountId) { + this.accountId = accountId; + } + + public int getHoldingId() { + return holdingId; + } + + public void setHoldingId(int holdingId) { + this.holdingId = holdingId; + } + + public Integer getOrderID() { + return orderID; + } + + public void setOrderID(Integer orderID) { + this.orderID = orderID; + } + + public String getOrderType() { + return orderType; + } + + public void setOrderType(String orderType) { + this.orderType = orderType; + } + + public String getOrderStatus() { + return orderStatus; + } + + public void setOrderStatus(String orderStatus) { + this.orderStatus = orderStatus; + } + + public Calendar getOpenDate() { + return openDate; + } + + public void setOpenDate(Calendar openDate) { + this.openDate = openDate; + } + + public Calendar getCompletionDate() { + return completionDate; + } + + public void setCompletionDate(Calendar completionDate) { + this.completionDate = completionDate; + } + + public Double getQuantity() { + return quantity; + } + + public void setQuantity(Double quantity) { + this.quantity = quantity; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BigDecimal getOrderFee() { + return orderFee; + } + + public void setOrderFee(BigDecimal orderFee) { + this.orderFee = orderFee; + } + + public String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomOrderBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomQuoteBean.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomQuoteBean.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomQuoteBean.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomQuoteBean.java Tue Jun 29 06:33:54 2010 @@ -1,129 +1,129 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader; - -import java.math.BigDecimal; - -/** - * This class to be used as the data model for quote information. - */ -public class CustomQuoteBean { - - private static final long serialVersionUID = 7129349720689180586L; - - protected String symbol; - protected String companyName; - protected BigDecimal price; - protected BigDecimal open; - protected BigDecimal low; - protected BigDecimal high; - protected Double change; - protected Double volume; - - public CustomQuoteBean() { - } - - /** - * Constructs an instance for quote information. - * - * @param symbol - * @param companyName - * @param volume - * @param price - * @param open - * @param low - * @param high - * @param change - */ - public CustomQuoteBean(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 String getSymbol() { - return symbol; - } - - public void setSymbol(String symbol) { - this.symbol = symbol; - } - - public String getCompanyName() { - return companyName; - } - - public void setCompanyName(String companyName) { - this.companyName = companyName; - } - - public BigDecimal getPrice() { - return price; - } - - public void setPrice(BigDecimal price) { - this.price = price; - } - - public BigDecimal getOpen() { - return open; - } - - public void setOpen(BigDecimal open) { - this.open = open; - } - - public BigDecimal getLow() { - return low; - } - - public void setLow(BigDecimal low) { - this.low = low; - } - - public BigDecimal getHigh() { - return high; - } - - public void setHigh(BigDecimal high) { - this.high = high; - } - - public Double getChange() { - return change; - } - - public void setChange(Double change) { - this.change = change; - } - - public Double getVolume() { - return volume; - } - - public void setVolume(Double volume) { - this.volume = volume; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader; + +import java.math.BigDecimal; + +/** + * This class to be used as the data model for quote information. + */ +public class CustomQuoteBean { + + private static final long serialVersionUID = 7129349720689180586L; + + protected String symbol; + protected String companyName; + protected BigDecimal price; + protected BigDecimal open; + protected BigDecimal low; + protected BigDecimal high; + protected Double change; + protected Double volume; + + public CustomQuoteBean() { + } + + /** + * Constructs an instance for quote information. + * + * @param symbol + * @param companyName + * @param volume + * @param price + * @param open + * @param low + * @param high + * @param change + */ + public CustomQuoteBean(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 String getSymbol() { + return symbol; + } + + public void setSymbol(String symbol) { + this.symbol = symbol; + } + + public String getCompanyName() { + return companyName; + } + + public void setCompanyName(String companyName) { + this.companyName = companyName; + } + + public BigDecimal getPrice() { + return price; + } + + public void setPrice(BigDecimal price) { + this.price = price; + } + + public BigDecimal getOpen() { + return open; + } + + public void setOpen(BigDecimal open) { + this.open = open; + } + + public BigDecimal getLow() { + return low; + } + + public void setLow(BigDecimal low) { + this.low = low; + } + + public BigDecimal getHigh() { + return high; + } + + public void setHigh(BigDecimal high) { + this.high = high; + } + + public Double getChange() { + return change; + } + + public void setChange(Double change) { + this.change = change; + } + + public Double getVolume() { + return volume; + } + + public void setVolume(Double volume) { + this.volume = volume; + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/CustomQuoteBean.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java Tue Jun 29 06:33:54 2010 @@ -1,69 +1,69 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.stonehenge.stocktrader.dal; - -import java.math.BigDecimal; -import java.util.List; - -import org.apache.stonehenge.stocktrader.CustomAccountBean; -import org.apache.stonehenge.stocktrader.CustomAccountProfileBean; -import org.apache.stonehenge.stocktrader.CustomOrderBean; -import org.apache.stonehenge.stocktrader.CustomHoldingBean; - -public interface CustomerDAO { - - public CustomHoldingBean getHoldingForUpdate(int orderId) - throws DAOException; - - public CustomHoldingBean getHolding(String userId, int holdingID) - throws DAOException; - - public void updateAccountBalance(int accountId, BigDecimal total) - throws DAOException; - - public CustomAccountBean login(String userId, String password) - throws DAOException; - - public void logoutUser(String userId) throws DAOException; - - public CustomAccountBean getCustomerByUserId(String userId) - throws DAOException; - - public CustomAccountProfileBean getAccountProfileData(String userId) - throws DAOException; - - public List<CustomOrderBean> getOrders(String userId, boolean top, - int maxTop, int maxDefault) throws DAOException; - - public List<CustomOrderBean> getClosedOrders(String userId) - throws DAOException; - - public void insertAccountProfile(CustomAccountProfileBean accountProfileBean) - throws DAOException; - - public void insertAccount(CustomAccountBean accountBean) - throws DAOException; - - public CustomAccountProfileBean update( - CustomAccountProfileBean customAccountProfile) throws DAOException; - - public List<CustomHoldingBean> getHoldings(String userID) - throws DAOException; - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.stonehenge.stocktrader.dal; + +import java.math.BigDecimal; +import java.util.List; + +import org.apache.stonehenge.stocktrader.CustomAccountBean; +import org.apache.stonehenge.stocktrader.CustomAccountProfileBean; +import org.apache.stonehenge.stocktrader.CustomOrderBean; +import org.apache.stonehenge.stocktrader.CustomHoldingBean; + +public interface CustomerDAO { + + public CustomHoldingBean getHoldingForUpdate(int orderId) + throws DAOException; + + public CustomHoldingBean getHolding(String userId, int holdingID) + throws DAOException; + + public void updateAccountBalance(int accountId, BigDecimal total) + throws DAOException; + + public CustomAccountBean login(String userId, String password) + throws DAOException; + + public void logoutUser(String userId) throws DAOException; + + public CustomAccountBean getCustomerByUserId(String userId) + throws DAOException; + + public CustomAccountProfileBean getAccountProfileData(String userId) + throws DAOException; + + public List<CustomOrderBean> getOrders(String userId, boolean top, + int maxTop, int maxDefault) throws DAOException; + + public List<CustomOrderBean> getClosedOrders(String userId) + throws DAOException; + + public void insertAccountProfile(CustomAccountProfileBean accountProfileBean) + throws DAOException; + + public void insertAccount(CustomAccountBean accountBean) + throws DAOException; + + public CustomAccountProfileBean update( + CustomAccountProfileBean customAccountProfile) throws DAOException; + + public List<CustomHoldingBean> getHoldings(String userID) + throws DAOException; + +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/CustomerDAO.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOException.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOException.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOException.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOException.java Tue Jun 29 06:33:54 2010 @@ -1,32 +1,32 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -package org.apache.stonehenge.stocktrader.dal; - -public class DAOException extends Exception { - - private static final long serialVersionUID = -3206469251941804179L; - - public DAOException(String message) { - super(message); - } - - public DAOException(String message, Throwable throwable) { - super(message, throwable); - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +package org.apache.stonehenge.stocktrader.dal; + +public class DAOException extends Exception { + + private static final long serialVersionUID = -3206469251941804179L; + + public DAOException(String message) { + super(message); + } + + public DAOException(String message, Throwable throwable) { + super(message, throwable); + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOException.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOFactory.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOFactory.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOFactory.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOFactory.java Tue Jun 29 06:33:54 2010 @@ -1,97 +1,97 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader.dal; - -import org.apache.stonehenge.stocktrader.mssql.MSSQLDAOFactory; -import org.apache.stonehenge.stocktrader.mysql.MySQLDAOFactory; -import org.apache.stonehenge.stocktrader.util.StockTraderUtility; - -import java.util.Properties; -import java.io.InputStream; -import java.io.IOException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -public abstract class DAOFactory { - public static final String PROP_DB_HOST = "org.apache.stonehenge.stocktrader.database.host"; - public static final String PROP_DB_PORT = "org.apache.stonehenge.stocktrader.database.port"; - public static final String PROP_DB_NAME = "org.apache.stonehenge.stocktrader.database.db"; - public static final String PROP_DB_USER = "org.apache.stonehenge.stocktrader.database.user"; - public static final String PROP_DB_PASSWORD = "org.apache.stonehenge.stocktrader.database.password"; - public static final String PROP_DB_TYPE = "org.apache.stonehenge.stocktrader.database.type"; - - public static Properties prop = null; - - public abstract CustomerDAO getCustomerDAO() throws DAOException; - - public abstract MarketSummaryDAO getMarketSummaryDAO() throws DAOException; - - public abstract OrderDAO getOrderDAO() throws DAOException; - - public static DAOFactory getFacotry() { - DAOFactory factory; - loadProperties(); - if ("mysql".equals(prop.getProperty(PROP_DB_TYPE))) { - factory = MySQLDAOFactory.getInstance(); - return factory; - } else if ("mssql".equals(prop.getProperty(PROP_DB_TYPE))) { - factory = MSSQLDAOFactory.getInstance(); - return factory; - } else { - throw new IllegalArgumentException("Unknown Database type " + prop.getProperty(PROP_DB_TYPE)); - } - } - - public static void loadProperties() { - Log logger = LogFactory.getLog(DAOFactory.class); - if (prop == null) { - prop = new Properties(); -// MessageContext messageContext = MessageContext.getCurrentMessageContext(); -// if (messageContext != null) { -// AxisService service = messageContext.getAxisService(); -// ClassLoader serviceClassLoader = service.getClassLoader(); -// InputStream is = serviceClassLoader.getResourceAsStream(StockTraderUtility.DB_PROPERRTIES_FILE); -// if (is != null) { -// try { -// prop.load(is); -// } catch (IOException e) { -// logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection",e); -// } -// } else { -// logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection"); -// -// } -// } - - InputStream is = DAOFactory.class.getClassLoader() - .getResourceAsStream(StockTraderUtility.DB_PROPERRTIES_FILE); - if (is != null) { - try { - prop.load(is); - } catch (IOException e) { - logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection", e); - } - } else { - logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection"); - - } - } - } - +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader.dal; + +import org.apache.stonehenge.stocktrader.mssql.MSSQLDAOFactory; +import org.apache.stonehenge.stocktrader.mysql.MySQLDAOFactory; +import org.apache.stonehenge.stocktrader.util.StockTraderUtility; + +import java.util.Properties; +import java.io.InputStream; +import java.io.IOException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public abstract class DAOFactory { + public static final String PROP_DB_HOST = "org.apache.stonehenge.stocktrader.database.host"; + public static final String PROP_DB_PORT = "org.apache.stonehenge.stocktrader.database.port"; + public static final String PROP_DB_NAME = "org.apache.stonehenge.stocktrader.database.db"; + public static final String PROP_DB_USER = "org.apache.stonehenge.stocktrader.database.user"; + public static final String PROP_DB_PASSWORD = "org.apache.stonehenge.stocktrader.database.password"; + public static final String PROP_DB_TYPE = "org.apache.stonehenge.stocktrader.database.type"; + + public static Properties prop = null; + + public abstract CustomerDAO getCustomerDAO() throws DAOException; + + public abstract MarketSummaryDAO getMarketSummaryDAO() throws DAOException; + + public abstract OrderDAO getOrderDAO() throws DAOException; + + public static DAOFactory getFacotry() { + DAOFactory factory; + loadProperties(); + if ("mysql".equals(prop.getProperty(PROP_DB_TYPE))) { + factory = MySQLDAOFactory.getInstance(); + return factory; + } else if ("mssql".equals(prop.getProperty(PROP_DB_TYPE))) { + factory = MSSQLDAOFactory.getInstance(); + return factory; + } else { + throw new IllegalArgumentException("Unknown Database type " + prop.getProperty(PROP_DB_TYPE)); + } + } + + public static void loadProperties() { + Log logger = LogFactory.getLog(DAOFactory.class); + if (prop == null) { + prop = new Properties(); +// MessageContext messageContext = MessageContext.getCurrentMessageContext(); +// if (messageContext != null) { +// AxisService service = messageContext.getAxisService(); +// ClassLoader serviceClassLoader = service.getClassLoader(); +// InputStream is = serviceClassLoader.getResourceAsStream(StockTraderUtility.DB_PROPERRTIES_FILE); +// if (is != null) { +// try { +// prop.load(is); +// } catch (IOException e) { +// logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection",e); +// } +// } else { +// logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection"); +// +// } +// } + + InputStream is = DAOFactory.class.getClassLoader() + .getResourceAsStream(StockTraderUtility.DB_PROPERRTIES_FILE); + if (is != null) { + try { + prop.load(is); + } catch (IOException e) { + logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection", e); + } + } else { + logger.debug("Unable to load mysql-db properties file and using [jdbc:mysql://localhost/stocktraderdb?user=trade&password=trade] as the default connection"); + + } + } + } + } \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/DAOFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/MarketSummaryDAO.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/MarketSummaryDAO.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/MarketSummaryDAO.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/MarketSummaryDAO.java Tue Jun 29 06:33:54 2010 @@ -1,36 +1,36 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader.dal; - -import org.apache.stonehenge.stocktrader.CustomMarketSummaryBean; -import org.apache.stonehenge.stocktrader.CustomQuoteBean; - -public interface MarketSummaryDAO { - - public CustomQuoteBean getQuote(String symbol) throws DAOException; - - public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException; - - public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) - throws DAOException; - - public CustomMarketSummaryBean getCustomMarketSummary() throws DAOException; - - - -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader.dal; + +import org.apache.stonehenge.stocktrader.CustomMarketSummaryBean; +import org.apache.stonehenge.stocktrader.CustomQuoteBean; + +public interface MarketSummaryDAO { + + public CustomQuoteBean getQuote(String symbol) throws DAOException; + + public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException; + + public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) + throws DAOException; + + public CustomMarketSummaryBean getCustomMarketSummary() throws DAOException; + + + +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/MarketSummaryDAO.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/OrderDAO.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/OrderDAO.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/OrderDAO.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/OrderDAO.java Tue Jun 29 06:33:54 2010 @@ -1,63 +1,63 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader.dal; - -import java.math.BigDecimal; - -import org.apache.stonehenge.stocktrader.CustomHoldingBean; -import org.apache.stonehenge.stocktrader.CustomOrderBean; -import org.apache.stonehenge.stocktrader.CustomQuoteBean; - -public interface OrderDAO { - - public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException; - - public int createHolding(CustomOrderBean order) throws DAOException; - - public void updateHolding(int holdingId, double quantity) - throws DAOException; - - public void deleteHolding(int holdingId) throws DAOException; - - public CustomHoldingBean getHoldingForUpdate(int orderId) - throws DAOException; - - public CustomHoldingBean getHolding(int holdingId) throws DAOException; - - public void updateAccountBalance(int accountId, BigDecimal total) - throws DAOException; - - public CustomOrderBean createOrder(String userID, String symbol, - String orderType, double quantity, int holdingID) - throws DAOException; - - public void updateOrder(CustomOrderBean order) throws DAOException; - - public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) - throws DAOException; - - public void closeOrder(CustomOrderBean order) throws DAOException; - - public void beginTransaction() throws DAOException; - - public void commitTransaction() throws DAOException; - - public void rollbackTransaction() throws DAOException; - - public void close() throws DAOException; -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader.dal; + +import java.math.BigDecimal; + +import org.apache.stonehenge.stocktrader.CustomHoldingBean; +import org.apache.stonehenge.stocktrader.CustomOrderBean; +import org.apache.stonehenge.stocktrader.CustomQuoteBean; + +public interface OrderDAO { + + public CustomQuoteBean getQuoteForUpdate(String symbol) throws DAOException; + + public int createHolding(CustomOrderBean order) throws DAOException; + + public void updateHolding(int holdingId, double quantity) + throws DAOException; + + public void deleteHolding(int holdingId) throws DAOException; + + public CustomHoldingBean getHoldingForUpdate(int orderId) + throws DAOException; + + public CustomHoldingBean getHolding(int holdingId) throws DAOException; + + public void updateAccountBalance(int accountId, BigDecimal total) + throws DAOException; + + public CustomOrderBean createOrder(String userID, String symbol, + String orderType, double quantity, int holdingID) + throws DAOException; + + public void updateOrder(CustomOrderBean order) throws DAOException; + + public void updateStockPriceVolume(double quantity, CustomQuoteBean quote) + throws DAOException; + + public void closeOrder(CustomOrderBean order) throws DAOException; + + public void beginTransaction() throws DAOException; + + public void commitTransaction() throws DAOException; + + public void rollbackTransaction() throws DAOException; + + public void close() throws DAOException; +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/dal/OrderDAO.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/mssql/AbstractMSSQLDAO.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/mssql/AbstractMSSQLDAO.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/mssql/AbstractMSSQLDAO.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/mssql/AbstractMSSQLDAO.java Tue Jun 29 06:33:54 2010 @@ -1,87 +1,87 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.stonehenge.stocktrader.mssql; - -import java.sql.Connection; -import java.sql.SQLException; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stonehenge.stocktrader.dal.DAOException; - -public class AbstractMSSQLDAO { - - private static final Log logger = LogFactory.getLog(AbstractMSSQLDAO.class); - - protected Connection sqlConnection; - - private int previousTransactionIsolation; - - public AbstractMSSQLDAO(Connection sqlConnection) throws DAOException { - this.sqlConnection = sqlConnection; - } - - public void beginTransaction() throws DAOException { - logger.debug("AbstractMSSQLDAO.beginTransaction()"); - try { - sqlConnection.setAutoCommit(false); - previousTransactionIsolation = sqlConnection - .getTransactionIsolation(); - sqlConnection - .setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); - } catch (SQLException e) { - e.printStackTrace(); - logger.debug("", e); - throw new DAOException( - "Exception was thrown during the start of transaction", e); - } - } - - public void commitTransaction() throws DAOException { - logger.debug("AbstractMSSQLDAO.commitTransaction()"); - try { - sqlConnection.commit(); - sqlConnection.setAutoCommit(true); - sqlConnection.setTransactionIsolation(previousTransactionIsolation); - } catch (SQLException e) { - throw new DAOException( - "Exception is thrown during the commit of transaction", e); - } - } - - public void rollbackTransaction() throws DAOException { - logger.debug("AbstractMSSQLDAO.rollbackTransaction()"); - try { - sqlConnection.rollback(); - sqlConnection.setAutoCommit(true); - sqlConnection.setTransactionIsolation(previousTransactionIsolation); - } catch (SQLException e) { - throw new DAOException( - "Exception is thrown during the rollback of transaction", e); - - } - } - - public void close() throws DAOException { - try { - sqlConnection.close(); - } catch (SQLException e) { - throw new DAOException("", e); - } - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stonehenge.stocktrader.mssql; + +import java.sql.Connection; +import java.sql.SQLException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stonehenge.stocktrader.dal.DAOException; + +public class AbstractMSSQLDAO { + + private static final Log logger = LogFactory.getLog(AbstractMSSQLDAO.class); + + protected Connection sqlConnection; + + private int previousTransactionIsolation; + + public AbstractMSSQLDAO(Connection sqlConnection) throws DAOException { + this.sqlConnection = sqlConnection; + } + + public void beginTransaction() throws DAOException { + logger.debug("AbstractMSSQLDAO.beginTransaction()"); + try { + sqlConnection.setAutoCommit(false); + previousTransactionIsolation = sqlConnection + .getTransactionIsolation(); + sqlConnection + .setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); + } catch (SQLException e) { + e.printStackTrace(); + logger.debug("", e); + throw new DAOException( + "Exception was thrown during the start of transaction", e); + } + } + + public void commitTransaction() throws DAOException { + logger.debug("AbstractMSSQLDAO.commitTransaction()"); + try { + sqlConnection.commit(); + sqlConnection.setAutoCommit(true); + sqlConnection.setTransactionIsolation(previousTransactionIsolation); + } catch (SQLException e) { + throw new DAOException( + "Exception is thrown during the commit of transaction", e); + } + } + + public void rollbackTransaction() throws DAOException { + logger.debug("AbstractMSSQLDAO.rollbackTransaction()"); + try { + sqlConnection.rollback(); + sqlConnection.setAutoCommit(true); + sqlConnection.setTransactionIsolation(previousTransactionIsolation); + } catch (SQLException e) { + throw new DAOException( + "Exception is thrown during the rollback of transaction", e); + + } + } + + public void close() throws DAOException { + try { + sqlConnection.close(); + } catch (SQLException e) { + throw new DAOException("", e); + } + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/common/src/org/apache/stonehenge/stocktrader/mssql/AbstractMSSQLDAO.java ------------------------------------------------------------------------------ svn:eol-style = native