incubator-stonehenge-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shan...@apache.org
Subject svn commit: r720797 [2/9] - in /incubator/stonehenge/contrib/stocktrader/ruby: ./ order_processor/ order_processor/keys/ order_processor/policies/ trader_client/ trader_client/app/ trader_client/app/controllers/ trader_client/app/helpers/ trader_client...
Date Wed, 26 Nov 2008 10:52:44 GMT
Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_logic.rb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_logic.rb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_logic.rb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_logic.rb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,487 @@
+
+# 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.
+
+
+require "trade_utils.rb"
+
+require 'wsf'    # Use WSO2 WSF/Ruby module
+
+#include WSO2::WSF
+
+# Constant definition
+WSDL_FILE_NAME = "public/wsdl/noimports.wsdl"
+LOG_FILE_NAME = "wsf_ruby_client.log"
+CONFIG_WSDL_NAME = "public/wsdl/config_svc.wsdl"
+CLIENT_NAME = "RUBY_CLIENT"
+
+#####################
+# Web Services Client 
+#####################
+
+
+# Get proxy client
+def GetProxy()
+  endpoint = GetBSEndpoint();
+  if(endpoint != nil)
+    client = WSO2::WSF::WSClient.new({"wsdl" => WSDL_FILE_NAME,
+              "to" => endpoint}, LOG_FILE_NAME)
+
+    return client.get_proxy
+  else
+    return nil
+  end
+end
+
+
+# Get client
+def GetClient()
+  endpoint = GetBSEndpoint();
+  if(endpoint != nil)
+    client = WSO2::WSF::WSClient.new(
+            {"to" => endpoint, "use_soap" => 1.1}, LOG_FILE_NAME)
+
+    return client
+  else
+    return nil
+  end
+end
+
+# Sends login request to verify whether current user is authorized
+# @param userid user id of current user
+# @param password password given by current user
+# @return profile id of the user if login is success. NULL otherwise
+def Login(userid, password)
+  proxy = GetProxy()
+  if(proxy != nil)
+    response = proxy.login({"login"=> {"userID"=> userid,
+               "password" => password}})
+    if(response["loginResponse"] != nil && response["loginResponse"]["loginReturn"] != nil)
+      return response["loginResponse"]["loginReturn"]["profileID"]
+    else
+      return nil
+    end
+  end
+end
+
+# When user logout, user id will be deleted from the cookie
+# @param username user id of current user
+
+def LogoutUser(username)
+
+	client = GetClient()
+  input = "<x:logout xmlns:x=\"http://trade.samples.websphere.ibm.com\"><userID>#{username}</userID></x:logout>"
+  begin
+    response = client.request(input)
+  rescue WSO2::WSF::WSFault => wsfault
+  end
+	DeleteCookie()
+end
+
+
+# get the orders
+def GetOrders(userid)
+  proxy = GetProxy()
+  response =proxy.getOrders({"getOrders"=> {"userID" => userid}})
+  if(response != nil && response["getOrdersResponse"] != nil &&
+      response["getOrdersResponse"]["getOrdersReturn"] != nil)
+      ret = response["getOrdersResponse"]["getOrdersReturn"]
+      return ret
+  end
+end
+
+#  Given the order details of a user, this method calculates summery of
+#  activities of the user. This includes total money spent on buying stocks
+#  total money earned from selling them etc.
+#  @param ordersReturn collection of orders of a user
+#  @return summery of user's activities
+
+
+def GetUserAccountSummary(ordersReturn)
+	index = 0
+  sells = 0
+  buys = 0
+  tax = 0
+
+  if(ordersReturn["OrderDataBean"].class.to_s == "Array")
+    while((order = ordersReturn["OrderDataBean"][index]) != nil)
+      if(order.class.to_s == "Hash")
+        if (order["orderType"] == "buy")
+          buys = buys + ((order["price"].to_f) * 
+            (order["quantity"].to_i)) + 
+            (order["orderFee"].to_f)
+        elsif (order["orderType"] == "sell")
+          sells = sells +  ((order["price"].to_f) * 
+            (order["quantity"].to_i)) - 
+            (order["orderFee"].to_f)
+        end
+        tax = tax + order["orderFee"].to_f;
+      end
+      index = index + 1;
+    end
+  else
+    order = ordersReturn["OrderDataBean"]
+    if(order.class.to_s == "Hash")
+      if (order["orderType"] == "buy")
+        buys = buys + ((order["price"].to_f) * 
+          (order["quantity"].to_i)) + 
+          (order["orderFee"].to_f)
+      elsif (order["orderType"] == "sell")
+        sells = sells +  ((order["price"].to_f) * 
+          (order["quantity"].to_i)) - 
+          (order["orderFee"].to_f)
+      end
+      tax = tax + order["orderFee"].to_f;
+    end
+  end
+  return {"totalBuys" => buys,
+          "totalSells" => sells,
+          "totalTax" => tax,
+          "totalImpact" => buys + tax - sells}
+end
+
+#  Updates account profile information
+#  @param userID id of the user
+#  @param fullname full name of the user
+#  @param email email address of the user
+#  @param address address of the user
+#  @param creditcard credit card number of the user
+#  @param password password of the user
+#  @return account details of the modified user on success. NULL otherwise.
+
+def UpdateAccountProfile(userID, fullName, email, 
+	address, creditCard, password)
+	proxy = GetProxy();
+	input = {"updateAccountProfile" =>
+              {"profileData" =>
+                { "userID" => userID,
+	                "password" => password,
+	                "fullName" => fullName,
+	                "address" => address,
+	                "email" => email,
+	                "creditCard" => creditCard}}}
+  response = proxy.updateAccountProfile(input);
+	return response;
+end
+
+
+#  Gets account details of current user
+#  @param userid user id of current user
+#  @return account details if success. NULL otherwise
+
+def GetAccountData(userid)
+	proxy = GetProxy()
+  input = {"getAccountData" =>
+	            {"userID" => userid}}
+  response = proxy.getAccountData(input)
+  if(response["getAccountDataResponse"] != nil &&
+    response["getAccountDataResponse"]["getAccountDataReturn"] != nil)
+	  return response["getAccountDataResponse"]["getAccountDataReturn"]
+  end
+end
+
+#  Gets account profile information of current user
+#  @param userid user id of current user
+#  @return account profile data of current user if success. NULL otherwise
+
+def GetAccountProfileData(userid)
+	proxy = GetProxy()
+  input = {"getAccountProfileData" =>
+	          {"userID" => userid}}
+  response = proxy.getAccountProfileData(input)
+  if(response["getAccountProfileDataResponse"] != nil &&
+      response["getAccountProfileDataResponse"]["getAccountProfileDataReturn"] != nil)
+	  return response["getAccountProfileDataResponse"]["getAccountProfileDataReturn"]
+  end
+end
+
+# Gets closed orders of current user
+# @return collection of orders whose status is closed
+
+def GetClosedOrders(userid)
+	proxy = GetProxy()
+  input = {"getClosedOrders" =>
+             {"userID" => userid}}
+  response = proxy.getClosedOrders(input)
+  #return response
+  if(response != nil &&
+      response["getClosedOrdersResponse"] != nil &&
+      response["getClosedOrdersResponse"]["getClosedOrdersReturn"] != nil)
+    return response["getClosedOrdersResponse"]["getClosedOrdersReturn"]
+  end
+  return nil
+end
+
+
+# Gets quote of given symbol
+# @param symbol id of the stock
+# @return details of the symbol when success. NULL otherwise
+
+def GetQuote(symbol)
+
+	proxy = GetProxy();
+  input = {"getQuote" => 
+            {"symbol" => symbol}}
+	response = proxy.getQuote(input)
+  if(response != nil &&
+       response["getQuoteResponse"] != nil &&
+       response["getQuoteResponse"]["getQuoteReturn"] != nil)
+    getQuoteReturn = response["getQuoteResponse"]["getQuoteReturn"]
+    return getQuoteReturn
+  end
+	return nil
+end
+
+
+# Buys number of stocks of given symbol 
+# @param userID user id of current user
+# @param symbol symbol of needed stock
+# @quantity number of stocks needed
+# @mode mode of buying
+# @return details of buy order if success. NULL otherwise
+
+def Buy(userID, symbol, quantity, mode)
+	proxy = GetProxy()
+  input = {"buy" => 
+           {"symbol" => symbol,
+	          "userID" => userID,
+	          "quantity" => quantity.to_f,
+	          "orderProcessingMode" => mode.to_i}}
+  response = proxy.buy(input)
+  if(response != nil &&
+         response["buyResponse"] != nil &&
+         response["buyResponse"]["buyReturn"] != nil)
+    return response["buyResponse"]["buyReturn"] 
+  end
+  return nil
+end
+
+# Sells given holding or part of it of given user
+# @param userID user id of current user
+# @param holdingID holding id of the holding
+# @param quantity number of stocks to be sold
+# @return details of sell order if success. NULL otherwise
+
+def SellEnhanced(userID, holdingID, quantity)
+	proxy = GetProxy()
+  input = {"sellEnhanced" => 
+    {"userID" => userID,
+     "holdingID" => holdingID.to_i,
+     "quantity" => quantity.to_f}}
+  response = proxy.sellEnhanced(input)
+  if(response != nil &&
+         response["sellEnhancedResponse"] != nil &&
+         response["sellEnhancedResponse"]["sellEnhancedReturn"] != nil)
+    return response["sellEnhancedResponse"]["sellEnhancedReturn"] 
+  end
+  return nil
+end
+
+
+# Gets holding details of given user
+# @param userid user id of current user
+# returns collection of holding if success. NULL otherwise
+
+def GetHoldings(userID)
+	proxy = GetProxy();
+  input = {"getHoldings" => 
+    {"userID" => userID}}
+  response = proxy.getHoldings(input)
+  if(response != nil &&
+         response["getHoldingsResponse"] != nil &&
+         response["getHoldingsResponse"]["getHoldingsReturn"] != nil)
+    return response["getHoldingsResponse"]["getHoldingsReturn"] 
+  end
+  return nil
+end
+
+
+# This method registes a new user in the system
+# @param userID id of the user
+# @param password password of the user
+# @param fullname full name of the user
+# @param address address of the user
+# @param email email address of the user
+# @param creditcard credit card number of the user
+# @param openBalance initial balance of the user
+# @return account details of the registerd user on success. NULL otherwise.
+
+def RegisterUser(userID, password, fullname, 
+	address, email, creditcard, openBalance)
+	
+  proxy = GetProxy()
+	input = {"register" =>
+     {"userID" => userID,
+      "password" => password,
+      "fullname" => fullname,
+      "address" => address,
+      "email" => email,
+      "creditcard" => creditcard,
+      "openBalance" => openBalance.to_f}}
+	response = proxy.register(input)
+  if(response != nil &&
+         response["registerResponse"] != nil &&
+         response["registerResponse"]["registerReturn"] != nil)
+    return response["registerResponse"]["registerReturn"] 
+  end
+	return response
+end
+
+require 'rexml/document'
+include REXML
+
+# Gets market summary
+# @return market summery
+
+def GetMarketSummary
+#	proxy = GetProxy()
+#  input = {"getMarketSummary" => nil}
+#	response = proxy.getMarketSummary(input)
+#  if(response != nil &&
+#         response["getMarketSummaryResponse"] != nil &&
+#         response["getMarketSummaryResponse"]["getMarketSummaryReturn"] != nil)
+#    return response["getMarketSummaryResponse"]["getMarketSummaryReturn"] 
+#  end
+#	return response
+  client = GetClient()
+  input = "<x:getMarketSummary xmlns:x=\"http://trade.samples.websphere.ibm.com\"></x:getMarketSummary>"
+
+  response = client.request(input)
+  
+  doc = Document.new(response.payload_to_s) 
+
+  ret_val = {}
+  ret_val["TSIA"]= XPath.first(doc, "//pq:TSIA", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+            XPath.first(doc, "//pq:TSIA", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+  ret_val["openTSIA"]= XPath.first(doc, "//pq:openTSIA", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+              XPath.first(doc, "//pq:openTSIA", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+  ret_val["volume"]= XPath.first(doc, "//pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+              XPath.first(doc, "//pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+  ret_val["summaryDate"]= XPath.first(doc, "//pq:summaryDate", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+              XPath.first(doc, "//pq:summaryDate", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+
+  top_gainers_arr = Array.new
+  XPath.each(doc, "//pq:topGainers/pq:QuoteDataBean",{"pq" => "http://trade.samples.websphere.ibm.com"}) do |quote|
+    top_gainers_arr <<
+       {
+         "symbol" => XPath.first(quote, "./pq:symbol", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:symbol", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "companyName" => XPath.first(quote, "./pq:companyName", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:companyName", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "price" => XPath.first(quote, "./pq:price", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:price", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "open" => XPath.first(quote, "./pq:open", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:open", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "low" => XPath.first(quote, "./pq:low", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:low", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "high" => XPath.first(quote, "./pq:high", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:high", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "change" => XPath.first(quote, "./pq:change", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:change", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "volume" => XPath.first(quote, "./pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+         }
+  end
+
+  top_losers_arr = Array.new
+  XPath.each(doc, "//pq:topLosers/pq:QuoteDataBean",{"pq" => "http://trade.samples.websphere.ibm.com"}) do |quote|
+    top_losers_arr <<
+       { "symbol" => XPath.first(quote, "./pq:symbol", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                XPath.first(quote, "./pq:symbol", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "companyName" => XPath.first(quote, "./pq:companyName", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:companyName", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "price" => XPath.first(quote, "./pq:price", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:price", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "open" => XPath.first(quote, "./pq:open", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:open", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "low" => XPath.first(quote, "./pq:low", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:low", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "high" => XPath.first(quote, "./pq:high", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:high", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "change" => XPath.first(quote, "./pq:change", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:change", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil,
+         "volume" => XPath.first(quote, "./pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"})?
+                  XPath.first(quote, "./pq:volume", {"pq" => "http://trade.samples.websphere.ibm.com"}).text.to_s : nil
+         }
+  end
+
+  ret_val["topLosers"] = top_losers_arr
+  ret_val["topGainers"] = top_gainers_arr
+
+ 
+  return ret_val
+end
+
+
+
+# Given the holdings of a user, this methods calculate total market value of 
+# holding and number of holdings
+# @param holdings collection of holdings of a user
+# @return summery of holding details
+
+def GetHoldingInformation(holdingsReturn)
+  quoteInfo = {}
+  index = 0
+  marketValue = 0
+  totalHoldings = 0
+  while ((bean=holdingsReturn["HoldingDataBean"][index]) != nil)
+    if (!quoteInfo[bean["quoteID"]])
+      quotesReturn = GetQuote(bean["quoteID"])
+      quoteInfo[bean["quoteID"]] = quotesReturn["price"]
+    end
+
+    quoteID = bean["quoteID"]
+    totalHoldings = totalHoldings + bean["purchasePrice"].to_f * (bean["quantity"].to_i)
+    marketValue = marketValue + (quoteInfo[quoteID].to_i) * (bean["quantity"].to_i)
+
+    index = index + 1
+  end
+
+  holdingInfo = {"totalHoldings" => marketValue, "noOfHoldings" => index }
+  return holdingInfo
+end
+
+# Get the endpoint of business service
+def GetBSEndpoint()
+    #get the endpoint first
+    endpoint = GetEndpoint()
+    if(endpoint == nil)
+      return nil
+    end
+    # create client in WSDL mode
+    client = WSO2::WSF::WSClient.new({"wsdl" =>CONFIG_WSDL_NAME,
+              "to" => endpoint}, LOG_FILE_NAME)
+
+    # get proxy object reference form client 
+    proxy = client.get_proxy();
+    input = {"ClientConfigRequest" => 
+          {"Client" => CLIENT_NAME } }
+
+    response = proxy.ClientConfigRequest(input);
+    if(response && response["ClientConfigResponse"])
+      bsendpoint = response["ClientConfigResponse"]["BS"]
+    end
+    cookies[:bsendpoint] = { :value => bsendpoint,
+              :expires => Time.now + 24.hour}
+	  return bsendpoint
+end
+
+
+# Get the endpoint of the business service to be consumed
+def GetEndpoint()
+  return cookies[:endpoint] 
+end
+
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_utils.rb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_utils.rb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_utils.rb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/controllers/trade_utils.rb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,117 @@
+
+# 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.
+
+
+# Store business service's endpoint in cookie
+# @param endPoint end point address of the business service
+def WriteEndpoint(endpoint)
+  if(cookies[:endpoint] == endpoint)
+    return false
+  else
+    cookies[:endpoint] = { :value => endpoint, :expires => Time.now + 24.hour}
+    if(cookies[:bsendpoint])
+      cookies.delete :bsendpoint
+    end
+    return true
+  end
+end
+
+
+# Checks whether user is logged in. If the user is logged in, user id 
+# cookie would have been already set. Checking whether cookie is set 
+# equals to checking whether user is logged in.
+def IsLoggedIn()
+  return cookies[:username] != nil &&
+      !cookies[:username].empty?
+end
+
+# Writes user id to cookie
+# @param username user id of the current user
+def WriteUsername(username)
+  cookies[:username] = { :value => username, :expires => Time.now + 24.hour}
+end
+
+# Deletes user id from cookie
+# @param username user id of current user
+def DeleteCookie()
+  cookies.delete :username
+end
+
+# Retrun the user
+def GetUserFromCookie()
+  return cookies[:username]
+end
+
+def obj_to_s(obj, terminator= "\n", index = 0)
+  str = ""
+  index.times do |num|
+    str = str + " "
+  end
+  if(obj.class.to_s == "Hash")
+    str = str + "{"
+    obj.each do |key, value|
+      value_to_str = obj_to_s(value, terminator, index + 2)
+      str = str + key + " => " + value_to_str + " "
+    end
+    str = str + "}"
+  elsif(obj.class.to_s == "Array")
+    str = str + "["
+    obj.each do |value|
+      value_to_str = obj_to_s(value, terminator, index + 2)
+      str = str + value_to_str + " "
+    end
+    str = str + "]"
+  elsif(obj.class.to_s == "String")
+    str = str + obj + " "
+  elsif(obj.class.to_s == "FixNum")
+    str = str + obj.to_s + " "
+  elsif(obj.class.to_s == "Float")
+    str = str + obj.to_s + " "
+  else
+    str = str + obj.to_s + " "
+  end
+  str = str + terminator
+  return str
+end
+
+
+def convert_date(str)
+  if(str)
+    date_arr = str.to_s.tr("T:.", "-").split("-")
+    year = date_arr[0]
+    mon = date_arr[1]
+    date = date_arr[2]
+    hour = date_arr[3]
+    min = date_arr[4]
+    sec = date_arr[5]
+      
+    if(hour.to_i > 12)
+      hour = hour.to_i - 12
+      hour = hour.to_s
+      ampm = "PM"
+    else
+      ampm = "AM"
+    end
+
+    return mon.to_s + "/" + 
+            date.to_s + "/" +
+            year.to_s + " " +
+            hour.to_s + ":" +
+            min.to_s + ":" +
+            sec.to_s + " " + ampm
+  end
+  return ""
+end

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/application_helper.rb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/application_helper.rb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/application_helper.rb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/application_helper.rb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,19 @@
+
+# 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.
+
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/trade_helper.rb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/trade_helper.rb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/trade_helper.rb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/helpers/trade_helper.rb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,18 @@
+
+# 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.
+
+module TradeHelper
+end

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/layouts/default.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/layouts/default.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/layouts/default.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/layouts/default.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+	<head>
+		<meta http-equiv="content-type" content="text/html;charset=utf-8" />
+		<meta name="generator" content="Adobe GoLive" />
+		<title>WSO2 WSF/Ruby StockTrader Welcome</title>
+		<link href="/stylesheets/style.css" rel="stylesheet" type="text/css" media="all" />
+	</head>
+
+	<body>
+
+	<div id="content">
+		<div id="header">
+			<div class="logo"><img src="/images/logo.gif"></div>
+		</div>
+
+		<div id="header-links">
+		<table>
+			<tr>
+			<td>
+			<a href="/trade/index">Welcome</a>
+			</td>
+			<td>
+			<a href="/trade/home">Home</a>
+			</td>
+			<td>
+			<a href="/trade/account">Account</a>
+			</td>
+			<td>
+			<a href="/trade/portfolio">Portfolio</a>
+			</td>
+			<td>
+			<a href="/trade/quotes">Quotes/Trade</a>
+			</td>
+			<td>
+			<a href="/trade/glossary">Glossary</a>
+			</td>
+			<td>
+			<a href="/trade/config">Config</a>
+			</td>
+			<td>
+			<a href="/trade/login">Login/Logout</a>
+			</td>
+			</tr>
+		</table>
+		</div>
+
+		<%= @content_for_layout %>
+		
+			<div id="footer">
+				<div style="float:left;">Copyright 2008, WSO2 Inc.</div>
+				<div style="margin-left:432px;float:left;">Powered by 
+				<img align="top" src="/images/powered-by-logo.gif" style="margin-top:-3px; margin-left: 0px;"/></div>
+			</div>
+		</div>
+	
+	</body>
+</html>
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/account.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/account.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/account.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/account.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,232 @@
+<div id="middle">
+              
+        <%
+				# Checking whether there is new status change happened in the 
+				# related to a particular order.
+				if (@closedOrders != nil)
+				%>
+					<p style="color: red" align="center">Trade Alert: 
+						The following orders have completed.</p>
+					<table class="table-outer" 
+						cellspacing="0" align="center"><thead>
+						<tr><th>Order ID</th><th>Order Status</th>
+						<th>Creation Date</th><th>Completion Date</th>
+						<th>Txn Fee</th><th>Type</th><th>Symbol</th>
+						<th>Quantity</th></tr></thead><tbody>
+          
+          <%
+					index = 0
+          if(@closedOrders["OrderDataBean"].class.to_s == "Array")
+            while ((order = @closedOrders["OrderDataBean"][index]) != nil)
+              openDate = convert_date(order["openDate"])
+              completionDate = convert_date(order["completionDate"])
+              %>
+              <tr>
+                <td><%=order["orderID"]%></td>
+                <td><%=order["orderStatus"]%></td>
+                <td><%=openDate%></td>
+                <td><%=completionDate%></td>
+                <td>$<%=order["orderFee"]%></td>
+                <td><%=order["orderType"]%></td>
+                <td><%=order["symbol"]%></td>
+                <td><%=order["quantity"]%></td>
+              </tr>
+              <%
+              index = index + 1
+            end
+          else
+            order = @closedOrders["OrderDataBean"]
+            openDate = convert_date(order["openDate"])
+            completionDate = convert_date(order["completionDate"])
+            %>
+            <tr>
+              <td><%=order["orderID"]%></td>
+              <td><%=order["orderStatus"]%></td>
+              <td><%=openDate%></td>
+              <td><%=completionDate%></td>
+              <td>$<%=order["orderFee"]%></td>
+              <td><%=order["orderType"]%></td>
+              <td><%=order["symbol"]%></td>
+              <td><%=order["quantity"]%></td>
+            </tr>
+          <%
+          end
+          %>
+					</tbody></table><br/><br/>
+        <%
+        end
+				%>
+
+
+        <%
+				# Display the account summary information of a particular user.
+				if (@accountSummary != nil)
+        %>
+					<div class="main-title"><h1>Account Information
+						</h1><script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script></div>
+
+					<table class="table-outer" cellspacing="0" align="center">
+						<thead><tr><th>Subtotal Buys</th><th>Subtotal Sells</th><th>Subtotal Fees
+						</th><th>Net Impact Cash Balance</th></tr></thead><tbody><tr>
+
+					<td class="currency"><%=@accountSummary["totalBuys"] %></td> 
+					<td class="currency"><%=@accountSummary["totalSells"] %></td> 
+					<td class="currency"><%=@accountSummary["totalTax"] %></td> 
+					<td class="currency">
+          
+          <%
+					if (@accountSummary["totalImpact"].to_i > 0)
+          %>
+						<span class="price-loss"><%=@accountSummary["totalImpact"]%></span> 
+          <%
+					elsif (@accountSummary["totalImpact"].to_i < 0)
+          %>
+						<span class="price-gain"><%=@accountSummary["totalImpact"]%></span> 
+          <%
+					else
+          %>
+						<span><%=@accountSummary["totalImpact"]%></span> 
+          <%
+          end
+          %>
+					</td></tr></tbody></table>
+        <%
+				end
+        %>
+
+        <%
+				# Display the orders a particular user is associated with
+				if (@ordersReturn != nil)
+        %>
+					<div><p><b>Total Orders Shown</b></p></div>
+					<table class="table-outer" cellspacing="0" align="center"><thead><tr>
+					<th>Order ID</th><th>Order Status</th><th>Creation Date</th><th>Completion Date
+						</th><th>Txn Fee</th><th>Type</th><th>Symbol</th><th>Quantity</th><th>Price
+						</th><th>Total</th></tr></thead><tbody>
+				<%	
+					index = 0
+          if(@ordersReturn["OrderDataBean"].class.to_s == "Array")
+            while((order = @ordersReturn["OrderDataBean"][index]) != nil)
+              openDate = convert_date(order["openDate"])
+              completionDate = convert_date(order["completionDate"])
+              %>
+                <tr><td><%=order["orderID"]%></td>
+                <td><%=order["orderStatus"]%></td>
+                <td><%=openDate%></td>
+                <td><%=completionDate%></td>
+                <td class="currency"><%=order["orderFee"]%></td>
+                <td><%=order["orderType"]%></td>
+                
+                <td><form action = "/trade/quotes" method = "post">
+                <input type="hidden" name="SYMBOLS" value="<%=order["symbol"]%>"/>
+                <input type="submit" name="GETQUOTE" value="<%=order["symbol"]%>"/></form></td>
+
+                <td class="currency"><%=order["quantity"]%></td>
+                <td class="currency">$<%=order["price"]%></td>
+                <td class="currency">$<%="%.2f" % ((order["price"].to_f * order["quantity"].to_i) + order["orderFee"].to_f)%></td></tr>
+
+            <%
+              index = index +1
+            end
+          else
+            order = @ordersReturn["OrderDataBean"]
+            openDate = converte_date(order["openDate"])
+            completionDate = convert_date(order["completionDate"])
+            %>
+              <tr><td><%=order["orderID"]%></td>
+              <td><%=order["orderStatus"]%></td>
+              <td><%=openDate%></td>
+              <td><%=completionDate%></td>
+              <td class="currency"><%=order["orderFee"]%></td>
+              <td><%=order["orderType"]%></td>
+              
+              <td><form action = "/trade/quotes" method = "post">
+              <input type="hidden" name="SYMBOLS" value="<%=order["symbol"]%>"/>
+              <input type="submit" name="GETQUOTE" value="<%=order["symbol"]%>"/></form></td>
+
+              <td class="currency"><%=order["quantity"]%></td>
+              <td class="currency"><%=order["price"]%></td>
+              <td class="currency"><%="%.2f" % ((order["price"].to_f * order["quantity"].to_i) + order["orderFee"].to_f)%></td></tr>
+
+          <%
+          end
+          %>
+					</tbody></table>
+				<%
+        end
+        %>
+
+        <%	
+				# Display the account profile information associted to a
+				# the user.
+				if (@userAccountProfileDataReturn)
+        %>
+					<form action = "/trade/account"  method ="post">
+						<table class="profile" cellspacing="0" width="100%"><thead><tr>
+						<th>Update Account Profile:<%=@userId%></th></tr></thead><tbody><tr><td>
+					<table cellspacing="0" align="center">
+					<tr><td>Full Name:</td><td><input name="FULLNAME" type="text" value="<%=@userAccountProfileDataReturn["fullName"]%>" id="" size="25"/>
+						</td><td>Email Address:</td><td><input name="EMAIL" type="text" value="<%=@userAccountProfileDataReturn["email"]%>" id="" size="25"/></td></tr>
+					<tr><td>Address:</td><td><input name="ADDRESS" type="text" value="<%=@userAccountProfileDataReturn["address"]%>" id="" size="25"/></td>
+						<td>Password:</td><td><input type="password" name="PASSWORD" type="text" value="<%=@userAccountProfileDataReturn["password"]%>" id="" size="25"/></td></tr>
+					<tr><td>Credit Card:</td><td><input name="CREDITCARD" type="text" value="<%=@userAccountProfileDataReturn["creditCard"]%>" id="" size="25"/></td>
+						<td>Confirm Password:</td><td><input type="password" name="PASSWORD" type="text" value="<%=@userAccountProfileDataReturn["password"]%>" id="" size="25"/></td></tr>
+					<tr><td colspan="4" class="button"><input type="submit" 
+						name="UPDATEUSERPROFILE"value="Update" class="button"/></td></tr>
+					</table>
+          </form>
+
+          <%
+					# Display the account information of a the user
+					if (@userAccountDataReturn)	
+					
+						creationDate = convert_date(@userAccountDataReturn["creationDate"])
+						lastLogin = convert_date(@userAccountDataReturn["lastLogin"])
+          %>
+						<table align="center" class="profile-content" cellspacing="0"><tbody>
+						<tr><td class="left">Account ID:</td>
+							<td><%=@userAccountDataReturn["accountID"]%></td><td class="left">
+							Account Created</td><td><%=creationDate%></td></tr>
+						<tr><td class="left">User ID:</td>
+							<td><%=@userAccountDataReturn["profileID"]%></td><td class="left">
+							Last Login:</td><td><%=lastLogin%></td></tr>
+						<tr><td class="left">Opening Balance:</td>
+							<td>$<%=@userAccountDataReturn["openBalance"]%></td>
+							<td class="left">Total Logins:</td>
+							<td><%=@userAccountDataReturn["loginCount"]%></td></tr>
+						<tr><td class="left">Cash Balance:</td>
+						
+            <%	
+						if (@userAccountDataReturn["balance"].to_f > 0)
+            %>
+							<td><span class="price-gain">$<%="%.2f" % @userAccountDataReturn["balance"]%></span></td>
+						<%
+						elsif(@userAccountDataReturn["balance"].to_f < 0)
+            %>
+							<td><span class="price-loss">$<%="%.2f" % ((-1) * @userAccountDataReturn["balance"].to_f)%></span></td>
+						<%
+						else
+						%>
+							<td>$<%=@userAccountDataReturn["balance"]%></td>
+            <%
+						end
+            %>
+            <td class="left">Total Logouts:</td>
+            <td><%=@userAccountDataReturn["logoutCount"]%></td></tr>
+            </tbody></table>
+          <%
+					end
+          %>
+					</td></tr></tbody></table>
+				<%
+        end
+		    %>
+
+			<div class="bottom">
+			<form method = "post"  action = "/trade/quotes">
+			<input type="text" value="<%=%>" name="SYMBOLS" size="25"/>
+			<input type="submit" value="Get Quote" name="GETQUOTE" class="button"/>
+			</form>
+			</div>
+</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/config.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/config.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/config.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/config.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,26 @@
+<div id="middle">
+
+    <%= @message %>
+		<div class="main-title">
+		<h1>Config</h1>
+		<script type=\"text/javascript\">
+			var thisdate = new Date();
+			document.writeln(thisdate.toLocaleString());
+		</script>
+		</div>
+
+		<div class="login">
+    <form method="post"  action="/trade/config">
+      <table>
+      <tr>
+      <td>Remote Host</td>
+      <td><input type="text" name = "ENDPOINT" value = <% if (GetEndpoint() == nil || GetEndpoint() == "") %>"http://localhost:80/TradeServiceWcf/TradeServiceWcf.svc"<% else %>"<%=GetEndpoint()%>" <%end%> size = "75"/></td>
+      </tr>
+      <tr>
+      <td></td>
+      <td><input type = "submit" name = "SETENDPOINT" value = "Set" class="button"/></td>
+      </tr>
+      </table>
+    </form>
+		</div>
+</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/confirmation.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/confirmation.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/confirmation.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/confirmation.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,50 @@
+<div id="middle">
+				<div class="main-title">
+					<h1>Trade</h1>
+					<script type=\"text/javascript\">
+						var thisdate = new Date();
+						document.writeln(thisdate.toLocaleString());
+					</script>
+				</div>
+				
+				<div id="confirm">
+				<h2>Trade Confirmation</h2>
+				<div class="confirm-content">
+					<form action="/trade/quotes" method="post">
+
+            <%
+						if (@isSell)
+						%>
+							<p>You have requested to sell all or part of your holding <%=@holdingID%> 
+									This holding has a total of <%=@quantity%> shares of stock <%=@symbol%>
+									Please indicate how many share to sell.</p>
+
+							<nobr>Number of Shares: <input type="text" name="QUANTITY" value="100" id="" size="10"/>
+							<input type="hidden" name="HOLDINGID" value="<%=@holdingID%>"></input>
+							<input type="submit" name="SELL" value="Sell" class="button"/>
+            <%
+						elsif (@isBuy)
+						%>
+							<nobr>Number of Shares: <input type="text" name="QUANTITY" value="100" id="" size="10"/>
+							<p>You have requested to buy shares of <%=@symbol%> which is currently trading at $".$price.".</p>
+							<input type="hidden" name="SYMBOL" value="<%=@symbol%>"></input>
+							<input type="submit" name="BUY" value="Buy" class="button"/>
+						<%
+						else
+						%>
+              <%=@messsage%>
+						<%
+            end
+            %>
+            <input type="submit" name = "CANCEL" value="Cancel" class="button"/></nobr>
+					</form>
+				</div>
+				</div>
+				
+			<div class="bottom">
+			<form method = "post"  action = "quotes.php">
+			<input type="text" value="<%=@symbol%>" name="SYMBOLS" size="25"/>
+			<input type="submit" value="Get Quote" name="GETQUOTE" class="button"/>
+			</form>
+			</div>
+</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/glossary.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/glossary.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/glossary.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/glossary.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,151 @@
+			<div id="middle">
+				<div class="main-title">
+					<h1>Glossary</h1>
+					<script type="text/javascript">
+						var thisdate = new Date();
+						document.writeln(thisdate.toLocaleString());
+					</script>
+				</div>
+				<table align="center" class="glossary" >
+					<thead>
+						<tr>
+							<th>Term</th>
+							<th>Description</th>
+						</tr>
+					</thead>
+					<tbody>
+						<tr>
+							<td class="left">Account ID</td>
+							<td>A unique Integer based key. Each user is assigned an account ID at account creation time.</td>
+						</tr>
+						<tr>
+							<td class="left">Account Created</td>
+							<td>The time and date the users account was first created.</td>
+						</tr>
+						<tr>
+							<td class="left">Cash Balance</td>
+							<td>The current cash balance in the users account. This does not include current stock holdings.</td>
+						</tr>
+							<td class="left">Company</td>
+							<td>The full company name for an individual stock.</td>
+						</tr>
+							<td class="left">Current Gain/Loss</td>
+							<td>The total gain or loss of this account, computed by substracting the current sum of cash/holdings minus the opening account balance.</td>
+						</tr>
+							<td class="left">Current Price</td>
+							<td>The current trading price for a given stock symbol.</td>
+						</tr>
+							<td class="left">Gain/Loss</td>
+							<td>The current gain or loss of an individual stock holding, computed as (current market value - holding basis).</td>
+						</tr>
+						</tr>
+							<td class="left">Last Login</td>
+							<td>The date and time this user last logged in to Trade.</td>
+						</tr>
+						</tr>
+							<td class="left">Market Value</td>
+							<td>The current total value of a stock holding, computed as (quantity * current price).</td>
+						</tr>
+						</tr>
+							<td class="left">Number of Holdings</td>
+							<td>The total number of stocks currently owned by this account.</td>
+						</tr>
+						</tr>
+							<td class="left">Open Price</td>
+							<td>The price of a given stock at the open of the trading session.</td>
+						</tr>
+						</tr>
+							<td class="left">Order ID</td>
+							<td>A unique Integer based key. Each order is assigned an order ID at order creation time.</td>
+						</tr>
+						</tr>
+							<td class="left">Opening Balance</td>
+							<td>The initial cash balance in this account when it was opened.</td>
+						</tr>
+						</tr>
+							<td class="left">Order Status</td>
+							<td>orders are opened, processed, closed and completed. Order status shows the current stat for this order.</td>
+						</tr>
+						</tr>
+							<td class="left">Price Range</td>
+							<td>The low and high prices for this stock during the current trading session</td>
+						</tr>
+						</tr>
+							<td class="left">Purchase Date</td>
+							<td>The date and time the a stock was purchased.</td>
+						</tr>
+						</tr>
+							<td class="left">Purchase Price</td>
+							<td>The price used when purchasing the stock.</td>
+						</tr>
+						</tr>
+							<td class="left">Purchase Basis</td>
+							<td>The total cost to purchase this holding. This is computed as (quantity * purchase price).</td>
+						</tr>
+						</tr>
+							<td class="left">Quantity</td>
+							<td>The number of stock shares in the order or user holding.</td>
+						</tr>
+						</tr>
+							<td class="left">Session Created</td>
+							<td>An HTTP session is created for each user at during login. Session created shows the time and day when the session was created.</td>
+						</tr>
+						</tr>
+							<td class="left">Sum of Cash/Holdings</td>
+							<td>The total current value of this account. This is the sum of the cash balance along with the value of current stock holdings.</td>
+						</tr>
+						</tr>
+							<td class="left">Symbol</td>
+							<td>The symbol for a Trade stock.</td>
+						</tr>
+						</tr>
+							<td class="left">Total Logins</td>
+							<td>The total number of logins performed by this user.</td>
+						</tr>
+						</tr>
+							<td class="left">Total Logouts</td>
+							<td>The total number of logouts performed by this user.</td>
+						</tr>
+						</tr>
+							<td class="left">Total of Holdings</td>
+							<td>The current total value of all stock holdings in this account given the current valuation of each stock held.</td>
+						</tr>
+						</tr>
+							<td class="left">Top gainers</td>
+							<td>The list of stocks (matching LIKE CLAUSE 's:1__%' per WebSphere Trade 6.1 behavior) gaining the most in price during the current trading session.</td>
+						</tr>
+						</tr>
+							<td class="left">Top Losers</td>
+							<td>The list of stocks (matching LIKE CLAUSE 's:1__%' per WebSphere Trade 6.1 behavior) falling the most in price during the current trading session.</td>
+						</tr>
+						</tr>
+							<td class="left">Trader Stock Index (TSIA)</td>
+							<td>A computed index of the top 20 stocks (matching LIKE CLAUSE 's:1__%' per WebSphere Trade 6.1 behavior) in Trade.</td>
+						</tr>
+						</tr>
+							<td class="left">Trading Volume</td>
+							<td>The total number of shares traded for stocks (matching LIKE CLAUSE 's:1__%' per WebSphere Trade 6.1 behavior) during this trading session.</td>
+						</tr>
+						</tr>
+							<td class="left">Txn Fee</td>
+							<td>The fee charged by the brokerage to process this order.</td>
+						</tr>
+						</tr>
+							<td class="left">Type</td>
+							<td>The order type (buy or sell).</td>
+						</tr>
+						</tr>
+							<td class="left">User ID</td>
+							<td>The unique user ID for the account chosen by the user at account registration.</td>
+						</tr>
+						</tr>
+							<td class="left">Volume</td>
+							<td>The total number of shares traded for this stock.</td>
+						</tr>
+					</tbody>
+				</table>
+								
+				
+				
+			
+			</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/home.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/home.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/home.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/home.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,231 @@
+<div id="middle">
+				<div class="main-title"><h1>Home</h1><script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script></div>
+				<h3>Welcome <%=@userId%></h3>
+
+				<table>
+				<tr>
+				<td>
+				<div class="left">
+					<table class="normal">
+						<thead><tr><th colspan="2">User Statistics</th></tr></thead>
+
+						  <%
+							if(@accountDataReturn)
+								creationDate = convert_date(@accountDataReturn["creationDate"])
+								lastLogin = convert_date(@accountDataReturn["lastLogin"])
+							%>
+								<tbody>
+								<tr><td class="left">Account ID:</td>
+									<td><%=@accountDataReturn["accountID"]%></td></tr>
+								<tr><td class="left">Account Created:</td>
+									<td><%=creationDate%></td></tr>
+								<tr><td class="left">Total Logins:</td>
+									<td><%=@accountDataReturn["loginCount"]%></td></tr>
+								<tr><td class="left">Session Created:</td>
+									<td><%=lastLogin%></td></tr>
+								</tbody>
+							<%
+              end
+						  %>
+
+
+						<thead><tr><th colspan="2">Summary</th></tr></thead>
+						<%
+							if (!(@holdingInfo == nil) || (@accountDataReturn == nil))
+							%>
+								<tbody>
+								<tr><td class="left">Cash Balance:</td>
+									<td><%=@accountDataReturn["balance"]%></td></tr>
+
+								<tr><td class="left">Number of Holdings:</td>
+									<td><%=@noOfHoldings%></td></tr>
+								
+								<tr><td class="left">Total of Holdings:</td><td>
+								<%=@totalHoldings%>
+								</td></tr>
+
+								<tr><td class="left">Sum of Cash and Holdings:</td><td>
+								$<%=@totalHoldings.to_f + (@accountDataReturn["balance"].to_f)%>
+								</td></tr>
+
+								<tr><td class="left">Opening Balance:</td><td>
+								$ <%=@accountDataReturn["openBalance"]%>
+								</td></tr>
+
+								<tr><td class="left">Current Gain/(Loss):</td>
+									<td><span class="price">
+								<% gain =  ((@totalHoldings.to_f + (@accountDataReturn["balance"].to_f)) - @accountDataReturn["openBalance"].to_f)%>
+                <%
+								if (gain < 0)
+								%>
+									<%=(-1) * gain%>
+								<%
+								elsif (gain >= 0)
+								%>
+									<%=gain%>
+								<%
+                end
+								gainPercent = (gain/@accountDataReturn["openBalance"].to_f) * 100
+                %>
+								</span></td></tr>
+
+
+								<tr><td class="left">%Gain/(Loss):</td><td>
+        
+                <%
+								if (gainPercent > 0)
+								%>
+									<span class="price-gain"><%=gainPercent%>%</span>
+								<%
+								elsif (gainPercent < 0)
+								%>
+									<span class="price-loss"><%=gainPercent%></span>
+								<%
+								else
+								%>
+									<span><%=gainPercent%>%</span>
+								<%
+                end
+								%>
+								</td></tr>
+								</tbody>
+							<%
+              end
+              %>
+							</table>
+						</td>
+
+						<td>
+						<div class="right">
+						<h3>Market Summary</h3>
+							<p><?php print(date("D, F j, Y, g:i a")); ?></p>
+
+							<table class="table-outer" cellspacing="0">
+              <%
+							if ((@holdingInfo != nil) && (@accountDataReturn != nil))
+							%>
+								<tr><td class="special">Trade Stock Index (TSIA)</td><td>
+								<%="%.2f" % @tsia%>
+                <%
+								if (@gain > 0)
+								%>
+                  <span class="price-gain">$
+								<%
+								elsif (@gain < 0)
+								%>
+                  <span class="price-loss">$
+								<%
+								else
+                %>
+									<span>$
+								<%
+								end
+                %>
+								<%="%.2f" % (@gain.to_f)%></span>
+								</td></tr>
+
+								<tr><td class="special">Trading Volume</td><td>
+
+								<%=@volume%>
+								</td></tr>
+
+								<tr><td class="special">Top Gainers</td><td>
+								<table class="table-inner" cellspacing="0">
+								<thead><tr><th>Symbol</th><th>Price</th><th>Change</th></tr></thead>
+								<tbody>
+
+                <%
+								index = 0
+								gainer = @topGainers[index]
+								while(gainer != nil)
+                %>
+									<tr><td><form action = "/trade/quotes" method = "post">
+										<input type="hidden" name="SYMBOLS" value="<%=gainer["symbol"]%>"/>
+										<input type="submit" name="GETQUOTE" value="<%=gainer["symbol"]%>"></input></form></td>
+
+									<td>$<%=gainer["price"]%></td>
+									<td>
+                  <%
+									if ((gainer["change"].to_f) > 0)
+									%>
+										<span class="price-gain">$
+									<%
+									elsif ((gainer["change"].to_f) < 0)
+									%>
+										<span class="price-loss">$
+									<%
+									else
+									%>
+										<span>$
+									<%
+                  end
+                  %>
+
+									<%=gainer["change"]%>
+									</span></td>
+									</form></tr>
+                  
+                  <%
+									index = index + 1
+									gainer = @topGainers[index]
+							  end
+                %>
+
+								</tbody></table></td></tr>
+
+								<tr><td class="special">Top Losers</td><td>
+									<table class="table-inner" cellspacing="0"><thead>
+									<tr><th>Symbol</th><th>Price</th><th>Change</th></tr></thead><tbody>
+
+                <%
+								index = 0
+								loser = @topLosers[index]
+								while(loser)
+								%>
+									<tr><td><form action = "quotes.php" method = "post">
+										<input type="submit" name="SYMBOLS" value="<%=loser["symbol"]%>"></input></form></td>
+
+									<td>$<%=loser["price"]%></td>
+									<td>
+                  
+                  <%
+									if ((loser["change"].to_f) > 0)
+									%>
+										<span class="price-gain">$
+									<%
+									elsif ((loser["change"].to_f) < 0)
+									%>
+										<span class="price-loss">$
+									<%
+									else
+									%>
+										<span>$
+									<%
+									end
+									%>
+									<%=loser["change"]%>
+									</span></td>	
+									</tr>
+                  
+                  <%
+									index = index + 1
+									loser = @topLosers[index]
+                end
+								%>
+								</tbody></table>
+								</td></tr></table>
+								</div>
+								</td></tr></table>
+							<%
+              end
+              %>
+
+
+			<div class="bottom">
+			<form method = "post"  action = "/trade/quotes">
+			<input type="text" value="<%=%>" name="SYMBOLS" size="25"/>
+			<input type="submit" value="Get Quote" name="GETQUOTE" class="button"/>
+			</form>
+			</div>
+</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/index.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/index.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/index.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/index.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,42 @@
+        <div id="middle">
+                <div class="main-title">
+        <h1>Welcome!</h1>
+        <script type=\"text/javascript\">
+            var thisdate = new Date();
+            document.writeln(thisdate.toLocaleString());
+        </script>
+        </div>
+        <table>
+        <tr>
+        <td>
+        <div class="left">
+                <p> The design of WSO2 StockTrader sample application is based on an online stock trading scenario with the functionality of the application equivalent to the  <a href="http://msdn.microsoft.com/stocktrader">Microsoft .NET Stock Trader </a> sample benchmark application and <a href="https://www14.software.ibm.com/webapp/iwm/web/preLogin.do?source=trade6">IBM WebSphere's Trade 6.1 </a> sample application. WSO2 StockTrader sample application is powered by <a href="http://wso2.org/projects/wsf/php">WSO2 WSF/PHP</a> and <a href="http://wso2.org/projects/wsas/java">WSO2 WSAS</a>. It serves to illustrate interoperability between PHP Java and .NET in deploying high-performance, scalable service oriented applications. </p>
+
+<p>For more details, check <a href="http://wso2.org/interop/stocktrader">WSO2 Stock Trader home page</a>. </p>
+
+        </div>
+        </td>
+        <td>    
+        <div class="right">
+                        <h3>Sample of Technologies Demonstrated</h3>
+                        <table>
+                            <tbody>
+                                <tr>
+                                    <td>
+                                        <ul>
+                                            <li>Service-oriented, n-tier design with PHP, Java and .NET</li>
+                                            <li>Clean separation of UI, business services and DB access</li>
+                                            <li>WSO2 Web Services Framework For PHP</li>
+                                            <li>WSO2 Web Services Application Server</li>
+                                            <li>Interoperability with .NET</li>
+                                            <li>Loosely-coupled, message-oriented design</li>
+                                        </ul>
+                                    </td>
+                                </tr>
+                            </tbody>
+                        </table>
+                    </div>
+                </tr>   
+            </table>
+        </div>
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/login.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/login.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/login.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/login.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,36 @@
+<div id="middle">
+
+    <div class="main-title">
+	 <h1>Login</h1>
+	 <b><%= @message %>  </b>
+       <script type="text/javascript">
+            var thisdate = new Date();
+            document.writeln(thisdate.toLocaleString());
+        </script>
+    </div>
+
+    <div class="login">
+        <form method="post"  action="/trade/login">
+            <table>
+                <tr>
+                    <td>Username</td>
+                    <td><input name="USERNAME" size="25"/></td>
+                </tr>
+                <tr>
+                    <td>Password</td>
+                    <td><input type="password" name="PASSWORD" size="25"/></td>
+                </tr>
+                <tr>
+                    <td></td>
+                    <td><input type="submit" name="LOGINREQUEST" value="Login" class="button"/></td>
+                </tr>
+            </table>
+        </form>
+
+        <p>Try password "xxx" for user "uid:0" to access the stock trader web application.</p>
+        <p class="new-user">
+            <a href="/trade/register">First time user?</a>
+        </p>
+</div>	
+</div>	
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/portfolio.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/portfolio.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/portfolio.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/portfolio.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,153 @@
+        <%
+				# Checking whether there is new status change happened in the 
+				# related to a particular order.
+				if (@closedOrders != nil)
+				%>
+					<p style="color: red" align="center">Trade Alert: 
+						The following orders have completed.</p>
+					<table class="table-outer" 
+						cellspacing="0" align="center"><thead>
+						<tr><th>Order ID</th><th>Order Status</th>
+						<th>Creation Date</th><th>Completion Date</th>
+						<th>Txn Fee</th><th>Type</th><th>Symbol</th>
+						<th>Quantity</th></tr></thead><tbody>
+          
+          <%
+					index = 0
+          if(@closedOrders["OrderDataBean"].class.to_s == "Array")
+            while ((order = @closedOrders["OrderDataBean"][index]) != nil)
+              openDate = convert_date(order["openDate"])
+              completionDate = convert_date(order["completionDate"])
+              %>
+              <tr>
+                <td><%=order["orderID"]%></td>
+                <td><%=order["orderStatus"]%></td>
+                <td><%=openDate%></td>
+                <td><%=completionDate%></td>
+                <td>$<%=order["orderFee"]%></td>
+                <td><%=order["orderType"]%></td>
+                <td><%=order["symbol"]%></td>
+                <td><%=order["quantity"]%></td>
+              </tr>
+              <%
+              index = index + 1
+            end
+          else
+            order = @closedOrders["OrderDataBean"]
+            openDate = convert_date(order["openDate"])
+            completionDate = convert_date(order["completionDate"])
+            %>
+            <tr>
+              <td><%=order["orderID"]%></td>
+              <td><%=order["orderStatus"]%></td>
+              <td><%=openDate%></td>
+              <td><%=completionDate%></td>
+              <td>$<%=order["orderFee"]%></td>
+              <td><%=order["orderType"]%></td>
+              <td><%=order["symbol"]%></td>
+              <td><%=order["quantity"]%></td>
+            </tr>
+          <%
+          end
+          %>
+					</tbody></table><br/><br/>
+        <%
+        end
+				%>
+
+        <%
+				if (@holdingsReturn)
+          %>
+					<div class="main-title">
+						<h1>Portfolio Information</h1><script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script></div>
+
+					<table class="table-outer" cellspacing="0" align="center">
+						<thead><tr><th>Holding ID</th><th>Purchase Date</th><th>Symbol</th>
+						<th>Quantity</th><th>Purchase Price</th><th>Current Price</th>
+						<th>Purchase Basis</th><th>Market Value</th><th>Gain(Loss)</th>
+						<th>Trade</th></tr></thead><tbody>
+          <%
+					index = 0;
+					purchaseBasis = 0;
+					marketValue = 0;
+					gain = 0;
+
+					while ((bean=@holdingsReturn["HoldingDataBean"][index]) != nil)
+            
+            quoteID = bean["quoteID"]
+						purchaseBasis = purchaseBasis + bean["purchasePrice"].to_f * (bean["quantity"].to_i)
+						marketValue = marketValue + (@quoteInfo[quoteID].to_i) * (bean["quantity"].to_i)
+						gain = (@quoteInfo[quoteID].to_f - bean["purchasePrice"].to_f) * (bean["quantity"].to_i)
+
+						dateTime = convert_date(bean["purchaseDate"])
+						%>
+            
+            <tr>
+              <td><%=bean["holdingID"]%></td>
+              <td><nobr><%=dateTime%></nobr></td>
+              <td>
+							<form action="/trade/quotes" method="post">
+							<input type="hidden" name="SYMBOLS" value="<%=bean["quoteID"]%>"/>	
+							<input type="submit" name="GETQUOTE" value="<%=bean["quoteID"]%>"></input>
+							</form></td>
+							<td class="currency"><%=bean["quantity"]%></td>
+              <td class="currency">$<%=bean["purchasePrice"]%></td>
+              <td class="currency">$<%=@quoteInfo[quoteID]%></td>
+              <td class="currency">$<%="%.2f" % ((bean["purchasePrice"].to_f) * (bean["quantity"].to_i))%></td>
+              <td class="currency">$<%="%.2f" % (@quoteInfo[quoteID].to_f * bean["quantity"].to_i)%></td>
+              <td class="currency">
+            <%
+						if (gain > 0)
+						%>
+							<span class="price-gain">$<%="%.2f" % gain%></span>
+						<%
+						elsif (gain < 0)
+              gain = gain * -1
+						%>
+							<span class="price-loss">$<%="%.2f" % gain%></span>
+						<%
+						else
+						%>
+							<span>$<%="%.2f" % gain%></span>
+						<%
+            end
+            %>
+						</td><td class="currency">
+						<form action = "/trade/confirmation" method = "post">
+						<input type="hidden" name="HOLDINGID" value="<%=bean["holdingID"]%>"></input>
+						<input type="hidden" name="QUANTITY" value="<%=bean["quantity"]%>"></input>
+						<input type="hidden" name="SYMBOL" value="<%=bean["quoteID"]%>"></input>
+						<input type="submit" value = "Sell" name="SELL">
+						</input></td></tr></form>
+
+					  <%
+						index = index + 1
+          end
+          %>
+					<tr class="total"><td colspan="6">Totals</td><td class="currency">$<%=purchaseBasis%></td>
+          <td class="currency">$<%=marketValue%></td><td>
+
+          <%
+					gain = marketValue - purchaseBasis
+					if (gain < 0)
+					%>
+						<span class=\"price-loss\">$<%=gain%></span></td><td></td></tr>
+					<%
+					elsif (gain > 0)
+					%>
+						<span class=\"price-gain\">$<%=gain%></span></td><td></td></tr>
+					<%
+					else
+					%>
+						<span>$<%=gain%></span></td><td></td></tr>
+					<%
+					end
+					%>
+					
+					</tbody></table>
+				<%
+        end
+        %>
+
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/quotes.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/quotes.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/quotes.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/quotes.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,231 @@
+<div id="middle">
+        
+        <%
+				# Checking whether there is new status change happened in the 
+				# related to a particular order.
+				if (@closedOrders != nil)
+				%>
+					<p style="color: red" align="center">Trade Alert: 
+						The following orders have completed.</p>
+					<table class="table-outer" 
+						cellspacing="0" align="center"><thead>
+						<tr><th>Order ID</th><th>Order Status</th>
+						<th>Creation Date</th><th>Completion Date</th>
+						<th>Txn Fee</th><th>Type</th><th>Symbol</th>
+						<th>Quantity</th></tr></thead><tbody>
+          
+          <%
+					index = 0
+          if(@closedOrders["OrderDataBean"].class.to_s == "Array")
+            while ((order = @closedOrders["OrderDataBean"][index]) != nil)
+              openDate = convert_date(order["openDate"])
+              completionDate = convert_date(order["completionDate"])
+              %>
+              <tr>
+                <td><%=order["orderID"]%></td>
+                <td><%=order["orderStatus"]%></td>
+                <td><%=openDate%></td>
+                <td><%=completionDate%></td>
+                <td>$<%=order["orderFee"]%></td>
+                <td><%=order["orderType"]%></td>
+                <td><%=order["symbol"]%></td>
+                <td><%=order["quantity"]%></td>
+              </tr>
+              <%
+              index = index + 1
+            end
+          else
+            order = @closedOrders["OrderDataBean"]
+            openDate = convert_date(order["openDate"])
+            completionDate = convert_date(order["completionDate"])
+            %>
+            <tr>
+              <td><%=order["orderID"]%></td>
+              <td><%=order["orderStatus"]%></td>
+              <td><%=openDate%></td>
+              <td><%=completionDate%></td>
+              <td>$<%=order["orderFee"]%></td>
+              <td><%=order["orderType"]%></td>
+              <td><%=order["symbol"]%></td>
+              <td><%=order["quantity"]%></td>
+            </tr>
+          <%
+          end
+          %>
+					</tbody></table><br/><br/>
+        <%
+        end
+				%>
+
+        <%
+				if (@isReply)
+					# Check whether the user has requested to buy or sell some quote.
+				%>
+					<div class="main-title"><h1>New Order</h1>
+						<script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script></div>
+					<p align="center">Order 
+						<%= (@buyReturn && @buyReturn["orderID"] != nil) ?  @buyReturn["orderID"]: @sellEnhancedReturn["orderID"] %>
+            to 
+						<%= (@buyReturn && @buyReturn["quantity"] != nil) ? "buy " + @buyReturn["quantity"]: "sell " + @sellEnhancedReturn["quantity"] %>
+            shares of s:0 has been submitted for processing.</p>
+					<p align="center">Order Details:</p>
+					<table class="table-outer" cellspacing="0" align="center"><thead><tr>
+						<th>Order ID</th><th>Order Status</th><th>Creation Date</th>
+						<th>Completion Date</th><th>Txn Fee</th><th>Type</th><th>Symbol</th>
+							<th>Quantity</th></tr></thead>
+							<tbody>
+          <%
+					if(@isBuy)
+						dateTime = convert_date(@buyReturn["openDate"])
+            %>
+						<tr>
+              <td><%=@buyReturn["orderID"]%></td>
+              <td><%=@buyReturn["orderStatus"]%></td>
+							<td><%=dateTime%></td>
+              <td>Pending </td>
+              <td>$<%=@buyReturn["orderFee"]%></td>
+              <td><%=@buyReturn["orderType"]%></td>
+              <td><%=@buyReturn["symbol"]%></td>
+              <td><%=@buyReturn["quantity"]%></td>
+            </tr>
+          <%
+					elsif (@isSell)
+						dateTime = convert_date(@sellEnhancedReturn["openDate"])
+            %>
+						<tr>
+              <td><%=@sellEnhancedReturn["orderID"]%></td>
+              <td><%=@sellEnhancedReturn["orderStatus"]%></td>
+              <td><%=dateTime%></td>
+              <td>Pending</td>
+              <td>$<%=@sellEnhancedReturn["orderFee"]%></td>
+              <td><%=@sellEnhancedReturn["orderType"]%></td>
+              <td><%=@sellEnhancedReturn["symbol"]%></td>
+              <td><%=@sellEnhancedReturn["quantity"]%></td>
+            </tr>
+          <%
+					end
+          %>
+					</tbody></table>
+        <%
+				elsif(@quotesReturn != nil) #else to isreply
+        %>
+					<div class=\"main-title\"><h1>Stock Quotes</h1>
+					<script type=\"text/javascript\">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script>
+					</div>
+					<table class="table-outer" cellspacing="0" align="center"><thead>
+						<tr><th>Symbol</th><th>Company</th><th>Volume</th><th>Price Range</th>
+						<th>Open Price</th><th>Current Price</th><th>Gain(Loss)</th><th>Trade</th></tr></thead><tbody>
+
+          <%
+					if(@quotesReturn["symbol"] != nil)
+					%>
+					  <tr>
+              <td><%=@quotesReturn["symbol"]%></td>
+              <td><%=@quotesReturn["companyName"]%></td>
+              <td><%=@quotesReturn["volume"]%></td>
+              <td>$<%=@quotesReturn["low"]%>-$<%=@quotesReturn["high"]%></td>
+              <td>$<%=@quotesReturn["open"]%></td>
+							<td>$<%=@quotesReturn["price"]%></td>
+            <td> 
+            <%
+						if (@quotesReturn["change"].to_f > 0)
+            %>
+							<span class="price-gain">$<%="%.2f" % @quotesReturn["change"]%></span>
+						<%
+						elsif (@quotesReturn["change"].to_f < 0)
+              abs_change = -1 * @quotesReturn["change"].to_f 
+						%>
+							<span class="price-loss">$<%="%.2f" % (abs_change)%></span>
+						<%
+						else
+						%>
+							<span>$<%=@quotesReturn["change"]%></span>
+            <%
+						end
+            %>
+						</td><td><form action="/trade/confirmation" method="post">
+							<input type="hidden" name="QUANTITY" value="<%=@quotesReturn["volume"]%>"/>
+							<input type="hidden" name="SYMBOL" value="<%=@quotesReturn["symbol"]%>"/>
+							<input type="hidden" name="PRICE" value="<%=@quotesReturn["price"]%>"/>
+							<input type="submit" name="BUY" value="Buy"></input>
+            </form></td></tr>
+          <%
+					end
+          %>
+					</tbody></table>
+        <%
+				elsif(@quotesInitialPage) # else for isreply
+				%>
+					<div class="main-title"><h1>Stock Quotes</h1>
+					<script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script>
+					</div>
+					<table class="table-outer" cellspacing="0" align="center"><thead>
+						<tr><th>Symbol</th><th>Company</th><th>Volume</th><th>Price Range</th>
+						<th>Open Price</th><th>Current Price</th><th>Gain(Loss)</th><th>Trade</th></tr></thead><tbody>
+
+          <%
+					symbolCount = 0;
+					while(symbolCount < 5)
+						quotesReturn = GetQuote("s:" + symbolCount.to_s)
+
+						if (quotesReturn)
+							if (quotesReturn["symbol"])
+                %>
+								<tr>
+                  <td><%=quotesReturn["symbol"]%></td>
+                  <td><%=quotesReturn["companyName"]%></td>
+                  <td><%=quotesReturn["volume"]%></td>
+                  <td>$<%=quotesReturn["low"]%>-$<%=quotesReturn[">high"]%></td>
+                  <td>$<%=quotesReturn["open"]%></td>
+									<td>$<%=quotesReturn["price"]%></td>
+                <td>
+                <%
+								if (quotesReturn["change"].to_f> 0)
+								%>
+									<span class="price-gain">$<%="%.2f" % quotesReturn["change"]%></span>
+								<%
+								elsif (quotesReturn["change"].to_f< 0)
+                  abs_ret = -1 *quotesReturn["change"].to_f
+								%>
+									<span class="price-loss">$<%="%.2f" % (abs_ret)%></span>
+								<%
+								else
+								%>
+									<span>$<%=quotesReturn["change"]%></span>
+								<%
+                end
+                %>
+								</td>
+                <td><form action="/trade/confirmation" method="post">
+									<input type="hidden" name="QUANTITY" value="<%=quotesReturn["volume"]%>"/>
+									<input type="hidden" name="SYMBOL" value="<%=quotesReturn["symbol"]%>"/>
+									<input type="hidden" name="PRICE" value="<%=quotesReturn["price"]%>"/>
+									<input type="submit" name="BUY" value="Buy"></input></form></td></tr>
+							<%
+              end
+              %>
+						<%
+            end
+						symbolCount = symbolCount + 1
+            %>
+					<%
+          end
+          %>
+					</tbody></table>
+
+				<%
+        else
+        %>
+					<div class="main-title"><h1>Stock Quotes</h1>
+					<script type="text/javascript">var thisdate = new Date();
+					document.writeln(thisdate.toLocaleString());</script>
+					</div>
+        <%
+        end
+        %>
+
+        
+</div>

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/register.html.erb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/register.html.erb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/register.html.erb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/app/views/trade/register.html.erb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,81 @@
+<%=@message%>
+<div id="middle">
+				<div class="main-title">
+					<h1>Register</h1>
+					<script type="text/javascript">
+						var thisdate = new Date();
+						document.writeln(thisdate.toLocaleString());
+					</script>
+				</div>
+        
+        <%
+				if (@successfulRegistration)
+				%>
+					<p style="color: red" align="center">
+						Registration was successful, please <a href ="/trade/login">login</a>.</p>
+				<%
+        else
+					if (@invalidInformation)
+				  %>
+						<p style="color: red" align="center">Please enter valid information.</p>
+					<%
+          end
+          %>
+					<table class="profile" cellspacing="0" width="100%">
+					<thead>
+					<tr>
+					<th>
+					Create Account Profile:
+					</th>
+					</tr>
+					</thead>
+					<tbody>
+					<tr>
+						<td>
+							<form action="/trade/register" method="post">
+							<table cellspacing="0" align="center">
+								<tr>
+									<td colspan="4" >
+										&nbsp;
+									</td>
+								</tr>
+								<tr>
+									<td>Requested ID:</td>
+									<td><input name="REQUESTEDID" type="text" id="" size="25"/></td>
+									<td>Opening Balance:</td>
+									<td><input type="text" name="OPENBALANCE" value="100000" id="" size="25"/></td>
+								</tr>
+								<tr>
+									<td>Full Name:</td>
+									<td><input type="text" name="FULLNAME" id="" size="25"/></td>
+									<td>Email Address:</td>
+									<td><input type="text" name="EMAIL" id="" size="25"/></td>
+								</tr>
+								<tr>
+									<td>Address:</td>
+									<td><input name="ADDRESS" type="text" id="" size="25"/></td>
+									<td>Password:</td>
+									<td><input name="PASSWORD" type="password" id="" size="25"/></td>
+								</tr>
+								<tr>
+									<td>Credit Card:</td>
+									<td><input name="CREDITCARD" type="text" id="" size="25"/></td>
+									<td>Confirm Password:</td>
+									<td><input name="CONFIRMATIONPASSWORD" type="password" id="" size="25"/></td>
+								</tr>
+								<tr>
+									<td colspan="4" class="button">
+										<input type="submit" name="REGISTERUSER" value="Register" class="button"/>
+									</td>
+								</tr>
+							</table>
+							</form>	
+						</td>
+					</tr>
+					</tbody>
+					</table>
+				<%
+        end
+        %>
+</div>
+

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/boot.rb
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/boot.rb?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/boot.rb (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/boot.rb Wed Nov 26 02:52:40 2008
@@ -0,0 +1,127 @@
+
+# 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.
+
+
+
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
+
+module Rails
+  class << self
+    def boot!
+      unless booted?
+        preinitialize
+        pick_boot.run
+      end
+    end
+
+    def booted?
+      defined? Rails::Initializer
+    end
+
+    def pick_boot
+      (vendor_rails? ? VendorBoot : GemBoot).new
+    end
+
+    def vendor_rails?
+      File.exist?("#{RAILS_ROOT}/vendor/rails")
+    end
+
+    def preinitialize
+      load(preinitializer_path) if File.exist?(preinitializer_path)
+    end
+
+    def preinitializer_path
+      "#{RAILS_ROOT}/config/preinitializer.rb"
+    end
+  end
+
+  class Boot
+    def run
+      load_initializer
+      Rails::Initializer.run(:set_load_path)
+    end
+  end
+
+  class VendorBoot < Boot
+    def load_initializer
+      require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+      Rails::Initializer.run(:install_gem_spec_stubs)
+    end
+  end
+
+  class GemBoot < Boot
+    def load_initializer
+      self.class.load_rubygems
+      load_rails_gem
+      require 'initializer'
+    end
+
+    def load_rails_gem
+      if version = self.class.gem_version
+        gem 'rails', version
+      else
+        gem 'rails'
+      end
+    rescue Gem::LoadError => load_error
+      $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
+      exit 1
+    end
+
+    class << self
+      def rubygems_version
+        Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+      end
+
+      def gem_version
+        if defined? RAILS_GEM_VERSION
+          RAILS_GEM_VERSION
+        elsif ENV.include?('RAILS_GEM_VERSION')
+          ENV['RAILS_GEM_VERSION']
+        else
+          parse_gem_version(read_environment_rb)
+        end
+      end
+
+      def load_rubygems
+        require 'rubygems'
+
+        unless rubygems_version >= '0.9.4'
+          $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
+          exit 1
+        end
+
+      rescue LoadError
+        $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
+        exit 1
+      end
+
+      def parse_gem_version(text)
+        $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
+      end
+
+      private
+        def read_environment_rb
+          File.read("#{RAILS_ROOT}/config/environment.rb")
+        end
+    end
+  end
+end
+
+# All that for this:
+Rails.boot!

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml Wed Nov 26 02:52:40 2008
@@ -0,0 +1,42 @@
+# MySQL.  Versions 4.1 and 5.0 are recommended.
+#
+# Install the MySQL driver:
+#   gem install mysql
+# On Mac OS X:
+#   sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
+# On Mac OS X Leopard:
+#   sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
+#       This sets the ARCHFLAGS environment variable to your native architecture
+# On Windows:
+#   gem install mysql
+#       Choose the win32 build.
+#       Install MySQL and put its /bin directory on your path.
+#
+# And be sure to use new-style password hashing:
+#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
+development:
+  adapter: mysql
+  encoding: utf8
+  database: rubytraderclient_development
+  username: %
+  password: 
+  host: localhost
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+  adapter: mysql
+  encoding: utf8
+  database: rubytraderclient_test
+  username: %
+  password: 
+  host: localhost
+
+production:
+  adapter: mysql
+  encoding: utf8
+  database: rubytraderclient_production
+  username: %
+  password: 
+  host: localhost

Added: incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml.bk
URL: http://svn.apache.org/viewvc/incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml.bk?rev=720797&view=auto
==============================================================================
--- incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml.bk (added)
+++ incubator/stonehenge/contrib/stocktrader/ruby/trader_client/config/database.yml.bk Wed Nov 26 02:52:40 2008
@@ -0,0 +1,19 @@
+# SQLite version 3.x
+#   gem install sqlite3-ruby (not necessary on OS X Leopard)
+development:
+  adapter: sqlite3
+  database: db/development.sqlite3
+  timeout: 5000
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+  adapter: sqlite3
+  database: db/test.sqlite3
+  timeout: 5000
+
+production:
+  adapter: sqlite3
+  database: db/production.sqlite3
+  timeout: 5000



Mime
View raw message