tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sl...@apache.org
Subject svn commit: r682170 - in /tuscany/sandbox/travelsample: ./ common-contribution/src/scatours/common/ currency-contribution/src/scatours/currencyconverter/ hotel-contribution/src/scatours/hotel/ node/ node/src/scatours/ trip-contribution/src/scatours/tri...
Date Sun, 03 Aug 2008 13:36:25 GMT
Author: slaws
Date: Sun Aug  3 06:36:24 2008
New Revision: 682170

URL: http://svn.apache.org/viewvc?rev=682170&view=rev
Log:
Updates to add in cars and flights

Added:
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java   (with
props)
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java   (with
props)
Removed:
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java
Modified:
    tuscany/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
    tuscany/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
    tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java
    tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java
    tuscany/sandbox/travelsample/node/build.xml
    tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java
    tuscany/sandbox/travelsample/pom.xml
    tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
    tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
    tuscany/sandbox/travelsample/ui-contribution/build.xml
    tuscany/sandbox/travelsample/ui-contribution/scatours.composite
    tuscany/sandbox/travelsample/ui-contribution/scatours.html

Modified: tuscany/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java (original)
+++ tuscany/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java Sun
Aug  3 06:36:24 2008
@@ -27,22 +27,34 @@
     private String name;
     private String description;
     private String location;
+    private String fromDate;
+    private String toDate;
+    private double price;
+    private String currency;
     private String link;
     
     public TripItem() {
     }  
     
     public TripItem(String id, 
-                        String type, 
-                        String name, 
-                        String description, 
-                        String location, 
-                        String link) {
+                    String type, 
+                    String name, 
+                    String description, 
+                    String location, 
+                    String fromDate, 
+                    String toDate, 
+                    double price, 
+                    String currency, 
+                    String link) {
         this.id = id;
         this.type = type;
         this.name = name;
         this.description = description;
         this.location = location;
+        this.fromDate = fromDate;
+        this.toDate = toDate;
+        this.price = price;
+        this.currency = currency;
         this.link = link;
     }  
     
@@ -86,6 +98,38 @@
         this.location = location;
     }
     
+    public String getFromDate() {
+        return fromDate;
+    }
+    
+    public void setFromDate(String fromDate) {
+        this.fromDate = fromDate;
+    }
+    
+    public String getToDate() {
+        return toDate;
+    }
+    
+    public void setToDate(String toDate) {
+        this.toDate = toDate;
+    }
+    
+    public double getPrice() {
+        return price;
+    }
+    
+    public void setPrice(double price) {
+        this.price = price;
+    }
+    
+    public String getCurrency() {
+        return currency;
+    }
+    
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+    
     public String getLink() {
         return link;
     }

Modified: tuscany/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
(original)
+++ tuscany/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
Sun Aug  3 06:36:24 2008
@@ -18,6 +18,9 @@
  */
 package scatours.currencyconverter;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.osoa.sca.annotations.Service;
 
 /**
@@ -25,10 +28,24 @@
  */
 @Service(interfaces={CurrencyConverter.class})
 public class CurrencyConverterImpl implements CurrencyConverter {
+    
+    // currency index
+    private Map<String, Integer> currencyIndex = new HashMap<String, Integer>();
+    
+    // exchange rates
+    private final double rates [][] = {{ 1.00, 0.50, 0.66 },
+                                       { 2.00, 1.00, 1.33 },
+                                       { 1.50, 0.75, 1.00 } } ;  
+    
+    public CurrencyConverterImpl(){
+        currencyIndex.put("USD", new Integer(0));
+        currencyIndex.put("GBP", new Integer(1));
+        currencyIndex.put("EUR", new Integer(2));
+    }
 
     public double getExchangeRate(String fromCurrencyCode, String toCurrencyCode){
-        // regardless of which currencies are specified return the same value
-        return 1.98;
+        return rates[currencyIndex.get(fromCurrencyCode).intValue()]
+                    [currencyIndex.get(toCurrencyCode).intValue()];
     } 
 
     public double convert(String fromCurrencyCode, String toCurrencyCode, double amount){

Modified: tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java (original)
+++ tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java Sun
Aug  3 06:36:24 2008
@@ -48,18 +48,34 @@
         hotels.add(new HotelInfo("Deep Bay Hotel", 
                              "Wonderful sea views and a relaxed atmosphere", 
                              "ANU", 
+                             "06/12/08",
+                             "200",
+                             100,
+                             "USD",
                              "http://localhost:8085/tbd" ));
         hotels.add(new HotelInfo("Long Bay Hotel", 
                              "Friendly staff and an ocean breeze", 
                              "ANU", 
+                             "06/12/08",
+                             "200",
+                             100,
+                             "USD",
                              "http://localhost:8085/tbd" ));
         hotels.add(new HotelInfo("City Hotel", 
                              "Smart rooms and early breakfasts", 
                              "NY", 
+                             "06/12/08",
+                             "200",
+                             100,
+                             "USD",
                              "http://localhost:8085/tbd" ));
         hotels.add(new HotelInfo("County Hotel", 
                              "The smell of the open country", 
                              "SOU", 
+                             "06/12/08",
+                             "200",
+                             100,
+                             "USD",
                              "http://localhost:8085/tbd" ));
     }
     
@@ -74,6 +90,10 @@
                                              hotel.getName(), 
                                              hotel.getDescription(), 
                                              hotel.getLocation(), 
+                                             tripLeg.getFromDate(),
+                                             tripLeg.getToDate(),
+                                             hotel.getPricePerBed(),
+                                             hotel.getCurrency(),
                                              hotel.getLink());
                 items.add(item);
             }

