From 2a25d97953be52451c073f8abc22034283c6d8c9 Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 10 Aug 2008 16:14:48 +0000 Subject: Start looking at a conversational interface on the Trip component git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@684543 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/scatours/travel/TravelBooking.java | 10 +++++--- .../src/scatours/travel/TravelImpl.java | 29 +++++++++++++--------- 2 files changed, 23 insertions(+), 16 deletions(-) (limited to 'sandbox/travelsample/travel-contribution/src/scatours/travel') diff --git a/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java index 5aa3ef94f5..fec3ceb366 100644 --- a/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java +++ b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java @@ -29,8 +29,10 @@ import scatours.common.TripItem; @Remotable public interface TravelBooking { - void addTripItem(String id); - void removeTripItem(String id); - double getTotalPrice(); - void purchaseTrip(); + String newTrip(); + void addTripItem(String tripId, String id); + void removeTripItem(String tripId, String id); + TripItem[] getTripItems(String tripId); + double getTotalPrice(String tripId); + void purchaseTrip(String tripId); } diff --git a/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java index 9d3b9b94e9..e4a641e1e5 100644 --- a/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java +++ b/sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java @@ -72,7 +72,7 @@ public class TravelImpl implements TravelSearch, SearchCallback, TravelBooking{ private int responsesReceived = 0; private List searchResults = new ArrayList(); - private Map> trips = new HashMap>(); + private Map trips = new HashMap(); // TravelSearch methods @@ -95,6 +95,7 @@ public class TravelImpl implements TravelSearch, SearchCallback, TravelBooking{ for (TripItem tripItem : searchResults){ tripItem.setId(UUID.randomUUID().toString()); + tripItem.setTripId(tripLeg.getId()); tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), quoteCurrencyCode, tripItem.getPrice())); @@ -124,28 +125,32 @@ public class TravelImpl implements TravelSearch, SearchCallback, TravelBooking{ String tripId = UUID.randomUUID().toString(); ServiceReference tripReference = componentContext.getServiceReference(Trip.class, "trip"); - //tripReference.setConversationID(tripId); - trips.put(tripId, tripReference); + tripReference.setConversationID(tripId); + trips.put(tripId, tripReference.getService()); return tripId; } - public void addTripItem(String id){ + public void addTripItem(String tripId, String id){ for (TripItem tripItem : searchResults) { if (tripItem.getId().equals(id)){ - trip.addTripItem(tripItem); + trips.get(tripId).addTripItem(tripItem); } } } - public void removeTripItem(String id){ - trip.removeTripItem(id); - } + public void removeTripItem(String tripId, String id){ + trips.get(tripId).removeTripItem(id); + } - public double getTotalPrice(){ - return trip.getTripPrice(); + public TripItem[] getTripItems(String tripId) { + return trips.get(tripId).getTripItems(); } - public void purchaseTrip() { - trip.purchaseTrip(); + public double getTotalPrice(String tripId){ + return trips.get(tripId).getTripPrice(); + } + + public void purchaseTrip(String tripId) { + trips.get(tripId).purchaseTrip(); } } -- cgit v1.2.3