summaryrefslogtreecommitdiffstats
path: root/sandbox/sca-cloud-tutorial/store-appengine-webapp/war
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:00 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-10-23 17:56:00 +0000
commita6e0a1a959b837f1441de68e070f53dee9e35a55 (patch)
treecc0a0d394b0df259c43c7b3001a48bd3ed4e67c1 /sandbox/sca-cloud-tutorial/store-appengine-webapp/war
parentf60bcd37dc61721f97fd2f3f99c62c16e0125513 (diff)
Updating store with new vegetables catalog and adding basic support for shoppingCart services using JSON-RPC
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@829149 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml20
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties35
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml18
-rw-r--r--sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html108
4 files changed, 162 insertions, 19 deletions
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
index 2e265231e9..6c83c9666b 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/appengine-web.xml
@@ -1,7 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * 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.
+-->
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>tuscany-store</application>
- <version>1</version>
+ <version>3</version>
<!-- Configure java.util.logging -->
<system-properties>
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
index 411c7f2003..03808336ec 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/logging.properties
@@ -1,3 +1,23 @@
+#
+#
+# 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.
+#
+#
# A default java.util.logging configuration.
# (All App Engine logging is through java.util.logging by default).
#
@@ -12,21 +32,6 @@
# Set the default logging level for all loggers to WARNING
.level = WARNING
-# Set the default logging level for ORM, specifically, to WARNING
-DataNucleus.JDO.level=WARNING
-DataNucleus.Persistence.level=WARNING
-DataNucleus.Cache.level=WARNING
-DataNucleus.MetaData.level=WARNING
-DataNucleus.General.level=WARNING
-DataNucleus.Utility.level=WARNING
-DataNucleus.Transaction.level=WARNING
-DataNucleus.Datastore.level=WARNING
-DataNucleus.ClassLoading.level=WARNING
-DataNucleus.Plugin.level=WARNING
-DataNucleus.ValueGeneration.level=WARNING
-DataNucleus.Enhancer.level=WARNING
-DataNucleus.SchemaTool.level=WARNING
-
#tuscany debug messages
org.apache.tuscany.level=WARNING
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
index 31ad8abe98..31fc39a160 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/WEB-INF/web.xml
@@ -1,4 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
diff --git a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
index cd9cff53a9..2fc5fcc434 100644
--- a/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
+++ b/sandbox/sca-cloud-tutorial/store-appengine-webapp/war/store.html
@@ -1,6 +1,25 @@
+<!--
+ * 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.
+-->
<html>
<head>
-<title>Store</title>
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+<title>Online Store - Powered by Apache Tuscany</title>
<script type="text/javascript" src="dojo/dojo/dojo.js"></script>
@@ -11,6 +30,10 @@
<script language="JavaScript">
var catalog = new dojo.rpc.JsonService("/catalogAggregator?smd");
+
+ var shoppingCart = new dojo.rpc.JsonService("/shoppingCart/Cart?smd");
+
+ var shoppingTotal = new dojo.rpc.JsonService("/shoppingCart/Total?smd");
var catalogItems;
@@ -25,9 +48,76 @@
catalogItems = items;
}
+ // This handles the response from shoppingCart.getAll
+ // which is a collection of Entry<K,D>
+ function shoppingCart_getResponse(items) {
+ var list='';
+ for (var i=0; i<items.length; i++) {
+ //get the actual item, that is Entry.data
+ var item = items[i].data;
+ // process its attributes
+ var name = item.name;
+ var price = item.price
+ list += name + ' - ' + price + ' <br>';
+ }
+ document.getElementById("shoppingCart").innerHTML = list;
+
+ if (items.length != 0) {
+ try {
+ shoppingTotal.getTotal().addCallback(shoppingTotal_getTotalResponse);
+ }
+ catch(e){
+ alert(e);
+ }
+ }
+ }
+
+ function shoppingTotal_getTotalResponse(total,exception) {
+ if(exception) {
+ alert(exception.message);
+ return;
+ }
+ document.getElementById('total').innerHTML = total;
+ }
+
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.getAll().addCallback(shoppingCart_getResponse);
+ }
+
+ function addToCart() {
+ var items = document.catalogForm.items;
+ var j = 0;
+ for (var i=0; i<items.length; i++)
+ if (items[i].checked) {
+ shoppingCart.post("", catalogItems[i]).addCallback(shoppingCart_postResponse);
+ items[i].checked = false;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='<h2>' +
+ 'Thanks for Shopping With Us!</h2>'+
+ '<h2>Your Order</h2>'+
+ '<form name="orderForm">'+
+ document.getElementById('shoppingCart').innerHTML+
+ '<br>'+
+ document.getElementById('total').innerHTML+
+ '<br>'+
+ '<br>'+
+ '<input type="submit" value="Continue Shopping">'+
+ '</form>';
+ shoppingCart.del("");
+ }
+ function deleteCart() {
+ shoppingCart.del("");
+ document.getElementById('shoppingCart').innerHTML = "";
+ document.getElementById('total').innerHTML = "";
+ }
+
+
function init() {
try {
catalog.get().addCallback(catalog_getResponse);
+ shoppingCart.get("").addCallback(shoppingCart_getResponse);
} catch (e) {
alert(e);
}
@@ -44,10 +134,22 @@
<h2>Catalog</h2>
<form name="catalogForm">
<div id="catalog" ></div>
- <br>
+ <br>
+ <input type="button" onClick="addToCart()" value="Add to Cart">
</form>
- <br>
+
+ <br>
+
+ <h2>Your Shopping Cart</h2>
+ <form name="shoppingCartForm">
+ <div id="shoppingCart"></div>
+ <br>
+ <div id="total"></div>
+ <br>
+ <input type="button" onClick="checkoutCart()" value="Checkout">
+ <input type="button" onClick="deleteCart()" value="Empty">
+ </form>
</div>
</body>
</html>