summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java54
-rw-r--r--sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java21
-rw-r--r--sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java20
-rw-r--r--sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java44
-rw-r--r--sandbox/travelsample/node/build.xml3
-rw-r--r--sandbox/travelsample/node/src/scatours/LaunchNode.java4
-rw-r--r--sandbox/travelsample/pom.xml2
-rw-r--r--sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java34
-rw-r--r--sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java129
-rw-r--r--sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java (renamed from sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java)4
-rw-r--r--sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml2
-rw-r--r--sandbox/travelsample/ui-contribution/build.xml2
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.composite41
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.html94
14 files changed, 400 insertions, 54 deletions
diff --git a/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java b/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
index 8f264c7f1d..aac90c7bd5 100644
--- a/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
+++ b/sandbox/travelsample/common-contribution/src/scatours/common/TripItem.java
@@ -27,22 +27,34 @@ public class TripItem {
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 @@ public class TripItem {
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;
}
diff --git a/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java b/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
index 06d1d23535..eddc59f555 100644
--- a/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
+++ b/sandbox/travelsample/currency-contribution/src/scatours/currencyconverter/CurrencyConverterImpl.java
@@ -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 @@ import org.osoa.sca.annotations.Service;
*/
@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){
diff --git a/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java b/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java
index 769cbcaed7..ac02c31e59 100644
--- a/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java
+++ b/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelImpl.java
@@ -48,18 +48,34 @@ public class HotelImpl implements Search {
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 @@ public class HotelImpl implements Search {
hotel.getName(),
hotel.getDescription(),
hotel.getLocation(),
+ tripLeg.getFromDate(),
+ tripLeg.getToDate(),
+ hotel.getPricePerBed(),
+ hotel.getCurrency(),
hotel.getLink());
items.add(item);
}
diff --git a/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java b/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java
index 6c8471ebb4..3b0d11d16e 100644
--- a/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java
+++ b/sandbox/travelsample/hotel-contribution/src/scatours/hotel/HotelInfo.java
@@ -25,6 +25,10 @@ public class HotelInfo {
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 class HotelInfo {
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 @@ public class HotelInfo {
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;
}
diff --git a/sandbox/travelsample/node/build.xml b/sandbox/travelsample/node/build.xml
index 9280cccb97..f5faece1ea 100644
--- a/sandbox/travelsample/node/build.xml
+++ b/sandbox/travelsample/node/build.xml
@@ -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"/>
diff --git a/sandbox/travelsample/node/src/scatours/LaunchNode.java b/sandbox/travelsample/node/src/scatours/LaunchNode.java
index 61f4fa27f8..310a1f5cfb 100644
--- a/sandbox/travelsample/node/src/scatours/LaunchNode.java
+++ b/sandbox/travelsample/node/src/scatours/LaunchNode.java
@@ -40,6 +40,8 @@ public class LaunchNode {
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 @@ public class LaunchNode {
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();
diff --git a/sandbox/travelsample/pom.xml b/sandbox/travelsample/pom.xml
index bab8add34f..4d7dafa0f9 100644
--- a/sandbox/travelsample/pom.xml
+++ b/sandbox/travelsample/pom.xml
@@ -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>
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
new file mode 100644
index 0000000000..78eb8fdab4
--- /dev/null
+++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
@@ -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();
+}
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
index 568b88c102..53e368f8e6 100644
--- a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
+++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
@@ -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 @@ import scatours.currencyconverter.CurrencyConverter;
* 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;
+ }
+
+
}
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
index 8ec0dbad67..2bdeb0ccb4 100644
--- a/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java
+++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
@@ -18,7 +18,6 @@
*/
package scatours.trip;
-import org.apache.tuscany.sca.data.collection.Item;
import org.osoa.sca.annotations.Remotable;
import scatours.common.TripItem;
@@ -28,7 +27,6 @@ import scatours.common.TripLeg;
* The Trip service interface
*/
@Remotable
-public interface Trip {
+public interface TripSearch {
TripItem[] search(TripLeg tripLeg);
- double getTotalPrice();
}
diff --git a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
index ca5bb4bc3e..51f91e071e 100644
--- a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
@@ -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
diff --git a/sandbox/travelsample/ui-contribution/build.xml b/sandbox/travelsample/ui-contribution/build.xml
index 924456228e..8d5b4a8dfa 100644
--- a/sandbox/travelsample/ui-contribution/build.xml
+++ b/sandbox/travelsample/ui-contribution/build.xml
@@ -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"/>
diff --git a/sandbox/travelsample/ui-contribution/scatours.composite b/sandbox/travelsample/ui-contribution/scatours.composite
index 7d340bebba..76fdc2c0d6 100644
--- a/sandbox/travelsample/ui-contribution/scatours.composite
+++ b/sandbox/travelsample/ui-contribution/scatours.composite
@@ -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"/>
diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html
index 88bad8ed1f..51feeb0815 100644
--- a/sandbox/travelsample/ui-contribution/scatours.html
+++ b/sandbox/travelsample/ui-contribution/scatours.html
@@ -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>