diff options
Diffstat (limited to 'sandbox/travelsample/travel-contribution/src')
-rw-r--r-- | sandbox/travelsample/travel-contribution/src/scatours/travel/TravelBooking.java | 10 | ||||
-rw-r--r-- | sandbox/travelsample/travel-contribution/src/scatours/travel/TravelImpl.java | 29 |
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(); } } |