diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-03 13:59:39 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-03 13:59:39 +0000 |
commit | 59523e81731bcac1034aceec0de0e65967248cd6 (patch) | |
tree | 367755e5f7d65e7bfd724d3fde9b1111f7fa5f41 /sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java | |
parent | fb3ace4ed73757a703f013d9ddc9ba83f206ad5c (diff) |
Allow trip items to be removed
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@682175 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java index 53e368f8e6..30d87a283e 100644 --- a/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java +++ b/sandbox/travelsample/trip-contribution/src/scatours/trip/TripImpl.java @@ -59,6 +59,8 @@ public class TripImpl implements TripSearch, SearchCallback, TripContents{ @Property public String quoteCurrencyCode = "USD"; + private int responsesReceived = 0; + private List<TripItem> searchResults = new ArrayList<TripItem>(); private Map<String, TripItem> tripItems = new HashMap<String, TripItem>(); @@ -67,15 +69,22 @@ public class TripImpl implements TripSearch, SearchCallback, TripContents{ public TripItem[] search(TripLeg tripLeg) { searchResults.clear(); + responsesReceived = 0; hotelSearch.searchAsynch(tripLeg); flightSearch.searchAsynch(tripLeg); carSearch.searchAsynch(tripLeg); - // TODO - wait for searches to complete + while (responsesReceived < 3){ + try { + this.wait(); + } catch (InterruptedException ex){ + // do nothing + } + } for (TripItem tripItem : searchResults){ - tripItem.setId(String.valueOf(searchResults.indexOf(tripItem))); + tripItem.setId(UUID.randomUUID().toString()); tripItem.setPrice(currencyConverter.convert(tripItem.getCurrency(), quoteCurrencyCode, tripItem.getPrice())); @@ -91,6 +100,12 @@ public class TripImpl implements TripSearch, SearchCallback, TripContents{ for(int i = 0; i < items.length; i++ ){ searchResults.add(items[i]); } + + responsesReceived++; + try { + this.notifyAll(); + } catch (Exception ex) { + } } // TripContents methods @@ -102,6 +117,9 @@ public class TripImpl implements TripSearch, SearchCallback, TripContents{ } } + 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 |