diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-21 13:31:55 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-02-21 13:31:55 +0000 |
commit | 7d9e691b83c7669f559337a5a2768b13ce176bd3 (patch) | |
tree | 5640631c7e1b148197fee46d2a9bc29e8ce718e9 /sandbox/travelsample/shared-contributions/scatours-contribution/src | |
parent | 60f2f3cefcbd87824288bd555209f87bcb72456a (diff) |
Fix up the BPEL payment component to run in the wider application and take advantage of the BPEL resolved fix in 1.x
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@746503 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/travelsample/shared-contributions/scatours-contribution/src')
-rw-r--r-- | sandbox/travelsample/shared-contributions/scatours-contribution/src/main/java/scatours/SCAToursImpl.java | 77 |
1 files changed, 9 insertions, 68 deletions
diff --git a/sandbox/travelsample/shared-contributions/scatours-contribution/src/main/java/scatours/SCAToursImpl.java b/sandbox/travelsample/shared-contributions/scatours-contribution/src/main/java/scatours/SCAToursImpl.java index bfbf05ce02..a2a299d9ed 100644 --- a/sandbox/travelsample/shared-contributions/scatours-contribution/src/main/java/scatours/SCAToursImpl.java +++ b/sandbox/travelsample/shared-contributions/scatours-contribution/src/main/java/scatours/SCAToursImpl.java @@ -40,7 +40,10 @@ import scatours.travelcatalog.TravelCatalogSearch; import scatours.tripbooking.TripBooking; /** - * An implementation of the Trip service + * An implementation of the SCA tours component. This component currently provides + * a front end to the components that the UI communicated with. It allows a conversation + * to be held with the shopping cart as javascript doesn't support conversations. + * Other than that it's just a pass through so we could look to remove it. */ @Scope("COMPOSITE") @Service(interfaces={SCAToursSearch.class, SCAToursBooking.class, SCAToursCart.class}) @@ -60,18 +63,13 @@ public class SCAToursImpl implements SCAToursSearch, SCAToursBooking, SCAToursCa private Map<String,ShoppingCart> carts = new HashMap<String,ShoppingCart>(); private Map<String,TripBooking> trips = new HashMap<String,TripBooking>(); - //private Map<String, TripItem> searchItemsCache = new HashMap<String, TripItem>(); // SCAToursSearch methods public TripItem[] search(TripLeg tripLeg) { - TripItem[] searchItems = travelCatalogSearch.search(tripLeg); - - //for (int i =0; i< searchItems.length; i++){ - // searchItemsCache.put(searchItems[i].getId(), searchItems[i]); - //} - return searchItems; + return travelCatalogSearch.search(tripLeg); + } // SCAToursBooking methods @@ -99,64 +97,7 @@ public class SCAToursImpl implements SCAToursSearch, SCAToursBooking, SCAToursCa } public void checkout(String cartId){ - shoppingCart.checkout("Fred"); - } - -/* - public String addTrip(String cartId){ - String tripId = UUID.randomUUID().toString(); - ServiceReference<TripBooking> tripReference = componentContext.getServiceReference(TripBooking.class, - "tripBooking"); - tripReference.setConversationID(tripId); - trips.put(tripId, tripReference.getService()); - - carts.get(cartId).addItem(tripId); - return tripId; - } - - public void removeTrip(String cartId, String tripId) { - carts.get(cartId).removeItem(tripId); - } - - public void addTripItem(String cartId, String tripId, String tripItemId){ - TripItem item = searchItemsCache.get(tripItemId); - TripItem itemCopy = new TripItem(item); - itemCopy.setTripId(tripId); - trips.get(tripId).addTripItem(itemCopy); - } - - public void removeTripItem(String cartId, String tripId, String tripItemId){ - trips.get(tripId).removeTripItem(tripItemId); - } - - public TripItem[] getTripItems(String cartId) { - List<TripItem> returnTripItems = new ArrayList<TripItem>(); - - for( String tripId : carts.get(cartId).getItems()){ - returnTripItems.addAll(Arrays.asList(trips.get(tripId).getTripItems())); - } - - return returnTripItems.toArray(new TripItem[returnTripItems.size()]); - } - - public double getTotalPrice(String cartId){ - double total = 0.0; - - for( String tripId : carts.get(cartId).getItems()){ - total += trips.get(tripId).getTripPrice(); - } - - return total; - } - - public void checkout(String cartId){ - // get users credentials. Hard coded for now but should - // come from the security context - String customerId = "Fred Bloggs"; - float amount = (float)getTotalPrice(cartId); - - paymentProcess.makePayment(customerId, amount); - } - -*/ + // need to get the user id from the context here + carts.get(cartId).checkout("Fred"); + } } |