summaryrefslogtreecommitdiffstats
path: root/sandbox/travelsample/travel-contribution/src
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-10 16:14:48 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-08-10 16:14:48 +0000
commit2a25d97953be52451c073f8abc22034283c6d8c9 (patch)
tree77132b7af9d104a019f38866a43594ad11a0266a /sandbox/travelsample/travel-contribution/src
parent569c99b45bb0b3e6408c3af066110f4212da0688 (diff)
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
Diffstat (limited to '')
-rw-r--r--sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java10
-rw-r--r--sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java29
2 files changed, 23 insertions, 16 deletions
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<TripItem> searchResults = new ArrayList<TripItem>();
- private Map<String,ServiceReference<Trip>> trips = new HashMap<String,ServiceReference<Trip>>();
+ private Map<String,Trip> trips = new HashMap<String,Trip>();
// 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<Trip> 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();
}
}