Modified: tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java (original)
+++ tuscany/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java Sun
Aug  3 06:36:24 2008
@@ -25,6 +25,10 @@
     private String name;
     private String description;
     private String location;
+    private String date;
+    private String beds;
+    private double pricePerBed;
+    private String currency;
     private String link;
     
     public HotelInfo() {
@@ -33,11 +37,19 @@
     public HotelInfo(String name, 
                  String description, 
                  String location,
+                 String date,
+                 String beds,
+                 double pricePerBed,
+                 String currency,
                  String link) {
 
         this.name = name;
         this.description = description;
         this.location = location;
+        this.date = date;
+        this.beds = beds;
+        this.pricePerBed = pricePerBed;
+        this.currency = currency;
         this.link = link;
     }  
     
@@ -66,6 +78,38 @@
         this.location = location;
     }
     
+    public String getDate() {
+        return date;
+    }
+    
+    public void setDate(String date) {
+        this.date = date;
+    }
+    
+    public String getBeds() {
+        return beds;
+    }   
+    
+    public void setBeds(String beds) {
+        this.beds = beds;
+    }
+    
+    public double getPricePerBed() {
+        return pricePerBed;
+    }
+    
+    public void setPricePerBed(double pricePerBed) {
+        this.pricePerBed = pricePerBed;
+    }
+    
+    public String getCurrency() {
+        return currency;
+    }
+    
+    public void setCurrency(String currency) {
+        this.currency = currency;
+    }
+    
     public String getLink() {
         return link;
     }

Modified: tuscany/sandbox/travelsample/node/build.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/node/build.xml?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/node/build.xml (original)
+++ tuscany/sandbox/travelsample/node/build.xml Sun Aug  3 06:36:24 2008
@@ -161,7 +161,6 @@
         <include name="commons-logging-1.1.jar"/>
         <include name="derby-10.3.1.4.jar"/>
         <include name="dom4j-1.6.1.jar"/>
-        <include name="geronimo-activation_1.0.2_spec-1.1.jar"/>
         <include name="geronimo-activation_1.1_spec-1.0-M1.jar"/>
         <include name="geronimo-commonj_1.1_spec-1.0.jar"/>
         <include name="geronimo-ejb_3.0_spec-1.0.jar"/>
@@ -175,7 +174,7 @@
         <include name="jaxen-1.1.1.jar"/>
         <include name="jaxws-api-2.1.jar"/>
         <include name="jdom-1.0.jar"/>
-        <include name="jettison-1.0.jar"/>
+        <include name="jettison-1.0.1.jar"/>
         <include name="jetty-6.1.7.jar"/>
         <include name="jetty-util-6.1.7.jar"/>
         <include name="json-rpc-1.0.jar"/>

