From 5842f30c2abd2ca2b296257910b48c0c1b3567a8 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Mon, 2 May 2011 05:58:59 +0000 Subject: Change app data model a bit. Store app properties in separate files and support app cloning. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1098491 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/edit/apps.py | 48 ++++++++---------- sca-cpp/trunk/modules/edit/apps/me360/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/nearme/app.stats | 1 + .../trunk/modules/edit/apps/ourphotos/app.stats | 1 + .../trunk/modules/edit/apps/shoppingcart/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/slice/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/test/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/testdb/app.stats | 1 + .../trunk/modules/edit/apps/testevents/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/testhttp/app.stats | 1 + .../trunk/modules/edit/apps/testlogic/app.stats | 1 + .../trunk/modules/edit/apps/testsearch/app.stats | 1 + .../trunk/modules/edit/apps/testsocial/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/testtext/app.stats | 1 + sca-cpp/trunk/modules/edit/apps/testurl/app.stats | 1 + .../trunk/modules/edit/apps/testvalues/app.stats | 1 + .../trunk/modules/edit/apps/testwidgets/app.stats | 1 + .../trunk/modules/edit/apps/testwidgets2/app.stats | 1 + sca-cpp/trunk/modules/edit/composites.py | 44 +++++++++++++++++ sca-cpp/trunk/modules/edit/dashboard.py | 25 +++++----- sca-cpp/trunk/modules/edit/edit.composite | 57 +++++++++++++++++----- sca-cpp/trunk/modules/edit/log.py | 2 +- sca-cpp/trunk/modules/edit/pages.py | 12 +---- sca-cpp/trunk/modules/edit/palettes.py | 2 - sca-cpp/trunk/modules/edit/store.py | 11 ----- 25 files changed, 140 insertions(+), 78 deletions(-) create mode 100644 sca-cpp/trunk/modules/edit/apps/me360/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/nearme/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/ourphotos/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/shoppingcart/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/slice/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/test/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testdb/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testevents/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testhttp/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testlogic/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testsearch/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testsocial/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testtext/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testurl/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testvalues/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testwidgets/app.stats create mode 100644 sca-cpp/trunk/modules/edit/apps/testwidgets2/app.stats create mode 100644 sca-cpp/trunk/modules/edit/composites.py (limited to 'sca-cpp') diff --git a/sca-cpp/trunk/modules/edit/apps.py b/sca-cpp/trunk/modules/edit/apps.py index 4add10a239..a820f969cb 100644 --- a/sca-cpp/trunk/modules/edit/apps.py +++ b/sca-cpp/trunk/modules/edit/apps.py @@ -15,15 +15,13 @@ # specific language governing permissions and limitations # under the License. -# Apps collection implementation -import uuid -import sys +# App collection implementation import os from util import * # Convert an id to an app id def appid(id): - return ("'" + car(id), "'app.composite") + return ("'" + car(id), "'app.stats") # Link implementation resources into an app def mkapplink(id): @@ -31,45 +29,41 @@ def mkapplink(id): os.symlink('../../../../../nuvem/nuvem-parallel/nuvem', 'apps/' + car(id) + '/nuvem') os.symlink('../../../../components', 'apps/' + car(id) + '/lib') os.mkdir('apps/' + car(id) + '/htdocs') - os.symlink('../../../htdocs/cache-manifest.cmf', 'apps/' + car(id) + '/htdocs/cache-manifest.cmf'); - os.symlink('../../../htdocs/login', 'apps/' + car(id) + '/htdocs/login'); - os.symlink('../../../htdocs/logout', 'apps/' + car(id) + '/htdocs/logout'); - os.symlink('../../../htdocs/public', 'apps/' + car(id) + '/htdocs/public'); - os.symlink('../../../htdocs/data', 'apps/' + car(id) + '/htdocs/data'); - os.symlink('../../../htdocs/app/index.html', 'apps/' + car(id) + '/htdocs/index.html'); - os.symlink('../../../htdocs/robots.txt', 'apps/' + car(id) + '/htdocs/robots.txt'); - os.symlink('../../../htdocs/favicon.ico', 'apps/' + car(id) + '/htdocs/favicon.ico'); - os.symlink('../app.html', 'apps/' + car(id) + '/htdocs/app.html'); except: pass return True -# Post a new app to the apps db -def post(collection, app, cache): - id = appid((str(uuid.uuid1()),)) - comp = cdr(cadddr(car(app))) - cache.put((id,), comp) - mkapplink((id,)) - return id - # Put an app into the apps db -def put(id, app, cache): - comp = cdr(cadddr(car(app))) - cache.put(appid(id), comp) +def put(id, app, cache, store, composites, pages): + eid = cadr(caddr(car(app))) + appentry = (("'entry", cadr(car(app)), ("'id", car(id))),) + + # Update app in apps db + if car(id) == eid: + cache.put(appid(id), appentry) + mkapplink(id) + return True + + # Clone an app's composite and page + cache.put(appid(id), appentry) mkapplink(id) + composites.put(id, composites.get((eid,))) + pages.put(id, pages.get((eid,))) return True # Get an app from the apps db -def get(id, cache): +def get(id, cache, store, composites, pages): if isNil(id): return (("'feed", ("'title", "Apps"), ("'id", "apps")),) app = cache.get(appid(id)); if (isNil(app) or app is None): return (("'entry", ("'title", car(id)), ("'id", car(id))),) - return (("'entry", ("'title", car(id)), ("'id", car(id)), ("'content", car(app))),) + return app # Delete an app from the apps db -def delete(id, cache): +def delete(id, cache, store, composites, pages): cache.delete(appid(id)) + composites.delete(id) + pages.delete(id) return True diff --git a/sca-cpp/trunk/modules/edit/apps/me360/app.stats b/sca-cpp/trunk/modules/edit/apps/me360/app.stats new file mode 100644 index 0000000000..a46c727280 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/me360/app.stats @@ -0,0 +1 @@ +((entry (title "Check my public social data") (id "me360"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/nearme/app.stats b/sca-cpp/trunk/modules/edit/apps/nearme/app.stats new file mode 100644 index 0000000000..b2f5c5ea79 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/nearme/app.stats @@ -0,0 +1 @@ +((entry (title "Where are my friends") (id "nearme"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/ourphotos/app.stats b/sca-cpp/trunk/modules/edit/apps/ourphotos/app.stats new file mode 100644 index 0000000000..e685d930dd --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/ourphotos/app.stats @@ -0,0 +1 @@ +((entry (title "Our photos of an event") (id "ourphotos"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/shoppingcart/app.stats b/sca-cpp/trunk/modules/edit/apps/shoppingcart/app.stats new file mode 100644 index 0000000000..4529005b54 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/shoppingcart/app.stats @@ -0,0 +1 @@ +((entry (title "My online store") (id "shoppingcart"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/slice/app.stats b/sca-cpp/trunk/modules/edit/apps/slice/app.stats new file mode 100644 index 0000000000..96700a9085 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/slice/app.stats @@ -0,0 +1 @@ +((entry (title "Slice") (id "slice"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/test/app.stats b/sca-cpp/trunk/modules/edit/apps/test/app.stats new file mode 100644 index 0000000000..9adad8c1a6 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/test/app.stats @@ -0,0 +1 @@ +((entry (title "An empty test app") (id "test"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testdb/app.stats b/sca-cpp/trunk/modules/edit/apps/testdb/app.stats new file mode 100644 index 0000000000..1128933dfd --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testdb/app.stats @@ -0,0 +1 @@ +((entry (title "Test database components") (id "testdb"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testevents/app.stats b/sca-cpp/trunk/modules/edit/apps/testevents/app.stats new file mode 100644 index 0000000000..51d6a0388e --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testevents/app.stats @@ -0,0 +1 @@ +((entry (title "Test event components") (id "testevents"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testhttp/app.stats b/sca-cpp/trunk/modules/edit/apps/testhttp/app.stats new file mode 100644 index 0000000000..be1fc6d254 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testhttp/app.stats @@ -0,0 +1 @@ +((entry (title "Test HTTP components") (id "testhttp"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testlogic/app.stats b/sca-cpp/trunk/modules/edit/apps/testlogic/app.stats new file mode 100644 index 0000000000..e557346327 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testlogic/app.stats @@ -0,0 +1 @@ +((entry (title "Test logic components") (id "testlogic"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testsearch/app.stats b/sca-cpp/trunk/modules/edit/apps/testsearch/app.stats new file mode 100644 index 0000000000..691c43875d --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testsearch/app.stats @@ -0,0 +1 @@ +((entry (title "Test search components") (id "testsearch"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testsocial/app.stats b/sca-cpp/trunk/modules/edit/apps/testsocial/app.stats new file mode 100644 index 0000000000..fa487f4d81 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testsocial/app.stats @@ -0,0 +1 @@ +((entry (title "Test social components") (id "testsocial"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testtext/app.stats b/sca-cpp/trunk/modules/edit/apps/testtext/app.stats new file mode 100644 index 0000000000..35e43ff383 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testtext/app.stats @@ -0,0 +1 @@ +((entry (title "Test text processing components") (id "testtext"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testurl/app.stats b/sca-cpp/trunk/modules/edit/apps/testurl/app.stats new file mode 100644 index 0000000000..b4142f40cf --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testurl/app.stats @@ -0,0 +1 @@ +((entry (title "Test URL components") (id "testurl"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testvalues/app.stats b/sca-cpp/trunk/modules/edit/apps/testvalues/app.stats new file mode 100644 index 0000000000..4b7a09cd38 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testvalues/app.stats @@ -0,0 +1 @@ +((entry (title "Test values and lists") (id "testvalues"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testwidgets/app.stats b/sca-cpp/trunk/modules/edit/apps/testwidgets/app.stats new file mode 100644 index 0000000000..6a66748ab1 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testwidgets/app.stats @@ -0,0 +1 @@ +((entry (title "Test widgets") (id "testwidgets"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/apps/testwidgets2/app.stats b/sca-cpp/trunk/modules/edit/apps/testwidgets2/app.stats new file mode 100644 index 0000000000..18f0cb50f8 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/apps/testwidgets2/app.stats @@ -0,0 +1 @@ +((entry (title "Test more widgets") (id "testwidgets2"))) \ No newline at end of file diff --git a/sca-cpp/trunk/modules/edit/composites.py b/sca-cpp/trunk/modules/edit/composites.py new file mode 100644 index 0000000000..7eb8593d18 --- /dev/null +++ b/sca-cpp/trunk/modules/edit/composites.py @@ -0,0 +1,44 @@ +# 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. + +# App composites collection implementation +from util import * + +# Convert an id to an app id +def appid(id): + return ("'" + car(id), "'app.composite") + +# Put an app into the apps db +def put(id, app, cache): + comp = cdr(cadddr(car(app))) + cache.put(appid(id), comp) + return True + +# Get an app from the apps db +def get(id, cache): + if isNil(id): + return (("'feed", ("'title", "Composites"), ("'id", "composites")),) + app = cache.get(appid(id)); + if (isNil(app) or app is None): + return (("'entry", ("'title", car(id)), ("'id", car(id))),) + return (("'entry", ("'title", car(id)), ("'id", car(id)), ("'content", car(app))),) + +# Delete an app from the apps db +def delete(id, cache): + cache.delete(appid(id)) + return True + diff --git a/sca-cpp/trunk/modules/edit/dashboard.py b/sca-cpp/trunk/modules/edit/dashboard.py index 4dd48ccc17..81ec447d10 100644 --- a/sca-cpp/trunk/modules/edit/dashboard.py +++ b/sca-cpp/trunk/modules/edit/dashboard.py @@ -16,8 +16,6 @@ # under the License. # Dashboards collection implementation -import uuid -import sys from util import * # Convert a particular user email to a dashboard id @@ -31,16 +29,8 @@ def getdashboard(id, cache): return () return dashboard -# Post a new app to the user's dashboard -def post(collection, app, user, cache): - id = (str(uuid.uuid1()),) - newapp = list("'entry", cadr(car(app)), list("'id", id), cadddr(car(app))) - dashboard = cons(newapp, getdashboard(dashboardid(user), cache)) - cache.put(dashboardid(user), dashboard) - return id - # Put an app into the user's dashboard -def put(id, app, user, cache): +def put(id, app, user, cache, apps): def putapp(app, dashboard): if isNil(dashboard): return app @@ -48,12 +38,16 @@ def put(id, app, user, cache): return cons(car(app), cdr(dashboard)) return cons(car(dashboard), putapp(app, cdr(dashboard))) - dashboard = putapp(app, getdashboard(dashboardid(user), cache)) + appentry = (("'entry", cadr(car(app)), ("'id", car(id))),) + dashboard = putapp(appentry, getdashboard(dashboardid(user), cache)) cache.put(dashboardid(user), dashboard) + + # Update app in app repository + apps.put(id, app); return True # Get apps from the user's dashboard -def get(id, user, cache): +def get(id, user, cache, apps): def findapp(id, dashboard): if isNil(dashboard): return None @@ -66,7 +60,7 @@ def get(id, user, cache): return findapp(id, getdashboard(dashboardid(user), cache)) # Delete apps from the user's dashboard -def delete(id, user, cache): +def delete(id, user, cache, apps): if isNil(id): return cache.delete(dashboardid(user)) @@ -79,5 +73,8 @@ def delete(id, user, cache): dashboard = deleteapp(id, getdashboard(dashboardid(user), cache)) cache.put(dashboardid(user), dashboard) + + # Delete app from app repository + apps.delete(id); return True diff --git a/sca-cpp/trunk/modules/edit/edit.composite b/sca-cpp/trunk/modules/edit/edit.composite index a7230296c2..c13c2ccc32 100644 --- a/sca-cpp/trunk/modules/edit/edit.composite +++ b/sca-cpp/trunk/modules/edit/edit.composite @@ -44,9 +44,10 @@ + - + @@ -58,6 +59,7 @@ + @@ -74,6 +76,17 @@ + + + + + + + + + + + @@ -81,7 +94,7 @@ - + @@ -89,7 +102,7 @@ - + @@ -146,29 +159,49 @@ apps - xml + scheme - + + + + + + + + + + + + + + apps + xml + + + + + + - - + + - - + + - + palettes xml - - + + diff --git a/sca-cpp/trunk/modules/edit/log.py b/sca-cpp/trunk/modules/edit/log.py index 0b13569c2d..d316831db6 100644 --- a/sca-cpp/trunk/modules/edit/log.py +++ b/sca-cpp/trunk/modules/edit/log.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -# User info service component +# Log service component from sys import stderr # Log a message diff --git a/sca-cpp/trunk/modules/edit/pages.py b/sca-cpp/trunk/modules/edit/pages.py index 1fe475b67e..aa84f40162 100644 --- a/sca-cpp/trunk/modules/edit/pages.py +++ b/sca-cpp/trunk/modules/edit/pages.py @@ -16,21 +16,11 @@ # under the License. # App pages collection implementation -import uuid -import sys -from sys import stderr from util import * # Convert an id to an app id def appid(id): - return ("'" + car(id), "'app.html") - -# Post a new app page to the apps db -def post(collection, app, cache): - id = appid((str(uuid.uuid1()),)) - xhtml = cdr(cadddr(car(app))) - cache.put((id,), xhtml) - return id + return ("'" + car(id), "'htdocs", "'app.html") # Put an app page into the apps db def put(id, app, cache): diff --git a/sca-cpp/trunk/modules/edit/palettes.py b/sca-cpp/trunk/modules/edit/palettes.py index 7872bb3db7..abe28a3364 100644 --- a/sca-cpp/trunk/modules/edit/palettes.py +++ b/sca-cpp/trunk/modules/edit/palettes.py @@ -16,8 +16,6 @@ # under the License. # Palettes collection implementation -import uuid -import sys from util import * # Convert an id to a palette id diff --git a/sca-cpp/trunk/modules/edit/store.py b/sca-cpp/trunk/modules/edit/store.py index 052605d2d6..9598cdf7fa 100644 --- a/sca-cpp/trunk/modules/edit/store.py +++ b/sca-cpp/trunk/modules/edit/store.py @@ -16,8 +16,6 @@ # under the License. # stores collection implementation -import uuid -import sys from util import * # Convert a particular store tag to a store id @@ -31,15 +29,6 @@ def getstore(id, cache): return () return store -# Post a new app to a store -def post(collection, app, cache): - tag = car(collection) - id = (str(uuid.uuid1()),) - newapp = list("'entry", cadr(car(app)), list("'id", id), cadddr(car(app))) - store = cons(newapp, getstore(storeid(tag), cache)) - cache.put(storeid(tag), store) - return id - # Put an app into a store def put(key, app, cache): def putapp(app, store): -- cgit v1.2.3