summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-10 15:15:28 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-10 15:15:28 +0000
commit569c99b45bb0b3e6408c3af066110f4212da0688 (patch)
tree3a9479e87ab058ccbecdf8b5a2e5e0417404a1df /sandbox/travelsample
parentf21ed5242ed195c2bfc082765c9a5ec95a26348c (diff)
Separate the search into a travel component so that it is independent of the trip booking
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684518 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sandbox/travelsample/node/src/scatours/LaunchNode.java2
-rw-r--r--sandbox/travelsample/pom.xml1
-rw-r--r--sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml25
-rw-r--r--sandbox/travelsample/travel-contribution/pom.xml88
-rw-r--r--sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java (renamed from sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java)11
-rw-r--r--sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java151
-rw-r--r--sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java (renamed from sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java)4
-rw-r--r--sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java46
-rw-r--r--sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java172
-rw-r--r--sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml1
-rw-r--r--sandbox/travelsample/ui-contribution/build.xml1
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.composite21
-rw-r--r--sandbox/travelsample/ui-contribution/scatours.html50
13 files changed, 401 insertions, 172 deletions
diff --git a/sandbox/travelsample/node/src/scatours/LaunchNode.java b/sandbox/travelsample/node/src/scatours/LaunchNode.java
index 310a1f5cfb..ae73a2d021 100644
--- a/sandbox/travelsample/node/src/scatours/LaunchNode.java
+++ b/sandbox/travelsample/node/src/scatours/LaunchNode.java
@@ -43,6 +43,7 @@ public class LaunchNode {
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("travel", "../trip-contribution/target/scatours-travel-contribution.jar"),
new SCAContribution("ui", "../ui-contribution/target/scatours-ui-contribution.jar"));
node.start();
@@ -71,6 +72,7 @@ public class LaunchNode {
new SCAContribution("flight", "../flight-contribution/target/classes"),
new SCAContribution("car", "../car-contribution/target/classes"),
new SCAContribution("trip", "../trip-contribution/target/classes"),
+ new SCAContribution("travel", "../travel-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 4d7dafa0f9..e9da4e8541 100644
--- a/sandbox/travelsample/pom.xml
+++ b/sandbox/travelsample/pom.xml
@@ -44,6 +44,7 @@
<module>car-contribution</module>
<module>payment-contribution</module>
<module>trip-contribution</module>
+ <module>travel-contribution</module>
<module>ui-contribution</module>
<module>domain</module>
diff --git a/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..687c894496
--- /dev/null
+++ b/sandbox/travelsample/travel-contribution/META-INF/sca-contribution.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<contribution xmlns="http://www.osoa.org/xmlns/sca/1.0">
+ <import.java package="scatours.common"/>
+ <import.java package="scatours.currencyconverter"/>
+ <import.java package="scatours.trip"/>
+ <export.java package="scatours.travel"/>
+</contribution> \ No newline at end of file
diff --git a/sandbox/travelsample/travel-contribution/pom.xml b/sandbox/travelsample/travel-contribution/pom.xml
new file mode 100644
index 0000000000..4ae7890544
--- /dev/null
+++ b/sandbox/travelsample/travel-contribution/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <!--relativePath>../../pom.xml</relativePath-->
+ </parent>
+ <artifactId>scatours-travel-contribution</artifactId>
+ <name>Apache Tuscany SCA Tours Travel Contribution</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-sca-api</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-data-api</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours-common-contribution</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours-currency-contribution</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>scatours-trip-contribution</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.2</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <finalName>${artifactId}</finalName>
+ <sourceDirectory>${basedir}/src</sourceDirectory>
+ <resources>
+ <resource>
+ <directory>${basedir}</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ <exclude>**/.*/**</exclude>
+ <exclude>pom.xml</exclude>
+ <exclude>build.xml</exclude>
+ <exclude>target/**</exclude>
+ <exclude>src/**</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+</project>
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java
index 0484dde02e..5aa3ef94f5 100644
--- a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripContents.java
+++ b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java
@@ -16,20 +16,21 @@
* specific language governing permissions and limitations
* under the License.
*/
-package scatours.trip;
+package scatours.travel;
+
-import org.apache.tuscany.sca.data.collection.Collection;
import org.osoa.sca.annotations.Remotable;
import scatours.common.TripItem;
/**
- * The Trip service interface
+ * The TravelBooking service interface
*/
@Remotable
-public interface TripContents extends Collection<String, TripItem> {
-
+public interface TravelBooking {
+
void addTripItem(String id);
void removeTripItem(String id);
double getTotalPrice();
+ void purchaseTrip();
}
diff --git a/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java
new file mode 100644
index 0000000000..9d3b9b94e9
--- /dev/null
+++ b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java
@@ -0,0 +1,151 @@
+/*
+ * 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.travel;
+
+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.ComponentContext;
+import org.osoa.sca.ServiceReference;
+import org.osoa.sca.annotations.Context;
+import org.osoa.sca.annotations.Property;
+import org.osoa.sca.annotations.Reference;
+import org.osoa.sca.annotations.Scope;
+import org.osoa.sca.annotations.Service;
+
+import scatours.common.Search;
+import scatours.common.SearchCallback;
+import scatours.common.TripItem;
+import scatours.common.TripLeg;
+import scatours.currencyconverter.CurrencyConverter;
+import scatours.trip.Trip;
+
+/**
+ * An implementation of the Trip service
+ */
+@Scope("COMPOSITE")
+@Service(interfaces={TravelSearch.class, TravelBooking.class})
+public class TravelImpl implements TravelSearch, SearchCallback, TravelBooking{
+
+ @Reference
+ protected CurrencyConverter currencyConverter;
+
+ @Reference
+ protected Search hotelSearch;
+
+ @Reference
+ protected Search flightSearch;
+
+ @Reference
+ protected Search carSearch;
+
+ @Reference
+ protected Trip trip;
+
+ @Property
+ public String quoteCurrencyCode = "USD";
+
+ @Context
+ protected ComponentContext componentContext;
+
+ private int responsesReceived = 0;
+
+ private List<TripItem> searchResults = new ArrayList<TripItem>();
+ private Map<String,ServiceReference<Trip>> trips = new HashMap<String,ServiceReference<Trip>>();
+
+ // TravelSearch methods
+
+ public TripItem[] search(TripLeg tripLeg) {
+
+ searchResults.clear();
+ responsesReceived = 0;
+
+ hotelSearch.searchAsynch(tripLeg);
+ flightSearch.searchAsynch(tripLeg);
+ carSearch.searchAsynch(tripLeg);
+
+ while (responsesReceived < 3){
+ try {
+ this.wait();
+ } catch (InterruptedException ex){
+ // do nothing
+ }
+ }
+
+ for (TripItem tripItem : searchResults){
+ tripItem.setId(UUID.randomUUID().toString());
+ tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(),
+ quoteCurrencyCode,
+ tripItem.getPrice()));
+ tripItem.setCurrency(quoteCurrencyCode);
+ }
+
+ 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]);
+ }
+
+ responsesReceived++;
+ try {
+ this.notifyAll();
+ } catch (Exception ex) {
+ }
+ }
+
+ // TravelBooking methods
+
+ public String newTrip(){
+ String tripId = UUID.randomUUID().toString();
+ ServiceReference<Trip> tripReference = componentContext.getServiceReference(Trip.class,
+ "trip");
+ //tripReference.setConversationID(tripId);
+ trips.put(tripId, tripReference);
+ return tripId;
+ }
+
+ public void addTripItem(String id){
+ for (TripItem tripItem : searchResults) {
+ if (tripItem.getId().equals(id)){
+ trip.addTripItem(tripItem);
+ }
+ }
+ }
+
+ public void removeTripItem(String id){
+ trip.removeTripItem(id);
+ }
+
+ public double getTotalPrice(){
+ return trip.getTripPrice();
+ }
+
+ public void purchaseTrip() {
+ trip.purchaseTrip();
+ }
+}
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java
index 2bdeb0ccb4..d1aeed2906 100644
--- a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripSearch.java
+++ b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelSearch.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package scatours.trip;
+package scatours.travel;
import org.osoa.sca.annotations.Remotable;
@@ -27,6 +27,6 @@ import scatours.common.TripLeg;
* The Trip service interface
*/
@Remotable
-public interface TripSearch {
+public interface TravelSearch {
TripItem[] search(TripLeg tripLeg);
}
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java
new file mode 100644
index 0000000000..17f36c33f7
--- /dev/null
+++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/Trip.java
@@ -0,0 +1,46 @@
+/*
+ * 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.Conversational;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.EndsConversation;
+import org.osoa.sca.annotations.Init;
+import org.osoa.sca.annotations.Remotable;
+
+import scatours.common.TripItem;
+
+/**
+ * The Trip service interface
+ */
+@Remotable
+@Conversational
+public interface Trip {
+
+ void startTrip(String id);
+
+ void addTripItem(TripItem tripItem);
+
+ void removeTripItem(String id);
+
+ double getTripPrice();
+
+ @EndsConversation
+ void purchaseTrip();
+}
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
index 30d87a283e..3f42edd587 100644
--- a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
+++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java
@@ -18,169 +18,59 @@
*/
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.ConversationID;
+import org.osoa.sca.annotations.Destroy;
+import org.osoa.sca.annotations.Init;
+
import org.osoa.sca.annotations.Scope;
import org.osoa.sca.annotations.Service;
-import scatours.common.Search;
-import scatours.common.SearchCallback;
+
import scatours.common.TripItem;
-import scatours.common.TripLeg;
-import scatours.currencyconverter.CurrencyConverter;
/**
* An implementation of the Trip service
*/
-@Scope("COMPOSITE")
-@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 int responsesReceived = 0;
+@Scope("CONVERSATION")
+@Service(interfaces={Trip.class})
+public class TripImpl implements Trip{
+
+ @ConversationID
+ protected String conversationId;
- private List<TripItem> searchResults = new ArrayList<TripItem>();
private Map<String, TripItem> tripItems = new HashMap<String, TripItem>();
+
+ // Trip methods
- // TripSearch methods
+ @Init
+ public void initTrip() {
+ //TODO
+ System.out.println("Trip init");
+ }
- public TripItem[] search(TripLeg tripLeg) {
-
- searchResults.clear();
- responsesReceived = 0;
-
- hotelSearch.searchAsynch(tripLeg);
- flightSearch.searchAsynch(tripLeg);
- carSearch.searchAsynch(tripLeg);
-
- while (responsesReceived < 3){
- try {
- this.wait();
- } catch (InterruptedException ex){
- // do nothing
- }
- }
-
- for (TripItem tripItem : searchResults){
- tripItem.setId(UUID.randomUUID().toString());
- tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(),
- quoteCurrencyCode,
- tripItem.getPrice()));
- tripItem.setCurrency(quoteCurrencyCode);
- }
-
- return searchResults.toArray(new TripItem[searchResults.size()]);
+ @Destroy
+ public void destroyTrip() {
+ //TODO
+ System.out.println("Trip destroy");
}
- // SearchCallback methods
+ public void startTrip(String id){
+ tripItems.clear();
+ }
- public void searchResults(TripItem[] items){
- for(int i = 0; i < items.length; i++ ){
- searchResults.add(items[i]);
- }
-
- responsesReceived++;
- try {
- this.notifyAll();
- } catch (Exception ex) {
- }
- }
-
- // TripContents methods
- public void addTripItem(String id){
- for (TripItem tripItem : searchResults) {
- if (tripItem.getId().equals(id)){
- tripItems.put(id, tripItem);
- }
- }
+ public void addTripItem(TripItem tripItem){
+ tripItems.put(tripItem.getId(), tripItem);
}
public void removeTripItem(String id){
tripItems.remove(id);
}
- // 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(){
+ public double getTripPrice(){
double totalPrice = 0.0;
for (TripItem tripItem : tripItems.values()){
@@ -190,5 +80,7 @@ public class TripImpl implements TripSearch, SearchCallback, TripContents{
return totalPrice;
}
-
+ public void purchaseTrip() {
+ // TODO
+ }
}
diff --git a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
index 51f91e071e..debc0e2ea5 100644
--- a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
+++ b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml
@@ -25,5 +25,6 @@
<import.java package="scatours.flight"/>
<import.java package="scatours.car"/>
<import.java package="scatours.trip"/>
+ <import.java package="scatours.travel"/>
<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 8d5b4a8dfa..5444c953ff 100644
--- a/sandbox/travelsample/ui-contribution/build.xml
+++ b/sandbox/travelsample/ui-contribution/build.xml
@@ -100,7 +100,6 @@
<include name="jsr250-api-1.0.jar"/>
<include name="stax-api-1.0-2.jar"/>
<include name="wstx-asl-3.2.1.jar"/>
- <include name="xml-apis-1.3.03.jar"/>
</fileset>
</project>
diff --git a/sandbox/travelsample/ui-contribution/scatours.composite b/sandbox/travelsample/ui-contribution/scatours.composite
index 76fdc2c0d6..fc28b0a884 100644
--- a/sandbox/travelsample/ui-contribution/scatours.composite
+++ b/sandbox/travelsample/ui-contribution/scatours.composite
@@ -37,23 +37,23 @@
<reference name="car" target="CarComponent">
<tuscany:binding.jsonrpc/>
</reference>
- <reference name="tripSearch" target="TripComponent/TripSearch">
+ <reference name="travelSearch" target="TravelComponent/TravelSearch">
<tuscany:binding.jsonrpc/>
</reference>
- <reference name="tripContents" target="TripComponent/TripContents">
+ <reference name="travelBooking" target="TravelComponent/TravelBooking">
<tuscany:binding.jsonrpc/>
</reference>
</component>
- <component name="TripComponent">
- <implementation.java class="scatours.trip.TripImpl"/>
- <service name="TripSearch">
+ <component name="TravelComponent">
+ <implementation.java class="scatours.travel.TravelImpl"/>
+ <service name="TravelSearch">
<tuscany:binding.jsonrpc/>
</service>
- <service name="TripContents">
+ <service name="TravelBooking">
<tuscany:binding.jsonrpc/>
</service>
- <reference name="hotelSearch" target="HotelComponent">
+ <reference name="hotelSearch" target="HotelComponent/Search">
<binding.sca/>
</reference>
<reference name="flightSearch" target="FlightComponent">
@@ -64,8 +64,15 @@
</reference>
<reference name="currencyConverter" target="CurrencyConverterComponent">
</reference>
+ <reference name="trip" target="TripComponent">
+ </reference>
<property name="quoteCurrencyCode">GBP</property>
</component>
+ <component name="TripComponent">
+ <implementation.java class="scatours.trip.TripImpl"/>
+ <service name="Trip">
+ </service>
+ </component>
<component name="HotelComponent">
<implementation.java class="scatours.hotel.HotelImpl"/>
diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html
index c699ddb046..7b1a0b60d8 100644
--- a/sandbox/travelsample/ui-contribution/scatours.html
+++ b/sandbox/travelsample/ui-contribution/scatours.html
@@ -36,10 +36,10 @@
var car = new Reference("car");
//@Reference
- var tripSearch = new Reference("tripSearch");
+ var travelSearch = new Reference("travelSearch");
//@Reference
- var tripContents = new Reference("tripContents");
+ var travelBooking = new Reference("travelBooking");
//local state
var searchResponseItems;
@@ -62,11 +62,11 @@
function getTripLeg(){
return new TripLegType("X",
- document.searchForm.fromLocation.value,
- document.searchForm.toLocation.value,
- document.searchForm.fromDate.value,
- document.searchForm.toDate.value,
- document.searchForm.noOfPeople.value);
+ document.travelForm.fromLocation.value,
+ document.travelForm.toLocation.value,
+ document.travelForm.fromDate.value,
+ document.travelForm.toDate.value,
+ document.travelForm.noOfPeople.value);
}
function init() {
@@ -90,8 +90,8 @@
car.searchSynch(getTripLeg(), search_response);
}
- function searchTrip() {
- tripSearch.search(getTripLeg(), search_response);
+ function searchPackages() {
+ travelSearch.search(getTripLeg(), search_response);
}
function search_response(items, exception) {
@@ -127,13 +127,13 @@
var j = 0;
for (var i=0; i<items.length; i++) {
if (items[i].checked == true) {
- tripContents.addTripItem(items[i].value);
+ travelBooking.addTripItem(items[i].value);
} else {
- tripContents.removeTripItem(items[i].value);
+ travelBooking.removeTripItem(items[i].value);
}
}
- tripContents.getTotalPrice(totalPrice_response);
+ travelBooking.getTotalPrice(totalPrice_response);
}
function totalPrice_response(totalPrice, exception) {
@@ -143,6 +143,19 @@
}
document.getElementById('totalPrice').innerHTML = totalPrice;
}
+
+ function newTrip() {
+
+ }
+
+ function purchaseTrip() {
+ travelBooking.purchaseTrip();
+
+ document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours";
+ document.getElementById('totalPrice').innerHTML = "";
+ searchResponseItems = null;
+ tripItems = null;
+ }
</script>
@@ -152,7 +165,7 @@
<img src="scatours.png" border="0" />
<div id="scatours">
<br>
- <form name="searchForm">
+ <form name="travelForm">
<table border="0">
<tr>
<td>From Location:</td>
@@ -178,18 +191,21 @@
<td/>
</tr>
</table>
+ <input type="button" onClick="searchPackages()" value="SearchPackages">
<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>
<form name="tripForm">
<div id="searchResponse"></div>
- <br>
+ <br>
+ <input type="button" onClick="newTrip()" value="Create New Trip">
+ <br>
<div id="totalPrice"></div>
<br>
- <input type="button" onClick="bookTrip()" value="Book Trip">
+ <div id="tripItems"></div>
+ <br>
+ <input type="button" onClick="purchaseTrip()" value="Purchase Trip">
</form>