Modified: tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java (original)
+++ tuscany/sandbox/travelsample/node/src/scatours/LaunchNode.java Sun Aug  3 06:36:24 2008
@@ -40,6 +40,8 @@
                                                                new SCAContribution("common",
"../common-contribution/target/scatours-common-contribution.jar"),
                                                                new SCAContribution("currency",
"../currency-contribution/target/scatours-currency-contribution.jar"),
                                                                new SCAContribution("hotel",
"../hotel-contribution/target/scatours-hotel-contribution.jar"),
+                                                               new SCAContribution("flight",
"../flight-contribution/target/scatours-flight-contribution.jar"),
+                                                               new SCAContribution("car",
"../car-contribution/target/scatours-car-contribution.jar"),
                                                                new SCAContribution("trip",
"../trip-contribution/target/scatours-trip-contribution.jar"),
                                                                new SCAContribution("ui",
"../ui-contribution/target/scatours-ui-contribution.jar"));
 
@@ -66,6 +68,8 @@
                                                                new SCAContribution("common",
"../common-contribution/target/classes"),
                                                                new SCAContribution("currency",
"../currency-contribution/target/classes"),
                                                                new SCAContribution("hotel",
"../hotel-contribution/target/classes"),
+                                                               new SCAContribution("flight",
"../flight-contribution/target/classes"),
+                                                               new SCAContribution("car",
"../car-contribution/target/classes"),
                                                                new SCAContribution("trip",
"../trip-contribution/target/classes"),
                                                                new SCAContribution("ui",
"../ui-contribution/target/classes"));
             node.start();

Modified: tuscany/sandbox/travelsample/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/pom.xml?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/pom.xml (original)
+++ tuscany/sandbox/travelsample/pom.xml Sun Aug  3 06:36:24 2008
@@ -40,6 +40,8 @@
                 <module>common-contribution</module>
                 <module>currency-contribution</module>
                 <module>hotel-contribution</module>
+                <module>flight-contribution</module>
+                <module>car-contribution</module>
                 <module>payment-contribution</module>
                 <module>trip-contribution</module>
                 <module>ui-contribution</module>

Added: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java?rev=682170&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java (added)
+++ tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java Sun
Aug  3 06:36:24 2008
@@ -0,0 +1,34 @@
+/*
+ * 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 scatours.trip;
+
+import org.apache.tuscany.sca.data.collection.Collection;
+import org.osoa.sca.annotations.Remotable;
+
+import scatours.common.TripItem;
+
+/**
+ * The Trip service interface
+ */
+@Remotable
+public interface TripContents extends Collection<String, TripItem> {
+    
+    void addTripItem(String id);
+    double getTotalPrice();
+}

Propchange: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java (original)
+++ tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java Sun Aug
 3 06:36:24 2008
@@ -19,8 +19,13 @@
 package scatours.trip;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.UUID;
 
+import org.apache.tuscany.sca.data.collection.Entry;
+import org.apache.tuscany.sca.data.collection.NotFoundException;
 import org.osoa.sca.annotations.Property;
 import org.osoa.sca.annotations.Reference;
 import org.osoa.sca.annotations.Scope;
@@ -36,46 +41,136 @@
  * An implementation of the Trip service
  */
 @Scope("COMPOSITE")
-@Service(interfaces={Trip.class})
-public class TripImpl implements Trip, SearchCallback {
+@Service(interfaces={TripSearch.class, TripContents.class})
+public class TripImpl implements TripSearch, SearchCallback, TripContents{
     
     @Reference
     protected CurrencyConverter currencyConverter;
     
     @Reference 
     protected Search hotelSearch;
+    
+    @Reference 
+    protected Search flightSearch;
+    
+    @Reference 
+    protected Search carSearch;
         
     @Property
     public String quoteCurrencyCode = "USD";
     
     private List<TripItem> searchResults = new ArrayList<TripItem>();
+    private Map<String, TripItem> tripItems = new HashMap<String, TripItem>();
+    
+    // TripSearch methods
     
     public TripItem[] search(TripLeg tripLeg) {
         
+        searchResults.clear();
+        
         hotelSearch.searchAsynch(tripLeg);
-        //flightSearch.searchAsynch(tripLeg);
-        //carSearch.searchAsynch(tripLeg);
+        flightSearch.searchAsynch(tripLeg);
+        carSearch.searchAsynch(tripLeg);
         
-        // TODO - extend this to have the three searches run in parallel
+        // TODO - wait for searches to complete
         
-        TripItem[] tripItemArray = searchResults.toArray(new TripItem[searchResults.size()]);
-        searchResults.clear();
+        for (TripItem tripItem : searchResults){
+            tripItem.setId(String.valueOf(searchResults.indexOf(tripItem)));
+            tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), 
+                                                        quoteCurrencyCode, 
+                                                        tripItem.getPrice()));
+            tripItem.setCurrency(quoteCurrencyCode);
+        }
         
