diff options
author | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-05 11:49:06 +0000 |
---|---|---|
committer | slaws <slaws@13f79535-47bb-0310-9956-ffa450edef68> | 2009-01-05 11:49:06 +0000 |
commit | 6ecc521d85871c1bc0d37927717434edcaccf234 (patch) | |
tree | 71cb219791ac9c910ef8adcb7d2b7ace7d56890d /sandbox/travelsample/ui-contribution | |
parent | 09145b638ddca5e5aab648290314163666e3dcc3 (diff) |
Add in shopping cart and extend scenario to talk to payment process. Now needs a revamp to simplify and to allow preconfigured trips to be added to the cart.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@731534 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
3 files changed, 104 insertions, 45 deletions
diff --git a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml index d3ea737a06..c244245722 100644 --- a/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml +++ b/sandbox/travelsample/ui-contribution/META-INF/sca-contribution.xml @@ -27,5 +27,10 @@ <import.java package="scatours.car"/> <import.java package="scatours.tripbooking"/> <import.java package="scatours.travelcatalog"/> + <import.java package="payment.creditcard.ws.impl"/> + <import.java package="scatours.emailgateway"/> + <import.java package="scatours.paymentprocess"/> + <import.java package="scatours.shoppingcart"/> <import.java package="scatours"/> + <import namespace="http://www.example.org/PaymentProcess/"/> </contribution>
\ No newline at end of file diff --git a/sandbox/travelsample/ui-contribution/scatours.composite b/sandbox/travelsample/ui-contribution/scatours.composite index 84864d4ba6..5dc1cb8453 100644 --- a/sandbox/travelsample/ui-contribution/scatours.composite +++ b/sandbox/travelsample/ui-contribution/scatours.composite @@ -21,6 +21,7 @@ targetNamespace="http://scatours" xmlns:scatours="http://scatours" xmlns:tuscany="http://tuscany.apache.org/xmlns/sca/1.0" + xmlns:pp="http://www.example.org/PaymentProcess" name="scatours"> <component name="UserInterfaceComponent"> @@ -46,7 +47,10 @@ </service> <reference name="travelCatalogSearch" target="TravelCatalogComponent/TravelCatalogSearch"/> <reference name="tripBooking" target="TripBookingComponent/TripBooking"/> - <!--reference name="shoppingCart" target="ShoppingCartComponent/shoppingCart"/--> + <reference name="shoppingCart" target="ShoppingCartComponent/ShoppingCart"/> + <reference name="paymentProcess"> + <binding.ws uri="http://localhost:8083/PaymentProcess" /> + </reference> </component> <component name="TravelCatalogComponent"> @@ -111,23 +115,38 @@ </service> </component> - <!-- component name="ShoppingCartComponent"> + <component name="ShoppingCartComponent"> <implementation.java class="scatours.shoppingcart.ShoppingCartImpl"/> - <service name="CurrencyConverter"> + <service name="ShoppingCart"> </service> - </component> + </component> - <component name="PaymentComponent"> - <implementation.java class="scatours.payment.PaymentImpl"/> - <service name="CurrencyConverter"> + <!--component name="PaymentProcessComponent"> + <implementation.bpel process="pp:PaymentProcess"/> + <service name="paymentProcessPartnerLink"> + <interface.wsdl interface="http://www.example.org/PaymentProcess/#wsdl.interface(PaymentProcess)" /> + <binding.ws uri="http://localhost:8080/PaymentProcess" wsdlElement="http://www.example.org/PaymentProcess/#wsdl.service(PaymentProcessService)"/> </service> - </component--> + <reference name="creditCardPaymentPartnerLink"> + <binding.ws uri="http://localhost:8081/CreditCardPayment"/> + </reference> + <reference name="emailGatewayPartnerLink"> + <binding.ws uri="http://localhost:8082/EmailGateway"/> + </reference> + </component> + + <component name="CreditCardPaymentWS"> + <implementation.java class="payment.creditcard.ws.impl.CreditCardPaymentWSImpl" /> + <service name="CreditCardPayment"> + <binding.ws uri="http://localhost:8081/CreditCardPayment" /> + </service> + </component> - <component name="CreditCardGateway"> - <implementation.java class="creditcard.CreditCardGatewayImpl" /> - <service name="CreditCardGateway"> - <binding.ws uri="http://localhost:8080/CreditCardGateway" /> + <component name="EmailGateway"> + <implementation.java class="scatours.emailgateway.EmailGatewayImpl" /> + <service name="EmailGateway"> + <binding.ws uri="http://localhost:8082/EmailGateway" /> </service> - </component> + </component--> </composite> diff --git a/sandbox/travelsample/ui-contribution/scatours.html b/sandbox/travelsample/ui-contribution/scatours.html index d2a6baf669..294c350ae1 100644 --- a/sandbox/travelsample/ui-contribution/scatours.html +++ b/sandbox/travelsample/ui-contribution/scatours.html @@ -33,7 +33,9 @@ var scaToursBooking = new Reference("scaToursBooking"); //local state - var currentTripId; + var currentCartId; + var tripIds = []; + var currentTripIdIndex = -1; var searchItems; var cartItems; @@ -53,7 +55,7 @@ } function getTripLeg(){ - return new TripLegType(currentTripId, + return new TripLegType(tripIds[currentTripIdIndex], document.travelForm.fromLocation.value, document.travelForm.toLocation.value, document.travelForm.fromDate.value, @@ -63,7 +65,7 @@ function init() { try { - newTrip(); + addCart(); } catch(e) { alert(e); @@ -113,13 +115,17 @@ // notify the server of the change if (items[i].checked == true) { - scaToursBooking.addTripItem(currentTripId, items[i].value); + scaToursBooking.addTripItem(currentCartId, tripIds[currentTripIdIndex], items[i].value); } else { - scaToursBooking.removeTripItem(currentTripId, items[i].value); + scaToursBooking.removeTripItem(currentCartId, tripIds[currentTripIdIndex], items[i].value); } } - scaToursBooking.getTripItems(currentTripId,getTripItems_response); + scaToursBooking.getTripItems(currentCartId, getTripItems_response); + } + + function getTripItems() { + scaToursBooking.getTripItems(currentCartId, getTripItems_response); } function getTripItems_response(items, exception) { @@ -127,26 +133,34 @@ alert(exception.javaStack); return; } - var itemsHTML = '<table border="0">'; - itemsHTML += '<tr>'; - itemsHTML += '<td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>'; - itemsHTML += '</tr>'; + var itemsHTML = ''; - for (var i=0; i<items.length; i++) { + for (var x=0; x<=currentTripIdIndex; x++){ + var tripId = tripIds[x] + itemsHTML += '<h3>Trip - ' + tripId + '</h3>'; + itemsHTML += '<table border="0">'; itemsHTML += '<tr>'; - itemsHTML += '<td>' + items[i].name + '</td>'; - itemsHTML += '<td>' + items[i].description + '</td>'; - itemsHTML += '<td>' + items[i].location + '</td>'; - itemsHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>'; - itemsHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>'; + itemsHTML += '<td>Name</td><td>Description</td><td>Location</td><td>From - To</td><td>Price</td>'; itemsHTML += '</tr>'; + + for (var i=0; i<items.length; i++) { + if (items[i].tripId == tripId) { + itemsHTML += '<tr>'; + itemsHTML += '<td>' + items[i].name + '</td>'; + itemsHTML += '<td>' + items[i].description + '</td>'; + itemsHTML += '<td>' + items[i].location + '</td>'; + itemsHTML += '<td>' + items[i].fromDate + ' - ' + items[i].toDate +'</td>'; + itemsHTML += '<td>' + items[i].price + ' ' + items[i].currency + '</td>'; + itemsHTML += '</tr>'; + } + } + + itemsHTML += '</table>'; } - itemsHTML += '</table>'; - document.getElementById('tripItems').innerHTML = itemsHTML; - scaToursBooking.getTotalPrice(currentTripId, getTotalPrice_response); + scaToursBooking.getTotalPrice(currentCartId, getTotalPrice_response); } function getTotalPrice_response(totalPrice, exception) { @@ -157,25 +171,44 @@ document.getElementById('totalPrice').innerHTML = totalPrice; } - function newTrip() { - scaToursBooking.newTrip(newTrip_response); + function addCart() { + scaToursBooking.addCart(addCart_response); document.getElementById('searchResponse').innerHTML = ""; document.getElementById('tripItems').innerHTML = ""; document.getElementById('totalPrice').innerHTML = ""; + currentTripIdIndex = -1; + tripIds = []; + } + + function addCart_response(cartId, exception) { + if(exception){ + alert(exception.javaStack); + return; + } + currentCartId = cartId + + if (currentTripIdIndex == -1){ + addTrip(); + } + } + + function addTrip() { + scaToursBooking.addTrip(currentCartId, addTrip_response); } - function newTrip_response(tripId, exception) { + function addTrip_response(tripId, exception) { if(exception){ alert(exception.javaStack); return; } - currentTripId = tripId - document.getElementById('tripId').innerHTML = "Trip Reference: " + tripId; + currentTripIdIndex++; + tripIds[currentTripIdIndex] = tripId; + getTripItems(); } - function bookTrip() { - travelBooking.bookTrip(currentTripId); + function checkout() { + scaToursBooking.checkout(currentCartId); document.getElementById('searchResponse').innerHTML = ""; document.getElementById('tripItems').innerHTML = "Thank you for shopping with SCA Tours"; @@ -232,13 +265,15 @@ <input type="button" onClick="addItemsToCart()" value="Add Items"> <br/> <h3>Shopping Cart</h3> - <h3><div id="tripId"></h3> + <h3><div id="cartId"></h3> <div id="tripItems"></div> - <br/> - <div id="totalPrice"></div> - <br/> - <input type="button" onClick="bookTrip()" value="Book"> - <input type="button" onClick="newTrip()" value="Create New Trip"> + <br/> + <h3>Cart Totals</h3> + Total Price: <div id="totalPrice"></div> + <br/> + <input type="button" onClick="addCart()" value="Reset Cart"> + <input type="button" onClick="addTrip()" value="Create New Trip"> + <input type="button" onClick="checkout()" value="Checkout"> </form> </div> |