KobrA2 WebApp Framework. WebService.SOS.ocl context ServiceController::process(request: Request):...
-
Upload
marcia-farmer -
Category
Documents
-
view
217 -
download
1
Transcript of KobrA2 WebApp Framework. WebService.SOS.ocl context ServiceController::process(request: Request):...
KobrA2
WebApp Framework
WebService.SOS.ocl
context ServiceController::process(request: Request): Response
post: let act = mvcAction->any(e | e.name =
request.get('action').value) in result = act.do(request)
WebService.SOT.oclcontext Response::write(value: String)post: responseBody = [email protected](value)
context StringDictionary::get(key: String):Stringpost: result = attribute->any(e | e.key = key).value
context StringDictionary::set(key: String, value:String):Stringpost: result = attribute@pre->any(e | e.key = key).value
and attribute->select(e | e.key = key)->size() > 0 and attribute->select(e | e.key = key).value = value
context StringDictionary::remove(key: String):Stringpost: result = attribute@pre->any(e | e.key = key).value
and attribute->select(e | e.key = key)->size() = 0
WebService.ROS.ocl
context WebService::process(request: Resquest):Response
post: result = serviceController.process(request)
ServiceController.SOS.ocl
context ServiceController::process(request: Request): Response
post: let act = mvcAction->any(e | e.name =
request.get('action').value) in result = act.do(request)
MVCModel.SOT.oclcontext ModelEntity::all():Sequence(ModelEntity)post:result = entity
context ModelEntity::put():ModelEntitypost: models->includes(self)
context ModelEntity::delete():ModelEntitypost: models->excludes(self)
context ModelEntity::get(eid : String):ModelEntitypost: result = models->select(e | e.id = eid)
KobrA2
PhotoAlbum as instance of WebApp Framework
AddComment.SOS-- do() simply calls addComment() method of PhotoManagercontext AddComment::do(request:Request):Response
post: let id:Integer = K2Library.createFromString(Integer, request.attribute-
>any( a:Attribute | a.key = 'photoId').value), us: String = request.attribute->any(a:Attribute | a.key =
'userName'), text:String = request.attribute->any(a:Attribute | a.key = 'text'), date: Timestamp = K2Library.createFromString(Timestamp,
request.attribute->any( a:Attribute | a.key = 'date').value) in PhotoManager^addComment(id,us,date,text)
AddPhoto.SOS
-- do() simply calls addPhoto() method of PhotoManagercontext AddPhotos::do(request:Request):Responsepost: let photo:Photo = Photo.createFromString(request.attribute-
>any( a:Attribute | a.key = 'photo').value) inPhotoManager.addPhoto(photo)
ListPhotos.SOS
-- do() simply calls getAllPhotos() method of PhotoManagercontext ListPhotos::do(request:Request):Responsepost: let photos:Sequence(Photo) =
PhotoManager.getAllPhotos() inresult.oclAsType(Response).write(K2Library.convertToStrin
g(Sequence(Photo), photos)) andresult.header.kind = HeaderKind::contentType andresult.header.value = 'binary/octet-stream'
PhotoManager.SOS (1/3)-- retrieve all photoscontext PhotoManager::getAllPhotos():Sequence(Photo)post: result = photos
-- add a photocontext PhotoManager::addPhoto(photo:Photo)pre: not photos->includes( photo) post: photos = photos@pre->including(photo)
-- updates a photo's informations (ex. name, description)context PhotoManager::updatePhoto(photo:Photo)pre: self.photos->exists( e:Photo | e.id = photo.id)post: self.photos->any( e:Photo | e.name = photo.name).data = photo.data and self.photos->any( e:Photo | e.name = photo.name).description = photo.description
PhotoManager.SOS (2/3)-- add a comment to a photo - Breno's versioncontext PhotoManager::addComment(id:Integer, us:String, c:String, data:Timestamp)pre: self.photos->exists( e:Photo | e.id = photo.id)post: let comment:Comment and comment.oclIsNew() and comment.userName = us and comment.date = data and comment.text = s in self.photos->any( e:Photo | e.id = id).comment->includes(comment)
-- add a comment to a photo - Ramon's versioncontext PhotoManager::addComment(photoId:Integer, userName:String, date:Timestamp, text:String)pre: self.photos->exists( e:Photo | e.id = photo.id)post: let photo:Photo = self.photos->any( e:Photo | e.photoId = photoId), c:Comment in c.oclIsNew() and c.userName = userName and c.date = date and c.text = text and photo.comments->includes(c) and photo.comments->size() = photo.comments@pre->size() + 1
PhotoManager.SOS (3/3) -- completely removes a photocontext PhotoManager::removePhoto(photo:Photo)pre: self.photos->exists( e:Photo | e.id = photo.id) post: self.photos->size() = self.photos@pre->size() - 1 and self.photos->excludes(photo)
OkButtonActionEvent.SOS
context OkButtonActionEvent::actionPerformed()
pre: source.name = 'btOk'post: let window = self.getWindow() in window^close()
PAWindowEvent.SOScontext PhViewWindowEvent::opened()pre: source.name = 'PhotoView'post: let elements = source.getNestedElements(), cell = elements->select(oclIsKindOf(GridCell))->any(c | c.photoImage.isSelected), ind = cell.position.x * 2 + cell.position.y + 1 in rq:Request and rq.oclIsNew() and rq.set('action', 'GetPhoto') and rq.set('id', ind) and ph = Photo.createFromString(PhotoAlbumWebService^process(rq).responseBody) and ev.photoImage = ph.data and ev.title = ph.description and ph->comment->forAll(c |
ev.comments.text.concat(c.username).concat(‘:').concat(c.text).concat('/n'))
context PAWindowEvent::closed()pre: source.name = 'ImageChooser'post: source.confirmDialog implies ph:Photo and ph.oclIsNew() and ph.data = Image.fromFile(source.file).content and ph.description = 'Enter your description here' and rq:Request and rq.oclIsNew() and rq.set('action', 'AddPhoto') and rq.set('photo',
Photo.convertToString(ph)) and PhotoAlbumWebService^process(rq)
RemoveButtonAction.SOS
context RemoveButtonActionEvent::actionPerformed()pre: source.name = 'removePhotoBt'post: let elements =
source.getWindow().getNestedElements(), cell = elements->select(oclIsKindOf(GridCell))->any(c |
c.photoImage.isSelected), ind = cell.position.x * 2 + cell.position.y + 1 in rq:Request and rq.oclIsNew() and rq.set('action',
'DeletePhoto') and rq.set('photoId', ind) and PhotoAlbumWebService^process(rq)
SendButtonActionEvent.SOScontext SendButtonActionEvent::actionPerformed()pre: source.name = 'sendBt'post: let elements = source.getWindow().getNestedElements(), cell = elements->select(oclIsKindOf(GridCell))->any(c |
c.photoImage.isSelected), ind = cell.position.x * 2 + cell.position.y + 1, nm = elements->select(oclIsKindOf(TextField))->any(c | c.name =
'nameField').text, tx = elements->select(oclIsKindOf(TextArea)->any(c | c.name =
'messageField').text in rq:Request and rq.oclIsNew() and rq.set('action', 'AddComment') and
rq.set('photoId', ind) and rq.set('userName', nm) and rq.set('text', tx) and rq.set('date', Date.now)
and PhotoAlbumWebService^process(rq)
Resources• KobrA2 Specification - 2009-03-13 out-kobra-mm.pdf
• KobrA2 Models on Google Project Hosting - http://code.google.com/p/kobra2/
• Kobra2MM (RSM)- http://kobra2.googlecode.com/svn/trunk/workspace/KobrA2MM
• WebApp Model (RSM) – http:// kobra2.googlecode.com/svn/trunk/workspace/WebApp
• GUI-PIM-UF (RSM) – http:// kobra2.googlecode.com/svn/trunk/workspace/GUI-
PIM-UF
Resources• KobrA2 Specification - 2009-03-13 out-kobra-mm.pdf
• KobrA2 Models on Google Project Hosting - http://code.google.com/p/kobra2/
• Kobra2MM (RSM)- http://kobra2.googlecode.com/svn/trunk/workspace/KobrA2MM
• WebApp Model (RSM) – http:// kobra2.googlecode.com/svn/trunk/workspace/WebApp
• PhotoAlbum Model (RSM) – http://
kobra2.googlecode.com/svn/trunk/workspace/PhotoAlbum
• GUI-PIM-UF (RSM) – http:// kobra2.googlecode.com/svn/trunk/workspace/GUI-
PIM-UF