-        return tripItemArray;
-    }
-       
-    public double getTotalPrice(){
-        String supplierCurrencyCode = "USD";
-        double price = 100.00;
-       
-        return currencyConverter.convert(supplierCurrencyCode, 
-                                         quoteCurrencyCode, 
-                                         price);
+        return searchResults.toArray(new TripItem[searchResults.size()]);
     }
     
+    // SearchCallback methods
+    
     public void searchResults(TripItem[] items){
         for(int i = 0; i < items.length; i++ ){
             searchResults.add(items[i]);
         }
+    }    
+
+    // TripContents methods
+    public void addTripItem(String id){
+        for (TripItem tripItem : searchResults) {
+            if (tripItem.getId().equals(id)){
+                tripItems.put(id, tripItem);
+            }
+        }
+    }
+    
+    
+    // Not using the DataCollection iface yet as it seems like a 
+    // likely attach vector to be passing complete tripItem records in
+    // really need to look up the cached item based on id    
+    public Entry<String, TripItem>[] getAll() {
+        Entry<String, TripItem>[] entries = new Entry[tripItems.size()];
+        int i = 0;
+        for (Map.Entry<String, TripItem> e: tripItems.entrySet()) {
+            entries[i++] = new Entry<String, TripItem>(e.getKey(), e.getValue());
+        }
+        return entries;
+    }
+    
+    public TripItem get(String key) throws NotFoundException {
+        TripItem item = tripItems.get(key);
+        if (item == null) {
+            throw new NotFoundException(key);
+        } else {
+            return item;
+        }
+    }
+
+    public String post(String key, TripItem item) {
+        tripItems.put(key, item);
+        return key;
+    }
+
+    public void put(String key, TripItem item) throws NotFoundException {
+        if (!tripItems.containsKey(key)) {
+            throw new NotFoundException(key);
+        }
+        tripItems.put(key, item);
     }
+    
+    public void delete(String key) throws NotFoundException {
+        if (key == null || key.equals("")) {
+            tripItems.clear();
+        } else {
+            TripItem item = tripItems.remove(key);
+            if (item == null)
+                throw new NotFoundException(key);
+        }
+    }
+
+    public Entry<String, TripItem>[] query(String queryString) {
+        List<Entry<String, TripItem>> entries = new ArrayList<Entry<String,TripItem>>();
+        if (queryString.startsWith("name=")) {
+            String name = queryString.substring(5);
+            for (Map.Entry<String, TripItem> e: tripItems.entrySet()) {
+                TripItem item = e.getValue();
+                if (item.getName().equals(name)) {
+                    entries.add(new Entry<String, TripItem>(e.getKey(), e.getValue()));
+                }
+            }
+        }
+        return entries.toArray(new Entry[entries.size()]);
+    }
+   
+    // TripTotal methods
+    
+    public double getTotalPrice(){ 
+        double totalPrice = 0.0;
+        
+        for (TripItem tripItem : tripItems.values()){
+            totalPrice += tripItem.getPrice();
+        }
+        
+        return totalPrice;
+    }
+    
+
 }

Added: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java?rev=682170&view=auto
==============================================================================
--- tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java (added)
+++ tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java Sun Aug
 3 06:36:24 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package scatours.trip;
+
+import org.osoa.sca.annotations.Remotable;
+
+import scatours.common.TripItem;
+import scatours.common.TripLeg;
+
+/**
+ * The Trip service interface
+ */
+@Remotable
+public interface TripSearch {
+    TripItem[] search(TripLeg tripLeg);
+}

Propchange: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: tuscany/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml (original)
+++ tuscany/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml Sun Aug  3
06:36:24 2008
@@ -22,6 +22,8 @@
    <import.java package="scatours.common"/>
    <import.java package="scatours.currencyconverter"/>
    <import.java package="scatours.hotel"/>
