001    /**
002     *  Licensed to the Apache Software Foundation (ASF) under one or more
003     *  contributor license agreements.  See the NOTICE file distributed with
004     *  this work for additional information regarding copyright ownership.
005     *  The ASF licenses this file to You under the Apache License, Version 2.0
006     *  (the "License"); you may not use this file except in compliance with
007     *  the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     *  Unless required by applicable law or agreed to in writing, software
012     *  distributed under the License is distributed on an "AS IS" BASIS,
013     *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     *  See the License for the specific language governing permissions and
015     *  limitations under the License.
016     */
017    package org.apache.geronimo.samples.daytrader;
018    
019    import java.math.BigDecimal;
020    import java.rmi.RemoteException;
021    
022    /**
023     * @author aspyker
024     *
025     * This is a TradeAction wrapper to handle web service handling
026     * of collections.  Instead this class uses typed arrays.
027     */
028    public class TradeWSAction {
029            TradeAction trade;
030            
031            public TradeWSAction() {
032                    trade = new TradeAction();
033            }
034    
035            public MarketSummaryDataBeanWS getMarketSummary() throws Exception, RemoteException {
036                    org.apache.geronimo.samples.daytrader.MarketSummaryDataBean marketSummary = trade.getMarketSummary();
037                    return MarketSummaryDataBeanWS.convertBean(marketSummary);
038            }
039            
040            public OrderDataBean buy(String userID, String symbol, double quantity, int orderProcessingMode) throws Exception, RemoteException {
041                    return trade.buy(userID, symbol, quantity, orderProcessingMode);
042            }
043            
044            public OrderDataBean sell(String userID, Integer holdingID, int orderProcessingMode) throws Exception, RemoteException {
045                    return trade.sell(userID, holdingID, orderProcessingMode);
046            }
047    
048            public void queueOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
049                    trade.queueOrder(orderID, twoPhase);
050            }
051            
052            public OrderDataBean completeOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
053                    return trade.completeOrder(orderID, twoPhase);
054            }
055    
056            public void cancelOrder(Integer orderID, boolean twoPhase) throws Exception, RemoteException {
057                    trade.cancelOrder(orderID, twoPhase);
058            }
059            
060            public void orderCompleted(String userID, Integer orderID) throws Exception, RemoteException {
061                    trade.orderCompleted(userID, orderID);
062            }
063            
064            public OrderDataBean[] getOrders(String userID) throws Exception, RemoteException {
065                    return (OrderDataBean[])((trade.getOrders(userID)).toArray(new OrderDataBean[0]));
066            }
067            
068            public OrderDataBean[] getClosedOrders(String userID) throws Exception, RemoteException {
069                    return (OrderDataBean[])((trade.getClosedOrders(userID)).toArray(new OrderDataBean[0]));
070            }
071            
072            public QuoteDataBean createQuote(String symbol, String companyName, BigDecimal price) throws Exception, RemoteException {
073                    return trade.createQuote(symbol, companyName, price);
074            }
075            
076            public QuoteDataBean getQuote(String symbol) throws Exception, RemoteException {
077                    return trade.getQuote(symbol);
078            }
079            
080            public QuoteDataBean[] getAllQuotes() throws Exception, RemoteException {
081                    return (QuoteDataBean[])((trade.getAllQuotes()).toArray(new QuoteDataBean[0]));
082            }
083            
084            public QuoteDataBean updateQuotePriceVolume(String symbol, BigDecimal newPrice, double sharesTraded) throws Exception, RemoteException {
085                    return trade.updateQuotePriceVolume(symbol, newPrice, sharesTraded);
086            }
087            
088            public HoldingDataBean[] getHoldings(String userID) throws Exception, RemoteException {
089                    return (HoldingDataBean[])((trade.getHoldings(userID)).toArray(new HoldingDataBean[0]));
090            }
091            
092            public HoldingDataBean getHolding(Integer holdingID) throws Exception, RemoteException {
093                    return trade.getHolding(holdingID);
094            }
095            
096            public AccountDataBean getAccountData(String userID) throws Exception, RemoteException {
097                    return trade.getAccountData(userID);
098            }
099            
100            public AccountProfileDataBean getAccountProfileData(String userID) throws Exception, RemoteException {
101                    return trade.getAccountProfileData(userID);
102            }
103            
104            public AccountProfileDataBean updateAccountProfile(AccountProfileDataBean profileData) throws Exception, RemoteException {
105                    return trade.updateAccountProfile(profileData);
106            }
107            
108            public AccountDataBean login(String userID, String password) throws Exception, RemoteException {
109                    return trade.login(userID, password);
110            }
111            
112            public void logout(String userID) throws Exception, RemoteException {
113                    trade.logout(userID);
114            }
115            
116            public AccountDataBean register(String userID, String password, String fullname, String address, String email, String creditcard, BigDecimal openBalance) throws Exception, RemoteException {
117                    return trade.register(userID, password, fullname, address, email, creditcard, openBalance);
118            }
119            
120            public RunStatsDataBean resetTrade(boolean deleteAll) throws Exception, RemoteException {
121                    return trade.resetTrade(deleteAll);
122            }
123    }