From stonehenge-commits-return-624-apmail-incubator-stonehenge-commits-archive=incubator.apache.org@incubator.apache.org Tue Jun 29 06:35:41 2010 Return-Path: Delivered-To: apmail-incubator-stonehenge-commits-archive@minotaur.apache.org Received: (qmail 39318 invoked from network); 29 Jun 2010 06:35:40 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Jun 2010 06:35:40 -0000 Received: (qmail 35965 invoked by uid 500); 29 Jun 2010 06:35:40 -0000 Delivered-To: apmail-incubator-stonehenge-commits-archive@incubator.apache.org Received: (qmail 35926 invoked by uid 500); 29 Jun 2010 06:35:40 -0000 Mailing-List: contact stonehenge-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stonehenge-dev@incubator.apache.org Delivered-To: mailing list stonehenge-commits@incubator.apache.org Received: (qmail 35917 invoked by uid 99); 29 Jun 2010 06:35:40 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 06:35:40 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Jun 2010 06:35:24 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 8C4202388C14; Tue, 29 Jun 2010 06:34:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r958838 [10/42] - in /incubator/stonehenge/trunk/stocktrader: dotnet/ dotnet/setup_utilities/Util/ metro/ metro/active_sts/ metro/active_sts/etc/ metro/active_sts/src/org/apache/stonehenge/stocktrader/sts/ metro/business_service/ metro/busi... Date: Tue, 29 Jun 2010 06:33:57 -0000 To: stonehenge-commits@incubator.apache.org From: chintana@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100629063400.8C4202388C14@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd1.xsd URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd1.xsd?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd1.xsd (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd1.xsd Tue Jun 29 06:33:54 2010 @@ -1,62 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd1.xsd ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd2.xsd URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd2.xsd?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd2.xsd (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd2.xsd Tue Jun 29 06:33:54 2010 @@ -1,98 +1,98 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/config_service/xsd2.xsd ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-jaxbbean.xml URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-jaxbbean.xml?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-jaxbbean.xml (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-jaxbbean.xml Tue Jun 29 06:33:54 2010 @@ -1,38 +1,38 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-jaxbbean.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-sei.xml URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-sei.xml?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-sei.xml (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-sei.xml Tue Jun 29 06:33:54 2010 @@ -1,30 +1,30 @@ - - - - - - false - - + + + + + + false + + Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/custom-sei.xml ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd0.xsd URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd0.xsd?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd0.xsd (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd0.xsd Tue Jun 29 06:33:54 2010 @@ -1,37 +1,37 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd0.xsd ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd1.xsd URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd1.xsd?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd1.xsd (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd1.xsd Tue Jun 29 06:33:54 2010 @@ -1,62 +1,62 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd1.xsd ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd2.xsd URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd2.xsd?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd2.xsd (original) +++ incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd2.xsd Tue Jun 29 06:33:54 2010 @@ -1,36 +1,36 @@ - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/etc/order_processor/xsd2.xsd ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/build.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/etc/sun-jaxws.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/etc/web.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/BeanFactory.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/UsernamePasswordValidator.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/UsernamePasswordValidator.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/UsernamePasswordValidator.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/UsernamePasswordValidator.java Tue Jun 29 06:33:54 2010 @@ -1,42 +1,42 @@ -/* - * 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 com.sun.xml.wss.impl.callback.PasswordValidationCallback; -import org.apache.stonehenge.stocktrader.dal.CustomerDAO; -import org.apache.stonehenge.stocktrader.dal.DAOException; -import org.apache.stonehenge.stocktrader.dal.DAOFactory; - -public class UsernamePasswordValidator implements PasswordValidationCallback.PasswordValidator { - public boolean validate(PasswordValidationCallback.Request request) throws - PasswordValidationCallback.PasswordValidationException { - PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = - (PasswordValidationCallback.PlainTextPasswordRequest) request; - try { - CustomerDAO user = DAOFactory.getFacotry().getCustomerDAO(); - CustomAccountProfileBean profileBean = user.getAccountProfileData(plainTextRequest.getUsername()); - if (profileBean != null && profileBean.getPassword().equals(plainTextRequest.getPassword())) { - return true; - } - } catch (DAOException e) { - e.printStackTrace(); - return false; - } - return false; - } -} +/* + * 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 com.sun.xml.wss.impl.callback.PasswordValidationCallback; +import org.apache.stonehenge.stocktrader.dal.CustomerDAO; +import org.apache.stonehenge.stocktrader.dal.DAOException; +import org.apache.stonehenge.stocktrader.dal.DAOFactory; + +public class UsernamePasswordValidator implements PasswordValidationCallback.PasswordValidator { + public boolean validate(PasswordValidationCallback.Request request) throws + PasswordValidationCallback.PasswordValidationException { + PasswordValidationCallback.PlainTextPasswordRequest plainTextRequest = + (PasswordValidationCallback.PlainTextPasswordRequest) request; + try { + CustomerDAO user = DAOFactory.getFacotry().getCustomerDAO(); + CustomAccountProfileBean profileBean = user.getAccountProfileData(plainTextRequest.getUsername()); + if (profileBean != null && profileBean.getPassword().equals(plainTextRequest.getPassword())) { + return true; + } + } catch (DAOException e) { + e.printStackTrace(); + return false; + } + return false; + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/UsernamePasswordValidator.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessManager.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessManager.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessManager.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessManager.java Tue Jun 29 06:33:54 2010 @@ -1,186 +1,186 @@ -/* - * 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.service; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stonehenge.stocktrader.CustomHoldingBean; -import org.apache.stonehenge.stocktrader.CustomOrderBean; -import org.apache.stonehenge.stocktrader.CustomQuoteBean; -import org.apache.stonehenge.stocktrader.dal.DAOException; -import org.apache.stonehenge.stocktrader.dal.DAOFactory; -import org.apache.stonehenge.stocktrader.dal.OrderDAO; -import org.apache.stonehenge.stocktrader.util.StockTraderUtility; - -import java.math.BigDecimal; -import java.util.Calendar; - -public class OrderProcessManager { - private static final Log logger = LogFactory - .getLog(OrderProcessManager.class); - - private OrderDAO orderDAO = null; - - public void processAndCompleteOrder(CustomOrderBean order) - throws DAOException { - if (logger.isDebugEnabled()) { - logger - .debug("ProcessOrder.processAndCompleteOrder(OrderDataModel) \nOrderID :" - + order.getOrderID() - + "\nOrderType :" - + order.getOrderType() - + "\nSymbol :" - + order.getSymbol() - + "\nQuantity :" - + order.getQuantity() - + "\nOrder Status :" - + order.getOrderStatus() - + "\nOrder Open Date :" - + order.getOpenDate() - + "\nCompletionDate :" - + order.getCompletionDate()); - } - - try { - DAOFactory factory = DAOFactory - .getFacotry(); - - orderDAO = factory.getOrderDAO(); - orderDAO.beginTransaction(); - - BigDecimal total = null; - int holdingId = -1; - - CustomQuoteBean quote = orderDAO.getQuoteForUpdate(order.getSymbol()); - if (quote == null) { - if (logger.isDebugEnabled()) { - logger - .debug("Unable to locate a quote entry for the symbol :" - + order.getSymbol()); - } - return; - } - - order.setPrice(quote.getPrice()); - - if (StockTraderUtility.ORDER_TYPE_BUY.equals(order.getOrderType())) { - holdingId = orderDAO.createHolding(order); - BigDecimal orderQuantity = BigDecimal.valueOf(order - .getQuantity()); - BigDecimal orderPrice = order.getPrice(); - total = orderQuantity.multiply(orderPrice); - - BigDecimal orderFee = order.getOrderFee(); - if (orderFee != null) { - total = total.add(orderFee); - } - - } else if (StockTraderUtility.ORDER_TYPE_SELL.equals(order - .getOrderType())) { - holdingId = sellHolding(order); - if (holdingId == -1) { - return; - } - - BigDecimal orderQuantity = BigDecimal.valueOf(-1 - * order.getQuantity()); - BigDecimal orderPrice = order.getPrice(); - total = orderQuantity.multiply(orderPrice); - - BigDecimal orderFee = order.getOrderFee(); - if (total != null) { - total = total.add(orderFee); - } - } - - orderDAO.updateAccountBalance(order.getAccountId(), total); - orderDAO.updateStockPriceVolume(order.getQuantity(), quote); - order.setOrderStatus(StockTraderUtility.ORDER_STATUS_CLOSED); - order.setCompletionDate(Calendar.getInstance()); - order.setHoldingId(holdingId); - orderDAO.closeOrder(order); - orderDAO.commitTransaction(); - - } catch (DAOException e) { - try { - orderDAO.rollbackTransaction(); - } catch (DAOException e1) { - logger.error("", e1); - } - } finally { - if (orderDAO != null) { - try { - orderDAO.close(); - } catch (DAOException e) { - logger.error("", e); - } - } - } - } - - private int sellHolding(CustomOrderBean order) throws DAOException { - if (logger.isDebugEnabled()) { - logger.debug("ProcessOrder.sellHolding(OrderDataModel) \nOrderID :" - + order.getOrderID() + "\nOrderType :" - + order.getOrderType() + "\nSymbol :" + order.getSymbol() - + "\nQuantity :" + order.getQuantity() + "\nOrder Status :" - + order.getOrderStatus() + "\nOrder Open Date :" - + order.getOpenDate() + "\nCompletionDate :" - + order.getCompletionDate()); - } - - CustomHoldingBean holding = orderDAO.getHoldingForUpdate(order.getOrderID()); - - if (holding == null) { - // TODO : DAOException .. - throw new RuntimeException( - "Unable to locate a holding entry for orderID :" - + order.getOrderID()); - } - order.setAccountId(holding.getAccountID()); - - // There are three distinct business cases here, each needs different - // treatment: - // a) Quantity requested is less than total shares in the holding -- - // update holding. - // b) Quantity requested is equal to total shares in the holding -- - // delete holding. - // c) Quantity requested is greater than total shares in the holding -- - // delete holding, update order table. - - if (order.getQuantity() < holding.getQuantity()) { - orderDAO.updateHolding(holding.getHoldingID(), order.getQuantity()); - - } else if (holding.getQuantity() == order.getQuantity()) { - orderDAO.deleteHolding(holding.getHoldingID()); - - } else if (order.getQuantity() > holding.getQuantity()) { - // We now need to back-update the order record quantity to reflect - // fact not all shares originally requested were sold since the - // holding had less shares in it, perhaps due to other orders placed - // against that holding that completed before this one. So we will - // sell the remaining shares, but need to update the final order to - // reflect this. - orderDAO.deleteHolding(holding.getHoldingID()); - order.setQuantity(holding.getQuantity()); - order.setAccountId(holding.getAccountID()); - orderDAO.updateOrder(order); - } - return holding.getHoldingID(); - } -} +/* + * 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.service; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stonehenge.stocktrader.CustomHoldingBean; +import org.apache.stonehenge.stocktrader.CustomOrderBean; +import org.apache.stonehenge.stocktrader.CustomQuoteBean; +import org.apache.stonehenge.stocktrader.dal.DAOException; +import org.apache.stonehenge.stocktrader.dal.DAOFactory; +import org.apache.stonehenge.stocktrader.dal.OrderDAO; +import org.apache.stonehenge.stocktrader.util.StockTraderUtility; + +import java.math.BigDecimal; +import java.util.Calendar; + +public class OrderProcessManager { + private static final Log logger = LogFactory + .getLog(OrderProcessManager.class); + + private OrderDAO orderDAO = null; + + public void processAndCompleteOrder(CustomOrderBean order) + throws DAOException { + if (logger.isDebugEnabled()) { + logger + .debug("ProcessOrder.processAndCompleteOrder(OrderDataModel) \nOrderID :" + + order.getOrderID() + + "\nOrderType :" + + order.getOrderType() + + "\nSymbol :" + + order.getSymbol() + + "\nQuantity :" + + order.getQuantity() + + "\nOrder Status :" + + order.getOrderStatus() + + "\nOrder Open Date :" + + order.getOpenDate() + + "\nCompletionDate :" + + order.getCompletionDate()); + } + + try { + DAOFactory factory = DAOFactory + .getFacotry(); + + orderDAO = factory.getOrderDAO(); + orderDAO.beginTransaction(); + + BigDecimal total = null; + int holdingId = -1; + + CustomQuoteBean quote = orderDAO.getQuoteForUpdate(order.getSymbol()); + if (quote == null) { + if (logger.isDebugEnabled()) { + logger + .debug("Unable to locate a quote entry for the symbol :" + + order.getSymbol()); + } + return; + } + + order.setPrice(quote.getPrice()); + + if (StockTraderUtility.ORDER_TYPE_BUY.equals(order.getOrderType())) { + holdingId = orderDAO.createHolding(order); + BigDecimal orderQuantity = BigDecimal.valueOf(order + .getQuantity()); + BigDecimal orderPrice = order.getPrice(); + total = orderQuantity.multiply(orderPrice); + + BigDecimal orderFee = order.getOrderFee(); + if (orderFee != null) { + total = total.add(orderFee); + } + + } else if (StockTraderUtility.ORDER_TYPE_SELL.equals(order + .getOrderType())) { + holdingId = sellHolding(order); + if (holdingId == -1) { + return; + } + + BigDecimal orderQuantity = BigDecimal.valueOf(-1 + * order.getQuantity()); + BigDecimal orderPrice = order.getPrice(); + total = orderQuantity.multiply(orderPrice); + + BigDecimal orderFee = order.getOrderFee(); + if (total != null) { + total = total.add(orderFee); + } + } + + orderDAO.updateAccountBalance(order.getAccountId(), total); + orderDAO.updateStockPriceVolume(order.getQuantity(), quote); + order.setOrderStatus(StockTraderUtility.ORDER_STATUS_CLOSED); + order.setCompletionDate(Calendar.getInstance()); + order.setHoldingId(holdingId); + orderDAO.closeOrder(order); + orderDAO.commitTransaction(); + + } catch (DAOException e) { + try { + orderDAO.rollbackTransaction(); + } catch (DAOException e1) { + logger.error("", e1); + } + } finally { + if (orderDAO != null) { + try { + orderDAO.close(); + } catch (DAOException e) { + logger.error("", e); + } + } + } + } + + private int sellHolding(CustomOrderBean order) throws DAOException { + if (logger.isDebugEnabled()) { + logger.debug("ProcessOrder.sellHolding(OrderDataModel) \nOrderID :" + + order.getOrderID() + "\nOrderType :" + + order.getOrderType() + "\nSymbol :" + order.getSymbol() + + "\nQuantity :" + order.getQuantity() + "\nOrder Status :" + + order.getOrderStatus() + "\nOrder Open Date :" + + order.getOpenDate() + "\nCompletionDate :" + + order.getCompletionDate()); + } + + CustomHoldingBean holding = orderDAO.getHoldingForUpdate(order.getOrderID()); + + if (holding == null) { + // TODO : DAOException .. + throw new RuntimeException( + "Unable to locate a holding entry for orderID :" + + order.getOrderID()); + } + order.setAccountId(holding.getAccountID()); + + // There are three distinct business cases here, each needs different + // treatment: + // a) Quantity requested is less than total shares in the holding -- + // update holding. + // b) Quantity requested is equal to total shares in the holding -- + // delete holding. + // c) Quantity requested is greater than total shares in the holding -- + // delete holding, update order table. + + if (order.getQuantity() < holding.getQuantity()) { + orderDAO.updateHolding(holding.getHoldingID(), order.getQuantity()); + + } else if (holding.getQuantity() == order.getQuantity()) { + orderDAO.deleteHolding(holding.getHoldingID()); + + } else if (order.getQuantity() > holding.getQuantity()) { + // We now need to back-update the order record quantity to reflect + // fact not all shares originally requested were sold since the + // holding had less shares in it, perhaps due to other orders placed + // against that holding that completed before this one. So we will + // sell the remaining shares, but need to update the final order to + // reflect this. + orderDAO.deleteHolding(holding.getHoldingID()); + order.setQuantity(holding.getQuantity()); + order.setAccountId(holding.getAccountID()); + orderDAO.updateOrder(order); + } + return holding.getHoldingID(); + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessManager.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessorImpl.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessorImpl.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessorImpl.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessorImpl.java Tue Jun 29 06:33:54 2010 @@ -1,66 +1,66 @@ -/* - * 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.service; - -import org.tempuri.OrderProcessorService; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.stonehenge.stocktrader.CustomOrderBean; -import org.apache.stonehenge.stocktrader.BeanFactory; -import org.apache.stonehenge.stocktrader.util.OrderProcessorUtility; -import org.apache.stonehenge.stocktrader.dal.DAOException; - -import javax.jws.WebParam; -import javax.jws.WebService; - -import traderorderhost.trade.SubmitOrder; -import traderorderhost.trade.IsOnline; -import com.ibm.websphere.samples.trade.OrderDataBean; - -@WebService(endpointInterface = "org.tempuri.OrderProcessorService") -public class OrderProcessorImpl implements OrderProcessorService { - private static final Log logger = LogFactory - .getLog(OrderProcessorImpl.class); - // OrderProcessManager is the controller for managing order processing. - private final OrderProcessManager orderProcessManager = new OrderProcessManager(); - private final BeanFactory factory = new BeanFactory(); - - public void submitOrder(@WebParam(name = "SubmitOrder", targetNamespace = "http://Trade.TraderOrderHost", partName = - "parameters") SubmitOrder submitOrder) { - OrderDataBean order = submitOrder.getOrder(); - CustomOrderBean orderData = factory.toCustomOrderBean(order); - try { - processOrder(orderData); - } catch (DAOException e) { - logger.error("", e); - } - } - - public void isOnline(@WebParam(name = "isOnline", targetNamespace = "http://Trade.TraderOrderHost", partName = - "parameters") IsOnline parameters) { - logger.debug("OrderProcessorImpl.isOnline(IsOnlines)"); - } - - private void processOrder(CustomOrderBean queueOrder) throws DAOException { - // 2 seconds delay to ensure that MSFT-BL has committed new order - // entries to the database which will happen when it gets HTTP 202 - // accepted header - OrderProcessorUtility.pauseForTwoSeconds(); - orderProcessManager.processAndCompleteOrder(queueOrder); - } -} +/* + * 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.service; + +import org.tempuri.OrderProcessorService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.stonehenge.stocktrader.CustomOrderBean; +import org.apache.stonehenge.stocktrader.BeanFactory; +import org.apache.stonehenge.stocktrader.util.OrderProcessorUtility; +import org.apache.stonehenge.stocktrader.dal.DAOException; + +import javax.jws.WebParam; +import javax.jws.WebService; + +import traderorderhost.trade.SubmitOrder; +import traderorderhost.trade.IsOnline; +import com.ibm.websphere.samples.trade.OrderDataBean; + +@WebService(endpointInterface = "org.tempuri.OrderProcessorService") +public class OrderProcessorImpl implements OrderProcessorService { + private static final Log logger = LogFactory + .getLog(OrderProcessorImpl.class); + // OrderProcessManager is the controller for managing order processing. + private final OrderProcessManager orderProcessManager = new OrderProcessManager(); + private final BeanFactory factory = new BeanFactory(); + + public void submitOrder(@WebParam(name = "SubmitOrder", targetNamespace = "http://Trade.TraderOrderHost", partName = + "parameters") SubmitOrder submitOrder) { + OrderDataBean order = submitOrder.getOrder(); + CustomOrderBean orderData = factory.toCustomOrderBean(order); + try { + processOrder(orderData); + } catch (DAOException e) { + logger.error("", e); + } + } + + public void isOnline(@WebParam(name = "isOnline", targetNamespace = "http://Trade.TraderOrderHost", partName = + "parameters") IsOnline parameters) { + logger.debug("OrderProcessorImpl.isOnline(IsOnlines)"); + } + + private void processOrder(CustomOrderBean queueOrder) throws DAOException { + // 2 seconds delay to ensure that MSFT-BL has committed new order + // entries to the database which will happen when it gets HTTP 202 + // accepted header + OrderProcessorUtility.pauseForTwoSeconds(); + orderProcessManager.processAndCompleteOrder(queueOrder); + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/service/OrderProcessorImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/util/OrderProcessorUtility.java URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/util/OrderProcessorUtility.java?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/util/OrderProcessorUtility.java (original) +++ incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/util/OrderProcessorUtility.java Tue Jun 29 06:33:54 2010 @@ -1,40 +1,40 @@ -/* - * 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.util; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * A class which contains utility functions for order processing. - */ -public class OrderProcessorUtility { - private static final Log logger = LogFactory - .getLog(OrderProcessorUtility.class); - - public static void pauseForTwoSeconds() { - logger.debug("OrderProcessorImpl.sleepForTwoSec()"); - try { - Thread.sleep(2 * 1000); - } catch (InterruptedException e) { - if (logger.isDebugEnabled()) { - logger.debug("Unable to sleep for 2 sec", 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.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +/** + * A class which contains utility functions for order processing. + */ +public class OrderProcessorUtility { + private static final Log logger = LogFactory + .getLog(OrderProcessorUtility.class); + + public static void pauseForTwoSeconds() { + logger.debug("OrderProcessorImpl.sleepForTwoSec()"); + try { + Thread.sleep(2 * 1000); + } catch (InterruptedException e) { + if (logger.isDebugEnabled()) { + logger.debug("Unable to sleep for 2 sec", e); + } + } + } +} Propchange: incubator/stonehenge/trunk/stocktrader/metro/order_processor/src/org/apache/stonehenge/stocktrader/util/OrderProcessorUtility.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: incubator/stonehenge/trunk/stocktrader/metro/resources/conf/TradeServiceConfig.properties URL: http://svn.apache.org/viewvc/incubator/stonehenge/trunk/stocktrader/metro/resources/conf/TradeServiceConfig.properties?rev=958838&r1=958837&r2=958838&view=diff ============================================================================== --- incubator/stonehenge/trunk/stocktrader/metro/resources/conf/TradeServiceConfig.properties (original) +++ incubator/stonehenge/trunk/stocktrader/metro/resources/conf/TradeServiceConfig.properties Tue Jun 29 06:33:54 2010 @@ -1,16 +1,16 @@ -# 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. - +# 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. + org.apache.stonehenge.stocktrader.TradeConfigService.url=http://localhost:8091/config_service/ConfigService \ No newline at end of file Propchange: incubator/stonehenge/trunk/stocktrader/metro/resources/conf/TradeServiceConfig.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/stonehenge/trunk/stocktrader/metro/resources/conf/db.properties ------------------------------------------------------------------------------ svn:eol-style = native