+   <import.java package="scatours.flight"/>
+   <import.java package="scatours.car"/>
    <import.java package="scatours.trip"/>
    <deployable composite="scatours:scatours"/>
 </contribution>
\ No newline at end of file

Modified: tuscany/sandbox/travelsample/ui-contribution/build.xml
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/build.xml?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/build.xml (original)
+++ tuscany/sandbox/travelsample/ui-contribution/build.xml Sun Aug  3 06:36:24 2008
@@ -88,7 +88,7 @@
         <include name="tuscany-xsd-1.4-SNAPSHOT.jar"/>
     </fileset>
     <fileset id="3rdparty.jars" dir="../../lib">
-        <include name="XmlSchema-1.3.1.jar"/>
+        <include name="XmlSchema-1.3.2.jar"/>
         <include name="activation-1.1.jar"/>
         <include name="asm-all-3.1.jar"/>
         <include name="cglib-nodep-2.1_3.jar"/>

Modified: tuscany/sandbox/travelsample/ui-contribution/scatours.composite
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/scatours.composite?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/scatours.composite (original)
+++ tuscany/sandbox/travelsample/ui-contribution/scatours.composite Sun Aug  3 06:36:24 2008
@@ -31,21 +31,40 @@
         <reference name="hotel" target="HotelComponent">
             <tuscany:binding.jsonrpc/>
         </reference>
-        <reference name="trip" target="TripComponent">
+        <reference name="flight" target="FlightComponent">
             <tuscany:binding.jsonrpc/>
         </reference>
+        <reference name="car" target="CarComponent">
+            <tuscany:binding.jsonrpc/>
+        </reference>
+        <reference name="tripSearch" target="TripComponent/TripSearch">
+            <tuscany:binding.jsonrpc/>
+        </reference>
+        <reference name="tripContents" target="TripComponent/TripContents">
+            <tuscany:binding.jsonrpc/>
+        </reference>  
     </component>
     
     <component name="TripComponent">
         <implementation.java class="scatours.trip.TripImpl"/>
-        <service name="Trip">
+        <service name="TripSearch">
+            <tuscany:binding.jsonrpc/>
+        </service>
+        <service name="TripContents">
             <tuscany:binding.jsonrpc/>
         </service>
         <reference name="hotelSearch" target="HotelComponent">
             <binding.sca/>
         </reference>
+        <reference name="flightSearch" target="FlightComponent">
+            <binding.sca/>
+        </reference> 
+        <reference name="carSearch" target="CarComponent">
+            <binding.sca/>
+        </reference>        
         <reference name="currencyConverter" target="CurrencyConverterComponent">
         </reference>
+        <property name="quoteCurrencyCode">GBP</property>
     </component>
         
     <component name="HotelComponent">
@@ -54,7 +73,23 @@
             <binding.sca/>
             <tuscany:binding.jsonrpc/>
         </service>
-    </component>    
+    </component>  
+    
+    <component name="FlightComponent">
+        <implementation.java class="scatours.flight.FlightImpl"/>
+        <service name="Search">
+            <binding.sca/>
+            <tuscany:binding.jsonrpc/>
+        </service>
+    </component> 
+    
+    <component name="CarComponent">
+        <implementation.java class="scatours.car.CarImpl"/>
+        <service name="Search">
+            <binding.sca/>
+            <tuscany:binding.jsonrpc/>
+        </service>
+    </component>     
     
     <component name="CurrencyConverterComponent">
         <implementation.java class="scatours.currencyconverter.CurrencyConverterImpl"/>

Modified: tuscany/sandbox/travelsample/ui-contribution/scatours.html
URL: http://svn.apache.org/viewvc/tuscany/sandbox/travelsample/ui-contribution/scatours.html?rev=682170&r1=682169&r2=682170&view=diff
==============================================================================
--- tuscany/sandbox/travelsample/ui-contribution/scatours.html (original)
+++ tuscany/sandbox/travelsample/ui-contribution/scatours.html Sun Aug  3 06:36:24 2008
@@ -28,14 +28,22 @@
 
 	//@Reference
 	var hotel = new Reference("hotel");
+    
+    //@Reference
+    var flight = new Reference("flight");
+    
+    //@Reference
+    var car = new Reference("car");    
 	
     //@Reference
-    var trip = new Reference("trip");
+    var tripSearch = new Reference("tripSearch");
     
