diff options
Diffstat (limited to 'sandbox/travelsample/scatours-contribution')
5 files changed, 96 insertions, 23 deletions
diff --git a/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml index 6d6a563b74..368e95ebd0 100644 --- a/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml +++ b/sandbox/travelsample/scatours-contribution/META-INF/sca-contribution.xml @@ -19,10 +19,8 @@ --> <contribution xmlns="http://www.osoa.org/xmlns/sca/1.0"> <import.java package="scatours.common"/> - <import.java package="scatours.currencyconverter"/> <import.java package="scatours.travelcatalog"/> <import.java package="scatours.tripbooking"/> - <import.java package="scatours.paymentprocess"/> <import.java package="scatours.shoppingcart"/> <export.java package="scatours"/> </contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java index 611b4d8945..ac39443e9c 100644 --- a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursBooking.java @@ -28,12 +28,5 @@ import scatours.common.TripItem; */ @Remotable public interface SCAToursBooking { - String addCart(); - String addTrip(String cartId); - void removeTrip(String cartId, String tripId); - void addTripItem(String cartId, String tripId, String tripItemId); - void removeTripItem(String cartId, String tripId, String tripItemId); - TripItem[] getTripItems(String cartId); - double getTotalPrice(String cartId); - void checkout(String name); + String bookTrip(String cartId, TripItem tripId); } diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursCart.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursCart.java new file mode 100644 index 0000000000..61e32ec4a2 --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursCart.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package scatours; + +import org.osoa.sca.annotations.Conversational; +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; + +/** + * The ShoppingCart service interface + */ +@Remotable +public interface SCAToursCart{ + String newCart(); + TripItem[] getTrips(String cartId); + void checkout(String cartId); +} diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java index d36a6604ce..c0f7bec6ea 100644 --- a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursImpl.java @@ -43,8 +43,8 @@ import scatours.tripbooking.TripBooking; * An implementation of the Trip service */ @Scope("COMPOSITE") -@Service(interfaces={TravelCatalogSearch.class, SCAToursBooking.class}) -public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{ +@Service(interfaces={SCAToursSearch.class, SCAToursBooking.class, SCAToursCart.class}) +public class SCAToursImpl implements SCAToursSearch, SCAToursBooking, SCAToursCart{ @Reference protected TravelCatalogSearch travelCatalogSearch; @@ -53,33 +53,38 @@ public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{ protected TripBooking tripBooking; @Reference - protected ShoppingCart shoppingCart; - - @Reference - protected PaymentProcess paymentProcess; + protected ShoppingCart shoppingCart; @Context protected ComponentContext componentContext; 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>(); + //private Map<String, TripItem> searchItemsCache = new HashMap<String, TripItem>(); - // TravelCatalogSearch methods + // 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]); - } + //for (int i =0; i< searchItems.length; i++){ + // searchItemsCache.put(searchItems[i].getId(), searchItems[i]); + //} return searchItems; } // SCAToursBooking methods - public String addCart(){ + public String bookTrip(String cartId, TripItem trip){ + TripItem bookedTrip = tripBooking.bookTrip(cartId, trip); + carts.get(cartId).addTrip(bookedTrip); + return bookedTrip.getBookingCode(); + } + + // SCAToursCart methods + + public String newCart(){ String cartId = UUID.randomUUID().toString(); ServiceReference<ShoppingCart> shoppingCart = componentContext.getServiceReference(ShoppingCart.class, "shoppingCart"); @@ -87,8 +92,17 @@ public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{ carts.put(cartId, shoppingCart.getService()); return cartId; - } + } + public TripItem[] getTrips(String cartId){ + return carts.get(cartId).getTrips(); + } + + 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, @@ -143,4 +157,6 @@ public class SCAToursImpl implements TravelCatalogSearch, SCAToursBooking{ paymentProcess.makePayment(customerId, amount); } + +*/ } diff --git a/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursSearch.java b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursSearch.java new file mode 100644 index 0000000000..f0f435fc06 --- /dev/null +++ b/sandbox/travelsample/scatours-contribution/src/scatours/SCAToursSearch.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package scatours; + +import org.osoa.sca.annotations.Remotable; + +import scatours.common.TripItem; +import scatours.common.TripLeg; + +/** + * The Trip service interface + */ +@Remotable +public interface SCAToursSearch { + TripItem[] search(TripLeg tripLeg); +} |