+    //@Reference
+    var tripContents = new Reference("tripContents");
+        
     //local state
-    var hotels;
-    var flights;
-    var cars;
+    var searchResponseItems;
+    var tripItems;
     
     //the constructor for trip leg beans
     function TripLegType(id,
@@ -74,8 +82,16 @@
         hotel.searchSynch(getTripLeg(), search_response);
     }
     
+    function searchFlights() {       
+        flight.searchSynch(getTripLeg(), search_response);
+    }    
+    
+    function searchCars() {       
+        car.searchSynch(getTripLeg(), search_response);
+    } 
+        
     function searchTrip() {        
-        trip.search(getTripLeg(), search_response);
+        tripSearch.search(getTripLeg(), search_response);
     }
         
     function search_response(items, exception) {
@@ -83,15 +99,48 @@
             alert(exception.javaStack);
             return;
         }
-        var hotelsHTML = "";
+        var responseHTML = '<table border="0">';
+        responseHTML    += '<tr>';
+        responseHTML    += '<td>Select</td><td>Name</td><td>Description</td><td>Location</td><td>From
- To</td><td>Price</td>';
+        responseHTML    += '</tr>';
+        
         for (var i=0; i<items.length; i++) {
-            var item = items[i].name + ' - ' + items[i].description;
-            hotelsHTML += '<input name="items" type="checkbox" value="' + 
-                        item + '">' + item + ' <br>';
+            responseHTML += '<tr>';
+            responseHTML += '<td><input onClick="processSelection()" name="items"
type="checkbox" value="' + items[i].id + '"></td>'
+            responseHTML += '<td>' +  items[i].name + '</td>';
+            responseHTML += '<td>' +  items[i].description + '</td>';
+            responseHTML += '<td>' +  items[i].location + '</td>';
+            responseHTML += '<td>' +  items[i].fromDate + ' - ' + items[i].toDate +'</td>';
+            responseHTML += '<td>' +  items[i].price + ' ' + items[i].currency + '</td>';
+            responseHTML += '</tr>';
         }
-        document.getElementById('searchResponse').innerHTML = hotelsHTML;
-        hotels = items;
+        
+        responseHTML    += '</table>';
+        
+        document.getElementById('searchResponse').innerHTML = responseHTML;
+        
+        searchResponseItems = items;
     }  
+    
+    function processSelection() {        
+        var items  = document.tripForm.items;
+        var j = 0;
+        for (var i=0; i<items.length; i++) {
+            if (items[i].checked == true) {
+                tripContents.addTripItem(items[i].value);
+            }
+        }
+        
+        tripContents.getTotalPrice(totalPrice_response);
+    }    
+    
+    function totalPrice_response(totalPrice, exception) {
+        if(exception){
+            alert(exception.javaStack);
+            return;
+        }
+        document.getElementById('totalPrice').innerHTML = totalPrice;
+    }
 	
 </script>
 
@@ -113,7 +162,7 @@
                     <td>Start Date:</td>
                     <td><input type="text" name="fromDate" value="06/12/08"></td>
                     <td>End Date:</td>
-                    <td><input type="text" name="toDate" value="06/12/08"></td>
+                    <td><input type="text" name="toDate" value="13/12/08"></td>
                 </tr>
                 <tr>
                     <td>Number of people:</td>
@@ -127,18 +176,21 @@
                     <td/>
                 </tr>
             </table>
-            <input type="button" onClick="searchHotels()" value="SearchHotels"> 
+            <input type="button" onClick="searchHotels()" value="Search Hotels">
+            <input type="button" onClick="searchFlights()" value="Search Flights">
+            <input type="button" onClick="searchHotels()" value="Search Cars"> 
+            <br/>
             <input type="button" onClick="searchTrip()" value="SearchTrip"> 
         </form>
-        <div id="searchResponse"></div>
-        <br>
-        <form name="tripForm">   
-            <input type="button" onClick="bookTrip()" value="BookTrip"> 
+        <form name="tripForm"> 
+            <div id="searchResponse"></div>
+            <br>  
+            <div id="totalPrice"></div>
+            <br>
+            <input type="button" onClick="bookTrip()" value="Book Trip"> 
         </form> 
-        <br> 
-        <div id="trip"></div>
-        <br>
-        <div id="total"></div>
+        
+        
 	</div>
   
 </body>



Mime
View raw message